RoboDK Forum
创造e script file to run on real robot- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+ - - -论坛:通用RoboDK问题(//www.sinclairbody.com/forum/Forum-General-questions-about-RoboDK)
+--- Thread: Create script file to run on real robot (/Thread-Create-script-file-to-run-on-real-robot)



创造e script file to run on real robot-Tieubu-11-26-2022

Hello,
I created a python script and simulation on RoboDK,
then used Universal Robots URP for generate program.
Python:


Generated script file:


If, Else is not include in generated script file.
How I can fix it?
Thanks


RE: Create script file to run on real robot-Albert-11-27-2022

Generating programs from the API will output the robot commands. If you have logic or loops in your Python code, they will be evaluated at the time you run your the script for program generation.

If you have specific code to output you can use RunCode to output custom code. Example:
Code:
robodk.RunCode("if a>0")
robodk.RunCode(" ProgramA()")
robodk.RunCode("else")
robodk.RunCode(" ProgramB()")
robodk.RunCode("end")
Some post processors understand statements such as if/then/else and may adjust the syntax if needed.