当前位置: 首页>>代码示例>>Python>>正文


Python cmds.keyframe方法代码示例

本文整理汇总了Python中maya.cmds.keyframe方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.keyframe方法的具体用法?Python cmds.keyframe怎么用?Python cmds.keyframe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.keyframe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ui

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def ui():
    '''
    User interface for ml_setKey
    '''

    with utl.MlUi('ml_setKey', 'SetKey', width=400, height=220, info='''Press Set Key to set a keyframe with the current checkbox settings.
Right click the button to create a hotkey or shelf button
with the currently selected settings.''') as win:

        mc.checkBoxGrp('ml_setKey_chanBox_checkBox', label='Selected Channels', annotation='Only key channels that are selected in the Channel Box')
        mc.checkBoxGrp('ml_setKey_graphVis_checkBox', label='Visible in Graph Editor', annotation='Only key curves visible in Graph Editor')
        mc.checkBoxGrp('ml_setKey_keyKeyed_checkBox', label='Key Only Keyed Channels', annotation='Only set keys on channels that are already keyed')
        mc.checkBoxGrp('ml_setKey_subFrames_checkBox', label='Delete Sub-Frames', annotation='Delete sub-frame keys surrounding the current frame')
        mc.checkBoxGrp('ml_setKey_insert_checkBox', label='Insert Key', annotation='Insert key (preserve tangents)')
        mc.checkBoxGrp('ml_setKey_shapes_checkBox', label='Key Shapes', annotation='Set keyframes on shapes')

        win.ButtonWithPopup(label='Set Key', name=win.name, command=setKey, annotation='Set a keyframe.',
            readUI_toArgs={
                'selectedChannels':'ml_setKey_chanBox_checkBox',
                'visibleInGraphEditor':'ml_setKey_graphVis_checkBox',
                'keyKeyed':'ml_setKey_keyKeyed_checkBox',
                'deleteSubFrames':'ml_setKey_subFrames_checkBox',
                'insert':'ml_setKey_insert_checkBox',
                'keyShapes':'ml_setKey_shapes_checkBox',
                }) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:27,代码来源:ml_setKey.py

示例2: selected

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def selected(*args):

    curves = mc.keyframe(query=True, selected=True, name=True)
    if not curves:
        return

    try:
        mc.delete(ATTR_FILTER_NAME)
    except:pass
    try:
        mc.delete(OBJ_FILTER_NAME)
    except:pass

    filters = list()
    for c in curves:
        plug = mc.listConnections(c, plugs=True, source=False, destination=True)[0]
        print plug
        filters.append(mc.itemFilter(byName=plug, classification='user'))

    print filters
    selectedFilter = mc.itemFilter(union=filters)
    #mc.delete(filters)
    print selectedFilter
    mc.outlinerEditor('graphEditor1OutlineEd', edit=True, attrFilter=selectedFilter) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:26,代码来源:ml_graphEditorMask.py

示例3: dragLeft

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def dragLeft(self):
        '''This is activated by the left mouse button, and weights to the next or previous keys.'''

        #clamp it
        if self.x < -1:
            self.x = -1
        if self.x > 1:
            self.x = 1

        if self.x > 0:
            self.drawString('>> '+str(int(self.x*100))+' %')
            for curve in self.keySel.curves:
                for i,v,n in zip(self.time[curve],self.value[curve],self.next[curve]):
                    mc.keyframe(curve, time=(i,), valueChange=v+((n-v)*self.x))
        elif self.x <0:
            self.drawString('<< '+str(int(self.x*-100))+' %')
            for curve in self.keySel.curves:
                for i,v,p in zip(self.time[curve],self.value[curve],self.prev[curve]):
                    mc.keyframe(curve, time=(i,), valueChange=v+((p-v)*(-1*self.x))) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:21,代码来源:ml_breakdown.py

示例4: minimizeRotationCurves

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [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 keyframe [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: time

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def time(self):
        '''
        The keySelection's time, formatted for maya's various keyframe command arguments.
        '''
        if self._time:
            if isinstance(self._time, list):
                return tuple(self._time)
            elif isinstance(self._time, float) or isinstance(self._time, int):
                return (self._time,)
            return self._time
        elif self._timeRangeStart and self._timeRangeEnd:
            return (self._timeRangeStart,self._timeRangeEnd)
        elif self._timeRangeStart:
            return (str(self._timeRangeStart)+':',)
        elif self._timeRangeEnd:
            return (':'+str(self._timeRangeEnd),)
        elif self.selected:
            #if keys are selected, get their times
            timeList = self.keyframe(query=True, timeChange=True)
            return tuple(set(timeList))
        return (':',) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:23,代码来源:ml_utilities.py

示例7: selectedLayers

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def selectedLayers(self, includeLayerWeight=True):
        '''
        This affects keys on all layers that the node belongs to.
        If includeLayerWeight, the keys on the layer's weight attribute will be affected also.
        '''
        layers = getSelectedAnimLayers()
        curves = list()
        for layer in layers:
            layerCurves = mc.animLayer(layer, query=True, animCurves=True)
            if layerCurves:
                curves.extend(layerCurves)
            if includeLayerWeight:
                weightCurve = mc.keyframe(layer+'.weight', query=True, name=True)
                if weightCurve:
                    curves.append(weightCurve[0])
        self._curves = curves
        #we only want to use curves, since nodes or channels wont accurately represent all layers
        self._nodes = None
        self._channels = None 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:21,代码来源:ml_utilities.py

示例8: scaleValue

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def scaleValue(percent=100, selectionOption=1, pivotOption=0):

    value = percent/100.0
    keySel = _getKeySelection(selectionOption)
    valuePivot = 0
    if pivotOption:
        values = keySel.keyframe(query=True, valueChange=True)
        values = sorted(list(set(values)))
        if pivotOption == 1:
            valuePivot = values[-1]
        elif pivotOption == 2:
            valuePivot = values[0]
        elif pivotOption == 3:
            valuePivot = (values[0]+values[-1])/2

    keySel.scaleKey(valueScale=value, valuePivot=valuePivot) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:18,代码来源:ml_animCurveEditor.py

示例9: rippleCut

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [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

示例10: keyObj

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [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: commands

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def commands():
    """This function will use the Maya commands API to query keyframes in a scene"""
    # Get the start time so we can calculate how long this took
    start = time.time()

    # Ask Maya to fetch all the animCurves for the joints
    curves = cmds.ls(type='animCurveTA')
    # Then query all the keyframes
    keyframes = set(cmds.keyframe(curves, q=True))

    # Finally calculate how long those two lines took
    delta = time.time() - start
    # And then return it so we tally it up
    return delta 
开发者ID:dgovil,项目名称:AdvancedPythonForMaya,代码行数:16,代码来源:standalone.py

示例12: bakePivot

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def bakePivot(self):

        if not mc.objExists(self.pivotHandle) or not mc.objExists(self.node):
            self.cleanup()
            return

        newPivot = mc.getAttr(self.pivotHandle+'.translate')[0]

        if newPivot == mc.getAttr(self.node+'.rotatePivot')[0]:
            self.cleanup()
            return

        if not mc.keyframe(self.node, attribute=('tx','ty','tz','rx','ry','rz'), query=True, name=True):
            mc.setAttr(self.node+'.rotatePivot', *newPivot)
            self.cleanup()
            return

        tempPosition = mc.group(em=True)
        mc.delete(mc.parentConstraint(self.pivotHandle, tempPosition))

        utl.matchBake(source=[self.node], destination=[tempPosition], bakeOnOnes=True, maintainOffset=True, preserveTangentWeight=False, rotate=False)

        mc.setAttr(self.node+'.rotatePivot', *newPivot)
        utl.matchBake(source=[tempPosition], destination=[self.node], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False, rotate=False)

        mc.delete(tempPosition)

        mc.select(self.node)

        self.cleanup()

        #end context
        try:
            qt_maya_window.removeEventFilter(self.keypressFilter)
        except:
            pass 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:38,代码来源:ml_pivot.py

示例13: dragMiddle

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def dragMiddle(self):
        '''This is activated by the middle mouse button, and weights to the average of the surrounding keys.'''

        #clamp it
        if self.x < -1:
            self.x = -1
        if self.x > 1:
            self.x = 1

        self.drawString('Average '+str(int(self.x*100))+' %')
        for curve in self.keySel.curves:
            for i,v,n in zip(self.time[curve],self.value[curve],self.average[curve]):
                mc.keyframe(curve, time=(i,), valueChange=v+((n-v)*self.x)) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:15,代码来源:ml_breakdown.py

示例14: dragShiftLeft

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def dragShiftLeft(self):
        '''This is activated by Shift and the left mouse button, and weights to the next or previous keys, without clamping.'''
        if self.x > 0:
            self.drawString('>> '+str(int(self.x*100))+' %')
            for curve in self.keySel.curves:
                for i,v,n in zip(self.time[curve],self.value[curve],self.next[curve]):
                    mc.keyframe(curve, time=(i,), valueChange=v+((n-v)*self.x))
        elif self.x <0:
            self.drawString('<< '+str(int(self.x*-100))+' %')
            for curve in self.keySel.curves:
                for i,v,p in zip(self.time[curve],self.value[curve],self.prev[curve]):
                    mc.keyframe(curve, time=(i,), valueChange=v+((p-v)*(-1*self.x))) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:14,代码来源:ml_breakdown.py

示例15: castToTime

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import keyframe [as 别名]
def castToTime(time):
    '''
    Maya's keyframe commands are finnicky about how lists of times or indicies are formatted.
    '''
    if isinstance(time, (list, tuple)):
        return [(x,) for x in time]
    return (time,) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:9,代码来源:ml_utilities.py


注:本文中的maya.cmds.keyframe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。