RoboDK Forum
Move Geometry (Apply move through python code?)- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Move Geometry (Apply move through python code?) (/Thread-Move-Geometry-Apply-move-through-python-code)



Move Geometry (Apply move through python code?)-Martin.K-03-08-2022

Hello,


我building this program to make it easier for our operators to use RoboDK.

But I get the following problems.

The object I import has an incorrect orientation so I use (setPoseAbs and setGeometryPose) to change the orientation and position to make it automaticly get the right position.But with the geometry you have to press the "Apply move" button to get changes to the geometry and I want to make it as simple as possible and therefore remove this extra navigation to the "Apply move" button if possible.


So is there some method to apply the move from the python program?

Best regards Martin.K


RE: Move Geometry (Apply move through python code?)-Alex-03-08-2022

You can use item.setGeometryPose()
//www.sinclairbody.com/doc/en/PythonAPI/robodk.html#robodk.robolink.Item.setGeometryPose


RE: Move Geometry (Apply move through python code?)-Martin.K-03-09-2022

(03-08-2022, 07:04 PM)Alex Wrote:You can use item.setGeometryPose()
//www.sinclairbody.com/doc/en/PythonAPI/robodk.html#robodk.robolink.Item.setGeometryPose

Sorry but i might have been a litle unclear in my sentence.
But I'm using the setGeometryPose()

The problem is that it won't apply the move untill i have pressed the "apply move" button.
Since i have not pressed "apply move" when i simulate the metal coating program it looks like a ghost shape of the object is geting the coating and no coating on the visible object.

But if i press this butten before simulation everything is fine.
But i would like for the operator to not have to navigate to this button every time we are using a new item.



Best regards Martin.K


RE: Move Geometry (Apply move through python code?)-Albert-03-09-2022

This is officially not supported right now using the API but there is a workaround you can do by following these steps:
  1. Open therobolink.py file you'll find here:
    C:/RoboDK/Python/robodk/robolink.py
  2. Search for thesetGeometrypose function (around line 4304)
  3. Replace this function by this one to have the optional apply flag:
Code:
def setGeometryPose(self, pose, apply=False):
"""Set the position (pose) the object geometry with respect to its own reference frame. This can be applied to tools and objects.
The pose must be a :class:`robomath.Mat`"""
with self.link._lock:
self.link._check_connection()
command = 'S_Hgeo2'
self.link._send_line(command)
self.link._send_item(self)
self.link._send_pose(pose)
self.link._send_int(1 if apply else 0)
self.link._check_status()

We'll add this by default with new versions of RoboDK.


RE: Move Geometry (Apply move through python code?)-Oxbown-03-17-2022

(03-09-2022, 07:41 AM)Albert Wrote:This is officially not supported right now using the API but there is a workaround you can do by following these steps:
  1. Open therobolink.py file you'll find here:
    C:/RoboDK/Python/robodk/robolink.py
  2. Search for thesetGeometrypose function (around line 4304)
  3. Replace this function by this one to have the optional apply flag:
Code:
def setGeometryPose(self, pose, apply=False):
"""Set the position (pose) the object geometry with respect to its own reference frame. This can be applied to tools and objects.
The pose must be a :class:`robomath.Mat`"""
with self.link._lock:
self.link._check_connection()
command = 'S_Hgeo2'
self.link._send_line(command)
self.link._send_item(self)
self.link._send_pose(pose)
self.link._send_int(1 if apply else 0)
self.link._check_status()

We'll add this by default with new versions of RoboDK.

This works fine! Yesterday I had to make the change.