Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add first line to program using API
#1
Hello,

I am using the commands "InstructionSelect" and "RunInstruction" to modify robot programs with the RoboDK API. I have found that it is possible to add lines to any location in the program, except for the first instruction. Is it possible to add the first instruction of the program?
#2
Hi,

Here's how to reorder Program Instructions, which should allow you to insert an instruction as a first instruction.

Code:
# Example to reorder instructions
# Test with Example-01.a

from robolink import *

RDK = Robolink()

p1 = RDK.Item("ApproachMove", ITEM_TYPE_PROGRAM)
p2 = RDK.Item("PaintTop", ITEM_TYPE_PROGRAM)

公关ogram_from = p1
公关ogram_to = p1 # this can be a different program as well
instruction_id_from = 2
instruction_id_to = 0

# Choose if you want to reorder before or after
reorder_cmd = "ReorderBefore"
#reorder_cmd = "ReorderAfter"

# Warning: This can crash if id's are not valid
公关ogram_from.setParam(reorder_cmd, str(instruction_id_from) + "|" + str(instruction_id_to) + "|" + str(program_to.item))
Please read the论坛Guidelinesbefore posting!
Find useful information about RoboDK by visiting our2022世界杯32强赛程表时间 .
#3
Hi Sam,

The sample code worked well. Thanks!




Users browsing this thread:
1 Guest(s)