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

Traceback (most recent call last):

File "", line 1, in
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
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?

我在RoboDK版本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)