How to obtain the handle of the second script

Typically: "How do I... ", "How can I... " questions
Post Reply
anyu
Posts: 5
Joined: 01 May 2025, 08:57

How to obtain the handle of the second script

Post by anyu »

I've encountered a small issue recently that has been bothering me for quite some time, and I'm seeking your help. Thank you very much!

I am using CoppeliaSim 4.7, and there is a built-in script file named "Script" under the RG2 gripper object. I've also created a new script file named "rg2control" under the RG2 gripper object. Now, I want to obtain the handle of the second script file "rg2control" in the console. How should I write the code to achieve this? I've tried some methods, but they all return nil.
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: How to obtain the handle of the second script

Post by coppelia »

Hello,

you have several possibilities. If there is only one object with such a name, then:

Code: Select all

local scriptHandle = sim.getObjectHandle('/rg2control')
Otherwise you need to specify the name more precisely, e.g.:

Code: Select all

local scriptHandle = sim.getObjectHandle('/UR5/RG2/rg2control')
Cheers
Post Reply