[Closed] Specify object via handle
- I hope I need not intruduce myself in this forum, if so please advise where to do so.
I have some doubts
-
Two objects in the same scene are able to have the same name. Thus the convention $‘name’ is not very unique in specifying objects. Each object has a unique id (.handle). Is it possible to specify an object using the handle e.g. $‘handle’ instead of $‘name’?
-
Is there any smart way of telling how many objects there is with the same name and with the same parent in the scene like a function?:
ReturnNumberOfObjectsWithSameName parent name
Regards,
– get the handle ID for $Box01
id = $Box01.handle
– and select the node with that handle ID
select (maxOps.getNodeByHandle id)
fn ReturnNumberOfObjectsWithSameName theName theParent: =
(
select (for obj in objects where obj.name == theName and (theParent == unsupplied or obj.parent == theParent) collect obj)
)
– usage: (‘theParent’ is optional)
ReturnNumberOfObjectsWithSameName “Box01”
ReturnNumberOfObjectsWithSameName “Box01” theParent:$Dummy01
Hope this helps,
Martijn
I am sure it is noted in the Reference, but just in case: Since a Teapot has a .handle property, it is always safer to say
theObject.inode.handle
I have SEEN people getting errors while testing node handle related code with a teapot!
lol, i just made the error while trying that. Now i’ll have to read the maxscript reference to understand why it doesn’t work. thx.
There is a note in the “Node Handles” topic, but not in the inode Interface topic.
I guess somebody will have to fix that…