RobotStudio event

API: Change Workobject

Hi,

I'm working on an Add-in that will loop through the active path and do some corrections. One of them are to change which workobject the targets refers to.

I have used the rsTarget class with the WorkObject property to simply change the workobject. The problem is of course that the target will still have the x,y,z coordinate, example if I had 1000mm in the X-axis in relations to world, I'll have the same coodinate in relation to the new workobject. Meaning that, if the workobject itself has a value 1000mm away from world, my target will appear 2000mm away from world.

My objective is of course to change the workobject, but not the relations to world.

So my question; Can I find this functionality somewhere in the RS API or do i need to do the math myself?

Kind regards
Daniel



Comments

  • Hi Daniel,

    Try this:
    [code]Matrix4 worldMatrix = target.Transform.GlobalMatrix;
    target.WorkObject = newWobj;
    target.Transform.GlobalMatrix = worldMatrix;
    [/code]

    Johannes Weiman
    Software Engineer
    ABB Robotics
  • Thanks, works great! :)
    //Daniel