View Full Version : Check for object presence?
mattjakob 02-03-2010, 09:27 PM Hello,
is there a way to check if an object with a dynamic name (*) exists already in the scene and if not create it?
*: something like "myObject_01", "myObject_02", "myObject_03" ... "myObject_" + n
thanks
|
|
denisT
02-03-2010, 09:49 PM
Hello,
is there a way to check if an object with a dynamic name (*) exists already in the scene and if not create it?
*: something like "myObject_01", "myObject_02", "myObject_03" ... "myObject_" + n
thanks
($myObject_* as array).count > 0
mattjakob
02-03-2010, 09:56 PM
do you also know how I can embed this in a for loop please?
kind of:
for i = 1 to 100 do
(
if( ($myObject_i as array).count == 0 ) then
(...)
else
(...)
)
thanks
Pjanssen
02-03-2010, 09:58 PM
Could this method maybe help you out?
uniqueName <prefix>
Generates a unique scene node name from a prefix string by adding a series of digits, in the same manner the 3ds Max does as you create objects in the scene. This name is only guaranteed to be unique until the next scene node creation.
denisT
02-03-2010, 10:14 PM
do you also know how I can embed this in a for loop please?
kind of:
for i = 1 to 100 do
(
if( ($myObject_i as array).count == 0 ) then
(...)
else
(...)
)
thanks
let's say you don't want to create more then 100 myObject nodes. so:
if ($myObject_* as array).count < 100 then (...) else (...)
mattjakob
02-03-2010, 10:20 PM
umh but I need to check if an object exist and if it does apply some calculations on it.
I solved it creating a global array and checking for undefined values.
thanks anyway :)
Pjanssen
02-04-2010, 07:04 AM
So you're looking for something like this then?
for i = 1 to 100 do
(
local node = getNodeByName ("myObject_" + i);
if (isValidNode node) then
dosomething
else
dosomethingelse
)
j-man
02-08-2010, 10:52 AM
Hi,
My little addition to this conversation:
b=box prefix:"My_object"
J.
CGTalk Moderation
02-08-2010, 10:52 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.