hello, how about this?

# query current frame
timeNow = cmds.currentTime(q=True)
# [[object name, translation x, y, z moving value]]
listToAnimate = [["pCube1", [5, 3, 2]],
                ["pCube2", [3, 6, 7]],
                ["pCube3", [8, 7, 1]]]

for object in listToAnimate:
    cmds.currentTime(timeNow)
    # set the keyframe in current frame
    cmds.setKeyframe(object[0])
    # jump to the frame where animation ends.
    cmds.currentTime(timeNow + 10)
    # set current translation value
    cmds.setAttr("{}.tx".format(object[0]), object[1][0])
    cmds.setAttr("{}.ty".format(object[0]), object[1][1])
    cmds.setAttr("{}.tz".format(object[0]), object[1][2])
    # re-key the object
    cmds.setKeyframe(object[0])

cheers.

On Fri, May 28, 2021 at 8:50 PM Amr Gamal <lordmoo...@gmail.com> wrote:

> def happyAttributes(): defaultFaceAttributes()
> cmds.setAttr("Dude_Lt_Mouth_Crnr_Ctrl.tx",-1.735)
> cmds.setAttr("Dude_Lt_Mouth_Crnr_Ctrl.ty",3.41)
> cmds.setAttr("Dude_Rt_Mouth_Crnr_Ctrl.tx",-1.735)
> cmds.setAttr("Dude_Rt_Mouth_Crnr_Ctrl.ty",3.41)
> cmds.setAttr("Dude_Lt_Brow_2_Ctrl.ty",2.943559)
> cmds.setAttr("Dude_Rt_Brow_2_Ctrl.ty",2.943559)
>  cmds.setAttr("Dude_Jaw_Ctrl.ty",-5.681)
>
>
> This function makes a certain facial expression on the 3D character model,
> how do I make this animated as in I want to make the attribute values
> change gradually?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/2898908b-8837-4037-a0cc-ede29ea89ac1n%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/2898908b-8837-4037-a0cc-ede29ea89ac1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CABSWsiZCxnf_mNqN2M%3DLHJjag1jwPu-JYCDOsDDb2hB81PbMnQ%40mail.gmail.com.

Reply via email to