RobotStudio event

VSTA - Dimension of objects

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.



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 Robotics
  • 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

  • Hi Matthias
    you need to do it like this
    part.GetBoundingBox(true,out min,out max);
    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering
  • 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

  • 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 Engineering
  • Ah, now I got it.
    I didn't add the part to the station before calling GetBoundingBox(..) image
    Shure it didn't work...

  • Additional question: How do I get a boundingBox of the complete robot?
  • apox
    apox ✭✭
    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()));
            }

  • 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:29
  • The Mechanism class also supports GetBoundingBox() since it inherits GraphicComponent image



    Johannes Weiman
    Software Engineer
    ABB Robotics