Robot program not running after using mountTool


I am using mountTool method from the vcHelpers.Robot2 library to mount a tool to a robot. It works, but the problem is, after I do that, the robot program is not executed anymore, I click play and the robot doesn’t move. I also don’t see the green dot next to statements in the robot program.


When you use getRobot method, it will turn off executor (Executor → IsEnabled), robot is only controlled by Python script, so you need to use callRoutine method to call the routine that you want to execute.

1 Like

Thank you for your reply, it was very helpful!
In my case, the robot is not only controlled by the Python script. I have a widget for mounting tools on the robot, and after I use that, I would like to be able to program the robot without having to manually set the Active Tool to be the newly mounted tool.

I managed to make the program run by setting the IsEnabled property of the executor to True right after mounting. My problem now is, I don’t know how to set the Active Tool to be the newly mounted tool. I tried with
Robot.ActiveTool = ‘NameOfNewTool’,
but that doesn’t work. It runs, so there’s no error, and if I print the property before and after I see that it changes, but in the Jog menu I still see the old tool (Null)


When it comes to PythonScript, it would be easier to check with layout. :laughing:

alright, here’s a layout that showcases my issue:
example.vcmx (3.3 MB)

There is a script inside the robot, that is executed when you start the simulation. It imports a tool and mounts it. After that, you will notice that the tool is not available in the list of possible tools in the jog menu. That’s not so important to me, I’m looking for a way to set the active tool of the robot using the Python API. If you look at lines 20-22 in the Python script and the output of the simulation, you’ll notice the active tool of the vcHelpers.Robot2.vcRobot2 object is being modified, but that doesn’t affect the tool of the actual robot.


Now I get your point. I assume that you want to use same teach points but want to test with multiple kind of tools, statement tool is not related to ActiveTool, because statement tool has been defined, you can use executor event, before execute the motion statement, set statement tool as robot controller’s last tool, this can make sure every statement tool is the new added tool, by the way, tool = app.load(VCID), when each simulation runs, this will create another new tool, which could makes layout messy, recommend to fix this.

def defineTool(statement, immediate):
    statement.Tool = executor.Controller.Tools[-1]
comp = getComponent()
executor = comp.findBehavioursByType(VC_ROBOTEXECUTOR)[0]
executor.OnPreExecuteStatement = defineTool