Animation plot data


#1

Hi,

Does anybody know if there is a way to export the plot data from the graph editor in Maya? I can see the time/value plot data using Spreadsheet… from the Curves menu in the graph editor, but would like to be able to export this to create a graph in other software (such as MatLab or Excel) using time as the x axis and the value as the y axis.

Any ideas?

Cheers,

Andy


#2

You can easily do this with a script, either MEL or Python. The latter would probably be recommendable due to it’s more advanced string editing methods and most importantly the inclusion of an XML module.

Edit:

here’s some example python code. very simple, creates an xml on C: with the time/value information for every curve selected in the GraphEditor

import maya.cmds as cmds
from xml.dom.minidom import Document

xmlDoc = Document()

root = xmlDoc.createElement('curveData')
xmlDoc.appendChild(root)


animCurves = cmds.keyframe(query=True, name=True, sl=True)

for c in animCurves:
	
	curveElement = xmlDoc.createElement('curve')
	curveElement.setAttribute('name', str(c))
	root.appendChild(curveElement)
	keyTimes = cmds.keyframe(c, q=True, tc=True)
	for t in keyTimes:
		
		frameElement = xmlDoc.createElement('frame')
		curveElement.appendChild(frameElement)
		
		value = cmds.keyframe(c, time=(t,), q=True, vc=True)[0]
		frameElement.setAttribute('time', str(t))
		frameElement.setAttribute('value', str(value))
		
file = open('C:/animInfo.xml', 'w')
file.write(xmlDoc.toprettyxml())
file.close()

#3

Built in method (…read ‘Not pretty’)

File>Export[] choose move format.

Altho’ if I had need to do something like this often I’d write/use something like what Nyro was kind enough to write above :thumbsup:


#4

Many thanks for the reply’s. I couldn’t find a built in method, not sure I fully understood the post, but I have Export All and Export Selection, and I think this just relates to the objects within the scene rather than plot data for the anim curves.

I tried the script and got this error…

Error: IOError: 13

You’ll have to excuse my dumbness, I’ve no experience with scripting.


#5

Can you turn on linenumbers in errors? You can do that in the script Editors menu.

But just by looking at the error, I’m guessing you either a) don’t have a C: drive because you’re not on Windows (are you using a Mac?) or b) you don’t have file creation/write permission.


#6

Hi, yes with line numbers this is the error:

Error: line 1: IOError: file <maya console> line 27: 13

I am on windows and do have a C drive, and on my home PC so should have full permissions


#7

weird. works perfectly for me.

Try creating the file manually first (just create an empty textfile and rename it to animInfo.xml)


#8

Done.

Apparently I didn’t have permission to save to C: as you suggested earlier, and I found out when trying to create the file manually. Strange that - I must have changed the permissions at some point (or the computer has gone off on one)

I changed to save to my H: and it worked fine.

Thanks for your help!! (y)


#9

I couldn’t find a built in method, not sure I fully understood the post, but I have Export All and Export Selection, and I think this just relates to the objects within the scene rather than plot data for the anim curves.

File>Export Selection… File Of Type == move
select channels | From ChannelBox > Save
Saved move file has saved values of channels/time

I mainly use this for bring info in from afterEffects, but hey, it’s all plain text :slight_smile:


#10

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.