Say for example I have an array that contains the numbers which represent a subAnim controller.
How could I build a variable which would allow me to directly get to that controller.
(
delete objects
obj = teapot()
subIndexes = #(3,1,1) -- SubAnim:X_Position
clearlistener()
-- example b = obj[3][1][1]
-- I need to build an array with the subIndexes that would return SubAnim:X Position
-- Keep in mind that the length of the subIndexes could change depending on the situation.
)
By
Comments (8)
Comment policy
Anubis after further messing around your script returns just the controller, I need it to return the object and controller
ex. Yours returns
'subAnim: X_position'
I need
'Node[3][1][1]'
Which would be the controller path and the node.
Soory for intrusion. Maybe this will help
fn returnSubAnim obj arr = (
local sa = obj[arr[1]]
if arr.count > 1 do
for i = 2 to arr.count do
sa = sa[arr[i]]
exprForMaxObject sa -- return result
)
edit :)
edit
Now we will use again "excute" fn after u get the result from below fn
my function do what you ask for :)
You can work with both "subAnum.value = get/set value" or "controller.value = get/set value", but if you prefer the function to return controller instead of subAnim, then just change last line to "sa.track".
And Node[3][1][1] is still SubAnim. If you need string, then use
as Branko suggest.
Anubis! Hey bud.
Thanks for the snippet. It seems like that is more of what I'm after. I'm never a bit fan of execute. Thanks guys.
Hi John
or maybe just...
woops, I miss last note... the sub tree is not fixed to 3, right?
P.S. corrected:
Thank you very much
Hi John
Try this
fn returnSubAnim obj arr =
(
local str = "$"+obj.name
for i in 1 to arr.count do append str ("[" + arr[i] as string + "]")
execute str
)
tea = teapot()
subIndexes = #(3,1,1)
returnSubAnim tea subIndexes