RobotStudio event

How to attach a part or tool to the robot

Options
How to attach a part or a tool to the robot?
 Addin program with C#

 

Thanks!

Comments

  • mattdavis
    Options
    this was the example code given in the training course, it attaches things too the tool and attaches peices to a pallet in the station. I have modified it to suit everything i have needed so hopefully it will help you out.


    A?A? A? A? A?public void Macro_DetachAttachTube()
    A?A? A? A? A?{
    A?A? A? A? A? A? A?Station actStn = Project.ActiveProject as Station;
    A?A? A? A? A? A? A?foreach (Attachment at in actStn.Attachments)
    A?A? A? A? A? A? A?{
    A?A? A? A? A? A? A? A? A?if (at.AttachmentParent.Parent.Name == "MyGripper")
    A?A? A? A? A? A? A? A? A?{
    A?A? A? A? A? A? A? A? A? A? A?GraphicComponent gc = at.AttachmentChild as GraphicComponent;
    A?A? A? A? A? A? A? A? A? A? A?Matrix4 matTube = gc.Transform.GlobalMatrix;

    A?A? A? A? A? A? A? A? A? A? A?//find flange
    A?A? A? A? A? A? A? A? A? A? A?Mechanism mech = at.AttachmentParent.Parent as Mechanism;
    A?A? A? A? A? A? A? A? A? A? A?if (mech == null) Logger.AddMessage(new LogMessage("mech null"));
    A?A? A? A? A? A? A? A? A? A? A?mech.GetToolDataInfo()[0].Detach(gc as IAttachableChild);
    A?A? A? A? A? A? A? A? A? A? A?gc.Transform.GlobalMatrix = matTube;
    A?A? A? A? A? A? A? A? A? A? A?IAttachableParent ap = actStn.GraphicComponents["euro_pallet"] as IAttachableParent;
    A?A? A? A? A? A? A? A? A? A? A?if (ap == null) Logger.AddMessage(new LogMessage("no pallet"));
    A?A? A? A? A? A? A? A? A? A? A?ap.Attach(gc as IAttachableChild, false, new Matrix4(new Vector3(0, 0, 0)));
    A?A? A? A? A? A? A? A? A?}
    A?A? A? A? A? A? A?}
    A?A? A? A? A?}


    A?A? A? A? A?public void Macro_DetachFromPallet()
    A?A? A? A? A?{
    A?A? A? A? A? A? A?Station actStn = Project.ActiveProject as Station;
    A?A? A? A? A? A? A?foreach (Attachment at in actStn.Attachments)
    A?A? A? A? A? A? A?{
    A?A? A? A? A? A? A? A? A?if (at.AttachmentParent.Name == "euro_pallet")
    A?A? A? A? A? A? A? A? A?{
    A?A? A? A? A? A? A? A? A? A? A?GraphicComponent gc = at.AttachmentChild as GraphicComponent;
    A?A? A? A? A? A? A? A? A? A? A?IAttachableParent ap = actStn.GraphicComponents["euro_pallet"] as IAttachableParent;
    A?A? A? A? A? A? A? A? A? A? A?ap.Detach(gc as IAttachableChild);
    A?A? A? A? A? A? A? A? A?}
    A?A? A? A? A? A? A?}
    A?A? A? A? A?}


  • Yes! I resolve the problem!
    Your information is so helpful! Thank you so much!Smile

     

    The way I do is:

    1. Find the flange of the robot.  "Flange[] Mechanism.GetFlanges()"

    2. Attach the part to the flange."bool Flange.Attach(IAttachableChild child, bool mount)"

        And detach is "bool Flange.Detach(IAttachableChild child)"