VSTA - Dimension of objects
apox
✭✭
in RobotStudio
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.
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.
0
Comments
-
Hi apox,
Unfortunately the GetBoundingBox() method is badly declared in 5.08, which means it's not compatible with VSTA.
regards,
Johannes
Johannes Weiman
Software Engineer
ABB Robotics0 -
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
0 -
Hi Matthias
you need to do it like this
part.GetBoundingBox(true,out min,out max);
Per Svensson
Robotics and Vision Specialist
Consat Engineering0 -
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
0 -
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);Per Svensson
Robotics and Vision Specialist
Consat Engineering0 -
Ah, now I got it.
I didn't add the part to the station before calling GetBoundingBox(..)
Shure it didn't work...
0 -
Additional question: How do I get a boundingBox of the complete robot?
0 -
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()));
}
0 -
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.
MaWi812008-4-16 11:42:290 -
The Mechanism class also supports GetBoundingBox() since it inherits GraphicComponent
Johannes Weiman
Software Engineer
ABB Robotics0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings