[Closed] Instancing a CA across multiple modifiers
Hi,
Has anyone tried this?
i know you can instance modifiers with ca’s on them, so you can have an instance of the ca on multiple objects, but is it also possible to instance the ca itself across modifiers?
i have a ca that i want to be visible on different modifiers all with different ca’s already on them
i’d appreciate any input on this
So this creates 10 spheres and adds an attribute holder modfifier to each one. The modifier isn’t instanced as it is being recreated for each sphere.
You then make a CA Definition, I think this is what you are asking as you use CA, well a CA often is just refering to a single spinner or item and not the whole definition. You really can’t instance a single CA from one definition to another but you can have a full definition instanced from one maxObject to another.
Once the definition is created I then add that definition to all the spheres, note that I’m not recreating the definition each time so this makes it an instance. Any updates to one will update the others.
I have written this in long form without taking any short cuts so that it makes the most sense.
--Make a bunch O spheres and add attribute holder modifiers
sphs=#()
for x= 1 to 10 do
(
bm=emptyModifier()
sph=sphere pos:(random [-50,-50,-50] [50,50,50])
addModifier sph bm
append sphs sph
)
--Create a CA definitions
def=attributes test
(
parameters testP rollout:testR
(
test1Sp type:#float
test2Sp type:#float
)
rollout testR "Test"
(
spinner test1Sp "Test 1"
spinner test2Sp "Test 2"
)
)
--Add the definition to all the spheres attribute holder modifiers
for x in sphs do
(
custAttributes.add x.modifiers[1] def
)
thanks paul, you assumed right that is what i want, a scripted definition
what i mean by instanced is i want the parameters to be instances (so in your example if i adjust the test1 spinner it should be the same for all the ca’s) i would need it to work with complex values as well
does this work for you in your example? i have tried it the same way and it didn’t work for me
What you need to do is instance the controllers themselves after adding the ca’s. I’ve made a couple additions to Paul’s script to show what I mean. (One correction to Paul’s script, which I’m sure he just overlooked, was to add the “ui:” paramater to each of the parameter definitions to make the spinner values “stick”. Without that the spinner values always returns to zero after you deselect the object.)
--Make a bunch O spheres and add attribute holder modifiers
sphs=#()
for x= 1 to 10 do
(
bm=emptyModifier()
sph=sphere pos:(random [-50,-50,-50] [50,50,50])
addModifier sph bm
append sphs sph
)
--Create a CA definitions
def=attributes test
(
parameters testP rollout:testR
(
test1Sp type:#float ui:test1Sp
test2Sp type:#float ui:test2Sp
)
rollout testR "Test"
(
spinner test1Sp "Test 1"
spinner test2Sp "Test 2"
)
)
--Add the definition to all the spheres attribute holder modifiers
for x in sphs do
(
custAttributes.add x.modifiers[1] def
)
-- create a controller for each of the spinners on the first sphere and then store it as a variable
con01 = sphs[1].modifiers[#Attribute_Holder].test.test1Sp.controller = bezier_float ()
con02 = sphs[1].modifiers[#Attribute_Holder].test.test2Sp.controller = bezier_float ()
-- assign the stored controller to each of the sphere's spinners, effectively instancing them so that when you change the value of one, all the others will update also
for x in sphs do
(
x.modifiers[#Attribute_Holder].test.test1Sp.controller = con01
x.modifiers[#Attribute_Holder].test.test2Sp.controller = con02
)
thanks for the help guys,
james: sorry but this won’t work in my case, i’d need this to work with maxObjectTabs and other parameter types, so i can’t copy the controllers
i don’t think you can easily instance the ca itself, but i have talked to mark tsang about this and he came up with a solution to my problem
to have the same parameter values across multiple ca’s you can store the parameters on a CA def on another node, then on all the modifiers you want the definition to be accessible from, have a version of the CA Def that copies the parameters from the ‘storage’ when the rollout opens (using “on rollout open” change handler) and copies changes back to the storage ca when the rollout closes (on rollout close), or using param change handlers
this way you can have the ca on various modifiers, and they can all use the same set of parameters
btw. i need this for CA Def that stores poses for multiple objects, and i want that ca to be visible on multiple control objects that all have different CA Defs on them already