本文整理汇总了Python中maya.cmds.cutKey函数的典型用法代码示例。如果您正苦于以下问题:Python cutKey函数的具体用法?Python cutKey怎么用?Python cutKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cutKey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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')
开发者ID:FranTirado,项目名称:PruebaMaya,代码行数:7,代码来源:#createRotwithUI.py
示例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')
开发者ID:Kif11,项目名称:maya_tools,代码行数:12,代码来源:turntable.py
示例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')
开发者ID:cesarpazguzman,项目名称:Maya---Basics-concepts,代码行数:12,代码来源:rotationWithGUI.py
示例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] )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:35,代码来源:cmdModel.py
示例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] )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:31,代码来源:cmdModel.py
示例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)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:31,代码来源:animationCrashRecovery.py
示例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))
开发者ID:Italic-,项目名称:maya-prefs,代码行数:7,代码来源:ml_animCurveEditor.py
示例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
开发者ID:eoghancunneen,项目名称:mayaflipbook,代码行数:29,代码来源:animationflipbook.py
示例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)
开发者ID:liudger,项目名称:ml_tools,代码行数:32,代码来源:ml_pivot.py
示例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!')
开发者ID:greymind,项目名称:Sequencer,代码行数:30,代码来源:Sequencer.py
示例11: CutSelKeys
def CutSelKeys():
# coding=1251
import maya.cmds as cmds
selectedCtrls = cmds.ls(sl = True)
cmds.cutKey(selectedCtrls)
开发者ID:AndreySibiryakov,项目名称:coding,代码行数:7,代码来源:face_animation_tools.py
示例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()
开发者ID:malandrin,项目名称:maya-scripts,代码行数:27,代码来源:MTRuntimeKeyTransform.py
示例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)
开发者ID:boochos,项目名称:work,代码行数:59,代码来源:animCurve_lib.py
示例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))
开发者ID:mocap-ca,项目名称:cleanup,代码行数:8,代码来源:keyTools.py
示例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))
开发者ID:mocap-ca,项目名称:cleanup,代码行数:8,代码来源:keyTools.py
示例16: deleteDummyKey
def deleteDummyKey(objects=None):
objs = filterNoneObjects(objects)
if not objs:
objs = getObjsSel()
if len(objs) > 0:
cmds.cutKey(objs, time=(-50000, -50000), clear=True)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:8,代码来源:animMod.py
示例17: assign
def assign( source, target, rangemode, replacemode ) :
''' Assign a marker, copying from source to destination
:param source: the source marker to copy data from
:param target: the target marker to paste data on to
:param replacemode: 'swap' or 'extract'
:param rangemode: sett getSourceRange
'''
print "Assign: %s ---> %s Modes: %s/%s" % (source, target, rangemode, replacemode )
if not m.objExists( target ) :
print "renaming: " + source + " as " + target
m.rename( source, target)
return True
if rangemode == 'gap' :
# fill the gap in the target using keys from the source
s = curve.currentSegmentOrGap( target, datarate.nodeRate(source) )
if s is None or s[0] != 'gap' :
print "Skipping: " + str(source) + " (not currently in a gap)"
return
# values of surrounding keyframes
sourceIn, sourceOut = s[1]
# contract range
sourceIn = sourceIn + 0.5
sourceOut = sourceOut - 0.5
else :
sourceIn, sourceOut = getSourceRange( source, rangemode )
# expand to
sourceIn = sourceIn - 0.5
sourceOut = sourceOut + 0.5
print "In: %f Out: %f" % (sourceIn, sourceOut)
if replacemode == 'swap' :
keyTools.swap( (source,target), sourceIn, sourceOut )
if replacemode == 'extract' :
# copy the segment over, any clashing keys on the marker will be removed as unlabelled
keyTools.extractRange( target, sourceIn, sourceOut )
m.cutKey( source, t = ( sourceIn, sourceOut ) )
m.pasteKey( target, option='replace' )
keyTools.setActiveKeys( source, delete=True )
keyTools.setActiveKeys( target )
#m.select(target)
m.dgdirty(a=True)
开发者ID:mocap-ca,项目名称:cleanup,代码行数:58,代码来源:assign.py
示例18: deleteKey
def deleteKey(self,*a,**kw):
""" Select the seted objects """
if self.setList:
mc.select(self.setList)
mc.cutKey(*a,**kw)
return True
guiFactory.warning("'%s' has no data"%(self.nameShort))
return False
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:9,代码来源:SetFactory.py
示例19: copyAnimation
def copyAnimation(source=None, destination=None, pasteMethod='replace', offset=0, start=None, end=None, layer=None):
'''
Actually do the copy and paste from one node to another. If start and end frame is specified,
set a temporary key before copying, and delete it afterward.
'''
if layer:
mc.select(destination)
mc.animLayer(layer, edit=True, addSelectedObjects=True)
#we want to make sure rotation values are within 360 degrees, so we don't get flipping when blending layers.
utl.minimizeRotationCurves(source)
utl.minimizeRotationCurves(destination)
if pasteMethod=='replaceCompletely' or not start or not end:
mc.copyKey(source)
if layer:
mc.animLayer(layer, edit=True, selected=True)
mc.pasteKey(destination, option=pasteMethod, timeOffset=offset)
else:
#need to do this per animation curve, unfortunately, to make sure we're not adding or removing too many keys
animCurves = mc.keyframe(source, query=True, name=True)
if not animCurves:
return
#story cut keytimes as 2 separate lists means we only have to run 2 cutkey commands, rather than looping through each
cutStart = list()
cutEnd = list()
for curve in animCurves:
#does it have keyframes on the start and end frames?
startKey = mc.keyframe(curve, time=(start,), query=True, timeChange=True)
endKey = mc.keyframe(curve, time=(end,), query=True, timeChange=True)
#if it doesn't set a temporary key for start and end
#and store the curve name in the appropriate list
if not startKey:
mc.setKeyframe(curve, time=(start,), insert=True)
cutStart.append(curve)
if not endKey:
mc.setKeyframe(curve, time=(end,), insert=True)
cutEnd.append(curve)
mc.copyKey(source, time=(start,end))
if layer:
for each in mc.ls(type='animLayer'):
mc.animLayer(each, edit=True, selected=False, preferred=False)
mc.animLayer(layer, edit=True, selected=True, preferred=True)
mc.pasteKey(destination, option=pasteMethod, time=(start,end), copies=1, connect=0, timeOffset=offset)
#if we set temporary source keys, delete them now
if cutStart:
mc.cutKey(cutStart, time=(start,))
if cutEnd:
mc.cutKey(cutEnd, time=(end,))
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:56,代码来源:ml_copyAnim.py
示例20: scaleConstraint
def scaleConstraint(master, slave, mo=False, force=False, attrList=['sx', 'sy', 'sz']):
"""
Create a scale constraint between the specified master and slave transforms.
Only constrains open, settable channels.
@param master: Constraint master transform.
@type master: str
@param slave: Constraint slave transform.
@type slave: str
@param mo: Maintain constraint offset
@type mo: bool
@param force: Force constraint by deleteing scale channel keys. Use with caution!
@type force: bool
@param attrList: List of transform attributes to constrain.
@type attrList: list
"""
# ==========
# - Checks -
# ==========
# Check Master
if not cmds.objExists(master):
raise Exception('Constraint master "' + master + '" does not exist!')
if not glTools.utils.transform.isTransform(master):
raise Exception('Constraint master "' + master + '" is not a valid transform!')
# Check Slave
if not cmds.objExists(slave):
raise Exception('Constraint slave "' + slave + '" does not exist!')
if not glTools.utils.transform.isTransform(slave):
raise Exception('Constraint slave "' + slave + '" is not a valid transform!')
# Check Settable Channels
sk = []
if not 'sx' in attrList or not cmds.getAttr(slave + '.sx', se=True): sk.append('x')
if not 'sy' in attrList or not cmds.getAttr(slave + '.sy', se=True): sk.append('y')
if not 'sz' in attrList or not cmds.getAttr(slave + '.sz', se=True): sk.append('z')
if not sk: st = 'none'
# Check All
if len(sk) == 3:
print('All scale channels locked! Unable to add constraint')
return None
# =====================
# - Create Constraint -
# =====================
if force: cmds.cutKey(slave, at=attrList)
constraint = ''
try:
constraint = cmds.scaleConstraint(master, slave, sk=sk, mo=mo)[0]
except Exception, e:
# raise Exception('Error creating constraint from "'+master+'" to "'+slave+'"! Exception msg: '+str(e))
print('Error creating constraint from "' + master + '" to "' + slave + '"! Exception msg: ' + str(e))
constraint = None
开发者ID:bennymuller,项目名称:glTools,代码行数:56,代码来源:constraint.py
注:本文中的maya.cmds.cutKey函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论