def makeMenuItem(self, label=None, name=None, command=None, parentMenu=None, subMenu=False, optionBox = False): ## Add to the count of items that are in this menu, so that each item ## can can it's own unique number. self.menuCount += 1 ## The parentMenu normally exists to support submenus ## Normally the new menu item should be added to specified parent ## however, if none was given we try to add it to the ## self.activeParentMenu, otherwise we fall back on the self.menu if parentMenu is None: if self.activeParentMenu == None: parentMenu = self.menu else: parentMenu = self.activeParentMenu ## If no label has been given, generate an automatic label. ## This will be obvious when see in the user interface if label is None: label = "MenuAutoLabel"+str(self.menuCount) ## Set maya's default parent! pm.setParent( parentMenu , menu=True) ## Maka a code-friendly name that can be used for calling functions fixedLabel = label.replace( " ", "").replace(".", "").replace("(", "" ).replace(")","").replace("'", "" ) if name=="": name = fixedLabel if command is None or command=="": command = "menu" + fixedLabel if subMenu==True: newMenuItem = pm.menuItem( label=label, sm=True, tearOff=True, allowOptionBoxes=True ) elif optionBox==True: newMenuItem = pm.menuItem( command = getattr(self,command+"Options"), optionBox=True ) else: try: ## This is just hard coded for now, should be made a list in conf or something labelFixedForMenu = label for word in ["Modeler ", "Texturer ", "Selector ", "Rigger " ]: if labelFixedForMenu.startswith( word ): labelFixedForMenu = labelFixedForMenu.replace( word, "", 1 ) ## 1 occurance max replacement newMenuItem = pm.menuItem( label=labelFixedForMenu, command = getattr(self,command) ) #self[command] ) except: newMenuItem = pm.menuItem( label=label+" Not Implemented" ) u.log( "Attempted to add a MmmmTools menu item for a " "UI command that hasn't been written yet. " "The menu item will do nothing." ) return newMenuItem
def makeMenuItemFromString(self, stringForItem): st = stringForItem if st == 'div' or st == 'divider': pm.menuItem(divider=True) elif st == 'Menu Main': self.activeParentMenu = self.menu pm.setParent(self.menu, menu=True) #u.log('Going back to parent menu') elif st.startswith('Menu '): stsub = st.replace('Menu ', '') #u.log( 'stsub is: ' + stsub ) self.makeSubMenu(stsub) #u.log('Entering Sub menu') elif st.startswith('optionBox '): stsub = st.replace('optionBox ', '') #u.log( 'stsub is: ' + stsub ) self.makeMenuItem(label=stsub, optionBox=True) else: self.makeMenuItem(label=st)
def makeMenuItemFromString(self, stringForItem ): st = stringForItem if st == 'div' or st == 'divider': pm.menuItem( divider=True ) elif st == 'Menu Main': self.activeParentMenu = self.menu pm.setParent( self.menu, menu=True ) #u.log('Going back to parent menu') elif st.startswith( 'Menu '): stsub = st.replace('Menu ','') #u.log( 'stsub is: ' + stsub ) self.makeSubMenu( stsub ) #u.log('Entering Sub menu') elif st.startswith('optionBox '): stsub = st.replace('optionBox ', '') #u.log( 'stsub is: ' + stsub ) self.makeMenuItem( label=stsub, optionBox=True ) else: self.makeMenuItem( label=st )
def dock(mainWindow): """ Show dockable window args mainWindow : QtGui.QMainWindow return None """ mainWindow.setObjectName('sampleWindowObject') DOCK_NAME = "dock_name" from pymel import all as pm if pm.dockControl(DOCK_NAME, q=True, ex=1): pm.deleteUI(DOCK_NAME) if pm.window('dummyWindow', q=True, ex=1): pm.deleteUI('dummyWindow') # Create dummy window object to keep the layout pm.window('dummyWindow') pm.columnLayout() floatingLayout = pm.paneLayout( configuration='single', w=300) pm.setParent('..') # Create new dock pm.dockControl( DOCK_NAME, aa=['right', 'left'], a='right', fl=False, con=floatingLayout, label="Sample Dock", w=300) # Parent QMainWindow object to the layout pm.control('sampleWindowObject', e=True, parent=floatingLayout)
def dock(mainWindow): """ Show dockable window args mainWindow : QtWidgets.QMainWindow return None """ mainWindow.setObjectName('sampleWindowObject') DOCK_NAME = "dock_name" from pymel import all as pm if pm.dockControl(DOCK_NAME, q=True, ex=1): pm.deleteUI(DOCK_NAME) if pm.window('dummyWindow', q=True, ex=1): pm.deleteUI('dummyWindow') # Create dummy window object to keep the layout pm.window('dummyWindow') pm.columnLayout() floatingLayout = pm.paneLayout(configuration='single', w=300) pm.setParent('..') # Create new dock pm.dockControl(DOCK_NAME, aa=['right', 'left'], a='right', fl=False, con=floatingLayout, label="Sample Dock", w=300) # Parent QMainWindow object to the layout pm.control('sampleWindowObject', e=True, parent=floatingLayout)
window = pma.window(windowName, title=windowName, width=120, height=200) pma.columnLayout("mainColumn", adjustableColumn=True) ################################################################################################UI################################################# pma.gridLayout("nameGridLayout01", numberOfRowsColumns=(1, 4), cellWidthHeight=(40, 40), parent="mainColumn") pma.symbolButton("nameButton1", image="polyCube.png", width=40, height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout01", command="creator(PRIMITIVE_CUBE)") pma.symbolButton("nameButton2", image="polyCylinder.png", width=40, height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout01", command="creator(PRIMITIVE_CYLINDER)") pma.symbolButton("nameButton3", image="polySphere.png", width=40, height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout01", command="creator(PRIMITIVE_SPHERE)") pma.columnLayout("columnLayoutName01", adjustableColumn=True, backgroundColor=[0.2, 0.2, 0.2]) pma.radioCollection("collection10", parent="columnLayoutName01") subRadioB = pma.radioButton("subRadio", select=True, label="Sub") addRadioB = pma.radioButton("addRadio", label="Add") pma.setParent('..') pma.setParent('..') ################################################################################################UI################################################# pma.separator(parent="mainColumn", height=20) pma.button("customMeshB", label="Use Custom Mesh", width=120, height=40, backgroundColor=[0.2, 0.2, 0.2], parent="mainColumn", command="creator(PRIMITIVE_CUSTOM)") pma.separator(parent="mainColumn", height=20) ################################################################################################UI################################################# pma.gridLayout("nameGridLayout03", numberOfRowsColumns=(1, 3), cellWidthHeight=(53, 40), parent="mainColumn") pma.button("hidSelB", label="Hide Sel", height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout03", command="hider(0)") pma.button("hidAllB", label="Hide All", height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout03", command="hider(1)") pma.button("showAll", label="Show All", height=40, backgroundColor=[0.2, 0.2, 0.2], parent="nameGridLayout03",
def makeMenuItem(self, label=None, name=None, command=None, parentMenu=None, subMenu=False, optionBox=False): ## Add to the count of items that are in this menu, so that each item ## can can it's own unique number. self.menuCount += 1 ## The parentMenu normally exists to support submenus ## Normally the new menu item should be added to specified parent ## however, if none was given we try to add it to the ## self.activeParentMenu, otherwise we fall back on the self.menu if parentMenu is None: if self.activeParentMenu == None: parentMenu = self.menu else: parentMenu = self.activeParentMenu ## If no label has been given, generate an automatic label. ## This will be obvious when see in the user interface if label is None: label = "MenuAutoLabel" + str(self.menuCount) ## Set maya's default parent! pm.setParent(parentMenu, menu=True) ## Maka a code-friendly name that can be used for calling functions fixedLabel = label.replace(" ", "").replace(".", "").replace( "(", "").replace(")", "").replace("'", "") if name == "": name = fixedLabel if command is None or command == "": command = "menu" + fixedLabel if subMenu == True: newMenuItem = pm.menuItem(label=label, sm=True, tearOff=True, allowOptionBoxes=True) elif optionBox == True: newMenuItem = pm.menuItem(command=getattr(self, command + "Options"), optionBox=True) else: try: ## This is just hard coded for now, should be made a list in conf or something labelFixedForMenu = label for word in ["Modeler ", "Texturer ", "Selector ", "Rigger "]: if labelFixedForMenu.startswith(word): labelFixedForMenu = labelFixedForMenu.replace( word, "", 1) ## 1 occurance max replacement newMenuItem = pm.menuItem(label=labelFixedForMenu, command=getattr( self, command)) #self[command] ) except: newMenuItem = pm.menuItem(label=label + " Not Implemented") u.log("Attempted to add a MmmmTools menu item for a " "UI command that hasn't been written yet. " "The menu item will do nothing.") return newMenuItem
def register(self): try: self.activeParentMenu = self.menu pm.setParent(self.menu, menu=True) pm.menuItem(divider=True) ## Obsolete, never worked anyway has syntax errors ## just an idea... ## mi will make menu items #mi = lambda x(y): self.makeMenuItem( label=y ) ## md will make dividers #md = lambda x: pm.menuItem(divider=True) ## Put a bunch of strings in a list ## which will be used to make menu items items = [ #'MmmmTools Dockable UI...', #'div', 'Save Incrementally', 'Set Project By Pasting Or Typing', 'div', #'Activate Hotkey Manager', #'Save User Hotkeys', #'Restore Earlier Saved Hotkeys', #'div', #'Set Hotkeys To Factory Defaults', #'Set Hotkeys To User Defaults', #'div', #'Set Hotkeys To Polygons', #'Set Hotkeys To Rendering', #'Set Hotkeys To UVs', #'div', 'Hotkeys Window...', 'Hotstring Window...', 'div', 'Menu Selector', 'Selector Store Selection To Slot', "Selector Select From Slot's Selection", 'div', 'Selector Previous Slot', 'Selector Next Slot', 'div', 'Selector Set And Save Named Slot By Name', 'Selector Select Named Slot By Name', 'div', 'Selector Show Used Named Slots', 'div', #'div', ## Volume Select App/Tool/UI current disabled because of a Maya crash bug. #'Selector Volume Select Tool' , 'Selector Volume Select Verts', 'Selector Volume Select Faces', 'Menu Main', 'Menu Modeler', 'Modeler Split Polygon Tool', 'div', 'Modeler Select Non Quads', 'Modeler Select Tris', 'Modeler Select NGons', 'Modeler Select Quads', 'div', 'Modeler Select Hard Edges', 'Modeler Select Creased Edges', 'Modeler Crease Selected Edges', 'Modeler Uncrease Selected Edges', 'Modeler Crease And Harden Selected Edges', 'Modeler Uncrease And Soften Selected Edges', 'Modeler Propagate Edge Hardness On', 'Modeler Propagate Edge Hardness Off', 'div', 'Modeler Vertex Aligner', 'Modeler Center Pivot On Components', 'div', 'Modeler Zero Pivot Delete History Freeze Xforms WS', 'div', 'Modeler Mr Clean', 'Modeler Retopology Tools', 'Modeler Grid Tools', 'Modeler Mirror Tools', 'Menu Main', 'Menu Texturer', 'Texturer Reload Textures', 'Texturer UV Xforms Tool', 'Texturer Select Seams', 'Texturer Show Seams', 'div', 'Texturer Calc And Store UV Sizing', 'Texturer Apply Stored UV Sizing', 'Texturer Apply Numerical UV Sizing', 'div', 'Texturer Unfold3D Only Selected', 'Texturer Unfold3D Multiple Objects', 'div', 'Texturer FileTextureManager', 'Menu Main', 'Menu Rigger', 'Rigger Attribute Setter', 'Rigger Attribute Connector', 'Rigger Rename By Regular Expression', 'div', 'Rigger Pivot Fix', 'Rigger Replace Objects', 'Rigger Move Up In Hierarchy', 'div', 'Rigger Align Xforms', 'Rigger Constrain Xforms', 'Rigger Align Then Constrain Xforms', 'Rigger Zero', 'Rigger Make Pole Vector', 'div', 'Rigger Joint Orient Helper', 'Rigger Create Twist Joint To Selected Child', 'Rigger Create Rivets', 'Menu Main', 'Menu Renderer', ## The following line is diabled because MIP shaders work by default in Maya 2011, so it isn't needed right now. 'Renderer Show Hypershade MIP Shaders', 'Renderer Create Rim Light', 'Renderer Adjust Lighting', 'Renderer Reflectivity Of Selected Materials To Zero', 'Renderer Add VRay Texture Input Gamma Attributes', 'Renderer Set VRay Texture To SRGB', 'Renderer Set VRay Texture To Linear', 'Renderer Enable Hypergraph Thumbnails', 'Renderer Disable Hypergraph Thumbnails', 'Renderer Expose MIP Shaders Restart Required', 'Renderer Do Not Expose MIP Shaders Restart Required', 'Renderer Transfer Shading Sets By Space For Sel', 'Renderer Transfer Shading Sets By Component For Sel', ## The following two lines are for future planned features #'Create Occluded Ambient Light' ) #'Render Animation Interactively' ) 'Menu Main', 'Menu Gamer', 'Gamer Add Attributes For Export To Selected Objects', 'div', 'Gamer FBX Export Selection', 'Gamer FBX Export All', 'div', 'Gamer Make UCX Objects And Parent To Last Selected Object', 'Menu Main', 'Menu Scripter', 'Scripter Editor', 'Scripter Run Scripts From Selection', 'div', 'Scripter Connect To Attribute Array By Typing Name', 'Scripter Select Connected To Array By Typing Name', 'div', 'Scripter Make Scripter Node', 'div', 'Scripter File Runner', 'div', 'Scripter Mel To Python Converter Ui', 'Menu Main', 'div', #'Menu Open Maya Toolbox', # 'OMT Connect Components', # 'OMT Scale Position', # 'OMT Select Element', # 'OMT Selection Dragger', # 'optionBox OMT Selection Dragger', # 'OMT Select Loop', # 'OMT Select Outline', # 'optionBox OMT Select Outline', # 'OMT Select Ring', # 'OMT Spin Edge', # 'OMT Split Around Selection', # 'OMT Split Loop', # 'OMT Xray Toggle', # 'About The Open Maya Toolbox', 'Menu Main', 'div', #'Download Extra Scripts...', #'HKLocalTools (Downloaded)', # #'ProgressiveRendering (Downloaded)', #'GoZ (Shelf Button Substitute)', 'div', ] for item in items: #if item == 'Menu Main': # # pm.setParent( self.menu, menu=True ) # u.log('Going back to parent menu') #else: if isinstance(item, basestring): self.makeMenuItemFromString(item) #elif isinstance(item, dict ): # self.makeMenuItemFromDict( item ) ## Set back to standard menu pm.setParent(self.menu, menu=True) ## Prepare to make make menus via commander commander = self.mmmm.commander cmdEntries = commander.entries #### Make Developer Menu developerMenu = pm.menuItem(label='MmmmTools Developer...', sm=True, tearOff=True, allowOptionBoxes=True) self.submenus['developerMenu'] = developerMenu pm.setParent(developerMenu, menu=True) for name, entry in cmdEntries.items(): inMenu = entry['inMenu'] print(name) if inMenu == True or inMenu == 'Developer': print("in menu name is:") print(entry['name']) uiLabel = entry.get('uiLabel') if uiLabel == None: uiLabel = name pm.menuItem( label=uiLabel, command='mmmmTools.commander.commands["' + name + '"]()', ) commander = self.mmmm.commander cmdEntries = commander.entries pm.setParent(developerMenu, menu=True) modelerMenu = self.submenus['modeler'] = pm.menuItem( label='Modeler (dev)...', sm=True, tearOff=True, allowOptionBoxes=True) pm.setParent(modelerMenu, menu=True) for name, entry in cmdEntries.items(): inMenu = entry.inMenu if inMenu == 'Modeler': uiLabel = entry.get('uiLabel') if uiLabel == None: uiLabel = name pm.menuItem( label=uiLabel, command='mmmmTools.commander.commands["' + name + '"]()', ) pm.setParent(developerMenu, menu=True) selectorMenu = self.submenus['selector'] = pm.menuItem( label='Selector (dev)...', sm=True, tearOff=True, allowOptionBoxes=True) pm.setParent(selectorMenu, menu=True) for name, entry in cmdEntries.items(): inMenu = entry.inMenu if inMenu == 'Selector': uiLabel = entry.get('uiLabel') if uiLabel == None: uiLabel = name pm.menuItem( label=uiLabel, command='mmmmTools.commander.commands["' + name + '"]()', ) pm.menuItem(divider=True) pm.setParent(self.menu, menu=True) pm.menuItem(divider=True) pm.menuItem(divider=True) pm.menuItem(divider=True) ## This one should go last! Its the about box pm.menuItem("MmmmToolsHelp", label='MmmmTools Help', annotation='Help not yet available.', command=self.menuHelp) pm.menuItem("MmmmToolsAbout", label='About MmmmTools', command=self.menuAbout) except: u.log("Failed to create MmmmTools main menu.")
def register(self): try: self.activeParentMenu = self.menu pm.setParent( self.menu, menu=True ) pm.menuItem( divider=True ); ## Obsolete, never worked anyway has syntax errors ## just an idea... ## mi will make menu items #mi = lambda x(y): self.makeMenuItem( label=y ) ## md will make dividers #md = lambda x: pm.menuItem(divider=True) ## Put a bunch of strings in a list ## which will be used to make menu items items = [ #'MmmmTools Dockable UI...', #'div', 'Save Incrementally', 'Set Project By Pasting Or Typing', 'div', #'Activate Hotkey Manager', #'Save User Hotkeys', #'Restore Earlier Saved Hotkeys', #'div', #'Set Hotkeys To Factory Defaults', #'Set Hotkeys To User Defaults', #'div', #'Set Hotkeys To Polygons', #'Set Hotkeys To Rendering', #'Set Hotkeys To UVs', #'div', 'Hotkeys Window...', 'Hotstring Window...', 'div', 'Menu Selector', 'Selector Store Selection To Slot' , "Selector Select From Slot's Selection" , 'div', 'Selector Previous Slot' , 'Selector Next Slot' , 'div', 'Selector Set And Save Named Slot By Name' , 'Selector Select Named Slot By Name' , 'div', 'Selector Show Used Named Slots' , 'div', #'div', ## Volume Select App/Tool/UI current disabled because of a Maya crash bug. #'Selector Volume Select Tool' , 'Selector Volume Select Verts' , 'Selector Volume Select Faces' , 'Menu Main', 'Menu Modeler', 'Modeler Split Polygon Tool' , 'div', 'Modeler Select Non Quads' , 'Modeler Select Tris' , 'Modeler Select NGons' , 'Modeler Select Quads' , 'div', 'Modeler Select Hard Edges' , 'Modeler Select Creased Edges' , 'Modeler Crease Selected Edges' , 'Modeler Uncrease Selected Edges' , 'Modeler Crease And Harden Selected Edges' , 'Modeler Uncrease And Soften Selected Edges' , 'Modeler Propagate Edge Hardness On' , 'Modeler Propagate Edge Hardness Off' , 'div', 'Modeler Vertex Aligner', 'Modeler Center Pivot On Components', 'div', 'Modeler Zero Pivot Delete History Freeze Xforms WS', 'div', 'Modeler Mr Clean', 'Modeler Retopology Tools', 'Modeler Grid Tools', 'Modeler Mirror Tools', 'Menu Main', 'Menu Texturer', 'Texturer Reload Textures', 'Texturer UV Xforms Tool', 'Texturer Select Seams', 'Texturer Show Seams', 'div', 'Texturer Calc And Store UV Sizing', 'Texturer Apply Stored UV Sizing', 'Texturer Apply Numerical UV Sizing', 'div', 'Texturer Unfold3D Only Selected', 'Texturer Unfold3D Multiple Objects', 'div', 'Texturer FileTextureManager', 'Menu Main', 'Menu Rigger', 'Rigger Attribute Setter', 'Rigger Attribute Connector', 'Rigger Rename By Regular Expression', 'div', 'Rigger Pivot Fix', 'Rigger Replace Objects', 'Rigger Move Up In Hierarchy', 'div', 'Rigger Align Xforms', 'Rigger Constrain Xforms', 'Rigger Align Then Constrain Xforms', 'Rigger Zero', 'Rigger Make Pole Vector', 'div', 'Rigger Joint Orient Helper', 'Rigger Create Twist Joint To Selected Child', 'Rigger Create Rivets', 'Menu Main', 'Menu Renderer', ## The following line is diabled because MIP shaders work by default in Maya 2011, so it isn't needed right now. 'Renderer Show Hypershade MIP Shaders', 'Renderer Create Rim Light', 'Renderer Adjust Lighting', 'Renderer Reflectivity Of Selected Materials To Zero', 'Renderer Add VRay Texture Input Gamma Attributes', 'Renderer Set VRay Texture To SRGB', 'Renderer Set VRay Texture To Linear', 'Renderer Enable Hypergraph Thumbnails', 'Renderer Disable Hypergraph Thumbnails', 'Renderer Expose MIP Shaders Restart Required', 'Renderer Do Not Expose MIP Shaders Restart Required', ## The following two lines are for future planned features #'Create Occluded Ambient Light' ) #'Render Animation Interactively' ) 'Menu Main', 'Menu Gamer', 'Gamer Add Attributes For Export To Selected Objects', 'div', 'Gamer FBX Export Selection', 'Gamer FBX Export All', 'div', 'Gamer Make UCX Objects And Parent To Last Selected Object', 'Menu Main', 'Menu Scripter', 'Scripter Editor', 'Scripter Run Scripts From Selection', 'div', 'Scripter Connect To Attribute Array By Typing Name', 'Scripter Select Connected To Array By Typing Name', 'div', 'Scripter Make Scripter Node', 'div', 'Scripter File Runner', 'div', 'Scripter Mel To Python Converter Ui', 'Menu Main', 'div', #'Menu Open Maya Toolbox', # 'OMT Connect Components', # 'OMT Scale Position', # 'OMT Select Element', # 'OMT Selection Dragger', # 'optionBox OMT Selection Dragger', # 'OMT Select Loop', # 'OMT Select Outline', # 'optionBox OMT Select Outline', # 'OMT Select Ring', # 'OMT Spin Edge', # 'OMT Split Around Selection', # 'OMT Split Loop', # 'OMT Xray Toggle', # 'About The Open Maya Toolbox', 'Menu Main', 'div', #'Download Extra Scripts...', #'HKLocalTools (Downloaded)', # #'ProgressiveRendering (Downloaded)', #'GoZ (Shelf Button Substitute)', 'div', ] for item in items: #if item == 'Menu Main': # # pm.setParent( self.menu, menu=True ) # u.log('Going back to parent menu') #else: if isinstance( item, basestring ): self.makeMenuItemFromString( item ) #elif isinstance(item, dict ): # self.makeMenuItemFromDict( item ) ## Set back to standard menu pm.setParent( self.menu, menu=True ) ## Prepare to make make menus via commander commander = self.mmmm.commander cmdEntries = commander.entries #### Make Developer Menu developerMenu = pm.menuItem( label='MmmmTools Developer...', sm=True, tearOff=True, allowOptionBoxes=True ) self.submenus['developerMenu']=developerMenu pm.setParent( developerMenu, menu=True ) for name, entry in cmdEntries.items(): inMenu = entry['inMenu'] print( name ) if inMenu==True or inMenu=='Developer': print( "in menu name is:") print( entry['name'] ) uiLabel = entry.get( 'uiLabel' ) if uiLabel==None: uiLabel = name pm.menuItem( label=uiLabel, command='mmmmTools.commander.commands["' + name + '"]()', ) commander = self.mmmm.commander cmdEntries = commander.entries pm.setParent( developerMenu, menu=True ) modelerMenu = self.submenus['modeler'] = pm.menuItem( label='Modeler (dev)...', sm=True, tearOff=True, allowOptionBoxes=True ) pm.setParent( modelerMenu, menu=True ) for name, entry in cmdEntries.items(): inMenu = entry.inMenu if inMenu=='Modeler': uiLabel = entry.get( 'uiLabel' ) if uiLabel==None: uiLabel = name pm.menuItem( label=uiLabel, command='mmmmTools.commander.commands["' + name + '"]()', ) pm.setParent( developerMenu, menu=True ) selectorMenu = self.submenus['selector'] = pm.menuItem( label='Selector (dev)...', sm=True, tearOff=True, allowOptionBoxes=True ) pm.setParent( selectorMenu, menu=True ) for name, entry in cmdEntries.items(): inMenu = entry.inMenu if inMenu=='Selector': uiLabel = entry.get( 'uiLabel' ) if uiLabel==None: uiLabel = name pm.menuItem( label=uiLabel, command='mmmmTools.commander.commands["' + name + '"]()', ) pm.menuItem( divider=True ) pm.setParent( self.menu, menu=True ) pm.menuItem( divider=True ) pm.menuItem( divider=True ) pm.menuItem( divider=True ) ## This one should go last! Its the about box pm.menuItem( "MmmmToolsHelp", label='MmmmTools Help', annotation='Help not yet available.',command=self.menuHelp ) pm.menuItem( "MmmmToolsAbout", label='About MmmmTools', command=self.menuAbout ) except:
def __init__(self, parent=None, mmmm=None, parentWidget=None): self.parent = parent self.mmmm = mmmm self.widgets = {} self.annotationAboutInteraction = ( "The settings should also auto apply when you change them,\n " + "but due to a Maya bug, you may occasionally have to apply manually,\n " + "with the button.") try: initialMultiplier = pm.melGlobals[ 'MmmmToolsModelerGridToolsMultiplier'] except: initialMultiplier = 1.0 pm.melGlobals.initVar('float', 'MmmmToolsModelerGridToolsMultiplier') pm.melGlobals['MmmmToolsModelerGridToolsMultiplier'] = 1.0 initialSpacing = ((pm.grid(query=True, spacing=True) / pm.grid(query=True, divisions=True)) / initialMultiplier) initialWholeSize = pm.grid(query=True, size=True) / initialMultiplier ## Use this as parent otherwise use something else if parentWidget == None: parentWidget = self.widgets['parentWidget'] = pm.Window( title="Grid Manager", width=100, height=200) else: self.widgets['parentWidget'] = parentWidget ## Make a shortcut for function that addWidgets aw = self.addWidget with parentWidget: with aw('col', pm.ColumnLayout()): aw( 'mayaOptionsButton', pm.Button(label="Maya Grid Options...", command=lambda x: pm.mel.eval("GridOptions;"))) aw( 'resetButton', pm.Button(label="Reset (To Maya Defaults)", command=lambda x: self.resetToMayaDefault())) #aw('resetText', pm.Text(label=' ')) aw( 'reset2Button', pm.Button(label="Apply These Settings", annotation=self.annotationAboutInteraction, command=lambda x: MmmmToolsMod.Static.Grid. reset_via_numbers( multiplier=self.getMultiplierFromUi(), spacing=self.getSpacingFromUi(), wholeSize=self.getWholeSizeFromUi(), setManip=True, ))) ## note the "with" doesn't work with rows, ## so we manually specify parents priorParent = self.widgets['col'] row1 = self.widgets["row1"] = pm.rowLayout(numberOfColumns=2) aw('rowText1', pm.Text('Multiplier:', parent=row1)) aw( 'multiplierFloatField', pm.floatField( value=initialMultiplier, parent=row1, annotation= "This will mutiply with both spacing and whole size \n " + "to determine the final amount used. \n \n" + self.annotationAboutInteraction, changeCommand=lambda x: self.onChangedField(), enterCommand=lambda x: self.onChangedField(), )) pm.setParent(priorParent) row2 = self.widgets["row2"] = pm.rowLayout(numberOfColumns=2) aw('rowText2', pm.Text('Spacing:', parent=row2)) aw( 'spacingFloatField', pm.floatField( value=initialSpacing, parent=row2, annotation="This will control grid point spacing,\n " + "and will multiply with multiplier\n " + "to determine the final amount used. \n \n" + self.annotationAboutInteraction, changeCommand=lambda x: self.onChangedField(), enterCommand=lambda x: self.onChangedField(), )) pm.setParent(priorParent) row3 = self.widgets["row3"] = pm.rowLayout(numberOfColumns=2) aw('rowText3', pm.Text('Whole:', parent=row3)) aw( 'wholeSizeFloatField', pm.floatField( value=initialWholeSize, parent=row3, annotation= "This will control the extents of the whole grid,\n " + "(width/height) and will multiply with multiplier \n " + "to determine the final amount used. \n \n" + "Note, Maya's grid width is like a radius, \n" + "visible grid in Maya always looks twice as tall/wide, \n" + "since the 'size' setting in Maya is distance from grid center, \n" + "that's how Maya is intended to work. \n \n" + self.annotationAboutInteraction, changeCommand=lambda x: self.onChangedField(), enterCommand=lambda x: self.onChangedField(), )) pm.setParent(priorParent) row4 = self.widgets["row4"] = pm.rowLayout(numberOfColumns=2) aw('rowText4', pm.Text('Auto adjust discreet move:', parent=row4)) aw('setManipCheckBox', pm.CheckBox(value=True, label=' ', parent=row4)) ## the checkbox has a built in label, but that shows on wrong side pm.setParent(priorParent) aw('spacerBlankText', pm.Text(label=' ')) aw( 'snapButton', pm.Button(label="Snap Selected Objs To Grid", command=lambda x: MmmmToolsMod.Static.Grid. putSelectedObjsOnGrid())) aw( 'snapButton', pm.Button(label="Snap Selected Verts To Grid", command=lambda x: MmmmToolsMod.Static.Grid. snapVertsToGrid())) aw('snapText', pm.Text(label=' ')) aw( 'growButton', pm.Button( label="Grow", command=lambda x: self.growWithWarning(log=True))) aw( 'shrinkButton', pm.Button( label="Shrink", command=lambda x: self.shrinkWithWarning(log=True))) # Show Window if type(parentWidget) == pm.core.windows.window: win = parentWidget pm.showWindow(win) win.setWidth(200) win.setHeight(300)
def __init__(self,parent=None,mmmm=None, parentWidget=None): self.parent = parent self.mmmm = mmmm self.widgets = { } self.annotationAboutInteraction = ( "The settings should also auto apply when you change them,\n "+ "but due to a Maya bug, you may occasionally have to apply manually,\n "+ "with the button." ) try: initialMultiplier = pm.melGlobals['MmmmToolsModelerGridToolsMultiplier'] except: initialMultiplier = 1.0 pm.melGlobals.initVar( 'float', 'MmmmToolsModelerGridToolsMultiplier' ) pm.melGlobals['MmmmToolsModelerGridToolsMultiplier'] = 1.0 initialSpacing =( ( pm.grid( query=True, spacing=True ) / pm.grid( query=True, divisions=True ) ) / initialMultiplier ) initialWholeSize = pm.grid( query=True, size=True ) / initialMultiplier ## Use this as parent otherwise use something else if parentWidget==None: parentWidget = self.widgets['parentWidget'] = pm.Window( title="Grid Manager", width=100,height=200 ) else: self.widgets['parentWidget'] = parentWidget ## Make a shortcut for function that addWidgets aw = self.addWidget with parentWidget: with aw( 'col', pm.ColumnLayout() ): aw('mayaOptionsButton',pm.Button(label="Maya Grid Options...", command= lambda x: pm.mel.eval("GridOptions;") ) ) aw('resetButton', pm.Button(label="Reset (To Maya Defaults)", command= lambda x: self.resetToMayaDefault() ) ) #aw('resetText', pm.Text(label=' ')) aw('reset2Button', pm.Button( label="Apply These Settings", annotation=self.annotationAboutInteraction, command= lambda x: MmmmToolsMod.Static.Grid.reset_via_numbers( multiplier=self.getMultiplierFromUi(), spacing=self.getSpacingFromUi(), wholeSize=self.getWholeSizeFromUi(), setManip=True, ) ) ) ## note the "with" doesn't work with rows, ## so we manually specify parents priorParent=self.widgets['col'] row1 = self.widgets["row1"] = pm.rowLayout( numberOfColumns=2 ) aw( 'rowText1', pm.Text('Multiplier:', parent=row1) ) aw( 'multiplierFloatField', pm.floatField(value=initialMultiplier, parent=row1, annotation="This will mutiply with both spacing and whole size \n " + "to determine the final amount used. \n \n"+ self.annotationAboutInteraction, changeCommand= lambda x: self.onChangedField(), enterCommand= lambda x: self.onChangedField(), ) ) pm.setParent( priorParent ) row2 = self.widgets["row2"] = pm.rowLayout( numberOfColumns=2 ) aw( 'rowText2', pm.Text('Spacing:', parent=row2) ) aw( 'spacingFloatField', pm.floatField(value=initialSpacing, parent=row2, annotation="This will control grid point spacing,\n "+ "and will multiply with multiplier\n "+ "to determine the final amount used. \n \n"+ self.annotationAboutInteraction, changeCommand= lambda x: self.onChangedField(), enterCommand= lambda x: self.onChangedField(), ) ) pm.setParent( priorParent ) row3 = self.widgets["row3"] = pm.rowLayout( numberOfColumns=2 ) aw( 'rowText3', pm.Text('Whole:', parent=row3) ) aw( 'wholeSizeFloatField', pm.floatField(value=initialWholeSize, parent=row3, annotation="This will control the extents of the whole grid,\n " + "(width/height) and will multiply with multiplier \n "+ "to determine the final amount used. \n \n"+ "Note, Maya's grid width is like a radius, \n"+ "visible grid in Maya always looks twice as tall/wide, \n"+ "since the 'size' setting in Maya is distance from grid center, \n"+ "that's how Maya is intended to work. \n \n"+ self.annotationAboutInteraction, changeCommand= lambda x: self.onChangedField(), enterCommand= lambda x: self.onChangedField(), ) ) pm.setParent( priorParent ) row4 = self.widgets["row4"] = pm.rowLayout( numberOfColumns=2 ) aw( 'rowText4', pm.Text('Auto adjust discreet move:', parent=row4) ) aw( 'setManipCheckBox', pm.CheckBox(value=True, label=' ', parent=row4) ) ## the checkbox has a built in label, but that shows on wrong side pm.setParent( priorParent ) aw('spacerBlankText', pm.Text(label=' ')) aw('snapButton', pm.Button(label="Snap Selected Objs To Grid", command= lambda x: MmmmToolsMod.Static.Grid.putSelectedObjsOnGrid() ) ) aw('snapButton', pm.Button(label="Snap Selected Verts To Grid", command= lambda x: MmmmToolsMod.Static.Grid.snapVertsToGrid() ) ) aw('snapText', pm.Text(label=' ')) aw('growButton', pm.Button(label="Grow", command= lambda x: self.growWithWarning(log=True) ) ) aw('shrinkButton', pm.Button(label="Shrink", command= lambda x: self.shrinkWithWarning(log=True) ) ) # Show Window if type( parentWidget ) == pm.core.windows.window: win = parentWidget pm.showWindow(win) win.setWidth(200) win.setHeight(300)
Custom_Tools = pm.menu(label=menuName) with Custom_Tools: obj_cr_btn = pm.menuItem( label="Object creator",command=lambda x: obj_creat()) cus_tls_btn = pm.menuItem( label="Custom Tools",command=lambda x: cus_tls()) const_btn = pm.menuItem( label="Constraint",command=lambda x: con_tls()) tnk_trd_bth = pm.menuItem( label="Tank Tread Rig (arun)", command=lambda x: tank_trd()) cpy_sdk_btn = pm.menuItem( label="Copy Sdk (arun)", command=lambda x: copy_sdk()) #tools_btn = pm.menuItem(subMenu=True, label = "Tools", tearOff=True) #tool_sub1_btn = pm.menuItem(label = "Test") joint_place_btn = pm.menuItem(subMenu=True, label = "Joint Placement", tearOff=True) joint_place_sub1_btn = pm.menuItem(label = "Center", command = lambda x: jnt_at_mid()) joint_place_sub2_btn = pm.menuItem(label = "Center aimed at vertex", command = lambda x: jnt_mid_aimed()) joint_place_sub3_btn = pm.menuItem(label = "Chain along edge loops", command = lambda x: jnt_along_loop()) pm.setParent('..', menu=True) skn_clstr_btn = pm.menuItem(subMenu=True, label = "Skin Cluster Tools") tool_sub_def_skn = pm.menuItem(label = "All deformers to skin cluster (suresh)", command = lambda x: def_to_sk_cl()) tool_sub_xfer = pm.menuItem(label = "SkinXfer (suresh)", command = lambda x: skin_xfer()) tool_sub_qaSknMng = pm.menuItem(label = "qa skin manager (amit das)", command = lambda x: qa_sk_mng()) pm.setParent('..', menu=True) clst_tl_btn = pm.menuItem(subMenu=True, label = "Cluster tools") cls_sub_mir = pm.menuItem(label = "Mirror Cluster (amit das)", command = lambda x: mir_cls()) pm.setParent('..', menu=True) scl_jnts_crv = pm.menuItem( label="Scale Joints By Curve (amit das)", command=lambda x: stretch_setup()) spline_ik = pm.menuItem( label="IK spline setup (arun)", command=lambda x: spline_ik_setup()) curve_through_points = pm.menuItem(label = "curve through points", command = lambda x: curve_points())
def ckFidgetWin(): """ ckFidgetWin() description: creates interface for ckFidget tool. the list is built dynamically from the list of active fidgets on load, so the more fidgets you add. the longer the tool window will become. inputs: outputs: the main fidget window. CK - I should add some menus to this that have basic falloffs for common tasks, like cloth, sss, or lighting. """ if pm.mel.eval('window -ex "fidgetMainWin" ;'): pm.mel.eval('deleteUI "fidgetMainWin";' ) fidgetWin = pm.mel.eval('window -title "Carl Keifer attribute fidgeter" -width 150 fidgetMainWin;') pm.columnLayout( adjustableColumn=True ) pm.frameLayout( label = "Build Fidget", borderStyle='in', collapsable=True ) pm.rowLayout( numberOfColumns=5, columnWidth=(75,75) ) pm.button( label = 'Add Fidget', command = 'ckAddFidget()' ) pm.button( label = 'refresh UI', command = 'ckFidget()' ) pm.button( label = 'Save All', command = 'ckSavRstZerAll( "save" )') pm.button( label = 'Zero All', command = 'ckSavRstZerAll( "zero" )') pm.button( label = 'Restore All', command = 'ckSavRstZerAll( "restore" )') pm.setParent( '..' ) pm.setParent( '..' ) pm.frameLayout( label = "Master Fidget", borderStyle='in', collapsable=True ) pm.rowLayout( numberOfColumns=6, columnWidth=(75,75) ) pm.mel.eval( 'floatField -value $gckFidgetBump -min 0 -changeCommand "$gckFidgetBump = `floatField -q -v masterBump`" masterBump;' ) pm.button( label = '<', command = 'ckFidgetBumpAll("Down")') pm.button( label = '>', command = 'ckFidgetBumpAll("Up")') pm.radioButtonGrp( label='Bump by:', labelArray2=['0.0', '%'], numberOfRadioButtons=2, sl=1, on1= 'pm.setAttr("ckFidget_GRP.bumpBy", False)', on2= 'pm.setAttr("ckFidget_GRP.bumpBy", True)') pm.setParent( '..' ) pm.setParent( '..' ) pm.frameLayout( label = "Fidget Attributes", borderStyle='in', collapsable=True ) e = 0 # this iterates the list of fidgets we have ckList = ckGetList("ckFidget_GRP.ckFidgetList") for i in ckList: print "i, ",i pm.rowLayout( numberOfColumns=6, columnWidth=(75,75) ) pm.attrFieldSliderGrp( l=str(i), min=-10.0, max=10.0, at = i ) pm.button( label = '<', command = 'ckFidgetBump(\"'+i+'\", "Down")' ) pm.button( label = '>', command = 'ckFidgetBump( \"'+i+'\","Up")' ) pm.button( label = 'save', command = 'ckSavRst( \"'+i+'\", "save")') pm.button( label = 'zero', command = 'pm.setAttr( \"'+i+'\", 0)' ) pm.button( label = 'restore', command = 'ckSavRst( \"'+i+'\", "restore")') pm.setParent( '..' ) pm.setParent( '..' ) pm.setParent( '..' ) pm.showWindow(fidgetWin) # I should now connect the master fidget value to the fidget group