本文整理汇总了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
#----------------------------------------------------------------------
示例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)
示例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)
示例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,))
示例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)
示例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)+':',))
示例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)
示例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])
示例9: keySel
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import setKeyframe [as 别名]
def keySel():
"""Key selected controls"""
pm.setKeyframe()
# ================================================
示例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)
示例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)
示例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)
# ================================================
示例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
示例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()
示例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()