Script to Convert Channel Animation to CSV File

Script to Convert Channel Animation to CSV File

Anonymous
Not applicable
1,451 Views
3 Replies
Message 1 of 4

Script to Convert Channel Animation to CSV File

Anonymous
Not applicable

I'm new to both Python and Maya, but not new to programming or animation, and I'm trying to do something a bit weird.

 

I'd like to create a script that searches through all bones and control sliders in an already rigged scene, retrieving all animation channels that contain a certain string for use in a later part of the script. Is this possible? Alternately, is it possible to have a popup appears like that of the File->Export Selection operation, asking for a channel or channels as input?

 

I'm trying to find a way to export frame-by-frame and/or keyframe data as a .txt or .csv file for simulation purposes.

0 Likes
1,452 Views
3 Replies
Replies (3)
Message 2 of 4

lee.dunham
Collaborator
Collaborator

All of that is certainly possible.

Do you have some progress on a script that we could help with? 

Check out the following maya commands to start;

ls, listAttr, getAttr, fileDialog2

 

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

At the moment I only have pseudocode

#select all objects that have an attribute called "Rotary Output" or "Linear Output"
#store number of control objects as an integer

#provide UI with the following features:
#    select which control object(s) to export data from
#        select all button
#        checkboxes next to list of names (sans "_ctrl")
#    input frame rate (defaults to current document framerate or 24)
#    Export Options:
#        all frames in range
#        keyframes in range
#    select location for .csv file to be saved
#    input file name and version number separately
#    Export button and Cancel Button

#Export button triggers a method/function that does the following
#create a 2D array of floats or doubles; dimension: (num of selected objects + 1) x num of frames
#loop from the first frame until the last frame
#    store time (itarator variable/framerate - starting frame) in the first column of the array (index 0)
#    if "all frames" selected
#        loop through selected control objects and store the value in the attribute called "Linear Output" or "Rotary Output" in teh array
#    if "keyframes" selected
#        loop through selected control objects and store the ouput values if there is a keyframe there
#loop through the array once for each control object, writing the time (column 0) and the onject output to a file

#format the file as a .csv and save it to the selected location
#display message saying the task has been completed

For context, all the relevant objects (rigged sliders) are locked so they are only able to move along or rotate about one axis. These objects contain special attributes called "Rotary Output" or "Linear Output." These attributes contain the data I'd like to export.

I checked out the four commands recommended, and I definitely think those will be useful in implementing the above pseudocode.

0 Likes
Message 4 of 4

menghui6WUWM
Contributor
Contributor

This is also my interest! 

Is there anyone know how to export csv file for my animated skeleton in maya? 

 

0 Likes