View Full Version : accessing attributes at a certain frame
03-27-2003, 06:22 PM
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-27-2003, 06:43 PM
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-27-2003, 06:55 PM
03-27-2003, 09:09 PM
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-27-2003, 11:01 PM
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.
03-29-2003, 10:05 PM
Would there be a way to do this without using an expression, and just through a Mel script?
03-31-2003, 10:12 AM
If you're writing a MEL script instead of an expression, just use the getAttr -t approach above and feel good about doing it! :D
01-14-2006, 07:00 PM
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.