RobotStudio event

keep part where it is after detachment

Hi:


I use Part.Detach() command to detach a part from a mechanism. However, the part always goes back to its original position instead of where it is carried by the mechanism to when it is detached.
Can I somehow keep the part where it is after detachment?
Thanks,
Sam

Comments

  • Hi
    You need to record the position before you detach and the apply it to your part.
    Something like this
    // prt is the part you want to attach
    //mech is what you attach the part to (in this case a robot)
    Matrix4 pos = prt.Transform.GlobalMatrix;
    mech.GetFlanges()[0].Detach(prt);
    prt.Transform.GlobalMatrix = pos;

    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering
  • Thanks again, Per.

    Sam

  • Hi,
    How can I attach an object to a  mechanism with an offset to the flange, i.e. I am using 

    mech.GetFlanges()[0].Attach(prt,true);

    Do I use the transform?

     

    Shane 

  • I have figured out how to move the flange but when I attach the part it attaches to the original flange coordinates.
     
    mech.GetFlanges()[0].GetFrame().Transform.Y = mech.GetFlanges()[0].GetFrame().Transform.Y + 1;
    mech.GetFlanges()[0].Attach(prt,
    true);
     

    Any thoughts?
  • Basically it works like this

    When you attach something for example a part to a robot mechanism it will use the part's coordinate system. So if you want to have offset you need to move the body's in the part relative to the part to get an offset.
    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering
  • Alternatively, put the part in a GraphicComponentGroup, offset the part, and attach the group instead.

    I'm not sure why Flange.Attach() doesn't have an offset parameter, it's probably something we should fix in the future..


    Johannes Weiman
    Software Engineer
    ABB Robotics