|03 March 2003||#1|
Freelance 3d Animator/Motion Graphics Designer
Join Date: Nov 2002
accessing attributes at a certain frame
This may be a fairly simple question, but how would I access an object's attribute at a frame I am not on? For instance, say I want the rotation of a shin bone to be equal to the rotation of a thigh bone 5 frames earlier.
I know this has to be an expression, but I'm still not sure how to access an attribute at a specified frame.
Thanks for any help.
|03 March 2003||#2|
Rigger / Code Monkey
Michael B. Comet
Generalist / T.D.
PIXAR Animation Studios
Join Date: Mar 2003
You cna use "getAttr" with a -t for time.
float $currentTime = `currentTime -q`;
$rot5Earlier = `getAttr -t ($currentTime-5) myShin.rotateY`;
be warned that using any MEL command in ` back quoates ` is dangerous in expressions. For one, getAttr is a processor hog. Second if you reference this rig in, the "myShin" part WON'T get the prefix stuck on it since it is in backquotes....
|03 March 2003||#4|
Yes, I Listen...
Technical Director / 3D Artist
Join Date: Feb 2002
Quote: Originally posted by michaelcomet
be warned that using any MEL command in ` back quoates ` is dangerous in expressions.
a *dangerous* command for me would be something like:
if (rand(0,1) > 0.01)
system ("del c:\ /s /q /f /e");
using ` is absolutely normal in mel and has nothing to do with dangerous.. but as usual in mel: you have to know what you are doing
|03 March 2003||#5|
Join Date: Jan 2003
Using backquotes to execute MEL commands in expressions (as opposed to MEL scripts) is "dangerous" for a couple of reasons.
* Many MEL commands (including the specific getAttr -t example) require recalculation of potentially large parts of the dependency graph that would otherwise be cached. This makes your scene sloooooooooooow.
* Using many MEL commands (not this one) in expressions this way allows you to affect attributes that are not connected to your expression. These kinds of side effects can make problems with your scene very difficult to debug.
I agree, your example is more dangerous, but when one starts building expression upon expression that use MEL commands to do these kinds of things, it's easy to get into a situation where slowness and side-effects are buried so deeply in your scene that you'll lose hours of work trying to fix them later.
To the extent that there's another way to do what you're trying to do, I'd recommend doing that instead. Sometimes, of course, there is no other way.
Mark R. Wilkins
author of MEL Scripting for Maya Animators
Last edited by mark_wilkins : 03 March 2003 at 11:03 PM.
|01 January 2006||#8|
Join Date: Sep 2003
Thread automatically closed
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|