Notifications
Clear all

[Closed] Check for object presence?

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

7 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

($myObject_* as array).count > 0

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

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

let’s say you don’t want to create more then 100 myObject nodes. so:


 if ($myObject_* as array).count < 100  then (...) else (...)
 

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.

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

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
)

Hi,

My little addition to this conversation:


b=box prefix:"My_object"

J.