SubAnim Name From Controller?


So if I have the controller can I get the subAnim name from it? What I’m looking to do is rebuild the subAnim name path but starting at the end with only the controller.


I’m not really sure if this is what you’re looking for but it might help,

getSubAnimNames $

Will give an array with subAnim names, if you only have a controller to start with and you want to get it’s node use “refs.dependents” like so

x = $.transform.controller
 refs.dependents  x

and it will return something like this:

#($Torus:Torus001 @ [-1599.989990,-0.000050,1139.296997], ReferenceTarget:NodeSelection, ReferenceTarget:ReferenceTarget, ReferenceTarget:ReferenceTarget)

Then you’ve got the node and subAnim names so I think you can create a full path from that.


does that also returns the objects material controllers if it has one?


it might be multiple subanims which use the same controller. so to find all subanims that use the controller you have to:

get parent controller(s) (node(s)) using [b]refs.dependents <controller> immediateOnly:on

[/b]go though all subanims of these nodes and find the subanim which controller is the same as your exploring controller


Thanks Denis, that is the mess I’m dealing with now. Instanced controllers make it impossible. So what I’m doing at the moment is just getting the nodes that are dependent and recursing from there till I find the correct instance of the controller that I have. Long winded for sure but it doesn’t need to be blazing fast.

I guess what you are suggesting Denis might be faster if I recurse in reverse, then go though the subAnimNames looking for the controller and keep backing up till the node. That would cut out lots of unnecessary recursion. I’ll do a rewrite when I get the time.

Was hoping some one had a really elegant solution.


This is what I have. Assumes that an object with a frozen transform is selected if you want to run it as is.

con=$.pos.track[2].track[3].track --Object with frozen transform
n=(refs.dependentNodes con)[1]

fn getSubAnimPathFromController con n p:("$"
	if n!=con then
		if subAnimPath=="" do
			for i = 1 to n.numSubs do
				if (n[i].track)!=undefined do
					getSubAnimPathFromController con n[i].track p:(p+"[#"+(getSubAnimName n i asString:true)+"]")
	)else subAnimPath=p

getSubAnimPathFromController con n
format "subAnimPath: %
" subAnimPath

Probably needs to be optimized.


the idea of using immediateOnly doesn’t works.
refs.dependents with immediateOnly option returns only first immediate node. which is wrong… but I found a nice trick.
refs.dependents is a recursive function but refs.dependson is not. Here we go:

 fn getImmediateDependents node = 
 	for d in (refs.dependents node) where finditem (refs.dependson d) node != 0 collect d
 fn getControllerSubAnim node =
 	subs = #()
 	for d in (getImmediateDependents node) do for k=1 to d.numsubs where d[k] == node do append subs d[k]
 	b = box()
 	s = sphere()
 	t = Taper()
 	c = t.amount.controller = s.radius.controller = b.rotation.controller[1].controller = b.position.controller[1].controller
 	getControllerSubAnim c


Interesting method Denis. Not sure that it is more or less work then what I have at this point but thanks.


how can I using your getSubAnimPathFromController function get paths for all subanims in my sample?

	b = box()
	s = sphere()
	t = Taper()
	c = t.amount.controller = s.radius.controller = b.rotation.controller[1].controller = b.position.controller[1].controller
	subanims = getControllerSubAnims c


I don’t really need it to do that so it isn’t. I would have to loop through all the objects that are dependent and do it for each one. I my case I’m just doing it for the first controller found.


the first subanim of a node is the Visibility… technically it can have a controller.


there is no problem to make a path for UNIQUE controller. is’t just:

exprForMAXObject <controller>

but i doesn’t work for controller which has multiple instances.


Sorry, I meant…

In my case I’m just doing it for the first NODE found.

exprForMaxObject doesn’t do what I need either as it doesn’t return the subAnimNames.


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.