Create Linear Motion Statement in Python

I’m trying to create linear motion statements with python.

It creates the statements in the program with correct position and everything (tool, base, etc), but when I double click on the statement the robot doesn’t move to its location.

Below is part of the code I’m using, what is wrong?


Program = executor.Program
Routine = Program.findRoutine(‘XCAL’)
if Routine != None:
Routine = Program.addRoutine(‘XCAL’)

… some other code here…

count += 1
sName = “XCAL%d” % count
Statement = Routine.addStatement(VC_STATEMENT_LINMOTION)
Statement.Base = Base1
Statement.Tool = controller.Tools[0]
PositionFrame = Statement.createPosition(sName)
PositionFrame.PositionInReference = TargetPos

Hi Fredrik,

you don’t have to create a new position. When adding a new LIN statement the list ‘Positions’ has already an item that have to be used for the target definition.

Statement.Tool = controller.Tools[0]
PositionFrame = Statement.Positions[0]
PositionFrame.PositionInReference = TargetPos …



<p style=“text-align: left;”>Hi Ralle,</p>
<p style=“text-align: left;”>Thanks for your comment, now it works like a charm</p>
<p style=“text-align: left;”>BR</p>
<p style=“text-align: left;”>Fredrik</p>