CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 07-03-2013, 11:21 AM   #1
andyman121
Veteran
portfolio
Andrew Brownridge
Manchester, United Kingdom
 
Join Date: Oct 2010
Posts: 75
Writing returned values to plot a graph

Hi there,

I have a script which returns Euler angles of a specific joint at the frame which the script is run at. What I am wanting to do is run this script throughout the animation to plot the returned Euler angles for every frame over time.

Code:
import maya.cmds as cmd from vectors import Matrix localHips = Matrix( cmd.getAttr( 'BVH:Hips.matrix' ) ) localUpLeg = Matrix( cmd.getAttr( 'BVH:RightUpLeg.matrix' ) ) localLeg = Matrix( cmd.getAttr( 'BVH:RightLeg.matrix' ) ) localFoot = Matrix( cmd.getAttr( 'BVH:RightFoot.matrix' ) ) localHeel = Matrix( cmd.getAttr( 'BVH:RightFootHeel.matrix' ) ) localEnd = Matrix( cmd.getAttr( 'BVH:RightFootHeel_End.matrix' ) ) worldHips = Matrix( cmd.getAttr( 'BVH:Hips.worldMatrix' ) ) worldUpLeg = Matrix( cmd.getAttr( 'BVH:RightUpLeg.worldMatrix' ) ) worldLeg = Matrix( cmd.getAttr( 'BVH:RightLeg.worldMatrix' ) ) worldFoot = Matrix( cmd.getAttr( 'BVH:RightFoot.worldMatrix' ) ) worldHeel = Matrix( cmd.getAttr( 'BVH:RightFootHeel.worldMatrix' ) ) worldEnd = Matrix( cmd.getAttr( 'BVH:RightFootHeel_End.worldMatrix' ) ) eulerXYZ = localFoot.ToEulerXYZ( degrees=True ) print eulerXYZ


This is the script, which returns
[8.089659570923553 -7.1246470579741645 0.30448006832249608]

How might I go about plotting these angles (or 1 of these angles e.g. rotateZ) over say 160 frames? Perhaps write them to an xml file or something?

Cheers,

Andy
 
Old 07-07-2013, 12:22 AM   #2
palohman
Frequenter
portfolio
Paul Lohman
Tech Artist
EA
Orlando, USA
 
Join Date: May 2004
Posts: 144
just in case you're an engineer and not an animator or possibly don't know maya very well I'll get this out of the way;
There's already a built-in UI for that, called the graph editor, shows a plotted curve of selected nodes animated attributes over time, attributes like rotation.

If you just said "no shit, I want something else that the graph editor doesn't do", then;
yes you could write the data to a text file, cvs, xml, etc, see python docs on Input and Output.
Incidentally you could also just query the graph editor for this info all at once instead of getting it one tick at a time.
__________________
blogfolio
 
Old 07-07-2013, 09:07 AM   #3
andyman121
Veteran
portfolio
Andrew Brownridge
Manchester, United Kingdom
 
Join Date: Oct 2010
Posts: 75
Hi palohman, thanks for replying.

Yes I'm familiar with Maya and the graph editor. The trouble with this for what I want is that it only plots the values which are displayed in the channel box/attribute editor.

What I am wanting to plot is something which isn't in there. I have a script which computes the Euler angles by decomposing the transformation matrix of a given node - in this case, the ankle joint of a character. The script however calculates this for the frame that it is run, and what I want is for each frame of the animation to be calculated and the results written to a text file (ideally xml) so that I can use the results to plot a graph.

I would presume the code given in the previous post (or at least the last line of it) needs putting into a loop so that it runs for each frame of the animation and writes this to a text file. The problem is I'm no programmer by any stretch of the imagination and don't have a clue how to go about this.

Hope that makes sense, and somebody will be able to help me out

Andy
 
Old 07-07-2013, 05:06 PM   #4
palohman
Frequenter
portfolio
Paul Lohman
Tech Artist
EA
Orlando, USA
 
Join Date: May 2004
Posts: 144
Code:
myFile = filePath+fileName f = open(myFile ,'a') for i in range(startTime,endTime): cmds.currentTime(i) # sets the time to that frame info = getSomeInfo() f.write(info) f.close()

if you want to use the playback range to define the start/end time
Code:
startTime = int( cmds.playbackOptions( q=True, minTime=True ) ) endTime = int( cmds.playbackOptions( q=True, maxTime=True ) )
__________________
blogfolio
 
Old 07-07-2013, 05:06 PM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:27 PM.


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