Just wondering if anyone can help me understand why my command is not recognized while I’m programming path statements. This code works as a Python robot behavior, but not as a “command”. I would like to run this code while I’m creating a new PTP statement to add a checkbox. I tried adding a “command” under my commands for adding a property. It seems like the python script is not being read when I open up the program editor. I can add the script under the robot as a behavior, but not as a command. I’m not sure how to get the command to execute.
Here is the code I used…
app = getApplication() def my_event_handler(statement): if statement.Type == VC_STATEMENT_PTPMOTION: statement.createProperty(VC_BOOLEAN, "checkbox") if app.TeachContext != None and \ app.TeachContext.ActiveRobot != None: robotdata = getSelectedRobotsData() executor = robotdata routine = executor.Program.MainRoutine routine.OnStatementAdded = my_event_handler
With Python Behavior
Without Python Behavior