RobotStudio event

Origin of joined body

I create a wire from (0,0,0) to (50,0,0) then set its position to (20,20,20), then I extrude a face from the wire using Body.Extrude(Wire, Vector3, Wire, SweepOptions).

I then add the face to a new part located at 0,0,0 and add the part to  station.GraphicComponents.

The face is then displayed as expected, adjoining the wire.

image

image

I repeat the exercise, but extrude two faces from the wire in opposite directions by using different vectors.

I then join the two faces using the Body.Join(Body) method to create a new face.

I add the new face to a new part located at 0,0,0 and add the part to  station.GraphicComponents as before.

The new face is not displayed adjacent to the wire, but translated from it by the same amount that the wire was moved from its original position.

image

I would have expected the joined face to have its origin at 0,0,0 so that when added to the part located at 0,0,0 it would be displayed adjacent to the wire.

What have I not understood about the origin used by the Body.Join(Body) method, and what must I do to get the joined face displayed at the same location as the wire?

Thanks,

Kevin




Comments

  • Hi Kevin,
     

    based on your despcription I wrote some code that I think is similar to yours, and I got the same result.

     

    In order to make it work the extruded bodies must be added to the same part before performing the join operation. When this is done they will share the same origin. Sooner or later you probably want to add the joined body to a part, so you can add the intermediate bodies to this part. If that is not desirable you can create a new "dummy" part in order to host the bodies, and you dont have to add this part to the station.

     

    Here is an example that first creates a part "p", where the extruded bodies are added, and another part "p2" wherre the final joined body is added. "p2" is added to the station.

     

     

    [CODE]


    Station
    s = Project.ActiveProject as Station;
    Body wireBody = Body.CreateLine(new Vector3(0, 0, 0), new Vector3(0.5, 0, 0));
    Part p = new Part();
    wireBody.Transform.GlobalMatrix =
    new Matrix4(new Vector3(0.2 ,0.2, 0.2));
    p.Bodies.Add(wireBody);

    Wire wire = wireBody.Shells[0].Wires[0];
    SweepOptions sweepOptions = new SweepOptions();
    sweepOptions.MakeSolid =
    false;
    Body[] extrudedBodies1 = Body.Extrude(wire, new Vector3(0, 0, 1), null, sweepOptions);
    Body[] extrudedBodies2 = Body.Extrude(wire, new Vector3(0, 1, 0), null, sweepOptions);


    p.Bodies.Add(extrudedBodies1[0]);
    p.Bodies.Add(extrudedBodies2[0]);

    Body[] joinedBodies = extrudedBodies2[0].Join(extrudedBodies1[0]);

     
    Part p2 = new Part();

    p2.Bodies.Add(wireBody);
    extrudedBodies1[0].Opacity = 0.5;
    extrudedBodies2[0].Opacity = 0.5;
    p2.Bodies.Add(extrudedBodies1[0]);
    p2.Bodies.Add(extrudedBodies2[0]);
    p2.Bodies.Add(joinedBodies[0]);
    s.GraphicComponents.Add(p2);

    [/CODE]

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • Kevin
    Kevin ✭✭
    That solved the problem.

    Many thanks Niklas.

    Kevin