Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Exporting Animation Data (Translation, Rotation, Scale)
  RSS 2.0 ATOM  

Exporting Animation Data (Translation, Rotation, Scale)
Rate this thread
 
20132
 
Permlink of this thread   Subscribe to this thread
avatar
  • Total Posts: 12
  • Joined: 03 April 2008 08:23 PM

Does anyone have a script that exports Maya animation data (Translation, Rotation, Scale) into notepad or anything else?



Replies: 0
avatar
  • Kym Watts
  • Posted: 08 December 2008 07:22 PM

Are you after transforns or deformation?
Can you give use a better idea what you want to do with the data?

ie, is it a single locator, a sphere with 20 faces or a rigged bear with hair simulations?

Cheers
Kym



Replies: 0
avatar

No deformation, just a single object moving.  For example a plane flying in the air, no landing gear or rotors spinning, just a plane doing an air show; climbing and diving and doing barrel rolls.



Replies: 0
avatar
  • Kym Watts
  • Posted: 09 December 2008 02:20 PM

Hey There,

Here is some code you can use to write out the basic functionallity or at least put you in the right direction.
All you need to do now is read the docs on how the xform tool works to work out how to extract the rotations and scale for the object.

snip-->
// where ever you want to open the file that you want to write to.
string $animFile = “c:/temp/animation.txt”;

// opeing the file in a file handel
int $fileId = `fopen $animFile “w"`;

// now the file is open, writing a mel style comment to the top.
fprint($fileId,"\/\/this is my per frame animation file\n");

// getting the start and end frames of the animation from the render globals, you can get this infor from any where or hardcode it.
int $startFrame = `getAttr “defaultRenderGlobals.startFrame"`;
int $endFrame = `getAttr “defaultRenderGlobals.endFrame"`;

// this is my object transform, the ojject i want its animation
string $object = “persp”;

// simple line to show the format of my file.
// \t is a tab space
fprint($fileId,"attr\t\t frame \t\t x\t\t y\t\t z \n");

// $current frame is my increment var
int $currentFrame = $startFrame;

// my chossen loop for this exersize , giving the end frame a padding of 1.
while ($currentFrame != ($endFrame+1))
{
//setting the maya timeline to my current frame
currentTime -e $currentFrame;

//get transformations using the xform tool.
float $trans[] = `xform -q -t -ws $object`;
//writting the formatted line to the file
fprint($fileId,"trans “+$currentFrame+” “+$trans[0]+"\t\t"+$trans[1]+"\t\t"+$trans[2]+" \n");

// read xform on how to get the rotation and scale of an ojbect.


//incrementing the count.
$currentFrame++;
}
// closing the file handle
fclose $fileId;
<--snip

Another way you could do this, but its more complicated to read the files in, is to export out the meshes to mi files with mentalray.
But at least the above code will put you in the right direction.

Hope this helps.
Cheers
Kym



Replies: 0
avatar

Have you tried the animImportExport.mll? Its been in Maya1 and beyond. It lets you export as a .anim file that has animation data in it.



Replies: 0




   
  Settings Choose Theme color: