[Closed] How to collect modifiers controllers into an array
Hi,
I am trying to return an array of all the controllers within a specific modifier on one object.
I have found this script on previous related threads but cannont work out how extract only the tracks on the first modifier:
fn getScriptedControllers ref =
(
local ctrlList = #()
local refList = refs.dependsOn ref
for r in refList do
(
if (isProperty r #keyable == true) then
append ctrlList r
)
return ctrlList
)
Can anyone help?
Thanks in advance!
I haven’t got max here to test this on, but the following should print out a list of controllers to the listener. Set the first line to the modifier of which you wish to collect controllers.
mod = $.modifiers[1]
modProps = getPropNames mod
for p in modProps do
(
ctrl = getPropertyController mod p
if ctrl != undefined then print ctrl
)
Cheers,
Martijn
[color=white]Hi Martijn,
Thanks very much for your reply on this. When I ran the code this is what I got, Im not sure if the script needs a little tweaking to make it work…
– Cannot assign to read-only variable: mod
– No ““getPropNames”” function for mod()
– No “map” function for undefined
…I have however worked out a slightly convoluted way around my problem.
I actually specifically needed the script to enable me to instance all the controllers from the PEN_Attribute_Holder02 modifier on one object (that I am using for my facial rig) onto another object. This then allows me to have one master controller for the entire face as well as sub controllers for the eyelids/eyebrows, cheeks, and mouth areas.
It just takes soooo long to manually copy and paste all the controllers seperately.
With script you just select the object you want to copy the controllers from first then the object that requires the new controllers. Please note you must copy and paste the PEN_attribute_holder02 modifier from the source object onto the target object first.
Anyway here it is: (amyface is refering to the parameter block within the PEN modifier)
[size=1]getTracksObj=selection[1]
setTracksObj=selection[2]
ctrllist = #()
for n in 1 to 100 do
(
if getTracksObj.modifiers[1].amyface[n] != undefined then
(
append ctrllist getTracksObj.modifiers[1].amyface[n]
)
else()
)
print ctrllist
for n in 1 to ctrllist.count do[size=2]
(
setTracksObj.modifiers[1].amyface[n].controller=getTracksObj.modifiers[1].amyface[n].controller
)
[/size]
I hope that helps somebody out there.
Spence
[/color][/size]