# VSTA - Dimension of objects

**URL:** <https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199>\
**Category:** RobotStudio\
**Created:** [May 10, 2007, 11:36am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199 "2007-05-10T11:36:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![apox](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/apox/32/2392_2.png) [@apox](https://tech-community.robotics.abb.com/u/apox)\
**Post date:** [May 10, 2007, 11:36am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/1 "2007-05-10T11:36:36Z")

</div>

Hi,

i would like to get the dimension of current working objects or objects that are selected. I found the GetBoundingBox method but have problems to use it.

---

<div class="post-metadata">

**Author:** ![Johannes\_Weiman\_old\_account](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/johannes_weiman_old_account/32/3345_2.png) [@Johannes\_Weiman\_old\_account](https://tech-community.robotics.abb.com/u/Johannes_Weiman_old_account)\
**Post date:** [May 10, 2007, 3:59pm UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/2 "2007-05-10T15:59:37Z")

</div>

Hi apox,

Unfortunately the GetBoundingBox() method is badly declared in 5.08, which means it’s not compatible with VSTA.

regards,  
Johannes

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [November 27, 2007, 1:02am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/3 "2007-11-27T01:02:16Z")

</div>

Does the GetBoundingBox() method work correctly in 5.09?

The following code creates a runtime error:  
Part part = Part.Load(“path to cad file”);  
Vector3 min = new Vector3();  
Vector3 max = new Vector3();  
part.GetBoundingBox(true, min, max);

Is there a mistake in the code?

best regards, Matthias

---

<div class="post-metadata">

**Author:** ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)\
**Post date:** [November 27, 2007, 8:19am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/4 "2007-11-27T08:19:59Z")

</div>

Hi Matthias  
you need to do it like this  
part.GetBoundingBox(true,out min,out max);

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [November 27, 2007, 9:48am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/5 "2007-11-27T09:48:14Z")

</div>

Hi!  
Thanks for your response.  
I have part.GetBoundingBox(true, out min, out max) in my code.  
Nevertheless I get a RuntimeError ☹

best regards, Matthias

---

<div class="post-metadata">

**Author:** ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)\
**Post date:** [November 27, 2007, 10:28am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/6 "2007-11-27T10:28:04Z")

</div>

Hmmm  
It works for me, maybe it’s the part that’s wrong.  
If you just create a solid box and reference to that instead  
Something like this

Station stn = Project.ActiveProject as Station;

Part prt = stn.GraphicComponents[“myBox”] as Part;

Vector3 min = new Vector3();

Vector3 max = new Vector3();

prt.GetBoundingBox(true, out min, out max);

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [November 27, 2007, 11:56am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/7 "2007-11-27T11:56:38Z")

</div>

Ah, now I got it.  
I didn’t add the part to the station before calling GetBoundingBox(..) :worried:  
Shure it didn’t work…

---

<div class="post-metadata">

**Author:** ![MaWi81](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@MaWi81](https://tech-community.robotics.abb.com/u/MaWi81)\
**Post date:** [April 16, 2008, 10:17am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/8 "2008-04-16T10:17:17Z")

</div>

Additional question: How do I get a boundingBox of the complete robot?

---

<div class="post-metadata">

**Author:** ![apox](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/apox/32/2392_2.png) [@apox](https://tech-community.robotics.abb.com/u/apox)\
**Post date:** [April 16, 2008, 11:09am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/9 "2008-04-16T11:09:42Z")

</div>

how about this:

public void Macro\_GetRobotBoundingBox()  
{  
// Check that we have an active project  
if (Project.ActiveProject == null) return;

Station station = Project.ActiveProject as Station;  
RsTask task = station.ActiveTask;  
Mechanism mech = task.Mechanism;  
GraphicComponentCollection gc = mech.GraphicComponents;

Vector3 global\_min = new Vector3(Double.MaxValue,Double.MaxValue,Double.MaxValue);  
Vector3 global\_max = new Vector3(Double.MinValue,Double.MinValue,Double.MinValue);

foreach (GraphicComponent \_gc in gc)  
{  
Vector3 min = new Vector3();  
Vector3 max = new Vector3();  
\_gc.GetBoundingBox(true, out min, out max);

if (min.x \< global\_min.x)  
global\_min.x = min.x;  
if (min.y \< global\_min.y)  
global\_min.y = min.y;  
if (min.z \< global\_min.z)  
global\_min.z = min.z;

if (max.x \> global\_max.x)  
global\_max.x = max.x;  
if (max.y \> global\_max.y)  
global\_max.y = max.y;  
if (max.z \> global\_max.z)  
global\_max.z = max.z;  
}  
Logger.AddMessage(new LogMessage(global\_min.ToString() + " / " + global\_max.ToString()));  
}

---

<div class="post-metadata">

**Author:** ![MaWi81](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@MaWi81](https://tech-community.robotics.abb.com/u/MaWi81)\
**Post date:** [April 16, 2008, 11:40am UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/10 "2008-04-16T11:40:22Z")

</div>

Okay this could be a solution.

I thought about a feature of the API that I haven’t found yet. The bounding box that is shown if you select the robot inside the objects view.

---

<div class="post-metadata">

**Author:** ![Johannes\_Weiman\_old\_account](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/johannes_weiman_old_account/32/3345_2.png) [@Johannes\_Weiman\_old\_account](https://tech-community.robotics.abb.com/u/Johannes_Weiman_old_account)\
**Post date:** [April 16, 2008, 2:26pm UTC](https://tech-community.robotics.abb.com/t/vsta-dimension-of-objects/1199/11 "2008-04-16T14:26:26Z")

</div>

The Mechanism class also supports GetBoundingBox() since it inherits GraphicComponent 😉
