def commonButtons(self): # Creates a button size parameter with a padding of 18 pixels. The width is the size of the UI width minus the padding # divided by three. The height is 26 pixels. self.commonBtnSize = ((self.size[0]-18)/3, 26) # Establishes the layout of the buttons. Sets them into a row, with three buttons in the row. Also establishes their size. # Creates the "create and close" button. self.actionBtn = mc.button(label = self.actionName, height = self.commonBtnSize[1], command = self.actionBtnCmd) # Creates the "create" button. self.createBtn = mc.button(label = "Create", height = self.commonBtnSize[1], command = self.createBtnCmd) # Creates the "close" button. self.closeBtn = mc.button(label = "Close", height = self.commonBtnSize[1], command = self.closeBtnCmd) # Dictates how the buttons scale when the user scales the UI. # First sets the main form to edit mode. mc.formLayout(self.mainForm, e=True, attachForm=( # Then takes each button, specifies the edge to adjust, and then specifies the value to adjust by. # Pins the action button to the left of the UI with a padding of 5 pixels. [self.actionBtn, 'left', 5], # Pins the action button to the bottom of the UI with a padding of 5 pixels. [self.actionBtn, 'bottom', 5], # Pins the create button to the bottom of the UI with a padding of 5 pixels. [self.createBtn, 'bottom', 5], # Pins the close botton to the bottom of the UI with a padding of 5 pixels. [self.closeBtn, 'bottom', 5], # Pins the close button to the right of the UI with a padding of 5 pixels. [self.closeBtn, 'right', 5]), # Pins buttons relative to the coordinates specified in the create(self) function according to the # numberOfDivisions flag in the mainForm command. attachPosition = ([self.actionBtn, 'right', 1, 33], [self.closeBtn, 'left', 0, 67]), # Pins the middle button to the outer two buttons. Allows it to scale along with the other two buttons. attachControl = ([self.createBtn, 'left', 4, self.actionBtn], [self.createBtn, 'right', 4, self.closeBtn]), # Makes sure that the the top edges of the buttons scale according to the above parameters. attachNone = ([self.actionBtn, 'top'], [self.createBtn, 'top'], [self.closeBtn, 'top']))
def create(self): if cmds.window( WinA_Global.winName, ex=1 ): cmds.deleteUI( WinA_Global.winName, wnd=1 ) cmds.window( WinA_Global.winName, title = WinA_Global.title, titleBarMenu = WinA_Global.titleBarMenu ) form = cmds.formLayout() exportPathForm = self.uiExportPath.create() exportTypeForm = self.uiExportType.create() searchForForm = self.uisearchFor.create() searchForTypeForm = self.uisearchForType.create() buttonsForm = cmds.button( l='<< EXPORT M E S H >>', bgc=[0.5,0.5,0.6], h=30 ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af = [( exportPathForm, 'top', 8 ), ( exportPathForm, 'left', 0 ), ( exportPathForm, 'right', 5 ), ( exportTypeForm, 'left',0 ), ( exportTypeForm, 'right', 0 ), ( searchForForm, 'left', 0 ), ( searchForTypeForm, 'left', 0 ), ( buttonsForm, 'left', 0 ), ( buttonsForm, 'right', 0 ) ], ac = [( exportTypeForm, 'top', 8, exportPathForm ), ( searchForForm, 'top', 8, exportTypeForm ), ( searchForTypeForm, 'top', 8, searchForForm ), ( buttonsForm, 'top', 12, searchForTypeForm )] ) cmds.window( WinA_Global.winName, e=1, w = WinA_Global.width, h = WinA_Global.height ) cmds.showWindow( WinA_Global.winName ) self.button = buttonsForm self.setUiCommand() WinA_Cmd.read_windowInfo() WinA_Cmd.setWindowCondition()
def create(self): # Checks to see if this window has already been created. If it has, it deletes the window. if mc.window(self.window, exists=True): mc.deleteUI(self.window, window=True) # Creates the window using the already initialized attributes as well as the menuBar attribute from below. self.window = mc.window(self.window, title=self.title, wh=self.size, menuBar = True) # Establishes themain layout of the GUI. self.mainForm = mc.formLayout(numberOfDivisions=100) # Calls the cmmonMenu function created below. self.commonMenu() # Calls the button creation function that is created below. self.commonButtons() # Creates a central pane in the display. self.optionsBorder = mc.tabLayout(scrollable=True, tabsVisible = False, height = 1) # Nests the pane within the main form layout. mc.formLayout(self.mainForm, e=True, attachForm = ( # Pins the top edge to the top of the UI with a padding of 0 pixels. [self.optionsBorder, 'top', 0], # Pins the left edge of pane to the left of the UI with a padding of 2 pixels. [self.optionsBorder, 'left', 2], # Pins the right edge of the pane to the right of the UI with a padding of 2 pixels. [self.optionsBorder, 'right', 2]), # Pins the bottom edge of the pane to the top edge of the buttons. attachControl = ([self.optionsBorder, 'bottom', 5, self.createBtn])) # Allows the panel to scale with the main UI. self.optionsForm = mc.formLayout(numberOfDivisions=100) # Calls the display option function from below. self.displayOptions() # Shows (displays) the window. mc.showWindow()
def createUI(self): """""" if cmds.window(self.window, ex=1): cmds.deleteUI(self.window) cmds.window(self.window, t='%s v%s' % (self.title, setup.getVersion()), w=230, s=0, rtf=1) # setup layout and ui elements form = cmds.formLayout() self.mainTabLayout = cmds.tabLayout(childResizable=True) cmds.formLayout( form, edit=True, attachForm=( (self.mainTabLayout, 'top', 0), (self.mainTabLayout, 'left', 0), (self.mainTabLayout, 'bottom', 0), (self.mainTabLayout, 'right', 0) ) ) # Setup tab ui from modules tabModules = [] for m in scUtil.findAllModules('ui'): mod = __import__('SoftClusterEX.ui.%s' % m, '', '', [m]) if hasattr(mod, 'TAB') and mod.ENABLE: reload(mod) tabModules.append(mod) tabModules.sort(key=lambda m: m.INDEX) [self.addTab(m.getTab()) for m in tabModules] cmds.showWindow(self.window)
def create(self): form = cmds.formLayout() text = cmds.text( l= self.label, w=self.width1, h=self.height, al= self.aline ) radio = cmds.radioCollection() rb1 = cmds.radioButton( l=self.rbLabel1, w=self.width2, sl=1 ) rb2 = cmds.radioButton( l=self.rbLabel2, w=self.width3 ) rb3 = cmds.radioButton( l=self.rbLabel3, w=self.width4 ) check = cmds.checkBox( l=self.rbLabel4 ) txf = cmds.textField( en=0 ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af = [( text, 'top', 0 ),( text, 'left', 0 ), ( rb1, 'top', 0 ), ( rb2, 'top', 0 ), ( rb3, 'top', 0 )], ac = [( rb1, 'left', 0, text ), ( rb2, 'left', 0, rb1 ), ( rb3, 'left', 0, rb2 ), ( check, 'top', 0, text ), ( check, 'left', 0, text ), ( txf, 'top', 0, text ), ( txf, 'left', 0, check )] ) WinA_Global.searchForType_radio = radio WinA_Global.searchForType_check = check WinA_Global.searchForType_txf = txf WinA_Global.searchForType_form = form return form
def create(self): if cmds.window( self.winName, ex=1 ): cmds.deleteUI( self.winName, wnd=1 ) cmds.window( self.winName, title=self.title ) form = cmds.formLayout() form_cloneTarget = self.uiCloneTargets.create() form_cloneLabel = self.uiCloneLabel.create() chk_shapeOn = cmds.checkBox( l='Shape On', v=1 ) chk_connectionOn = cmds.checkBox( l='Connection On', v=0 ) bt_createClone = cmds.button( l='C R E A T E C L O N E', h=25, c = WinA_Cmd.cmdCreateClone ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af = [( form_cloneTarget, 'top', 5 ), ( form_cloneTarget, 'left', 5 ), ( form_cloneTarget, 'right', 5 ), ( form_cloneLabel, 'top', 5 ), ( form_cloneLabel, 'left', 5 ), ( form_cloneLabel, 'right', 5 ), ( chk_shapeOn, 'left', 50 ), ( bt_createClone, 'left', 0 ),( bt_createClone, 'right', 0 )], ac = [( form_cloneLabel, 'top', 10, form_cloneTarget ), ( chk_shapeOn, 'top', 10, form_cloneLabel ), ( chk_connectionOn, 'top', 10, form_cloneLabel ), ( chk_connectionOn, 'left', 30, chk_shapeOn ), ( bt_createClone, 'top', 10, chk_connectionOn )] ) cmds.window( self.winName, e=1, wh=[ self.width, self.height ], rtf=1 ) cmds.showWindow( self.winName ) WinA_Global.ui_clones = self.uiCloneTargets WinA_Global.chk_shapeOn = chk_shapeOn WinA_Global.chk_connectionOn = chk_connectionOn
def create(self): if cmds.window( WinMain.name, q=1, ex=1 ): cmds.deleteUI( WinMain.name ) cmds.window( WinMain.name, title=WinMain.title ) form = cmds.formLayout() textExplanation = cmds.text( l='1.컨트롤러 선택 \n2.컨트롤할 타겟들 선택'.decode( 'utf-8' ), al='center', h=50, bgc=[.3,.3,.3], font='fixedWidthFont' ) textAttr = cmds.text( l='Attribute Name', h=25 ) fieldAttrName = cmds.textField( tx='show', h=25) buttonConnect = cmds.button( l='Connect', h=30, c=Cmd.connect ) cmds.formLayout( form, e=1, af=[(textExplanation, 'top', 0), (textExplanation, 'left', 0), (textExplanation, 'right', 0), (textAttr, 'left', 5), (fieldAttrName, 'right', 5), (buttonConnect, 'left', 0), (buttonConnect, 'right', 0)], ac=[(textAttr, 'top', 5, textExplanation), (fieldAttrName, 'top', 5, textExplanation), (fieldAttrName, 'left', 5, textAttr), (buttonConnect, 'top', 5, textAttr)] ) cmds.window( WinMain.name, e=1, width=WinMain.width, height=WinMain.height ) WinMain.fieldAttrName = fieldAttrName
def createChannelBoxForNode(node): ''' This function pops open an independent channel box window in maya, for the node supplied in the arguments. ''' assert cmds.objExists(node), "Node %s does not exist!!!" % node selectionConnectionName = ("%s_rigBuilderSelectionConnection" % node) selectionConnection = None if cmds.selectionConnection(selectionConnectionName, ex=True): selectionConnection = selectionConnectionName else: selectionConnection = cmds.selectionConnection(selectionConnectionName) cmds.selectionConnection(selectionConnectionName, e=True, obj=node) channelBoxWindow = cmds.window(t=node) formLayout = cmds.formLayout(p=channelBoxWindow) channelBox = cmds.channelBox(p=formLayout, mlc=selectionConnection) cmds.formLayout(formLayout, e=True, af=[(channelBox, "top", 0), (channelBox, "bottom", 0), (channelBox, "left", 0), (channelBox, "right", 0)]) return cmds.showWindow(channelBoxWindow)
def create(self): form = cmds.formLayout() text = cmds.text( l= self._label, al='right', h=20, width = self._textWidth ) field = cmds.textField(h=21) cmds.popupMenu() cmds.menuItem( l=self._popup, c=self.cmdPopup ) cmds.formLayout( form, e=1, af=[(text,'top',0), (text,'left',0), (field,'top',0),(field,'right',0)], ac=[(field, 'left', 0, text)] ) if self._position: cmds.formLayout( form, e=1, ap=[(text,'right',0,self._position)]) cmds.setParent( '..' ) self._text = text self._field = field self._form = form self._globalForm = form self._globalField = field return form
def create(self): form = cmds.formLayout() text1 = cmds.text( l= self.label1, w=self.width1, h=self.height, al='right' ) text2 = cmds.text( l= self.label2, w=self.width1, h=self.height, al='right' ) text3 = cmds.text( l= self.label3, w=self.width1-10, h=self.height, al='right' ) field1 = cmds.floatField( w=self.width2, h=self.height, step=0.25, pre=2 ) field2 = cmds.floatField( w=self.width2, h=self.height, step=0.25, pre=2 ) field3 = cmds.floatField( w=self.width2, h=self.height, step=0.25, pre=2, v=1 ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af=[( text1, 'top', 0 ), ( text1, 'left', 0 ), ( text2, 'top', 0 ), ( text3, 'top', 0 )], ac=[( field1, 'left', 0, text1 ), ( text2, 'left', 0, field1 ), ( field2, 'left', 0, text2 ), ( text3, 'left', 0, field2 ), ( field3, 'left', 0, text3 )]) WinA_Global.fld_startFrame = field1 WinA_Global.fld_endFrame = field2 WinA_Global.fld_step = field3 self.form = form return form
def create(self): if cmds.window( WinA_Global.winName, ex=1 ): cmds.deleteUI( WinA_Global.winName, wnd=1 ) cmds.window( WinA_Global.winName, title = WinA_Global.title, titleBarMenu = WinA_Global.titleBarMenu ) form = cmds.formLayout() exportPathForm = self.uiExportPath.create() exportTypeForm = self.uiExportType.create() timeRanges = self.uiTimeRanges.create() buttonsForm = cmds.button( l='<< EXPORT A L E M B I C >>', bgc=[0.85,0.85,0.45], h=30, c = WinA_Cmd.export ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af = [( exportPathForm, 'top', 8 ), ( exportPathForm, 'left', 0 ), ( exportPathForm, 'right', 5 ), ( exportTypeForm, 'left',0 ), ( exportTypeForm, 'right', 0 ), ( timeRanges, 'left', 0 ), ( timeRanges, 'right', 0 ), ( buttonsForm, 'left', 0 ), ( buttonsForm, 'right', 0 ) ], ac = [( exportTypeForm, 'top', 8, exportPathForm ), ( timeRanges, 'top', 8, exportTypeForm ), ( buttonsForm, 'top', 8, timeRanges )] ) cmds.window( WinA_Global.winName, e=1, w = WinA_Global.width, h = WinA_Global.height ) cmds.showWindow( WinA_Global.winName ) self.button = buttonsForm WinA_Cmd.setFrameRange() WinA_Cmd.setExportPath() popupMenu = cmds.popupMenu( p= WinA_Global.exportPath_txf ) sgBFunction_ui.updatePathPopupMenu( WinA_Global.exportPath_txf, popupMenu )
def warningWindow(): formLayout = cmds.setParent(query=True) icon = cmds.image(image= uiMod.getImagePath("ACR_white_bright")) titleText = cmds.text(label="You have newer animation. Do you want to load?", font="boldLabelFont", align="left") messageText = cmds.text(label=message, align="left") buttonLoad = cmds.button(label='Load', command='cmds.layoutDialog(dismiss="load")') buttonMaybe = cmds.button(label='Maybe Later', command='cmds.layoutDialog(dismiss="maybe")', w=100) cmds.formLayout (formLayout, edit=True, width=300, height=height, attachPosition = [ (icon, 'left', 10, 0), (icon, 'top', 10, 0), (titleText, 'top', 10, 0), (messageText, 'left', 10, 0), (messageText, 'top', 0, 30), (buttonLoad, 'left', 10, 0), (buttonLoad, 'bottom', 10, 100), (buttonMaybe, 'bottom', 10, 100) ], attachForm = [ (buttonLoad, 'left', 10), (buttonMaybe, 'right', 10) ], attachControl = [ (titleText, 'left', 10, icon), (buttonLoad, 'right', 5, buttonMaybe) ])
def loadWindow(): mayaFileName = infoData["mayaFileName"] message = "%s\n%s\n\nWarning: Loading crash files after editing your Maya file can lead to unpredictable results."%(mayaFileName, time.ctime(modDate)) formLayout = cmds.setParent(query=True) icon = cmds.image(image= uiMod.getImagePath("ACR_white_bright")) titleText = cmds.text(label="Do you want to load?", font="boldLabelFont", align="left") messageText = cmds.text(label=message, align="left") buttonLoad = cmds.button(label='Load', command='cmds.layoutDialog(dismiss="load")') buttonLoadSel = cmds.button(label='Load On Selection', command='cmds.layoutDialog(dismiss="load_selection")', w=110) cmds.formLayout (formLayout, edit=True, width=300, height=170, attachPosition = [ (icon, 'left', 10, 0), (icon, 'top', 10, 0), (titleText, 'top', 10, 0), (messageText, 'left', 10, 0), (messageText, 'top', 0, 30), (buttonLoad, 'left', 10, 0), (buttonLoad, 'bottom', 10, 100), (buttonLoadSel, 'bottom', 10, 100) ], attachForm = [ (buttonLoad, 'left', 10), (buttonLoadSel, 'right', 10) ], attachControl = [ (titleText, 'left', 10, icon), (buttonLoad, 'right', 5, buttonLoadSel) ])
def modifyMayaUI(): mayaHotKeys.disableAllHotKeys() mayaUI.simplifyUI() mayaUI.setViewportQuality() myWindow = cmds.window() myForm = cmds.formLayout(parent=myWindow) global gCadNanoToolbar gCadNanoToolbar = cmds.toolBar( "cadnanoBox", area='top', allowedArea='top', content=myWindow) global gIconPath closeCadNanoCmd = 'import maya.cmds;maya.cmds.closeCadNano()' myButton = cmds.iconTextButton( label='Quit cadnano', annotation='Quit cadnano interface', image1=gIconPath, parent=myForm, command=closeCadNanoCmd) cmds.formLayout( myForm, edit=True, attachForm=[(myButton, 'right', 10)])
def buildFilter(self): self.opt = cmds.optionMenuGrp(self.opt, label='Filter:', cc=self.cmdFilter, cw2=[40, 75], height=20) for i, item in enumerate(self.filters): itm = (item + '_%02d_menuItem' % i) cmds.menuItem(itm, l=item) attachForm = [(self.opt, 'bottom', 5), (self.opt, 'left', 0)] cmds.formLayout(self.form, edit=True, attachForm=attachForm)
def create(self): if cmds.window( Win_Global.winName, q=1, ex=1 ): cmds.deleteUI( Win_Global.winName ) cmds.window( Win_Global.winName, title=Win_Global.title ) form = cmds.formLayout() text = cmds.text( l= "Select joint tops", al='center', h=30, bgc=[.5,.5,.5] ) check = cmds.checkBox( l='Add Pin Control' ) controllerName = self.ui_controllerName.create() colorIndex = self.ui_colorIndex.create() controllerSize = self.ui_controllerSize.create() button = self.ui_buttons.create() cmds.setParent( '..' ) cmds.formLayout( form, e=1, af=[ (text, 'top', 0 ), (text, 'left', 0 ), (text, 'right', 0 ), (check, 'top', 5 ), (check, 'left', 10 ), (check, 'right', 0 ), (controllerName, 'left', 10 ), (controllerName, 'right', 5 ), (colorIndex, 'left', 10 ), (colorIndex, 'right', 5 ), (controllerSize, 'left', 10 ), (controllerSize, 'right', 5 ), (button, 'left', 0 ), (button, 'right', 0 ), (button, 'bottom', 0 )], ac=[ (check, 'top', 5, text), (controllerName, 'top', 5, check), (colorIndex, 'top', 5, controllerName), (controllerSize, 'top', 5, colorIndex), (button, 'top', 5, controllerSize) ] ) cmds.window( Win_Global.winName, e=1, width = Win_Global.width, height = Win_Global.height, rtf=1 ) cmds.showWindow( Win_Global.winName ) Win_Global.checkBox = check
def new(self): cmds.setParent(self.parent) self.name = cmds.button(self.name, label=self.label, c=self.cmd, h=self.h) if self.bgc: cmds.button(self.name, e=True, bgc=self.bgc) attachForm = [(self.name, 'bottom', self.moveUp), (self.name, 'right', 0), (self.name, 'left', 0)] cmds.formLayout(self.parent, edit=True, attachForm=attachForm)
def remappingWindow(self,exsitingData,importedData): #if (cmds.window(MainSkinUI.RemapWindowID,ex=True)): #cmds.deleteUI(MainSkinUI.RemapWindowID, wnd=True) #cmds.window(MainSkinUI.RemapWindowID,w=500,h=340,title='Influence Remapping Dialog') formLayout=cmds.setParent(q=True) cmds.formLayout(formLayout,e=True,w=500,h=340) mainColumnLayout = cmds.columnLayout(w=500,h=340) cmds.columnLayout(h=5) cmds.setParent('..') cmds.columnLayout(cat=['left',25]) cmds.text(l='The following influences hace no corresponding influence from the imported weight\n'\ ' data. You can remap the influences or skip them',al='left', w=450,h=40) cmds.setParent('..') cmds.separator(w=500, st='in') formLayout = cmds.formLayout() exsitingInfluences = cmds.columnLayout() cmds.frameLayout(l='Exsiting Influences:') self.exsitingInfluencesBox = cmds.textScrollList(w=230,h=230) cmds.setParent('..') cmds.setParent('..') importedInfluences = cmds.columnLayout() cmds.frameLayout(l='Imported Influences:') self.importedInfluencesLayout = cmds.columnLayout(w=230,h=230) cmds.columnLayout(h=5) cmds.setParent('..') #self.importedInfluencesLayout = cmds.columnLayout(cat=['left',40]) cmds.formLayout(formLayout,e=True,af=[(exsitingInfluences,'left',10)],ac=[(importedInfluences,'left',10,exsitingInfluences)]) cmds.setParent(mainColumnLayout) cmds.columnLayout(h=5) cmds.setParent('..') cmds.columnLayout(cat=['left',150]) cmds.button(l='Import Remapped Skin Weight', w=200, c=self.passRemappingData) self.setInfluenceDialog(exsitingData,importedData)
def addFloatVariable(self, nodeAttr, varslayout, name=None, value=None): n = cmds.columnLayout(varslayout, query=1, numberOfChildren=1) indexStr = "[%d]" % n nameAttr = nodeAttr + indexStr valueAttr = nodeAttr.replace("fparam_name", "fparam_value") + indexStr form = cmds.formLayout(numberOfDivisions=100, parent=varslayout) rembtn = cmds.button(label="-") namefld = cmds.textField(text=("fparam%d" % n if name is None else name)) vallbl = cmds.text(label="=") valfld = cmds.floatField(value=(0.0 if value is None else value)) cmds.setAttr(nameAttr, ("fparam%d" % n if name is None else name), type="string") cmds.setAttr(valueAttr, (0.0 if value is None else value)) self.setupVariableNameCallback(nameAttr, namefld) self.setupFloatVariableValueCallback(valueAttr, valfld) cmds.button(rembtn, edit=1, command=lambda *args: self.removeFloatVariable(nodeAttr, varslayout, n)) cmds.formLayout(form, edit=1, attachForm=[(rembtn, "top", 0), (rembtn, "bottom", 0), (rembtn, "left", 0), (namefld, "top", 0), (namefld, "bottom", 0), (vallbl, "top", 0), (vallbl, "bottom", 0), (valfld, "top", 0), (valfld, "bottom", 0)], attachControl=[(namefld, "left", 5, rembtn), (vallbl, "left", 5, namefld), (valfld, "left", 5, vallbl)], attachNone=[(rembtn, "right"), (vallbl, "right")], attachPosition=[(namefld, "right", 0, 30), (valfld, "right", 0, 100)])
def create(self): if cmds.window( self.winName, ex=1 ): cmds.deleteUI( self.winName, wnd=1 ) cmds.window( self.winName, title= self.title ) form = cmds.formLayout() field_meshForm = self.field_mesh.create() field_uvForm = self.field_uv.create() checkForm = self.check.create() buttons_form = self.buttons.create() cmds.setParent( '..' ) cmds.formLayout( form, e=1, af=[(field_meshForm, 'top', 0 ), ( field_meshForm, 'left', 0 ), ( field_meshForm, 'right', 0 ), (field_uvForm, 'left', 0 ), ( field_uvForm, 'right', 0 ), (checkForm, 'left', 0 ), (checkForm, 'right', 0 ), (buttons_form, 'left', 0 ), ( buttons_form, 'right', 0 ) ], ac=[(field_uvForm, 'top', 0, field_meshForm ), (checkForm, 'top', 0, field_uvForm), (buttons_form, 'top', 0, checkForm )]) cmds.window( self.winName, e=1, w=self.width, h=self.height ) cmds.showWindow( self.winName ) self.setTextInfomation() self.popupSetting() self.buttonCommandSetting()
def create(self): """ Draw the window """ # delete the window if its handle exists if cmds.window(self.window, exists=True): # deletes window. 'window' flag makes sure that deleted object is a window cmds.deleteUI(self.window, window=True) # initialize the window self.window = cmds.window(title=self.title, widthHeight=self.size, menuBar=True) # main form for the window self.mainForm = cmds.formLayout(numberOfDivisions=100) # create common menu items items and buttons self.commonMenu() self.commonButtons() # create a tabLayout self.optionsBorder = cmds.tabLayout(scrollable=True, tabsVisible=False, height=1) # Attach tabLayout to parent formLayout, and to control button cmds.formLayout(self.mainForm, edit=True, attachForm= ([self.optionsBorder, 'top', 0], [self.optionsBorder, 'left', 2], [self.optionsBorder, 'right', 2]), attachControl= ([self.optionsBorder, 'bottom', 5, self.applyBtn])) # new form to attach controls in displayOptions() self.optionForm = cmds.formLayout(numberOfDivisions=100) self.displayOptions() # Show the window cmds.showWindow(self.window)
def create(self): if cmds.window( WinA_Global.winName, ex=1 ): cmds.deleteUI( WinA_Global.winName, wnd=1 ) cmds.window( WinA_Global.winName, title= WinA_Global.title, titleBarMenu = WinA_Global.titleBarMenu ) form = cmds.formLayout() importPathForm = self.uiImportPath.create() importByMatrixForm = self.importByMatrix.create() buttonForm = self.uiButton.create() cmds.setParent( '..' ) cmds.formLayout( form, e=1, af=[(importPathForm, 'top', 8), (importPathForm, 'left', 0), (importPathForm, 'right', 0), (importByMatrixForm, 'left', 120 ), (importByMatrixForm, 'right', 0 ), (buttonForm, 'left', 0 ), (buttonForm, 'right', 0 )], ac=[(importByMatrixForm, 'top', 8, importPathForm), (buttonForm, 'top', 8, importByMatrixForm)] ) cmds.window( WinA_Global.winName, e=1, w= WinA_Global.width, h= WinA_Global.height, rtf=1 ) cmds.showWindow( WinA_Global.winName ) WinA_uiCmd.setUiDefault() WinA_uiCmd.loadInfo() WinA_uiCmd.setUiCommand()
def commonButtons(self): """ Create common buttons for all option boxes """ self.commonBtnSize = ((self.size[0]-18)/3, 26) # The basic idea for computing the width is that we want 5 pixels of padding on the left and right, # and 4 pixels of padding in between the buttons (5+4+4+45 =18). Hence, we subtract a total of # 18 from the window's width before dividing by 3. The height is 26 pixels. self.actionBtn = cmds.button(label=self.actionName, height=self.commonBtnSize[1], command=self.actionBtnCmd) self.applyBtn = cmds.button(label='Apply', height=self.commonBtnSize[1], command=self.applyBtnCmd) self.closeBtn = cmds.button(label='Close', height=self.commonBtnSize[1], command=self.closeBtnCmd) cmds.formLayout(self.mainForm, edit=True, attachForm= ([self.actionBtn, 'left', 5], [self.actionBtn, 'bottom', 5], [self.applyBtn, 'bottom', 5], [self.closeBtn, 'bottom', 5], [self.closeBtn, 'right', 5]), attachPosition= ([self.actionBtn, 'right', 1, 33], [self.closeBtn, 'left', 0, 67]), attachControl= ([self.applyBtn, 'left', 4, self.actionBtn], [self.applyBtn, 'right', 4, self.closeBtn]), attachNone= ([self.actionBtn, 'top'], [self.applyBtn, 'top'], [self.closeBtn, 'top']))
def __init__( self ): baseMelUI.BaseMelWindow.__init__( self ) mel.zooVisManUtils() mel.zooVisInitialSetup() self.setSceneChangeCB( self.populate ) self.UI_form = cmd.formLayout(docTag=0) self.UI_check_state = cmd.checkBox(v=self.state(), al="left", l="turn ON", cc=self.on_state_change) self.UI_button_marks = cmd.button(l="bookmarks") self.UI_tsl_sets = cmd.textScrollList(ams=1, dcc=self.on_collapse, nr=18, sc=self.on_select) self.POP_marks = cmd.popupMenu(p=self.UI_button_marks, b=1, aob=1, pmc=self.popup_marks) self.POP_marks_sh = cmd.popupMenu(p=self.UI_button_marks, sh=1, b=1, aob=1, pmc=self.popup_marks_add) self.POP_sets = cmd.popupMenu(p=self.UI_tsl_sets, b=3, pmc=self.popup_sets) self.reparentUI = None cmd.formLayout(self.UI_form, e=True, af=((self.UI_check_state, "top", 3), (self.UI_check_state, "left", 3), (self.UI_button_marks, "top", 0), (self.UI_button_marks, "right", 0), (self.UI_tsl_sets, "left", 0), (self.UI_tsl_sets, "bottom", 0)), ac=((self.UI_button_marks, "left", 5, self.UI_check_state), (self.UI_tsl_sets, "top", 0, self.UI_button_marks)), ap=((self.UI_tsl_sets, "right", 0, 100)) ) self.populate() self.show()
def __init__( self, setsToReparent ): baseMelUI.BaseMelWindow.__init__( self ) allSets = set( mel.zooVisManListHeirarchically() ) allSets.difference_update( set(setsToReparent) ) self.UI_form = cmd.formLayout() self.UI_tsl = cmd.textScrollList(ams=0, nr=18) self.UI_button_parent = cmd.button(l="parent") cmd.textScrollList(self.UI_tsl, e=True, dcc='%s.ui.reparentUI.on_done()' % name) cmd.button(self.UI_button_parent, e=True, c='%s.ui.reparentUI.on_done()' % name) # cmd.textScrollList(self.UI_tsl, e=True, a=self.NO_PARENT) for vset in allSets: cmd.textScrollList(self.UI_tsl, e=True, a=vset) cmd.formLayout(self.UI_form, e=True, af=((self.UI_tsl, "top", 0), (self.UI_tsl, "left", 0), (self.UI_tsl, "right", 0), (self.UI_button_parent, "left", 0), (self.UI_button_parent, "right", 0), (self.UI_button_parent, "bottom", 0)), ac=((self.UI_tsl, "bottom", 0, self.UI_button_parent)) ) #select the no parent option cmd.textScrollList(self.UI_tsl, e=True, si=self.NO_PARENT) self.show()
def create(self): try:frame = cmds.frameLayout( l='Follow Area', bgs=1, bgc=[0.2,0.2,.4] ) except:frame = cmds.frameLayout( l='Follow Area', bgc=[0.2,0.2,.4] ) form = cmds.formLayout() text = cmds.text( l='Select Ik And Set' ) root = cmds.checkBox( l='Root', v=1 ) fly = cmds.checkBox( l='Fly', v=1 ) move = cmds.checkBox( l='Move', v=1 ) world = cmds.checkBox( l='World', v=1 ) btSet = cmds.button( l='Set', c= Win_Cmd.addFollow ) cmds.setParent( '..' ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af=[ ( text, 'left', 0 ), ( text, 'right', 0 ), ( text, 'top', 0 ), ( root, 'left', 0 ), ( world, 'right', 0 ), ( btSet, 'left', 0 ), ( btSet, 'right', 0 ) ], ac=[ ( root, 'top', 5, text ), ( fly, 'top', 5, text ), ( move, 'top', 5, text ), ( world, 'top', 5, text ), ( btSet, 'top', 5, move ) ], ap=[ ( root, 'right', 0, 25 ), ( fly, 'left', 0, 25 ), ( fly, 'right', 0, 50 ), ( move, 'left', 0, 50 ), ( move, 'right', 0, 75 ), ( world, 'left', 0, 75 ) ] ) Win_Global.rootfollow = root Win_Global.flyfollow = fly Win_Global.movefollow = move Win_Global.worldfollow = world return frame
def create(self): if cmds.window( Win_Global.winName, q=1, ex=1 ): cmds.deleteUI( Win_Global.winName ) cmds.window( Win_Global.winName, title= Win_Global.title ) formOuter = cmds.formLayout() stdForm = self.stdArea.create() rigForm = self.rigArea.create() followForm = self.followArea.create() addRigForm = self.addRigArea.create() cmds.setParent( '..' ) cmds.formLayout( formOuter, e=1, af = [ (stdForm, 'left', 5), (stdForm, 'right', 5), (stdForm, 'top', 5), (rigForm, 'left', 5), (rigForm, 'right', 5), (followForm, 'left', 5), (followForm, 'right', 5), (addRigForm, 'left', 5), (addRigForm, 'right', 5), (addRigForm, 'bottom', 5) ], ac = [ (rigForm, 'top', 5, stdForm ), (followForm, 'top', 5, rigForm ), (addRigForm, 'top', 5, followForm )] ) cmds.window( Win_Global.winName, e=1, width = Win_Global.width, height= Win_Global.height ) cmds.showWindow( Win_Global.winName ) Win_Global.loadInfo()
def installCreateButton(self): """""" layout = cmds.frameLayout("createLayout", lv=False, bv=False) form = cmds.formLayout() self.createBtn = cmds.iconTextButton(st='iconOnly', l='Create', ann="Create cluster by default, turn on \"J\" to create joint.", c=lambda *args: self.createSoftDeformerCmd() ) self.jointCheck = cmds.iconTextCheckBox(st='textOnly', l=' J ', ann="Create joint", cc=lambda *args: self.setCreateBtnIcon()) cmds.formLayout(form, e=1, af=[(self.createBtn, 'left', 0), (self.createBtn, 'right', 0), (self.createBtn, 'top', 0), (self.createBtn, 'bottom', 0), (self.jointCheck, 'right', 0), (self.jointCheck, 'top', 0)] ) cmds.setParent( '..' ) cmds.setParent( '..' ) self.setCreateBtnIcon() return layout
def startLayout(self,m=1,n=1): # cmds.frameLayout( cll=True,label='ePMV') self.form = cmds.formLayout(numberOfDivisions=100)#the main form ? self.mainscroll = cmds.scrollLayout('scrollLayout')#,w=self.w*self.scale)#,p=self.winName) cmds.formLayout( self.form, edit=True, attachForm=((self.mainscroll, 'top', 0), (self.mainscroll, 'left', 0), (self.mainscroll, 'bottom', 0), (self.mainscroll, 'right', 0)) )
def startBlock(self,m=1,n=1): #currently i will just make basic layou using the rawLayout # columnWidth=[] # for i in range(1,m): # columnWidth.append([i,80])#[(1, 60), (2, 80), (3, 100)] # cmds.rowColumnLayout(numberOfColumns=m,columnWidth=columnWidth) # cmds.flowLayout(wr=True) if not self.inNotebook and self.notebook is not None: if self.afterNoteBook is None: c=self.afterNoteBook = cmds.flowLayout(wr=True,p=self.form) cmds.formLayout( self.form, edit=True, attachForm=((c, 'left', 0),(c, 'bottom', 0), (c, 'right', 0)),attachControl = ((c,'top',5,self.notebook["id"])) ) if m==0: c=cmds.flowLayout(wr=True,w=self.w*self.scale,p=self.afterNoteBook) else : c=cmds.rowLayout(numberOfColumns=m,w=self.w*self.scale,p=self.afterNoteBook) else : # if self.mainlayout is None: # c=self.mainlayout = cmds.scrollLayout('scrollLayout',p=self.form)#cmds.flowLayout(wr=True,p=self.form) # cmds.formLayout( self.form, edit=True, attachForm=((c, 'left', 0),(c, 'bottom', 0), # (c, 'right', 0),(c, 'top', 0),) ) if m==0: cmds.flowLayout(wr=True,w=self.w*self.scale)#,p=self.mainlayout) else : cmds.rowLayout(numberOfColumns=m,w=self.w*self.scale)#,p=self.mainlayout)
def displayListWindow(itemList, title): ''' ''' # Check itemList if not itemList: return # Window window = 'displayListWindowUI' if mc.window(window, q=True, ex=True): mc.deleteUI(window) window = mc.window(window, t=title, s=True) # Layout FL = mc.formLayout(numberOfDivisions=100) # UI Elements TSL = mc.textScrollList('displayListWindowTSL', allowMultiSelection=True) for item in itemList: mc.textScrollList(TSL, e=True, a=item) mc.textScrollList(TSL, e=True, sc='glTools.ui.utils.selectFromTSL("' + TSL + '")') closeB = mc.button('displayListWindowB', l='Close', c='mc.deleteUI("' + window + '")') # Form Layout mc.formLayout(FL, e=True, af=[(TSL, 'top', 5), (TSL, 'left', 5), (TSL, 'right', 5)]) mc.formLayout(FL, e=True, af=[(closeB, 'bottom', 5), (closeB, 'left', 5), (closeB, 'right', 5)]) mc.formLayout(FL, e=True, ac=[(TSL, 'bottom', 5, closeB)]) # Display Window mc.showWindow(window)
def reportWindow(msg, title): ''' ''' # Check message if not msg: return # Window window = 'reportWindowUI' if mc.window(window, q=True, ex=True): mc.deleteUI(window) window = mc.window(window, t=title, s=True) # Layout FL = mc.formLayout(numberOfDivisions=100) # UI Elements reportSF = mc.scrollField('reportWindowSF', editable=False, wordWrap=True, text=msg) closeB = mc.button('reportWindowB', l='Close', c='mc.deleteUI("' + window + '")') # Form Layout mc.formLayout(FL, e=True, af=[(reportSF, 'top', 5), (reportSF, 'left', 5), (reportSF, 'right', 5)]) mc.formLayout(FL, e=True, af=[(closeB, 'bottom', 5), (closeB, 'left', 5), (closeB, 'right', 5)]) mc.formLayout(FL, e=True, ac=[(reportSF, 'bottom', 5, closeB)]) # Display Window mc.showWindow(window)
def __init__(self, parent, name="Attr Info", mixer=1, attrs=[]): self.mainFrame = cmds.frameLayout( parent=parent, cll=True, label=name ) # self.mainScroll = cmds.scrollLayout() self.mainFrm = cmds.formLayout( parent=self.mainFrame ) topWidgit = self._manipWidgit(self.mainFrm) # Creating the gui elements above the attributes # Add & Remove self.attrGrp = AttrGroup( self.mainFrm ) # Mixer elements at the bottom # bottomWidgit = self._mixerWidgit( self.mainFrm ) # Positioning the widgits cmds.formLayout( self.mainFrm, e=1, af=[[topWidgit, "top", 2],[topWidgit, "left", 5]]) cmds.formLayout( self.mainFrm, e=1, af=[self.attrGrp.mainLayout, "left", 5], ac=[self.attrGrp.mainLayout, "top", 5, topWidgit]) if( mixer ): mixer = self._mixerGUI(self.mainFrm) cmds.formLayout( self.mainFrm, e=1, af=[mixer, "left", 5], ac=[mixer, "top", 5, self.attrGrp.mainLayout])
def installRedefineSection(self): """""" cmds.frameLayout(l='Redefine:', cll=False, mh=5, w=200) form1 = cmds.formLayout() self.installEdit() self.installDone() self.installAppendCheck() cmds.formLayout(form1, e=1, af=[(self.editBtn, 'left', 0), (self.editBtn, 'top', 0), (self.editBtn, 'bottom', 0), (self.doneBtn, 'left', 0), (self.doneBtn, 'top', 0), (self.doneBtn, 'bottom', 0), (self.appendCheck, 'right', 0), (self.appendCheck, 'top', 0), (self.appendCheck, 'bottom', 0)], ac=[(self.doneBtn, 'left', 1, self.editBtn), (self.doneBtn, 'right', 4, self.appendCheck)], ap=[(self.editBtn, 'right', 0, 42)]) cmds.setParent("..") separator = cmds.separator(st='in') form2 = cmds.formLayout() self.installDetach() cmds.formLayout(form2, e=1, af=[(self.detachBtn, 'left', 0), (self.detachBtn, 'top', 0), (self.detachBtn, 'bottom', 0), (self.detachBtn, 'right', 0)]) cmds.setParent("..") cmds.setParent("..")
def build_gui_generate_inbetween(): window_name = "build_gui_generate_inbetween" if cmds.window(window_name, exists=True): cmds.deleteUI(window_name) # Main GUI Start Here ================================================================================= # Build UI build_gui_generate_inbetween = cmds.window(window_name, title=script_name + " v" + script_version,\ titleBar=True, mnb=False, mxb=False, sizeable =True) # #cmds.window("build_gui_generate_inbetween", title="gt_inbetween " + script_version,\ # titleBar=True,minimizeButton=True,maximizeButton=False, sizeable =False,widthHeight=[323, 217]) cmds.window(window_name, e=True, s=True, wh=[1, 1]) column_main = cmds.columnLayout() form = cmds.formLayout(p=column_main) content_main = cmds.columnLayout(adj=True) # Title Text cmds.separator(h=10, style='none') # Empty Space cmds.rowColumnLayout(nc=1, cw=[(1, 330)], cs=[(1, 10)], p=content_main) # Window Size Adjustment cmds.rowColumnLayout(nc=3, cw=[(1, 10), (2, 260), (3, 50)], cs=[(1, 10), (2, 0), (3, 0)], p=content_main) # Title Column cmds.text(" ", bgc=[0, .5, 0]) # Tiny Empty Green Space cmds.text(script_name + " v" + script_version, bgc=[0, .5, 0], fn="boldLabelFont", align="left") cmds.button(l="Help", bgc=(0, .5, 0), c=lambda x: build_gui_help_generate_inbetween()) cmds.separator(h=10, style='none', p=content_main) # Empty Space # Body ==================== body_column = cmds.rowColumnLayout(nc=1, cw=[(1, 320)], cs=[(1, 10)], p=content_main) cmds.separator(h=15, p=body_column) mid_container = cmds.rowColumnLayout(p=body_column, numberOfRows=1, h=25) transform_type = cmds.optionMenu(p=mid_container, label=' Layer Type') cmds.menuItem(label='Group') cmds.menuItem(label='Joint') cmds.menuItem(label='Locator') transform_parent_type = cmds.optionMenu(p=mid_container, label=' Parent Type') cmds.menuItem(label='Selection') cmds.menuItem(label='Parent') cmds.text(" ", p=mid_container) cmds.separator(h=10, style='none', p=body_column) # Empty Space color_container = cmds.rowColumnLayout(p=body_column, numberOfRows=1, h=25) color_slider = cmds.colorSliderGrp(label='Outliner Color ', rgb=(settings.get("outliner_color")[0], \ settings.get("outliner_color")[1], settings.get("outliner_color")[2]),\ columnWidth=((1,85),(3,130)), cc=lambda x:update_stored_values()) cmds.separator(h=15, p=body_column) bottom_container = cmds.rowColumnLayout(p=body_column, adj=True) cmds.text('New Transform Suffix:', p=bottom_container) desired_tag = cmds.textField(p = bottom_container, text="_rigLayer", enterCommand=lambda x:create_inbetween(parse_text_field(cmds.textField(desired_tag, q=True, text=True))[0],\ cmds.optionMenu(transform_parent_type, q=True, value=True),\ cmds.optionMenu(transform_type, q=True, value=True))) cmds.separator(h=10, style='none') # Empty Space cmds.button(l ="Generate", bgc=(.6, .8, .6), c=lambda x:create_inbetween(parse_text_field(cmds.textField(desired_tag, q=True, text=True))[0],\ cmds.optionMenu(transform_parent_type, q=True, value=True),\ cmds.optionMenu(transform_type, q=True, value=True))) cmds.separator(h=10, style='none') # Empty Space # Updates Stored Values def update_stored_values(): settings["outliner_color"] = cmds.colorSliderGrp(color_slider, q=True, rgb=True) #print(settings.get("outliner_color")) Debugging # Show and Lock Window cmds.showWindow(build_gui_generate_inbetween) cmds.window(window_name, e=True, s=False) # Set Window Icon qw = omui.MQtUtil.findWindow(window_name) widget = wrapInstance(long(qw), QWidget) icon = QIcon(':/hsGraphMaterial.png') widget.setWindowIcon(icon)
def __init__(self): #获取制定路径文件 f=open('O:/hq_tool/Maya/hq_maya/scripts/fantabox/animation/animLib/AniLibPath.py','r') ap=f.readlines() f.close() for line in ap: self.pathA1=line.encode('gbk')#转码获取正确路径 pathA=self.pathA1[0:] #加载动画api aniLoaded = cmds.pluginInfo('animImportExport',query=True, l=True) if aniLoaded!=True: cmds.loadPlugin('animImportExport') aniLoaded = cmds.pluginInfo('animImportExport',query=True, l=True) self.user=getpass.getuser() if cmds.window("AnimateLibWin",ex=1): cmds.deleteUI("AnimateLibWin",window=1) #if cmds.control('AniWin',ex=1): # cmds.deleteUI('AniWin',control=True) self.AnilibWindow=cmds.window('AnimateLibWin',t="动作库管理系统",menuBar=1 ,wh=(705, 585),s=1) cmds.menu(label=u'文件',tearOff=True) cmds.menuItem(label=u"登入管理员",c=self.ENTRYwin) cmds.menuItem(label=u"退出管理员",c=self.SecedeUser) cmds.menu(label=u"帮助",helpMenu=True) cmds.menuItem(label="About",c=self.helpWin) cmds.rowColumnLayout( numberOfColumns=2, columnAlign=(1, 'right'), columnAttach=(2, 'both', 0), columnWidth=(2, 705) ) cmds.text( label='') cmds.separator(bgc=(.5,.5,.6)) cmds.setParent('..') rowlay=cmds.rowLayout(nc=8) cmds.text('usertext',l=u'用户:',w=30) cmds.text('userlist',l=self.user,w=50) cmds.button('Addanims',l=u'添加动作库',bgc=(.7,.7,1),vis=1,c=self.doanilib) cmds.button('mirrorani',l=u'动画镜像',bgc=(.7,.7,1),vis=1,c=self.mirrorani) cmds.button(l=u'删除类别',bgc=(.7,.7,1),vis=0) self.editwins=cmds.checkBox('cBWinS',label="WinSizeable",onc=self.ON,ofc=self.OFF) cmds.button(l=u'刷新',bgc=(.5,.9,.5),c='AnimLibWin.AniLibWin()') cmds.setParent('..') rowlayPath=cmds.rowLayout(nc=3) cmds.text('Pathtext',l=u'总路径:',w=40) self.allpat=cmds.textField('Path',tx=pathA,w=600,en=False,ec=self.EDITPATH_01) self.textFieldenable=cmds.checkBox('Path001EN',label="enable",onc=self.ONTEXTfon,ofc=self.ONTEXTfoff) cmds.setParent('..') findlayPath=cmds.rowLayout(nc=3) cmds.text('findobj',l=u'搜索:',w=40) self.FindObj=cmds.textField('Name',tx='',w=150,en=True,ec=self.FINDOBJ) self.PicS=cmds.intSlider('picSize',min=0,max=200,value=100,w=200,step=1,cc=self.EDITSbSIZE) cmds.setParent('..') self.column = cmds.columnLayout('column') self.theForm=cmds.formLayout('theForm') self.t1 = cmds.treeView('ok',w=50,h=500) self.column1 =cmds.rowLayout('column1',nc=2) cmds.text(l=u'动作名称:') self.AniName=cmds.textField('aniName',tx='',w=220,editable=False) cmds.setParent('..') self.tuplistlayout=cmds.tabLayout('tuplistlayout',h=520,w=100) cmds.setParent('..') self.column2 =cmds.rowLayout('column2',nc=2) cmds.text(l=u'作者:') cmds.textField('aa',tx=u'陈文渊(SevinChen)', w=220,editable=False) cmds.setParent('..') self.column3 = cmds.rowLayout('column3',nc=2) cmds.text(l=u'日期:') cmds.textField (tx='2014/10',w=220,editable=False) cmds.setParent('..') self.column4 = cmds.rowLayout('column4',nc=2) cmds.text(l=u'路径:') self.dzlj=cmds.textField('dzlj',tx='',w=220,editable=False) cmds.setParent('..') self.column5 = cmds.rowLayout('column5',nc=1) b1 = cmds.button(l=u'添加备注',en=1,bgc=(.5 ,1 ,.5 ),c=self.addbeizhu) cmds.setParent('..') self.column6 = cmds.rowLayout('column6',nc=1) t6 = cmds.scrollField('t6',wordWrap=True,text=u'无') cmds.setParent('..') self.column7 =cmds.rowLayout('column7',nc=1) self.img=cmds.image('Pic',image ='O:/hq_tool/Maya/hq_maya/scripts/fantabox/animation/animLib/小怪.jpg') cmds.setParent('..') self.column8 = cmds.gridLayout('column8',numberOfColumns=3,cw=85) cmds.button(l=u'观看视频',bgc=(.5, .8, 1),c=self.OPENVIDEO) cmds.button(l=u'使用动作',bgc=(.5, .8, 1),c=self.IMPPORTwin) cmds.popupMenu() cmds.menuItem(l=u'高级动画',c=self.gaojiani) cmds.button(l=u'打开文件',bgc=(.5 ,.8, 1),c=self.OPENMB) cmds.popupMenu('ButtonPM') cmds.menuItem(l=u'打开文件夹',c=self.OPENFILE) cmds.formLayout('theForm',e=True, attachForm=[('ok', 'top', 0),('ok', 'left' ,0),('ok', 'bottom', 0),('ok', 'right', 550), ('column1','top',5),('column1','right',0),('column2','top',30),('column2','right',0), ('column3','top',55),('column3','right',0),('column4','top',75),('column4','right',0), ('column5','top',95),('column5','right',0),('column6','top',115),('column6','right',0), ('column7','top',335),('column7','right',0),('column8','top',500),('column8','right',0),('tuplistlayout', "top", 0),('tuplistlayout', "right", 300)], attachPosition=[('column1','left',0, 60),('column2','left',0, 63),('column3','left',0, 63),('column4','left',0, 63), ('column5','left',0, 63),('column6','left',0, 63),('column7','left',0, 63),('column8','left',0, 63),('tuplistlayout',"left" , 0, 25)], attachControl=[('column1','bottom',0,'ok'),('column2','bottom',0,'ok'),('column3','bottom',0,'ok'),('column4','bottom',0,'ok'), ('column5','bottom',0,'ok'),('column6','bottom',0,'ok'),('column7','bottom',0,'ok'),('column8','bottom',0,'ok'),('tuplistlayout', "bottom", 0 ,'ok')] ) cmds.showWindow('AnimateLibWin') cmds.window('AnimateLibWin',e=True,wh=(405, 670),s=1) #allowedAreas = ['right', 'left'] #cmds.dockControl('AniWin',l='AniWin',area='left', content='AnimateLibWin', allowedArea=allowedAreas ) #导入类别与项目 getpath=cmds.textField('Path',q=True,tx=True) delto=getpath.replace('\\','/')#修改路径 path=delto+'/' WJno=cmds.getFileList(folder=path) for i in WJno: cmds.treeView('ok',edit=True,addItem=(i,'')) WJno1=cmds.getFileList(folder=path+i+'/') if WJno1!=[]: for j in WJno1: pt=path+i+'/'+j+'/' cmds.treeView('ok',edit=True,addItem=(j,i),scc=self.REN)
import maya.cmds as cmds
import os import errno suffName = 'D:/PH_SCRIPTS/SCRIPTS/suffNodes.py' global unidadDisco global unidad global scene global char #namesCharacters=[] nameWindow = 'fixUpdateCharacterAlembic' if mc.window(nameWindow ,ex=True): mc.deleteUI(nameWindow) mc.window(nameWindow, title="fixUpdateCharacterAlembic", sizeable=False, resizeToFitChildren=True) form = mc.formLayout(numberOfDivisions=100) cl1 = cmds.columnLayout(adjustableColumn = True) mc.text(label='-INFORMACION NECESARIA-') tfu=mc.textFieldGrp(nameWindow + 'UD', label='UNIDAD:', ann='Nombre de la unidad.') tfe=mc.textFieldGrp(nameWindow + 'ESC', label='ESCENA:',ann='Nombre de la escena.') l1=mc.checkBox(label='UV WRITW',value=True) l2=mc.checkBox(label='FIT TIME RANGE',value=True) l2=mc.checkBox(label='BLENDSHAPE TO ALEMBIC', value=True) mc.text(label='-CHARACTERS-') scrol = cmds.textScrollList( nameWindow + 'FOLDERS', numberOfRows=5, allowMultiSelection=True, append=charsFolders, selectItem=selecStringChar, showIndexedItem=8 ) b1=mc.button(nameWindow + 'btn1', label="CREATE ABC", w=50, h=50, command="importChar()")
def __init__(self): tl = self.treeLister.wid cmds.formLayout(self.form, edit=True, af=((tl, 'top', 0), (tl, 'left', 0), (tl, 'bottom', 0), (tl, 'right', 0)))
def antiAliasNoiseQual(): global aanqSeparator aanqGroup1 = cmds.radioButtonGrp("aanqRadButGrp1", numberOfRadioButtons=3, label='Anitalias/Noise Qual (15%)', labelArray3=['A+ -A', 'B+ -B', 'C+ -C'], onCommand=antiAliasButton1) aanqGroup2 = cmds.radioButtonGrp("aanqRadButGrp2", numberOfRadioButtons=2, shareCollection=aanqGroup1, label='', labelArray2=['D', 'F'], onCommand=antiAliasButton2) cmds.formLayout(gradeFrm, edit=1, attachForm=[aanqGroup1, "left", 5], attachControl=[aanqGroup1, "top", 5, cflSeparator]) cmds.formLayout(gradeFrm, edit=1, attachForm=[ aanqGroup2, "left", 5, ], attachControl=[aanqGroup2, "top", 5, aanqGroup1]) aanqShapeField = cmds.intFieldGrp("aanqIntField", numberOfFields=1, label='Grade', changeCommand=updateGradeTotal) aanqTextScrollList = cmds.scrollField("aanqTSList", w=200, h=150, wordWrap=1) aanqCommentsLabel = cmds.text(label='Comments') cmds.formLayout(gradeFrm, edit=1, attachForm=[aanqShapeField, "top", 5], attachControl=[aanqShapeField, "top", 10, aanqGroup2]) cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqTextScrollList, "left", 140], attachControl=[aanqTextScrollList, "top", 10, aanqShapeField]) cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqCommentsLabel, "left", 60], attachControl=[aanqCommentsLabel, "top", 10, aanqShapeField]) aanqSeparator = cmds.separator(height=15, width=460, style='in') cmds.formLayout( gradeFrm, edit=1, attachForm=[aanqSeparator, "left", 5], attachControl=[aanqSeparator, "top", 5, aanqTextScrollList])
def stretchyIkSplineUI(): """ UI for stretchyIkSpline() """ # Window window = 'stretchyIkSplineUI' if cmds.window(window, q=True, ex=1): cmds.deleteUI(window) window = cmds.window(window, t='Stretchy IK Spline') # Layout FL = cmds.formLayout() # UI Elements # --- # IK Handle handleTFB = cmds.textFieldButtonGrp('stretchyIkSplineTFB', label='IK Handle', text='', buttonLabel='Load Selected') # Prefix prefixTFG = cmds.textFieldGrp('stretchyIkSplinePrefixTFG', label='Prefix', text='') # Scale Axis axisList = ['X', 'Y', 'Z'] scaleAxisOMG = cmds.optionMenuGrp('stretchyIkSplineAxisOMG', label='Joint Scale Axis') for axis in axisList: cmds.menuItem(label=axis) cmds.optionMenuGrp(scaleAxisOMG, e=True, sl=1) # Scale Attr scaleAttrTFB = cmds.textFieldButtonGrp('stretchyIkSplineScaleAttrTFB', label='Scale Attribute', text='', buttonLabel='Load Selected') # Blend blendCtrlTFB = cmds.textFieldButtonGrp('stretchyIkSplineBlendCtrlTFB', label='Blend Control', text='', buttonLabel='Load Selected') blendAttrTFG = cmds.textFieldGrp('stretchyIkSplineBlendAttrTFG', label='Blend Attribute', text='stretchScale') # Stretch Method methodList = ['Arc Length', 'Parametric'] methodOMG = cmds.optionMenuGrp('stretchyIkSplineMethodOMG', label='Stretch Method') for method in methodList: cmds.menuItem(label=method) cmds.optionMenuGrp(methodOMG, e=True, sl=2) # Parametric Layout paramFrameL = cmds.frameLayout('stretchyIkSplineParamFL', l='Parametric Bounds', cll=0) paramFormL = cmds.formLayout(numberOfDivisions=100) # Min/Max Percent minPercentFSG = cmds.floatSliderGrp('stretchyIkSplineMinPFSG', label='Min Percent', field=True, minValue=0.0, maxValue=1.0, fieldMinValue=0.0, fieldMaxValue=1.0, value=0.0) maxPercentFSG = cmds.floatSliderGrp('stretchyIkSplineMaxPFSG', label='Max Percent', field=True, minValue=0.0, maxValue=1.0, fieldMinValue=0.0, fieldMaxValue=1.0, value=1.0) closestPointCBG = cmds.checkBoxGrp('stretchyIkSplineClosestPointCBG', l='Use Closest Point', ncb=1, v1=True) cmds.setParent('..') cmds.setParent('..') # Buttons createB = cmds.button('stretchyIkSplineCreateB', l='Create', c='glTools.ui.ik.stretchyIkSplineFromUI(False)') cancelB = cmds.button('stretchyIkSplineCancelB', l='Cancel', c='cmds.deleteUI("' + window + '")') # UI callback commands cmds.textFieldButtonGrp(handleTFB, e=True, bc='glTools.ui.utils.loadTypeSel("' + handleTFB + '","' + prefixTFG + '",selType="ikHandle")') cmds.textFieldButtonGrp(scaleAttrTFB, e=True, bc='glTools.ui.utils.loadChannelBoxSel("' + scaleAttrTFB + '")') cmds.textFieldButtonGrp(blendCtrlTFB, e=True, bc='glTools.ui.utils.loadObjectSel("' + blendCtrlTFB + '")') cmds.optionMenuGrp(methodOMG, e=True, cc='cmds.frameLayout("' + paramFrameL + '",e=True,en=cmds.optionMenuGrp("' + methodOMG + '",q=True,sl=True)-1)') # Form Layout - MAIN cmds.formLayout(FL, e=True, af=[(handleTFB, 'top', 5), (handleTFB, 'left', 5), (handleTFB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(prefixTFG, 'top', 5, handleTFB)]) cmds.formLayout(FL, e=True, af=[(prefixTFG, 'left', 5), (prefixTFG, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(scaleAxisOMG, 'top', 5, prefixTFG)]) cmds.formLayout(FL, e=True, af=[(scaleAxisOMG, 'left', 5), (scaleAxisOMG, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(scaleAttrTFB, 'top', 5, scaleAxisOMG)]) cmds.formLayout(FL, e=True, af=[(scaleAttrTFB, 'left', 5), (scaleAttrTFB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(blendCtrlTFB, 'top', 5, scaleAttrTFB)]) cmds.formLayout(FL, e=True, af=[(blendCtrlTFB, 'left', 5), (blendCtrlTFB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(blendAttrTFG, 'top', 5, blendCtrlTFB)]) cmds.formLayout(FL, e=True, af=[(blendAttrTFG, 'left', 5), (blendAttrTFG, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(methodOMG, 'top', 5, blendAttrTFG)]) cmds.formLayout(FL, e=True, af=[(methodOMG, 'left', 5), (methodOMG, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(paramFrameL, 'top', 5, methodOMG), (paramFrameL, 'bottom', 5, createB)]) cmds.formLayout(FL, e=True, af=[(paramFrameL, 'left', 5), (paramFrameL, 'right', 5)]) cmds.formLayout(FL, e=True, af=[(createB, 'left', 5), (createB, 'bottom', 5)]) cmds.formLayout(FL, e=True, ap=[(createB, 'right', 5, 50)]) cmds.formLayout(FL, e=True, af=[(cancelB, 'right', 5), (cancelB, 'bottom', 5)]) cmds.formLayout(FL, e=True, ap=[(cancelB, 'left', 5, 50)]) # Form Layout - Parametric cmds.formLayout(paramFormL, e=True, af=[(minPercentFSG, 'top', 5), (minPercentFSG, 'left', 5), (minPercentFSG, 'right', 5)]) cmds.formLayout(paramFormL, e=True, ac=[(maxPercentFSG, 'top', 5, minPercentFSG)]) cmds.formLayout(paramFormL, e=True, af=[(maxPercentFSG, 'left', 5), (maxPercentFSG, 'right', 5)]) cmds.formLayout(paramFormL, e=True, ac=[(closestPointCBG, 'top', 5, maxPercentFSG)]) cmds.formLayout(paramFormL, e=True, af=[(closestPointCBG, 'left', 5), (closestPointCBG, 'right', 5)]) # Show Window cmds.showWindow(window)
def lightingFunction(): global lightSeparator lightGroup1 = cmds.radioButtonGrp("lightButGrp1", numberOfRadioButtons=3, label='Lighting (60%)', labelArray3=['A+ -A', 'B+ -B', 'C+ -C'], onCommand=lightingButton1) lightGroup2 = cmds.radioButtonGrp("lightButGrp2", numberOfRadioButtons=2, shareCollection=lightGroup1, label='', labelArray2=['D', 'F'], onCommand=lightingButton2) cmds.formLayout(gradeFrm, edit=1, attachForm=[[lightGroup1, "top", 5], [lightGroup1, "left", 5]]) cmds.formLayout(gradeFrm, edit=1, attachForm=[ lightGroup2, "left", 5, ], attachControl=[lightGroup2, "top", 5, lightGroup1]) lightShapeField = cmds.intFieldGrp("lightIntField", numberOfFields=1, label='Grade', changeCommand=updateGradeTotal) lightTextScrollList = cmds.scrollField("lightTSList", w=200, h=150, wordWrap=1) lightCommentsLabel = cmds.text(label='Comments') cmds.formLayout(gradeFrm, edit=1, attachForm=[lightShapeField, "top", 5], attachControl=[lightShapeField, "top", 10, lightGroup2]) cmds.formLayout( gradeFrm, edit=1, attachForm=[lightTextScrollList, "left", 140], attachControl=[lightTextScrollList, "top", 10, lightShapeField]) cmds.formLayout( gradeFrm, edit=1, attachForm=[lightCommentsLabel, "left", 60], attachControl=[lightCommentsLabel, "top", 10, lightShapeField]) lightSeparator = cmds.separator(height=15, width=460, style='in') cmds.formLayout( gradeFrm, edit=1, attachForm=[lightSeparator, "left", 5], attachControl=[lightSeparator, "top", 5, lightTextScrollList])
def compFocalLength(): global cflSeparator cflGroup1 = cmds.radioButtonGrp("cflButGrp1", numberOfRadioButtons=3, label='Comp/Focal Length (15%)', labelArray3=['A+ -A', 'B+ -B', 'C+ -C'], onCommand=compFocalButton1) cflGroup2 = cmds.radioButtonGrp("cflButGrp2", numberOfRadioButtons=2, shareCollection=cflGroup1, label='', labelArray2=['D', 'F'], onCommand=compFocalButton2) cmds.formLayout(gradeFrm, edit=1, attachForm=[cflGroup1, "left", 5], attachControl=[cflGroup1, "top", 5, lightSeparator]) cmds.formLayout(gradeFrm, edit=1, attachForm=[ cflGroup2, "left", 5, ], attachControl=[cflGroup2, "top", 5, cflGroup1]) cflShapeField = cmds.intFieldGrp("cflIntField", numberOfFields=1, label='Grade', changeCommand=updateGradeTotal) cflTextScrollList = cmds.scrollField("cflTSList", w=200, h=150, wordWrap=1) cflCommentsLabel = cmds.text(label='Comments') cmds.formLayout(gradeFrm, edit=1, attachForm=[cflShapeField, "top", 5], attachControl=[cflShapeField, "top", 10, cflGroup2]) cmds.formLayout( gradeFrm, edit=1, attachForm=[cflTextScrollList, "left", 140], attachControl=[cflTextScrollList, "top", 10, cflShapeField]) cmds.formLayout(gradeFrm, edit=1, attachForm=[cflCommentsLabel, "left", 60], attachControl=[cflCommentsLabel, "top", 10, cflShapeField]) cflSeparator = cmds.separator(height=15, width=460, style='in') cmds.formLayout(gradeFrm, edit=1, attachForm=[cflSeparator, "left", 5], attachControl=[cflSeparator, "top", 5, cflTextScrollList])
def gradeTotalsFrame(): cmds.frameLayout(label='Grade Totals', cll=True, labelAlign='center', borderStyle='etchedIn', w=480) cmds.columnLayout() gradeFrm = cmds.formLayout() global gradeTotal global cflDeductGradeTotal global aanDeductGradeTotal global proDeductGradeTotal global lateGradeTotal global totalGradeTotal # Create the Output Grades and Comments to Text File button textOutputButton = cmds.button( label='Output Grades and Comments to Text File', align='center', command=textOutputButtonFunction) cmds.formLayout(gradeFrm, edit=1, attachForm=[[textOutputButton, "left", 5], [textOutputButton, "top", 5]]) # Create the Art Grade Total label and intField gradeGradeField = cmds.intFieldGrp("gradeIntField", numberOfFields=1, label='Grade Total', changeCommand=updateGradeTotal) cmds.formLayout( gradeFrm, edit=1, attachOppositeControl=[[gradeGradeField, "top", 35, textOutputButton], [gradeGradeField, "left", 0, textOutputButton]]) # Create the Comp/Focal Length Deductions Grade Total label and intField cflDeductGradeField = cmds.intFieldGrp("cflDeductGradeIntField", numberOfFields=1, label='Comp/Focal Len Deductions', changeCommand=updateGradeTotal) cmds.formLayout(gradeFrm, edit=1, attachOppositeControl=[[ cflDeductGradeField, "top", 35, gradeGradeField ], [cflDeductGradeField, "left", 0, gradeGradeField]]) # Create the Antialias/Noise Deductions Grade Total label and intField aanDeductGradeField = cmds.intFieldGrp("aanDeductGradeIntField", numberOfFields=1, label='Alias/Noise Deductions', changeCommand=updateGradeTotal) cmds.formLayout(gradeFrm, edit=1, attachOppositeControl=[[ aanDeductGradeField, "top", 35, cflDeductGradeField ], [aanDeductGradeField, "left", 0, cflDeductGradeField]]) # Create the Professionalism Deductions Grade Total label and intField proDeductGradeField = cmds.intFieldGrp("proDeductGradeIntField", numberOfFields=1, label='Prof Deductions', changeCommand=updateGradeTotal) cmds.formLayout(gradeFrm, edit=1, attachOppositeControl=[[ proDeductGradeField, "top", 35, aanDeductGradeField ], [proDeductGradeField, "left", 0, aanDeductGradeField]]) # Create the Late Deductions Grade Total label and intField lateGradeField = cmds.intFieldGrp("lateGradeIntField", numberOfFields=1, label='Late Deductions', changeCommand=updateGradeTotal) cmds.formLayout(gradeFrm, edit=1, attachOppositeControl=[[ lateGradeField, "top", 35, proDeductGradeField ], [lateGradeField, "left", 0, proDeductGradeField]]) # Create the Overall Grade Total label and intField totalGradeField = cmds.intFieldGrp("totalGradeIntField", numberOfFields=1, label='Grade Total') cmds.formLayout( gradeFrm, edit=1, attachOppositeControl=[[totalGradeField, "top", 35, lateGradeField], [totalGradeField, "left", 0, lateGradeField]]) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..')
def append_session_commment(self): self.log('append session comment stuff') def close_command(*args): self.log('close command') # maya.utils.executeDeferred("cmds.deleteUI('ASCW')") def get_comment(*args): self.log('get comment') title = cmds.textField(comment_title, query=True, text=True) comment = cmds.scrollField(comment_text, query=True, text=True) self.log('\nTitle: {}\nComment: {}'.format(title, comment)) if title != 'Comment Title' and comment != 'Type your comment text here...': cmds.menuItem(parent=self.rmb_menu, label=title, command=lambda args, i=comment: self. add_comment_to_comments(i)) cmds.deleteUI('ASCW') reorder_comments() else: cmds.error( 'Type in a comment title and comment text to continue.\nClose the window to cancel.' ) self.add_comment_to_comments(comment) def reorder_comments(*args): self.log('reorder comments') comment_items = cmds.popupMenu(self.rmb_menu, query=True, itemArray=True) comment_items[-1], comment_items[-2] = comment_items[ -2], comment_items[-1] comment_labels_commands = [] for i in comment_items: l = cmds.menuItem(i, query=True, label=True) c = cmds.menuItem(i, query=True, command=True) comment_labels_commands.append((l, c)) cmds.popupMenu(self.rmb_menu, edit=True, deleteAllItems=True) for i in comment_labels_commands: cmds.menuItem(label=i[0], command=i[1], parent=self.rmb_menu) self.log('make comment window') window_widthHeight = (250, 200) padding = 2 #if ASCW window exists delete it if (cmds.window('ASCW', exists=True)): cmds.deleteUI('ASCW') comment_window = cmds.window('ASCW', title='Append Session Comment', width=window_widthHeight[0], height=window_widthHeight[1], closeCommand=close_command) comment_form = cmds.formLayout(numberOfDivisions=250) comment_title = cmds.textField(text='Comment Title') comment_text = cmds.scrollField(editable=True, wordWrap=True, text='Type your comment text here...') comment_btn = cmds.button(label='Append Comment', command=get_comment) cmds.setParent('..') cmds.formLayout(comment_form, edit=True, attachForm=[(comment_title, 'left', padding), (comment_title, 'right', padding), (comment_title, 'top', padding), (comment_text, 'left', padding), (comment_text, 'right', padding), (comment_btn, 'left', padding), (comment_btn, 'right', padding), (comment_btn, 'bottom', padding)], attachControl=[ (comment_text, 'top', padding, comment_title), (comment_text, 'bottom', padding, comment_btn) ]) cmds.showWindow(comment_window)
def installToolboxWindow(): installForm = cmds.formLayout() textLabel = cmds.text(label='Shelf') nameText = cmds.textField('nameText', width=200, tx='Custom') scriptsMenu = cmds.optionMenu('scriptsMenu') jsonPathText = cmds.textField('jsonPathText', ed=False, pht='path to json') jsonPathBtn = cmds.button('jsonPathBtn', width=50, label='...', c='browseForFile()') separator = ';' if cmds.about(nt=True) else ':' scriptsPaths = os.getenv('MAYA_SCRIPT_PATH') allparts = scriptsPaths.split(separator) for i, part in enumerate(allparts): if (i == 0): cmds.menuItem(label='Manually install scripts') if (i < 7): isSystemPath = FilterOutSystemPaths(part) if (isSystemPath == 0): cmds.menuItem(label=part) iconsMenu = cmds.optionMenu('iconsMenu') iconsPaths = os.getenv('XBMLANGPATH') iconsParts = iconsPaths.split(separator) for i, part in enumerate(iconsParts): if (i < 6): isSystemPath = FilterOutSystemPaths(part) if (isSystemPath == 0): cmds.menuItem(label=part) progressControl = cmds.progressBar('progressControl', maxValue=10, vis=False, width=250) btn1 = cmds.button(height=50, label='Install', c='CheckText()') btn2 = cmds.button(height=50, label='Close', c='cmds.deleteUI(\'Install Toolbox\')') listLayout = cmds.columnLayout('listLayout', adjustableColumn=True) try: dirname = os.path.dirname(__file__) except: print 'running in test environment' dirname = 'C:/Users/Admin/Documents/Toolbox' JSONPath = dirname + '/toolboxShelf.json' try: data = json.load(open(JSONPath), object_pairs_hook=OrderedDict) cmds.textField('jsonPathText', e=True, text=JSONPath) for k in data: cb = cmds.checkBox(h=20, label=k, v=1) try: if data[k]["checkStatus"] == 0: cmds.checkBox(cb, e=True, v=0) if data[k]["checkStatus"] == 2: cmds.checkBox(cb, e=True, v=1, ed=0) except: pass except: pass cmds.formLayout(installForm, edit=True, attachForm=[(textLabel, 'top', 15), (textLabel, 'left', 10), (nameText, 'top', 10), (nameText, 'right', 10), (scriptsMenu, 'right', 10), (iconsMenu, 'right', 10), (jsonPathBtn, 'right', 10), (progressControl, 'left', 10), (progressControl, 'right', 10), (btn1, 'bottom', 0), (btn1, 'left', 0), (btn2, 'bottom', 0), (btn2, 'right', 0)], attachControl=[(nameText, 'left', 10, textLabel), (scriptsMenu, 'top', 10, textLabel), (scriptsMenu, 'left', 10, textLabel), (iconsMenu, 'top', 10, scriptsMenu), (iconsMenu, 'left', 10, textLabel), (jsonPathText, 'top', 10, iconsMenu), (jsonPathBtn, 'top', 10, iconsMenu), (jsonPathText, 'left', 10, textLabel), (jsonPathText, 'right', 10, jsonPathBtn), (progressControl, 'top', 20, jsonPathText), (progressControl, 'left', 10, textLabel), (listLayout, 'top', 20, jsonPathText), (listLayout, 'left', 10, textLabel), (btn2, 'left', 0, btn1)], attachPosition=[(btn1, 'right', 0, 50)]) shelfName = '' #get current tab names = cmds.layout('ShelfLayout', q=True, ca=True) shelfIndex = cmds.shelfTabLayout('ShelfLayout', query=True, selectTabIndex=True) #set text selectionString = (names[shelfIndex - 1]) cmds.textField(nameText, edit=True, tx=selectionString)
def ikHandleUI(): """ UI for ikHandle() """ # Window window = 'ikHandleUI' if cmds.window(window, q=True, ex=1): cmds.deleteUI(window) window = cmds.window(window, t='Create IK Handle') # Layout FL = cmds.formLayout() # UI Elements # --- # Joints sJointTFB = cmds.textFieldButtonGrp('ikHandleStartJointTFB', label='Start Joint', text='', buttonLabel='Load Selected') eJointTFB = cmds.textFieldButtonGrp('ikHandleEndJointTFB', label='End Joint', text='', buttonLabel='Load Selected') # Prefix prefixTFG = cmds.textFieldGrp('ikHandlePrefixTFG', label='Prefix', text='') # IK Solver solverList = ['ikSplineSolver', 'ikSCsolver', 'ikRPsolver', 'ik2Bsolver'] solverOMG = cmds.optionMenuGrp('ikHandleSolverOMG', label='IK Solver') for solver in solverList: cmds.menuItem(label=solver) cmds.optionMenuGrp(solverOMG, e=True, sl=3) # Spline IK splineFrameL = cmds.frameLayout('ikHandleSplineFL', l='Spline IK Options', cll=0, en=0) splineFormL = cmds.formLayout(numberOfDivisions=100) # Curve curveTFB = cmds.textFieldButtonGrp('ikHandleCurveTFB', label='Curve', text='', buttonLabel='Load Selected', en=0) offsetFSG = cmds.floatSliderGrp('ikHandleOffsetFSG', label='Offset', field=True, minValue=0.0, maxValue=1.0, fieldMinValue=0.0, fieldMaxValue=1.0, value=0, en=0) cmds.setParent('..') cmds.setParent('..') # Buttons createB = cmds.button('ikHandleCreateB', l='Create', c='glTools.ui.ik.ikHandleFromUI(False)') cancelB = cmds.button('ikHandleCancelB', l='Cancel', c='cmds.deleteUI("' + window + '")') # UI callback commands cmds.optionMenuGrp(solverOMG, e=True, cc='cmds.frameLayout("' + splineFrameL + '",e=True,en=not(cmds.optionMenuGrp("' + solverOMG + '",q=True,sl=True)-1))') cmds.textFieldButtonGrp(sJointTFB, e=True, bc='glTools.ui.ik.ikHandleUI_autoComplete("' + sJointTFB + '","' + eJointTFB + '","' + prefixTFG + '")') cmds.textFieldButtonGrp(eJointTFB, e=True, bc='glTools.ui.utils.loadTypeSel("' + eJointTFB + '",selType="joint")') cmds.textFieldButtonGrp(curveTFB, e=True, bc='glTools.ui.utils.loadCurveSel("' + curveTFB + '")') # Form Layout - MAIN cmds.formLayout(FL, e=True, af=[(sJointTFB, 'top', 5), (sJointTFB, 'left', 5), (sJointTFB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(eJointTFB, 'top', 5, sJointTFB)]) cmds.formLayout(FL, e=True, af=[(eJointTFB, 'left', 5), (eJointTFB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(prefixTFG, 'top', 5, eJointTFB)]) cmds.formLayout(FL, e=True, af=[(prefixTFG, 'left', 5), (prefixTFG, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(solverOMG, 'top', 5, prefixTFG)]) cmds.formLayout(FL, e=True, af=[(solverOMG, 'left', 5), (solverOMG, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(splineFrameL, 'top', 5, solverOMG)]) cmds.formLayout(FL, e=True, af=[(splineFrameL, 'left', 5), (splineFrameL, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(splineFrameL, 'bottom', 5, createB)]) cmds.formLayout(FL, e=True, af=[(createB, 'left', 5), (createB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(createB, 'bottom', 5, cancelB)]) cmds.formLayout(FL, e=True, af=[(cancelB, 'left', 5), (cancelB, 'right', 5), (cancelB, 'bottom', 5)]) # Form Layout - Spline cmds.formLayout(splineFormL, e=True, af=[(curveTFB, 'top', 5), (curveTFB, 'left', 5), (curveTFB, 'right', 5)]) cmds.formLayout(splineFormL, e=True, ac=[(offsetFSG, 'top', 5, curveTFB)]) cmds.formLayout(splineFormL, e=True, af=[(offsetFSG, 'left', 5), (offsetFSG, 'right', 5)]) # Show Window cmds.showWindow(window)
def professionalism(): global proSeparator proGroup1 = cmds.radioButtonGrp("proButGrp1", numberOfRadioButtons=3, label='Professionalism (10%)', labelArray3=['A+ -A', 'B+ -B', 'C+ -C'], onCommand=proButton1) proGroup2 = cmds.radioButtonGrp("proButGrp2", numberOfRadioButtons=2, shareCollection=proGroup1, label='', labelArray2=['D', 'F'], onCommand=proButton2) cmds.formLayout(gradeFrm, edit=1, attachForm=[proGroup1, "left", 5], attachControl=[proGroup1, "top", 5, aanqSeparator]) cmds.formLayout(gradeFrm, edit=1, attachForm=[ proGroup2, "left", 5, ], attachControl=[proGroup2, "top", 5, proGroup1]) proShapeField = cmds.intFieldGrp("proIntField", numberOfFields=1, label='Grade', changeCommand=updateGradeTotal) proTextScrollList = cmds.scrollField("proTSList", w=200, h=150, wordWrap=1) proCommentsLabel = cmds.text(label='Comments') cmds.formLayout(gradeFrm, edit=1, attachForm=[proShapeField, "top", 5], attachControl=[proShapeField, "top", 10, proGroup2]) cmds.formLayout( gradeFrm, edit=1, attachForm=[proTextScrollList, "left", 140], attachControl=[proTextScrollList, "top", 10, proShapeField]) cmds.formLayout(gradeFrm, edit=1, attachForm=[proCommentsLabel, "left", 60], attachControl=[proCommentsLabel, "top", 10, proShapeField]) proSeparator = cmds.separator(height=15, width=460, style='in') cmds.formLayout(gradeFrm, edit=1, attachForm=[proSeparator, "left", 5], attachControl=[proSeparator, "top", 5, proTextScrollList]) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..')
def stretchyIkLimbUI(): """ UI for stretchyIkLimb() """ # Window window = 'stretchyIkLimbUI' if cmds.window(window, q=True, ex=1): cmds.deleteUI(window) window = cmds.window(window, t='Stretchy IK Limb') # Layout FL = cmds.formLayout() # UI Elements # --- # IK Handle handleTFB = cmds.textFieldButtonGrp('stretchyIkLimbTFB', label='IK Handle', text='', buttonLabel='Load Selected') # Prefix prefixTFG = cmds.textFieldGrp('stretchyIkLimbPrefixTFG', label='Prefix', text='') # Control controlTFB = cmds.textFieldButtonGrp('stretchyIkLimbControlTFB', label='Control Object', text='', buttonLabel='Load Selected') # Scale Axis axisList = ['X', 'Y', 'Z'] scaleAxisOMG = cmds.optionMenuGrp('stretchyIkLimbAxisOMG', label='Joint Scale Axis') for axis in axisList: cmds.menuItem(label=axis) cmds.optionMenuGrp(scaleAxisOMG, e=True, sl=1) # Scale Attr scaleAttrTFB = cmds.textFieldButtonGrp('stretchyIkLimbScaleAttrTFB', label='Scale Attribute', text='', buttonLabel='Load Selected') # Separator SEP = cmds.separator(height=10, style='single') # Buttons createB = cmds.button('stretchyIkLimbCreateB', l='Create', c='glTools.ui.ik.stretchyIkLimbFromUI(False)') cancelB = cmds.button('stretchyIkLimbCancelB', l='Cancel', c='cmds.deleteUI("' + window + '")') # UI callback commands cmds.textFieldButtonGrp(handleTFB, e=True, bc='glTools.ui.utils.loadTypeSel("' + handleTFB + '","' + prefixTFG + '",selType="ikHandle")') cmds.textFieldButtonGrp(controlTFB, e=True, bc='glTools.ui.utils.loadObjectSel("' + controlTFB + '")') cmds.textFieldButtonGrp(scaleAttrTFB, e=True, bc='glTools.ui.utils.loadChannelBoxSel("' + scaleAttrTFB + '")') # Form Layout - MAIN cmds.formLayout(FL, e=True, af=[(handleTFB, 'top', 5), (handleTFB, 'left', 5), (handleTFB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(prefixTFG, 'top', 5, handleTFB)]) cmds.formLayout(FL, e=True, af=[(prefixTFG, 'left', 5), (prefixTFG, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(controlTFB, 'top', 5, prefixTFG)]) cmds.formLayout(FL, e=True, af=[(controlTFB, 'left', 5), (controlTFB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(scaleAxisOMG, 'top', 5, controlTFB)]) cmds.formLayout(FL, e=True, af=[(scaleAxisOMG, 'left', 5), (scaleAxisOMG, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(scaleAttrTFB, 'top', 5, scaleAxisOMG)]) cmds.formLayout(FL, e=True, af=[(scaleAttrTFB, 'left', 5), (scaleAttrTFB, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(SEP, 'top', 5, scaleAttrTFB)]) cmds.formLayout(FL, e=True, af=[(SEP, 'left', 5), (SEP, 'right', 5)]) cmds.formLayout(FL, e=True, ac=[(createB, 'top', 5, SEP)]) cmds.formLayout(FL, e=True, af=[(createB, 'left', 5), (createB, 'bottom', 5)]) cmds.formLayout(FL, e=True, ap=[(createB, 'right', 5, 50)]) cmds.formLayout(FL, e=True, ac=[(cancelB, 'top', 5, SEP)]) cmds.formLayout(FL, e=True, af=[(cancelB, 'right', 5), (cancelB, 'bottom', 5)]) cmds.formLayout(FL, e=True, ap=[(cancelB, 'left', 5, 50)]) # Show Window cmds.showWindow(window)
def maya2nuke(): window = "maya2nuke" if cmds.window(window, ex=1): cmds.deleteUI(window) cmds.window(window, menuBar=1) cmds.menu(tearOff=1, l='Edit') cmds.menuItem(l='Calculate Maya Data', c=getAllCamera) cmds.menuItem(divider=1) cmds.menuItem(l='Generator Nuke Script', c=generator) cmds.menuItem(l='Show Nuke Script', c=m2nShowText) cmds.menuItem(l='Save Nuke Script As', c=saveNukeScript) cmds.menuItem(divider=1) cmds.menuItem(l='Rest Setings', c=restSetings) cmds.menuItem(l='Exit', c='cmds.deleteUI("maya2nuke")') cmds.menu(tearOff=1, l='Type') cmds.menuItem('typeAll', l='All', checkBox=1, c=adjOption) cmds.menuItem(divider=1) cmds.menuItem('typeCamera', l='Camera', checkBox=1, c=setOption) cmds.menuItem('typeMesh', l='Mesh', checkBox=1, c=setOption) cmds.menu(tearOff=1, l='Animation') cmds.menuItem('animAll', l='All', checkBox=1, c=adjOption) cmds.menuItem(divider=1) cmds.menuItem('animCamera', l='Camera', checkBox=1, c=setOption) cmds.menuItem('animMesh', l='Mesh', checkBox=0, c=setOption) cmds.menu(tearOff=1, l='Networks') cmds.radioMenuItemCollection() cmds.menuItem('netNone', l='None', radioButton=0, c=setOption) cmds.menuItem('netBace', l='Bace', radioButton=1, c=setOption) cmds.menuItem('netContactSheet', l='ContactSheet', radioButton=0, c=setOption) cmds.menu(l='Help') cmds.menuItem(l='Help', c='m2nShowText("help")') cmds.menuItem(l='About', c=aboutThis) mianLayout = cmds.formLayout(nd=1000) b1 = cmds.outlinerEditor('dirList') cmds.outlinerEditor( 'dirList', e=1, mainListConnection="worldList", selectionConnection="modelList", showShapes=0, showAttributes=0, showConnected=0, showAnimCurvesOnly=0, autoExpand=0, showDagOnly=1, ignoreDagHierarchy=0, expandConnections=0, showNamespace=1, showCompounds=1, showNumericAttrsOnly=0, highlightActive=1, autoSelectNewObjects=0, doNotSelectNewObjects=0, transmitFilters=0, showSetMembers=1, ## setFilter="DefaultAllLightsFilter" ) cmds.cmdScrollFieldExecuter('copytext', vis=0) b2 = cmds.textField('filterText', cc=setFilterName, ec=setFilterName) b3 = cmds.button(l="Generator", c=generator) cmds.formLayout(mianLayout, e=1, attachControl=[(b1, "top", 3, b2), (b1, "bottom", 3, b3)], attachForm=[ (b1, "left", 3), (b1, "right", 3), (b2, "top", 3), (b2, "left", 3), (b2, "right", 3), (b3, "bottom", 3), (b3, "left", 3), (b3, "right", 3), ], attachNone=[(b2, "bottom"), (b3, "top")]) cmds.window(window, e=1, t="maya2nuke", widthHeight=(300, 700)) cmds.showWindow(window) getOption()
def quick_connection(): if cmds.window('QuickConnction', exists=True ): cmds.deleteUI( 'QuickConnction', window=True) if cmds.windowPref('QuickConnction', exists=True ): cmds.windowPref( 'QuickConnction', r=True ) cmds.window('QuickConnction', title='Quick Connection', iconName='Short Name', widthHeight=(336,260),s=0 ) form = cmds.formLayout(numberOfDivisions=100,bgc =[(.284),(.284),(.284)],w=336,h=260) driver = cmds.textField('drivertxf',w=150,h=40) driven = cmds.textScrollList('asd',h=40,w=150) driverButton = cmds.button(l='Driver',w=150,h=35,bgc =[(.394),(.394),(.394)],c='createDriver()') drivenButton = cmds.button(l='Driven',w=150,h=35,bgc =[(.394),(.394),(.394)],c='createDriven()') connectRotate = cmds.button(l='Connect Rotate',w=310,bgc =[(.2),(.5),(.4)],h=25,c='create_rotate_connection()') connectTranslate = cmds.button(l='Connect Translate',w=310,bgc =[(.2),(.5),(.4)],h=25,c='create_translate_connection()') connectScale = cmds.button(l='Connect Scale',w=310,bgc =[(.2),(.5),(.4)],h=25,c='create_scale_connection()') author = cmds.symbolButton(i='UV_Freeze_Tool.png',c='author()') deleteButton=cmds.button(l='Delete Connections',w=310,h=25,bgc =[(0.4),(0.5),(2)],c='delete_connections()') cmds.formLayout(form,edit=True,attachForm=[ (driver,'top',17), (driven,'top',17), (driverButton,'top',65), (drivenButton,'top',65), (author,'bottom',2), (driver,'left',12), (driven,'left',12), (driverButton,'left',12), (drivenButton,'left',12), (connectRotate,'left',12), (connectTranslate,'left',12), (connectScale,'left',12), (deleteButton,'left',12), (author,'left',151) ], attachControl=[ (driven, 'left', 10, driver), (driverButton, 'bottom', 20, driver), (drivenButton, 'left', 10, driverButton), (connectTranslate,'top',7,connectRotate), (connectScale,'top',7, connectTranslate), (connectRotate,'top',14,driverButton), (deleteButton,'top',7,connectScale) ] ) cmds.showWindow('QuickConnction')
def _refrTimeForm(obj): '''Aggiorna il form della timeline window.''' timeForm = obj + _timeFormSfx min = cmds.playbackOptions(q=True, min=True) max = cmds.playbackOptions(q=True, max=True) rng = max - min + 1.0 currentFrame = cmds.currentTime(q=True) # rimuovi gli elementi del time form children = cmds.formLayout(timeForm, q=True, ca=True) if children: cmds.deleteUI(children) # rintraccia il nodo di parent pcNode = cmds.ls(_getParentConstraint(obj)) if pcNode: pcNode = pcNode[0] else: # aggiorna le label cmds.text(obj + _labelSfx[0], e=True, l='%d' % currentFrame, w=50) cmds.text(obj + _labelSfx[1], e=True, l='') return # il main form e' il parent cmds.setParent(timeForm) # parametri per l'edit del form attachPositions = [] attachForms = [] # lista dei target targets = cmds.parentConstraint(pcNode, q=True, tl=True) for tid in range(len(targets)): times = cmds.keyframe('%s.w%d' % (pcNode, tid), q=True, tc=True) values = cmds.keyframe('%s.w%d' % (pcNode, tid), q=True, vc=True) # nessuna chiave, lista nulla e passa al successivo if not times: continue # indici dei tempi delle chiavi di attach/detach idxList = [] check = True for v in range(len(values)): if values[v] == check: idxList.append(v) check = not check # deve funzionare anche se l'ultima chiave e' attached (quindi numero chiavi dispari) times.append(cmds.playbackOptions(q=True, aet=True) + 1.0) # ogni elemento di attach times e' relativo ad un particolare target ed e' una lista di questo tipo [[3,10], [12, 20]] timeRanges = [ times[idxList[i]:idxList[i] + 2] for i in range(0, len(idxList), 2) ] hsvCol = _getColor(tid) # aggiungi i nuovi controlli for timeRange in timeRanges: # normalizza il timeRange normRange = [ _timeFormDiv * (_crop(tr, min, max + 1) - min) / rng for tr in timeRange ] # se l'elemento e' stato croppato dal timerange passa al successivo if normRange[0] == normRange[1]: continue control = cmds.canvas( hsvValue=hsvCol, w=1, h=1, ann='%s [%d, %d]' % (targets[tid], timeRange[0], timeRange[1] - 1.0)) for button in [1, 3]: cmds.popupMenu(mm=True, b=button) cmds.menuItem(l='[%s]' % targets[tid], c='cmds.select(\'%s\')' % targets[tid], rp='N') cmds.menuItem(l='Select child', c='cmds.select(\'%s\')' % obj, rp='S') cmds.menuItem(l='Fix snaps', c='cmds.select(\'%s\')\n%s.fixSnap(True)' % (obj, __name__), rp='E') attachForms.extend([(control, 'top', 0), (control, 'bottom', 0)]) attachPositions.extend([(control, 'left', 0, normRange[0]), (control, 'right', 0, normRange[1])]) # current frame if currentFrame >= min and currentFrame <= max: frameSize = _timeFormDiv / rng normCf = frameSize * (currentFrame - min) currentTarget = _getActiveAttachTarget(pcNode) if not currentTarget: hsvCol = (0.0, 0.0, 0.85) else: hsvCol = _getColor(targets.index(currentTarget), 0.15) cf = cmds.canvas(hsvValue=hsvCol, w=1, h=1) attachForms.extend([(cf, 'top', 0), (cf, 'bottom', 0)]) attachPositions.extend([(cf, 'left', 0, normCf), (cf, 'right', 0, normCf + frameSize)]) # setta i parametri del form cmds.formLayout(timeForm, e=True, attachForm=attachForms, attachPosition=attachPositions) # aggiorna le label cmds.text(obj + _labelSfx[0], e=True, l='%d' % currentFrame, w=50) cmds.text(obj + _labelSfx[1], e=True, l='[%s]' % _getActiveAttachTarget(pcNode))
def about(self, warnUpdate=None, *args): winName = "aboutWindow" title = "About" if not warnUpdate else "aTools has been updated!" if cmds.window(winName, query=True, exists=True): cmds.deleteUI(winName) window = cmds.window( winName, title=title) form = cmds.formLayout(numberOfDivisions=100) pos = 10 minWidth = 300.0 # Creating Elements object = cmds.image(image= uiMod.getImagePath("aTools_big")) cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos), ( object, 'left', 10)] ) object = cmds.text( label="aTools - Version %s"%VERSION, font="boldLabelFont") cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos), ( object, 'left', 80)] ) #========================================= pos += 30 object = cmds.text( label="More info:") cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos), ( object, 'left', 80)] ) #========================================= object = cmds.text( label="<a href=\"%s\">aTools website</a>"%SITE_URL, hyperlink=True) cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos), ( object, 'left', 205)] ) #========================================= pos += 15 object = cmds.text( label="Author: Alan Camilo") cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos), ( object, 'left', 80)] ) #========================================= object = cmds.text( label="<a href=\"http://www.alancamilo.com/\">www.alancamilo.com</a>", hyperlink=True) cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos), ( object, 'left', 205)] ) #========================================= minWidth = 550.0 w = 210 object = cmds.text( label="Do you like aTools?", w=w) cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos-50), ( object, 'right', 10)] ) #========================================= object = cmds.iconTextButton(label="Buy Me a Beer!", style="iconAndTextVertical", bgc=(.3,.3,.3), h=45, w=w, command=lambda *args: webbrowser.open_new_tab(DONATE_URL), image= uiMod.getImagePath("beer"), highlightImage= uiMod.getImagePath("beer copy")) cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos-30), ( object, 'right', 10)] ) object = cmds.text( label="I really appreciate\nthe support!", w=w) cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos+20), ( object, 'right', 10)] ) if warnUpdate: pos += 40 object = cmds.text( label="aTools has been updated to version %s. What is new?"%VERSION, align="left") cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos), ( object, 'left', 10)] ) pos -= 20 #========================================= pos += 40 object = cmds.text( label=WHATISNEW, align="left") cmds.formLayout( form, edit=True, attachForm=[( object, 'top', pos), ( object, 'left', 10)] ) #========================================= for x in xrange(WHATISNEW.count("\n")): pos += 13 pos += 25 cmds.setParent( '..' ) cmds.showWindow( window ) whatsNewWidth = cmds.text(object, query=True, width=True) + 15 wid = whatsNewWidth if whatsNewWidth > minWidth else minWidth cmds.window( winName, edit=True, widthHeight=(wid, pos))
fieldMaxValue=600.00, value=0) extraBendLinksVar = cmds.floatSliderGrp(label='Extra Bend Links', cw3=(100, 50, 50), field=True, minValue=-10.00, maxValue=10.00, fieldMinValue=-10, fieldMaxValue=10.00, value=0) cmds.setParent('..') #the stiffness scale frame layout with its settings and graph cmds.frameLayout(label='Stiffness Scale', cll=True, po=True, width=350) #going to need layouts on these graphed frame layouts stiffnessForm = cmds.formLayout(numberOfDivisions=50) stiffColumn = cmds.columnLayout(columnAttach=('both', 5), rowSpacing=1, columnWidth=175, cal='left') #adding the float fields and drop down blend mode stiffnessPosVar = cmds.floatFieldGrp(numberOfFields=1, label='Selected Position', value1=0.0, columnWidth=([1, 100], [2, 50])) sitffnessValVar = cmds.floatFieldGrp(numberOfFields=1, label='Selected value', value1=0.0, columnWidth=([1, 100], [2, 50])) stiffInterp = cmds.optionMenu(label='Interpolation', w=75) cmds.menuItem(label='None')
def __init__(self): self.WINDOW_NAME = env.DAZ_TO_UE4_NAMESPACE self.WINDOW_TITLE = "DAZ to UE4 Tools" self.WINDOW_SIZE = (260, 700) if cmds.window(self.WINDOW_NAME, exists=True): cmds.deleteUI(self.WINDOW_NAME) self.WINDOW_NAME = cmds.window(self.WINDOW_NAME, title=self.WINDOW_TITLE, widthHeight=self.WINDOW_SIZE, maximizeButton=False) self.mainForm = cmds.formLayout(nd=100) self.mainColumn = cmds.columnLayout(rowSpacing=10, adjustableColumn=True) cmds.formLayout(self.mainForm, edit=True, attachForm=([self.mainColumn, 'left', 10], [self.mainColumn, 'right', 10], [self.mainColumn, 'top', 10])) with uiExt.FrameLayout(label='Skeletal mesh', collapsable=True, collapse=False, marginHeight=8, marginWidth=8): with uiExt.FrameLayout(labelVisible=False, borderVisible=True, marginHeight=4, marginWidth=4): with uiExt.ColumnLayout(rowSpacing=5, adjustableColumn=True): self.btnOptimizeSkeleton = cmds.button( label="Optimize Skeleton and Mesh", command=self.OptimizeSkeleton) self.chkbxLoadExtBaseMesh = uiExt.SaveableCheckBox( label='Load External BaseMesh', align='left', value=True) self.chkbxLoadExtMorphs = uiExt.SaveableCheckBox( label='Load External Morphs', align='left', value=True) self.chkbxLoadExtUVs = uiExt.SaveableCheckBox( label='Load External UVs', align='left', value=True) self.chkbxCreateIKConstraints = uiExt.SaveableCheckBox( label='Create IK Constraints', align='left', value=False) self.chkbxCollapseToes = uiExt.SaveableCheckBox( label='Collapse Toes', align='left', value=False) with uiExt.FrameLayout(labelVisible=False, borderVisible=True, marginHeight=4, marginWidth=4): with uiExt.ColumnLayout(rowSpacing=5, adjustableColumn=True): self.btnRetargetAnim = cmds.button( label="Create Skeleton and Retarget Anim", command=self.CreateOptimizedSkeletonOnlyAndRetargetAnim ) self.chkbxFilterCurves = cmds.checkBox( label='Filter Curves', align='left', value=True) with uiExt.FrameLayout(label='Joints Selection Utils', collapsable=True, collapse=False, marginHeight=8, marginWidth=8): with uiExt.ColumnLayout(rowSpacing=5, adjustableColumn=True): cmds.button(label="Select Face Rig", enableBackground=False, command=self.SelectFaceRig) cmds.button(label="Select Body Anim Relevant Joints", command=self.SelectBodyAnimRelevantJoints) with uiExt.FrameLayout(labelVisible=False, borderVisible=True, marginHeight=4, marginWidth=4): with uiExt.ColumnLayout(rowSpacing=5, adjustableColumn=True): cmds.button(label="Select Joints for Selected Meshes", command=self.SelectJointsForSelectedMeshes) self.chkbxKeepSelection = cmds.checkBox( label='Keep Selection', align='left', value=True) self.chkbxIncludeSpecialJoints = cmds.checkBox( label='Include Special Joints', align='left', value=True) self.chkbxIncludeIKjoints = cmds.checkBox( label='Include IK Joints', align='left', value=True) with uiExt.FrameLayout(label='Batch processing', collapsable=True, collapse=False, marginHeight=8, marginWidth=8): with uiExt.FrameLayout(labelVisible=False, borderVisible=True, marginHeight=4, marginWidth=4): with uiExt.ColumnLayout(rowSpacing=5, adjustableColumn=True): batchProcessingDir = env.GetRootDir(pCanBeEmpty=True) self.batchPathGrp = cmds.textFieldButtonGrp(label='Path', fileName=batchProcessingDir, buttonLabel='...',\ columnWidth3=(25, 0, 20), adjustableColumn3=2, editable=False, buttonCommand=self.BrowseBatchDir) self.chkbxForceFullRebuild = uiExt.SaveableCheckBox( label='Force Full Rebuild', align='left', value=False) self.btnPreProcessMorphsDir = cmds.button( label="PreProcess Morphs Dir", command=self.PreProcessMorphsDir) self.btnFullBatchProcessing = cmds.button( label="Full Batch Processing", command=self.DoFullBatchProcessing) with uiExt.FrameLayout(label='Mesh optimization', collapsable=True, collapse=True, marginHeight=8, marginWidth=8): with uiExt.ColumnLayout(rowSpacing=5, adjustableColumn=True): self.btnOptimizeMeshForBaking = cmds.button( label="Optimize Mesh for Baking", command=self.OptimizeMeshForBaking) self.btnTriangulateAllSkinnedMeshes = cmds.button( label="Triangulate all skinned meshes", command=self.TriangulateAllSkinnedMeshes) cmds.showWindow(self.WINDOW_NAME) cmds.window(self.WINDOW_NAME, e=True, widthHeight=self.WINDOW_SIZE)
def __init__(self, margin=5, padding=5): self.loadReferencesOnOpen = False self.items = {} self.layout = cmds.formLayout() self.menu = cmds.menuBarLayout() cmds.menu(label='File') cmds.menuItem(label='Load References On Open', checkBox=False, c=self.setloadReferencesOnOpen) cmds.menuItem(divider=True) cmds.menuItem(label='Open', c=self.open) cmds.menu(label='References') cmds.menuItem(label='Load All', c=self.loadAllReferences) cmds.menuItem(label='Unload All', c=self.unloadAllReferences) cmds.menu(label='Visibility') cmds.menuItem(label='Show All', c=lambda *x: self.toggleAssembly(True)) cmds.menuItem(label='Hide All', c=lambda *x: self.toggleAssembly(False)) # cmds.menu(label='Extras', enable=False) # cmds.menuItem(label='Show All') # cmds.menuItem(label='Hide All') cmds.menu(label='UI') cmds.menuItem(label='Refresh', c=self.load) cmds.menu(label='Help', helpMenu=True) cmds.menuItem(label='Print Debug Info', c=self.debugInfo) cmds.setParent('..') self.ui = cmds.treeView(parent=self.layout, numberOfButtons=3, abr=False, adr=False, ams=False, idc=self.doubleClickCallback, dc2=self.doubleClickCallback, pc=[ [1, self.loadReferenceCallback], [2, self.setVisibleCallback], [3, self.selectControlsCallback], ]) cmds.setParent('..') cmds.formLayout(self.layout, e=True, attachForm=(self.menu, 'top', padding)) cmds.formLayout(self.layout, e=True, attachForm=(self.menu, 'left', padding)) cmds.formLayout(self.layout, e=True, attachForm=(self.menu, 'right', padding)) cmds.formLayout(self.layout, e=True, attachControl=(self.ui, 'top', margin, self.menu)) cmds.formLayout(self.layout, e=True, attachForm=(self.ui, 'bottom', padding)) cmds.formLayout(self.layout, e=True, attachForm=(self.ui, 'left', padding)) cmds.formLayout(self.layout, e=True, attachForm=(self.ui, 'right', padding)) cmds.treeView(self.ui, edit=True, selectCommand=self.selectTreeCallBack) self.load() # ScriptJobs cmds.scriptJob(p=self.ui, event=['PostSceneRead', self.load])
def create(): ''' ''' # Window win = 'nDynamicsUI' if mc.window(win, ex=True): mc.deleteUI(win) win = mc.window(win, t='nDynamics', s=True, mb=True, wh=[650, 390]) # --------------- # - Main Window - # --------------- # Menu mc.menu(label='Edit', tearOff=1) mc.menuItem(label='Reset', c='glTools.ui.nDynamics.create()') # FormLayout FL = mc.formLayout(numberOfDivisions=100) # UI Elements nucleusTXT = mc.text(l='Nucleus List:', al='left') nucleusTSL = mc.textScrollList('nDyn_nucleusTSL', allowMultiSelection=False) nucleus_createB = mc.button(label='Create', c='glTools.ui.nDynamics.createNucleusFromUI()') nucleus_deleteB = mc.button(label='Delete', c='glTools.ui.nDynamics.deleteNucleusFromUI()') nucleus_enableB = mc.button( label='Enable', c='glTools.ui.nDynamics.toggleNucleusFromUI(1)') nucleus_disableB = mc.button( label='Disable', c='glTools.ui.nDynamics.toggleNucleusFromUI(0)') nDyn_refreshB = mc.button(label='Refresh', c='glTools.ui.nDynamics.create()') nDyn_closeB = mc.button(label='Close', c='mc.deleteUI("' + win + '")') # TabLayout nDynTabLayout = mc.tabLayout('nDynTabLayout', innerMarginWidth=5, innerMarginHeight=5) # Layout mc.formLayout(FL, e=True, af=[(nucleusTXT, 'left', 5), (nucleusTXT, 'top', 5)], ap=[(nucleusTXT, 'right', 5, 35)]) mc.formLayout(FL, e=True, af=[(nucleusTSL, 'left', 5)], ap=[(nucleusTSL, 'right', 5, 35)], ac=[(nucleusTSL, 'top', 5, nucleusTXT), (nucleusTSL, 'bottom', 5, nucleus_createB)]) mc.formLayout(FL, e=True, af=[(nucleus_createB, 'left', 5)], ap=[(nucleus_createB, 'right', 5, 18)], ac=[(nucleus_createB, 'bottom', 5, nucleus_enableB)]) mc.formLayout(FL, e=True, ac=[(nucleus_deleteB, 'left', 5, nucleus_createB), (nucleus_deleteB, 'right', 5, nDynTabLayout), (nucleus_deleteB, 'bottom', 5, nucleus_disableB)]) mc.formLayout(FL, e=True, af=[(nucleus_enableB, 'left', 5)], ap=[(nucleus_enableB, 'right', 5, 18)], ac=[(nucleus_enableB, 'bottom', 5, nDyn_refreshB)]) mc.formLayout(FL, e=True, ac=[(nucleus_disableB, 'left', 5, nucleus_enableB), (nucleus_disableB, 'right', 5, nDynTabLayout), (nucleus_disableB, 'bottom', 5, nDyn_refreshB)]) mc.formLayout(FL, e=True, af=[(nDyn_refreshB, 'left', 5), (nDyn_refreshB, 'bottom', 5)], ap=[(nDyn_refreshB, 'right', 5, 50)]) mc.formLayout(FL, e=True, af=[(nDyn_closeB, 'right', 5), (nDyn_closeB, 'bottom', 5)], ap=[(nDyn_closeB, 'left', 5, 50)]) mc.formLayout(FL, e=True, af=[(nDynTabLayout, 'top', 5), (nDynTabLayout, 'right', 5)], ac=[(nDynTabLayout, 'left', 5, nucleusTSL), (nDynTabLayout, 'bottom', 5, nDyn_closeB)]) # UI Callbacks mc.textScrollList(nucleusTSL, e=True, sc='glTools.ui.nDynamics.setCurrentNucleus()') mc.textScrollList(nucleusTSL, e=True, dcc='glTools.ui.utils.selectFromTSL("' + nucleusTSL + '")') mc.textScrollList(nucleusTSL, e=True, dkc='glTools.ui.nDynamics.deleteNucleusFromUI()') # Popup menu nClothPUM = mc.popupMenu(parent=nucleusTSL) mc.menuItem(l='Select Hilited Nodes', c='glTools.ui.utils.selectFromTSL("' + nucleusTSL + '")') mc.menuItem(l='Select Connected nCloth', c='glTools.ui.nDynamics.selectConnectedMeshFromUI("' + nucleusTSL + '")') mc.menuItem(l='Select Connected nRigid', c='glTools.ui.nDynamics.selectConnectedSolverFromUI("' + nucleusTSL + '")') # Attr Presets nucleusPresetList = glTools.utils.attrPreset.listNodePreset('nucleus') if nucleusPresetList: mc.menuItem(allowOptionBoxes=False, label='Apply Preset', subMenu=True, tearOff=False) for nucleusPreset in nucleusPresetList: mc.menuItem(l=nucleusPreset, c='glTools.ui.nDynamics.applyPreset("' + nucleusTSL + '","' + nucleusPreset + '")') # ----------------- # - nCloth Layout - # ----------------- mc.setParent(nDynTabLayout) # FormLayout nClothFL = mc.formLayout(numberOfDivisions=100) # UI Elements nClothVisRB = mc.radioButtonGrp( 'nClothVisRB', cw=[(1, 60), (2, 60), (3, 80)], label='Display:', labelArray2=['All', 'Current'], numberOfRadioButtons=2, sl=1, cc='glTools.ui.nDynamics.toggleNClothVis()') nClothTSL = mc.textScrollList('nDyn_nClothTSL', allowMultiSelection=True) nCloth_createB = mc.button(label='Create from Mesh', c='glTools.ui.nDynamics.createNClothFromUI()') nCloth_deleteB = mc.button(label='Delete Selected', c='glTools.ui.nDynamics.deleteNClothFromUI()') nCloth_addToNucleusB = mc.button( label='Assign to Nucleus', c='glTools.ui.nDynamics.addNClothToNucleusFromUI()') nCloth_enableB = mc.button( label='Enable', c='glTools.ui.nDynamics.toggleNClothStateFromUI(1)') nCloth_disableB = mc.button( label='Disable', c='glTools.ui.nDynamics.toggleNClothStateFromUI(0)') nCloth_saveCacheB = mc.button( label='Save Cache', c='glTools.ui.nDynamics.saveNClothCacheFromUI()') nCloth_loadCacheB = mc.button( label='Load Cache', c='glTools.ui.nDynamics.loadNClothCacheFromUI()') # Layout mc.formLayout(nClothFL, e=True, af=[(nClothVisRB, 'top', 5), (nClothVisRB, 'left', 5), (nClothVisRB, 'right', 5)]) mc.formLayout(nClothFL, e=True, af=[(nClothTSL, 'left', 5), (nClothTSL, 'bottom', 5)], ap=[(nClothTSL, 'right', 5, 55)], ac=[(nClothTSL, 'top', 5, nClothVisRB)]) mc.formLayout(nClothFL, e=True, af=[(nCloth_createB, 'right', 5)], ac=[(nCloth_createB, 'left', 5, nClothTSL), (nCloth_createB, 'top', 5, nClothVisRB)]) mc.formLayout(nClothFL, e=True, af=[(nCloth_deleteB, 'right', 5)], ac=[(nCloth_deleteB, 'left', 5, nClothTSL), (nCloth_deleteB, 'top', 5, nCloth_createB)]) mc.formLayout(nClothFL, e=True, af=[(nCloth_addToNucleusB, 'right', 5)], ac=[(nCloth_addToNucleusB, 'left', 5, nClothTSL), (nCloth_addToNucleusB, 'top', 5, nCloth_deleteB)]) mc.formLayout(nClothFL, e=True, af=[(nCloth_enableB, 'right', 5)], ac=[(nCloth_enableB, 'left', 5, nClothTSL), (nCloth_enableB, 'top', 5, nCloth_addToNucleusB)]) mc.formLayout(nClothFL, e=True, af=[(nCloth_disableB, 'right', 5)], ac=[(nCloth_disableB, 'left', 5, nClothTSL), (nCloth_disableB, 'top', 5, nCloth_enableB)]) mc.formLayout(nClothFL, e=True, af=[(nCloth_saveCacheB, 'right', 5)], ac=[(nCloth_saveCacheB, 'left', 5, nClothTSL), (nCloth_saveCacheB, 'top', 5, nCloth_disableB)]) mc.formLayout(nClothFL, e=True, af=[(nCloth_loadCacheB, 'right', 5)], ac=[(nCloth_loadCacheB, 'left', 5, nClothTSL), (nCloth_loadCacheB, 'top', 5, nCloth_saveCacheB)]) # UI Callbacks mc.textScrollList(nClothTSL, e=True, dcc='glTools.ui.utils.selectFromTSL("' + nClothTSL + '")') mc.textScrollList(nClothTSL, e=True, dkc='glTools.ui.nDynamics.deleteNClothFromUI()') mc.radioButtonGrp(nClothVisRB, e=True, cc='glTools.ui.nDynamics.refreshNodeList("' + nClothTSL + '","nCloth","' + nClothVisRB + '")') mc.setParent('..') # Popup menu nClothPUM = mc.popupMenu(parent=nClothTSL) mc.menuItem(l='Select Hilited Nodes', c='glTools.ui.utils.selectFromTSL("' + nClothTSL + '")') mc.menuItem(l='Select Connected Mesh', c='glTools.ui.nDynamics.selectConnectedMesh("' + nClothTSL + '")') mc.menuItem(l='Select Connected Solver', c='glTools.ui.nDynamics.selectConnectedSolver("' + nClothTSL + '")') # Attr Presets nClothPresetList = glTools.utils.attrPreset.listNodePreset('nCloth') if nClothPresetList: mc.menuItem(allowOptionBoxes=False, label='Apply Preset', subMenu=True, tearOff=False) for nClothPreset in nClothPresetList: mc.menuItem(l=nClothPreset, c='glTools.ui.nDynamics.applyPreset("' + nClothTSL + '","' + nClothPreset + '")') # ----------------- # - nRigid Layout - # ----------------- mc.setParent(nDynTabLayout) # FormLayout nRigidFL = mc.formLayout(numberOfDivisions=100) # UI Elements nRigidVisRB = mc.radioButtonGrp( 'nRigidVisRB', cw=[(1, 60), (2, 60), (3, 80)], label='Display:', labelArray2=['All', 'Current'], numberOfRadioButtons=2, sl=1, cc='glTools.ui.nDynamics.toggleNClothVis()') nRigidTSL = mc.textScrollList('nDyn_nRigidTSL', allowMultiSelection=True) nRigid_createB = mc.button(label='Create from Mesh', c='glTools.ui.nDynamics.createNRigidFromUI()') nRigid_deleteB = mc.button(label='Delete Selected', c='glTools.ui.nDynamics.deleteNRigidFromUI()') nRigid_addToNucleusB = mc.button( label='Add to Nucleus', c='glTools.ui.nDynamics.addNRigidToNucleusFromUI()') nRigid_enableB = mc.button( label='Enable', c='glTools.ui.nDynamics.toggleNRigidStateFromUI(1)') nRigid_disableB = mc.button( label='Disable', c='glTools.ui.nDynamics.toggleNRigidStateFromUI(0)') # Layout mc.formLayout(nRigidFL, e=True, af=[(nRigidVisRB, 'top', 5), (nRigidVisRB, 'left', 5), (nRigidVisRB, 'right', 5)]) mc.formLayout(nRigidFL, e=True, af=[(nRigidTSL, 'left', 5), (nRigidTSL, 'bottom', 5)], ap=[(nRigidTSL, 'right', 5, 55)], ac=[(nRigidTSL, 'top', 5, nRigidVisRB)]) mc.formLayout(nRigidFL, e=True, af=[(nRigid_createB, 'right', 5)], ac=[(nRigid_createB, 'left', 5, nRigidTSL), (nRigid_createB, 'top', 5, nRigidVisRB)]) mc.formLayout(nRigidFL, e=True, af=[(nRigid_deleteB, 'right', 5)], ac=[(nRigid_deleteB, 'left', 5, nRigidTSL), (nRigid_deleteB, 'top', 5, nRigid_createB)]) mc.formLayout(nRigidFL, e=True, af=[(nRigid_addToNucleusB, 'right', 5)], ac=[(nRigid_addToNucleusB, 'left', 5, nRigidTSL), (nRigid_addToNucleusB, 'top', 5, nRigid_deleteB)]) mc.formLayout(nRigidFL, e=True, af=[(nRigid_enableB, 'right', 5)], ac=[(nRigid_enableB, 'left', 5, nRigidTSL), (nRigid_enableB, 'top', 5, nRigid_addToNucleusB)]) mc.formLayout(nRigidFL, e=True, af=[(nRigid_disableB, 'right', 5)], ac=[(nRigid_disableB, 'left', 5, nRigidTSL), (nRigid_disableB, 'top', 5, nRigid_enableB)]) # UI Callbacks mc.textScrollList(nRigidTSL, e=True, dcc='glTools.ui.utils.selectFromTSL("' + nRigidTSL + '")') mc.textScrollList(nRigidTSL, e=True, dkc='glTools.ui.nDynamics.deleteNRigidFromUI()') mc.radioButtonGrp(nRigidVisRB, e=True, cc='glTools.ui.nDynamics.refreshNodeList("' + nRigidTSL + '","nRigid","' + nRigidVisRB + '")') mc.setParent('..') # Popup menu nRigidPUM = mc.popupMenu(parent=nRigidTSL) mc.menuItem(l='Select Hilited Nodes', c='glTools.ui.utils.selectFromTSL("' + nRigidTSL + '")') mc.menuItem(l='Select Connected Mesh', c='glTools.ui.nDynamics.selectConnectedMesh("' + nRigidTSL + '")') mc.menuItem(l='Select Connected Solver', c='glTools.ui.nDynamics.selectConnectedSolver("' + nRigidTSL + '")') # Attr Presets nRigidPresetList = glTools.utils.attrPreset.listNodePreset('nRigid') if nRigidPresetList: mc.menuItem(allowOptionBoxes=False, label='Apply Preset', subMenu=True, tearOff=False) for nRigidPreset in nRigidPresetList: mc.menuItem(l=nRigidPreset, c='glTools.ui.nDynamics.applyPreset("' + nRigidTSL + '","' + nRigidPreset + '")') # -------------------- # - nParticle Layout - # -------------------- mc.setParent(nDynTabLayout) # FormLayout nParticleFL = mc.formLayout(numberOfDivisions=100) # UI Elements nParticleVisRB = mc.radioButtonGrp( 'nParticleVisRB', cw=[(1, 60), (2, 60), (3, 80)], label='Display:', labelArray2=['All', 'Current'], numberOfRadioButtons=2, sl=1, cc='glTools.ui.nDynamics.toggleNClothVis()') nParticleTSL = mc.textScrollList('nDyn_nParticleTSL', allowMultiSelection=True) nParticle_createB = mc.button( label='Fill Mesh', c='glTools.ui.nDynamics.createNParticleFromUI()') nParticle_deleteB = mc.button( label='Delete Selected', c='glTools.ui.nDynamics.deleteNParticleFromUI()') nParticle_addToNucleusB = mc.button( label='Add to Nucleus', c='glTools.ui.nDynamics.addNParticleToNucleusFromUI()') # Layout mc.formLayout(nParticleFL, e=True, af=[(nParticleVisRB, 'top', 5), (nParticleVisRB, 'left', 5), (nParticleVisRB, 'right', 5)]) mc.formLayout(nParticleFL, e=True, af=[(nParticleTSL, 'left', 5), (nParticleTSL, 'bottom', 5)], ap=[(nParticleTSL, 'right', 5, 55)], ac=[(nParticleTSL, 'top', 5, nParticleVisRB)]) mc.formLayout(nParticleFL, e=True, af=[(nParticle_createB, 'right', 5)], ac=[(nParticle_createB, 'left', 5, nParticleTSL), (nParticle_createB, 'top', 5, nParticleVisRB)]) mc.formLayout(nParticleFL, e=True, af=[(nParticle_deleteB, 'right', 5)], ac=[(nParticle_deleteB, 'left', 5, nParticleTSL), (nParticle_deleteB, 'top', 5, nParticle_createB)]) mc.formLayout(nParticleFL, e=True, af=[(nParticle_addToNucleusB, 'right', 5)], ac=[(nParticle_addToNucleusB, 'left', 5, nParticleTSL), (nParticle_addToNucleusB, 'top', 5, nParticle_deleteB)]) # UI Callbacks mc.textScrollList(nParticleTSL, e=True, dcc='glTools.ui.utils.selectFromTSL("' + nParticleTSL + '")') mc.textScrollList(nParticleTSL, e=True, dkc='glTools.ui.nDynamics.deleteNParticleFromUI()') mc.radioButtonGrp(nParticleVisRB, e=True, cc='glTools.ui.nDynamics.refreshNodeList("' + nParticleTSL + '","nParticle","' + nParticleVisRB + '")') mc.setParent('..') # Popup menu nParticlePUM = mc.popupMenu(parent=nParticleTSL) mc.menuItem(l='Select Hilited Nodes', c='glTools.ui.utils.selectFromTSL("' + nParticleTSL + '")') mc.menuItem(l='Select Connected Mesh', c='glTools.ui.nDynamics.selectConnectedMesh("' + nParticleTSL + '")') mc.menuItem(l='Select Connected Solver', c='glTools.ui.nDynamics.selectConnectedSolver("' + nParticleTSL + '")') # Attr Presets nParticlePresetList = glTools.utils.attrPreset.listNodePreset( 'nParticleTSL') if nParticlePresetList: mc.menuItem(allowOptionBoxes=False, label='Apply Preset', subMenu=True, tearOff=False) for nParticlePreset in nParticlePresetList: mc.menuItem(l=nParticlePreset, c='glTools.ui.nDynamics.applyPreset("' + nParticleTSL + '","' + nParticlePreset + '")') # ----------------- # - nCache Layout - # ----------------- mc.setParent(nDynTabLayout) # FormLayout nCacheFL = mc.formLayout(numberOfDivisions=100) mc.setParent('..') # -------------- # - End Layout - # -------------- # Set TabLayout Labels mc.tabLayout(nDynTabLayout, e=True, tabLabel=((nClothFL, 'nCloth'), (nRigidFL, 'nRigid'), (nParticleFL, 'nParticle'), (nCacheFL, 'nCache'))) # Display UI mc.showWindow(win) refreshUI()
def reorderAttrUI(): ''' ''' # Window window = 'reorderAttrUI' if mc.window(window,q=True,ex=1): mc.deleteUI(window) window = mc.window(window,t='Reorder Attributes') # Layout fl = mc.formLayout(numberOfDivisions=100) # UI Elements objTFB = mc.textFieldButtonGrp('reorderAttrTFB',label='',text='',buttonLabel='Load Selected',cw=[1,5]) attrTSL = mc.textScrollList('reorderAttrTSL', allowMultiSelection=True ) moveUpB = mc.button(label='Move Up', c='glTools.tools.reorderAttr.reorderAttrFromUI(0)' ) moveDnB = mc.button(label='Move Down', c='glTools.tools.reorderAttr.reorderAttrFromUI(1)' ) moveTpB = mc.button(label='Move to Top', c='glTools.tools.reorderAttr.reorderAttrFromUI(2)' ) moveBtB = mc.button(label='Move to Bottom', c='glTools.tools.reorderAttr.reorderAttrFromUI(3)' ) cancelB = mc.button(label='Cancel', c='mc.deleteUI("'+window+'")' ) # Form Layout mc.formLayout(fl,e=True,af=[(objTFB,'left',5),(objTFB,'top',5),(objTFB,'right',5)]) mc.formLayout(fl,e=True,af=[(moveUpB,'left',5),(moveUpB,'right',5)],ac=[(moveUpB,'bottom',5,moveDnB)]) mc.formLayout(fl,e=True,af=[(moveDnB,'left',5),(moveDnB,'right',5)],ac=[(moveDnB,'bottom',5,moveTpB)]) mc.formLayout(fl,e=True,af=[(moveTpB,'left',5),(moveTpB,'right',5)],ac=[(moveTpB,'bottom',5,moveBtB)]) mc.formLayout(fl,e=True,af=[(moveBtB,'left',5),(moveBtB,'right',5)],ac=[(moveBtB,'bottom',5,cancelB)]) mc.formLayout(fl,e=True,af=[(cancelB,'left',5),(cancelB,'right',5),(cancelB,'bottom',5)]) mc.formLayout(fl,e=True,af=[(attrTSL,'left',5),(attrTSL,'right',5)],ac=[(attrTSL,'top',5,objTFB),(attrTSL,'bottom',5,moveUpB)]) # UI callback commands mc.textFieldButtonGrp('reorderAttrTFB',e=True,bc='glTools.tools.reorderAttr.reorderAttrLoadSelected()') # Load selection sel = mc.ls(sl=1) if sel: reorderAttrLoadSelected() # Display UI mc.showWindow(window)
def kinematifyUI(): # Create window if cmds.window('kinematifyWin', exists=1): cmds.deleteUI('kinematifyWin') window = cmds.window('kinematifyWin', title='Kinematify', sizeable=1) # Create form + UI elements form = cmds.formLayout(numberOfDivisions=100) startJointText = cmds.textFieldGrp(label='Start Joint ', adj=2, editable=0) startJointBtn = cmds.button(label='Set Selected', command=partial(checkSelectedJoint, startJointText)) endJointText = cmds.textFieldGrp(label='End Joint ', adj=2, editable=0) endJointBtn = cmds.button(label='Set Selected', command=partial(checkSelectedJoint, endJointText)) ikControlText = cmds.textFieldGrp(label='IK Control ', adj=2, editable=0) ikControlBtn = cmds.button(label='Set Selected', command=partial(checkSelectedControl, ikControlText)) ikfkSwitchControlText = cmds.textFieldGrp(label='IK/FK Switch Control ', adj=2, editable=0) ikfkSwitchControlBtn = cmds.button(label='Set Selected', command=partial(checkSelectedControl, ikfkSwitchControlText)) jointNameSuffixText = cmds.textFieldGrp(label='Joint Name Suffix ', adj=2) kinematifyBtn = cmds.button(label='Kinematify!', command=partial(executeKinematify, startJointText, endJointText, ikControlText, ikfkSwitchControlText, jointNameSuffixText)) applyBtn = cmds.button(label='Apply', command=partial(applyKinematify, startJointText, endJointText, ikControlText, ikfkSwitchControlText, jointNameSuffixText)) closeBtn = cmds.button(label='Close', command="cmds.deleteUI('kinematifyWin')") # Format UI elements cmds.formLayout( form, edit=1, attachForm=[(startJointText, 'top', 15), (startJointText, 'left', 0), (startJointBtn, 'top', 15), (startJointBtn, 'right', 10), (endJointText, 'left', 0), (endJointText, 'right', 0), (endJointBtn, 'right', 10), (ikControlText, 'left', 0), (ikControlText, 'right', 0), (ikControlBtn, 'right', 10), (ikfkSwitchControlText, 'left', 0), (ikfkSwitchControlText, 'right', 0), (ikfkSwitchControlBtn, 'right', 10), (jointNameSuffixText, 'left', 0), (jointNameSuffixText, 'right', 0), (kinematifyBtn, 'left', 5), (kinematifyBtn, 'bottom', 5), (applyBtn, 'bottom', 5), (closeBtn, 'bottom', 5), (closeBtn, 'right', 5)], attachControl=[ (startJointText, 'bottom', 5, endJointText), (startJointText, 'right', 5, startJointBtn), (startJointBtn, 'bottom', 5, endJointBtn), (endJointText, 'bottom', 5, ikControlText), (endJointText, 'right', 5, endJointBtn), (endJointBtn, 'bottom', 5, ikControlBtn), (ikControlText, 'bottom', 5, ikfkSwitchControlText), (ikControlText, 'right', 5, ikControlBtn), (ikControlBtn, 'bottom', 5, ikfkSwitchControlBtn), (ikfkSwitchControlText, 'bottom', 5, jointNameSuffixText), (ikfkSwitchControlText, 'right', 5, ikfkSwitchControlBtn), (ikfkSwitchControlBtn, 'bottom', 5, jointNameSuffixText), (jointNameSuffixText, 'bottom', 25, kinematifyBtn), (kinematifyBtn, 'right', 5, applyBtn), (closeBtn, 'left', 5, applyBtn) ], attachPosition=[ (kinematifyBtn, 'right', 0, 33), (applyBtn, 'left', 0, 34), (applyBtn, 'right', 0, 66), ]) cmds.showWindow(window)
def p(self): pathA=self.pathA1[0:] getpath=cmds.textField('Path',q=True,tx=True) delto=getpath.replace('\\','/') path=delto+'/' trvsel=cmds.treeView('ok',q=True,si=True) trvselP=cmds.treeView('ok',q=True,ip=trvsel[0]) object=cmds.tabLayout('tuplistlayout',q=True,st=True) Path1=path+trvselP+'/'+trvsel[0]+'/'+object[0:]+'/' id1=cmds.getFileList(folder=Path1) slLc=cmds.scrollLayout(object[0:],q=True,ca=True) #cmds.rowColumnLayout('RowL',numberOfColumns=1,p=object[0:]) if slLc!=None: for slLcobj in slLc: cmds.deleteUI(slLcobj,control=True) else: print '没有' if cmds.formLayout('RowL',ex=True): cmds.deleteUI('RowL') #cmds.rowColumnLayout('RowL',numberOfColumns=1,p=object[0:]) cmds.formLayout('RowL',p=object[0:]) ksymbolButtonk=[] ktextk=[] k_tW=100 k_tH=100 k_tH=20 for i in range(len(id1)): pic=[w for w in os.listdir(Path1+id1[i]+'/') if w.endswith('.jpg')] pp=Path1+id1[i]+'/' #cmds.symbolButton(image=(Path1+id1[i]+'/'+pic[0]),ann='oo',p='RowL',w=100,h=100,c=partial(self.showFileInfo,(Path1+id1[i]+'/'))) #增加图片按钮 ksymbolButtonk.append(cmds.symbolButton(image=(Path1+id1[i]+'/'+pic[0]),p='RowL',w=k_tW,h=k_tH,c=partial(self.showFileInfo,(Path1+id1[i]+'/'))))#增加图片按钮 cmds.popupMenu() cmds.menuItem(l=u'导入动画数据',c = partial(self.eidtpath,(Path1+id1[i]+'/'))) cmds.menuItem(l=u'观看视频!',c=self.OPENVIDEO) cmds.menuItem(l=u'打开文件夹!',c=self.OPENFILE) cmds.menuItem(l=u'打开文件!',c=self.OPENMB) cmds.menuItem(l=u'信息查看与动画截取',c=self.editaniwin) #cmds.text(l=id1[i],p='RowL') ktextk.append(cmds.iconTextButton (style=('textOnly'),enable=0,l=id1[i],w=k_tW,h=k_tH,p='RowL')) self.editSBsize() for o in range(len(id1)): if o==0: cmds.formLayout('RowL',e=True,attachPosition=((ksymbolButtonk[o],'top',0,0),(ksymbolButtonk[o],'left',0,0))) elif o==1: cmds.formLayout('RowL',e=True,attachPosition=(ksymbolButtonk[o],'top',0,0),attachControl=(ksymbolButtonk[o],'left',0,ksymbolButtonk[o-1])) elif o%2==1: cmds.formLayout('RowL',e=True,attachControl=((ksymbolButtonk[o],'top',0,ktextk[o-2]),(ksymbolButtonk[o],'left',0,ksymbolButtonk[o-1]))) else: cmds.formLayout('RowL',e=True,attachControl=(ksymbolButtonk[o],'top',k_tH,ksymbolButtonk[o-2]),attachPosition=(ksymbolButtonk[o],'left',0,0)) for u in range(len(id1)): if u%2==1: cmds.formLayout('RowL',e=True,attachControl=((ktextk[u],'top',0,ksymbolButtonk[u]),(ktextk[u],'left',0,ktextk[u-1]))) else: cmds.formLayout('RowL',e=True,attachControl=(ktextk[u],'top',0,ksymbolButtonk[u]),attachPosition=(ktextk[u],'left',0,0))