Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

External Python code and interaction with GUI

Using the RoboDK API it is possible to control a robot in the GUI window of RoboDK when executing an external Python file.

Things look nicer when I open the the same file in the GUI (Open -> *.py), as there is the line of movement depicted that the tool will make if it is run with (rightClick -> Run Python Script). When I now change the Python file in an external editor, re-running the file will execute the old instructions before the change. The only way to update that script is to delete it on the GUI and open it again.

So I got two questions:
1. Is there a way to have the line of movement also depicted when running Python externally?
2. Is there an alternative to deleting and re-opening the externally changed Python scripts?
Hi Martin,

You should be able to run Python scripts externally the same way you do it internally from the GUI. When you run a Python script from the GUI, RoboDK automatically uses the Python folder (C:/RoboDK/Python/) as the Python path so it will always use the latest version of the robodk library for Python as these libraries are placed there.

I'm assuming you once installed the RoboDK library for Python and you may be using an older version of the Robolink library. So, just make sure you update the RoboDK library for Python. 


pip install robodk --upgrade

Hi Albert,

thanks for your answer. Indeed, running external Python code works in general without issues, just the trajectory line of the tool is not depicted in the GUI. I just installed the Robodk-API (using "sudo python install" on Linux) so I guess I am up to date.

The workflow would be easier if an externally changed Python file that is part of the GUI tree structure would get updated, without manual re-loading of that file.

Hi Martin,

I'm sorry I misread your original questions. It is not possible to see the Yellow line when running Python files externally. However, you can activate the trace and show lines. It should give you a very similar effect. The trace can be activated using Python. You can also customize the appearance. 

RDK.Command("Trace", "On") # Activate the trace
RDK.Command("Trace", "1") # Frames: 0, Lines=1, Dots=2, Points=3, Spheres=4
RDK.Command("Trace", "Reset") # Delete the previous trace
RDK.Command("Trace", "Off") # Turn off the trace

Saving a Python file opened from a RoboDK project should update the Python script in the same RoboDK project. By default it will not save the RDK file immediately. You can activate this option here:
This setting used to be activated by default before RoboDK v5.0.

Users browsing this thread:
1 Guest(s)