RoboDK Forum
Add simulation events to a program using Python API- Printable Version

+- RoboDK Forum (//m.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//m.sinclairbody.com/forum/Forum-RoboDK-EN)
+ - - -论坛:通用RoboDK问题(//m.sinclairbody.com/forum/Forum-General-questions-about-RoboDK)
+--- Thread: Add simulation events to a program using Python API (/Thread-Add-simulation-events-to-a-program-using-Python-API)



Add simulation events to a program using Python API-neurotek-12-13-2018

Hello,

Is it possible to add simulation events to a program from the Python API?

e.g.

sorter_tray_manipulate = RDK.Item('sorter_tray_manipulate')
sorting_destination_frame = RDK.Item('sorting_destination_frame')
prog=RDK.AddProgram(“New_Program')
prog.AddSimualtionEvent(type=EVENT_TYPE_ATTACH, tcp=sorter_tray_manipulate)
prog.AddSimualtionEvent(type=EVENT_TYPE_DETACH_ALL, attach_frame=sorting_destination_frame)


RE: Add simulation events to a program using Python API-Albert-12-13-2018

This is not possible. Instead, I recommend you to add a program call to a macro that provokes a customized event.

For example, if you want to attach something together at a specific point in your program (such as grabbing an object with your robot tool):

program = RDK.AddProgram('YourProgram')
...
program.RunInstruction('YourEvent', INSTRUCTION_CALL_PROGRAM)
...

Then, the program "YourEvent" can be a Python macro in your RoboDK station that does something like this:

object.setParentStatic(tool)

This will attach the object to the tool. More information about this function here:
//m.sinclairbody.com/doc/en/PythonAPI/robolink.html#robolink.Item.setParentStatic