本文整理汇总了Python中maya.cmds.cacheFile函数的典型用法代码示例。如果您正苦于以下问题:Python cacheFile函数的具体用法?Python cacheFile怎么用?Python cacheFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cacheFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: importAssetCache
def importAssetCache(self, cacheXmlLt, cacheErrorCheck = False):
""" cacheXmlLt = "R:/data/cache/sq001/sh001/light/char/ben00c_ben/ben00c_ben.xml" """
if os.path.exists(cacheXmlLt):
cacheChannels = mc.cacheFile(fileName=cacheXmlLt,q=1,channelName=1)
cacheGeos = self.getCacheGeos()
cacheGeoDict, cacheChannelsTmp = {}, []
for chn in cacheChannels:
for geo in cacheGeos:
baseChn = utils.stripNames(utils.convertName(chn, "texture"))
baseGeo = utils.stripNames(utils.stripNames(geo, ":"), "|")
if baseChn in baseGeo:
cacheGeoDict[chn] = geo
cacheChannelsTmp.append(chn)
continue
else:
utils.msgWin("Error", "File does not exist : %s"%cacheXmlLt, self.silent)
return False
if cacheErrorCheck:
missedChannels = list(set(cacheChannels).difference(set(cacheGeoDict.keys())))
if len(missedChannels) > 0:
msg = "Cache geometry missing\n"
msg += "\n".join(missedChannels)
utils.msgWin("Error", msg, self.silent)
return missedChannels
else:
return False
for chNode in self.getCacheNodes():
mc.delete(chNode)
for chn in cacheGeoDict.keys():
deformShp = cacheGeoDict[chn]
try:
shpSwitch = mc.deformer(deformShp, type="historySwitch")
except:
continue
shpHist = mc.listHistory(deformShp, pdo=1)
if shpHist:
for hist in shpHist:
if mc.nodeType(hist) == "tweak":
dblList = mc.listAttr("%s.plist"%hist, m= 1)
fltList = mc.listAttr("%s.vlist"%hist, m= 1)
dbCon, flCon = False, False
if dblList:
if len(dblList) > 1: dbCon = True
if fltList:
if len(fltList) > 1: flCon = True
if not(dbCon or flCon):
mc.delete(hist)
break
conns = mc.listConnections("%s.ip[0].ig"%shpSwitch[0], p=1)
mc.connectAttr(conns[0], "%s.ug[0]"%shpSwitch[0])
mc.setAttr("%s.playFromCache"%shpSwitch[0], 1)
mc.getAttr("%s.op[0]"%shpSwitch[0], sl = 1)
mc.setAttr("%s.playFromCache"%shpSwitch[0], 0)
mc.disconnectAttr(conns[0], "%s.ug[0]"%shpSwitch[0])
switch = mc.rename(shpSwitch[0],'cacheSwitch#')
mc.setAttr(switch+'.ihi',0)
cacheNode = mc.cacheFile(f = cacheXmlLt, attachFile = True, ia = '%s.inp[0]'%switch, cnm = chn)
mc.connectAttr(cacheNode+".inRange", switch + '.playFromCache')
utils.msgWin("Message", "Cache loaded successfully for %s"%self.namespace, self.silent)
return True
开发者ID:sid2364,项目名称:Maya_Python,代码行数:60,代码来源:pipeClasses.py
示例2: doOperation
def doOperation( self, operands ) :
result = 'done'
frameRange = operands['FrameRange']['range'].value
meshPrimitives = operands["%sNodes" % self.prefix].value.split(',')
tmpFileName = tempfile.mkstemp()[1]
self.data['assetPath'] = "%sFrame%%d.mc" % tmpFileName
self.data['multipleFiles'] = range(frameRange[0],frameRange[1]+1)
self.data['nodes'] = meshPrimitives
if m:
m.cycleCheck(e=0)
m.cacheFile(
dtf =1,
format ="OneFilePerFrame",
fileName =os.path.basename(tmpFileName),
directory =os.path.dirname(tmpFileName),
cacheableNode =' '.join(meshPrimitives),
st =frameRange[0],
et =frameRange[1],
)
# check if simulation finished susccefuly by looking for all the cached files!
frames = self.data['multipleFiles']
if len(filter(lambda x: os.path.exists(self.data['assetPath']%x), frames)) != len(frames):
raise Exception("Simulation was cancelled by user interaction or some other unknown issue. Asset not published!!")
else:
raise Exception("We can only publish nParticles from within maya!")
return IECore.StringData( result )
开发者ID:hradec,项目名称:pipeVFX,代码行数:31,代码来源:nParticles-1.py
示例3: doCreateCharacterGeoCache
def doCreateCharacterGeoCache(self, value):
geoCacheDirPath = self.geoCharacterCacheDir(value)
ns = self.nameOfCharacterCache(value)
self.shapes = self.deformCharacterShapeSel(value)
mc.select(self.shapes, r=1)
mc.cacheFile(staticCache=1,
dir=geoCacheDirPath,
f = ns,
format='OneFilePerFrame',#OneFile
sch = 1,
st=self.min, et=self.max,
points=self.shapes)
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:12,代码来源:核心脚本.py
示例4: doCreateCharacterGeoCache
def doCreateCharacterGeoCache(self, value):
geoCacheDirPath = self.geoCharacterCacheDir(value)
ns = self.nameOfCharacterCache(value)
self.shapes = self.deformCharacterShapeSel(value)
mc.select(self.shapes, r=1)
mc.cacheFile(staticCache=1,
dir=geoCacheDirPath,
f = ns,
format='OneFilePerFrame',#OneFile
sch = 1,
st=mc.textField(self.startText, q=1, text=1), et=mc.textField(self.endText, q=1, text=1),
points=self.shapes,
dtf=True)
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:13,代码来源:mulitBatchExportCache_11.py
示例5: exportAssetCache
def exportAssetCache(self, cacheXmlAn):
""" cacheXmlAn = "R:/data/cache/sq999/sh001" """
self.animCachePath=self.getAstCacheFldr(cacheXmlAn, "anim")
stF = mc.playbackOptions(q=1,ast=1)
edF = mc.playbackOptions(q=1,aet=1)
if os.path.exists(self.animCachePath):
shutil.rmtree(self.animCachePath,ignore_errors=True)
os.makedirs(self.animCachePath)
pts = self.getCacheGeos()
if pts:
mc.cacheFile(pts=pts,f=self.astCacheName,directory=self.animCachePath,cacheFormat="mcc",st=stF,et=edF,fm='OneFile',sch=1)
utils.msgWin("Message", "Cache exported successfully for %s"%self.namespace, self.silent)
return True
开发者ID:sid2364,项目名称:Maya_Python,代码行数:13,代码来源:pipeClasses.py
示例6: create
def create(start, end, dir, smr=1, attrcachefile="cachefile", per=False):
set = cmds.ls(sl=True, l=True)
len_set = float(len(set))
if len_set == 0:
cmds.warning("Please select objects!")
return
i = 0
for shape in set:
cachefile = cmds.getAttr(shape+"."+attrcachefile)
cmds.cacheFile(f=cachefile, staticCache=0, st=start, et=end, points=shape, smr=smr, dir=dir, format='OneFile')
if not per == False:
increase_per(per/len_set)
i=i+1
开发者ID:ivanzotov,项目名称:mdc,代码行数:15,代码来源:mdc.py
示例7: doCreateGeoCache
def doCreateGeoCache(self, value):
geoCacheDirPath = self.geoCacheDir(value)
ns = self.nameOfCache(value)
self.shapes = self.deformShapeSel(value)
mc.select(self.shapes, r=1)
mc.cacheFile(
staticCache=1,
dir=geoCacheDirPath,
f=ns,
format="OneFilePerFrame", # OneFile
sch=1,
st=self.min,
et=self.max,
points=self.shapes,
dtf=True,
)
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:16,代码来源:修改过的代码new_01.py
示例8: doCreateGeoCache
def doCreateGeoCache(self, value):
try:
geoCacheDirPath = self.geoCacheDir(value)
ns = self.nameOfCache(value)
self.shapes = self.deformShapeSel(value)
mc.select(self.shapes, r=1)
mc.cacheFile(staticCache=1,
dir=geoCacheDirPath,
f = ns,
format='OneFilePerFrame',#OneFile
sch = 1,
st=mc.textField(self.startText, q=1, text=1), et=mc.textField(self.endText, q=1, text=1),
points=self.shapes,
dtf=True)
except:
return 'Failed export:'
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:16,代码来源:mulitBatchExportCache_08.py
示例9: attach
def attach(dir, attrcachefile="cachefile"):
set = cmds.ls(sl=True, l=True)
for shape in set:
cachefile = cmds.getAttr(shape+"."+attrcachefile)
switch = mel.eval('createHistorySwitch("'+shape+'",false)')
cacheNode = cmds.cacheFile(f=cachefile+".xml", ia='%s.inp[0]' % switch , directory=dir, attachFile=True)
cmds.setAttr( '%s.playFromCache' % switch, 1 )
开发者ID:ivanzotov,项目名称:mdc,代码行数:8,代码来源:mdc.py
示例10: attachHairCacheNode
def attachHairCacheNode(eachDagObject, eachObjCacheDir, eachObjCacheFile):
"""连接毛发缓存"""
cacheNode = cmds.cacheFile(attachFile = True, fileName = eachObjCacheFile, directory = eachObjCacheDir,
channelName = [eachDagObject + "_hairCounts", eachDagObject + "_vertexCounts", eachDagObject + "_positions"],
inAttr = [eachDagObject + ".hairCounts", eachDagObject + ".vertexCounts", eachDagObject + ".positions"])
cmds.setAttr("%s.playFromCache"% eachDagObject, 1)
cmds.connectAttr(cacheNode+".inRange", eachDagObject+".playFromCache")
return eachDagObject + " Attach To : " + eachObjCacheDir + eachObjCacheFile + ".xml"
开发者ID:chloechan,项目名称:clothAndHair,代码行数:9,代码来源:cacheAllMag.py
示例11: get_cache_channels
def get_cache_channels(cache_path):
if cache_path is None:
return []
try:
return mcc.get_channels(cache_path)
except mcc.ParseError as e:
cmds.warning('Could not parse MCC for channel data; %r' % e)
channels = cmds.cacheFile(q=True, fileName=cache_path, channelName=True)
return [(c, None) for c in channels]
开发者ID:felixzxf,项目名称:mayatools,代码行数:9,代码来源:utils.py
示例12: attachClothCacheNode
def attachClothCacheNode(eachDagObject, eachObjCacheDir, eachObjCacheFile):
"""连接物体缓存"""
objShapeName = cmds.listRelatives(eachDagObject, shapes = True) #拿到物体的shape节点
connectFlag = False
for eachShapeNode in objShapeName:
if eachShapeNode.find("Deformed") >= 0:
switch = mel.eval('createHistorySwitch("%s",false)'%eachShapeNode)
cacheNode = cmds.cacheFile(fileName = eachObjCacheFile, directory = eachObjCacheDir, ia = "%s.inp[0]"%switch, attachFile = True)
cmds.setAttr("%s.playFromCache"% switch, 1)
cmds.connectAttr(cacheNode+".inRange", switch+".playFromCache")
connectFlag = True
if not connectFlag:
switch = mel.eval('createHistorySwitch("%s",false)'%objShapeName[0])
cacheNode = cmds.cacheFile(fileName = eachObjCacheFile, directory = eachObjCacheDir, ia = "%s.inp[0]"%switch, attachFile = True)
cmds.setAttr("%s.playFromCache"% switch, 1)
cmds.connectAttr(cacheNode+".inRange", switch+".playFromCache")
return eachDagObject + " Attach To : " + eachObjCacheDir + eachObjCacheFile + ".xml"
开发者ID:chloechan,项目名称:clothAndHair,代码行数:19,代码来源:cacheAllMag.py
示例13: doCreateCharacterGeoCache
def doCreateCharacterGeoCache(self, value):
try:
geoCacheDirPath = self.geoCharacterCacheDir(value)
ns = self.nameOfCharacterCache(value)
self.shapes = self.deformCharacterShapeSel(value)
mc.select(self.shapes, r=1)
mc.cacheFile(
staticCache=1,
dir=geoCacheDirPath,
f=ns,
format="OneFilePerFrame", # OneFile
sch=1,
st=self.min,
et=self.max,
points=self.shapes,
dtf=True,
)
except:
return "Failed export:"
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:19,代码来源:修改过的代码new_04.py
示例14: exportMcc
def exportMcc(dataPath=None):
#datapath is the asset path get from cmds.file(q=True, r=True)
if dataPath is None: raise registrarError, 'datapath not specified'
#get asset namespace and path
assetNameSpace = cmds.referenceQuery(dataPath, ns=True).replace(':','')
assetPath = dataPath[:dataPath.rfind('/')]
assetPath = assetPath[:assetPath.rfind('/')]
#get data from scene file
sceneName = cmds.getAttr('sceneInfo.shotName', asString=True)
episode = cmds.getAttr('sceneInfo.episodeName', asString=True)
sequnceDataPath = genDataPath(pathType='sequence', sceneName=sceneName, episode=episode)
frameCount = cmds.getAttr('sceneInfo.frameCount', asString=True)
endTime = 100+int(frameCount)
#select object based on conData.xml
obj = []
tree = ET.parse(assetPath+'/shader/conData.xml')
root = tree.getroot()
for chk in root:
obj.append(assetNameSpace+':'+chk.text)
cmds.select(obj)
#export sceneInfo data
if os.path.isfile(sequnceDataPath+'/info.xml'): os.remove(sequnceDataPath+'/info.xml')
root = ET.Element('root')
for attr in cmds.listAttr('sceneInfo', ud=True):
tagWrite = ET.SubElement(root, attr)
tagWrite.text = str(cmds.getAttr('sceneInfo.'+str(attr), asString=True))
tree = ET.ElementTree(root)
tree.write(sequnceDataPath+'/info.xml')
#export mcc file to server
if not os.path.isdir(sequnceDataPath+'/render/'+assetNameSpace): os.makedirs(sequnceDataPath+'/render/'+assetNameSpace)
cmds.cacheFile(f=assetNameSpace, dir=sequnceDataPath+'/render/'+assetNameSpace, st=101, et=int(endTime), fm='OneFile', points=cmds.ls(sl=True), sch=True)
openVar = open(sequnceDataPath+'/render/'+assetNameSpace+'/filePath.txt', 'w')
openVar.write(assetPath)
openVar.close()
return
开发者ID:andrewwillish,项目名称:veRegistrarFileManager,代码行数:42,代码来源:veRegCore.py
示例15: mergeFluidCaches
def mergeFluidCaches(interactiveFoamXML = '', interactiveWakeXML = ''):
"""
Creates blendcaches for the fluid containers....
"""
###########################################
## IS THIS AN INTERACTIVE SETUP FX SCENE???
## IF SO BLEND THE CACHES
###########################################
## Now that we have cached the fluids we have to merge the cache files together
## Animation publishes these caches with the SAME name as the base wake caches, so these can actually blend!
debug(app = None, method = 'mergeFluidCaches', message = 'Creating cache blends now...', verbose = False)
foamCache = cmds.cacheFile(createCacheNode = True, fileName = interactiveFoamXML.replace('\\', '/'))
foamCache = cmds.rename(foamCache, '%s_cacheFile' % CONST.INTERACTIVE_FOAM_FLUID_SHAPENODE)
debug(app = None, method = '_publish_fx_caches_for_item', message = 'foamCache: \t\t%s' % foamCache, verbose = False)
wakeCache = cmds.cacheFile(createCacheNode = True, fileName = interactiveWakeXML.replace('\\', '/'))
wakeCache = cmds.rename(wakeCache, '%s_cacheFile' % CONST.INTERACTIVE_WAKE_FLUID_SHAPENODE)
debug(app = None, method = '_publish_fx_caches_for_item', message = 'wakeCache: %s' % wakeCache, verbose = False)
cmds.select(CONST.FOAM_FLUID_SHAPENODE, r = True)
foamBlend = cmds.cacheFileCombine()
debug(app = None, method = 'mergeFluidCaches', message = 'foamBlend: %s' % foamBlend, verbose = False)
cmds.cacheFileCombine(foamBlend[0], e = True, cc = foamCache)
debug(app = None, method = 'mergeFluidCaches', message = 'CacheBlend for foam made successfully', verbose = False)
cmds.select(CONST.WAKE_FLUID_SHAPENODE, r = True)
wakeBlend = cmds.cacheFileCombine()
debug(app = None, method = 'mergeFluidCaches', message = 'wakeBlend: %s' % wakeBlend, verbose = False)
cmds.cacheFileCombine(wakeBlend[0], e = True, cc = wakeCache)
debug(app = None, method = 'mergeFluidCaches', message = 'CacheBlend for wake made successfully', verbose = False)
## Now hard set all the inputs to a weight of 1
for each in cmds.ls(type = 'cacheBlend'):
cmds.setAttr("%s.cacheData[0].weight" % each, 1)
cmds.setAttr("%s.cacheData[1].weight" % each, 1)
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:38,代码来源:fluidCaches.py
示例16: getGeoCacheFromObj
def getGeoCacheFromObj(objName):
"""根据物体名拿到该物体相连的缓存列表
Description:
若存在缓存(一个或多个),返回缓存节点列表;若不存在缓存,返回空
Arguments:
objName:物体名
Returns:
cacheNodes:缓存节点列表
"""
cacheNodesList = clothHairT.getCacheNodes() #拿到所有的cacheNode
cacheNodes = []
if cacheNodesList:
for eachCacheNode in cacheNodesList:
isGeoCache = cmds.cacheFile(eachCacheNode, query=True, geometry=True)
if isGeoCache: #为geoCache,不是hairCache
shapeWithCache = cmds.cacheFile(eachCacheNode, query=True, geometry=True)
objWithCache = cmds.listRelatives(shapeWithCache[0], parent = True) #拿到该cache的物体名
if objWithCache[0] == objName:
cacheNodes.append(eachCacheNode)
return cacheNodes
开发者ID:chloechan,项目名称:clothAndHair,代码行数:23,代码来源:cacheMag.py
示例17: cache
def cache():
""" Cache the constrained duplicate geo """
# GeoCache selected
sel = cmds.ls(sl=True)
grp = cmds.group(em=True,n='CachedGeoGrp')
for mesh in sel:
if cmds.objectType(mesh) == 'transform':
try:
shape = cmds.listRelatives(mesh,shapes=True)[0]
if cmds.objectType(shape) == 'mesh':
if mel.eval('findRelatedSkinCluster( "%s");'%mesh):
cacheFiles = cmds.cacheFile( st=290, et=344, points=shape,dir='/Users/mauricioptkvp/Desktop/21_July_2010_scarecrow_rig - Copy/CleanedUp/geoCaches')
cmds.parent(mesh,grp)
print 'Cached: ',shape
except Exception,e:
print e
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:16,代码来源:CacheNonTransformingGeo.py
示例18: isNOrGeoCacheNode
def isNOrGeoCacheNode(cacheNodeName):
"""判断是nCache或是geoCache
Description:
判断某个缓存节点是geo缓存还是n缓存
Arguments:
cacheNodeName:缓存节点名
Returns:
“nCache”:为nCache
“geoCache”:为geoCache
"""
cacheFileXML = cmds.cacheFile(cacheNodeName, query=True, f=True)[0]
cacheSize = os.path.getsize(cacheFileXML) #该XML文件的大小
if cacheSize > 5000:
return "nCache"
else:
return "geoCache"
开发者ID:chloechan,项目名称:clothAndHair,代码行数:19,代码来源:cacheAllMag.py
示例19: channels
def channels(self):
cache_path = self.cachePath()
if not cache_path:
return []
else:
return cmds.cacheFile(q=True, fileName=cache_path, channelName=True) or []
开发者ID:oglops,项目名称:mayatools,代码行数:6,代码来源:importer.py
示例20: list
mc.setAttr('nucleus1.spaceScale', 0.45)
mc.setAttr('nucleus1.subSteps', 6)
mc.setAttr('nucleus1.maxCollisionIterations', 8)
#Set Up Pin Constraints
mc.select('ten_sim_robe.vtx[2310:2334]', 'ten_sim_robe.vtx[3088:3111]', replace=True)
mc.select('ten_sim_robe.vtx[699:701]', 'ten_sim_robe.vtx[1652]', 'ten_sim_robe.vtx[1691]', 'ten_sim_robe.vtx[1694]', 'ten_sim_robe.vtx[1725]', add=True)
mc.select('ten_collide_body', toggle=True)
mel.eval('createNConstraint pointToSurface 0;')
#Cache Out the Cloth Sim
#filepath = '/users/animation/mitchbre/Documents/Cloth_Script_Files/Test_Cache'
filepath = '/users/ugrad/e/ecmraven/workspace/cache'
shapeRelatives = mc.listRelatives('ten_sim_robe', shapes=True)
print shapeRelatives
mc.cacheFile(fileName='tenRobe_cache', format='OneFilePerFrame', startTime=-20, endTime=120, points=shapeRelatives[1], directory='/users/ugrad/e/ecmraven/workspace/cache')
#Connect the Cloth Cache
mc.currentTime(-20)
pc.mel.doImportCacheFile(filepath + '/tenRobe_cache.xml', '', ['ten_Robe_Sim'], list())
#Group Colliders
mc.group(['ten_Collider', 'ten_ColliderBase', 'ten_Mittens', 'nRigid1', 'nRigid2'], name='colliders')
#Group Robe
mc.group(['ten_Robe_Sim','ten_Sash_Sim'], name='robe_Objects' ) #Objects
mc.group(['nCloth1','dynamicConstraint1'], name='robe_Sim' ) #Group Robe Sim
mc.group(['robe_Objects', 'robe_Sim'], name='robe') #Group All Robe Groups
#Group Pants
开发者ID:lasaldan,项目名称:taijitu_cloth_scripts,代码行数:31,代码来源:df_ten_preroll_sim.py
注:本文中的maya.cmds.cacheFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论