Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 14-07-2014 , 04:36 PM
Subscriber
Join Date: Sep 2013
Posts: 3

Keyframe simple maya loops in python?

Hey,

I have this very simple python script in Maya that I want to "animate".
I first want to adapt the end time of the animation to the number of iterations, in order to have enough keyframes for the animation.
After that I want to add a keyframe for the movement of the polyCube at each loop iteration to produce the moving animation.

Code:
import maya.cmds as mc

iterations = 10 #number of keyframes
transVal = 1 #translation value for each iteration

mc.polyCube(constructionHistory=True, width=1, height=1, depth=1)

for i in range(iterations):
    mc.move(transVal, cube, relative=True, moveZ=True)
    mc.setKeyframe(insert=True, value=i)
Would it alternatively be possible to add a keyframe at the beginning and one at the end and let maya calculate the motion tweens (like it does when using the UI)?

Any ideas?

Thanks.

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads