How to get animation key values from a text file?

How to get animation key values from a text file?

Anonymous
Not applicable
1,699 Views
6 Replies
Message 1 of 7

How to get animation key values from a text file?

Anonymous
Not applicable

I try to make a tool, getting animation key values without opening a file.

I wonder if there a way to get animation key values from a text file.

I already tried to open maya text files and if my guess is right, the lines about key information are as following:

createNode animCurveTL -n "main_ctrl_translateZ";

           setAttr ".tan" 18;

           setAttr ".wgt" no;

           setAttr -s 2 ".ktv[0:1]"  101 0 120 7.0140664544235554;

I assume, the “main_ctrl_translateZ” has two key values, like frame 101 is value “0” and frame 120 is value “7.0140664544235554”. Is it right?

And the second curious thing is when there are more than two same assets in one file, why is controller’s attribution name different like "main_ctrl_translateZ1"

I could not match key values with controller because of random attribution name.

I attached a file and I appreciate if you can check it out.

Thank you for your further information.

0 Likes
1,700 Views
6 Replies
Replies (6)
Message 2 of 7

Roland.Reyer
Autodesk
Autodesk

Hi,

 

are you trying to READ the keyframes from a .ma file or do you want to WRITE keyfame data that you then need to import into Maya?

 

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi

I try to read key values from Maya ASCII file.

In my case, there are two types of rigging file, type “A” is for a minimum amount of data and type “B” is for rendering, including all the materials and object IDs, etc…

My working process as below:

  1. Setting Key frames using a type “A” and save a file in the name of ‘xxx_ani.ma’.
  2. Open a new maya file and load ‘xxx_ani.ma’ with a reference type. Then save a file in the name of ‘xxx_lit.ma’.
  3. Setting lights in the ‘xxx_lit.ma’.
  4. Change reference from type “A” to type “B” for rendering.

It is possible to edit keys in the ‘xxx_ani.ma’ file up to step 3, but it is impossible after doing step 4. Because edited keys are not reflected in the type “B”. This is really a problem.

If keys in ‘xxx_ani.ma’ were changed after step 4, it needs to open two files ‘xxx_ani.ma’ and ‘xxx_lig.ma’. Then, copy keys frame by frame from ‘xxx_ani.ma’ and paste keys to ‘xxx_lig.ma’. This is a difficult and time-consuming process.

So, I try to build up a new tool for copying Keys without opening a MAYA file like ‘xxx_ani.ma’.

I think it would be good if that just open the Maya scene(‘xxx_lit.ma’ file) and read edited keys from ‘xxx_ani.ma‘ using python code like open()/read() functions then automatically paste keys to ‘xxx_lit.ma’ file.

I hope the above is a sufficient explanation.

If anyone knows about this issue, would you please let me know.

Thank you.

0 Likes
Message 4 of 7

Roland.Reyer
Autodesk
Autodesk

Hi,

 

I'm not sure if I understand this correctly:

 

- You have a light character (A) and a production character (B).

- You need at animate the character (A)

- you want to reference (A) into a final scene, do the lighting

- later you want to swap out (A) for (B) and keep the animation of (A)

 

Have you tried to reference file (A) into the lighting scene, THEN do the animation (keyframes stay in the lighting file) and then swap (A) for (B)?

It certainly works for Scene Assemblies (Create->Scene Assembly) when the names for the animated objects.channels are the same. You swap the objects and the system reconnects the keyframes to the respective objects.

I'm pretty sure that it works also with referneces, but I don't know *how*.

0 Likes
Message 5 of 7

Anonymous
Not applicable

Thank you for your reply.

I think you understood correctly about my workflow.

 

Have you tried to reference file (A) into the lighting scene, THEN do the animation (keyframes stay in the lighting file) and then swap (A) for (B)?

=> Yes. (B) has keyframes same as (A) after swap with (A).

 

The question is keyframes of edited (A) after swapped (A) with (B) on a final scene.

It is okay that after swapped (A) with (B) on a final scene and edit keyframes of (A), If reference (A) into a final scene again and swap (A) for (B).

Also, I think it will work for “Scene Assemblies” like you mentioned above.

I want to avoid the complicated process like the above and want to make process simple by reading key values from Maya ASCII using python.

Are there any other ways to get keyframes from a .ma File?

Could you please check out the very first a .ma file I attached?

Thank you.

0 Likes
Message 6 of 7

Roland.Reyer
Autodesk
Autodesk

Reading and interpreting a .ma file in Python is certainly not easy.

 

The perfect interpreter for .ma files is Maya itself.

You could run Maya in batch to extract the animation from file A and import it into file B.

 

Scene Assembly lets you define B as the render version of the object. Whenever you animate the file you will only see A. Isn't that what you need?

 

0 Likes
Message 7 of 7

Anonymous
Not applicable

Okay, Roland.

Unfortunately, I do not know about running Maya in batch.

I think that Scene Assembly is better idea if I could not read a .ma file. I'll try Scene Assembly.

Thanks for your help.

0 Likes