Notifications
Clear all

[Closed] custAttributes.makeUnique

 eek

I’m trying to understand what custAttributes.makeUnique does so if i make an attribute like so:

testCa = attributes testAttribs
(
parameters testParams
(
val type:#float animatable:true
)
)

custAttributes.add $objectA_01.pos.controller testCa

with the val referencng another objects float e.g

$objectA_01.pos.controller.testCa.val = objectB_01.pos.controller[1].controller

and then i run this custom attribute on another unique object e.g

custAttributes.add $objectA_02.pos.controller testCa

referencing another unique object

$objectA_02.pos.controller.testCa.val = objectB_02.pos.controller[1].controller

Do i need to use makeUnique? Does the actual custom Attribute testCa need to be unique each time i.e testCa_01, _02 etc etc.

Edit: also what happens if you instance this controller with the CA on? does that need to made unique?

Thanks,

5 Replies

hey charles
if you want to apply the same CA to a maxobject multiply times you need to use the unique flag – other wise it just returns false –

interestingly you cannot make the rollout unique only the parameters

do you have to use unique in the case you listed,… i dont think so

mark

 PEN

Attribute definitions are like a scripted plugin loading. If the definition of the plugin changes all the instances of that plugin will change as well. The values that are stored in that plugin instance will remain as you had set them but the definition of the plugin has changed. So if you add a parameter that will now show up in all the instances of the ca def.

So here is something to consider. You have created a character with a ca def that controls parts of the body. You decide to create a second character that is much like the first so you just start with the first rig and change it as you need it. You then decide that the new character doesn’t need some of the parameters that were stored in the ca def so you get the def using .getDef, change it and update it on the new character. You then load the first character in the scene and start animation on it. You then load in the second character into the scene as well. Since the two share an instance of the same ca def, once the second character is loaded in the scene the instance of the def is updated with the new definition of it. In this case what you happen is the first character would be broken as the def on the first rig would now not have all the parameters that were needed.

To stop this from happening you will need to make the def on the second character unique. Here is the problem. I you are like most people you have the two rigs in seperate files. If you just try and make the def on the second character unique nothing will really happen as it is already unique to that scene. You will need to load in the first character so that there are two. What will happen then is the second def will now change to the first. This isn’t a good solution either so what I have done is get the def, add it to another object then you can make the first one unique as there is another instance in the scene.

Pain you say…yup.

hey,
paul i think you can make it unique with only one copy of the definition in the scene check out the following

box()
 box()
 box()
 
 blahAttribs = attributes blahAttribs
 (
 	parameters blahParams
 	(
 		nothing type:#string
 	)
 )
 
 custattributes.add $box01.baseobject blahAttribs
 (custattributes.getdef $box01.baseobject 1).attribID
 custattributes.makeUnique $box01.baseobject 1
 (custattributes.getdef $box01.baseobject 1).attribID
 custattributes.add $box02.baseobject (custattributes.getdef $box01.baseobject 1)
 custattributes.add $box03.baseobject blahAttribs
 
 format "Box01 def is the same as Box02 def: %
" ((custattributes.getdef $box01.baseobject 1) == (custattributes.getdef $box02.baseobject 1))
format "Box02 def is the same as Box03 def: %
" ((custattributes.getdef $box02.baseobject 1) == (custattributes.getdef $box03.baseobject 1))

as you can see the classID changes when makeunique is called making the definition unique

cheers,
mark

 PEN

Ah great, this has changed then. I talked to Larry about it some time ago but I never heard if anything was changed. I found this problem way back in Max 4 when they were first added and had the problem for some time. I think that I have adjusted the way that I do things so much that I don’t really see it any more. At least I know that it works as we would expect now.

 eek

Ah thanks guys, yep this is what i thought (making the definition unique to allow multiple instances have different parameters) – something i dont need to do atm.

cheers,