handles

Hi I am trying to select an object by it unique handle. I can find out what the handle is (see below) what I dont know is how to select the object via its handle. Can anyone help?

$.handle (Returns the unique id associated with the node)

Thanks

Gram

Comments

Comment viewing options

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

Thanks, the hasProperty()

Thanks, the hasProperty() function will fix it!

Graph's picture

the hasproperty function

the hasproperty function should help to filter the ones out that dont have it. or isProperty dunno wich one it was for CAs

Raphael Steves

Garp's picture

About identifying through

About identifying through handle IDs, using the appropriate method:

select (maxOps.getNodeByHandle 3) --for selection
obj = maxOps.getNodeByHandle 3 --for assignment
gramx's picture

Thanks, trying to use custom

Thanks, trying to use custom handles rather than the handle function built into max. Allthough all objects get a unique handle if you merge objects into another scenes then the handle IDs can change. :(

gramx's picture

selecting object via custom ID

Hi

I have used the following code to add an ID to an object:-

local DataCA = attributes data ; (parameters main;(myNewID type:#integer default:2 animatable:false;))
custAttributes.add $ DataCA

I then select the object with the following code:-

for obj in $* where obj.myNewID == 2 do select obj

If I have any objects in the scene that dont have this extra attribute I get the following error:-

-- Error occurred in obj loop
-- Frame:
-- obj: $Box01
-- Unknown property: "myNewID" in blabla

How would I get around this?

Thanks

Gram

Graph's picture

Scripted Custom attributes

Scripted Custom attributes are what you might want to look into

local DataCA = attributes data ; (parameters main;(myNewID type:#integer default:2 animatable:false;))
custAttributes.add $ DataCA

Raphael Steves

gramx's picture

Thanks Graph, Thats going to

Thanks Graph,

Thats going to help alot:)

g

Anubis's picture

same result without collecting

for obj in $* where obj.handle == 2 do select obj

my recent MAXScripts RSS (archive here)

gramx's picture

Thanks Anubis, that makes

Thanks Anubis, that makes sense. Is it possible to add your own hidden handels to objects? such as an ID tag. The .handle works ok but if you merge it into another scene then the handle number changes.

Ta

G

gramx's picture

User Defined properties

Better idea? - instead of using tags I can give objects a tag_code in the User Defined Properties. This way if the object gets renamed I can still select it via the tag_code.

g

Comment viewing options

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