本文整理汇总了Python中maya.cmds.cutKey函数的典型用法代码示例。如果您正苦于以下问题:Python cutKey函数的具体用法?Python cutKey怎么用?Python cutKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cutKey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyFullRotation
def keyFullRotation (pObjectName, pStartTime, pEndTime, pTargetAttribute):
cmds.cutKey (pObjectName, time = (pStartTime, pEndTime), attribute=pTargetAttribute)
cmds.setKeyframe (pObjectName, time = pStartTime, attribute=pTargetAttribute, value=0)
cmds.setKeyframe (pObjectName, time = pEndTime, attribute=pTargetAttribute, value=360)
cmds.selectKey (pObjectName, time = (pStartTime, pEndTime), attribute=pTargetAttribute, keyframe=True)
cmds.keyTangent (inTangentType='linear', outTangentType='linear')
示例2: keyFullRotation
def keyFullRotation(pObjectName, pStartTime, pEndTime, pTangentAttribute):
# Enable key on selected objects
cmds.cutKey(pObjectName, time=(pStartTime, pEndTime), attribute=pTangentAttribute)
# Set keyframes
cmds.setKeyframe(pObjectName, time=pStartTime, attribute=pTangentAttribute, value=0)
cmds.setKeyframe(pObjectName, time=pEndTime, attribute=pTangentAttribute, value=360)
# Set linear tangent
cmds.selectKey(pObjectName, time=(pStartTime, pEndTime), attribute=pTangentAttribute)
cmds.keyTangent(inTangentType='linear', outTangentType='linear')
示例3: keyFullRotation
def keyFullRotation(pObjectName, pStartTime, pEndTime, pTargetAttribute):
#The keys are deleted
cmds.cutKey(pObjectName, time=(pStartTime, pEndTime), attribute=pTargetAttribute)
#Define new keys for the animations (rotation in the axis Y).
cmds.setKeyframe(pObjectName, time= pStartTime, attribute=pTargetAttribute, value = 0)
cmds.setKeyframe(pObjectName,time=pEndTime, attribute=pTargetAttribute, value = 360)
#In order to mantain a constant rate of rotation with linear tangents
cmds.selectKey(pObjectName, time=(pStartTime, pEndTime), attribute=pTargetAttribute)
cmds.keyTangent( inTangentType='linear', outTangentType='linear')
示例4: keyCopyObjects
def keyCopyObjects( fromList, toList, start, end ):
for i in range( len( fromList ) ):
fromCtl = fromList[i]
toCtl = toList[i]
targetMtx = cmds.getAttr( fromCtl+'.m' )
mirrorMtx = getMirrorMatrix_local( targetMtx )
listAttr = cmds.listAttr( fromCtl, k=1 )
if not listAttr: continue
for attr in listAttr:
times = cmds.keyframe( fromCtl+'.'+attr, q=1, t=(start,end), tc=1 )
if not times: continue
values = cmds.keyframe( fromCtl+'.'+attr, q=1, t=(start,end), vc=1 )
keyLocks = cmds.keyTangent( fromCtl+'.'+attr, q=1, t=(start,end), lock=1 )
inAngles = cmds.keyTangent( fromCtl+'.'+attr, q=1, t=(start,end), ia=1 )
outAngles = cmds.keyTangent( fromCtl+'.'+attr, q=1, t=(start,end), oa=1 )
cmds.cutKey( toCtl+'.'+attr, t=(start+0.01, end-0.01) )
for i in range( len( times ) ):
if attr.find( 'translate' ) != -1:
value = -values[i]
ia = -inAngles[i]
oa = -outAngles[i]
else:
value = values[i]
ia = inAngles[i]
oa = outAngles[i]
cmds.setKeyframe( toCtl+'.'+attr, t=times[i], v=value )
cmds.keyTangent( toCtl+'.'+attr, e=1, t=(times[i],times[i]), lock=0 )
cmds.keyTangent( toCtl+'.'+attr, e=1, t=(times[i],times[i]), ia=ia )
cmds.keyTangent( toCtl+'.'+attr, e=1, t=(times[i],times[i]), oa=oa )
cmds.keyTangent( toCtl+'.'+attr, e=1, t=(times[i],times[i]), lock=keyLocks[i] )
示例5: keyCopyObjectOnce
def keyCopyObjectOnce( target, start, end ):
otherTarget = ''
if target in CtlInfo.leftCtls:
otherTarget = target.replace( '_L1_', '_R1_' )
elif target in CtlInfo.rightCtls:
otherTarget = target.replace( '_R1_', '_L1_' )
if not otherTarget: return None
attrs = cmds.listAttr( target, k=1 )
for attr in attrs:
times = cmds.keyframe( target+'.'+attr, q=1, t=(start,end), tc=1 )
if not times: continue
values = cmds.keyframe( target+'.'+attr, q=1, t=(start,end), vc=1 )
keyLocks = cmds.keyTangent( target+'.'+attr, q=1, t=(start,end), lock=1 )
inAngles = cmds.keyTangent( target+'.'+attr, q=1, t=(start,end), ia=1 )
outAngles = cmds.keyTangent( target+'.'+attr, q=1, t=(start,end), oa=1 )
cmds.cutKey( otherTarget+'.'+attr, t=(start+0.01, end-0.01) )
for i in range( len( times ) ):
value = values[i]
ia = inAngles[i]
oa = outAngles[i]
cmds.setKeyframe( otherTarget+'.'+attr, t=times[i], v=value )
cmds.keyTangent( otherTarget+'.'+attr, e=1, t=(times[i],times[i]), lock=0 )
cmds.keyTangent( otherTarget+'.'+attr, e=1, t=(times[i],times[i]), ia=ia )
cmds.keyTangent( otherTarget+'.'+attr, e=1, t=(times[i],times[i]), oa=oa )
cmds.keyTangent( otherTarget+'.'+attr, e=1, t=(times[i],times[i]), lock=keyLocks[i] )
示例6: applyAttrData
def applyAttrData(self, attrData):
firstStep = 0
totalSteps = len(attrData)
estimatedTime = None
status = "aTools Animation Crash Recovery - Step 2/3 - Applying attributes data..."
startChrono = None
for thisStep, loopData in enumerate(attrData):
if cmds.progressBar(G.progBar, query=True, isCancelled=True ): return
startChrono = utilMod.chronoStart(startChrono, firstStep, thisStep, totalSteps, estimatedTime, status)
objAttr = loopData["object"]
value = loopData["value"]["value"]
if not cmds.objExists(objAttr): continue
if not cmds.getAttr(objAttr, settable=True): continue
if cmds.getAttr(objAttr, lock=True): continue
if cmds.getAttr(objAttr, type=True) == "string": continue
cmds.cutKey(objAttr)
if type(value) is list: #translate, rotate, scale
value = value[0]
cmds.setAttr(objAttr, value[0],value[1],value[2], clamp=True)
else: #translatex, translatey, etc
cmds.setAttr(objAttr, value, clamp=True)
estimatedTime = utilMod.chronoEnd(startChrono, firstStep, thisStep, totalSteps)
示例7: deleteSubFrameKeys
def deleteSubFrameKeys(selectionOption=1):
keySel = _getKeySelection(selectionOption)
for curve, times in zip(keySel.curves, keySel.times):
cutTimes = [x for x in times if x % 1 != 0 and -9999 < x < 9999]
if cutTimes:
mc.cutKey(curve, time=utl.castToTime(cutTimes))
示例8: delete_page
def delete_page():
""" Delete an existing page.
Cuts the key from the flipbook_LOC so that it is no longer set.
:returns: None.
:raises: None.
"""
# Get the current frame that we're on:
current_frame = cmds.currentTime(query=True)
# We're going to have to delete the group first and foremost:
page_name = "page_%04d" % (current_frame)
expression_name = "page_%04d_visibility_EXP" % (current_frame)
if cmds.objExists(expression_name):
cmds.delete(expression_name)
if cmds.objExists(page_name):
cmds.delete(page_name)
# Then we need to delete the key from the master node:
cmds.cutKey("flipbook_LOC",
attribute="pagesToDisplay",
time=(current_frame, current_frame),
option="keys",
clear=True)
# Now that that's done, we *could* set the current frame to the last keyed
# page?...maybe.
return
示例9: doEditPivotDriver
def doEditPivotDriver(self, *args):
newValue = mc.floatSliderButtonGrp(self.floatSlider, query=True, value=True)
try:
mc.deleteUI(self.pivotDriverWindow)
except:
pass
currentValue = mc.getAttr(self.pivotDriver)
if newValue == currentValue:
return
oldRP = mc.getAttr(self.node+'.rotatePivot')[0]
mc.setAttr(self.pivotDriver, newValue)
newRP = mc.getAttr(self.node+'.rotatePivot')[0]
mc.setAttr(self.pivotDriver, currentValue)
parentPosition = mc.group(em=True)
offsetPosition = mc.group(em=True)
offsetPosition = mc.parent(offsetPosition, parentPosition)[0]
mc.setAttr(offsetPosition+'.translate', newRP[0]-oldRP[0], newRP[1]-oldRP[1], newRP[2]-oldRP[2])
mc.delete(mc.parentConstraint(self.node, parentPosition))
utl.matchBake(source=[self.node], destination=[parentPosition], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False)
mc.cutKey(self.pivotDriver)
mc.setAttr(self.pivotDriver, newValue)
mc.refresh()
utl.matchBake(source=[offsetPosition], destination=[self.node], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False, rotate=False)
mc.delete(parentPosition)
示例10: TrimKeys
def TrimKeys(self, extraArg=None):
selection = Cmds.ls(selection=True)
if not len(selection) == 1 or not Cmds.nodeType(selection) == 'joint':
self.MessageBox('Please select (only) the topmost joint of the skeletal system', 'Trim keys pre-requisite error')
return
trimStart = int(Cmds.textField(self.startFrameTextBox, q=True, text=True))
trimEnd = int(Cmds.textField(self.endFrameTextBox, q=True, text=True))
if trimStart < 0:
self.MessageBox('Trim can start only from 0. Please ensure start frame is valid.', 'Trim keys pre-requisite error')
trimRegions = [0] * (trimEnd + 1)
for animation in self.sequencer.Animations.values():
trimRegions[animation.StartFrame:animation.EndFrame + 1] = [1] * (animation.EndFrame - animation.StartFrame + 1)
i = 0
while i < len(trimRegions):
tStart = FindIndexOf(trimRegions, 0, i, trimEnd)
tEnd = FindIndexOf(trimRegions, 1, tStart, trimEnd) - 1
if tEnd < tStart:
break
Cmds.cutKey(selection, animation='keysOrObjects', option='keys', clear=True, hierarchy='below', time=(tStart,tEnd))
i = tEnd + 1
i = i + 1
self.MessageBox('Trim complete!')
示例11: CutSelKeys
def CutSelKeys():
# coding=1251
import maya.cmds as cmds
selectedCtrls = cmds.ls(sl = True)
cmds.cutKey(selectedCtrls)
示例12: OnKeyChange
def OnKeyChange( self, *args ):
checks = [ cmds.checkBox( self.cXKey, query = True, value = True ), cmds.checkBox( self.cYKey, query = True, value = True ), cmds.checkBox( self.cZKey, query = True, value = True ) ]
attribs = [ ".translateX", ".translateY", ".translateZ" ]
# ... se quieren cambios? ...
sequence = next( ( seq for seq in self.SequenceInfo if seq.GetNode() == self.ActiveNode ), None )
frameInfo = sequence.GetFrameInfo( self.ActiveManip.GetFrame() )
# ...
refreshCurve = False
frame = self.ActiveManip.GetFrame() + self.StartFrame
for i in range( 0, 3 ):
if ( checks[ i ] != frameInfo.HasTranslationKeyAxis( i ) ):
if ( checks[ i ] ): # ... se crea la key ...
cmds.setKeyframe( self.ActiveNode + attribs[ i ], insert = True, time = ( frame, frame ) )
frameInfo.SetTranslationKey( i )
else: # ... se borra la key ...
#cmds.selectKey( self.ActiveNode + attribs[ i ], add = True, keyframe = True, time = ( frame, frame ) )
cmds.cutKey( self.ActiveNode + attribs[ i ], time = ( frame, frame ), option = "keys" )
frameInfo.RemoveTranslationKey( i )
refreshCurve = True
# ...
if ( refreshCurve ):
self.CreateCurve()
示例13: distributeKeys
def distributeKeys(step=3.0, destructive=True, forceWholeFrames=True):
'''
operates on selected curves
'''
s = GraphSelection()
sel = cmds.ls(sl=1, fl=True)
rng = fr.Get()
if s.crvs:
# gather info
autoK = cmds.autoKeyframe(q=True, state=True)
frames = getKeyedFrames(s.crvs)
# process start/end of loop
framesNew = []
if rng.selection:
for f in frames:
if f >= rng.keyStart and f <= rng.keyEnd:
framesNew.append(f)
frames = framesNew
#
cut = []
# print frames
if forceWholeFrames:
framesOrig = frames
frames = [round(frame) for frame in frames]
framesPartial = list(set(framesOrig) - set(frames))
cut = [frame for frame in framesPartial]
# print cut, '______cut'
lastFrame = frames[len(frames) - 1]
count = frames[0]
i = frames[0]
# turn off autokey
cmds.autoKeyframe(state=False)
framesNew = []
# process keys
while i < lastFrame:
if i == count:
cmds.setKeyframe(s.crvs, i=True, t=count)
framesNew.append(count)
count = count + step
else:
if i in frames:
cut.append(i)
i = i + 1
# remove keys is destructive
if destructive:
framesDel = sorted(list(set(frames) - set(framesNew)))
for frame in framesDel:
cut.append(frame)
# print framesOrig, '________orig'
# print framesNew, '________new'
# print cut, '_________cut'
if cut:
for frame in cut:
if frame >= rng.keyStart and frame <= rng.keyEnd:
cmds.cutKey(sel, clear=1, time=(frame, frame))
# restore autokey
cmds.autoKeyframe(state=autoK)
else:
message('Select one or more anima curves', maya=1)
示例14: cutBefore
def cutBefore() :
''' cut the keys from 0 to current '''
cur = m.currentTime(q=True)
start = m.playbackOptions(q=True, min=True)
sel = m.ls(sl=True)
for i in sel: m.cutKey(i, time=(0, cur))
示例15: cutAfter
def cutAfter() :
''' cut the keys from current to end on selected '''
cur = m.currentTime(q=True)
end = m.playbackOptions(q=True, max=True)
sel = m.ls(sl=True)
for i in sel: m.cutKey(i, time=(cur, end))