Get selected motion statement in Python

Adding a statement to the main routine place it at the end of the program, i.e.


If I want to place it after a selected statement, like this

executor.Program.MainRoutine.addStatement(‘Process’, index)<b></b><i></i><u></u>

How can I find the selected statement and it’s index?

I guess you can use getApplication().SelectionManager.getSelection(VC_SELECTION_RSLSTATEMENT)

I tried that, but I get an error, “global name ‘VC_SELECTION_RSLSTATEMENT’ is not defined”.

Also in the manual it says “Deprecated”

Thanks anyway


Try this, getApplication().SelectionManager.getSelection(VC_SELECTION_STATEMENT)

Ok, this worked.

Next, what’s the best way to find the index of the statement in the program?

Iterate through the “List of vcStatement” from vcScope object?


Chungmin, no need to answer I solved it, very simple, just use 'Statements.index(…)