def fleshtx(arg): listseledcb=pm.checkBox("seledcb" ,q=True,v=True) vail = ["png","tga","tif","jpg"] nowtime = time.localtime(time.time()) nowtimeymd = str(nowtime[0])+str(nowtime[1])+str(nowtime[2])+str(nowtime[3]) path =pm.textField('sptexpath',tx=1,q=1).replace("\\","/") invalidtx = ['roughness','Height','Normal','f0'] if listseledcb==True: print"路径模式!!", if os.path.exists(path)==True: filelist = pm.textScrollList("piclist",q=1,si=1) if filelist!=[]: for f in range(len(filelist)): type = filelist[f].split(".")[-1] basename = filelist[f][:-len(type)] os.system("maketx -v -u --oiio --checknan --filter lanczos3 %s -o %s" %(path+"/"+filelist[f],path+"/"+basename+"tx")) # print path+"/"+filelist[f],path+"/"+basename+"tx" else: print "列表为空,获取路径下最新修改贴图并转换为tx!!", filelist= pm.getFileList(fld=path) for f in range(len(filelist)): filetime = time.localtime(os.path.getmtime(path+"/"+filelist[f])) fileymd = str(filetime[0])+str(filetime[1])+str(filetime[2])+str(filetime[3]) type = filelist[f].split(".")[-1] basename = filelist[f][:-len(type)] if fileymd ==nowtimeymd: if nowtime[4]-filetime[4]<=3: invalidjudge =[t for t in invalidtx if filelist[f].find(t)!=-1] if invalidjudge==[]: os.system("maketx -v -u --oiio --checknan --filter lanczos3 %s -o %s" %(path+"/"+filelist[f],path+"/"+basename+"tx")) else: print "路径不存在!!", else: print "场景模式!!", filelist=[] filesel = pm.ls(type="file") for a in range(len(filesel)): filepath = pm.getAttr(filesel[a]+".fileTextureName") filemode = pm.getAttr(filesel[a]+".uvTilingMode") if filemode==0: filelist.append(filepath) elif filemode==3: filelist=[] orgname = os.path.basename(filepath)[:-len(os.path.basename(filepath).split(".")[-1])-6] dirname = os.path.dirname(filepath) filell =[g for g in pm.getFileList(fld=dirname) if g.split(".")[-1] in vail] for e in range(len(filell)): traname = os.path.basename(filell[e])[:-len(os.path.basename(filell[e]).split(".")[-1])-6] if traname ==orgname: filelist.append(dirname+"/"+filell[e]) filetime = time.localtime(os.path.getmtime(dirname+"/"+filell[e])) fileymd = str(filetime[0])+str(filetime[1])+str(filetime[2])+str(filetime[3]) type = os.path.basename(filell[e]).split(".")[-1] basename = filell[e][:-len(type)] if fileymd ==nowtimeymd: if nowtime[4]-filetime[4]<=3: invalidjudge =[t for t in invalidtx if filell[e].find(t)!=-1] if invalidjudge==[]: os.system("maketx -v -u --oiio --checknan --filter lanczos3 %s -o %s" %(dirname+"/"+filell[e],dirname+"/"+basename+"tx"))
def selectSetCallback(*args): sel = pm.textScrollList('setScrollList', q=True, si=True) searchDir = pm.textField('pathTxtField', q=True, tx=True) if sel: groupDir = os.path.join(searchDir, sel[0], 'wolftv', 'asset', 'group') print groupDir if os.path.isdir(groupDir): pm.text('groupTxt', e=True, l=' found!') else: pm.text('groupTxt', e=True, l=' no diretory found') set_pieceDir = os.path.join(searchDir, sel[0], 'wolftv', 'asset', 'set_piece') print set_pieceDir if os.path.isdir(set_pieceDir): pm.text('pieceTxt', e=True, l=' found!') else: pm.text('pieceTxt', e=True, l=' no diretory found') descriptionFileDir = os.path.join(searchDir, sel[0]) descList = pm.getFileList(folder=descriptionFileDir, filespec='*.json') if len(descList) == 1: pm.text('descriptionTxt', e=True, l=' found!') elif len(descList) > 1: pm.text('descriptionTxt', e=True, l=' more than one found!') else: pm.text('descriptionTxt', e=True, l=' no json file found!')
def spaddfile(arg): vail = ["png","tga","tif","jpg"] path = pm.textField('sptexpath',tx=1,q=1).replace("\\","/") if os.path.exists(path)==True: filelist = [i for i in pm.getFileList(fld=path) if i.split(".")[-1] in vail] pm.textScrollList("piclist",e=1,ra=1,a=filelist) else: print "路径错误!!",
def udimexnode(arg): filesel =pm.ls(sl=1,type="file") if filesel!=[]: for i in range(len(filesel)): filemode = pm.getAttr(filesel[i]+".uvTilingMode") if filemode ==3: pm.setAttr(filesel[i]+".uvTilingMode",0) baseptnode = pm.listConnections(filesel[i],d=0,type="place2dTexture")[0] pm.setAttr(baseptnode+".wrapU",0) pm.setAttr(baseptnode+".wrapV",0) filepath =pm.getAttr(filesel[i]+".fileTextureName").replace("\\","/") type =filepath.split(".")[-1] adjname =os.path.basename(filepath)[:-len(type)-6] dirname = os.path.dirname(filepath) filelist = pm.getFileList(fld = dirname) fileseled = [] for f in range(len(filelist)): listype = filelist[f].split(".")[-1] listadj = os.path.basename(filelist[f])[:-len(listype)-6] if listadj == adjname: fileseled.append(dirname+"/"+filelist[f]) filenodeas = [] for l in range(1,len(fileseled)): types =fileseled[l].split(".")[-1] vvalue =int(fileseled[l][:-len(types)-1][-2]) uvalue = int(fileseled[l][:-len(types)-1][-1])-1 if types!="tx": # print fileseled[l],vvalue,uvalue filenode =pm.shadingNode("file",asTexture=1,name=filesel[i]) pm.setAttr(filenode+".fileTextureName",fileseled[l],type="string") ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=filesel[i]) pm.setAttr(ptnode+".translateFrameU",int(uvalue)) pm.setAttr(ptnode+".translateFrameV",int(vvalue)) pm.setAttr(ptnode+".wrapU",0) pm.setAttr(ptnode+".wrapV",0) filenodebuild().builder(ptnode,filenode) filenodeas.append(filenode) fnum = len(filenodeas) if fnum==1: pm.connectAttr(filenodeas[fnum-1]+".outColor",filesel[i]+".defaultColor",f=1) else: pm.connectAttr(filenodeas[fnum-1]+".outColor",filenodeas[fnum-2]+".defaultColor",f=1) else: if pm.listConnections(filesel[i]+".defaultColor",d=0)!=[]: filein = pm.listConnections(filesel[i]+".defaultColor",d=0,plugs=1) pm.disconnectAttr(filein[0],filesel[i]+".defaultColor") ptfile = pm.listConnections(filesel[i],d=0,type="place2dTexture") pm.setAttr(ptfile[0]+".wrapU",1) pm.setAttr(ptfile[0]+".wrapV",1) pm.setAttr(ptfile[0]+".translateFrameU",0) pm.setAttr(ptfile[0]+".translateFrameV",0) pm.setAttr(filesel[i]+".uvTilingMode",3) mel.eval('hyperShadePanelMenuCommand("hyperShadePanel", "deleteUnusedNodes");') else: print "请选择需要转换的file节点!!",
def pathtx(arg): path =pm.textField('sptexpath',tx=1,q=1).replace("\\","/") if os.path.exists(path): filelist= pm.getFileList(fld=path) invalidtx = ['Roughness','Height','Normal','f0'] for f in range(len(filelist)): type = filelist[f].split(".")[-1] basename = filelist[f][:-len(type)] invalidjudge =[t for t in invalidtx if filelist[f].find(t)!=-1] if invalidjudge==[]: os.system("maketx -v -u --oiio --checknan --filter lanczos3 %s -o %s" %(path+"/"+filelist[f],path+"/"+basename+"tx"))
def increment_and_save(self): """Increments the version to the next largest version of files in the current folder then save""" file_list = pmc.getFileList(folder=self.dir) max_version = 0 for filename in file_list: # main_???.ma underscore_index = filename.rfind('_') dot_index = filename.rfind('.') version = int(filename[underscore_index + 1:dot_index]) if version > max_version: max_version = version self.version = max_version + 1 self.save()
def importCallback(*args): sel = pm.textScrollList('setScrollList', q=True, si=True) searchDir = pm.textField('pathTxtField', q=True, tx=True) if sel: if pm.text('pieceTxt', q=True, label=True) == ' found!': resp = pm.confirmDialog(title='Import set_pieces', ma='center', message='Import Set_Pieces?', button=['Ok', 'No'], defaultButton='Ok', dismissString='No') if resp == 'Ok': pathTgt = ['set', sel[0], 'setPiece'] pathSrc = os.path.join(searchDir, sel[0]) database.addFolder(['set', sel[0], 'setPiece']) ingestPieces(pathSrc, pathTgt) if pm.text('groupTxt', q=True, label=True) == ' found!': resp = pm.confirmDialog(title='Import Groups', ma='center', message='Import Group?', button=['Ok', 'No'], defaultButton='Ok', dismissString='No') if resp == 'Ok': pathTgt = ['set', sel[0], 'group'] pathSrc = os.path.join(searchDir, sel[0]) database.addFolder(['set', sel[0], 'group']) ingestGroups(pathSrc, pathTgt) if pm.text('descriptionTxt', q=True, label=True) == ' found!': resp = pm.confirmDialog(title='Import File Description', ma='center', message='Import File Description?', button=['Ok', 'No'], defaultButton='Ok', dismissString='No') if resp == 'Ok': descriptionFileDir = os.path.join(searchDir, sel[0]) descList = pm.getFileList(folder=descriptionFileDir, filespec='*.json') if len(descList) == 1: descFileName = descList[0] pathTgt = ['set', sel[0]] pathSrc = os.path.join(searchDir, sel[0]) database.addFolder(['set', sel[0]]) ingestSet(descFileName, pathSrc, pathTgt) pm.deleteUI('FlyingBarkIngestTool', window=True)
def increment_and_save(self): """Checks to see if existing version of file exist, if so then it should increment and save from the largest version in file. If not, then save the scene file. """ file_list = pmc.getFileList(folder=self.dir) scene_list = list() for file in file_list: file_path = Path(file) scene = file_path.name scene_list.append(scene) top_version = self.version try: for scene in scene_list: descriptor = scene.split("_v")[0] if descriptor == self.descriptor: version_name = scene.split("_v")[1] version_name_final = version_name.split(".")[0] version = int(version_name_final) if version > self.version: top_version = version except IndexError: for scene in scene_list: descriptor = scene.split("_")[0] if descriptor == self.descriptor: version_name = scene.split("_")[1] version_name_final = version_name.split(".")[0] version = int(version_name_final) if version > self.version: top_version = version self.version = top_version + 1 self.save()
def increment_and_save(self): """Increments the version and saves the scene file. If existing versions of a file already exist, it should increment from the largest number available in the folder. Returns: Path: The path to the scene file if successful, None, otherwise. """ """ pre-code plan - Look through the contents of the directory. - create list of paths with same descriptor as self.descriptor - search through list for highest version - make our current file highest version+1, then save. - print path """ files = pmc.getFileList(folder=self.dir) scenes = list() for file in files: filename = Path(file).name scenes.append(filename) largest_number = self.version for scene in scenes: descriptor = scene.split("_v")[0] if descriptor == self.descriptor: name = scene.split("_v")[1].split(".")[0] value = int(name) if value > self.version: largest_number = value if value == self.version: self.version = (largest_number + 1) self.save()
def ingestGroups(pathSrc, pathTgt): groupPath = r'wolftv\asset\group' proxyModelPath = r'modeling\proxy_model\desc' groupsFullPath = os.path.join(pathSrc, groupPath) logger.debug('groupFullPath: %s' % groupsFullPath) fileList = pm.getFileList(folder=groupsFullPath) progressWin = ProgressWindowWidget(title='groups', maxValue=len(fileList)) for group in fileList: logger.info('importing %s to pipeLine' % group) progressWin.progressUpdate(1) fileName = group versionPath = os.path.join(groupsFullPath, fileName, proxyModelPath) versionsAvailable = pm.getFileList(folder=versionPath) maxVer = 0 for ver in versionsAvailable: verNum = int(ver[1:]) maxVer = max(maxVer, verNum) version = 'v%03d' % maxVer groupFullPath = os.path.join(versionPath, version) groupFile = pm.getFileList(folder=groupFullPath)[0] groupFullPath = os.path.join(groupFullPath, groupFile) ingestionDict = { 'name': fileName, 'version': maxVer, 'sourcePath': groupFullPath, 'assetType': 'group', 'task': 'proxy', 'setAssemble': os.path.split(pathSrc)[-1] } database.incrementNextCode('asset', fromBegining=True) itemMData = database.createItem( itemType='asset', name=fileName, path=pathTgt, workflow='group', customData={'ingestData': ingestionDict}) itemProxy = Item(task='proxy', code=itemMData['proxy']['code']) itemModel = Item(task='model', code=itemMData['model']['code']) descDict = readDescription(groupFullPath, 1, maxDepth=0, searchInGroupAsset=True) for component in descDict: logger.debug('add %s to %s' % (component['name'], fileName)) itemList = database.searchName(component['name']) if 0 < len(itemList) > 1: proxyComponentMData = database.addSource( item=itemProxy.getDataDict(), ns='ref', componentCode=itemList[0]['code'], componentTask='proxy', assembleMode='reference', update=True, proxyMode='proxy', xform=component['xform'], onSceneParent='') modelComponentMData = database.addSource( item=itemModel.getDataDict(), ns='ref', componentCode=itemList[0]['code'], componentTask='proxy', assembleMode='reference', update=True, proxyMode='model', xform=component['xform'], onSceneParent='') progressWin.closeWindow()
def ingestPieces(pathSrc, pathTgt): setPiecesPath = r'wolftv\asset\set_piece' proxyModelPath = r'modeling\proxy_model\source' setPiecesFullPath = os.path.join(pathSrc, setPiecesPath) fileList = pm.getFileList(folder=setPiecesFullPath) progressWin = ProgressWindowWidget(title='set pieces', maxValue=len(fileList)) for piece in fileList: logger.info('importing %s to pipeLine' % piece) progressWin.progressUpdate(1) fileName = piece versionPath = os.path.join(setPiecesFullPath, fileName, proxyModelPath) versionsAvailable = pm.getFileList(folder=versionPath) maxVer = 0 for ver in versionsAvailable: verNum = int(ver[1:]) maxVer = max(maxVer, verNum) version = 'v%03d' % maxVer pieceFullPath = os.path.join(versionPath, version) pieceFile = pm.getFileList(folder=pieceFullPath)[0] pieceFullPath = os.path.join(pieceFullPath, pieceFile) ingestionDict = { 'name': fileName, 'version': maxVer, 'sourcePath': pieceFullPath, 'assetType': 'set_piece', 'task': 'proxy', 'setAssemble': os.path.split(pathSrc)[-1] } database.incrementNextCode('asset', fromBegining=True) itemMData = database.createItem( itemType='asset', name=fileName, path=pathTgt, workflow='static', customData={'ingestData': ingestionDict}) item = Item(task='proxy', code=itemMData['proxy']['code']) item.status = 'created' item.putDataToDB() workPath = item.getWorkPath(make=True) shutil.copyfile(pieceFullPath, workPath) prj = database.getCurrentProject() insertFileInfo(workPath, projectName=prj, task=item.task, code=item.code, type=item.type) # done copy to publish folder item.publishVer += 1 publishPath = item.getPublishPath(make=True) shutil.copyfile(workPath, publishPath) item.putDataToDB() logger.info('%s imported as %s and published' % (piece, item.task + item.code + item.name)) progressWin.closeWindow()
def vrayspshmaker(arg): selit = pm.textScrollList("piclist",q=1,si=1) #selit = ["jia_al_1102l_Diffuse.1001.png"] path =pm.textField('sptexpath',tx=1,q=1).replace("\\","/") #path ="D:\\udim".replace("\\","/") paths =path+"/"+selit[0] textype = os.path.splitext(os.path.basename(paths))[0].split("_")[-1] type = os.path.splitext(os.path.basename(paths))[-1] udimadj= os.path.splitext(os.path.basename(paths))[0].split(".")[-1] udimvial =["1001","1002","1003","1004","1005","1006","1007","1008","1009","1011","1012","1013","1014","1015","1016","1017","1018","1019"] basename = os.path.splitext(os.path.basename(paths))[0][0:len(os.path.splitext(os.path.basename(paths))[0])-len(textype)-1] dirname = os.path.dirname(paths) texlist =pm.getFileList(fld = dirname) textlists =[i for i in texlist if i[0:len(i)-len(i.split("_")[-1])-1]==basename] textlistspath =[dirname+"/"+i for i in textlists] if udimadj not in udimvial: textypeadj =[i.split(".")[0] for i in textlists ] diftex = dirname+"/"+ basename+"_Diffuse"+type iortex = dirname+"/"+ basename+"_ior"+type nortex = dirname+"/"+ basename+"_Normal"+type heitex = dirname+"/"+ basename+"_Height"+type Glosstex = dirname+"/"+ basename+"_Glossiness"+type Reftex = dirname+"/"+ basename+"_Reflection"+type else : textypeadj =[i.split(".")[0] for i in textlists ] diftex = dirname+"/"+ basename+"_Diffuse."+str(udimadj)+type iortex = dirname+"/"+ basename+"_ior."+str(udimadj)+type nortex = dirname+"/"+ basename+"_Normal."+str(udimadj)+type heitex = dirname+"/"+ basename+"_Height."+str(udimadj)+type Glosstex = dirname+"/"+ basename+"_Glossiness."+str(udimadj)+type Reftex = dirname+"/"+ basename+"_Reflection."+str(udimadj)+type sel =pm.ls(sl=1,type="transform") if sel!=[]: selshape = sel[0].getShape() typeadj = pm.nodeType(selshape) if typeadj=="mesh": name = sel[0]+"_VS" newaishader = pm.shadingNode("VRayMtl",asShader=1,name=name) pm.setAttr(newaishader+".brdfType",3) pm.setAttr(newaishader+".lockFresnelIORToRefractionIOR",0) selshape = sel[0].getShape() pm.select(sel,r=1) pm.hyperShade(assign=newaishader) if diftex in textlistspath: filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) gammanode =pm.shadingNode("gammaCorrect",asUtility=1,name=name) pm.setAttr(gammanode+".gammaX",0.454) pm.setAttr(gammanode+".gammaY",0.454) pm.setAttr(gammanode+".gammaZ",0.454) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",diftex,type="string") pm.connectAttr(filenode+".outColor",gammanode+".value") pm.connectAttr(gammanode+".outValue",newaishader+".diffuseColor") if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if Reftex in textlistspath: filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) gammanode =pm.shadingNode("gammaCorrect",asUtility=1,name=name) pm.setAttr(gammanode+".gammaX",0.454) pm.setAttr(gammanode+".gammaY",0.454) pm.setAttr(gammanode+".gammaZ",0.454) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",Reftex,type="string") pm.connectAttr(filenode+".outColor",gammanode+".value") pm.connectAttr(gammanode+".outValue",newaishader+".reflectionColor") if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if iortex in textlistspath: filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) gammanode =pm.shadingNode("gammaCorrect",asUtility=1,name=name) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",iortex,type="string") pm.connectAttr(filenode+".outAlpha",newaishader+".fresnelIOR") if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if Glosstex in textlistspath: filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",Glosstex,type="string") pm.connectAttr(filenode+".outAlpha",newaishader+".reflectionGlossiness") if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if nortex in textlistspath: filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",nortex,type="string") pm.connectAttr(filenode+".outColor",newaishader+".bumpMap") pm.setAttr(newaishader+".bumpMapType",1) if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if heitex in textlistspath: vraybump = pm.shadingNode("VRayBumpMtl",asShader=1,name=name) vraysg = pm.listConnections(newaishader,s=0,type="shadingEngine") pm.connectAttr(newaishader+".outColor",vraybump+".base_material",f=1) pm.connectAttr(vraybump+".outColor",vraysg[0]+".surfaceShader",f=1) filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",heitex,type="string") pm.connectAttr(filenode+".outColor",vraybump+".bumpMap",f=1) if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) else: print "请选择模型!!"
def arnoldspshmaker(arg): autocbvalue=pm.checkBox("autocb" ,q=True,v=True) selit = pm.textScrollList("piclist",q=1,si=1) #selit = ["jia_al_1102l_Diffuse.1001.png"] path =pm.textField('sptexpath',tx=1,q=1).replace("\\","/") #path ="D:\\udim".replace("\\","/") paths =path+"/"+selit[0] textype = os.path.splitext(os.path.basename(paths))[0].split("_")[-1] type = os.path.splitext(os.path.basename(paths))[-1] udimadj= os.path.splitext(os.path.basename(paths))[0].split(".")[-1] udimvial =["1001","1002","1003","1004","1005","1006","1007","1008","1009","1011","1012","1013","1014","1015","1016","1017","1018","1019"] basename = os.path.splitext(os.path.basename(paths))[0][0:len(os.path.splitext(os.path.basename(paths))[0])-len(textype)-1] dirname = os.path.dirname(paths) texlist =pm.getFileList(fld = dirname) textlists =[i for i in texlist if i[0:len(i)-len(i.split("_")[-1])-1]==basename] textlistspath =[dirname+"/"+i for i in textlists] if udimadj not in udimvial: textypeadj =[i.split(".")[0] for i in textlists ] diftex = dirname+"/"+ basename+"_Diffuse"+type f0tex = dirname+"/"+ basename+"_f0"+type nortex = dirname+"/"+ basename+"_Normal"+type heitex = dirname+"/"+ basename+"_Height"+type routex = dirname+"/"+ basename+"_Roughness"+type spetex = dirname+"/"+ basename+"_Specular"+type else : textypeadj =[i.split(".")[0] for i in textlists ] diftex = dirname+"/"+ basename+"_Diffuse."+str(udimadj)+type f0tex = dirname+"/"+ basename+"_f0."+str(udimadj)+type nortex = dirname+"/"+ basename+"_Normal."+str(udimadj)+type heitex = dirname+"/"+ basename+"_Height."+str(udimadj)+type routex = dirname+"/"+ basename+"_Roughness."+str(udimadj)+type spetex = dirname+"/"+ basename+"_Specular."+str(udimadj)+type sel =pm.ls(sl=1,type="transform") if sel!=[]: selshape = sel[0].getShape() typeadj = pm.nodeType(selshape) if typeadj=="mesh": name = sel[0]+"_AS" newaishader = pm.shadingNode("aiStandard",asShader=1,name=name) pm.setAttr(newaishader+".Ks",1) pm.setAttr(newaishader+".Kd",1) pm.setAttr(newaishader+".specularDistribution",1) pm.setAttr(newaishader+".specularFresnel",1) selshape = sel[0].getShape() pm.select(sel,r=1) pm.hyperShade(assign=newaishader) if diftex in textlistspath: if autocbvalue==1: os.system("maketx -v -u --oiio --checknan --filter lanczos3 %s -o %s" %(diftex,diftex[:-len(diftex.split(".")[-1])]+"tx")) filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",diftex,type="string") pm.connectAttr(filenode+".outColor",newaishader+".color") if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if spetex in textlistspath: if autocbvalue==1: os.system("maketx -v -u --oiio --checknan --filter lanczos3 %s -o %s" %(spetex,spetex[:-len(spetex.split(".")[-1])]+"tx")) filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",spetex,type="string") pm.connectAttr(filenode+".outColor",newaishader+".KsColor") if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if f0tex in textlistspath: filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) gammanode =pm.shadingNode("gammaCorrect",asUtility=1,name=name) pm.setAttr(gammanode+".gammaX",2.2) pm.setAttr(gammanode+".gammaY",2.2) pm.setAttr(gammanode+".gammaZ",2.2) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",f0tex,type="string") pm.connectAttr(filenode+".outColor",gammanode+".value") pm.connectAttr(gammanode+".outValueX",newaishader+".Ksn") if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if routex in textlistspath: filenode =pm.shadingNode("file",asTexture=1,name=name) ptnode = pm.shadingNode("place2dTexture",asUtility=1,name=name) gammanode =pm.shadingNode("gammaCorrect",asUtility=1,name=name) pm.setAttr(gammanode+".gammaX",2.2) pm.setAttr(gammanode+".gammaY",2.2) pm.setAttr(gammanode+".gammaZ",2.2) filenodebuild().builder(ptnode,filenode) pm.setAttr(filenode+".colorProfile",3) pm.setAttr(filenode+".fileTextureName",routex,type="string") pm.connectAttr(filenode+".outColor",gammanode+".value") pm.connectAttr(gammanode+".outValueX",newaishader+".specularRoughness") if udimadj in udimvial: pm.setAttr(filenode+".uvTilingMode",3) if nortex in textlistspath and heitex in textlistspath: if autocbvalue==1: os.system("maketx -v -u --oiio --checknan --filter lanczos3 %s -o %s" %(nortex,nortex[:-len(nortex.split(".")[-1])]+"tx")) nmfilenode =pm.shadingNode("file",asTexture=1,name=name) bmfilenode =pm.shadingNode("file",asUtility=1,name=name) nmptnode = pm.shadingNode("place2dTexture",asTexture=1,name=name) bmptnode = pm.shadingNode("place2dTexture",asTexture=1,name=name) nmnode =pm.shadingNode("bump2d",asUtility=1,name=name) bmnode =pm.shadingNode("bump2d",asUtility=1,name=name) pm.setAttr(nmnode+".bumpInterp",1) pm.setAttr(nmnode+".aiFlipR",0) pm.setAttr(nmnode+".aiFlipG",0) filenodebuild().builder(nmptnode,nmfilenode) filenodebuild().builder(bmptnode,bmfilenode) pm.setAttr(nmfilenode+".colorProfile",3) pm.setAttr(bmfilenode+".colorProfile",3) pm.setAttr(bmnode+".bumpDepth",0.002) pm.setAttr(nmfilenode+".fileTextureName",nortex,type="string") pm.setAttr(bmfilenode+".fileTextureName",heitex,type="string") pm.connectAttr(nmfilenode+".outAlpha",nmnode+".bumpValue") pm.connectAttr(bmfilenode+".outAlpha",bmnode+".bumpValue") pm.connectAttr(bmnode+".outNormal",nmnode+".normalCamera") pm.connectAttr(nmnode+".outNormal",newaishader+".normalCamera") if udimadj in udimvial: pm.setAttr(nmfilenode+".uvTilingMode",3) pm.setAttr(bmfilenode+".uvTilingMode",3) elif nortex in textlistspath: if autocbvalue==1: os.system("maketx -v -u --oiio --checknan --filter lanczos3 %s -o %s" %(nortex,nortex[:-len(nortex.split(".")[-1])]+"tx")) nmfilenode =pm.shadingNode("file",asTexture=1,name=name) nmptnode = pm.shadingNode("place2dTexture",asTexture=1,name=name) nmnode =pm.shadingNode("bump2d",asUtility=1,name=name) pm.setAttr(nmnode+".bumpInterp",1) pm.setAttr(nmnode+".aiFlipR",0) pm.setAttr(nmnode+".aiFlipG",0) filenodebuild().builder(nmptnode,nmfilenode) pm.setAttr(nmfilenode+".colorProfile",3) pm.setAttr(nmfilenode+".fileTextureName",nortex,type="string") pm.connectAttr(nmfilenode+".outAlpha",nmnode+".bumpValue") pm.connectAttr(nmnode+".outNormal",newaishader+".normalCamera") if udimadj in udimvial: pm.setAttr(nmfilenode+".uvTilingMode",3) elif heitex in textlistspath: bmfilenode =pm.shadingNode("file",asUtility=1,name=name) bmptnode = pm.shadingNode("place2dTexture",asTexture=1,name=name) bmnode =pm.shadingNode("bump2d",asUtility=1,name=name) filenodebuild().builder(bmptnode,bmfilenode) pm.setAttr(bmfilenode+".colorProfile",3) pm.setAttr(bmnode+".bumpDepth",0.002) pm.setAttr(bmfilenode+".fileTextureName",heitex,type="string") pm.connectAttr(bmfilenode+".outAlpha",bmnode+".bumpValue") pm.connectAttr(bmnode+".outNormal",newaishader+".normalCamera") if udimadj in udimvial: pm.setAttr(bmfilenode+".uvTilingMode",3) else: print "请选择模型!!"
search(data['components']) def ingestAtPath(pathSrc, pathTgt): pass pathTgt = ['set', 'howlingtonClassroom', 'setPieces'] pathSrc = r'T:\FTP Downloaded Files\howlingtonClassroom' setPiecesPath = r'wolftv\asset\set_piece' proxyModelPath = r'modeling\proxy_model\source' setPiecesFullPath = os.path.join(pathSrc, setPiecesPath) print setPiecesFullPath fileList = pm.getFileList(folder=setPiecesFullPath) print fileList for piece in fileList: fileName = piece versionPath = os.path.join(setPiecesFullPath, fileName, proxyModelPath) versionsAvailable = pm.getFileList(folder=versionPath) maxVer = 0 for ver in versionsAvailable: verNum = int(ver[1:]) maxVer = max(maxVer, verNum) version = 'v%03d' % maxVer pieceFullPath = os.path.join(versionPath, version) pieceFile = pm.getFileList(folder=pieceFullPath)[0] pieceFullPath = os.path.join(pieceFullPath, pieceFile)
defaultButton='OK', cancelButton='Cancel', dismissString='Cancel') if pathInputWindow == u'\u786e\u8ba4': pathOfFiles = pm.promptDialog(query=True, text=True) pathOfFiles = pathOfFiles.replace('\\', '/') pathOfFiles = pathOfFiles + '/' reduceInputWindow = pm.promptDialog(title='减面设置', message='减少至(%):', button=['确认', '取消'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel') if pathInputWindow == u'\u786e\u8ba4': reducePercent = 100 - int(pm.promptDialog(query=True, text=True)) files = pm.getFileList(folder=pathOfFiles) os.mkdir(pathOfFiles + '/ReducedFiles/') fileCount = len(files) if len(files) == 0: cmds.warning('No Files Found') else: for f in files: if f != '.DS_Store': cmds.file(pathOfFiles + f, i=True) else: fileCount -= 1 pm.rename('_Mesh', '_Mesh0') for i in range(1, fileCount): pm.rename('_Mesh' + str(fileCount - 1 - i), '_Mesh' + str(fileCount - i)) pm.rename('Mesh', '_Mesh0')