accessing attributes at a certain frame

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  03 March 2003
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
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....
Michael B. Comet - - Code Monkey - Pixar Animation Studios
  03 March 2003
  03 March 2003
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

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
Mark R. Wilkins
author of MEL Scripting for Maya Animators

Last edited by mark_wilkins : 03 March 2003 at 11:03 PM.
  03 March 2003
Would there be a way to do this without using an expression, and just through a Mel script?
  03 March 2003
If you're writing a MEL script instead of an expression, just use the getAttr -t approach above and feel good about doing it!

-- Mark
Mark R. Wilkins
author of MEL Scripting for Maya Animators
  01 January 2006
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 10:46 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.