當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.setKeyframe方法代碼示例

本文整理匯總了Python中maya.cmds.setKeyframe方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.setKeyframe方法的具體用法?Python cmds.setKeyframe怎麽用?Python cmds.setKeyframe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.setKeyframe方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: attrSampling

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def attrSampling(node, attr, minVal, maxVal, interval=1):
    """
    Args:
      node (str)
      attrs (list)
      minVal (float)
      maxVal (float)
      interval (int)
    
    Returns:
      int
    """    
    currTime = cmds.currentTime(q=1)
    currVal = cmds.getAttr('%s.%s' % (node, attr))
    vals = [currVal, currVal+minVal, currVal+maxVal, currVal]

    for i, v in enumerate(vals):
        if i not in [0, len(vals)-1] and (currVal - v) == 0:
            continue
        
        cmds.setKeyframe(node, at=attr, v=v, t=currTime)
        currTime += interval
    return currTime

#---------------------------------------------------------------------- 
開發者ID:WebberHuang,項目名稱:DeformationLearningSolver,代碼行數:27,代碼來源:samplingFunc.py

示例2: bakeJointMotion

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def bakeJointMotion(skinJoints, skinMatrix):
    asl = om.MSelectionList()
    for sj in skinJoints:
        asl.add(sj.path)
    om.MGlobal.setActiveSelectionList(asl)
    startTime = oma.MAnimControl.animationStartTime()
    endTime = oma.MAnimControl.animationEndTime()
    frame = 0
    ctime = startTime
    oma.MAnimControl.setCurrentTime(ctime)
    while ctime <= endTime:
        oma.MAnimControl.setCurrentTime(ctime)
        for jid, sj in enumerate(skinJoints):
            m = om.MMatrix(np.dot(sj.bindPose, skinMatrix[jid, frame]).tolist())
            m = om.MTransformationMatrix(m)
            om.MFnTransform(sj.path).setTransformation(m)
        cmds.setKeyframe()
        frame = frame + 1
        ctime = ctime + 1
    oma.MAnimControl.setCurrentTime(startTime) 
開發者ID:TomohikoMukai,項目名稱:ssds,代碼行數:22,代碼來源:main.py

示例3: test_getattrtime

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def test_getattrtime():
    """getAttr(time=)"""
    transform = cmdx.createNode("transform")

    for time, value in ((1, 1.0),
                        (10, 10.0)):
        cmds.setKeyframe(str(transform),
                         time=[time],
                         attribute="translateY",
                         value=value)
    cmds.keyTangent(str(transform),
                    edit=True,
                    time=(1, 10),
                    attribute="translateY",
                    outTangentType="linear")

    # These floating point values can differ ever so slightly
    assert_almost_equals(transform["ty"].read(time=1), 1.0, places=5)
    assert_almost_equals(transform["ty"].read(time=5), 5.0, places=5)
    assert_almost_equals(transform["ty"].read(time=10), 10.0, places=5) 
開發者ID:mottosso,項目名稱:cmdx,代碼行數:22,代碼來源:tests.py

示例4: minimizeRotationCurves

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def minimizeRotationCurves(obj):
    '''
    Sets rotation animation to the value closest to zero.
    '''

    rotateCurves = mc.keyframe(obj, attribute=('rotateX','rotateY', 'rotateZ'), query=True, name=True)

    if not rotateCurves or len(rotateCurves) < 3:
        return

    keyTimes = mc.keyframe(rotateCurves, query=True, timeChange=True)
    tempFrame = sorted(keyTimes)[0] - 1

    #set a temp frame
    mc.setKeyframe(rotateCurves, time=(tempFrame,), value=0)

    #euler filter
    mc.filterCurve(rotateCurves)

    #delete temp key
    mc.cutKey(rotateCurves, time=(tempFrame,)) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:23,代碼來源:ml_utilities.py

示例5: setAnimValue

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def setAnimValue(plug, value, tangentType=None):
    '''
    Sets key if the channel is keyed, otherwise setAttr
    '''

    if mc.keyframe(plug, query=True, name=True):
        mc.setKeyframe(plug, value=value)
        if tangentType:
            time = mc.currentTime(query=True)
            itt = tangentType
            ott = tangentType
            if tangentType == 'step':
                itt = 'linear'
            mc.keyTangent(plug, time=(time,), edit=True, itt=itt, ott=ott)

    mc.setAttr(plug, value) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:18,代碼來源:ml_utilities.py

示例6: cutUnselected

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def cutUnselected(selectionOption=1, setKey=True):

    keySel = _getKeySelection(selectionOption)
    start = None
    end = None
    if keySel.keyRange():
        start, end = keySel.time
    else:
        start, end = utl.frameRange()

    if setKey:
        if keySel.findKeyframe('previous', time=(start,)) < start:
            mc.setKeyframe(keySel.curves, time=(start,), insert=True)
        if keySel.findKeyframe('next', time=(end-1,)) > end-1:
            mc.setKeyframe(keySel.curves, time=(end-1,), insert=True)

    keySel.cutKey(time=(':'+str(start),))
    keySel.cutKey(time=(str(end)+':',)) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:20,代碼來源:ml_animCurveEditor.py

示例7: rippleCut

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def rippleCut(selectionOption=1, setKey=True):

    keySel = _getKeySelection(selectionOption)

    if keySel.selectedFrameRange():pass
    else: return

    start, end = keySel.time

    if setKey:
        if keySel.findKeyframe('previous', time=(start-1,)) < start-1:
            mc.setKeyframe(keySel.curves, time=(start-1,), insert=True)
        if keySel.findKeyframe('next', time=(end,)) > end:
            mc.setKeyframe(keySel.curves, time=(end,), insert=True)
        mc.setKeyframe(keySel.curves, time=(start-1,end), insert=True)

    keySel.cutKey()

    #move everything after the cut
    keySel.keyframe(edit=True, time=(str(end)+':',), relative=True, timeChange=start-end) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:22,代碼來源:ml_animCurveEditor.py

示例8: __keyframe_nodes_callback

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def __keyframe_nodes_callback(*args):
    """Wrapper function to call Maya's setKeyframe command on given controls

    Args:
        list: callback from menuItem
    """

    cmds.setKeyframe(args[0]) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:10,代碼來源:dagmenu.py

示例9: keySel

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def keySel():
    """Key selected controls"""

    pm.setKeyframe()

# ================================================ 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:8,代碼來源:anim_utils.py

示例10: keyObj

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def keyObj(model, object_names):
    """Set the keyframe in the controls pass by a list in obj_names variable

    Args:
        model (Str): Name of the namespace that will define de the model
        object_names (Str): names of the controls, without the name space

    Returns:
        None
    """
    with pm.UndoChunk():
        nodes = []
        nameSpace = getNamespace(model)
        for name in object_names:
            if nameSpace:
                node = getNode(nameSpace + ":" + name)
            else:
                node = getNode(name)

            if not node:
                continue

            if not node and nameSpace:
                mgear.log("Can't find object : %s:%s" % (nameSpace, name),
                          mgear.sev_error)
            elif not node:
                mgear.log("Can't find object : %s" % (name), mgear.sev_error)
            nodes.append(node)

        if not nodes:
            return

        pm.setKeyframe(*nodes) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:35,代碼來源:anim_utils.py

示例11: keyAll

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def keyAll(model):
    """Keyframe all the controls inside the controls group

    Note: We use the workd "group" to refer to a set in Maya

    Args:
        model (PyNode): Rig top node
    """
    controlers = getControlers(model)
    pm.setKeyframe(controlers) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:12,代碼來源:anim_utils.py

示例12: keyGroup

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def keyGroup(model, groupSuffix):
    """Keyframe all the members of a given group

    Args:
        model (PyNode): Rig top node
        groupSuffix (str): The group preffix
    """
    controlers = getControlers(model, groupSuffix)
    pm.setKeyframe(controlers)

# ================================================ 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:13,代碼來源:anim_utils.py

示例13: bakeSprings

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def bakeSprings(model=None):
    """Bake the automatic spring animation to animation curves

    Args:
        model (dagNode): The rig top node
    """

    # filters the root node from selection
    if not model:
        model = getRootNode()

    print("Using root: {}".format(model))

    # first clear animation
    clearSprings(model)

    # bake again
    springNodes = getControlers(model, gSuffix=PLOT_GRP_SUFFIX)
    if springNodes:

        start = pm.playbackOptions(q=True, min=True)
        end = pm.playbackOptions(q=True, max=True)
        ct = start
        for i in range(int(end - start) + 1):
            pm.currentTime(int(ct))
            pm.setKeyframe(springNodes, insertBlend=True, attribute='rotate')
            ct += 1 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:29,代碼來源:anim_utils.py

示例14: cutEarlier

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def cutEarlier(selectionOption=1, setKey=True):

    keySel = _getKeySelection(selectionOption)
    keySel.fromBeginning()
    if setKey and keySel.findKeyframe('previous', time=(keySel._timeRangeEnd,)) < keySel._timeRangeEnd :
        mc.setKeyframe(keySel.curves, time=keySel._timeRangeEnd)
    keySel.cutKey() 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:9,代碼來源:ml_animCurveEditor.py

示例15: cutLater

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setKeyframe [as 別名]
def cutLater(selectionOption=1, setKey=True):

    keySel = _getKeySelection(selectionOption)
    keySel.toEnd()
    timeValue = keySel._timeRangeStart-keySel.shortestTime
    if setKey and keySel.findKeyframe('next', time=(timeValue,)) > timeValue:
        mc.setKeyframe(keySel.curves, time=(timeValue,))
    keySel.cutKey() 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:10,代碼來源:ml_animCurveEditor.py


注:本文中的maya.cmds.setKeyframe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。