Get current active tool frame for robot in python script - expose to OPCUA connectivity

Hello
I am currently using kuka.sim 4.3 and also Visual Components 4.8

Is possible to access the name of the current active tool frame in a python script in the modelling tab when the simulation is running. Could anyone please help with a demo script for it on how to access the tool frame of a component

Ideally a script to get the robot component and its current active tool frame from the list of many tool frame when the simulation running and assign it as to a “string” variable so that it can be used in OPC UA connectivity.

Link to setupimage -
image.png

Any help will be really appreciated, I am very stuck

Thank you

Seems that the Python API (vcRobotController) doesn’t have equivalent getter for the IRobotController.CurrentTool found in .NET API.

However, it seems that vcHelpers.Robot2 has an ActiveTool getter. You’ll need to poll that at some suitable interval using a Python script and copy the value to e.g. component property.

edit. It might be that Robot2.ActiveTool only changes if you make robot motions through that Robot2 helper class. You’ll need to test that. If it doesn’t work, a workaround could be to listen for robot executor’s events and try to find the tool setting from the vcMotionStatements as they are executed. That probably won’t work with KUKA.Sim and KRL as those use their own custom robot executor and statements.