Cannot get JointValues

Hello,

I want to get JointValues in subroutine, following is my code.

The mainRoutine is working fine, but when I try to get subroutine’s JointValue(I changed only one place, marked in red), the value always zero. You can also see my robot program from attached picture.robot program main routine

robot program subroutine

comp = getComponent()
robotExecutor = comp.findBehavioursByType(“rRobotExecutor”)[0]
robotProgram = robotExecutor.Program
mainRoutine = robotProgram.MainRoutine
subroutines = robotProgram.Routines

for statement in mainRoutine.Statements:
try:
print statement.Type
print statement.Positions[0].JointValues[1]
except:
continue

for statement in subroutines[0].Statements:
try:
print statement.Type
print statement.Positions[0].JointValues[1]
except:
continue

Problem update.

I test it today, find out the problem is not relate to mainroutine or subroutines.

All the PTP or LIN statements in my subroutines were generated by robot.RecordRSL. So I assume the statements generated by robot.RecordRSL cannot get jointvalues.

I generate several statements in mainRoutine by robot.RecordRSL, and add some statements manually in mainRoutine . The manually added statements can be get jointvalues, while the statements generated by robot.RecordRSL cannot.

Hope someone can explain why.