def imp_option_list(self, *args): del self.listOfImagePlanes[:] self.imgplanesOptionMenu.clear() # creates a list of existing image planes and update Image Plane Option menu self.listOfImagePlanes = [i for i in pm.ls(type='imagePlane')] _logger.debug("imp_option_list: %s" % self.listOfImagePlanes) if len(self.listOfImagePlanes) > 0: self.currentImgPlane = pm.imagePlane(self.listOfImagePlanes[0], query=True, name=True) for item in self.listOfImagePlanes: _logger.debug('imp is %s' % pm.imagePlane(item, query=True, name=True)) imp = pm.imagePlane(item, query=True, name=True) pm.menuItem(l=imp[0], parent=self.imgplanesOptionMenu) # set active menu item to current image plane _logger.debug('Current Imageplane: %s' % self.currentImgPlane) pm.optionMenu(self.imgplanesOptionMenu, e=True, value="%s" % self.currentImgPlane[0]) else: pm.menuItem(l="No Image Planes", parent=self.imgplanesOptionMenu) self.currentImgPlane = False
def _makeArgRow(self, methodIndex, type, argName, direction, annotation=''): COL1_WIDTH = 260 COL2_WIDTH = 120 pm.rowLayout(nc=4, cw4=[COL1_WIDTH, COL2_WIDTH, 70, 150], **self.layout) label = str(type) pm.text(l=label, ann=annotation) pm.text(l=argName, ann=annotation) if direction == 'return': pm.text(l='(result)') else: direction_om = pm.optionMenu(l='', w=60, ann=annotation, cc=pm.CallbackWithArgs( MethodRow.setDirection, self, methodIndex, argName)) for unit in ['in', 'out']: pm.menuItem(l=unit) direction_om.setValue(direction) if self._isPotentialUnitType(type): om = pm.optionMenu(l='', ann=annotation, cc=pm.CallbackWithArgs(MethodRow.setUnitType, self, methodIndex, argName)) for unit in ['unitless', 'linear', 'angular', 'time']: pm.menuItem(l=unit) if argName == 'return': try: value = factories.apiClassOverrides[ self.apiClassName]['methods'][self.apiMethodName][ methodIndex]['returnInfo']['unitType'] except KeyError: pass else: try: value = factories.apiClassOverrides[ self.apiClassName]['methods'][self.apiMethodName][ methodIndex]['argInfo'][argName]['unitType'] except KeyError: pass try: om.setValue(value) except: pass else: pm.text(l='', ann=annotation) pm.setParent('..')
def _build_add_io_frame(parent_layout): pm.frameLayout('add_io_frame', label="Add IO", collapsable=True) add_io_col = pm.columnLayout(adj=True, columnAttach=('both', 5)) pm.separator(height=5, style='none') pm.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAlign=[(1, 'left'), (2, 'left')], columnAttach=[(1, 'both', -1), (2, 'both', 0), (3, 'both', 0)]) pm.text(label='IO Name: ') pm.textField('t_ioNameText', placeholderText='ioName', font=FONT) pm.setParent('..') pm.separator(height=3, style='none') pm.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAlign=[(1, 'left'), (2, 'left')], columnAttach=[(1, 'both', -1), (2, 'both', 0), (3, 'both', 0)]) pm.text(label='Postproc ID: ') pm.textField('t_ioPostprocIDText', placeholderText='postprocID', font=FONT) pm.setParent('..') pm.separator(height=3, style='none') pm.optionMenu('ioNumberMenu', label='IO Number:', height=18) io_number_list = [i + 1 for i in range(12)] for io_number in io_number_list: pm.menuItem(label=io_number) pm.separator(height=3, style='none') pm.optionMenu('ioTypeMenu', label='IO Type: ', height=18) io_type = ['digital', 'analog'] for attr in io_type: pm.menuItem(label=attr) pm.separator(height=3, style='none') pm.rowLayout(numberOfColumns=1) pm.checkBox('cb_ignoreIO', label="Ignore in prostprocessor", value=0) pm.setParent('..') pm.separator(height=4, style='none') pm.setParent(add_io_col) pm.button('b_add_io', label='Add IO', height=25, backgroundColor=[.361, .361, .361], command=mimic_io.add_io) pm.separator(height=5, style='none') pm.setParent(parent_layout)
def reset_external_axis_UI(): """ Restores externa axis UI inputs in Mimic UI to defaults :return: """ pm.frameLayout('add_external_axis_frame', edit=True, label="Add External Axis") # Update axis parameters pm.textField('t_externalAxisDescriptionText', edit=True, text='', editable=True) pm.optionMenu('axisNumberMenu', edit=True, value='1') pm.optionMenu('drivingAttributeMenu', edit=True, value='translateX') pm.textField('t_externalAxisLimitMin', edit=True, text='') pm.textField('t_externalAxisLimitMax', edit=True, text='') pm.textField('t_externalAxisVelocityLimit', edit=True, text='') pm.checkBox('cb_ignoreExternalAxis', edit=True, value=0) # Change "Add Axis" button to "Update Axis" # Change background color of button pm.button('b_add_Axis', edit=True, label='Add Axis', backgroundColor=[.361, .361, .361], command=add_external_axis)
def scaleChara(self, mayaFalse): #this part does the importing and admin stuff try: pm.createReference( '//p.sv/Prism/project/Parallel/element/character_Roll/scenes/' + pm.optionMenu(self.charalist, q=True, value=True)[-4:-1] + '001_SP01.mb', namespace=':') except: pm.confirmDialog(title=u'Parallel scaling', message=u'Parallel フォルダーの許可がないです。') #this part does the scaling pm.optionMenu('listofchara', q=True, value=True) inverseScale = 1 / self.nameScale[pm.optionMenu( self.charalist, q=True, value=True)] pm.scale('Reference|Root', inverseScale, inverseScale, inverseScale) for i in pm.listRelatives('Reference', ad=True, type='joint'): try: pm.copyKey(i) pm.pasteKey(i.replace('Reference', 'Reference1')) except: print 'no keys to copypasta' pm.scaleKey('Reference1|Root|Hips', valueScale=inverseScale, valuePivot=0, attribute='translate') #this part cleans up the file pm.delete('Reference') pm.listReferences()[0].importContents(removeNamespace=False) pm.rename('Reference1', 'Reference')
def create(self): self.main_layout = pm.columnLayout(adjustableColumn= True, width= 400) main_frame = pm.frameLayout( label='%s' % (self.obj), collapsable= True) pm.columnLayout(adjustableColumn= False, width= 400) self.mapping_menu = pm.optionMenu( label='Mapping', width= 150, changeCommand= pm.Callback(self.mapping_type, self.obj)) pm.menuItem( label='Spherical') pm.menuItem( label='Angular') pm.setParent(main_frame) self.type_menu = pm.optionMenu( label='Type', width= 150, changeCommand= pm.Callback(self.file_type, self.obj)) pm.menuItem( label='Image File') pm.menuItem( label='Texture') self.image_field = pm.textFieldButtonGrp(label= 'Image Name', editable= False, columnWidth3= [100,200,100], buttonLabel= '<<<', buttonCommand= pm.Callback(self.load_image, self.obj)) self.list_field = pm.textScrollList(allowMultiSelection= False , width= 100, height= 100) pm.attrColorSliderGrp( at='%s.color' % (self.obj), columnWidth4= [100, 75, 175, 50]) pm.rowColumnLayout(numberOfColumns= 2, columnWidth= ([1, 200], [2, 200])) pm.button(label= 'List Ramps', command= pm.Callback(self.list_textures)) pm.button(label= 'Link Ramps', command= pm.Callback(self.link_texture, self.obj)) pm.button(label= 'Edit Ramps', command= pm.Callback(self.edit_ramp)) pm.button(label= 'Create Ramps', command= pm.Callback(self.create_ramp))
def __init__(self): respresets = [4096, 2048, 1024, 512, 256, 128, 64, 32] with pm.frameLayout(l='Options', cll=True, cl=False, bs='out'): with pm.columnLayout(): pm.text('Map Size:') pm.separator(st='in', width=160, height=8) with pm.rowColumnLayout(nc=3, cw=[20, 60]): pm.text(l='Width:') self.width = pm.intField(v=1024, width=42) with pm.optionMenu(): for i in respresets: pm.menuItem(l=i) pm.text(l='Height:') self.height = pm.intField(v=1024, width=42) with pm.optionMenu(): for i in respresets: pm.menuItem(l=i) pm.button(l='Get Map Size') pm.separator(st='in', width=160, height=8) with pm.columnLayout(): self.compSpace = pm.checkBox(l='Retain Component Spaceing', cc=lambda *args: pm.texMoveContext('texMoveContext', e=True, scr=self.compSpace.getValue()), v=pm.texMoveContext('texMoveContext', q=True, scr=True)) self.pixelUnits = pm.checkBox(l='Transform In Pixels')
def update_io_UI(io_info): """ Updates IO inputs of Mimic UI based on IO selection in io list :param io_info: dict containing info about selected io :return: """ # Change frame name from "Add" to "Update" pm.frameLayout('add_io_frame', edit=True, label="Update IO") # Update io parameters pm.textField('t_ioNameText', edit=True, text=io_info['IO Name'], editable=False) pm.textField('t_ioPostprocIDText', edit=True, text=io_info['Postproc ID']) pm.optionMenu('ioNumberMenu', edit=True, value=str(io_info['IO Number'])) pm.optionMenu('ioTypeMenu', edit=True, value=io_info['Type'], enable=False) pm.checkBox('cb_ignoreIO', edit=True, value=io_info['Ignore']) # Change "Add IO" button to "Update IO" # Change background color of button pm.button('b_add_io', edit=True, label='Update IO', backgroundColor=[.7, .7, .7], command=update_io)
def __init__(self): version = "1.0" if pm.window('ms_copyAnimWin', exists=True): pm.deleteUI('ms_copyAnimWin', window=True) self.window = pm.window( 'ms_copyAnimWin', title="Copy Animation v%s" % version, iconName='ms_copyAnimWin') #, widthHeight=(200,100) ) with pm.columnLayout(adj=1): self.mainLO = pm.columnLayout(adjustableColumn=True) removeList = ['shared', 'UI'] self.namespaces = pm.namespaceInfo(lon=1) for each in removeList: self.namespaces.remove(each) with pm.rowLayout(nc=2): self.srcFld = pm.optionMenu(label='Source Namespace') for each in self.namespaces: pm.menuItem(label=each) self.tgtFld = pm.optionMenu(label='Target Namespace') for each in self.namespaces: pm.menuItem(label=each) pm.button(l='Copy animation', c=self.copyAnim) pm.showWindow(self.window)
def copyAnim(self, args): ''' Copy all animation on transform nodes from one namespace to another ''' srcNS = pm.optionMenu(self.srcFld, q=1, v=1) tgtNS = pm.optionMenu(self.tgtFld, q=1, v=1) sourceControls = pm.ls('%s:*' % srcNS, type='transform') sourceControls += pm.ls('%s:CRIG:*' % srcNS, type='transform') msgs = [] for src in sourceControls: try: if not src.getShape().type() == 'nurbsCurve': continue except: continue print "Trying: ", src cnt = src.split(':')[1:] cnt = ":".join(cnt) tgtCnt = '%s:%s' % (tgtNS, cnt) try: pm.copyKey(src) pm.pasteKey(tgtCnt) except Exception, e: # try: # pm.delete(pm.pointConstraint(src, tgtCnt, mo=0)) # pm.delete(pm.orientConstraint(src, tgtCnt, mo=0)) # except Exception, e: print '\nFailed' print 'Source: ', src print 'Error:', e
def __init__( self, label='', options=[], parent='..', cc=None): self.custom={} if cc!=None: self.optionMenu=pm.optionMenu( l=label, p=parent, cc=cc) else: self.optionMenu=pm.optionMenu( l=label, p=parent) for i,option in enumerate(options): self.custom[i+1]=option pm.menuItem(l=option)
def _build_add_robot_frame(parent_layout): # Create frame layout with one column add_robot_frame = pm.frameLayout(label="Add Robot", collapsable=True) add_robot_col = pm.columnLayout(adj=True, columnAttach=('both', 5)) pm.separator(height=5, style='none') # Create list of robots pm.rowLayout(numberOfColumns=2, adjustableColumn=1, columnAttach=(1, 'left', 3), columnWidth=[(1, 158), (2, 45)], height=20) pm.optionMenu('robotImportList') rigs = general_utils.get_rigs_dict() rig_names = general_utils.get_rigs_names(rigs) for rig_name in rig_names: pm.menuItem(label=rig_name) pm.button(label=' Add ', command=add_robot, width=45, height=20, annotation='Imports selected robot into the scene') pm.setParent(add_robot_frame) pm.separator(style='none') pm.setParent(parent_layout)
def populateObjects(self, *args): ProjectPath = pm.text('FilePathText', q=True, l=True) menuItems = pm.optionMenu("Contents_Menu", q=True, itemListLong=True) print 'MENU ITEMS LIST :' print menuItems if menuItems != None: for item in menuItems: pm.deleteUI(item) selectedProject = pm.optionMenu("library_Menu", q=True, v=True) print selectedProject projectPath = ProjectPath + "/" + selectedProject + "/" files = os.listdir(projectPath) characters = [] for file in files: if file.rpartition(".")[2] == "mb": characters.append(file) for character in characters: niceName = character.rpartition(".")[0] pm.menuItem(label=character, parent="Contents_Menu")
def __init__(self, settingsObj): rowColumnLayout(nc=2) # LegType UI text(l='Leg Type') self.legType = optionMenu(l='') menuItem(l='Human') menuItem(l='Dogleg') settingsObj.settings.optionMenuSetup(self.legType, 'legType') # Spine Orient UI text(l="Spine Orientation") self.spineOrient = optionMenu(l='') menuItem('Vertical') menuItem('Horizontal') settingsObj.settings.optionMenuSetup(self.spineOrient, 'spineOrient') text(l='Number of Spine Joints') self.spineCount = intFieldGrp(nf=1, v1=settingsObj.settings.spineCount) text(l='Number of Fingers') self.fingerCount = intFieldGrp(nf=1, v1=settingsObj.settings.fingerCount) text(l="Thumb") self.thumb = checkBox(l='', v=settingsObj.settings.thumb) #setParent("..") text(l='') text(l='') text(l='') button(l="Start", w=300, c=core.alt.Callback(self.start))
def _get_io_params(): """ Finds the user-defined IO parameters from the Mimic UI Checks that user inputs meet parameter riteria :return io_param_dict: dict containing IO params "IO Name" (str) "Postproc ID" (str) "IO Number" (int) "Type" (str) "Ignore" (bool) """ io_param_dict = {} io_param_dict['IO Name'] = pm.textField('t_ioNameText', query=True, text=True) io_param_dict['Postproc ID'] = pm.textField('t_ioPostprocIDText', query=True, text=True) io_param_dict['IO Number'] = int( pm.optionMenu('ioNumberMenu', query=True, value=True)) io_param_dict['Type'] = pm.optionMenu('ioTypeMenu', query=True, value=True) io_param_dict['Ignore'] = pm.checkBox('cb_ignoreIO', query=True, value=True) _check_io_params(io_param_dict) # Ensure IO name input complies with Maya's attribute name requirements io_name = io_param_dict['IO Name'] io_param_dict['IO Name'] = _filter_io_name(io_name) return io_param_dict
def deleteShotSculptNode(): global editState ssn = pm.optionMenu("selectedSSNode_menu", q=True, v=True) print ssn bshps = pm.getAttr(ssn + '.bshps') result = pm.confirmDialog(title='Delete Shot Sculpt Group', message='Are you sure you want to delete ' + ssn + "?", button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if result == 'Yes': ##exit editmode if enabled if editState: editSculptFrame() pm.textScrollList("SculptLayers_tsl", e=True, ra=True) pm.delete(ssn, bshps) pm.deleteUI(str(ssn)) existing_ssns = pm.optionMenu('selectedSSNode_menu', q=True, ils=True) print existing_ssns if len(existing_ssns) < 1: pm.menuItem("-- None --", p="selectedSSNode_menu") else: loadShotSculptNode()
def wnd_rowShapes(): global opt_shapeOptions, txt_shapeName, txt_shapeSuffix global opt_placementOption pm.frameLayout(label="Shape Maker", width=500, collapsable=True) pm.rowLayout(numberOfColumns=2, columnAlign=([1, "left"], [2, "right"]), width=450, columnWidth=([1, 200], [2, 250])) pm.text(label="Choose a shape") opt_shapeOptions = pm.optionMenu(width=100) pm.menuItem(label="Circle") pm.menuItem(label="Sphere") pm.menuItem(label="Square") pm.menuItem(label="Cube") pm.menuItem(label="2D Arrow") pm.menuItem(label="3D Arrow") pm.menuItem(label="Round Pointer") pm.menuItem(label="COG Circle") pm.menuItem(label="Compass") pm.setParent("..") pm.rowLayout(numberOfColumns=2, columnAlign=([1, "left"], [2, "right"]), width=450, columnWidth=([1, 200], [2, 250])) pm.text(label="Enter a name.\nLeave blank for default shape name.") txt_shapeName = pm.textField(placeholderText="shape") pm.setParent("..") pm.rowLayout(numberOfColumns=2, columnAlign=([1, "left"], [2, "right"]), width=450, columnWidth=([1, 200], [2, 250])) pm.text( label="Insert a suffix.\nLeave blank for default\n\"icon\" to be added" ) txt_shapeSuffix = pm.textField(placeholderText="icon") pm.setParent("..") pm.rowLayout(numberOfColumns=2, columnAlign=([1, "left"], [2, "right"]), width=450, columnWidth=([1, 200], [2, 250])) pm.text(label="Shape is placed on:") opt_placementOption = pm.optionMenu(width=150) pm.menuItem(label="Origin") pm.menuItem(label="Currently Selected Object") pm.setParent("..") pm.rowLayout(numberOfColumns=3, columnWidth=([1, 150], [2, 150])) pm.text(label="") pm.button(label="Create Shape", command=pm.Callback(createShape, opt_shapeOptions, txt_shapeName, txt_shapeSuffix, opt_placementOption)) pm.text(label="") pm.setParent("..") pm.setParent("..")
def build(self, *args): ProjectPath = pm.text('FilePathText', q=True, l=True) selectedProject = pm.optionMenu("library_Menu", q=True, v=True) FolderPath = ProjectPath + "/" + selectedProject + "/" selectedCharacter = pm.optionMenu("Contents_Menu", q=True, v=True) filePath = FolderPath + selectedCharacter print filePath cmds.file(filePath, i=True, iv=True)
def updateMenu(self, nodeAttr): self.clear() currVal = str(pm.getAttr(nodeAttr)) prevVal = str(self._prevLabel) defval = str(self._defaultLabel) currVal = currVal.replace(" (Inactive)", "") prevVal = prevVal.replace(" (Inactive)", "") if defval == "": self._defaultLabel = currVal defval = str(self._defaultLabel) if currVal == self.NEW_AOV_ITEM: currVal = prevVal activeNodes = dict(aovs.getAOVNodes(names=True)) self.activeNames = sorted(activeNodes.keys()) # If default value is not used, add it to the menu list if defval != currVal: if defval not in self.activeNames and defval != self.BEAUTY_ITEM: defval = self.UNKNOWN_AOV_ITEM % defval pm.menuItem(label=defval, parent=(self.menuName)) if not currVal or currVal == self.EMPTY_AOV_ITEM: currVal = self.EMPTY_AOV_ITEM elif currVal not in self.activeNames and currVal != self.BEAUTY_ITEM: currVal = self.UNKNOWN_AOV_ITEM % currVal pm.menuItem(label=currVal, parent=(self.menuName)) # beauty is always first, so remove it in all cases, it will be added below if # includeBeauty is enabled try: index = self.activeNames.index(self.BEAUTY_ITEM) self.activeNames.pop(index) except ValueError: pass if self.includeBeauty: pm.menuItem(label=self.BEAUTY_ITEM, parent=(self.menuName)) # add items for aov in self.activeNames: pm.menuItem(label=aov, parent=(self.menuName)) if self.allowEmpty: pm.menuItem(label=self.EMPTY_AOV_ITEM, parent=(self.menuName)) if self.allowCreation: pm.menuItem(label=self.NEW_AOV_ITEM, parent=(self.menuName)) # set active pm.optionMenu(self.menuName, edit=True, value=currVal) self._prevLabel = currVal menu = pm.optionMenu( self.menuName, edit=True, changeCommand=lambda *args: self.changeCallback(nodeAttr, *args)) return menu
def updateMenu(self, nodeAttr): self.clear() currVal = str(pm.getAttr(nodeAttr)) prevVal = str(self._prevLabel) defval = str(self._defaultLabel) currVal = currVal.replace(" (Inactive)", "") prevVal = prevVal.replace(" (Inactive)", "") if defval == "": self._defaultLabel = currVal defval = str(self._defaultLabel) if currVal == self.NEW_AOV_ITEM: currVal = prevVal activeNodes = dict(aovs.getAOVNodes(names=True)) self.activeNames = sorted(activeNodes.keys()) # If default value is not used, add it to the menu list if defval != currVal: if defval not in self.activeNames and defval != self.BEAUTY_ITEM: defval = self.UNKNOWN_AOV_ITEM % defval pm.menuItem(label=defval, parent=(self.menuName)) if not currVal or currVal == self.EMPTY_AOV_ITEM: currVal = self.EMPTY_AOV_ITEM elif currVal not in self.activeNames and currVal != self.BEAUTY_ITEM: currVal = self.UNKNOWN_AOV_ITEM % currVal pm.menuItem(label=currVal, parent=(self.menuName)) # beauty is always first, so remove it in all cases, it will be added below if # includeBeauty is enabled try: index = self.activeNames.index(self.BEAUTY_ITEM) self.activeNames.pop(index) except ValueError: pass if self.includeBeauty: pm.menuItem(label=self.BEAUTY_ITEM, parent=(self.menuName)) # add items for aov in self.activeNames: pm.menuItem(label=aov, parent=(self.menuName)) if self.allowEmpty: pm.menuItem(label=self.EMPTY_AOV_ITEM, parent=(self.menuName)) if self.allowCreation: pm.menuItem(label=self.NEW_AOV_ITEM, parent=(self.menuName)) # set active pm.optionMenu(self.menuName, edit=True, value=currVal) self._prevLabel = currVal menu = pm.optionMenu(self.menuName, edit=True, changeCommand=lambda *args: self.changeCallback(nodeAttr, *args)) return menu
def autoKey(attr, time): ##Get attrs from ui easeInFrames = pm.intField("EaseInIntFeild", q=True, v=True) holdInFrames = pm.intField("HoldInIntFeild", q=True, v=True) holdOutFrames = pm.intField("HoldOutIntFeild", q=True, v=True) easeOutFrames = pm.intField("EaseOutIntFeild", q=True, v=True) InTangentType = pm.optionMenu("EaseInTangetType_optmenu", q=True, v=True) OutTangentType = pm.optionMenu("EaseOutTangetType_optmenu", q=True, v=True) pm.cutKey(attr, t=":") initKey = pm.setKeyframe(attr, v=1, t=time, inTangentType=InTangentType, outTangentType=OutTangentType) if easeInFrames > 0: pm.setKeyframe( attr, v=0, t=[time - easeInFrames - holdInFrames], outTangentType=InTangentType) ##ease in @UndefinedVariable else: initKey if holdInFrames > 0: pm.setKeyframe( attr, v=1, t=(time - holdInFrames), inTangentType=InTangentType, outTangentType=InTangentType) ##inHold @UndefinedVariable else: initKey if holdOutFrames > 0: pm.setKeyframe( attr, v=1, t=(time + holdOutFrames), inTangentType=OutTangentType, outTangentType=OutTangentType) ##outHold @UndefinedVariable else: initKey if easeOutFrames > 0: pm.setKeyframe( attr, v=0, t=[time + easeOutFrames + holdOutFrames], inTangentType=OutTangentType) ##ease out @UndefinedVariable else: initKey
def initialize_tankard(self, x): self.logger.debug('--- initialize_tankard()') self.namespace_tankard = '' self.root_obj_tankard = 'manip_tankard' self.switch_obj_tankard = 'manip_tankard_matchPS' self.switch_attr_tankard = 'manip_tankard.Follow' pm.optionMenu('optionMenu_tankard', e = True, v = '-select-') # Get selection tmp_sel = pm.ls(sl = True) self.logger.debug('selection: ' + str(tmp_sel)) if not tmp_sel: pm.warning('Select root controller of Tankard!') return # Get the namespace chunk = tmp_sel[0] chunk_splitted = '' if ':' in chunk: chunk_splitted = chunk.split(':') if not chunk_splitted[-1] == self.root_obj_tankard: pm.warning('Select root controller of Tankard!') return iterator = 0 while iterator < len(chunk_splitted)-1: self.namespace_tankard = self.namespace_tankard + chunk_splitted[iterator] + ':' self.logger.debug('NAMESPACE: ' + self.namespace_tankard) iterator += 1 else: if not chunk == self.root_obj_tankard: pm.warning('Select root controller of Tankard!') return self.logger.debug('FINAL NAMESPACE: ' + self.namespace_tankard) self.switch_obj_tankard = self.namespace_tankard + self.switch_obj_tankard self.switch_attr_tankard = self.namespace_tankard + self.switch_attr_tankard self.set_constraints_tankard() #pm.button('binitialize_tankard', e = True, label = '-', enable = False) pm.optionMenu('optionMenu_tankard', e = True, enable = True) pm.button('b_switch_PS_tankard', e = True, label = 'SWITCH!', enable = True) pm.button('b_select_switch_obj_tankard', e = True, label = '"Select Switch Object"', enable = True)
def execute(self, *args): lOD = self.displayTypeList.index( pm.optionMenu(self.displayType, value=True, query=True)) dT = self.levelofDetailList.index( pm.optionMenu(self.levelOfDetail, value=True, query=True)) allSelected = pm.ls(g=True) dNH = pm.ls(g=True, regex='.*_DO_NOT_HIDE') allSelected = [s for s in allSelected if s not in dNH] for obj in allSelected: pm.setAttr('{}.overrideEnabled'.format(obj.name()), 1) pm.setAttr('{}.overrideDisplayType'.format(obj.name()), lOD) pm.setAttr('{}.overrideLevelOfDetail'.format(obj.name()), dT)
def update_external_axis_UI(axis_info): """ :param axis_info: :return: """ # Change frame name from "Add" to "Update" pm.frameLayout('add_external_axis_frame', edit=True, label="Update External Axis") # Update axis parameters pm.textField('t_externalAxisDescriptionText', edit=True, text=axis_info['Axis Name'], editable=False) pm.optionMenu('axisNumberMenu', edit=True, value=str(axis_info['Axis Number'])) pm.optionMenu('drivingAttributeMenu', edit=True, value=axis_info['Driving Attribute']) # If the driving attribute is a translate attribute, we convert the user # input from millimeters to Maya's default unit of centimeters position_limit_min = axis_info['Position Limit Min'] position_limit_max = axis_info['Position Limit Max'] if 'translate' in axis_info['Driving Attribute']: position_limit_min = position_limit_min * 10 position_limit_max = position_limit_max * 10 pm.textField('t_externalAxisLimitMin', edit=True, text=str(position_limit_min)) pm.textField('t_externalAxisLimitMax', edit=True, text=str(position_limit_max)) pm.textField('t_externalAxisVelocityLimit', edit=True, text=str(axis_info['Velocity Limit'])) pm.checkBox('cb_ignoreExternalAxis', edit=True, value=axis_info['Ignore']) # Change "Add Axis" button to "Update Axis" # Change background color of button pm.button('b_add_Axis', edit=True, label='Update Axis', backgroundColor=[.7, .7, .7], command=update_external_axis)
def refreshBlsMenu(self): all_bls = self.getAllBLS() selectedBlsNode = mc.optionMenu(self.bls_node, q=1, v=1) pm.optionMenu(self.bls_node, e=1, dai=1) if all_bls != []: for node in all_bls: pm.menuItem(parent=self.bls_node, label="{}".format(node.bs_node)) try: mc.optionMenu(self.bls_node, e=1, v=selectedBlsNode) except RuntimeError: pass else: pm.menuItem(parent=self.bls_node, label='None')
def armTypeVis(): armType=pm.radioButtonGrp("armType_Btn",q=True, sl=True) if armType == 1: ik_val = 1 fk_val = 0 ikfk_val = 0 if armType == 2: ik_val = 0 fk_val = 1 ikfk_val = 0 if armType == 3: ik_val = 1 fk_val = 1 ikfk_val = 1 pm.text('ikStyleText', e=True, vis=ik_val) pm.optionMenu('ikIcon_Menu',e=True, vis=ik_val) pm.text('fkStyle_Text', e=True, vis=fk_val) pm.optionMenu('fkIcon_Menu',e=True, vis=fk_val) pm.optionMenu('handIcon_menu',e=True, vis=ikfk_val) pm.text('handStyle_Text',e=True,vis=ikfk_val) pm.text('pvStyle_Text',e=True, vis=ikfk_val) pm.optionMenu('pvIcon_menu',e=True,vis=ikfk_val) pm.text('PV_text',e=True,vis=ik_val) pm.radioButtonGrp('addPVElbow_btn',e=True,vis=ik_val)
def fixOptionMenus(self): ''' Callback to fix an annoying bug where option menus do not respect their set width. ''' # The only thing I've found that will make the option menu's return to their proper width # is hiding and then unhiding them. However, this must be delayed until after the window they're in # is shown. Even an idle event scriptJob (set to run-once) is not 100% successful as sometimes it # is trigger too soon. This technique relies on an idle callback where we skip the first coule fires # before calling fixOptionMenus() callback and removing the idle callback. -CHAD #print self.idle_id, self.idle_ticker for menu in self.optionMenus: #print "fixing", menu pm.optionMenu(menu, edit=True, visible=False) pm.optionMenu(menu, edit=True, visible=True)
def _get_io_params(): """ Finds the user-defined IO parameters from the Mimic UI Checks that user inputs meet parameter riteria :return io_param_dict: dict containing IO params "IO Name" (str) "Postproc ID" (str) "IO Number" (int) "Type" (str) "Ignore" (bool) """ io_param_dict = {} io_param_dict['IO Name'] = pm.textField('t_ioNameText', query=True, text=True) io_param_dict['Postproc ID'] = pm.textField('t_ioPostprocIDText', query=True, text=True) io_param_dict['IO Number'] = int( pm.optionMenu('ioNumberMenu', query=True, value=True)) io_param_dict['Type'] = pm.optionMenu('ioTypeMenu', query=True, value=True) io_param_dict['Resolution'] = pm.optionMenu('ioResolutionMenu', query=True, value=True) io_param_dict['Ignore'] = pm.checkBox('cb_ignoreIO', query=True, value=True) # Resolution is currently only enabled for digital outputs # If the dropdown isn't enabled, default to None io_param_dict['Resolution'] = None res_enabled = pm.optionMenu('ioResolutionMenu', query=True, enable=True) if res_enabled: io_param_dict['Resolution'] = pm.optionMenu('ioResolutionMenu', query=True, value=True) _check_io_params(io_param_dict) # Ensure IO name input complies with Maya's attribute name requirements io_name = io_param_dict['IO Name'] io_param_dict['IO Name'] = _filter_io_name(io_name) return io_param_dict
def __init__(self): self.light_types = { 1: 'spotLight', 2: 'areaLight', 3: 'directionalLight', 4: 'pointLight', 5: 'ambientLight', 6: 'volumeLight' } self.layout = pm.columnLayout(adjustableColumn=False) pm.rowColumnLayout(numberOfColumns=2, columnWidth=([1, 200], [2, 150]), columnAlign=([1, 'center'], [2, 'center'])) # fill light option menu self.fill_type = pm.optionMenu(label='Fill Light', width=200) pm.menuItem(label='Spot') pm.menuItem(label='Area') pm.menuItem(label='Directional') pm.menuItem(label='Point') pm.menuItem(label='Ambient') pm.menuItem(label='Volume') self.fill_name = pm.textField(text='Fill_Light', width=100) #pm.setParent('..') # key light option menu self.key_type = pm.optionMenu(label='key Light', width=200) pm.menuItem(label='Spot') pm.menuItem(label='Area') pm.menuItem(label='Directional') pm.menuItem(label='Point') pm.menuItem(label='Ambient') pm.menuItem(label='Volume') self.key_name = pm.textField(text='Key_Light', width=100) # rim light option menu #pm.setParent('..') self.rim_type = pm.optionMenu(label='Rim Light', width=200) pm.menuItem(label='Spot') pm.menuItem(label='Area') pm.menuItem(label='Directional') pm.menuItem(label='Point') pm.menuItem(label='Ambient') pm.menuItem(label='Volume') self.rim_name = pm.textField(text='Rim_Light', width=100) pm.setParent(self.layout) pm.button(label='Create 3 Point System', command=pm.Callback(self.create_rig), width=550)
def MakeRandomizeOptionsMenu(randomizerController, annotation=None): """ Creates & returns a menu group giving the the randomiser options for a given randomizeController. :param randomizerController: RandomiseController instance. :param annotation: toolTip annotation, or None. """ if(type(randomizerController) != at.RandomizeController): raise TypeError("Attempt to make randomizer menu from non-RandomizeController attribute.") rowLayout = MakeRowLayout(2, rightColumnWidth=__OPTIONS_MENUS_WIDTH__, makeAdjustable=False) text = MakeText(randomizerController.attributeLabel, annotation) optionMenu = pm.optionMenu() try: for i in xrange(sys.maxint): pm.menuItem(label=at.RandomizeController.StringForOption(i)) except Exception: pass optionMenu.changeCommand(lambda *args: randomizerController._setValue(optionMenu.getValue())) randomizerController.updateUiCommand = optionMenu.setValue randomizerController.uiEnableMethod = rowLayout.setEnable if(annotation is not None): optionMenu.setAnnotation(annotation) elif(randomizerController.annotation is not None): optionMenu.setAnnotation(randomizerController.annotation) SetAsChildLayout(rowLayout) return rowLayout
def multi_BasicSettings(): # Basic Settings pm.text(l='', h=5) multi_nameField = pm.textFieldGrp('hp3dNameField', l='Name', text='', cw=[2, 150], cc=fun.partial(multi_nameChange, 'hp3dNameField'), fcc=True) pm.rowColumnLayout(nc=2) pm.text(l='Basic Settings', w=75, al='left', en=False) pm.separator(w=marginWidth-75, h=14) pm.setParent(multiLight_layout) multi_color = pm.colorSliderGrp('hp3dColorSlider', label='Color', rgb=(1, 1, 1), cw=[3, 20], dc=fun.partial(multi_colorChange, '.color', 'all', 'hp3dColorSlider')) multi_intensity = pm.floatSliderGrp('hp3dIntensitySlider', label='Intensity', field=True, v=1.000, fmx=1000000000, pre=3, cw=[3, 20], dc=fun.partial(multi_floatChange, '.intensity', 'all', 'hp3dIntensitySlider')) # pm.text(l='', h=3) # GUI SPACER pm.rowColumnLayout(nc=2) pm.text(l='', w=142) # GUI SPACER global multi_illDefault_box multi_illDefault_box = pm.checkBox(l='Illuminates by Default', v=1, cc=multi_illDefault) pm.setParent(multiLight_layout) pm.rowColumnLayout(nc=3) pm.text(l='', w=142) # GUI SPACER multi_emitDiff_box = pm.checkBox('hp3dEmitDiffCheckbox', l='Emit Diffuse', v=1, w=120, cc=fun.partial(multi_checkboxChange, '.emitDiffuse', 'all', 'hp3dEmitDiffCheckbox')) multi_emitSpec_box = pm.checkBox('hp3dEmitSpecCheckbox', l='Emit Specular', v=1, cc=fun.partial(multi_checkboxChange, '.emitSpecular', 'all', 'hp3dEmitSpecCheckbox')) pm.setParent(multiLight_layout) pm.rowColumnLayout(nc=3) pm.text(l='Decay Rate', w=140, al='right') pm.text(l='', w=3) multi_decayRate_menu = pm.optionMenu('hp3dDecayRateMenu', bgc=primary_componentColor, cc=fun.partial(multi_menuChange, '.decayRate', 'not directional', 'hp3dDecayRateMenu')) pm.menuItem(l='No Decay', da=0) pm.menuItem(l='Linear', da=1) pm.menuItem(l='Quadratic', da=2) pm.menuItem(l='Cubic', da=3) pm.setParent(multiLight_layout)
def multi_MentalRaySettings(): # Mental Ray Settings pm.rowColumnLayout(nc=2) pm.text(l='Mental Ray Settings', w=106, al='left', en=False) pm.separator(w=marginWidth-106, h=14) pm.setParent(multiLight_layout) pm.rowColumnLayout(nc=2) pm.text(l='', w=142) # GUI SPACER multi_MrAreaLight_box = pm.checkBox('hp3dUseShapeCheckbox', l='Use Light Shape', cc=fun.partial(multi_checkboxChange, '.areaLight', 'area & spot', 'hp3dUseShapeCheckbox')) pm.setParent(multiLight_layout) pm.rowColumnLayout(nc=3) pm.text(l='Type', w=140, al='right') pm.text(l='', w=3) multi_areaType_menu = pm.optionMenu('hp3dAreaTypeMenu', bgc=primary_componentColor, cc=fun.partial(multi_menuChange, '.areaType', 'area & spot', 'hp3dAreaTypeMenu')) pm.menuItem(l='Rectangle', da=0) pm.menuItem(l='Disc', da=1) pm.menuItem(l='Sphere', da=2) pm.menuItem(l='Cylinder', da=3) pm.menuItem(l='Custom', da=4) pm.setParent(multiLight_layout) multi_highSamples = pm.intFieldGrp('hp3dHighSamplesField', numberOfFields=1, label='High Samples', v1=8, cc=fun.partial(multi_samplesChange, 'highSamp')) multi_highSampLimit = pm.intFieldGrp('hp3dHighSampleLimitField', numberOfFields=1, label='High Sample Limit', v1=1, cc=fun.partial(multi_samplesChange, 'highSampLimit')) multi_lowSamples = pm.intFieldGrp('hp3dLowSamplesField', numberOfFields=1, label='Low Samples', v1=1, cc=fun.partial(multi_samplesChange, 'lowSamp')) pm.setParent(multiLight_layout)
def multi_menuChange(attr, lightType, component, *args): value = pm.optionMenu(component, q=True, select=True) sel_lights = pm.ls(sl=True, lights=True, dag=True) new_list = sortBy_type(sel_lights, lightType) for each in new_list: pm.setAttr(each+attr, value-1)
def refresh(self, deformer): """ If a blendShape is selected, populate the list of targets. """ for item in pm.optionMenu(self.control_name + '|OptionMenu', q=True, itemListLong=True): pm.deleteUI(item) self.all_item = None # The blend shape array is sparse, so keep a mapping from list indices to blend # shape weight indices. Note that for some reason, these are 1-based. self.blend_shape_map.clear() if not isinstance(deformer, pm.nodetypes.BlendShape): return def add_target(name, shape_id): item = pm.menuItem(label=name, parent=self.control_name + '|OptionMenu') idx = pm.optionMenuGrp(self.control_name, q=True, numberOfItems=True) self.blend_shape_map[idx] = shape_id return item if self.all_text is not None: self.all_item = add_target(self.all_text, '(all)') add_target('Main deformer weights', '(main)') # Add the blend shape targets in the source blend shape to the list. for idx, weight in enumerate(deformer.attr('weight')): add_target('Target: ' + pm.aliasAttr(weight, q=True), weight)
def createLayout(self, *args): #creates the layout and attaches the controls to the given field the class has been called in self.disabler = pm.optionMenu( l='Auto-detect Proxy', cc=self._disableButton ) for option in self.o: pm.menuItem( label=option ) self.button = pm.textFieldButtonGrp( adj=1, ad2=1, ad3=1 , cw=[2, self.w/2], w=self.w, label = self.n, text='', buttonLabel=self.b, buttonCommand = self._buttonAction ) self.textField = pm.textFieldButtonGrp(self.button, e=True, cw=[1, self.w/4])
def _disableButton(self, arg): if pm.optionMenu( self.disabler, q=True, select=True) - 1: #pm.textFieldButtonGrp( self.textField, e=True, en=False) pass else: #pm.textFieldButtonGrp( self.textField, e=True, en=True) pass
def exporter(arg,prefix): pm.select(r=arg) temp=[] stripFN='' temp=arg.split(":") #Removing namespaces if len(temp)>1: stripFN=temp[-1:] else: stripFN=arg expType=pm.optionMenu("exportType",q=1,v=1) extension='' #Determining Export type #OBJ if expType == "OBJ": extension=".obj" prefix=prefix + "OBJ/" pm.file(pr=1,typ="OBJexport",es=(prefix + stripFN),op="groups=0;ptgroups=0;materials=0;smoothing=1;normals=1") if expType == "FBX": extension=".fbx" #FBX prefix=prefix + "FBX/" pm.file(typ="FBX export",force=1,options="binary=1;compression=0;tabstop=8;perframe=0;padframe=0;perlayer=0;pathnames=3313333333;assembly=1;fragment=1;fragsurfmats=1;fragsurfmatsassign=1;fragincshdrs=1;fragchilddag=1;passcontrimaps=1;passusrdata=0;filter=00000011010000001101000;overrideAssemblyRootName=0;assemblyRootName=",es=(prefix + stripFN + extension)) if expType == "PROXY": extension=".mi" #PROXY prefix=prefix + "renderProxy/" pm.Mayatomr(binary=1,assembly=1,fis=1,mi=1,fem=1,exportFilter=721600,fcd=1,fe=1,file=(prefix + stripFN + extension),pcm=1,active=1,xp="3313333333",asn=stripFN,fma=1) print " Creating file: " + (prefix + stripFN) + extension + "\n"
def loadDriven(self, *args): """ Load object name for driven object in text field """ sel = pm.ls(sl=True, fl=True) pm.textFieldButtonGrp(self.drivenField, edit=True, text=sel[0]) # Clear the menu items so list doesn't grow items = pm.optionMenu(self.drivenAttField, q=True, ill=True) if(items): pm.setParent(self.drivenAttField, menu=True) for each in items: pm.deleteUI(each) # Check if blendshape if 'BlendShape' in str(type(sel[0])): bs = sel[0] temp = pm.aliasAttr(bs, q=1) temp.sort() targets = [] for each in temp: if each.startswith('weight'): continue targets.append(each) for tgt in targets: try: pm.menuItem(parent=self.drivenAttField, label=tgt) except Exception, e: print e pm.warning('%s failed to create / connect' % tgt)
def MakeStringOptionsField(stringAttribute, optionsListStrings, annotation=None): """ Creates & returns a menu with a given list of options for corresponding stringAttribute. :param stringAttribute: StringAttribute instance. :param optionsListStrings: List of possible values for string attribute, will be presented as menu options. :param annotation: toolTip annotation, or None. """ if(not isinstance(stringAttribute, at.StringAttribute)): raise TypeError("Attempted to make string options (expected:%s, got:%s)" % (at.StringAttribute, type(stringAttribute))) elif(stringAttribute.value not in optionsListStrings): raise ValueError("Initial value %s is not in options list." % stringAttribute.value) rowLayout = MakeRowLayout(2, rightColumnWidth=__OPTIONS_MENUS_WIDTH__ + 45, makeAdjustable=False) MakeText(stringAttribute.attributeLabel, annotation) optionMenu = pm.optionMenu() menuItemsList = [] for option in optionsListStrings: menuItemsList.append(pm.menuItem(label=option)) optionMenu.setValue(stringAttribute.value) optionMenu.changeCommand(lambda *args: stringAttribute._setValue(optionMenu.getValue())) stringAttribute.updateUiCommand = optionMenu.setValue stringAttribute.uiEnableMethod = optionMenu.setEnable if(annotation is not None): optionMenu.setAnnotation(annotation) elif(stringAttribute.annotation is not None): optionMenu.setAnnotation(stringAttribute.annotation) SetAsChildLayout(rowLayout) return (optionMenu, menuItemsList)
def __init__(self, lightTransform, lightType, lightShape): super(PointLight, self).__init__(lightTransform, lightType, lightShape) pm.setParent(self.indivLight_layout) pm.rowColumnLayout(nc=3) pm.text(l='Decay Rate', w=140, al='right') pm.text(l='', w=3) decayRate_menu = pm.optionMenu(bgc=primary_componentColor) pm.menuItem(l='No Decay', da=0) pm.menuItem(l='Linear', da=1) pm.menuItem(l='Quadratic', da=2) pm.menuItem(l='Cubic', da=3) pm.connectControl(decayRate_menu, lightShape+'.decayRate') pm.setParent(self.indivLight_layout) pm.rowColumnLayout(nc=2) pm.text(l='Shadow Settings', w=90, al='left', en=False) pm.separator(w=marginWidth-90, h=14) pm.setParent(self.indivLight_layout) pm.attrFieldSliderGrp(at=lightShape+'.lightRadius', cw=[[2, 75], [3, 120]], hmb=False) self.shadowRays_slide = pm.attrFieldSliderGrp(at=lightShape+'.shadowRays', cw=[[2, 75], [3, 120]], hmb=False) pm.attrFieldSliderGrp(at=lightShape+'.rayDepthLimit', cw=[[2, 75], [3, 120]], hmb=False) pm.setParent(lights_layout)
def refresh(self): # Clear the existing target list. for item in pm.optionMenu(self.control_name + '|OptionMenu', q=True, itemListLong=True): pm.deleteUI(item) # Get the names of the outputs of the selected deformer. value = pm.optionMenuGrp(self.deformer_control.control_name, q=True, v=True) if not value: return nodes = pm.ls(value) if not nodes: return node = nodes[0] # Make a list of output shapes for this deformer. self.shapes = [] for deformed_idx in range(node.numOutputConnections()): try: output_shape = node.outputShapeAtIndex(deformed_idx) except RuntimeError: # This fails with RuntimeError if we query an index that isn't connected, which can happen if you # create a deformer for three shapes and then delete the second one. continue self.shapes.append((output_shape, deformed_idx)) pm.menuItem(label=output_shape.getParent().name(), parent=self.control_name + '|OptionMenu')
def applyCallback( pNoiseOption, pMaxValueField, pMinValueField, *pArgs ): NoiseOptionState = pm.optionMenu( pNoiseOption, query=True, value=True ) MaxValue = pm.floatField( pMaxValueField, query=True, value=True ) MinValue = pm.floatField( pMinValueField, query=True, value=True ) GenerateVertexColor( NoiseOptionState, MaxValue, MinValue )
def fill_blend_target(self, unused=True): # Clear the existing target list. for item in pm.optionMenu('sbsTargetList|OptionMenu', q=True, itemListLong=True): pm.deleteUI(item) # Prevent a warning from being printed if there aren't any blendShapes. if pm.optionMenuGrp('sbsList', q=True, ni=True) == 0: return # Get the names of the targets in the selected blend shape. value = pm.optionMenuGrp('sbsList', q=True, v=True) if not value: return nodes = pm.ls(value) if not nodes: return node = nodes[0] pm.menuItem(label='All', parent='sbsTargetList|OptionMenu') for item in node.attr('w'): target_name = pm.aliasAttr(item, q=True) pm.menuItem(label=target_name, parent='sbsTargetList|OptionMenu')
def initPanel(cls): """doc""" global pal_opMenu global brn_opMenu if pm.optionMenu(pal_opMenu, q=1, ex=1): for item in pm.optionMenu(pal_opMenu, q=1, ill=1): pm.deleteUI(item) if pm.optionMenu(brn_opMenu, q=1, ex=1): for item in pm.optionMenu(brn_opMenu, q=1, ill=1): pm.deleteUI(item) pm.image(cls.img_snap, e=1, i=cls.snapNull) cls.snapshot_clear() cls.makePanel(cls.qsb_mode.isChecked())
def create(self): # destroy the window if it already exists try: pm.deleteUI(self.WINDOW_NAME, window=True) except: pass # draw the window with pm.window(self.WINDOW_NAME) as res_window: with pm.columnLayout(adjustableColumn=True): with pm.horizontalLayout(): pm.text(label='Resolution') with pm.optionMenu() as self.res_menu: pm.menuItem(l='Low') pm.menuItem(l='Med') pm.menuItem(l='Hi') set_res_btn = pm.button(label='Set LOD', command=pm.Callback(self.on_set_res_btn)) pm.separator(style='in', height=4) with pm.horizontalLayout() as h1: pm.text(label='Low') select_low_btn = pm.button(label='Select All', command=pm.Callback(self.on_select_btn,'Low')) toggle_low_btn = pm.button(label='Toggle Visibility', command=pm.Callback(self.on_vis_btn, 'Low')) with pm.horizontalLayout() as h1: pm.text(label='Medium') select_med_btn = pm.button(label='Select All', command=pm.Callback(self.on_select_btn, 'Med')) toggle_med_btn = pm.button(label='Toggle Visibility', command=pm.Callback(self.on_vis_btn, 'Med')) with pm.horizontalLayout() as h1: pm.text(label='High') select_hi_btn = pm.button(label='Select All', command=pm.Callback(self.on_select_btn, 'Hi')) toggle_hi_btn = pm.button(label='Toggle Visibility', command=pm.Callback(self.on_vis_btn, 'Hi')) self.status_line = pm.textField(editable=False) res_window.setWidthHeight((350,140))
def __init__(self, baseUi, parent): BaseUi.__init__(self, parent) self.uiparent = parent self.baseUi = baseUi self.tmpJnts = [] self.defaultAxis = 'y' #ui try: pm.deleteUI(self.rigCol) except: pass with pm.columnLayout(adj=True, rs=3, parent=self.uiparent) as self.rigCol: with pm.rowColumnLayout(nc=2, co=[(1, 'left', 155), (2, 'left', 5)]): pm.text(l='axis') with pm.optionMenu(w=60) as self.axisMenu: pm.menuItem(l='x') pm.menuItem(l='y') pm.menuItem(l='z') with pm.columnLayout(adj=True, rs=2, co=['left', 165]): self.ribbonChkBox = pm.checkBox(l='Ribbon Lo/Hi', v=False) with pm.rowColumnLayout(nc=3, co=[(1, 'left', 30), (2, 'left', 5), (3, 'left', 5)]): pm.text(l='tmpJnts') self.tmpJntsTxtFld = pm.textField(w=230, ed=False) self.loadTmpJntButt = pm.button(l='<<', c=pm.Callback(self.loadTmpJnts)) self.axisMenu.setValue(self.defaultAxis) self.baseUi.clearElemSideTxtFld()
def __init__(self, baseUi, parent): BaseUi.__init__(self, parent) self.uiparent = parent self.baseUi = baseUi self.tmpJnts = [] self.attrCtrl = None #ui try: pm.deleteUI(self.rigCol) except: pass with pm.columnLayout(adj=True, rs=3, parent=self.uiparent) as self.rigCol: with pm.rowColumnLayout(nc=2, co=[(1, 'left', 130), (2, 'left', 5)]): pm.text(l='Finger Name') with pm.optionMenu(w=60) as self.fingerNameMenu: pm.menuItem(l='index') pm.menuItem(l='middle') pm.menuItem(l='ring') pm.menuItem(l='pinky') pm.menuItem(l='thumb') with pm.rowColumnLayout(nc=3, co=[(1, 'left', 30), (2, 'left', 5), (3, 'left', 5)]): pm.text(l='attrCtrl') self.attrCtrlTxtFld = pm.textField(w=230, ed=False) self.loadAttrCtrlButt = pm.button(l='<<', c=pm.Callback(self.loadAttrCtrl)) pm.text(l='tmpJnts') self.tmpJntsTxtFld = pm.textField(w=230, ed=False) self.loadTmpJntButt = pm.button(l='<<', c=pm.Callback(self.loadTmpJnts)) self.baseUi.clearElemSideTxtFld()
def _addLocMultiOptions(): pm.setParent(q=True) pm.columnLayout(adjustableColumn=True, cal="right") pm.text(l='', al="center") fl = pm.formLayout() jNumber = pm.intFieldGrp(v1=3, l="Joint Number") pm.setParent('..') pm.formLayout(fl, e=True, af=(jNumber, "left", -30)) dirSet = ["X", "-X", "Y", "-Y", "Z", "-Z"] fl = pm.formLayout() dirAxis = pm.optionMenu(l="Direction") dirAxis.addMenuItems(dirSet) pm.setParent('..') pm.formLayout(fl, e=True, af=(dirAxis, "left", 70)) fl = pm.formLayout() jSpac = pm.floatFieldGrp(v1=1.0, l="spacing") pm.setParent('..') pm.formLayout(fl, e=True, af=(jSpac, "left", -30)) pm.text(l='', al="center") pm.button(l='Continue', c=partial(_retriveOptions, jNumber, dirAxis, jSpac)) pm.setParent('..')
def createUI( SWindowTitle, pApplyCallback ): windowID = 'vcgnWindowID' # If Window is Already Open, Delete it and Open a New One if pm.window( windowID, exists=True ): pm.deleteUI( windowID ) # Init Window pm.window( windowID, title=SWindowTitle, sizeable=False, resizeToFitChildren=True ) pm.rowColumnLayout( numberOfColumns=3, columnWidth=[ (1, 75), (2, 75), (3,75) ], columnOffset=[ (1,'right', 3) ]) pm.text( label='Min Value:' ) # Minimum Value Field, Default = 0.0, min = 0.0, max = 1.0, invisible slider step = 0.01 MinValueField = pm.floatField( value=0.0, minValue=0.0, maxValue=1.0, step=0.01, annotation="This is the Minimum Value, It Can't Go below 0.0 or above 1.0" ) pm.separator( h=10, style='none' ) pm.text( label='Max Value:' ) # Maximum Value Field, Default = 1.0, min = 0.0, max = 1.0, invisible slider step = 0.01 MaxValueField = pm.floatField( value=1.0, minValue=0.0, maxValue=1.0, step=0.01, annotation="This is the Maximum Value, It Can't Go below 0.0 or above 1.0" ) pm.separator( h=10, style='none' ) # Formatting pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.text( label='Noise Type:' ) # Noise Options - Enabled in 2.0 NoiseOption = pm.optionMenu( 'NoiseFunctions', enable=True, annotation="Select Alternate Distributions and Generation Functions Here" ) pm.menuItem( label='Simple', parent='NoiseFunctions', annotation="A Simple Psuedo Random Noise Function that generates Random Values Between Min and Max" ) pm.menuItem( label='Perlin', parent='NoiseFunctions', annotation="Try Moving the Object Around for More Variety with Perlin Noise" ) pm.menuItem( label='3D Weighted', parent='NoiseFunctions', annotation="This Function Uses a Mixed Up Vertex List Randomly Adjust the Appearance of a Psuedo Random Number Generation" ) pm.menuItem( label='Triangular', parent='NoiseFunctions', annotation="This Function Uses a Psuedo Random Number Generator with a Triangular Distribution" ) pm.menuItem( label='Gamma', parent='NoiseFunctions', annotation="This Function Uses the Gamma Distribution, Does Not Work Well with Low Min Values, Suggestion Minimum 0.1" ) pm.separator( h=10, style='none' ) # Formatting pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) # Buttons pm.separator( h=10, style='none' ) pm.button( label='Apply', command=functools.partial(pApplyCallback, NoiseOption, MaxValueField, MinValueField) ) def cancelCallback( *Args ): if pm.window( windowID, exists=True ): pm.deleteUI( windowID ) pm.button( label='Cancel', command=cancelCallback ) pm.showWindow()
def init(self): #Initializing Variables self.localProject = os.environ[ 'MAYA_PROJECT' ] self.localUser=os.environ[ 'USER' ] self.path = (localProject + "/export/GEO") self.title='aw_msvExp' self.wh = [352,542] # Make me a button! if pm.window(self.title, query=True, exists=True): pm.deleteUI(self.title) if pm.windowPref(self.title, query=True, exists=True): pm.windowPref(self.title, remove=True) # Window creation self.window = pm.window(self.title,widthHeight=self.wh,title=self.title) self.majorLayout = pm.gridLayout('aw_expLayout',numberOfColumns=1,cellWidthHeight=(self.wh[0], (self.wh[1]/18))) pm.text(bgc=(.3, .35, .4),ebg=1,al="center",fn="boldLabelFont",l=" Obj Exporter") #menu for export type pm.optionMenu('exportType',label=" FileType") pm.menuItem(label="FBX") pm.menuItem(label="OBJ") pm.menuItem(label="PROXY") #menu for model type pm.optionMenu('modelType',changeCommand=lambda *args: mel.aw_addRemCombName(),label=" ModelType") pm.menuItem(label="Combined") pm.menuItem(label="Separate") #EXPORTER pm.textField('combName',tx="Object Export Name") pm.text(al="left",l="Set directory for objects to be outputted") pm.textField('pathName',tx=path_here) pm.button('fileBrowse2',command=lambda *args: mel.fileBrowser(pathname),label="Browse") pm.button('msvExp',bgc=(0.1, .7, .145),command=lambda *args: mel.objExp(),label="Export") pm.text(l="") #IMPORTER pm.text(bgc=(.3, .3, .4),ebg=1,al="center",fn="boldLabelFont",l=" Obj importer") pm.text(al="left",l="Set directory for objects to be inputted") pm.textField('pathImpName',tx=path_here) pm.button('fileBrowse1',command=lambda *args: mel.fileBrowser(pathimpname),label="Browse") pm.button('msvList',command=lambda *args: mel.fileList(),label="List OBJ Files") pm.text(al="left",l="Type wildcard here or leave blank for all objs in the folder") pm.textField('wildName') pm.button('msvImp',bgc=(0.1, .7, .145),command=lambda *args: mel.objImp(),label="Import") pm.button('msvKillBtn',command=lambda *args: deleteUI('aw_msvExp'),label="Close Window") self.window.show()
def __init__(self): self.option_menu = pm.optionMenu( label='Light Type', width= 200) pm.menuItem( label='Spot') pm.menuItem( label='Area') pm.menuItem( label='Directional') pm.menuItem( label='Point') pm.menuItem( label='Ambient') pm.menuItem( label='Volume')
def defaultTranslatorChanged(self, defaultNode, menu, outputType): ''' rebuilds the menu, updating the value for the default driver/filter and restoring the selected item to the proper value ''' # clear menu value = pm.optionMenu(menu, query=True, value=True) for item in pm.optionMenu(menu, query=True, itemListLong=True) or []: pm.deleteUI(item) default = '<%s>' % pm.getAttr(defaultNode + '.aiTranslator') pm.cmds.menuItem(parent=menu, label=default) for tran in templates.getTranslators(outputType): pm.cmds.menuItem(parent=menu, label=tran) callbacks.DelayedIdleCallbackQueue(self.fixOptionMenus) if value.startswith('<'): value = default pm.cmds.optionMenu(menu, e=True, value=value)
def doDelAOV(*args): curr_aov = pm.optionMenu( 'enumAOVList', q=True, value=True ) if curr_aov == None: return 0 aovs.AOVInterface().removeAOVs(curr_aov) doUpdateScnAOV(1) return 1;
def copyAnim(self, args): ''' Copy all animation on transform nodes from one namespace to another ''' srcNS = pm.optionMenu(self.srcFld, q=1, v=1) tgtNS = pm.optionMenu(self.tgtFld, q=1, v=1) sourceControls = pm.ls('%s:*' % srcNS, type='transform') sourceControls.sort() for src in sourceControls: try: pm.copyKey(src) pm.pasteKey('%s:%s' % (tgtNS, src.split(':')[-1])) except Exception, e: print src print '%s:%s' % (tgtNS, src.split(':')[-1])
def createUI( SWindowTitle, pApplyCallback ): windowID = 'vcgnWindowID' # If Window is Already Open, Delete it and Open a New One if pm.window( windowID, exists=True ): pm.deleteUI( windowID ) # Init Window pm.window( windowID, title=SWindowTitle, sizeable=False, resizeToFitChildren=True ) pm.rowColumnLayout( numberOfColumns=3, columnWidth=[ (1, 75), (2, 75), (3,75) ], columnOffset=[ (1,'right', 3) ]) pm.text( label='Min Value:' ) # Minimum Value Field, Default = 0.0, min = 0.0, max = 1.0, invisible slider step = 0.01 MinValueField = pm.floatField( value=0.0, minValue=0.0, maxValue=1.0, step=0.01 ) pm.separator( h=10, style='none' ) pm.text( label='Max Value:' ) # Maximum Value Field, Default = 1.0, min = 0.0, max = 1.0, invisible slider step = 0.01 MaxValueField = pm.floatField( value=1.0, minValue=0.0, maxValue=1.0, step=0.01 ) pm.separator( h=10, style='none' ) # Formatting pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.text( label='Noise Type:' ) # Noise Options - Disabled For Version 1.0 Will Be Enabled in 2.0 NoiseOption = pm.optionMenu( 'NoiseFunctions', enable=False ) pm.menuItem( label='Simple', parent='NoiseFunctions' ) pm.menuItem( label='Perlin', parent='NoiseFunctions' ) pm.menuItem( label='OpenSimplex', parent='NoiseFunctions' ) pm.separator( h=10, style='none' ) # Formatting pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) pm.separator( h=10, style='none' ) # Buttons pm.separator( h=10, style='none' ) pm.button( label='Apply', command=functools.partial(pApplyCallback, NoiseOption, MaxValueField, MinValueField) ) def cancelCallback( *Args ): if pm.window( windowID, exists=True ): pm.deleteUI( windowID ) pm.button( label='Cancel', command=cancelCallback ) pm.showWindow()
def _selectNamespace(self): ite = self.uiMain['namespaceOpM'].getSelect() item = pmc.optionMenu(self.uiMain['namespaceOpM'], query=True, itemListLong=True)[ite-1] nameSpace = pmc.menuItem(item, query=True, label=True) if nameSpace==self.rootNamespace: nameSpace = ':' self.listFile.nameSpace = nameSpace
def doDelAOV(*args): curr_aov = pm.optionMenu( 'enumAOVList', q=True, value=True ) if curr_aov == None: return 0 aovs.AOVInterface().removeAOVs(curr_aov) #// type = 1, no need to update indof insude AOV node doUpdateScnAOV(1) return 1;
def __init__(self): self.main_layout = pm.columnLayout(adjustableColumn= True) self.layout01 = pm.rowColumnLayout(numberOfColumns= 3, columnWidth=([1, 150],[2, 150], [3, 250])) pm.columnLayout() pm.text(label= 'Shaders') self.shader_scroll_list01 = pm.textScrollList(width= 150, height= 200, selectCommand= pm.Callback(self.get_output_geo)) pm.button(label= 'Refresh', width= 150, command= pm.Callback(self.update_shaders_list)) pm.setParent(self.layout01) pm.columnLayout() pm.text(label= 'Shader Geo') self.shader_geo_scroll_list = pm.textScrollList(width= 150, height= 200, allowMultiSelection= True) #self.check_box = pm.checkBox(label= 'select node') pm.setParent(self.layout01) pm.columnLayout() pm.text(label= 'Scene Geo') self.scene_geo_scroll_list = pm.textScrollList(width= 250, height= 200, allowMultiSelection= True) pm.button(label= 'Refresh', width= 275, command= pm.Callback(self.update_scene_geo_list)) pm.setParent(self.main_layout) self.layout02 = pm.rowColumnLayout(numberOfColumns= 2, columnWidth=([1, 275],[2, 275])) pm.columnLayout(adjustableColumn= True) pm.text(label= 'Shaders') self.shader_scroll_list02 = pm.textScrollList(width= 275, height= 200) pm.button(label= 'Assign', width= 275, command= pm.Callback(self.assign_to_geometry)) pm.setParent(self.layout02) pm.columnLayout(adjustableColumn= True) pm.text(label= 'Create Shaders') self.option_menu = pm.optionMenu( label='Material Type', width= 200) pm.menuItem( label='mia_material_x') pm.menuItem( label='blinn') pm.menuItem( label='lambert') pm.menuItem( label='phong') pm.menuItem( label='rampShader') pm.menuItem( label='anisotropic') pm.menuItem( label='phongE') pm.menuItem( label='useBackground') self.text_field = pm.textFieldGrp(label= 'Name', columnWidth2= [100, 150]) pm.button(label= 'Create and Assign Shader', command= pm.Callback(self.create_and_assign_shader)) self.update_scene_geo_list() self.update_shaders_list()
def updateSunLightOptionMenu(self, selection=None): uiDict = self.rendererTabUiDict['environment'] opMenu = uiDict['sunLightOptionMenu'] + "|OptionMenu" if selection: if selection == "Create New Sun Light...": lightShape = pm.createNode("directionalLight") sunConnection = lightShape.getParent() sunConnection.rename("asSunLight") sunConnection.message >> self.renderGlobalsNode.physicalSunConnection else: connections = self.renderGlobalsNode.physicalSunConnection.inputs() if len(connections) > 0: connectedSunShape = connections[0].getShape() if selection == "None": connections[0].message // self.renderGlobalsNode.physicalSunConnection else: if connectedSunShape != selection: pm.PyNode(selection).getParent().message >> self.renderGlobalsNode.physicalSunConnection else: pm.PyNode(selection).getParent().message >> self.renderGlobalsNode.physicalSunConnection menuItems = pm.optionMenu(opMenu, q=True, itemListLong=True) if menuItems: pm.deleteUI(menuItems) directionalLightList = pm.ls(type="directionalLight") if len(directionalLightList) == 0: directionalLightList.append("Create New Sun Light...") else: directionalLightList.append("None") for value in directionalLightList: pm.menuItem(str(value), parent=opMenu) connections = self.renderGlobalsNode.physicalSunConnection.inputs() selectIndex = len(directionalLightList) - 1 if len(connections) > 0: sunShape = connections[0].getShape() for index, l in enumerate(directionalLightList): if l == sunShape: selectIndex = index pm.optionMenu(opMenu, e=True, select=selectIndex + 1)