PDA

View Full Version : Uinque Custom Attributes on Instanced Max Objects


kylawl
03-04-2009, 11:46 PM
I would like to have a custom attribute definition applied to a bunch of instanced max objects. But allow each instance to store it's own unique values for the parameters in the definition.

So far, the furthest that I have gotten is by using the get and set events on the parameter block to write the variables to the user-defined properties buffer. I again hit a snag with this because getting the owner object of a given instance of a definition will return an array of all the instances using the definition. With no way for me to know which one is which, I'm pretty much back to square one.

Any help would be appreciated

Cheers

Kyle

ZeBoxx2
03-05-2009, 12:44 AM
Aren't they unique by design?

(blue lines are result in listener, green are comments)

-- create a custom attribute block
myAttributes = attributes test (
rollout roll_test "test" (
spinner spn_test "test"
)
parameters main rollout:roll_test (
someValue type:#float ui:spn_Test
)
)
<AttributeDef:test>

-- create two spheres and assign the CA to them
sphereA = sphere()
$Sphere:Sphere01 @ [0.000000,0.000000,0.000000]
sphereB = sphere()
$Sphere:Sphere02 @ [0.000000,0.000000,0.000000]
custattributes.add sphereA myAttributes
true
custattributes.add sphereB myAttributes
true

-- let's change the CA values on these objects
sphereA.someValue = 12
12
sphereB.someValue = 34
34

-- and now retrieve them again
sphereA.someValue
12.0
sphereB.someValue
34.0

kylawl
03-05-2009, 01:00 AM
Sorry, not a unique instance. Like an instance or reference. As if you created an instanced copy of sphereA.

ZeBoxx2
03-05-2009, 02:01 AM
ah!

er. hmmm...

Well you can't have unique -parameters- in the custom attribute block across instanced objects. So you'd have to work with, as you mentioned, the user properties buffer or appdata, etc.

Presuming script access would already know that they have to access that buffer/appdata, that just leaves user interaction with any rollout controls?
If so - you could just grab the currently selected object(s) and work on that/those?

If you do need scripts to be able to get/set values through a parameters block, then... er. hmmm indeed. Not so sure you -can- get the actual object being operated on there.

kylawl
03-05-2009, 04:47 AM
Yeah, as I suspected. My issue is that I'm relying on the custom attributes to be exported in an fbx file so i'll can't rely on the selection data. I'll have to move to my alternate option which is to write out a second file with the date embedded in the user-defined buffer. Not a big deal, just a little extra work.

Thanks for the help.

Cheers

Kyle

magicm
03-05-2009, 11:55 PM
I'm not sure if this is what you want, but you could add the custom attribute to the object itself instead of the baseObject (which is the default). The downside of this is that the attributes' rollout does not appear in the modify panel when the object is selected. You can however display the dialog manually by running "createDialog spherea.test.roll_test"

-- create a custom attribute block
myAttributes = attributes test (
rollout roll_test "test" (
spinner spn_test "test"
)
parameters main rollout:roll_test (
someValue type:#float ui:spn_Test
)
)
<AttributeDef:Test>

-- create two spheres and assign the CA to them
sphereA = sphere()
$Sphere:Sphere01 @ [0.000000,0.000000,0.000000]
sphereB = instance sphereA
$Sphere:Sphere02 @ [0.000000,0.000000,0.000000]
custattributes.add sphereA myAttributes baseObject:false
true
custattributes.add sphereB myAttributes baseObject:false
true

-- let's change the CA values on these objects
sphereA.someValue = 12
12
sphereB.someValue = 34
34

-- and now retrieve them again
sphereA.someValue
12.0
sphereB.someValue
34.0
Martijn

CGTalk Moderation
03-05-2009, 11:55 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.