Hi, I think some months ago the default code when adding a new Python program in the RoboDK tree has been changed in how RoboDK packages are loaded and 'RDK' is assigned. (Post edit: as I read here now:Python API for RoboDK 5.4.0)
The 'old' lines of code are as below, and I could use e.g. ITEM_TYPE_PROGRAM to search for a robot program:
This still works fine, the program is found and its name gets printed. The version with the 'new' preamble is however:
The latter results in an error:NameError: name 'ITEM_TYPE_PROGRAM' is not defined.
When I use:prog = RDK.Item('myProgram',8)using an integer 8 instead of the ITEM_TYPE_PROGRAM string, the item does get found.
Why do I get this error? And as it seems to have something to do with the loading of packages, how do you recommend to load the required packages?
Best regards,
Maarten
The 'old' lines of code are as below, and I could use e.g. ITEM_TYPE_PROGRAM to search for a robot program:
Code:
from robolink import * # RoboDK API
from robodk import * # Robot toolbox
RDK = Robolink()
prog = RDK.Item('myProgram',ITEM_TYPE_PROGRAM)
print('Program name: ' + prog.Name())
raise Exception('Eof exception.')
This still works fine, the program is found and its name gets printed. The version with the 'new' preamble is however:
Code:
from robodk import robolink # RoboDK API
从robodk进口robomath #机器人工具箱
RDK = robolink.Robolink()
prog = RDK.Item('myProgram',ITEM_TYPE_PROGRAM)
print('Program name: ' + prog.Name())
raise Exception('Eof exception.')
The latter results in an error:NameError: name 'ITEM_TYPE_PROGRAM' is not defined.
When I use:prog = RDK.Item('myProgram',8)using an integer 8 instead of the ITEM_TYPE_PROGRAM string, the item does get found.
Why do I get this error? And as it seems to have something to do with the loading of packages, how do you recommend to load the required packages?
Best regards,
Maarten