How to create an object with a customized name?

Typically: "How do I... ", "How can I... " questions
Post Reply
dada_17528
Posts: 2
Joined: 24 Jun 2021, 10:04

How to create an object with a customized name?

Post by dada_17528 »

When I use Lua script to create a new object, (e.g. a cuboid), I can not give the new object a proper name.
The function usage is
int objectHandle=sim.createPureShape(int primitiveType,int options,table[3] sizes,float mass,table[2] precision=nil)
It is not easy to use when the created object does not have a customized name.

So, how to create an object with a customized name?

coppelia
Site Admin
Posts: 10366
Joined: 14 Dec 2012, 00:25

Re: How to create an object with a customized name?

Post by coppelia »

Hello,

you will have to use sim.setObjectName (and maybe also sim.getObjectName), but keep in mind that object names have to be unique. Use sim.handleflag_silenterror to generate silent errors and find out whether a name already exists (or contains illegal chars).

Starting with CoppeliaSim V4.3.0, object names will be deprecated and object aliases used instead: they will allow for non-unique aliases, and be very convenient for object access via an absolute or relative path, e.g. sim.getObjectHandle("./path/to/alias").

Cheers

Post Reply