Notifications
Clear all

[Closed] array path to controller

Say for example I have an array that contains the numbers which represent a subAnim controller path.
I’m trying to build a function that would return the controller and node’s complete path.
How could I build a variable which would allow me to directly get to that controller.

example:


m = returnSubAnim $Teapot #(3,1,1)
print m
--printed "$Teapot[1][1]"

Working code, but I’m not a fan of execute


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)

clearlistener()
m = (returnSubAnim tea subIndexes)

m.value = 10


6 Replies
1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

You can use also


fn returnSubAnim obj arr val: =
(
	local str = "$"+obj.name
	for i in 1 to arr.count do append str ("[" + arr[i] as string + "]")
	m = execute str
	if val != unsupplied do m.value = val
)
tea = teapot()
subIndexes = #(3,1,1)
returnSubAnim tea subIndexes val:100

Working code, but I’m not a fan of execute

Yes I never feel comfortable using it. I’ve never understood why the scope has to be global. Why can’t it just be in the scope of the code where it’s executed?

Cg.

seems like no matter what the execute will have to be used. I’m going to keep searching around.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

what do you know about exprForMAXObject?

I know that it is awesome ! and life saver at times

I’ve never heard of that. It seems rather awesome!
Thank you for sharing that!