def _find_value_obj(self, getFirstattr, values): # try: # values=float(values) # except: # values=int(values) # get_variable_type = type(values) # if type == str: # values = string(values) # elif type == int: # values = int(values) # elif type == float: # values = float(values) print type(values) getAll=cmds.ls("*") collectAttr=[] for each in getAll: try: Attrs=[(attrItem) for attrItem in cmds.listAttr (each, w=1, a=1, s=1,u=1) if cmds.getAttr(each+"."+attrItem)==values] except: pass if len(Attrs)>0: for item in Attrs: newItem=each+"."+item collectAttr.append(newItem) menuItems = cmds.optionMenu(self.objAtt, q=True, ill=True) if menuItems: cmds.deleteUI(menuItems) getListAttr=sorted(collectAttr) cmds.optionMenu(self.objAtt, e=1) for each in getListAttr: menuItem(label=each, parent=self.objAtt)
def changeCharBgCombo(self, *pArgs): #helps load the models combobox from some locations #gives the exact scene and dept presently selected self.makeSaveInvisible() deptCmb = cmds.optionMenu( "deptList", query = True, value = True) sceneCmb = cmds.optionMenu( "sceneList", query = True, value = True) self.comboChBgLoad(deptCmb, sceneCmb)
def playBlast(self,*args): """ Create instance of BlastMaster, then play blast based on user settings. If play blast is successful, Write persistent data to TG_BM_NODE """ #Get the scene name and format it for display sceneName = ' ' temp = cmds.file(query=True,sn=True) if(temp): #Not empty temp2 = os.path.split(temp) sceneName = temp2[1] #SequenceShot.Take from file name info = sceneName[:-3] #Pass GUI data as a dictionary guiData = { 'info':info, 'name':cmds.textFieldGrp(self.nameField,query=True,text=True), 'comment':cmds.textFieldGrp(self.commentField,query=True,text=True), 'camera':cmds.optionMenu(self.camMenu,query=True,value=True), 'phase':cmds.optionMenu(self.phaseMenu,query=True,value=True), 'image':cmds.textFieldButtonGrp(self.imageField,query=True,text=True), 'slate':cmds.textFieldButtonGrp(self.slateField,query=True,text=True), 'maya_scene':sceneName, 'dir':cmds.textFieldGrp(self.dirField,query=True,text=True)} blast = bm.BlastMaster() blast.playBlast(guiData)
def setUiInfo( self, *args ): self._fileTypeOption = mainInfo.fileTypeOption self._namespaceOption = mainInfo.namespaceOption self._frontNameOption = mainInfo.frontNameOption self._thisString = mainInfo.thisString cia = cmds.radioCollection( self._fileTypeCollection, q=1, cia=1 ) if self._fileTypeOption == 'motion': cmds.radioCollection( self._fileTypeCollection, e=1, sl=cia[0].split('|')[-1] ) elif self._fileTypeOption == 'hik': cmds.radioCollection( self._fileTypeCollection, e=1, sl=cia[1].split('|')[-1] ) else: cmds.radioCollection( self._fileTypeCollection, e=1, sl=cia[2].split('|')[-1] ) cia = cmds.radioCollection( self._nameCollection, q=1, cia=1 ) if self._namespaceOption == 'prefix': cmds.radioCollection( self._nameCollection, e=1, sl=cia[0].split('|')[-1] ) else: cmds.radioCollection( self._nameCollection, e=1, sl=cia[1].split('|')[-1] ) if self._frontNameOption == 'fileName': cmds.optionMenu( self._frontNameOptionMenu, e=1, sl=1 ) cmds.textField( self._thisStringField, e=1, en=0 ) else: cmds.optionMenu( self._frontNameOptionMenu, e=1, sl=2 ) cmds.textField( self._thisStringField, e=1, en=1 )
def _find_value(self, getFirstattr, values): try: values=float(values) except: values=int(values) getSel=ls(sl=1, fl=1) collectAttr=[] for each in getFirstattr: getSel=ls(getSel[0]) find=menuItem(each, q=1, label=1) try: foundAttr=getattr(getSel[0],find).get() except: pass if foundAttr == values: print foundAttr collectAttr.append(find) optionMenu(self.attributeFirstSel, e=1, v=collectAttr[0]) newAttr=getattr(getSel[0],collectAttr[0]) select(newAttr, add=1) getChangeAttr=getattr(getSel[0],collectAttr[0]).get() menuItems = cmds.optionMenu(self.attributeFirstSel, q=True, ill=True) if menuItems: cmds.deleteUI(menuItems) getListAttr=sorted(collectAttr) cmds.optionMenu(self.attributeFirstSel, e=1) for each in getListAttr: menuItem(label=each, parent=self.attributeFirstSel) self.count_attr_output(getChangeAttr) print newAttr, getChangeAttr
def saveToNW(self, *pArgs): self.nameOfCurr = self.getNameOfFile() self.filepathnew = os.path.dirname(self.nameOfCurr) #print filepath, nameOfCurr versionslocal = [] matchObj = re.match( r'.*\\(.+)\..+', self.nameOfCurr, re.M|re.I) if matchObj: substringForName=matchObj.group(1)[:-5] for f in os.listdir(self.filepathnew): if substringForName in f: addThis = f[-6:-3] versionslocal.append(addThis) versionslocal = sorted(versionslocal) theversionToOpen = versionslocal[len(versionslocal)-1] temp = str((int(theversionToOpen)+1)).zfill(3) subs = self.nameOfCurr.replace(self.nameOfCurr[-6:-3], temp) print subs print temp print theversionToOpen cmds.file(rename = subs) cmds.file(save = True) de=cmds.optionMenu( "deptList", query = True, value = True) sc=cmds.optionMenu( "sceneList", query = True, value = True) self.comboChBgLoad(de, sc) #print "Saved to: %s" % subs self.makeSaveVisible() """
def loadShots(shot=None, showErr=False): '''Load shots from the sheet for selected episod, and select shot after load if necessary. If no sheet, read shots from episod directory.''' episod = mc.optionMenu('optEpi', q=True, v=True).zfill(3) shots = util.getShotsInSheet(episod) #shots = None if ((episod == '002') or (episod == '003')) else util.getShotsInSheet(episod) # Clear shots menuItems.. shotsOld = mc.optionMenu('optShot', q=True, ils=True) if shotsOld: for x in shotsOld: mc.deleteUI(x, mi=1) if not shots: # Find shots from episod directory and load epiPath = '%s/%s/%s%s' % (util.path, util.deptDic['wkspcFldr'], util.epOrSeq, episod) expr = '^sh[0-9]{3}[a-z]?' if os.path.exists(epiPath): shots = [ x[2:] for x in sorted(os.listdir(epiPath)) if re.search(expr, x) ] if shots: # Add new list for x in sorted(shots): try: mc.menuItem('shot'+x, l=x, p='optShot') except: pass if shot: try: mc.optionMenu('optShot', e=True, v=shot) except: pass displayLastVersion(showErr=showErr)
def expose_list(self,tabAnchor,rootData): samplingConnections = rootData[0] caption = rootData[1] mc.textField( tx=caption,ed=False ,p=tabAnchor , font="boldLabelFont",bgc=[0.8,0.8,0.8]) mc.optionMenu( label=' Options: ' ,p=tabAnchor , w=432 -30) mc.menuItem( label='select' ) mc.menuItem( label='connect' ) mc.menuItem( label='swap' ) mc.menuItem( label='constraint' ) mc.menuItem( label='Manage Input' ) scrollWdth = mc.scrollLayout( horizontalScrollBarThickness=0,verticalScrollBarThickness=8, p=tabAnchor ,h=150,childResizable=True ) inputIdxList = mc.getAttr(samplingConnections,mi=True ) ctrlHgt = 24 for idx in inputIdxList: input = mc.listConnections(samplingConnections+'[%s]'%idx) if input is not None and len(input)>0: input = input[0] else: input = samplingConnections+'[%s]'%idx mc.separator(style='none', p=scrollWdth,h=6 ) mc.flowLayout( columnSpacing=4 , p=scrollWdth ) fldLnk = mc.textField( tx=input,ed=False ,w=395 -30,h=ctrlHgt) mc.popupMenu( button=3 ,p=fldLnk) mc.menuItem(l='moveUP' ) mc.menuItem(l='moveDown' ) mc.menuItem(l='Delete' ) mc.button( label='<')
def build_gui(s, language): """ build out buttons etc """ s.save_data["lang"] = language s.language = LANGUAGE[language] s.store.save() cmds.optionMenu(s.language_box, e=True, v=language) s.update_current()
def read_windowInfo(): import cPickle import sgBFunction_fileAndPath sgBFunction_fileAndPath.makeFile( WinA_Global.keyExportInfoFile, False ) sgBFunction_fileAndPath.makeFile( WinA_Global.cacheExportInfoFile, False ) sgBFunction_fileAndPath.makeFile( WinA_Global.infoPath, False ) import sgBModel_aniScene upFolderNum, addPath = sgBModel_aniScene.exportCachePathFromAni sceneName = cmds.file( q=1, sceneName=1 ) sceneFolder = '/'.join( sceneName.split( '/' )[:-1+upFolderNum] ) cacheExportPath = sceneFolder + addPath upFolderNum, addPath = sgBModel_aniScene.exportKeyPathFromAni sceneName = cmds.file( q=1, sceneName=1 ) sceneFolder = '/'.join( sceneName.split( '/' )[:-1+upFolderNum] ) keyExportPath = sceneFolder + addPath cmds.textField( WinA_Global.exportKeyPath_txf, e=1, tx=keyExportPath ) cmds.textField( WinA_Global.exportCachePath_txf, e=1, tx=cacheExportPath ) try: f = open( WinA_Global.infoPath, 'r' ) data = cPickle.load( f ) f.close() cacheTypeIndex = data[0] exportByMatrix = data[1] cmds.optionMenu( WinA_Global.optionMenu, e=1, sl=cacheTypeIndex ) cmds.checkBox( WinA_Global.chk_exportByMatrix , e=1, v=exportByMatrix ) except: return None
def export( *args ): import sgBExcute_data import sgBFunction_fileAndPath WinA_Cmd.write_windowInfo() path = cmds.textField( WinA_Global.exportPath_txf, q=1, tx=1 ) if not os.path.exists( path ): try: sgBFunction_fileAndPath.makeFolder( path ) except: cmds.error( '"%s" is not exist path' % path ) return None if not os.path.isdir( path ): cmds.error( '"%s" is not Directory' % path ) return None path = cmds.textField( WinA_Global.exportPath_txf, q=1, tx=1 ) startFrame = cmds.floatField( WinA_Global.fld_startFrame, q=1, v=1 ) endFrame = cmds.floatField( WinA_Global.fld_endFrame, q=1, v=1 ) step = cmds.floatField( WinA_Global.fld_step, q=1, v=1 ) exportTargets = sgBFunction_selection.getDeformedObjectsFromGroup( WinA_Cmd.getExportTargets() ) cacheTypeIndex = cmds.optionMenu( WinA_Global.om_cacheType, q=1, sl=1 )-1 pointsSpaceIndex = cmds.optionMenu( WinA_Global.om_pointsSpace, q=1, sl=1 )-1 cacheType = ['mcc', 'mcx'] pointsSpace = ['world', 'local'] if not exportTargets: cmds.error( 'Target is not exists' ) else: sgBExcute_data.exportCacheData( exportTargets, startFrame, endFrame, step, path, cacheType[cacheTypeIndex], pointsSpace[pointsSpaceIndex] )
def modulesLayout(): moduleArm = moduleType('Arm') moduleLeg = moduleType('Leg') moduleSpine = moduleType('spine') cmds.frameLayout(label='Prefix :',mw =1 ,mh =3,bs="etchedOut",cl= 0,cll=0,w=442) cmds.rowColumnLayout (nc=4,cw=[(1,50),(2,90),(3,80),(4,100)]) cmds.text(l =" Name :",align="left" ) cmds.textField() cmds.text(l =" Side : ",align="center" ) cmds.optionMenu (l='Method:') cmds.menuItem(label ="l/r",c ="") cmds.menuItem(label ="lt/rt",c ="") cmds.menuItem(label= "left/right",c='') cmds.menuItem(label= "custom",c='') cmds.menuItem(label= "none",c='') cmds.separator(height= 7,style ="none") cmds.setParent('..') cmds.rowColumnLayout (nc=3,cw=[(1,137),(2,137),(3,137)]) cmds.text(l ="Left :",align="center" ) cmds.text(l ="Center :",align="center" ) cmds.text(l ="Right : ",align="center" ) cmds.colorIndexSliderGrp('leftColorGrp',min =1 ,max= 31 ,value= 14 ,columnWidth=[(1,37),(2,100)]) cmds.colorIndexSliderGrp('centerColorGrp',min =1 ,max= 31 ,value= 23 ,columnWidth=[(1,37),(2,100)]) cmds.colorIndexSliderGrp('rightColorGrp',min =1 ,max= 31 ,value= 7 ,columnWidth=[(1,37),(2,100)]) cmds.setParent('..') cmds.setParent('..') cmds.separator(height =7 ,style= "none" ) cmds.scrollLayout(horizontalScrollBarThickness=16,verticalScrollBarThickness=16,h=285) moduleArm.mainModule() moduleLeg.mainModule() moduleSpine.mainModule() cmds.setParent('..') cmds.button(l='Build Skeleton',h=50)
def read_windowInfo(): import cPickle import sgBFunction_fileAndPath if not os.path.exists( WinA_Global.infoPath ): sgBFunction_fileAndPath.makeFile( WinA_Global.infoPath ) try: f = open( WinA_Global.infoPath, 'r' ) data = cPickle.load( f ) f.close() except: return None if not data: return None try:exportPath, exportType, searchFor, searchForType, splitStringAndSerchCheck, splitStringAndSearchString, cacheType, pointsSpace = data except: return None cmds.textField( WinA_Global.exportPath_txf, e=1, tx= exportPath ) items = cmds.radioCollection( WinA_Global.exportType_radio, q=1, cia=1 ) cmds.radioButton( items[ exportType ], e=1, sl=1 ) cmds.textField( WinA_Global.searchFor_txf, e=1, tx=searchFor ) items = cmds.radioCollection( WinA_Global.searchForType_radio, q=1, cia=1 ) cmds.radioButton( items[ searchForType ], e=1, sl=1 ) cmds.checkBox( WinA_Global.searchForType_check, e=1, v=splitStringAndSerchCheck ) cmds.textField( WinA_Global.searchForType_txf, e=1, tx=splitStringAndSearchString ) cmds.optionMenu( WinA_Global.om_cacheType, e=1, sl=cacheType ) cmds.optionMenu( WinA_Global.om_pointsSpace, e=1, sl=pointsSpace )
def saveToNW(self, *pArgs): self.nameOfCurr = self.getNameOfFile() self.filepathnew = os.path.dirname(self.nameOfCurr) versionslocal = [] matchObj = re.match( r'.*\\(.+)\..+', self.nameOfCurr, re.M|re.I) if matchObj: substringForName=matchObj.group(1)[:-5] for f in os.listdir(self.filepathnew): if substringForName in f: addThis = f[-6:-3] versionslocal.append(addThis) #getting the number part of the string and adding that to versionList versionslocal = sorted(versionslocal) theversionToOpen = versionslocal[len(versionslocal)-1] temp = str((int(theversionToOpen)+1)).zfill(3) #incrementing version number and then converting back to a string subs = self.nameOfCurr.replace(self.nameOfCurr[-6:-3], temp) cmds.file(rename = subs) cmds.file(save = True) de=cmds.optionMenu( "deptList", query = True, value = True) sc=cmds.optionMenu( "sceneList", query = True, value = True) print dept, scene self.comboChBgLoad(dept, scene) #to reload all other combo boxes according to the new information self.makeSaveVisible()
def _addEyeDialog(rbsNode): form = cmds.setParent(q=True) # used prefixes idxPrfxList = _getEyeIdxPrfxList(rbsNode) prfxList = [s[1] for s in idxPrfxList] # available prefixes availList = [s for s in _labelList if not s in prfxList] # preferred prefix selPrfx = None for prfx in _orderedLabelList: if prfx in availList: selPrfx = prfx break menu = cmds.optionMenu(label='Please choose a name.\nUsually "L" or "R" ') for l in availList: cmds.menuItem(label=l) if selPrfx: cmds.optionMenu(menu, e=True, v=selPrfx) sep = cmds.separator(style='none') b = cmds.button(l='OK', c=lambda *x: cmds.layoutDialog(dismiss=cmds.optionMenu(menu, q=True, v=True))) cmds.formLayout(form, e=True, attachForm=[(menu, 'top', 10), (menu, 'left', 10), (menu, 'right', 2), (b, 'bottom', 2), (b, 'left', 2), (b, 'right', 2)], attachControl=[(sep, 'top', 4, menu), (sep, 'bottom', 4, b)])
def populate_render_layer_layout(self, attr): if self.render_layer_layout is not None: node = attr.split('.')[0] # delete old ui children = cmds.columnLayout(self.render_layer_layout, q=True, childArray=True) if children is not None: for name in children: cmds.deleteUI(name) for i in range(50): i += 1 layer_name = 'render_layer_{0}_name'.format(i) if cmds.attributeQuery(layer_name, exists=True, node=node): cmds.setParent(self.render_layer_layout) current_render_layer_layout = cmds.rowLayout(nc=5) for n, width in enumerate(self.render_layer_layout_widths): cmds.rowLayout(current_render_layer_layout, e=True, cw=[n + 1, width]) cmds.textField(cc=partial(self.set_render_layer_name, node, i), text=cmds.getAttr('{0}.render_layer_{1}_name'.format(node, i))) entity_type_menu = cmds.optionMenu(cc=partial(self.set_render_layer_type, node, i)) for entity_type in ms_commands.RENDER_LAYER_ENTITY_TYPES: cmds.menuItem(label=entity_type) cmds.optionMenu(entity_type_menu, e=True, v=cmds.getAttr('{0}.render_layer_{1}_type'.format(node, i))) pattern_text_field = cmds.textField(cc=partial(self.set_render_layer_pattern, node, i), text=cmds.getAttr('{0}.render_layer_{1}_pattern'.format(node, i))) cmds.textField(cc=partial(self.set_render_layer_order, node, i), text=cmds.getAttr('{0}.render_layer_{1}_order'.format(node, i))) cmds.button(' - ', height=20, command=partial(self.remove_render_layer, node, i)) cmds.setParent(self.render_layer_layout) current_render_layer_layout = cmds.rowLayout(nc=2) cmds.button(' + ', command=partial(self.add_render_layer, node))
def SundayPlusSaveOptionsUI(): global plusSaveDialogUI if len(os.path.splitext(cmds.file(query = True, sceneName = True, shortName = True))[0].split('_')) > 2: SundayMayaGuiPath = mel.eval('getenv SundayGui;') try: if cmds.window(plusSaveDialogUI, exists = True): cmds.deleteUI(plusSaveDialogUI) plusSaveDialogUI = cmds.loadUI(uiFile = SundayMayaGuiPath + 'SundayPlusSaveOption.ui') except: plusSaveDialogUI = cmds.loadUI(uiFile = SundayMayaGuiPath + 'SundayPlusSaveOption.ui') cmds.textField('plusSaveAuthorLineEdit', edit = True, text = cmds.optionVar(query = 'SundayUserName')) cmds.textField('plusSaveNewSceneLineEdit', edit = True, text = os.path.splitext(cmds.file(query = True, sceneName = True, shortName = True))[0].split('_')[0]) cmds.textField('plusSaveFileVersionLineEdit', edit = True, text = int(os.path.splitext(cmds.file(query = True, sceneName = True, shortName = True))[0].split('_')[1]) + 1) curNameSplit = os.path.splitext(cmds.file(query = True, sceneName = True, shortName = True))[0].split('_') curCaption = '' for i in range(3, len(curNameSplit)): curCaption = curCaption + '_' + curNameSplit[i] cmds.textField('plusSaveNewCaptionLineEdit', edit = True, text = curCaption[1:]) cmds.textField('plusSaveHistoryCaptionLineEdit', edit = True, text = curCaption[1:]) cmds.optionMenu('plusSaveNewCaptionComboBox', edit = True, changeCommand = 'SundayPlusSavePy.SundayPlusSaveChangeNewCaption()') cmds.optionMenu('plusSaveHistoryCaptionComboBox', edit = True, changeCommand = 'SundayPlusSavePy.SundayPlusSaveChangeHistoryCaption()') cmds.showWindow(plusSaveDialogUI) if platform.system() == 'Windows': cmds.window(plusSaveDialogUI, edit = True, topLeftCorner = [ 100, 100]) else: SundayPlusSaveWrongFileConvention()
def ruMainWindow(): ruWin = "riggUtils" if mc.window(ruWin,q=True,ex=True): mc.deleteUI(ruWin) mc.window(ruWin,title = "Rigging Utilities") mc.scrollLayout(horizontalScrollBarThickness=16) ruMainColumn = mc.columnLayout(columnAttach=("both",5),rowSpacing=10,columnWidth=320) mc.frameLayout(label="General",bs="etchedOut",w=300,mw=5,cll=1) mc.button(label='Show Axis',command='mc.toggle(state=True, localAxis=True)') mc.button(label='Hide Axis',command='mc.toggle(state=False, localAxis=True)') mc.frameLayout(label="Non T-Pose joint placer",bs="etchedOut",w=300,mw=5,cll=1,p=ruMainColumn) mc.columnLayout(rs=5,adj=1) mc.button(l="Create Helper Locator",c =ruCreateLocator) mc.button(l="Create Joint on Helper Locator",c =ruCreateJointLocator) mc.floatSliderGrp("ruJointRadius",en=1,label="Joint Radius",field=True,minValue=0,maxValue=5,fieldMinValue=0,fieldMaxValue=5,value=0.5,cw3=(70,30,10),dc=ruJointRadius) mc.frameLayout(label="Fingers Utils",bs="etchedOut",w=300,mw=5,cll=1,p=ruMainColumn) mc.columnLayout(rs=5,adj=1) mc.floatSliderGrp("ruJointOrientation",en=1,label="Finger Orient",field=True,minValue=0,maxValue=5,fieldMinValue=0,fieldMaxValue=5,value=0.5,cw3=(70,30,10),dc=ruOrientJoint) mc.frameLayout(label="Finger Renaming",bs="etchedOut",w=300,mw=5,cll=1) mc.optionMenu('ruFinger',l='Choose finger') mc.menuItem(l='Thumb') mc.menuItem(l='Index') mc.menuItem(l='Middle') mc.menuItem(l='Ring') mc.menuItem(l='Pinky') mc.textFieldButtonGrp( label='Template string', text='', buttonLabel='Rename', bc=ruRenameFinger, cw3=[120,70,70],ct3=['left','left','left'],co3=[2,2,2] ) mc.showWindow(ruWin)
def UI(): if cmds.window('FBXExport',ex=True): cmds.deleteUI('FBXExport',wnd=True) window = cmds.window('FBXExport',t='FBX Export Version 1.0.0',wh=(450,300),sizeable=False) mainLayout = cmds.columnLayout(w=450, h=300) cmds.menuBarLayout() # cmds.menu(label ='About Me',helpMenu=True) cmds.menu(label='File') cmds.menuItem(label='About Me',c=AboutMe) cmds.menuItem(label='Help',c=Help) cmds.separator(st='in') cmds.columnLayout(columnAlign='left', columnAttach=('both', 50), rowSpacing=30, columnWidth=420) cmds.text(l='') cmds.optionMenu(label ='ExportType:',changeCommand=printNewMenuItem) cmds.menuItem( label='Export Selection' ) cmds.menuItem( label='Export All' ) cmds.rowColumnLayout(numberOfColumns=2) cmds.textField("filepath",w=270,pht=configpath, bgc=(0.2,0.2,0.2)) cmds.button(l='path',w =50,h=20,c=browseFilePath) cmds.setParent( '..' ) cmds.rowColumnLayout(numberOfColumns=2) cmds.button(l='Name:',w =50,h=20,en=False) cmds.textField('FileName',pht='Enter a filename',ed =True,w=270,bgc=(0.2,0.2,0.2)) cmds.setParent( '..' ) cmds.button(l='Export',bgc=(0.3,0.7,0.7),c=ExportFBX) cmds.showWindow(window)
def loadUI(self, ui_file): """ Loads the UI and does an post-load commands """ # monkey patch the cmds module for use when the UI gets loaded cmds.submit_callb = partial(self.get_initial_value, self) cmds.do_submit_callb = partial(self.submit, self) if cmds.window('SubmitDialog', q=True, ex=True): cmds.deleteUI('SubmitDialog') name = cmds.loadUI(f=ui_file) cmds.textScrollList('layers', e=True, append=self.layers) # check for existing projects to determine how project selection should # be displayed num_existing_projs = cmds.optionMenu('existing_project_name', q=True, ni=True) if num_existing_projs == 0: cmds.radioButton('existing_project', e=True, en=False) else: cmds.radioButton('existing_project', e=True, en=True) # callbacks cmds.checkBox('upload_only', e=True, changeCommand=self.upload_only_toggle) cmds.checkBox('distributed', e=True, changeCommand=self.distributed_toggle) cmds.optionMenu('renderer', e=True, changeCommand=self.change_renderer) cmds.radioButton('new_project', e=True, onCommand=self.select_new_project) cmds.radioButton('existing_project', e=True, onCommand=self.select_existing_project) self.change_renderer( self.renderer ) self.select_new_project( True ) return name
def loadSelectedObj(): cmds.file(new=True, pm=False, force=True) selected = cmds.optionMenu(loadComponentsMenu, q=True, v=True) global furniture global furnitureFilePath path = os.path.split(furnitureFilePath)[0] + "/meshes/furniture/" menuItems = cmds.optionMenu(componentsMenu, q=True, itemListLong=True) cmds.textField(objNameInput, tx=selected.split(".")[0].split("/")[1], e=True) if menuItems: cmds.deleteUI(menuItems) for comp in furniture["components"] : if comp["src"] == selected : global currentComponent componentDef = "" with open(os.path.split(furnitureFilePath)[0]+"/"+comp["src"], "r") as componentFile: componentDef = componentFile.read() currentComponent = json.loads(componentDef) cmds.file(path + currentComponent["src"], i=True) for con in currentComponent["connectors"]: #for connectors in the current objects connectors for types in con["componentTypes"]: cmds.menuItem(p=componentsMenu, label=types) for jnt in con["out"]: loc = cmds.spaceLocator() cmds.move(jnt["position"][0], jnt["position"][1], jnt["position"][2], loc) cmds.scale(jnt["scale"][0], jnt["scale"][1], jnt["scale"][2], loc) cmds.rotate(jnt["rotation"][0], jnt["rotation"][1], jnt["rotation"][2], loc) updateJson() selectLocators() cmds.textField(typeInput, tx=currentComponent["type"], e=True)
def _find_attV1(self, getFirstattr, attribute): try: getSel=ls(sl=1, fl=1) getFirst=getSel[0] except: print "must select something" return if ", " in getFirstattr: getFirstattr=getFirstattr.split(",") else: getFirstattr=[getFirstattr] getSel=ls(sl=1, fl=1) collectAttr=[] for each in getFirstattr: find=menuItem(each, q=1, label=1) if each in find: collectAttr.append(find) optionMenu(self.attributeFirstSel, e=1, v=collectAttr[0]) newAttr=getattr(getSel[0],collectAttr[0]) select(newAttr, add=1) getChangeAttr=getattr(getSel[0],collectAttr[0]).get() menuItems = cmds.optionMenu(self.attributeFirstSel, q=True, ill=True) if menuItems: cmds.deleteUI(menuItems) getListAttr=sorted(collectAttr) cmds.optionMenu(self.attributeFirstSel, e=1) for each in getListAttr: menuItem(label=each, parent=self.attributeFirstSel) self.count_attr_output(getChangeAttr) print newAttr, getChangeAttr
def _find_att(self, getName): getSel=cmds.ls(sl=1, fl=1) if "," in getName: getName=getName.split(", ") else: getName=[getName] collectAttr=[] for each in getSel: print each Attrs=[(attrItem) for attrItem in cmds.listAttr (each, w=1, a=1, s=1,u=1) for attrName in getName if attrName in attrItem] if len(Attrs)>0: for item in Attrs: print item newItem=each+"."+item print newItem collectAttr.append(newItem) getChangeAttr=getAttr(collectAttr[0]) menuItems = cmds.optionMenu(self.attributeFirstSel, q=True, ill=True) if menuItems: cmds.deleteUI(menuItems) getListAttr=sorted(collectAttr) cmds.optionMenu(self.attributeFirstSel, e=1) for each in getListAttr: menuItem(label=each, parent=self.attributeFirstSel) self.count_attr_output(getChangeAttr) print getChangeAttr
def switch_module(self,dishName,dishFile,*args): archive = zipfile.ZipFile(dishFile, 'r') jsonFile = archive.read('dish.ini') jsondata = json.loads(jsonFile) archive.close() #Clear chld chldrn = mc.layout( self.InfosTab, query=True, childArray=True ) for chld in chldrn: mc.deleteUI(chld) #------------------------------------------------------------------- mc.columnLayout( adjustableColumn=True ,p=self.InfosTab ,rs=5) header = """<html> <body> <h1>%s</h1></body> </html> """%(dishName ) self.dishType = dishName mc.text( self.module,e=True,l=header,font='boldLabelFont') mc.scrollField( editable=False, wordWrap=True, text=jsondata['moduleInfos'] ,h=140) mc.separator() mc.text( l='name bank') mc.columnLayout( adjustableColumn=True) LimbMenu = mc.optionMenu( label='',w=224 ) mc.menuItem( label='NONE') mc.setParent('..') mc.button(l='Open name composer',h=28) mc.optionMenu( LimbMenu ,e=True,changeCommand=partial(self.composePrfX,LimbMenu)) self.dishPrfx = mc.textField() mc.button(l='Import', h=42,c=self.validate_dish_before_merge )
def getRenderSettings(self): #get render settings frCheck = cmds.menuItem(self._rs_mm_range, q=True, cb=True) padCheck = cmds.menuItem(self._rs_mm_pad, q=True, cb=True) resCheck = cmds.menuItem(self._rs_mm_res, q=True, cb=True) fncCheck = cmds.menuItem(self._rs_mm_fnc, q=True, cb=True) ofCheck = cmds.menuItem(self._rs_mm_of, q=True, cb=True) rCheck = cmds.menuItem(self._rs_mm_r, q=True, cb=True) pdCheck = cmds.menuItem(self._rs_mm_pd, q=True, cb=True) rdCheck = cmds.menuItem(self._rs_mm_rd, q=True, cb=True) fr, pad, res, fnc, of, r, pd, rd = None, None, None, None, None, None, None, None renderers = ['default', 'rman', 'sw', 'mr'] if frCheck: fr = [cmds.intField(self._rs_start, q=True, v=True), cmds.intField(self._rs_end, q=True, v=True)] if padCheck: pad = cmds.intField(self._rs_pad, q=True, v=True) if resCheck: res = [cmds.intField(self._rs_resW, q=True, v=True), cmds.intField(self._rs_resH, q=True, v=True)] if fncCheck: fnc = cmds.optionMenu(self._rs_fncOpt, q=True, v=True) if ofCheck: of = cmds.optionMenu(self._rs_ofOpt, q=True, v=True) if rCheck: r = renderers[cmds.optionMenu(self._rs_rOpt, q=True, sl=True)] if pdCheck: pd = cmds.textField(self._rs_pdField, q=True, tx=True) if rdCheck: rd = cmds.textField(self._rs_rdField, q=True, tx=True) return {'range':fr, 'pad':pad, 'res':res, 'fnc':fnc, 'of':of, 'r':r, 'pd':pd, 'rd':rd}
def getdata(*pargs): #get data from options power = cmds.optionMenu( powerList, query = True, value = True) iter = cmds.optionMenu( iterList, query = True, value = True) size = cmds.optionMenu( sizeList, query = True, value = True) print "\nSelected params:-\nPower - ", power, "\nIterations - ", iter, "\nSize - ", size #return functools.partial(function_to_execute, int(power), float(size), int(iter)) mandelbulb(int(power), float(size), int(iter))
def registerNewAssetUI(self,*args): if cmds.window('ramAssetRegisterNew', exists=True): cmds.deleteUI('ramAssetRegisterNew', window=True) cmds.window('ramAssetRegisterNew',t='Register New Asset', s=False,mxb=False,mnb=False) cmas=cmds.columnLayout(adj=True) cmds.rowColumnLayout(nc=2,cw=[(1,60),(2,220)]) cmds.text(l='Name : ',fn='boldLabelFont', al='left') cmds.textField('assetNewName',w=220) cmds.text(l='Keyword : ',fn='boldLabelFont', al='left') cmds.textField('assetNewKey',w=220) cmds.text(l='') cmds.text(l='note : separate keyword with comma',al='left',fn='smallObliqueLabelFont') cmds.text(l='Type : ',fn='boldLabelFont', al='left') cmds.optionMenu('assetNewOption',w=220) cmds.menuItem(l='') cmds.menuItem(l='CHAR') cmds.menuItem(l='PROP') cmds.menuItem(l='SETS') cmds.text(l='Stage : ',fn='boldLabelFont', al='left') cmds.optionMenu('assetNewStage',w=220) cmds.menuItem(l='') cmds.menuItem(l='model') cmds.menuItem(l='shader') cmds.menuItem(l='rig') cmds.text(l='Descript : ',fn='boldLabelFont', al='left') cmds.scrollField('newAssetScrollField',wordWrap=True,h=100) cmds.separator(p=cmas) cmds.button(l='REGISTER AND UPLOAD',p=cmas,c=self.registerNewAssetRecord) cmds.showWindow() return
def dpaf_refreshLayerMenu(self, *args): global dpaf_unRenderableLayers # if I don't print something, scriptJob [renderLayerChange] may not work sometimes, ex: deleting the only (v)renderLayer except (x)masterLayer print 'dpaf_Afanasy: Refreshing layer optionMenu...' if cmds.optionMenu('af_layerMenu',q= 1, ni= 1): for item in cmds.optionMenu('af_layerMenu', q= 1, ils= 1): cmds.deleteUI(item) for layer in cmds.ls(et= 'renderLayer'): if cmds.getAttr(layer + '.renderable'): if layer in dpaf_unRenderableLayers: dpaf_unRenderableLayers.remove(layer) cmds.menuItem('af_layerMenuItem_' + layer, l= layer if layer != 'defaultRenderLayer' else 'masterLayer', p= 'af_layerMenu') if layer != 'defaultRenderLayer': cmds.scriptJob(ro= 1, ac= [layer + '.renderable', partial(self.dpaf_layerRenderableTracker, layer)], p= 'af_layerMenuItem_' + layer) cmds.scriptJob(nodeNameChanged= [layer, partial(self.dpaf_layerReNameTracker, layer)], p= 'af_layerMenuItem_' + layer) else: if layer not in dpaf_unRenderableLayers: dpaf_unRenderableLayers.append(layer) if layer != 'defaultRenderLayer': cmds.scriptJob(ro= 1, ac= [layer + '.renderable', partial(self.dpaf_layerRenderableTracker, layer)], p= 'cgru_afanasy_wnd') currentLayer = cmds.editRenderLayerGlobals(q= 1, currentRenderLayer= 1) if cmds.optionMenu('af_layerMenu', q= 1, ni= 1): if 'af_layerMenuItem_' + currentLayer in cmds.optionMenu('af_layerMenu', q= 1, ils= 1): cmds.optionMenu('af_layerMenu', e= 1, v= currentLayer if currentLayer != 'defaultRenderLayer' else 'masterLayer') cmds.optionMenu('af_layerMenu', e= 1, en= 1) else: cmds.menuItem('af_layerMenuItem_NoRenderableLayer', l= 'No Renderable Layer', p= 'af_layerMenu') cmds.optionMenu('af_layerMenu', e= 1, en= 0) self.dpaf_layerMenuSync()
def change_job_type(self, job_type): job_type = job_type.lower() if job_type == 'render': cmds.textField('output_dir', e=True, en=True) cmds.text('frange_label', e=True, label='Frame Range:') cmds.textField('frange', e=True, tx=self.frange) cmds.optionMenu('camera', e=True, en=True) cmds.text('layers_label', e=True, label='Render Layers:') cmds.textScrollList('layers', e=True, removeAll=True) cmds.textScrollList('layers', e=True, append=self.layers) cmds.textField('x_res', e=True, tx=self.x_res) cmds.textField('y_res', e=True, tx=self.y_res) elif job_type == 'bake': cmds.textField('output_dir', e=True, en=False) cmds.text('frange_label', e=True, label='UDIM Range:') cmds.textField('frange', e=True, tx=self.udim_range) cmds.optionMenu('camera', e=True, en=False) cmds.text('layers_label', e=True, label='Bake Sets:') cmds.textScrollList('layers', e=True, removeAll=True) cmds.textScrollList('layers', e=True, append=self.bake_sets) try: default_x_res = str(cmds.getAttr('vrayDefaultBakeOptions.resolutionX')) except: default_x_res = '' cmds.textField('x_res', e=True, tx=default_x_res) try: default_y_res = str(cmds.getAttr('vrayDefaultBakeOptions.resolutionY')) except: default_y_res = '' cmds.textField('y_res', e=True, tx=default_y_res) else: cmds.error('Unknown Job Type "%s".' % (job_type,))
def cmdUpdateApp( tabLayout, optionMenu, title, cmdType ): menuItems = cmds.optionMenu( optionMenu, q=1, itemListShort=1 ) selectIndex = cmds.optionMenu( optionMenu, q=1, select=1 )-1 addPath = cmds.menuItem( menuItems[ selectIndex ], q=1, l=1 ) f = open( model.idPath, 'r' ) data = f.read() f.close() myHost = socket.gethostname() lines = data.split( '\n' ) myId = '' for line in lines: host, id, date = line.strip().split( ':' ) if myHost == host: myId = id if not myId: view.RegistrationUI().create() return None if addPath == 'None': folderPath = folderPath = model.categoryBasePath + '/' + myId else: folderPath = model.categoryBasePath + '/' + myId + "/" + addPath makeAppFolders( tabLayout, title, cmdType, folderPath )
def asset_populateVersions(*args): menuItems = mc.optionMenu('versionOptionMenu', q=True, itemListLong=True) if menuItems != None: for item in menuItems: mc.deleteUI(item) selectedType = mc.optionMenu('op_typeOptionMenu', q=True, v=True) selectedAsset = mc.optionMenu('fileOptionMenu', q=True, v=True) selectedState = mc.optionMenu('stateOptionMenu', q=True, v=True) if selectedAsset != None: projectPath = project_dir + '/prod/assets/' + selectedType + '/' + selectedAsset + '/' + selectedState files = os.listdir(projectPath) else: files = [] for file in files: mc.menuItem(label=file, parent='versionOptionMenu')
def loadTargetList(): global selectedBlend selectedBlend = cmds.textField('selectedBlendShapeText', q=True, tx=True) existingItems = cmds.optionMenu('targetObjectMenu', q=True, itemListLong=True) if existingItems != None and existingItems != []: cmds.deleteUI(existingItems) cmds.menuItem(label='Please select blendShape', parent='targetObjectMenu') blendTargets = cmds.listAttr(selectedBlend + '.w', m=True) for target in blendTargets: cmds.menuItem(label='%s' % (target), parent='targetObjectMenu')
def UI_manipShape_form( self , name , parent ): mc.rowColumnLayout( name , nc = 3 , columnWidth = [ ( 1 , 120 ) , ( 2 , 10 ) , ( 3 , 140 ) ] , p = parent ) #--------------------------------------- mc.rowColumnLayout( nc = 1 , w = 120) mc.text( l = ' ' , h = 15 ) mc.optionMenu( 'formList' , w = 120 , bgc = [ 0.35 , 0.35 , 0.35 ] ) for form in self.CurveShape.getForms(): mc.menuItem( l = form ) mc.menuItem( l = '>> ADD <<' ) mc.text( l = ' ' , h = 15 ) mc.setParent(name) mc.text( l = ' ' , h = 15 ) mc.rowColumnLayout( nc = 1 , w = 140) mc.text( l = ' ' , h = 15 ) mc.button( l = 'CHANGE SHAPE' , bgc = [ 0.35 , 0.35 , 0.35 ] , c = '{}.cmds_changeShape()'.format(self.variableNameInGlobal) ) mc.text( l = ' ' , h = 15 )
def setCharacterSource(char, source): if not isCharacterDefinition(char): raise Exception('%s is not a valid HIKCharacterNode!' % char) # mel.eval('hikSetCurrentSource("'+source+'");') # mel.eval('hikUpdateSourceList()') # mel.eval('hikUpdateSkeletonUI()') allSourceChar = cmds.optionMenuGrp("hikSourceList", query=True, itemListLong=True) i = 1 for item in allSourceChar: optMenu = 'hikSourceList|OptionMenu' sourceChar = cmds.menuItem(item, query=True, label=True) print sourceChar.strip() if sourceChar.strip() == source: print 'Retarget Source Found.' cmds.optionMenu(optMenu, edit=True, select=i) mel.eval('hikUpdateCurrentSourceFromUI()') mel.eval('hikUpdateContextualUI()') mel.eval('hikControlRigSelectionChangedCallback') break i += 1
def pickControl(*args): global ctrl ctrl = mc.ls(sl=True) mc.textScrollList(showControl, e=True, ra=True) mc.textScrollList(showControl, e=True, append=ctrl) attrList = mc.listAttr(ctrl, userDefined=True) existedItems = mc.optionMenu(attrMenu, query=1, itemListLong=1) if existedItems: mc.deleteUI(existedItems) for at in attrList: mc.menuItem(parent=attrMenu, label=at) else: for at in attrList: mc.menuItem(parent=attrMenu, label=at)
def add_row(*args): cmds.scriptTable('scrtable', edit=True, selectedRows=[]) selectedBlend = cmds.optionMenu('targetObjectMenu', query=True, value=True) selectedBlendI = cmds.optionMenu('targetObjectMenu', query=True, select=True) selectedLinkBlend = cmds.optionMenu('fcloneObjectMenu', query=True, value=True) selectedLinkBlendI = cmds.optionMenu('fcloneObjectMenu', query=True, select=True) last_row_num = cmds.scriptTable('scrtable', query=True, rows=True) cmds.scriptTable('scrtable', edit=True, insertRow=last_row_num) cmds.scriptTable('scrtable', e=True, ci=[last_row_num, 1], cv=selectedBlend) cmds.scriptTable('scrtable', e=True, ci=[last_row_num, 2], cv=selectedLinkBlend) cmds.scriptTable('scrtable', e=True, ci=[last_row_num, 3], cv='0') cmds.scriptTable('scrtable', e=True, ci=[last_row_num, 4], cv='1') cmds.scriptTable('scrtable', e=True, ci=[last_row_num, 5], cv=selectedBlendI) cmds.scriptTable('scrtable', e=True, ci=[last_row_num, 6], cv=selectedLinkBlendI)
def displayRetake(filename='', changeDisplay=True): if not filename: episod, shot = getEpiAndShotFromUI() if not shot: return dept = mc.optionMenu('optDept', q=True, v=True).lower() vers = mc.optionMenu('optVers', q=True, v=True).zfill(2) versFldr = '%s/%s/%s%s/sh%s/versions' % (util.path, util.deptDic['wkspcFldr'], util.epOrSeq, episod, shot) shotName = '%s_%s%ssh%s_%s_v%s_rtk' % (util.projShort, util.epOrSeq, episod, shot, util.deptDic['short'], vers) for i in xrange(100): if os.path.exists('%s/%s%s.ma' % (versFldr, shotName, str(i).zfill(2))): filename = '%s%s' % (shotName, str(i).zfill(2)) break if '_rtk' in filename: indx = filename.find('_rtk') rtk = filename[indx+4: indx+6] else: rtk = 0 if changeDisplay: mc.text('txtRtk', e=True, l=int(rtk)) return rtk
def create(self): form = cmds.formLayout() optionMenu = cmds.optionMenu(l=self.label1) cmds.menuItem(l=self.label2) cmds.menuItem(l=self.label3) cmds.setParent('..') cmds.formLayout(form, e=1, af=[(optionMenu, 'left', 80), (optionMenu, 'top', 0)]) WinA_Global.optionMenu = optionMenu return form
def CreateUI(self): ''' Creates a UI for this tool ''' self.DelUI() window = cmds.window(self.mWin, height=150, title="Rename Objects", width=300) self.mLayout = cmds.columnLayout(adjustableColumn=True, height=150, parent=window, rowSpacing=10) column = cmds.columnLayout(adjustableColumn=True, columnAttach=["both", 25], parent=self.mLayout, rowSpacing=5) self.textGrp = cmds.textFieldGrp(adjustableColumn=True, columnAlign=[1, "left"], columnWidth=[2, 100], label="Name: ", parent=column) self.oMenuPrefix = cmds.optionMenu(label="Prefix", parent=column, width=100) cmds.menuItem(label="R", parent=self.oMenuPrefix) cmds.menuItem(label="L", parent=self.oMenuPrefix) cmds.menuItem(label="none", parent=self.oMenuPrefix) self.oMenuSuffix = cmds.optionMenu(label="Suffix", parent=column, width=100) cmds.menuItem(label="Geo", parent=self.oMenuSuffix) cmds.menuItem(label="Jnt", parent=self.oMenuSuffix) cmds.menuItem(label="Ctrl", parent=self.oMenuSuffix) cmds.menuItem(label="Grp", parent=self.oMenuSuffix) cmds.menuItem(label="Ctrl_Grp", parent=self.oMenuSuffix) cmds.menuItem(label="Loc", parent=self.oMenuSuffix) cmds.menuItem(label="none", parent=self.oMenuSuffix) self.oMenuPadding = cmds.optionMenu(label="Padding", parent=column, width=100) cmds.menuItem(label="#", parent=self.oMenuPadding) cmds.menuItem(label="##", parent=self.oMenuPadding) cmds.menuItem(label="none", parent=self.oMenuPadding) self.row1 = cmds.rowLayout(adjustableColumn=True, parent=self.mLayout) self.row2 = cmds.rowLayout(adjustableColumn=True, columnAttach1="both", columnOffset1=100, parent=self.row1) cmds.button(height=25, label="Rename", command=lambda *args: self.GetRename(self.oMenuPrefix, self.textGrp, self.oMenuPadding, self.oMenuSuffix), parent=self.row2, width=100) cmds.showWindow(window)
def ChangeTrack(self, tracksMenu, selectedTrack): """ Changes from one audio node to another """ # Set selected track as the audio in the playBackSlider cmds.timeControl(self.playBackSlider, edit=True, sound=selectedTrack, displaySound=True) # Get the index of this track numberOfItems = cmds.optionMenu(tracksMenu, query=True, select=True) # Set the wav reader self.reader = self.readersList[numberOfItems - 1]
def backUpFunc(self): projectList = self.jobList2[0] moduleList = self.jobList2[1] projectOption = cmds.optionMenu('optionProject2', q=True, select=True) moduleOption = cmds.optionMenu('optionModule2', q=True, select=True) project = projectList[int(projectOption) - 1] module = moduleList[int(moduleOption) - 1] ServerRoot = Path.Path().GetServerPath() LocalRoot = Path.Path().GetLocalPath() ServerBackUpPath = '%s/%s/ProjectConfig/workNodeScripts/%s/backup/' % ( ServerRoot, project, module) ids = cmds.iconTextRadioCollection('historyCodeList', select=True, q=True) try: backup_codeName = cmds.iconTextRadioButton(ids, label=True, q=True) except RuntimeError: cmds.confirmDialog(title='Erro', message='Please select a file first!', button='Gotcha') sys.exit() pass codeName = backup_codeName.split('&')[-1] file = open(ServerBackUpPath + backup_codeName, 'r').read() cmds.textField('showTextName', enable=self.flag[4], text=codeName, edit=True) cmds.scrollField('showText', enable=self.flag[3], text=file.decode('utf-8'), edit=True) self.textOldFileName = codeName cmds.deleteUI('backUpWindow')
def cmds_animCurveRefreshPath(self): #GET INFO print('cmds_animCurveRefreshPath') self.animCurvePath = self.rwi.utilsPath_RemoveFile( mc.textField( self.ftAnimPath , q = True , tx = True ) ) showLatest = mc.checkBox( self.cbFileShowLatest , q = True , v = True ) self.animCurvefiles = self.rwi.utilsPath_getFiles( self.animCurvePath , extention = 'xml' , latest = showLatest ) #REFRESH UI LIST menuItems = mc.optionMenu(self.omFileNames, q=True, itemListLong=True) if menuItems: mc.deleteUI(menuItems) for animCurvefile in self.animCurvefiles: mc.menuItem( p = self.omFileNames , l = animCurvefile ) #REFRESH UI TEXT FIELD mc.textField( self.ftAnimPath , e = True , ann = self.animCurvePath )
def cmdsGuiGroup(self,aiAOV): name = cmds.getAttr('%s.name'%aiAOV) layout = cmds.frameLayout(aiAOV,parent='aiAOV_nodeList',labelVisible=False,width=340,borderStyle='in') cmds.rowColumnLayout(numberOfColumns=7, columnWidth=[(1, 140),(2,60),(3,60),(4,80),(5,5),(6,25),(7,25)]) nameLayout = cmds.rowColumnLayout(numberOfColumns=4, columnWidth=[(1, 5),(2,25),(3,105),(4,5)]) cmds.text(' ') cmds.checkBox(label='',value=True,align='center') cmds.textField(text = name) cmds.text(' ') cmds.setParent('..') dataOptionMenu = cmds.optionMenu('dataOptionMenu',label='') cmds.menuItem(label='int') cmds.menuItem(label='bool') cmds.menuItem(label='float') cmds.menuItem(label='rgb') cmds.menuItem(label='rgba') cmds.menuItem(label='vector') cmds.menuItem(label='point') cmds.menuItem(label='point2') cmds.menuItem(label='pointer') cmds.optionMenu(label='',height=20) cmds.menuItem(label='<exr>') cmds.optionMenu(label='',height=20) cmds.menuItem(label='gaussian') data = cmds.getAttr('%s.type'%aiAOV) if data == 1: dataname = 'int' elif data == 3: dataname = 'bool' elif data == 4: dataname = 'float' elif data == 5: dataname = 'rgb' elif data == 6: dataname = 'rgba' elif data == 7: dataname = 'vector' elif data == 8: dataname = 'point' elif data == 9: dataname = 'point2' elif data == 11: dataname = 'pointer' else: pass cmds.optionMenu('dataOptionMenu',e=True,value=dataname,changeCommand=lambda *args:self.dataOptionMenuChange(aiAOV,dataOptionMenu)) cmds.text(' ') cmds.iconTextButton( style='iconOnly', image1='selectByHierarchy.png', label='',height=25,c=lambda:cmds.select(aiAOV)) cmds.iconTextButton( style='iconOnly', image1='deleteActive.png', label='',height=25,c=lambda:(cmds.delete(aiAOV),cmds.deleteUI(layout),self.refreshRenderViewAovOptionMenu())) cmds.setParent('..') cmds.setParent('..')
def PopulateNameMenu( item ): subFolders = ListFolders(ioWorkspace+"/scenes/REF/"+item) clearList("modelName") cmds.menuItem(parent="modelName",label="Create New") cmds.menuItem(parent="modelName",divider=True) if(subFolders): for file in subFolders: if (file[0] != '.') and (file != 'backup'): cmds.menuItem(parent="modelName",label=file) if(len(subFolders)>2): cmds.optionMenu("modelName", edit=True, sl=3) if(cmds.optionMenu("modelName", q=True, numberOfItems=True)>2): cmds.optionMenu("modelName", edit=True, sl=3) cmds.textField("modelNameInputText", edit=True, vis=False) cmds.optionMenu("modelName", edit=True, vis=True) cmds.button("modelBtn1", edit=True, l="Open") else: cmds.textField("modelNameInputText", edit=True, vis=True) cmds.optionMenu("modelName", edit=True, vis=False) cmds.button("modelBtn1", edit=True, l="New")
def Snap_To_Ground_Main(): # Axis , Ground_Geometry_list , Object_list , Axis_Method , PointCheckThreshold , Threshold_On , Align_to_Surface Axis_RadioButton_List = ['POSX', 'POSY', 'POSZ', 'NEGX', 'NEGY', 'NEGZ'] Axis_index = 0 for indRB in Axis_RadioButton_List: if cmds.radioButton(indRB, q=1, sl=1): # print ('Axis ' + indRB) break else: Axis_index += 1 Object_list = cmds.ls(selection=True) # Axis_Method 0 : bbox 1 : ObjectAxis 2: Lowest/extreme Position # Axis_Method = cmds.radioButton( 'Object_Axis' , q = 1 , sl = 1) Axis_Method = cmds.optionMenu("Transfrom_Method", q=1, v=1) Check_Other_Point = cmds.checkBox('Check_Other_Point', query=1, value=1) threshold = cmds.floatField('PointCheckThreshold', query=1, value=1) Align_to_Surface = cmds.checkBox('Align_to_Surface', query=1, value=1) Refresh_Viewport_each_Move = cmds.checkBox('Refresh_Viewport_each_Move', query=1, value=1) # print (Ground_Geometry_list) # print (" Axis_Method " + str(Axis_Method)) # print ( 'Check_Other_Point' + str ( Check_Other_Point ) ) # print (threshold) # print ("-----------------------------Snap_To_Ground_Main") cmds.select(cl=1) for indObject in Object_list: for indGround in Ground_Geometry_list: # print ( ('indProjection ')+str((indObject , indGround )) ) Action_Success = indProjection(indObject, indGround, Axis_index, Axis_Method, threshold, Check_Other_Point, Align_to_Surface) # print ( "Action_Success " + str(Action_Success) ) if Action_Success: print("Success : Move < " + indObject + " > to < " + indGround) if Refresh_Viewport_each_Move: cmds.refresh() break else: print("Operation Failed Try next Ground") cmds.select(Object_list)
def clearOptionMenu(name, *args): # Option menus are tiresome because you have to use its full name as parent name optionMenuFullName = None try: menuItems = cmds.optionMenu(name, q=True, ill=True) if menuItems != None and menuItems != []: cmds.deleteUI(menuItems) firstItem = menuItems[0] optionMenuFullName = firstItem[:-len( firstItem.split('|')[-1]) - 1] # strip out the child menu item name along with its preceeding "|" symbol. except: pass return optionMenuFullName
def cmds_changeShape(self): selection = mc.ls(sl = True ) form = mc.optionMenu( 'formList' , q = True , v = True ) updateOthers = mc.checkBox( self.cbModifDupli , q = True , v = True ) objs = selection if( updateOthers == 1 ): objs = objsRelationShip_getOthers( self.dupliDictCtrls , selection , addSource = True ) print( '--- form {} apply to {} ---'.format( form , objs ) ) for obj in objs: self.CurveShape.setForm( obj , form ) mc.select( selection )
def playblastFormat(self, format, *args): if format == 'avi': Cache.playblastFormat = 'avi' codecs = ['none', "MS-YUV", "IYUV codec"] elif format == 'qt': Cache.playblastFormat = 'qt' codecs = ['Sorenson Video 3', 'h264'] # menuItems = cmds.optionMenu('codecOptionMenu', query=True, itemListLong=True) if menuItems != None: # this will clear out the character menu from pervious project selection but only if there is something there to begin with. for item in menuItems: cmds.deleteUI(item) for i in codecs: cmds.menuItem(label=i, parent='codecOptionMenu')
def setVrayTextureGamma(*args): def job(fileNode, colorspace): mel.eval("vray addAttributesFromGroup {} " "vray_file_gamma 1;".format(fileNode)) cmds.setAttr(fileNode + '.vrayFileColorSpace', colorspace) colorspace = cmds.optionMenu("VMG_menu", query=True, sl=1) - 1 selected = cmds.ls(sl=True, et="file") if selected: for fileNode in selected: job(fileNode, colorspace) else: for fileNode in cmds.ls(type="file"): job(fileNode, colorspace)
def setVrayTextureFilter(*args): def job(fileNode, method): mel.eval("vray addAttributesFromGroup {} " "vray_texture_filter 1;".format(fileNode)) cmds.setAttr(fileNode + '.vrayTextureSmoothType', method) method = cmds.optionMenu("VMF_menu", query=True, sl=1) - 1 selected = cmds.ls(sl=True, et="file") if selected: for fileNode in selected: job(fileNode, method) else: for fileNode in cmds.ls(type="file"): job(fileNode, method)
def comboChBgLoad(self, deptCmb, sceneNum): self.makeSaveInvisible() #to load the combo box in the main UI fucntion for Characters and Bgs according to the main Char/Backgrounds menuItems = cmds.optionMenu('charBgList', q=True, ill=True) if menuItems: cmds.deleteUI(menuItems) #to delete existing items if called twice if deptCmb == 'Character Modeling': deptChoice = 'char' else: deptChoice = 'bg' for root, dir, files in os.walk( os.path.join(rootpath, deptChoice, 'scene' + sceneNum)): for f in files: fullpath = os.path.join(root, f) if os.path.splitext(fullpath)[1] == '.ma': cmds.menuItem(label=f, p='charBgList') self.comboVersionLoad()
def _collection_menu_change(self, character, parent): flg = logging.getLogger("lettuce._collection_menu_change") menu_item = mc.optionMenu(parent, value=True, query=True, ) flg.info("Item: {0} currently selected in menu {1}".format(menu_item, parent)) try: character.set_current_collection(menu_item) flg.info("Current Collection changed to {}".format(menu_item)) except NameError as e: flg.warning("Could not change current collection") flg.warning(e)
def playBetterGUI(self, *args, **kwds): vals = [0,0,0,0,0] ops = ["playblast", "playImages","convertToMovie","playMovie", "copyToDailies"] drops = ['imgType','movType'] window = 'playBetter' dropVals = [] for one in drops: dropMenu = '%s|%s|%s' %(window, 'mainColumn|mainRows|dropColumn', one) dropVals.append(cmd.optionMenu(dropMenu, q=True, v=True)) for one in range (0,5): go = one+1 checkbox = '%s|%s|%s' %(window, 'mainColumn|mainRows|buttonColumn', ops[one]) if (cmd.checkBox(checkbox, q = True, v = True)): self.alert(color= 'orange', message = ('Please Wait, doing '+ops[one])) self.playBetter(go, imgType = dropVals[0], movType = dropVals[1]) self.alert(color= 'grey', message = '')
def optionmenu_onChange(delf, *args): current_option = cmds.optionMenu("optionMenu_option", q=True, value=True) if current_option == 'Shot' and getInfo.isType() == 'shot': cmds.textField("RenderPath_TextFieldGroup", e=True, tx=config['shot']['path'] + getInfo.get_sequence()) cmds.textField("assetName_TextFieldGroup", e=True, tx=getInfo.get_shot()) elif current_option == "Turntable": cmds.textField("RenderPath_TextFieldGroup", e=True, tx=config['turntable']['path'])
def camera_select_new(self, node_name): self.camera_menu = cmds.optionMenu( label="Camera", changeCommand=self.camera_select_change, beforeShowPopup=self.refresh_menu, visibleChangeCommand=self.refresh_menu) # Get the camera name attribute, or create it with a default if nonexistant try: camera = cmds.getAttr(self.nodeAttr('camera_name')) except Exception: camera = self.get_filtered_cameras()[0] cmds.addAttr(dataType='string', longName='camera_name') cmds.setAttr(self.nodeAttr('camera_name'), camera, type='string') self.update_shader_parameters()
def setShader(fileBasic, fileFrozen, fileDesert): sel = cmds.ls(selection=True) currentValue = cmds.optionMenu(biomeMenu, query=True, value=True) if currentValue == 'Basic': newname = "SM_Basic_" cmds.hyperShade( assign='BasicShader') if currentValue == 'Frozen': newname = "SM_Frozen_" cmds.hyperShade( assign='FrozenShader') if currentValue == 'Desert': newname = "SM_Desert_" cmds.hyperShade( assign='DesertShader') for item in pmc.selected(): item.rename(item.name().replace('SM_Basic_', newname)) item.rename(item.name().replace('SM_Frozen_', newname)) item.rename(item.name().replace('SM_Desert_', newname))
def copyUnityScene(): #get version of Unity from selection menu unityVersion = cmds.optionMenu('versionSelection', v=True, q=True) #check if checkBox is checked and a Unity version exists if cmds.checkBox('unityCheck', v=True, q=True) and len(unityVersion) > 0: #get file/folder path parentFolder, remainingPath = getParentFolder() filename = cmds.file(q=True, sn=True, shn=True) #paths unityTemplateFile = '%s/Unity/Assets/Scenes/Templates/shotTemplate.unity' % ( parentFolder) unitySceneFile = '%s/Unity/Assets/Scenes/%s/%s.unity' % ( parentFolder, remainingPath, filename.split('.')[0]) #make folder folder = unitySceneFile.rsplit('/', 1)[0] if not os.path.exists(folder): os.makedirs(folder) #make Unity Scene File try: projectPath = "%s/Unity" % parentFolder scenePath = "Assets/Scenes/%s/%s.unity" % (remainingPath, filename.split('.')[0]) shotName = "%s" % filename.split('.')[0] #get path to Unity from text field unityEditorPath = cmds.textFieldButtonGrp('unityPath', q=True, tx=True) if platform.system() == "Windows": subprocess.Popen( '\"%s/%s/Editor/Unity.exe\" -quit -batchmode -projectPath \"%s\" -executeMethod BuildSceneBatch.PerformBuild -shotName \"%s\" -scenePath \"%s\" ' % (unityEditorPath, unityVersion, projectPath, shotName, scenePath), shell=True) else: subprocess.Popen( '%s/%s/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath %s -executeMethod BuildSceneBatch.PerformBuild -shotName \"%s\" -scenePath \"%s\" ' % (unityEditorPath, unityVersion, projectPath, shotName, scenePath), shell=True) except: print "Unable to populate Unity scene file" #copy blank Unity scene if auto population fails try: copyfile(unityTemplateFile, unitySceneFile) except: print "no Unity scene file created"
def TimeToPlayBlast(*args): resolution = { 'HD 720': [1280, 720], 'HD 1080': [1920, 1080], 'HD 540': [960, 540] } #Playblasts The Scene res = cmds.optionMenu('resViewPanel', q=True, v=True) filePath = cmds.textField("FilePathGoesHere", q=True, text=True) fileName = cmds.textField("FileNameGoesHere", q=True, text=True) NameOfFile = os.path.join(filePath, fileName) WidthField = resolution[res][0] HeightField = resolution[res][1] #make the integer field for quality 0-100 QualityField = cmds.intField("QualityField", q=True, value=True) #Make the checkbox for the show ornaments OrnamentsCheck = cmds.checkBox("OrnamentsCheck", q=True, value=True) #get ready to print the width of the play blast in the script editor editor = cmds.playblast(activeEditor=True) #hide all objects in view cmds.modelEditor(editor, edit=True, allObjects=False) #make polygons visible only cmds.modelEditor(editor, edit=True, polymeshes=True) #make cv's hidden cmds.modelEditor(editor, edit=True, cv=False) #make hulls hidden cmds.modelEditor(editor, edit=True, hulls=False) #make grid hidden cmds.modelEditor(editor, edit=True, grid=False) #make selected items hidden cmds.modelEditor(editor, edit=True, sel=False) #make heads up display hidden cmds.modelEditor(editor, edit=True, hud=False) #playblast from selected settings cmds.playblast(filename=NameOfFile, format="qt", sequenceTime=0, clearCache=1, viewer=True, showOrnaments=OrnamentsCheck, framePadding=4, percent=100, compression="H.264", quality=QualityField, widthHeight=(WidthField, HeightField), forceOverwrite=True)
def refreshDataDropDown(): #Delete all existing list items ma.optionMenu(brsUI.dataDropDown, e=True, dai=True) #If instance list has objects if len(brsUI.aBRS_instanceList) > 0: for inst in brsUI.aBRS_instanceList: ma.menuItem(label=inst.getInstanceName(), p=brsUI.dataDropDown) ma.optionMenu(brsUI.dataDropDown, e=True, en=True) else: ma.optionMenu(brsUI.dataDropDown, e=True, en=False)
def updateKove(self, fileregistration=False, registerType=None): if __main__.projectManager == 'offline': print 'Ignoring file registration as of Offline mode' elif __main__.projectManager == 'kove': # Update status & Progress __main__.activeComponent.status = cmds.optionMenu('saverGeneralStatus_optionMenu', q=True, v=True) __main__.activeComponent.percentage = cmds.text('saverGeneralProgress_label', q=True, l=True) dict = {'status':__main__.activeComponent.status, 'percentage':__main__.activeComponent.percentage} #dict = {'status':newStatus, 'percentage':self.progress} if __main__.activeType == 'assets': __main__.kove.updateAssetComponent({'data':dict, 'projectId':__main__.activeProject.id, 'assetGroupId':__main__.activeGroup.id, 'assetId':__main__.activeItem.id, 'componentId':__main__.activeComponent.id}) if __main__.activeType == 'sequences': __main__.kove.updateShotComponent({'data':dict, 'projectId':__main__.activeProject.id, 'sceneId':__main__.activeGroup.id, 'shotId':__main__.activeItem.id, 'componentId':__main__.activeComponent.id}) elif __main__.projectManager == 'ftrack': print 'ftrack saver' print '# core: File successfully saved'