assigning numbers to objects

I have made a script that will export selected obj(s) name(s) and a given number to the listner

100, mybox
101, mybox2
etc

What I want to be able to do is, import that info from an external text file (ie my example, saved previously from listener to desktop)
and apply the numbers to the objects (in this case mybox & mybox2) in the scene. so I can then write that info with some other data to the listener with another script at any time I select them.

What I really want to know is how would I permanently assign a number to an obj and how would I be able to call it?

hope this makes sense

thanks for any help

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
veneta's picture

each node has build-in unique

each node has build-in unique identifier, so you can get it with ".handle" and find your obj with maxOps.getNodeByHandle function.

Smallface's picture

Sorry Im new at this. by

Sorry Im new at this. by using that I can change the handle value to one from an imported text file and read that number in another script?

I tried inode.handle which seemed to be the number of the object (in order it was created) in the scene but everything I tried come back as non writable or read only, something along those lines.

how do I assign a number to it and read from it? or are there empty handles I should have used?

Anubis's picture

Hi Smallface,yes, node

Hi Smallface,
yes, node handle ID is read only auto-enumeration.

-- restet Max and...
b = box(); c = cone() -- create 2 objects to test
id = b.inode.handle -->> 1
id = c.inode.handle -->> 2
 
c.inode.handle = 3 -- Runtime error: Property is read-only: handle
 
-- find obj's by handle ID:
obj1 = maxOps.getNodeByHandle 1 -->> $Box01
obj2 = maxOps.getNodeByHandle 2 -->> $Cone01
 
-- also the handle ID is unique:
delete b -- delete the box
maxOps.getNodeByHandle 1 -->> undefined
b = box() -- create new box
b.inode.handle -->> 3 (now is 3, the ID 1 no more used)

I hope this help.

P.S. - if you look for your own independent enumerator (not controlled by Max), check in the help 2 possibilities:
AppData (setAppData, getAppData, ...)
or
User-Defined properties (getUserProp, setUserProp, ...).

Cheers
Anubis

my recent MAXScripts RSS (archive here)

Smallface's picture

" User-Defined properties

"
User-Defined properties (getUserProp, setUserProp, ...)."

This seems to be exactly what Im after. thank you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.