PDA

View Full Version : set property for all new objects


murry
03-24-2008, 12:56 AM
i'm trying to create a script which will output information about all objects in a scene, and i want to keep updating this file over time for a history log.

The idea i've got is to give every object a unique id which can be identifed in the log file to make sure the right data goes with the right object, but i can't seem to find any sign of a unique object id already in max.

So is there a way for me to add a user property to every object that gets created in a scene automatically? The id needs to be assigned and once done this id can't be used again for another object in the scene even if the original is deleted.
Any thoughts?
Thanks

Bobo
03-24-2008, 01:09 AM
i'm trying to create a script which will output information about all objects in a scene, and i want to keep updating this file over time for a history log.

The idea i've got is to give every object a unique id which can be identifed in the log file to make sure the right data goes with the right object, but i can't seem to find any sign of a unique object id already in max.

So is there a way for me to add a user property to every object that gets created in a scene automatically? The id needs to be assigned and once done this id can't be used again for another object in the scene even if the original is deleted.
Any thoughts?
Thanks

Each node in Max gets assigned a unique integer NodeID which is accessible via

theNodeID = theNode.inode.handle

where theNode is a variable containing a valid scene object.
You can get the node corresponding to a given ID using

theNode = maxOps.getNodeByHandle theNodeID

where theNodeID is an integer. If the ID does not match a scene node, undefined will be returned.

This ID is not unique between scenes though, it is unique only within the scene.
Adding new objects to the scene will give them new IDs. Even if you have created 1000 objects already and decide to delete them, then create a new object, the new one will have an ID of 1001 and not 1. If you do a File>Reset and start creating objects, their node handle will start from 1 again.

murry
03-24-2008, 01:26 AM
Thanks for the fast response Bobo. That's exactly what i was looking for in the first place, i thought there might be something like that already in Max but the help files aren't that great unless you know exactly the phrase to search for.
Thanks very much

PEN
03-24-2008, 01:14 PM
I have done something similar in the past and I used a custom attribute definition that I added to each object that I needed to track. In the def I had a parameter that was assigned a unique ID using genClassId(). You could also store the data in the appData channels, one thing to consider and it is kind of a good thing for you is that when an object is copied the appData channels are not copied with it.

CGTalk Moderation
03-24-2008, 01:14 PM
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.