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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2003   #1
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.
 
Old 03 March 2003   #2
You cna use "getAttr" with a -t for time.

ie:

float $currentTime = `currentTime -q`;
$rot5Earlier = `getAttr -t ($currentTime-5) myShin.rotateY`;

HOWEVER

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 - comet@comet-cartoons.com
www.comet-cartoons.com - Code Monkey
www.pixar.com - Pixar Animation Studios
 
Old 03 March 2003   #3
thanks
 
Old 03 March 2003   #4
Quote: Originally posted by michaelcomet
be warned that using any MEL command in ` back quoates ` is dangerous in expressions.



hehe..

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



cheers

alexx
 
Old 03 March 2003   #5
Alexx:

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.
 
Old 03 March 2003   #6
Would there be a way to do this without using an expression, and just through a Mel script?
 
Old 03 March 2003   #7
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
 
Old 01 January 2006   #8
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 05:02 AM.


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