SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / Maya Expression - Value of Object Attribute at specific frame
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 10-01-2010, 01:21 PM   #1
Ecker00
Registered User
 
Join Date: Jan 2010
Location: UK & Norway
Posts: 4
Thanks: 0
Thanked 4 Times in 4 Posts
Default Maya Expression - Value of Object Attribute at specific frame

Hi!
To get the value of an objects attribute at the CURRENT time is just to write:

ObjectName.AttributeName

But what if I want to get the value of the objects attribute at a SPECIFIC time?
Would be grateful for a fast reply, cheers!
Ecker00 is offline   Reply With Quote
The Following User Says Thank You to Ecker00 For This Useful Post:
Old 10-01-2010, 05:46 PM   #2
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,988
Thanks: 33
Thanked 532 Times in 471 Posts
Default

Nasty little hack-together:

// set below
//===================
$object = "polySphere1";
$attribute = "radius";
$getAtTime = 24;

// don't touch below
//===================
$oldTime = `currentTime -q`;

currentTime $getAtTime;

$value = `getAttr ($object + "." + $attribute)`;

currentTime $oldTime;

// do something with the result
print $value;
__________________
Imagination is more important than knowledge.
NextDesign is offline   Reply With Quote
The Following User Says Thank You to NextDesign For This Useful Post:
Old 10-01-2010, 08:40 PM   #3
Ecker00
Registered User
 
Join Date: Jan 2010
Location: UK & Norway
Posts: 4
Thanks: 0
Thanked 4 Times in 4 Posts
Default

THANK YOU SO MUCH!
That was exactly what i needed! Was going nuts because I couldn't find a way to do that. I was sure it was an easier way to do it, but this method works great!

Basically now I've made a script with make my characters feet move correctly according to the ground. So I animate him to walk on the spot, and the scripts moves him correctly on the ground according to the movement of his feet.

I'm very new to Maya, and this is my first real project (making a dance), and this will make my life a lot easier!


Cheers man!
Ecker00 is offline   Reply With Quote
The Following User Says Thank You to Ecker00 For This Useful Post:
Old 11-01-2010, 01:47 AM   #4
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,988
Thanks: 33
Thanked 532 Times in 471 Posts
Default

No problem mate. Glad to help out.
__________________
Imagination is more important than knowledge.
NextDesign is offline   Reply With Quote
The Following User Says Thank You to NextDesign For This Useful Post:
Old 11-01-2010, 07:42 AM   #5
bendingiscool
Subscriber
 
bendingiscool's Avatar
 
Join Date: Jul 2006
Location: London
Posts: 567
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey there,

As you are new to all this it's probably not so important, but if you want to get realistic motion, you are going to have to think about getting the feet not to slide along the floor.

Unless you have already accounted for that in some way?

cheers,
Chris
bendingiscool is offline   Reply With Quote
The Following User Says Thank You to bendingiscool For This Useful Post:
Old 11-01-2010, 05:25 PM   #6
Ecker00
Registered User
 
Join Date: Jan 2010
Location: UK & Norway
Posts: 4
Thanks: 0
Thanked 4 Times in 4 Posts
Default

@ bendingiscool
Hi, that is the basic idea behind the script. As I had problems with the characters feet sliding on the ground. So the script calulates how the character would move around according to the animation of the feet. If that makes sense... or just look at this crap example I put together in 5 min: LINK
Ecker00 is offline   Reply With Quote
The Following User Says Thank You to Ecker00 For This Useful Post:
Old 11-01-2010, 06:40 PM   #7
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,988
Thanks: 33
Thanked 532 Times in 471 Posts
Default

You usually always want to animate the center of gravity by hand, as this is where a lot of the illusion of weight comes from.

In your case, you need to animate the root translation node, as well as the center of gravity to create a good look.

You application of the script looks cool though! You just need to find a way to be able to create some animation on top of the generated animation. Perhaps by having a locator, parented to another. The script run on the child, and you animation the parent. You then parent constrain the child locator to the center of gravity.

See if that works.
__________________
Imagination is more important than knowledge.

Last edited by NextDesign : 11-01-2010 at 06:45 PM.
NextDesign is offline   Reply With Quote
The Following User Says Thank You to NextDesign For This Useful Post:
Old 11-01-2010, 06:58 PM   #8
Ecker00
Registered User
 
Join Date: Jan 2010
Location: UK & Norway
Posts: 4
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Thanks for the tips NextDesign!
I really see what you mean, and I've been thinking about it. Because it's hard to make it look natural doing animation with math. It's smart to have manual controle over everything so the script don't overrun natural motion. I'll try the method you mentioned, was a good idea.

Thanks once again! =)
Ecker00 is offline   Reply With Quote
The Following User Says Thank You to Ecker00 For This Useful Post:
New Thread

« Previous Thread | Next Thread »

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Moderators on Simply Maya Miss_Nova Site News & Announcements 21 17-05-2011 12:24 AM
Maya Hair/Polygon Error ingram_no.7 Members Lounge 13 10-12-2010 10:27 AM
LayoutTools for Maya 2011 is here... ctbram Members Lounge 1 06-12-2010 10:32 PM
Open a Lightwave file in Maya 2011 radiant777 Maya Basics & Newbie Lounge 2 04-12-2010 02:45 AM

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.