Hello Coppelia,
How can I evaluate whether an object name exists in scene?
simGetObjectHandle is throwing a Lua runtime error, but from documentation I was expecting it to return -1 on error.
Best,
Tiago
Evaluate whether object name exists or not
Re: Evaluate whether object name exists or not
Hello Tiago,
you have two options:
1. You can disable throwing errors for V-REP API functions if you set variable raiseErrorWithApiScriptFunctions to false in system/usrset.txt. This is not an elegant solution, since an error message will still be output in the status bar.
2. You can use following code:
Cheers
you have two options:
1. You can disable throwing errors for V-REP API functions if you set variable raiseErrorWithApiScriptFunctions to false in system/usrset.txt. This is not an elegant solution, since an error message will still be output in the status bar.
2. You can use following code:
Code: Select all
local savedState=simGetInt32Parameter(sim_intparam_error_report_mode)
simSetInt32Parameter(sim_intparam_error_report_mode,0)
print(simGetObjectHandle('objectName'))
simSetInt32Parameter(sim_intparam_error_report_mode,savedState)
Re: Evaluate whether object name exists or not
Hi coppelia,
Thank you!
Best,
Tiago
Thank you!
Best,
Tiago
Re: Evaluate whether object name exists or not
coppelia wrote: ↑12 Jul 2016, 20:26Hello Tiago,
you have two options:
1. You can disable throwing errors for V-REP API functions if you set variable raiseErrorWithApiScriptFunctions to false in system/usrset.txt. This is not an elegant solution, since an error message will still be output in the status bar.
2. You can use following code:
CheersCode: Select all
local savedState=simGetInt32Parameter(sim_intparam_error_report_mode) simSetInt32Parameter(sim_intparam_error_report_mode,0) print(simGetObjectHandle('objectName')) simSetInt32Parameter(sim_intparam_error_report_mode,savedState)
5 years later, newest version of coppelia doesnt have this variable. How we do it now, please?
Re: Evaluate whether object name exists or not
From
sim.getObjectHandle
:So,objectName: If the name is appended by a "@silentError" suffix, then no error will be output if the object does not exist.
sim.getObjectHandle('Floor@silentError')