本文整理汇总了Python中maya.cmds.bakeResults函数的典型用法代码示例。如果您正苦于以下问题:Python bakeResults函数的具体用法?Python bakeResults怎么用?Python bakeResults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bakeResults函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bakeInfinity
def bakeInfinity(sparseKeys=True, smart=True, sim=False):
crvs = cmds.keyframe(q=True, name=True, sl=True)
if crvs:
start = cmds.playbackOptions(q=True, minTime=True)
end = cmds.playbackOptions(q=True, maxTime=True)
objs = cmds.listConnections(crvs, d=True, s=False, plugs=True)
cmds.refresh(suspend=1)
print sim, '________'
cmds.bakeResults(objs, t=(start, end), simulation=sim, pok=True, smart=smart, sac=sparseKeys, sampleBy=1)
cmds.refresh(suspend=0)
message(str(len(objs)) + ' curves baked --' + str(objs), maya=1)
else:
message('no curves are selected', maya=1)
示例2: bd_bakeControllers
def bd_bakeControllers(args):
cmds.select('*_Anim')
animCtrls = cmds.ls(sl=True, type='transform')
minTime = cmds.playbackOptions(q=True,minTime=True)
maxTime = cmds.playbackOptions(q=True,maxTime=True)
cmds.bakeResults(animCtrls,simulation=True, t=(minTime,maxTime) )
cmds.select('*_Anim')
animCtrls = cmds.ls(sl=True, type='transform')
cmds.select(clear=True)
for anim in animCtrls:
constr = cmds.listRelatives(anim, children=True,type = 'constraint')
if constr:
cmds.delete(constr)
示例3: bakeDynamicCmd
def bakeDynamicCmd(*args):
'''
Bake the dynamic simulation as key frames on the joints rotations for the specified frame range
'''
# display warning message
result = cmds.confirmDialog(messageAlign="left", title="Bake Simulation", message="Baking simulation will replace the dynamics\nfor keyframe animation. Action is undoable. Do you wish to continue?", button=["Yes", "No"])
if result == "Yes":
# get selected object
selected = cmds.ls(sl=True)
if selected:
# manage the dynamic node
dNode = lpDynamicChain(node=selected[0])
startJoint = dNode.startJoint[0]
endJoint = dNode.endJoint[0]
# get frame range
startFrame = cmds.intFieldGrp("frameRangeIFG", q=True, v1=True)
endFrame = cmds.intFieldGrp("frameRangeIFG", q=True, v2=True)
if cmds.checkBoxGrp("useTimeSliderCBG", q=True, v1=True):
startFrame = cmds.playbackOptions(q=True, minTime=True)
endFrame = cmds.playbackOptions(q=True, maxTime=True)
# get the joints
joints = [startJoint]
joints.extend( findAllJointsFromTo(startJoint, endJoint) )
# bake the simulation for the frame range - this action is undoable
cmds.bakeResults(joints, t=(startFrame, endFrame), dic=False, preserveOutsideKeys=True, simulation=True)
示例4: exportBake
def exportBake( self, ctls, timeRange ):
cmds.undoInfo( swf=0 )
time = ( timeRange[0], timeRange[1] )
sampleValue = timeRange[2]
cmds.bakeResults( ctls, simulation=True, t=time, sampleBy=sampleValue, disableImplicitControl=True, preserveOutsideKeys=False,
sparseAnimCurveBake=False, removeBakedAttributeFromLayer=False, bakeOnOverrideLayer=False, minimizeRotation=False,
controlPoints=False, shape=False )
timeControl = cmds.createNode( 'timeControl', n='timeControl' )
dgtrAnimCurves = cmds.ls( 'DGTR_*', type='animCurve' )
for anim in dgtrAnimCurves:
cmds.connectAttr( timeControl+'.outTime', anim+'.input' )
for ctl in ctls:
animNodeRx = cmds.listConnections( ctl+'.rx', s=1, d=0, type='animCurve' )[0]
animNodeRy = cmds.listConnections( ctl+'.ry', s=1, d=0, type='animCurve' )[0]
animNodeRz = cmds.listConnections( ctl+'.rz', s=1, d=0, type='animCurve' )[0]
animNodeIrx = cmds.listConnections( ctl+'.irx', s=1, d=0, type='animCurve' )[0]
animNodeIry = cmds.listConnections( ctl+'.iry', s=1, d=0, type='animCurve' )[0]
animNodeIrz = cmds.listConnections( ctl+'.irz', s=1, d=0, type='animCurve' )[0]
self.eulerFilter( [animNodeRx, animNodeRy, animNodeRz] )
self.eulerFilter( [animNodeIrx, animNodeIry, animNodeIrz] )
cmds.undoInfo( swf=1 )
示例5: bake
def bake(constraint,
start=None,
end=None,
sampleBy=1,
simulation=True):
"""
Bake specified constraint
@param constraint: Constraint to bake animation for.
@type constraint: str
@param start: Start frame of bake animation range
@type start: float or None
@param end: End frame of bake animation range
@type end: float or None
@param sampleBy: Sample every Nth frame
@type sampleBy: int
@param simulation: Simulation option for bakeResults
@type simulation: bool
"""
# ==========
# - Checks -
# ==========
# Check Constraint
if not glTools.utils.constraint.isConstraint(constraint):
raise Exception('Object "' + constraint + '" is not a valid constraint node!')
# Check Start/End Frames
if start == None: start = cmds.playbackOptions(q=True, min=True)
if end == None: end = cmds.playbackOptions(q=True, max=True)
# ====================================
# - Get Slave Transform and Channels -
# ====================================
# Get Slave Transform
slave = glTools.utils.constraint.slave(constraint)
# Get Slave Channels
attrList = cmds.listConnections(constraint, s=False, d=True, p=True) or []
slaveAttrs = [i.split('.')[-1] for i in attrList if i.startswith(slave + '.')] or []
if not slaveAttrs: raise Exception('No slave channels to bake!')
# ===================
# - Bake Constraint -
# ===================
cmds.refresh(suspend=True)
cmds.bakeResults(slave,
at=slaveAttrs,
time=(start, end),
disableImplicitControl=True,
simulation=simulation,
sampleBy=sampleBy)
cmds.refresh(suspend=False)
# =================
# - Return Result -
# =================
return [slave + '.' + i for i in slaveAttrs]
示例6: createFreeCameras
def createFreeCameras(self):
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'self.cameras: %s' % self.cameras, verbose = False)
for camera in self.cameras:
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'Processing camera: %s' % camera, verbose = False)
cmds.select(camera, r= True)
newCamera = cmds.duplicate( rr=True )
newCamera = newCamera[0]
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'newCamera: %s' % newCamera, verbose = False)
for attr in ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']:
cmds.setAttr(newCamera + "." + attr, lock=False)
hisObject = cmds.listHistory(newCamera)
for attr in ['hfa', 'vfa', 'fl', 'lsr', 'fs', 'fd', 'sa', 'coi']:
cmds.setAttr(hisObject[0] + "." + attr, lock=False)
parentNode = cmds.listRelatives(camera, p= True)
if parentNode != None:
cmds.parent( newCamera, world= True)
pointConst = cmds.pointConstraint( camera, newCamera )
orientConst = cmds.orientConstraint( camera, newCamera )
cmds.bakeResults( newCamera+'*', t=(self.startFrame, self.endFrame), simulation=True, sparseAnimCurveBake=False, shape=False)
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'newCamera %s baked successfully...' % newCamera, verbose = False)
cmds.delete(pointConst, orientConst, cn=True )
newCameraName = cmds.rename(newCamera, '%s_Cpy' % camera)
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'newCameraName: %s' % newCameraName, verbose = False)
self.newCameras.extend([newCameraName])
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'self.newCameras: %s' % self.newCameras, verbose = False)
示例7: reCenterPivot
def reCenterPivot(obj):
locName = obj + "_loc"
cmds.spaceLocator(n=locName )
cmds.parent( locName, obj )
cmds.setAttr(locName + ".translateX",0)
cmds.setAttr(locName + ".translateY",0)
cmds.setAttr(locName + ".translateZ",0)
cmds.setAttr(locName + ".rotateX",0)
cmds.setAttr(locName + ".rotateY",0)
cmds.setAttr(locName + ".rotateZ",0)
cmds.Unparent(locName)
pConst = cmds.parentConstraint(obj,locName,mo=True,w=1)
cmds.bakeResults(locName,sm=True, t=(0,44),at=["tx","ty","tz","rx","ry","rz"])
cmds.delete(pConst)
newObj = cmds.duplicate(obj,n=obj+"_new")
cmds.xform(newObj[0],cp=True)
nConst = cmds.parentConstraint(locName,newObj, mo=True,w=1)
cmds.bakeResults(newObj,sm=True, t=(0,44),at=["tx","ty","tz","rx","ry","rz"])
cmds.delete(nConst)
cmds.delete(locName)
示例8: export
def export(path_to_save, script_name, namespace):
util.debug("Importing all references, flattening scene.")
scene.importReferences("all")
shots = scene.getShots()
scene_start, scene_end = scene.length()
#util.debug("Selecting all joint hierarchies.")
#cmds.select(all=1, hi=1)
#cmds.select(cmds.ls(sl=1, typ='joint'), r=1)
util.debug("Baking all animations.")
scene_start, scene_end = scene.length()
cmds.select("%s:root" % namespace, hi=1)
cmds.select(cmds.ls(sl=1, typ='joint'), r=1)
cmds.bakeResults(sm=1, t=(scene_start,scene_end), sb=1, sac=0, pok=0,at= ["tx","ty","tz","rx","ry","rz"])
ns.deleteOthers(namespace)
ns.remove()
util.debug("Setting tangent to stepped for keys that occur on cuts: %s" % shots)
cut_frames = []
for shot in shots:
cut_frames.append(shot['end'])
scene.makeCutTangentsStep(cut_frames)
psa_name = "%(script_name)s_%(namespace)s" % {
'script_name': script_name,
'namespace': namespace
}
util.debug("Creating .PSA file: %s" % psa_name)
#for shot in shots:
# ## Unreal xyz
# util.debug("{",shot,"[",\
# -cmds.getAttr("%s:root.translateZ" % namespace,t=shot['start']),\
# cmds.getAttr("%s:root.translateX" % namespace,t=shot['start']),\
# -cmds.getAttr("%s:root.translateY" % namespace,t=shot['start']),\
# "][",\
# -cmds.getAttr("%s:root.rotateZ" % namespace,t=shot['start']),\
# cmds.getAttr("%s:root.rotateX" % namespace,t=shot['start']),\
# -cmds.getAttr("%s:root.rotateY" % namespace,t=shot['start']),\
# "]}")
for shot in shots:
cmds.playbackOptions(min = shot['start'], max = shot['end'])
sequence_name = "%(psa_name)s_%(#)02d" % {
'psa_name' : psa_name,
'#' : shots.index(shot)
}
util.debug("Adding Sequence %s" % sequence_name)
if shots.index(shot) == len(shots)-1 :
if 'command AXExecute executed. ' == cmds.axexecute(path = path_to_save, animfile = psa_name, sequence = sequence_name, rate = scene.GAME_RATE, saveanim = 1):
return True
else:
return False
else:
cmds.axexecute(path = path_to_save, animfile = psa_name, sequence = sequence_name, rate = scene.GAME_RATE)
示例9: bakeSkinJoints
def bakeSkinJoints():
startTime = cmds.playbackOptions(q=True, min = True)
endTime = cmds.playbackOptions(q=True, max = True)
listJoints = cmds.attributeQuery( 'list', node='listSkinJoints', listEnum=True )
bakeJoints = listJoints[0].rsplit(':')
del bakeJoints[0:1]
print bakeJoints
cmds.bakeResults( bakeJoints , t=(startTime ,endTime), simulation=True )
示例10: legIkToFk
def legIkToFk(rigNS,side,start=None,end=None,sampleBy=1):
'''
Bake IK leg animation to FK controls
@param rigNS: IK/FK toggle attribute
@type rigNS: str
@param side: Leg side ("lf" or "rt")
@type side: str
@param start: Transfer animation start frame
@type start: int or None
@param end: Transfer animation end frame
@type end: int or None
@param sampleBy: Bake animation by N frames
@type sampleBy: int
'''
# Get Start/End
if start == None: start = mc.playbackOptions(q=True,min=True)
if end == None: end = mc.playbackOptions(q=True,max=True)
# Set Leg to IK mode
mc.setAttr(rigNS+':config.'+side+'LegIkFkBlend',0) # IK
# Build IK/FK Joint List
ikJntList = [rigNS+':'+side+'_leg_ik'+i+'_jnt' for i in ['A','B']]
ikJntList += [rigNS+':'+side+'_foot_ik'+i+'_jnt' for i in ['A','B']]
fkJntList = [rigNS+':'+side+'_leg_fk'+i+'_jnt' for i in ['A','B']]
fkJntList += [rigNS+':'+side+'_foot_fk'+i+'_jnt' for i in ['A','B']]
# Duplicate FK Joints and Constrain to IK
fkDupList = []
fkOriList = []
for i in range(len(ikJntList)):
fkDupList.append(mc.duplicate(fkJntList[i],po=True)[0])
fkOriList.append(mc.orientConstraint(ikJntList[i],fkDupList[-1])[0])
# Transfer Baked Anim to FK Joints
mc.refresh(suspend=True)
for i in range(len(fkDupList)):
mc.bakeResults( fkDupList[i],
t=(start,end),
at=['rx','ry','rz'],
simulation=True,
preserveOutsideKeys=True,
sampleBy=sampleBy )
mc.copyKey(fkDupList[i],at=['rx','ry','rz'],t=(start,end))
mc.pasteKey(fkJntList[i],at=['rx','ry','rz'],t=(start,end),option='replace')
mc.refresh(suspend=False)
# Delete Duplicate Joints and Constraints
if fkOriList:
try: mc.delete(fkOriList)
except Exception, e: print('Error deleting nodes '+str(fkOriList)+'! Exception Msg: '+str(e))
if fkDupList:
try: mc.delete(fkDupList)
except Exception, e: print('Error deleting nodes '+str(fkDupList)+'! Exception Msg: '+str(e))
# Set to FK mode
mc.setAttr(rigNS+':config.'+side+'LegIkFkBlend',1) # FK
示例11: mBakeRigkey
def mBakeRigkey(rigCtrlList, playbackRange):
"""
"""
cmds.bakeResults(rigCtrlList, at= ['.t', '.r', '.s'], t= playbackRange,
sm= 1, s= 0)
for ctrl in rigCtrlList:
findPC = cmds.listRelatives(ctrl, c= 1, typ= 'parentConstraint')
for pc in _xList(findPC):
cmds.delete(pc)
示例12: _bakeObj
def _bakeObj(obj):
'''Bake animazione.'''
constrName = _getParentConstraint(obj)
constrExists = cmds.ls(constrName)
# se il constraint non esiste o non contiene keyframe esci
if not constrExists or cmds.keyframe(constrName, q=True, kc=True) == 0:
sys.stdout.write('Nothing to bake\n')
return
# primo frame
currentFrame = cmds.currentTime(q=True)
firstFrame = cmds.playbackOptions(q=True, ast=True)
cmds.currentTime(firstFrame)
# salva come lastFrame l'ultimo frame d'animazione del constraint o dell'oggetto
keyTimes = cmds.keyframe(obj, q=True, tc=True)
if not keyTimes:
keyTimes = cmds.keyframe(constrName, q=True, tc=True)
else:
keyTimes.extend(cmds.keyframe(constrName, q=True, tc=True))
lastFrame = max(keyTimes)
# se all'ultimo frame rimane attached oppure il corpo e' rigido allora usa animation end time
if max(cmds.keyframe(constrName, q=True, ev=True, t=(lastFrame, lastFrame))) > 0.0 or _getRigidBody(obj):
lastFrame = max(lastFrame, cmds.playbackOptions(q=True, aet=True))
# crea il locator
locatorName = obj + _locSfx
_setRootNamespace()
loc = cmds.spaceLocator(n=locatorName)[0]
cmds.hide(loc)
# trova il parent del gruppo PH
parent = cmds.listRelatives(_getParentHandle(obj), p=True)
if parent:
cmds.parent([loc, parent[0]])
# copia l'ordine degli assi
cmds.setAttr(loc + '.rotateOrder', cmds.getAttr(obj + '.rotateOrder'))
# copia matrice e pivot
cmds.xform(loc, m=cmds.xform(obj, q=True, m=True, ws=True), ws=True)
cmds.xform(loc, piv=cmds.xform(obj, q=True, rp=True, ws=True), ws=True)
# costringi il locator
constraint = cmds.parentConstraint(obj, loc, mo=True)[0]
# fai il bake
cmds.bakeResults(loc, at=['t', 'r'], sm=True, t=(firstFrame, lastFrame), dic=True, pok=True)
# cancella il constraint
cmds.delete(constraint)
# ripristina il frame precedente
cmds.currentTime(currentFrame)
示例13: drop_simulation
def drop_simulation():
start = time.time()
cmds.playbackOptions(min = STARTFRAME, max = ENDFRAME)
cmds.currentTime(STARTFRAME)
cmds.select(clear = True)
cmds.select("shirt")
cmds.bakeResults(simulation = True, controlPoints = True, shape = True, time = (STARTFRAME, ENDFRAME))
cmds.currentTime(ENDFRAME)
end = time.time()
return end-start
示例14: bakeMoc
def bakeMoc( mocLoc ):
import sgBFunction_dag
targetLocs = sgBFunction_dag.getChildrenJointExists( mocLoc )
targetLocs.append( mocLoc )
cmds.select( targetLocs )
minFrame = cmds.playbackOptions( q=1, min=1 )
maxFrame = cmds.playbackOptions( q=1, max=1 )
cmds.bakeResults( sm=True, t=(minFrame, maxFrame), sb=1, dic=True, pok=True, sac=False, removeBakedAttributeFromLayer=False, bakeOnOverrideLayer=False, cp=False, s=True)
示例15: bake
def bake(self, controls, frame_range):
"""
Responsible for baking out the dynamic animation to the original rig.
@params:
controls: Controls that you're baking the animation onto.
frame_range: Targeted frame range (int(start), int(end)).
"""
start = frame_range[0]
end = frame_range[1]
# bake
cmds.bakeResults(controls, sm=True, t=(start, end), at=TR_ATTRS)