0
votes

I am doing a keyframe scripted physics animation in Maya (with Python) and I want to show some vectors (results of the algorithm) that affect the animated objects.

To represent a vector I chose a curve:

import maya.cmds as cmds
vectorCurve = cmds.curve(d=1, p=[(x, y, z), (p, q, r)])

Then, when creating the keyframes for the animation, I do:

for i in range(300):
    #a,b,c,d,e,f values change every iteration
    cmds.move(a, b, c, vectorCurve + ".ep[0]", wd=True)
    cmds.move(d, e, f, vectorCurve + ".ep[1]", wd=True)

    cmds.setKeyframe(vectorCurve, time=i)

But when I run the script, the curves stay in their final position and do not move during the animation.

How could I set the animation keyframes for a (linear) curve correctly?

EDIT:
The curve actually has keyframes, but when I look into the keyed values in Channel Box, translate and rotate are all 0 and scale is 1 (for X, Y and Z).

1
I don't think you can animate straight on Edit Points, but you can probably bind them to a cluster handle, then animate this cluster? Edit: Could be worth trying setKeyframe with controlPoints=True, I'm not sure. Standard is definitely just TRSDaniel Skovli
@itypewithmyhands I added controlPoints=True to setKeyframe and it worked! Thank you very much, I must have overlooked it in the documentation. Now the curves move and change with the rest of the animation. Should I add it as an answer to this question or is it enough that it is in the comments?Zdeněk
@itypewithmyhands Just to clarify for potential future use, what exactly is a cluster handle? I could only find a cluster deformer (knowledge.autodesk.com/support/maya/learn-explore/caas/…) is it just two names for the same thing or is it something different?Zdeněk
Yeah that cluster deformer is what I was referring to, just using a the wrong terminology. I'll add an answer to this question based on our comment thread, so future Googlers can find the solution a bit easier :)Daniel Skovli

1 Answers

0
votes

As discussed in the comments, OP's issue was solved by specifying that control points should also be keyed:

# Original code
cmds.setKeyframe(vectorCurve, time=i)

# Becomes
cmds.setKeyframe(vectorCurve, time=i, controlPoints=True)