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

setParam() with ITEM_TYPE_PROGRAM

#1
Hi,

I am currently trying to acces the instruction parameters in a program from the Python API. I would like to do something similar to this example: https://robodk.com/doc/en/PythonAPI/examples.html#id5.

But the example doesn't work for me when I run it as it is.

I get the following output.
Code:
Program selected: gcode_example


Instruction: 0
(ItemCommand)   (ItemParameter) (description)<br>Approach       (Normal|Tangent|Side|XYZ|NTS|ArcN|ArcS A B C)   Set the approach or retract of a robot machining toopath<br>ApproachRetractAllCurves    (1|0)   For curve follow projects: Apply approach and retract to each curve section.<br>BoundingBox             Returns the bounding box of this object, robot or tool a JSON string, in mm and with respect to station coordinates (absolute)<br>Cutter        (1|0)   Set this tool as a cutter: it is treated accordingly when using a robot machining project.<br>DisplayThreshold  (double)        Do not display small object of a given size (size as a percentage of the screen). Set to -1 to always display everything.<br>FilterMesh (double double double)  Remove small object triangles given a tolerance [min part size (mm), min triangle surface (mm2), triangle angle (deg)].<br>JoinCurveTol (double)        For curve follow projects: Join curve tolerance (in mm).<br>MouseFeedback       (1|0)   Activate or disable mouse feedback (highlight object on hover).<br>NormalApproach       (double)        For robot machining projects: Use a normal approach with a given distance.<br>OffsetRail        (double)        For robot machining projects: Offset of the rail when optimized (mm).<br>OffsetTurntable        (double)        For robot machining projects: Offset of the turntable when optimized (deg).<br>OperationSpeed   (double)        For curve follow projects: Operation speed (in mm/s).<br>OptimRail      (0|1)   For robot machining projects: Use linear rail optimization.<br>OptimTurntable   (0|1)   For robot machining projects: Use turntable optimization.<br>PostProcessor      (string)        Set the post processor (file or name excluding the path). Leave empty to retrieve current post processor.<br>RangeRotZ  (double 0-180)  For robot machining projects: Tool rotation range around the Z axis (deg).<br>Reframe   (ignored)       Reframe on this object<br>Retract       (Normal|Tangent|Side|XYZ|NTS|ArcN|ArcS A B C)   Set the approach or retract of a robot machining toopath<br>SelectAlgorithm     (0|1|2) Select the algorithm (0: minimum tool orientation change, 1: Tool orientation follows path, 3: Robot holds object).<br>ShowWorkspace    (0|1|2|3)       Show or hide robot workspace (0: hide, 1: show for wrist center, 2: show for flange, 3: show for active tool).<br>SimplifyMesh  (ignored)       Simplify the geometry of an object (it does not change the object appearance).<br>StatsAccuracy (Validation|Calibration)        Robot calibration statistics<br>StepRotZ        (double)        For robot machining projects: Tool rotation steps around the Z axis (deg).<br>Tree      (expand|collapse)       Expand or collapse the item in the tree.<br>UpdatePath  (ignored)       Update the operation toolpath (green path). Use this option after changing an approach or retract<br>
Traceback (most recent call last):

 File "<ipython-input-29-fe3d63a94826>", line 1, in <module>
   runfile('//triton.meca.polymtl.ca/usagers/abbhe/profiles/Desktop/untitled0.py', wdir='//triton.meca.polymtl.ca/usagers/abbhe/profiles/Desktop')

 File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
   execfile(filename, namespace)

 File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
   exec(compile(f.read(), filename, 'exec'), namespace)

 File "//triton.meca.polymtl.ca/usagers/abbhe/profiles/Desktop/untitled0.py", line 37, in <module>
   if instruction_dict['Type'] == INS_TYPE_CHANGESPEED:

TypeError: string indices must be integers

It looks like prog.setParam(ins_id) returns a string when it is supposed to return a dict. 

Is the example still up to date?

I am on RoboDK version 4.0.2

Thank you,

Abraham
#2
Hi Abraham,
The dictionary option to get/set instructions was added recently (after version 4.2).
I recommend you to update to the latest version of RoboDK.
Albert
  




Users browsing this thread:
1 Guest(s)