Reputation: 309
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.
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 in the UI)?
Any ideas?
Thanks.
Upvotes: 0
Views: 2204
Reputation: 4434
Scripting in Maya is the same thing as using the GUI so yes its possible to do exactly the same thing as in GUI.
import maya.cmds as mc
distance = 10
timedelta = 10
cube = mc.polyCube(constructionHistory=True, width=1, height=1, depth=1)
mc.setKeyframe(cube[0], time=1, v=0, at='translateZ')
mc.setKeyframe(cube[0], time=timedelta, v=10, at='translateZ')
Upvotes: 1