PDA

View Full Version : Copy out Y axis numbers from object for every frame


PunchlineNetwork
10-19-2011, 07:48 AM
Hi everyone, I was wondering if any one would know a easier way to copy a polygons Y axis numbers for every frame for 252 frames. I have been manually doing that, and it is very very annoying and very easy to make mistakes.

If anyone has any better ways to do so, can you please please please tell me.

Thank you very much everyone!!!

whisperwing
10-24-2011, 10:34 PM
what do you mean "a polygons Y axis numbers", the translateY value of an object?
Copy from whom to whom? It seems to be something straightforward with a loop that go through the frames you want and apply the same action

Hi everyone, I was wondering if any one would know a easier way to copy a polygons Y axis numbers for every frame for 252 frames. I have been manually doing that, and it is very very annoying and very easy to make mistakes.

If anyone has any better ways to do so, can you please please please tell me.

Thank you very much everyone!!!

PunchlineNetwork
10-25-2011, 02:57 AM
what do you mean "a polygons Y axis numbers", the translateY value of an object?
Copy from whom to whom? It seems to be something straightforward with a loop that go through the frames you want and apply the same action

Thank you very much for the reply!

I have already made 196 cubes layed out 14*14, so it is a square, and I have animated each one of them to move in the Y axis. the animation is about 10s long, and I need to extract the movement number of Y axis for each of the cubes for every frame into a excel. This animation is a simulation of the real thing, so I need all the information so I can give to the guys who do the real thing to make it move according to the simulation.

I hope this explains.

whisperwing
10-25-2011, 06:59 AM
Here's something to get you started. You can totally do this in MEL if it's easier for you.
I'm using tab as separator, I think Excel will import a text file like that. Or use any other separator you want.
As to specifically how you want to do the formatting you'll have to make your own decision. You can write each frame into a different file too.

from maya import cmds as MayaCmds

# list the mesh objects of your interest: should be 196 elements in the list
cubes = MayaCmds.ls(type="mesh")
# this is the file you'll be writing into, assuming you write all the data into one file
f = open('/mcp/output.txt', 'w')
# you said 10s of animation, I assume it starts at frame 1 and ends at frame 240
startFrame = 1
endFrame = 240
# at each frame, iterate through each cube to get the transform value
for frame in range(startFrame, endFrame):
# force animation to evaluate at the current frame
MayaCmds.currentTime(frame)
for cube in cubes:
parentTransform = MayaCmds.listRelatives(cube, parent=True)
ty = MayaCmds.getAttr(parentTransform[0]+".ty")
f.write(str(ty)+"\t")
f.close()

CGTalk Moderation
10-25-2011, 06:59 AM
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.