Animating a facial expression

57 views
Skip to first unread message

Amr Gamal

unread,
May 28, 2021, 7:50:39 AM5/28/21
to Python Programming for Autodesk Maya
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?
Screenshot 2021-05-28 134912.png

Michael Eden

unread,
May 30, 2021, 9:45:01 AM5/30/21
to python_in...@googlegroups.com
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.

--
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_m...@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.
Reply all
Reply to author
Forward
0 new messages