API: Change Workobject

in RobotStudio
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
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
0
Comments
-
Hi Daniel,
Try this:
[code]Matrix4 worldMatrix = target.Transform.GlobalMatrix;
target.WorkObject = newWobj;
target.Transform.GlobalMatrix = worldMatrix;
[/code]
Johannes Weiman
Software Engineer
ABB Robotics0 -
Thanks, works great!
//Daniel
0
Categories
- All Categories
- 5.6K RobotStudio
- 401 UpFeed
- 20 Tutorials
- 15 RobotApps
- 303 PowerPacs
- 407 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 353 IRC5
- 74 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 849 RAPID Programming
- 24 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 110 Collaborative Robots
- 5 Job listings