def btn_play(): if pm.play( q=True, state=True ): pm.symbolButton( widget['playButton'], e=True, image='interactivePlayback.png' ) pm.play( state=False ) else: pm.symbolButton( widget['playButton'], e=True, image='timestop.png' ) pm.mel.InteractivePlayback()
def uiContents(): with pm.frameLayout(l='Color', cll=True, mw=3, mh=3 ): with pm.columnLayout(adj=True): with pm.rowLayout(nc=2): pm.text(label='Set Override Color : ', align='right', w=130) with pm.rowColumnLayout( nc=10 ): wh=18 for i in range(0,32): rgb = (0,0,0) if i == 0: rgb = (0.5,0.5,0.5) anno = 'Reset' pm.symbolButton( i=iconPath+'ui_colorNone.png', annotation=anno, w=wh, h=wh, c=pm.Callback( setColor.setColor, color=i ) ) else: rgb = pm.colorIndex( i, q=True ) anno = '- index : %d\n- RGB : %03.3f %03.3f %03.3f\n- name : %s'%(i, rgb[0], rgb[1], rgb[2], setColor.color_intToStr(i) ) pm.canvas( rgbValue = rgb, annotation = anno, w=wh, h=wh, pressCommand = pm.Callback( setColor.setColor, color=i ) ) #partial( self.setColor, i, True , self._toShape)) #partial( self.setColor, i, False, False)) pm.separator(h=8,style='in') with pm.rowLayout( nc=10 ): pm.text(label='Set Wire Frame Color : ', align='right', w=130) pm.button(label='Object Color Palette', c=pm.Callback( pm.mel.objectColorPalette ), w=180 ) # ====================================== # Buttons # ======================================
def rtb_toggle_select_mode(*args, **kwargs): if pm.control(prefix + '_symbolButton_select_mode', exists=True): componentMode = pm.selectMode(query=True, component=True) if not componentMode: pm.selectMode(component=True) pm.symbolButton(prefix + '_symbolButton_select_mode', edit=True, image='selectByComponent.png') else: pm.selectMode(object=True) pm.symbolButton(prefix + '_symbolButton_select_mode', edit=True, image='selectByObject.png')
def componentsListRebuild(self, node): if node.passType.get() == 2: self.componentsButton = pm.button(label="Add Component", c=pm.Callback(self.showComponentList, node), parent=self.uiParent) componentString = node.components.get() if componentString is None or len(componentString) == 0: return pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) with pm.frameLayout(labelVisible=False, collapsable=False, w=240, parent=self.uiParent) as self.componentsListUI: with pm.rowColumnLayout(nc=2, cw=((1,200), (2, 30))): for c in componentString.split(","): pm.text(label=c, align="right") pm.symbolButton(image="smallTrash.png", c=pm.Callback(self.removeComponent, node, c)) pm.setUITemplate("attributeEditorTemplate", popTemplate=True)
def customLightFiltersNew(self, attr): pm.rowLayout(numberOfColumns=3, adjustableColumn=2, rowAttach=(1, "top", 0), columnWidth=[(1, 140), (2, 180)]) pm.text(label="") pm.columnLayout(adjustableColumn=True, columnAttach=("both", 0), rowSpacing=5) uiName = '%s_aiFilter' % (self.nodeType()) self.scrollList = pm.textScrollList( uiName, height=150, ams=False, sc=self.lightFilterListChanged, dcc=self.updateCustomLightFiltersNew) pm.rowLayout(numberOfColumns=2, columnWidth2=(80, 80), columnAttach2=("both", "both"), columnAlign2=("center", "center"), columnOffset2=(2, 2)) pm.button('lf_add_button', label="Add", c=Callback(self.addLightFilterWin)) pm.button('lf_remove_button', label="Disconnect", c=Callback(self.removeLightFilter)) # implicit end of row layout pm.setParent('..') # back to column layout pm.setParent('..') # back to row layout pm.columnLayout(adjustableColumn=True, columnAttach=("both", 0), rowSpacing=5) pm.symbolButton('lf_move_up_button', image='arrowUp.xpm', c=Callback(self.moveLightFilterUp)) pm.symbolButton('lf_move_down_button', image='arrowDown.xpm', c=Callback(self.moveLightFilterDown)) pm.setParent('..') pm.setParent('..') self.addOptionMenuGrp = pm.optionMenuGrp( 'lf_add_menu', label='Add', changeCommand=self.addLightFilterCB) self.addOptionMenu = self.addOptionMenuGrp + '|OptionMenu' self.lightFiltersUpdateList() self.updateAddMenu()
def createBrowser(self): win = pm.window(w=200) form = pm.formLayout(numberOfDivisions=100) col2 = pm.columnLayout(p=form, adjustableColumn=True) allowedAreas = ['right', 'left'] pm.dockControl(label='BROWSER', w=200, area='left', content=win, allowedArea=allowedAreas) self.projectSelectWidget = ProjectSelectWidget() self.projectSelectWidget.createProjectSelect(col2) pm.rowLayout(nc=3, adj=1) self.typeOpt = pm.optionMenuGrp(label='Item Type', changeCommand=self.changeTypeCallback, cat=[[1,'left',5],[2,'left',-80]]) types = ['asset', 'shot', 'model', 'uvs', 'texture', 'blendShape', 'rig', 'layout', 'animation', 'shotFinalizing', 'lightining', 'render'] for assetType in types: pm.menuItem(label=assetType) pm.symbolButton(image=r'D:/JOBS/PIPELINE/pipeExemple/scenes/icons/small.png', c=lambda x, y=2: self.changeViewCallback(y)) pm.symbolButton(image=r'D:/JOBS/PIPELINE/pipeExemple/scenes/icons/big.png', c=lambda x, y=1: self.changeViewCallback(y)) pane = pm.paneLayout(p=form, configuration='top3', ps=[(1, 20, 80), (2, 80, 80), (3, 100, 20)], shp = 0) self.folderTreeWidget = FolderTreeWidget('asset') self.folderTreeWidget.createFolderTree(pane) self.folderTreeWidget.getFolderTree() self.itemListWidget = ItemListWidget() self.itemListWidget.createList(pane) self.itemListWidget.refreshList(path=[], task='asset') self.infoWidget = InfoWidget() self.infoWidget.createInfo(pane) self.folderTreeWidget.itemListWidget = self.itemListWidget self.folderTreeWidget.itemListWidget.type = 'asset' self.folderTreeWidget.itemListWidget.task = 'asset' self.projectSelectWidget.folderTreeWidget = self.folderTreeWidget self.projectSelectWidget.itemListWidget = self.itemListWidget self.itemListWidget.infoWidget = self.infoWidget pm.formLayout(form, edit=True, attachForm=[(pane, 'left', 5), (pane, 'bottom', 5), (pane, 'right', 5), (col2, 'top', 5), (col2, 'left', 5), (col2, 'right', 5)], attachControl=[(pane, 'top', 5, col2)], attachPosition=[], attachNone=() ) pm.showWindow()
def RefreshAnimationModuleList(self, _index = 1): pm.textScrollList(self.UIElements["animationModule_textScroll"], edit = True, removeAll = True) pm.symbolButton(self.UIElements["deleteModuleButton"], edit = True, enable = False) pm.symbolButton(self.UIElements["duplicateModuleButton"], edit = True, enable = False) selectedBlueprintModule = pm.textScrollList(self.UIElements["blueprintModule_textScroll"], query = True, selectItem = True) self.selectedBlueprintModule = self.blueprintModules[selectedBlueprintModule[0]] self.SetupActiveModuleControls() pm.namespace(setNamespace = self.selectedBlueprintModule) controlModuleNamespaces = pm.namespaceInfo(listOnlyNamespaces = True) pm.namespace(setNamespace = ":") if len(controlModuleNamespaces) != 0: for module in controlModuleNamespaces: moduleName = utils.StripAllNamespaces(module)[1] pm.textScrollList(self.UIElements["animationModule_textScroll"], edit = True, append = moduleName) pm.textScrollList(self.UIElements["animationModule_textScroll"], edit = True, selectIndexedItem = _index) pm.symbolButton(self.UIElements["deleteModuleButton"], edit = True, enable = True) pm.symbolButton(self.UIElements["duplicateModuleButton"], edit = True, enable = True) self.SetupModuleSpecificControls() self.previousBlueprintListEntry = selectedBlueprintModule
def lc_browse_field_button(cls, width, textFieldName, lct_cfg, configAttr, placeholderText, annotation='Browse a path', fileMask='', *args, **kwargs): ''' make a text field and browse button return a string path ''' cw2 = 25 cw1 = width - cw2 pm.rowColumnLayout(nc=2, cw=([1, cw1], [2, cw2])) pm.textField(textFieldName, w=cw2, placeholderText=placeholderText, changeCommand=lambda *args: lct_cfg.set(configAttr, pm.textField(textFieldName, query=True, tx=True))) pm.symbolButton(image='navButtonBrowse.png', annotation=annotation, w=cw2, command=lambda *args: cls.lc_browse_field_set(textFieldName, lct_cfg, configAttr, fileMask, annotation))
def createModuleInstallButton(self, module): mod = __import__("Blueprint." + module, {}, {}, [module]) reload(mod) title = mod.TITLE description = mod.DESCRIPTION icon = mod.ICON buttonSize = 64 pm.rowColumnLayout(numberOfColumns=2, columnWidth=[(1, buttonSize)]) #Create UI #distinguish between buttons with partial functions self.UIElements["module_button_" + module] = pm.symbolButton( width=buttonSize, height=buttonSize, image=icon, command=partial(self.installModule, module)) textColumn = pm.columnLayout(columnAlign="center") pm.text(align="left", width=self.windowWidth - 30, label=title) pm.scrollField(text=description, editable=False, width=self.windowWidth - 30, height=50, wordWrap=True) pm.setParent(self.UIElements["moduleList_row"])
def asset_widget(self, current_parent, asset_name): ''' Single asset widget. ''' self.main = pm.frameLayout(labelVisible=False, parent=current_parent) self.form = pm.formLayout() self.image_name = (self.asset_name + '.jpg') self.scene_name = pm.sceneName() # Creating Components self.asset_image = pm.symbolButton(image=self.image_name, width=48, height=48) self.asset_text = pm.text(height=48, width=125, align='left', label=asset_name) self.asset_low = pm.button(height=26, width=60, label='Low', command=pm.Callback(self.reference_asset, 'low')) self.asset_med = pm.button(height=26, width=60, label='Med', command=pm.Callback(self.reference_asset, 'medium')) self.asset_high = pm.button(height=26, width=60, label='Hi', command=pm.Callback( self.reference_asset, 'high')) # Positioning Components. # Symbol Button self.form.attachForm(self.asset_image, 'top', 5) self.form.attachForm(self.asset_image, 'left', 5) # asset text self.form.attachForm(self.asset_text, 'top', 5) self.form.attachForm(self.asset_low, 'top', 15) self.form.attachForm(self.asset_med, 'top', 15) self.form.attachForm(self.asset_high, 'top', 15) self.form.attachControl(self.asset_text, 'left', 15, self.asset_image) # form.attachControl(asset_text, 'right', 5, asset_low) self.form.attachControl(self.asset_low, 'left', 5, self.asset_text) self.form.attachControl(self.asset_med, 'left', 5, self.asset_low) self.form.attachControl(self.asset_high, 'left', 5, self.asset_med) self.form.attachForm(self.asset_high, 'right', 5) self.form.attachForm(self.asset_image, 'bottom', 5) # res buttons # Return parent to orginal layout pm.setParent(current_parent)
def AppleseedTranslatorCreateTab(self): log.debug("AppleseedTranslatorCreateTab()") self.createGlobalsNode() parentForm = pm.setParent(query=True) pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) scLo = self.rendererName + "TrScrollLayout" with pm.scrollLayout(scLo, horizontalScrollBarThickness=0): with pm.columnLayout(self.rendererName + "TrColumnLayout", adjustableColumn=True, width=400): with pm.frameLayout(label="Translator", collapsable=True, collapse=False): attr = pm.Attribute(self.renderGlobalsNodeName + ".translatorVerbosity") ui = pm.attrEnumOptionMenuGrp(label="Translator Verbosity", at=self.renderGlobalsNodeName + ".translatorVerbosity", ei=self.getEnumList(attr)) with pm.frameLayout(label="{0} export".format(self.rendererName), collapsable=True, collapse=False): ui = pm.checkBoxGrp(label="Export {0} Scene file:".format(self.rendererName), value1=False) pm.connectControl(ui, self.renderGlobalsNodeName + ".exportSceneFile", index=2) # xmlDict = {} # self.rendererTabUiDict['xml'] = xmlDict # defaultXMLPath = pm.workspace.path + "/" + pm.sceneName().basename().split(".")[0] + ".appleseed" # if not defaultXMLPath.dirname().exists(): # defaultXMLPath.dirname().makedirs() # with pm.rowLayout(nc=3): # xmlDict['xmlFileText'] = pm.text(label="Export to") # xmlDict['xmlFile'] = pm.textField(text=defaultXMLPath) # pm.symbolButton(image="navButtonBrowse.png", c=self.xmlFileBrowse) # pm.connectControl(xmlDict['xmlFile'], self.renderGlobalsNodeName + ".exportSceneFileName", index=2) with pm.frameLayout(label="Optimize Textures", collapsable=True, collapse=False): optiDict = {} ui = pm.checkBoxGrp(label="Use Optimized Textures:", value1=False) pm.connectControl(ui, self.renderGlobalsNodeName + ".useOptimizedTextures", index=2) with pm.rowLayout(nc=3): self.rendererTabUiDict['opti'] = optiDict pm.text(label="OptimizedTex Dir:") optiDict['optiField'] = pm.textField(text=self.renderGlobalsNode.optimizedTexturePath.get()) pm.symbolButton(image="navButtonBrowse.png", c=self.dirBrowse) pm.connectControl(optiDict['optiField'], self.renderGlobalsNodeName + ".optimizedTexturePath", index=2) with pm.frameLayout(label="Additional Settings", collapsable=True, collapse=False): ui = pm.floatFieldGrp(label="Scene scale:", value1=1.0, numberOfFields=1) pm.connectControl(ui, self.renderGlobalsNodeName + ".sceneScale", index=2) pm.setUITemplate("attributeEditorTemplate", popTemplate=True) pm.formLayout(parentForm, edit=True, attachForm=[ (scLo, "top", 0), (scLo, "bottom", 0), (scLo, "left", 0), (scLo, "right", 0) ])
def uiContents(): # Curve Shape ----------------------- with pm.frameLayout(l='Control Curve Shapes', cll=True, mw=3, mh=3 ): with pm.columnLayout(adj=True): nc = int( 320 / buttonSize ) with pm.rowColumnLayout( nc=nc ): wh=buttonSize for key in curveShape.CURVESHAPE.keys(): #pm.button(l=key, w=wh, h=wh, c=pm.Callback(curveShape.create, key), annotation=key) #pm.symbolButton( i=iconPath+'ui_thumbnail__%s.png'%key, w=wh, h=wh, c=pm.Callback(curveShape.create, key), annotation=key, bgc=(174.0/255,157.0/255,217.0/255), ebg=True ) pm.symbolButton( i=iconPath+'ui_thumbnail__%s.png'%key, w=wh, h=wh, c=pm.Callback(curveShape.create, key), annotation=key ) with pm.rowLayout( nc=10 ): pm.text(label=' ', align='right', w=150) pm.button(label='Batch Render Icons', c=pm.Callback( icon_batchRender ), w=118 ) pm.button(label='Demo', c=pm.Callback( curveShape.demo ), w=40 ) pm.separator(h=8,style='in') with pm.rowLayout( nc=10 ): pm.text(label='Create Curve Text : ', align='right', w=150) pm.button(label='Text', c=pm.Callback( curveShape.createText ), w=160 ) # Curve Tools ----------------------- with pm.frameLayout(l='Curve Tools', cll=True, mw=3, mh=3 ): with pm.columnLayout(adj=True): with pm.rowLayout( nc=10 ): pm.text(label='Print Curve Command : ', align='right', w=150) pm.button(label='Print Command', c=pm.Callback( curveShape.printCurveCommand ), w=160 ) with pm.rowLayout( nc=10 ): pm.text(label='Curve Command : ', align='right', w=150) pm.button(label='Collapse', c=pm.Callback( curveShape.combine ), w=52 ) pm.button(label='Separate', c=pm.Callback( curveShape.separate ), w=52 ) pm.button(label='Replace', c=pm.Callback( curveShape.replace ), w=52) with pm.rowLayout(nc=4): pm.text(l='Curve Display : ', w= 150, align='right') pm.button( l='cv', w= 39, c=pm.Callback( btn_toggleCrvDisp, 'cv')) pm.button( l='ep', w= 39, c=pm.Callback( btn_toggleCrvDisp, 'ep' )) pm.button( l='hull', w= 39, c=pm.Callback( btn_toggleCrvDisp, 'hull' ))
def UI(self): width = 410 height = 210 # create window if pm.window('ehm_Colorize_UI', exists=True): pm.deleteUI('ehm_Colorize_UI') pm.window('ehm_Colorize_UI', title='change color', w=width, h=height, mxb=False, mnb=False, sizeable=False) # main layout mainLayout = pm.columnLayout(w=width, h=height) formLayout = pm.formLayout(w=width - 10, h=height - 10) frameLayout = pm.frameLayout(borderStyle='etchedIn', labelVisible=False) # left column and form pm.setParent(formLayout) buttonsLayout = pm.rowColumnLayout(nc=8) # find color icons iconPath = os.path.join(ehsan_script_directory, 'ui', 'icons') icons = os.listdir(iconPath) colorIcons = [] for icon in icons: if 'color_' in icon: colorIcons.append(icon) # button for icon in colorIcons: colorCode = int(icon.partition('.')[0].partition('_')[2]) pm.symbolButton(image=os.path.join(iconPath, icon), w=50, h=50, c=partial(self.colorize, None, colorCode)) # show window pm.showWindow('ehm_Colorize_UI')
def AEzFileSwitchPathNew(fileAttribute): pm.setUITemplate('attributeEditorTemplate', pst=True) pm.columnLayout(adj=True) pm.rowLayout(nc=3) if fileAttribute.split('.')[-1] == 'highResolution': label = 'High-resolution' else: label = 'Low-resolution' pm.text('filenameName', label=label) pm.textField('filenameField', fileName='') pm.symbolButton('browseFileSwitch', image='navButtonBrowse.png') pm.setParent('..') pm.setParent('..') pm.setUITemplate(ppt=True) AEzFileSwitchPathReplace(fileAttribute)
def IndigoTranslatorCreateTab(self): log.debug("IndigoTranslatorCreateTab()") self.createGlobalsNode() parentForm = pm.setParent(query = True) pm.setUITemplate("attributeEditorTemplate", pushTemplate = True) scLo = self.rendererName + "TrScrollLayout" with pm.scrollLayout(scLo, horizontalScrollBarThickness = 0): with pm.columnLayout(self.rendererName + "TrColumnLayout", adjustableColumn = True, width = 400): with pm.frameLayout(label="Translator", collapsable = True, collapse=False): attr = pm.Attribute(self.renderGlobalsNodeName + ".translatorVerbosity") ui = pm.attrEnumOptionMenuGrp(label = "Translator Verbosity", at=self.renderGlobalsNodeName + ".translatorVerbosity", ei = self.getEnumList(attr)) with pm.frameLayout(label="Indigo Scene File export", collapsable = True, collapse=False): ui = pm.checkBoxGrp(label="Export Indigo Scene file:", value1 = False) pm.connectControl(ui, self.renderGlobalsNodeName + ".exportSceneFile", index = 2 ) xmlDict = {} self.rendererTabUiDict['xml'] = xmlDict defaultXMLPath = pm.workspace.path + "/" + pm.sceneName().basename().split(".")[0] + ".igs" if not defaultXMLPath.dirname().exists(): defaultXMLPath.dirname().makedirs() with pm.rowLayout(nc=3): xmlDict['xmlFileText'] = pm.text(label = "Export to") xmlDict['xmlFile'] = pm.textField(text = defaultXMLPath) pm.symbolButton(image="navButtonBrowse.png", c=self.xmlFileBrowse) pm.connectControl(xmlDict['xmlFile'], self.renderGlobalsNodeName + ".exportSceneFileName", index = 2 ) with pm.frameLayout(label="Optimize Textures", collapsable = True, collapse=False): optiDict = {} ui = pm.checkBoxGrp(label="Use Optimized Textures:", value1 = False) with pm.rowLayout(nc=3): self.rendererTabUiDict['opti'] = optiDict pm.text(label="OptimizedTex Dir:") optiDict['optiField'] = pm.textField(text = self.renderGlobalsNode.optimizedTexturePath.get()) pm.symbolButton(image="navButtonBrowse.png", c=self.dirBrowse) pm.connectControl(optiDict['optiField'], self.renderGlobalsNodeName + ".optimizedTexturePath", index = 2 ) with pm.frameLayout(label="Additional Settings", collapsable = True, collapse=False): ui = pm.floatFieldGrp(label="Scene scale:", value1 = 1.0, numberOfFields = 1) pm.connectControl(ui, self.renderGlobalsNodeName + ".sceneScale", index = 2 ) pm.setUITemplate("attributeEditorTemplate", popTemplate = True) pm.formLayout(parentForm, edit = True, attachForm = [ (scLo, "top", 0), (scLo, "bottom", 0), (scLo, "left", 0), (scLo, "right", 0) ])
def ui(): columnWidth1st = 120 if pm.window('AlembicMasterUI', q=True, exists=True) : pm.deleteUI('AlembicMasterUI') with pm.window('AlembicMasterUI',menuBar=True, s=True): with pm.columnLayout(adj=True): with pm.frameLayout( label='Export Alembic', mw=3, mh=3,cll=True, bs='etchedIn'): with pm.columnLayout(adj=True): with pm.rowLayout(nc=3, adj=2): pm.text(label='file :', w=columnWidth1st, align='right') pm.textField('path_TFG', text="D:/") pm.symbolButton( image='navButtonBrowse.png', c=pm.Callback( browseIt, 'path_TFG', 0, 'Alembic (*.abc)' ) ) with pm.rowLayout(nc=2, adj=2 ): startFrame=pm.animation.playbackOptions(q=1, minTime=1) EndFrame=pm.animation.playbackOptions(q=1, maxTime=1) with pm.rowLayout(nc=2, adj=2): pm.text(l='',w=columnWidth1st) pm.button(l='Export',bgc=(0.19,0.29,0.19),c=pm.Callback(exportScene)) pm.radioButtonGrp( 'timeRange_RBG', label='Time range :', labelArray3=['Camera Setting','Time Slider', 'Start/End'], numberOfRadioButtons=3, select=1, cw = [1,columnWidth1st], on1=pm.Callback( callback_timerangeSelect, 1), on2=pm.Callback( callback_timerangeSelect, 2), on3=pm.Callback( callback_timerangeSelect, 3), ) pm.floatFieldGrp( 'timeRange_FFG', label='Start / End : ', value1=1, value2=24, numberOfFields=2, cw = [1,117], en=False) with pm.frameLayout( label='Rebuild Scene', mw=3, mh=3,cll=True, bs='etchedIn'): with pm.columnLayout(adj=True): with pm.rowLayout(nc=2, adj=2): pm.text(l='',w=columnWidth1st) pm.button(l='New Scene', bgc=(0.24,0.49,0.24), c=pm.Callback(buildscene)) with pm.frameLayout( label='Import Alembic', mw=3, mh=3,cll=True, bs='etchedIn'): with pm.columnLayout(adj=True): with pm.rowLayout(nc=3, adj=2): pm.text(label='file :', w=columnWidth1st, align='right') pm.textField('path_ABC2', text="D:/") pm.symbolButton( image='navButtonBrowse.png', c=pm.Callback( browseIt, 'path_ABC2', 1, 'Alembic (*.abc)' ) ) with pm.rowLayout(nc=2, adj=2): pm.text(l='',w=columnWidth1st) pm.button(l='Import', bgc=(0.19,0.19,0.28), c=pm.Callback(importAbcFile)) with pm.frameLayout( label='Save Scene', mw=3, mh=3,cll=True, bs='etchedIn'): with pm.columnLayout(adj=True): with pm.rowLayout(nc=3, adj=2): pm.text(label='file :', w=columnWidth1st, align='right') pm.textField('path_TFG2', text="D:/") pm.symbolButton( image='navButtonBrowse.png', c=pm.Callback( browseIt, 'path_TFG2', 0 ) ) with pm.rowLayout(nc=2, adj=2): pm.text(l='',w=columnWidth1st) pm.button(l='Save Scene', w=64, bgc=(0.22,0.23,0.43), c=pm.Callback(saveScene))
def AppleseedTranslatorCreateTab(self): self.createGlobalsNode() parentForm = pm.setParent(query=True) pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) scLo = self.rendererName + "TrScrollLayout" uiDict = {} self.rendererTabUiDict['translator'] = uiDict with pm.scrollLayout(scLo, horizontalScrollBarThickness=0): with pm.columnLayout(self.rendererName + "TrColumnLayout", adjustableColumn=True, width=400): with pm.frameLayout(label="Translator", collapsable=True, collapse=False): with pm.columnLayout(adjustableColumn=True, width=400): self.addRenderGlobalsUIElement(attName='translatorVerbosity', uiType='enum', displayName='Verbosity:', default='0', uiDict=uiDict) with pm.frameLayout(label="appleseed Output", collapsable=True, collapse=False): with pm.columnLayout(adjustableColumn=True, width=400): self.addRenderGlobalsUIElement(attName='exportMode', uiType='enum', displayName='Output Mode:', default='0', uiDict=uiDict, callback=self.AppleseedTranslatorUpdateTab) with pm.rowLayout(nc=3) as uiDict['outputFilenameLayout']: pm.text(label="Output Filename:") uiDict['fileNameField'] = pm.textField(text=self.renderGlobalsNode.exportSceneFileName.get()) pm.symbolButton(image="navButtonBrowse.png", c=self.outputFileBrowse) pm.connectControl(uiDict['fileNameField'], self.renderGlobalsNodeName + ".exportSceneFileName", index=2) with pm.frameLayout(label="Optimize Textures", collapsable=True, collapse=False): with pm.columnLayout(adjustableColumn=True, width=400): optiDict = {} ui = pm.checkBoxGrp(label="Use Optimized Textures:", value1=False) pm.connectControl(ui, self.renderGlobalsNodeName + ".useOptimizedTextures", index=2) with pm.rowLayout(nc=3): self.rendererTabUiDict['opti'] = optiDict pm.text(label="Optimized Textures Dir:") optiDict['optiField'] = pm.textField(text=self.renderGlobalsNode.optimizedTexturePath.get()) pm.symbolButton(image="navButtonBrowse.png", c=self.dirBrowse) pm.connectControl(optiDict['optiField'], self.renderGlobalsNodeName + ".optimizedTexturePath", index=2) with pm.frameLayout(label="Additional Settings", collapsable=True, collapse=False): ui = pm.floatFieldGrp(label="Scene Scale:", value1=1.0, numberOfFields=1) pm.connectControl(ui, self.renderGlobalsNodeName + ".sceneScale", index=2) pm.setUITemplate("attributeEditorTemplate", popTemplate=True) pm.formLayout(parentForm, edit=True, attachForm=[ (scLo, "top", 0), (scLo, "bottom", 0), (scLo, "left", 0), (scLo, "right", 0) ]) self.AppleseedTranslatorUpdateTab()
def lcToolbox_child_popout(cls, mainColumn, windowName, height, commandString, iconPath, lct_cfg, *args, **kwargs): ''' pop out the tool from the lcToolbox ''' import lct.src.lcToolbox.lcToolbox as lcToolbox lcToolboxPath = os.path.join(os.path.abspath(os.path.dirname(__file__)), os.pardir, 'lcToolbox', "lcToolbox.conf") conf = lcConfiguration.Conf.load_conf_file(lcToolboxPath) srcPath = lcPath.Path.getSrcPath() if pm.columnLayout(mainColumn, ex=True) and pm.window(windowName, ex=False) and pm.window('lcToolbox', ex=True): pm.deleteUI(mainColumn) toolboxHeight = pm.window('lcToolbox', query=True, h=True) - height + conf['height'] pm.picture(image=os.path.join(srcPath, 'lcToolbox', 'icons', 'none.png'), parent='fl_form_tool') pm.symbolButton('lcTb_{}'.format(windowName), edit=True, enable=True, image=os.path.join(iconPath, '{}_Return.png'.format(windowName)), command=functools.partial(lcToolbox.lcTb_open_tool, 'lcToolbox', height, commandString)) lct_cfg.set(windowName + 'Pop', True) lct_cfg.set('lcToolboxHeight', conf['height']) lct_cfg.set('lcToolboxCurrentTool', '') pm.window('lcToolbox', edit=True, h=toolboxHeight)
def customLightFiltersNew(self, attr): pm.rowLayout(numberOfColumns=3, adjustableColumn=2, rowAttach=(1, "top", 0), columnWidth=[(1, 140), (2, 180)]) pm.text(label="") pm.columnLayout(adjustableColumn=True, columnAttach=("both", 0), rowSpacing=5) uiName = '%s_aiFilter'%(self.nodeType()) self.scrollList = pm.textScrollList(uiName, height=150, ams=False, sc=self.lightFilterListChanged, dcc=self.updateCustomLightFiltersNew) pm.rowLayout(numberOfColumns=2, columnWidth2=(80,80), columnAttach2=("both", "both"), columnAlign2=("center", "center"), columnOffset2=(2, 2)) pm.button('lf_add_button', label="Add", c=Callback(self.addLightFilterWin)) pm.button('lf_remove_button', label="Disconnect", c=Callback(self.removeLightFilter)) # implicit end of row layout pm.setParent('..') # back to column layout pm.setParent('..') # back to row layout pm.columnLayout(adjustableColumn=True, columnAttach=("both", 0), rowSpacing=5) pm.symbolButton('lf_move_up_button', image='arrowUp.xpm', c=Callback(self.moveLightFilterUp)) pm.symbolButton('lf_move_down_button', image='arrowDown.xpm', c=Callback(self.moveLightFilterDown)) pm.setParent('..') pm.setParent('..') self.addOptionMenuGrp = pm.optionMenuGrp('lf_add_menu', label='Add', changeCommand=self.addLightFilterCB) self.addOptionMenu = self.addOptionMenuGrp + '|OptionMenu' self.lightFiltersUpdateList() self.updateAddMenu()
def componentsListRebuild(self, node): if node.passType.get() == 2: self.componentsButton = pm.button(label="Add Component", c=pm.Callback( self.showComponentList, node), parent=self.uiParent) componentString = node.components.get() if componentString is None or len(componentString) == 0: return pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) with pm.frameLayout(labelVisible=False, collapsable=False, w=240, parent=self.uiParent) as self.componentsListUI: with pm.rowColumnLayout(nc=2, cw=((1, 200), (2, 30))): for c in componentString.split(","): pm.text(label=c, align="right") pm.symbolButton(image="smallTrash.png", c=pm.Callback(self.removeComponent, node, c)) pm.setUITemplate("attributeEditorTemplate", popTemplate=True)
def new(self, plug): plug = pm.Attribute(plug) with pm.ui.UITemplate("attributeEditorTemplate"): with pm.rowLayout(numberOfColumns=3, adjustableColumn=2) as self._coordsysLayout: if not self.attr.label: label = pm.interToUI(self.attr.longname) else: label = self.attr.label pm.text(label=label, annotation=self.attr.help) self._coordsys = pm.textField(annotation=help) self._browserButton = pm.symbolButton(image="coordsys.png", annotation=self.attr.help) self._popupMenu = pm.popupMenu(parent=self._browserButton, button=1) self.replace(str(plug))
def UI(self): width = 410 height = 210 # create window if pm.window( 'ehm_Colorize_UI', exists=True ): pm.deleteUI( 'ehm_Colorize_UI' ) pm.window( 'ehm_Colorize_UI', title='change color', w=width, h=height, mxb=False, mnb=False, sizeable=False ) # main layout mainLayout = pm.columnLayout(w=width, h=height) formLayout = pm.formLayout(w=width-10, h=height-10) frameLayout = pm.frameLayout(borderStyle='etchedIn', labelVisible=False) # left column and form pm.setParent( formLayout ) buttonsLayout = pm.rowColumnLayout( nc=8 ) # find color icons iconPath = os.path.join ( ehsan_script_directory, 'ui', 'icons' ) icons = os.listdir( iconPath ) colorIcons=[] for icon in icons: if 'color_' in icon: colorIcons.append( icon ) # button for icon in colorIcons: colorCode = int( icon.partition('.')[0].partition('_')[2] ) pm.symbolButton( image=os.path.join(iconPath,icon), w=50, h=50, c=partial( self.colorize, None, colorCode ) ) # show window pm.showWindow( 'ehm_Colorize_UI' )
def TheaTranslatorCreateTab(self): log.debug("TheaTranslatorCreateTab()") self.createGlobalsNode() parentForm = pm.setParent(query = True) pm.setUITemplate("attributeEditorTemplate", pushTemplate = True) scLo = self.rendererName + "TrScrollLayout" with pm.scrollLayout(scLo, horizontalScrollBarThickness = 0): with pm.columnLayout(self.rendererName + "TrColumnLayout", adjustableColumn = True, width = 400): with pm.frameLayout(label="Translator", collapsable = True, collapse=False): attr = pm.Attribute(self.renderGlobalsNodeName + ".translatorVerbosity") ui = pm.attrEnumOptionMenuGrp(label = "Translator Verbosity", at=self.renderGlobalsNodeName + ".translatorVerbosity", ei = self.getEnumList(attr)) with pm.frameLayout(label="Thea XML export", collapsable = True, collapse=False): ui = pm.checkBoxGrp(label="Export scene XML file:", value1 = False) pm.connectControl(ui, self.renderGlobalsNodeName + ".exportXMLFile", index = 2 ) xmlDict = {} self.rendererTabUiDict['xml'] = xmlDict with pm.rowColumnLayout(nc=3, width = 120): pm.text(label="XMLFileName:", width = 60, align="right") defaultXMLPath = pm.workspace.path + "/" + pm.sceneName().basename().split(".")[0] + ".Thea" xmlDict['xmlFile'] = pm.textField(text = defaultXMLPath, width = 60) pm.symbolButton(image="navButtonBrowse.png", c=self.xmlFileBrowse) pm.connectControl(xmlDict['xmlFile'], self.renderGlobalsNodeName + ".exportXMLFileName", index = 2 ) with pm.frameLayout(label="Optimize Textures", collapsable = True, collapse=False): with pm.rowColumnLayout(nc=3, width = 120): optiDict = {} pm.text(label="OptimizedTex Dir:", width = 60, align="right") self.rendererTabUiDict['opti'] = optiDict pm.symbolButton(image="navButtonBrowse.png", c=self.dirBrowse) optiDict['optiField'] = pm.textField(text = self.renderGlobalsNode.optimizedTexturePath.get(), width = 60) pm.connectControl(optiDict['optiField'], self.renderGlobalsNodeName + ".optimizedTexturePath", index = 2 ) with pm.frameLayout(label="Additional Settings", collapsable = True, collapse=False): ui = pm.floatFieldGrp(label="Scene scale:", value1 = 1.0, numberOfFields = 1) pm.connectControl(ui, self.renderGlobalsNodeName + ".sceneScale", index = 2 ) pm.setUITemplate("attributeEditorTemplate", popTemplate = True) pm.formLayout(parentForm, edit = True, attachForm = [ (scLo, "top", 0), (scLo, "bottom", 0), (scLo, "left", 0), (scLo, "right", 0) ])
def asset_widget(self, current_parent, asset_name): ''' Single asset widget. ''' self.main = pm.frameLayout(labelVisible=False, parent=current_parent) self.form = pm.formLayout() self.image_name = (self.asset_name+'.jpg') self.scene_name = pm.sceneName() # Creating Components self.asset_image = pm.symbolButton(image=self.image_name, width=48, height=48) self.asset_text = pm.text(height=48, width=125, align='left', label=asset_name) self.asset_low = pm.button(height=26, width=60, label='Low', command=pm.Callback(self.reference_asset, 'low')) self.asset_med = pm.button(height=26, width=60, label='Med', command=pm.Callback(self.reference_asset, 'medium')) self.asset_high = pm.button(height=26, width=60, label='Hi', command=pm.Callback(self.reference_asset, 'high')) # Positioning Components. # Symbol Button self.form.attachForm(self.asset_image, 'top', 5) self.form.attachForm(self.asset_image, 'left', 5) # asset text self.form.attachForm(self.asset_text, 'top', 5) self.form.attachForm(self.asset_low, 'top', 15) self.form.attachForm(self.asset_med, 'top', 15) self.form.attachForm(self.asset_high, 'top', 15) self.form.attachControl(self.asset_text, 'left', 15, self.asset_image) # form.attachControl(asset_text, 'right', 5, asset_low) self.form.attachControl(self.asset_low, 'left', 5, self.asset_text) self.form.attachControl(self.asset_med, 'left', 5, self.asset_low) self.form.attachControl(self.asset_high, 'left', 5, self.asset_med) self.form.attachForm(self.asset_high, 'right', 5) self.form.attachForm(self.asset_image, 'bottom', 5) # res buttons # Return parent to orginal layout pm.setParent(current_parent)
def uiContents_tab2(): with pm.frameLayout(l='2. Joint Chain Rig', cll=True, mw=3, mh=3 ): with pm.columnLayout(adj=True): with pm.rowLayout(nc=5): pm.text(l='Select Joint Chain : ', w= labelWidth, align='right') pm.button( l='Select', w=80, c=pm.Callback( jnt.findJointChain ) ) pm.separator( h=8, style='in') with pm.rowLayout(nc=5, ann=u'연이은 조인트들을 선택하고 실행. \n원하는헤어시스템이나 뉴클리어스 노드가 존재하면 함께 선택할것'): pm.text(l='Rig Hair Jiggle Joint Chain : ', w= labelWidth, align='right') pm.button( l='Non Stretch', w=80, c=pm.Callback( btn_hairJiggle, stretchable=False ) ) pm.button( l='Stretch', w=80, c=pm.Callback( btn_hairJiggle, stretchable=True ) ) with pm.frameLayout(l='3. Simulation', cll=True, mw=3, mh=3 ): with pm.columnLayout(adj=True): with pm.rowLayout(nc=5): pm.text(l='Selection : \n( Please select a joint in Chain ) ', w= labelWidth, align='right') with pm.rowColumnLayout(nc=2): pm.button(l='HairSystem', c=pm.Callback( jnt.findHairSystem ), w=80) pm.button(l='Nucleus', c=pm.Callback( jnt.findNucleus ), w=80) pm.button(l='Follicle', c=pm.Callback( jnt.findFollicle )) pm.button(l='ikHandle', c=pm.Callback( jnt.findIKHandle )) pm.button(l='splineIKCurve', c=pm.Callback( jnt.findSplineIKCrv )) pm.button(l='Dynamic Curve', c=pm.Callback( jnt.findDynamicCurve )) pm.button(l='JointChain', c=pm.Callback( jnt.findJointChain )) pm.separator( h=8, style='in') with pm.rowLayout(nc=5): pm.text(l='Interactive Playback : ', w= labelWidth, align='right') #pm.button( l='>>', w=160, c=pm.Callback( pm.mel.InteractivePlayback ) ) # interactivePlayback.png widget['playButton'] = pm.symbolButton( image='interactivePlayback.png', w=32, h=32, c=pm.Callback( btn_play ) ) with pm.rowLayout(nc=5): pm.text(l='Bake Simulation : ', w= labelWidth, align='right') pm.button( l='Open UI..', w=160, c=pm.Callback( pm.mel.BakeSimulationOptions ) )
def lcUVToolsUI(dockable=False, asChildLayout=False, *args, **kwargs): ''' ''' global lct_cfg global prefix global height windowName = 'lcUVTools' shelfCommand = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()'.format( windowName, prefix) commandString = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)'.format( windowName, prefix) icon = os.path.join(basePath, 'lcUVTools.png') if pm.window(windowName, ex=True): pm.deleteUI(windowName) if not asChildLayout: lcUI.UI.lcToolbox_child_popout(prefix + '_columnLayout_main', windowName, height, commandString, iconPath, lct_cfg) mainWindow = lcUI.lcWindow(prefix=prefix, windowName=windowName, width=width, height=height, icon=icon, shelfCommand=shelfCommand, annotation=annotation, dockable=dockable, menuBar=True) mainWindow.create() # column for the uv tool bar pm.columnLayout(prefix + '_columnLayout_main') # build ui in parts # Row 1 - basic pm.rowColumnLayout(nc=4, cw=[(1, 95), (2, 35), (3, 35), (4, 35)]) pm.columnLayout() pm.checkBox( prefix + '_checkBox_shell', l=' Shell Mode', v=False, changeCommand=lambda *args: lct_cfg.set( 'lcUVToolsShell', pm.checkBox(prefix + '_checkBox_shell', query=True, v=True))) pm.button(l='Grab Shell', bgc=colorWheel.getNext(), h=20, w=93, command=lambda *args: lcGeometry.UV().grabShell()) pm.setParent('..') pm.symbolButton(image=os.path.join(srcPath, 'icons', 'temp.png'), enable=False, visible=False) button_snapshot = pm.symbolButton(image='polyUVSnapshot.png', annotation='Take UV Snapshot', command=lambda *args: uvmp_uv_snapshot()) popup_snapshot = pm.popupMenu(parent=button_snapshot) pm.menuItem( prefix + '_checkBox_antiAlias', l='Antialias', checkBox=False, parent=popup_snapshot, command=lambda *args: lct_cfg.set( 'lcUVToolsAntialias', pm.menuItem( prefix + '_checkBox_antiAlias', query=True, checkBox=True))) pm.menuItem( prefix + '_checkBox_openPS', l='Auto Open PS', checkBox=True, parent=popup_snapshot, command=lambda *args: lct_cfg.set( 'lcUVToolsOpenPS', pm.menuItem(prefix + '_checkBox_openPS', query=True, checkBox=True) )) pm.symbolButton(image='textureEditor.png', annotation='Open the UV Editor', command=lambda *args: pm.mel.eval('TextureViewWindow')) # pm.text(l='') pm.setParent(prefix + '_columnLayout_main') # Row 2 pm.separator(style='in', h=10, w=200) row2 = pm.rowColumnLayout(nc=3, cw=[(1, 66), (2, 66), (3, 66)]) ##MOVE pm.columnLayout() pm.text(l='Move', w=66, align='center') pm.separator(style='none', h=9) bgc = colorWheel.getNext() pm.rowColumnLayout(nc=3, cw=[(1, 15), (2, 34), (3, 15)]) pm.text(l='') pm.button( l='^', h=15, bgc=bgc, command=lambda *args: uvmp_move( [0, 1 * pm.floatField(prefix + '_move_value', q=True, v=True)])) pm.text(l='') pm.button( l='<', bgc=bgc, command=lambda *args: uvmp_move( [-1 * pm.floatField(prefix + '_move_value', q=True, v=True), 0])) pm.floatField(prefix + '_move_value', h=34, v=1.00, pre=2) pm.button( l='>', bgc=bgc, command=lambda *args: uvmp_move( [1 * pm.floatField(prefix + '_move_value', q=True, v=True), 0])) pm.text(l='') pm.button( l='v', h=15, bgc=bgc, command=lambda *args: uvmp_move( [0, -1 * pm.floatField(prefix + '_move_value', q=True, v=True)])) pm.text(l='') pm.setParent(row2) ##SCALE pm.columnLayout() pm.text(l='Scale', w=66, align='center') pm.separator(style='none', h=4) bgc = colorWheel.getNext() pm.rowColumnLayout(nc=3, cw=[(1, 25), (2, 14), (3, 25)]) pm.button('U+', bgc=bgc, c=lambda *args: uvmp_scale( [pm.floatField(prefix + '_scale_value', q=True, v=True), 1])) pm.button('+', bgc=bgc, c=lambda *args: uvmp_scale([ pm.floatField(prefix + '_scale_value', q=True, v=True), pm.floatField(prefix + '_scale_value', q=True, v=True) ])) pm.button( 'V+', bgc=bgc, c=lambda *args: uvmp_scale( [1, pm.floatField(prefix + '_scale_value', q=True, v=True)])) pm.setParent('..') pm.rowColumnLayout(nc=3, cw=[(1, 13), (2, 38), (3, 13)]) pm.text(l='') pm.floatField(prefix + '_scale_value', v=2.00, min=1.0, pre=2, h=25) pm.text(l='') pm.setParent('..') pm.rowColumnLayout(nc=3, cw=[(1, 25), (2, 14), (3, 25)]) pm.button( 'U-', bgc=bgc, c=lambda *args: uvmp_scale([ pm.floatField(prefix + '_scale_value', q=True, v=True) / pow( pm.floatField(prefix + '_scale_value', q=True, v=True), 2), 1 ])) # x/(x^2) pm.button( '-', bgc=bgc, c=lambda *args: uvmp_scale([ pm.floatField(prefix + '_scale_value', q=True, v=True) / pow( pm.floatField(prefix + '_scale_value', q=True, v=True), 2), pm.floatField(prefix + '_scale_value', q=True, v=True) / pow( pm.floatField(prefix + '_scale_value', q=True, v=True), 2) ])) # x/(x^2) pm.button( 'V-', bgc=bgc, c=lambda *args: uvmp_scale([ 1, pm.floatField(prefix + '_scale_value', q=True, v=True) / pow( pm.floatField(prefix + '_scale_value', q=True, v=True), 2) ])) # x/(x^2) pm.setParent(row2) ##ROTATE pm.columnLayout() pm.text(l='Rotate', w=66, align='center') pm.separator(h=2) bgc = colorWheel.getNext() pm.rowColumnLayout(nc=2, cw=[(1, 16), (2, 48)]) pm.columnLayout() pm.button(prefix + '_clockwise', l='>', bgc=bgc, w=15, h=20, c=lambda *args: uvmp_rotate(-pm.floatField( prefix + '_rotate_value', q=True, v=True))) pm.button(prefix + '_counter_clockwise', l='<', bgc=bgc, w=15, h=20, c=lambda *args: uvmp_rotate( pm.floatField(prefix + '_rotate_value', q=True, v=True))) pm.setParent('..') pm.floatField(prefix + '_rotate_value', v=45.00, pre=2, h=40) pm.setParent('..') pm.floatSlider(prefix + '_rotate_free', min=-1, max=1, v=0, w=64, dc=uvmp_rotate_interactive, cc=uvmp_reset_slider) pm.button(l='align', bgc=bgc, w=65, h=20, command=lambda *args: uvmp_align_cardinal()) pm.setParent(prefix + '_columnLayout_main') # Row 3 pm.separator(style='in', h=10, w=200) row3 = pm.rowColumnLayout(nc=2, cw=[(1, 100), (2, 100)]) uvmp_texture_range_UI() pm.setParent(row3) ##TOOLS pm.gridLayout(nrc=[2, 2], cwh=[48, 48]) pm.symbolButton(image='expandContainer.png', bgc=(0.25, 0.5, 0.25), command=lambda *args: uvmp_split_edges_at_UVs(), annotation='Enter UV Unfold') pm.symbolButton(image='collapseContainer.png', bgc=(0.5, 0.25, 0.25), command=lambda *args: uvmp_merge_special(), annotation='Exit UV Unfold') pm.symbolButton(image='polyMapCut.png', command=lambda *args: uvmp_cut_edge(), annotation='Cut UV Edge') pm.symbolButton(image='textureEditorUnfoldUVsLarge.png', command=lambda *args: uvmp_auto_layout(), annotation='Auto UV Layout') pm.setParent(prefix + '_columnLayout_main') # #Row 4 # pm.separator(style='in', h=10, w=200) # pm.rowColumnLayout(nc=2, cw=[(1,100), (2,100)]) # pm.setParent(prefix+'_columnLayout_main') # if not asChildLayout: mainWindow.show() pm.window(mainWindow.mainWindow, edit=True, h=height, w=width) else: pm.setParent('..') pm.setParent('..') # edit menus optionsMenu, helpMenu = lcUI.UI.lcToolbox_child_menu_edit( asChildLayout, windowName) # restore interface selections pm.checkBox(prefix + '_checkBox_shell', edit=True, value=lct_cfg.get('lcUVToolsShell')) # extra stuff pm.setFocus( prefix + '_move_value' ) # set cursor focus on move value, otherwise it sets to first available ui element lcPlugin.Plugin.reload_plugin(plugin='Unfold3D', autoload=True)
def __init__(self): self.directory = "%s/nwModularRiggingTool" %pm.internalVar(userScriptDir = True) self.previousBlueprintListEntry = None self.previousBlueprintModule = None self.previousAnimationModule = None #baseIconsDir = "%s/Icons/" %self.directory baseIconsDir = "%s/Icons/" %os.environ["RIGGING_TOOL_ROOT"] self.selectedCharacter = self.FindSelectedCharacter() if self.selectedCharacter == None: return self.characterName = self.selectedCharacter.partition("__")[2] self.windowName = "%s_window" %self.characterName # Create UI self.UIElements = {} if pm.window(self.windowName, exists = True): pm.deleteUI(self.windowName) self.windowWidth = 420 self.windowHeight = 730 self.frameColumnHeight = 125 self.UIElements["window"] = pm.window(self.windowName, width = self.windowWidth, height = self.windowHeight, title = "Animation UI: %s" %self.characterName, sizeable = False) self.UIElements["topColumnLayout"] = pm.columnLayout(adjustableColumn = True, rowSpacing = 3, parent = self.UIElements["window"]) buttonWidth = 32 columnOffset = 5 buttonColumnWidth = buttonWidth + (2 * columnOffset) textScrollWidth = (self.windowWidth - buttonColumnWidth - 8) / 2 self.UIElements["listboxRowLayout"] = pm.rowLayout(numberOfColumns = 3, columnWidth3 = [textScrollWidth, textScrollWidth, buttonColumnWidth], columnAttach = ([1, "both", columnOffset], [2, "both", columnOffset], [3, "both", columnOffset]), parent = self.UIElements["topColumnLayout"]) self.UIElements["blueprintModule_textScroll"] = pm.textScrollList(numberOfRows = 12, allowMultiSelection = False, selectCommand = self.RefreshAnimationModuleList, parent = self.UIElements["listboxRowLayout"]) self.InitializeBlueprintModuleList() self.UIElements["animationModule_textScroll"] = pm.textScrollList(numberOfRows = 12, allowMultiSelection = False, selectCommand = self.SetupModuleSpecificControls, parent = self.UIElements["listboxRowLayout"]) self.UIElements["buttonColumnLayout"] = pm.columnLayout(parent = self.UIElements["listboxRowLayout"]) self.UIElements["pinButton"] = pm.symbolCheckBox(onImage = "%s_pinned.xpm" %baseIconsDir, offImage = "%s_unpinned.xpm" %baseIconsDir, width = buttonWidth, height = buttonWidth, onCommand = self.DeleteScriptJob, offCommand = self.SetupScriptjob, parent = self.UIElements["buttonColumnLayout"]) if pm.objExists("%s:non_blueprint_grp" %self.selectedCharacter): value = pm.getAttr("%s:non_blueprint_grp.display" %self.selectedCharacter) self.UIElements["non_blueprintVisibility"] = pm.symbolCheckBox(image = "%s_shelf_character.xpm" %baseIconsDir, value = value, width = buttonWidth, height = buttonWidth, onCommand = self.ToggleNonBlueprintVisibility, offCommand = self.ToggleNonBlueprintVisibility, parent = self.UIElements["buttonColumnLayout"]) value = pm.getAttr("%s:character_grp.animationControlVisibility" %self.selectedCharacter) self.UIElements["animControlVisibility"] = pm.symbolCheckBox(image = "%s_visibility.xpm" %baseIconsDir, value = value, width = buttonWidth, height = buttonWidth, onCommand = self.ToggleAnimControlVisibility, offCommand = self.ToggleAnimControlVisibility, parent = self.UIElements["buttonColumnLayout"]) self.UIElements["deleteModuleButton"] = pm.symbolButton(image = "%s_shelf_delete.xpm" %baseIconsDir, width = buttonWidth, height = buttonWidth, enable = False, command = self.DeleteSelectedModule, parent = self.UIElements["buttonColumnLayout"]) self.UIElements["duplicateModuleButton"] = pm.symbolButton(image = "%s_duplicate.xpm" %baseIconsDir, width = buttonWidth, height = buttonWidth, enable = False, parent = self.UIElements["buttonColumnLayout"]) pm.separator(style = "in", parent = self.UIElements["topColumnLayout"]) self.UIElements["activeModuleColumn"] = pm.columnLayout(adjustableColumn = True, parent = self.UIElements["topColumnLayout"]) self.SetupActiveModuleControls() pm.separator(style = "in", parent = self.UIElements["topColumnLayout"]) self.UIElements["matchingButton"] = pm.button(label = "Match Controls to Result", enable = False, parent = self.UIElements["topColumnLayout"]) pm.separator(style = "in", parent = self.UIElements["topColumnLayout"]) pm.rowColumnLayout("module_rowColumn", numberOfRows = 1, rowAttach = [1, "both", 0], rowHeight = [1, self.windowHeight - 395], parent = self.UIElements["topColumnLayout"]) self.UIElements["moduleSpecificControlsScroll"] = pm.scrollLayout(width = self.windowWidth + 10, horizontalScrollBarThickness = 0, parent = "module_rowColumn") self.UIElements["moduleSpecificControlsColumn"] = pm.columnLayout(columnWidth = self.windowWidth, columnAttach = ["both", 5], parent = self.UIElements["moduleSpecificControlsScroll"]) self.RefreshAnimationModuleList() self.SetupScriptjob() pm.showWindow(self.UIElements["window"]) self.SelectionChanged()
wind = pm.window( 'TheRiggersToolkitX',t = 'RigToolkitX',w=300,h=330,s=1,bgc = [(.17),(.18),(.19)]) Tab = tabLayout('Tabs',p='TheRiggersToolkitX',tc =1,stb=1,snt=1,ntc = 'NewTab()') ToolsSc = pm.scrollLayout('Controls',p='Tabs',w=300,h=330) channelbox = pm.channelBox('ChannelBox',p = 'Tabs',ac = [(.8),(.9),(1)],bc = [(.3),(.3),(.3)],ekf =1,fw=150,hlc=[(.2),(.6),(.4)],hol =1,ln=1,nn=0,m=1,pre = 5,) out = pm.formLayout('Outliner',p='Tabs',w=300,h=330) outpanel = pm.outlinerPanel(p = 'Outliner') ToolsSc = pm.scrollLayout('Tools',p='Tabs') SkinSc= pm.scrollLayout('Skin',p='Tabs') ScriptEdt = pm.scrollLayout('MelCmd',p='Tabs') MiscSc = pm.scrollLayout('Misc',p='Tabs') cmdShll = cmds.cmdShell(p='MelCmd',w=290,h=260 , bgc = [(.17),(.18),(.19)]) clearBtn = pm.symbolButton('minusBtn',p = 'MelCmd',i = 'clearAll.png',w = 285,h=43,ebg =1 , bgc = [(.1),(.11),(.11)],en = 1,command=('cmds.cmdShell(\"' + cmdShll + '\", edit=True, clear=True)' )) ControlsForm = pm.formLayout( 'ControlsForm',p='Controls') ToolsForm = pm.formLayout('ToolkitForm',p='Tools') SkinForm = pm.formLayout('SkinForm',p='Skin') MiscForm = pm.formLayout('MiscForm',p='Misc') GlobalName = pm.textField('Globalfield', w = 270 , h=25 ,pht = 'Name for Ctrls or Attrs',p = 'ControlsForm',bgc = [(.17),(.18),(.19)]) BaseCtlBtn = pm.iconTextButton('ControlBase',style='iconAndTextHorizontal', image1='polyColorSetEditor.png', label='Control Class',p = 'ControlsForm',w=130,h=40, bgc = [(.3),(.5),(.5)]) BaseCtlShapeBtn = pm.iconTextButton('ControlShape',style='iconAndTextHorizontal', image1='fluidCreate3D.png', label='Control Shape',p = 'ControlsForm',w=130,h=40, bgc = [(.3),(.5),(.5)]) Border01Btn = pm.button('Border01',l = '',p = 'ControlsForm',w= 260,h = 60,en=0) CtrlSizeText = pm.iconTextButton('Sizetxt',style='iconAndTextHorizontal',image1='StandinShelf.png',l = 'SHAPE SIZE',p = 'ControlsForm',w = 105,h=40, bgc = [(.2),(.3),(.3)],en = 1)
def show( self ): try: pm.deleteUI( self.__name__ ) except: pass self.win = pm.window( self.__name__ ) self.win.setTitle( self._title ) self.win.setWidthHeight( (150,300) ) pm.menuBarLayout() pm.menu( label='File' ) pm.menuItem( label='Import...', command=self._import ) pm.menuItem( label='Export Pose...', command=self._exportPose ) pm.menuItem( label='Export Group...', command=self._exportGroup ) pm.menu( label='Edit' ) pm.menuItem( label='New Pose', command=lambda *args: self._newPose() ) pm.menuItem( label='New Group', command=lambda *args: self._newGroup() ) pm.menuItem(divider=True) pm.menuItem( label='Rename Selected Pose', command=lambda *args: self._renamePose() ) pm.menuItem( label='Delete Selected Pose', command=lambda *args: self._deletePose() ) pm.menuItem(divider=True) pm.menuItem( label='Rename Current Group', command=lambda *args: self._renameGroup() ) pm.menuItem( label='Delete Current Group', command=lambda *args: self._deleteGroup() ) pm.menuItem( label='Clear Current Group', command=lambda *args: self._clearGroup() ) pm.menu( label='Help', helpMenu=True ) pm.menuItem( label='About...' ) self.mainForm = pm.formLayout( numberOfDivisions=100 ) self.namespaceCol = pm.rowColumnLayout( numberOfColumns=2, columnAttach=[(1,"both",0),(2,"both",0)], columnAlign=[(2,"right"),], columnWidth=[(1,30),(2,125)] ) self.namespacePM = pm.popupMenu( button=1, parent=self.namespaceCol, postMenuCommand=pm.Callback( self._updateNamespacePopupList ) ) pm.symbolButton( image='pickMenuIcon.xpm' ) self.namespaceTF = pm.textField( editable=False ) pm.setParent( self.mainForm ) self.optionMenuCol = pm.columnLayout( adjustableColumn=True, rowSpacing=0, columnAttach=( 'both', 0 ), columnAlign='right' ) pm.setParent( self.mainForm ) self.poseListTSL = pm.textScrollList( allowMultiSelection=False, doubleClickCommand=pm.Callback( self._applyPose ), selectCommand=pm.Callback( self._setGlobalPose ), deleteKeyCommand=pm.Callback( self._deletePose ) ) self.radMenu = pm.popupMenu( markingMenu=True ) pm.menuItem( label='New Pose...', radialPosition='N', command=lambda *args: self._newPose() ) pm.menuItem( label='Apply', radialPosition='W', command=lambda *args: self._applyPose() ) pm.menuItem( label='Rename Pose...', radialPosition='S', command=lambda *args: self._renamePose() ) pm.menuItem( label='Delete Pose', radialPosition='SE', command=lambda *args: self._deletePose() ) pm.menuItem( label='New Group', command=lambda *args: self._newGroup() ) pm.menuItem( divider=True ) pm.menuItem( label='Rename Current Group', command=lambda *args: self._renameGroup() ) pm.menuItem( label='Delete Current Group', command=lambda *args: self._deleteGroup() ) pm.menuItem( label='Clear Current Group', command=lambda *args: self._clearGroup() ) pm.menuItem( divider=True ) self._updateGroupList() self._updatePoseList() self._updateNamespaceList() self.mainForm.attachForm( self.optionMenuCol, 'top', 4 ) self.mainForm.attachForm( self.optionMenuCol, 'left', 2 ) self.mainForm.attachForm( self.optionMenuCol, 'right', 2 ) self.mainForm.attachNone( self.optionMenuCol, 'bottom' ) self.mainForm.attachControl( self.poseListTSL, 'top', 4, self.optionMenuCol) self.mainForm.attachForm( self.poseListTSL, 'left', 2 ) self.mainForm.attachForm( self.poseListTSL, 'right', 2 ) self.mainForm.attachControl( self.poseListTSL, 'bottom', 4, self.namespaceCol ) self.mainForm.attachNone( self.namespaceCol, 'top' ) self.mainForm.attachForm( self.namespaceCol, 'left', 2 ) self.mainForm.attachForm( self.namespaceCol, 'right', 2 ) self.mainForm.attachForm( self.namespaceCol, 'bottom', 4 ) self.win.show() pm.scriptJob( replacePrevious=1, parent=self.__name__, event=['SceneOpened', pm.Callback(self._updateNamespaceList) ] )
def lcRetopoBasicUI(dockable=False, asChildLayout=False, *args, **kwargs): """ """ global lct_cfg global prefix ci = 0 # color index iterator windowName = 'lcRetopoBasic' shelfCommand = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()'.format( windowName, prefix) commandString = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)'.format( windowName, prefix) icon = os.path.join(basePath, 'lcRetopoBasic.png') winWidth = 205 winHeight = height if pm.window(windowName, ex=True): pm.deleteUI(windowName) if not asChildLayout: lcUI.UI.lcToolbox_child_popout(prefix + '_columnLayout_main', windowName, height, commandString, iconPath, lct_cfg) mainWindow = lcUI.lcWindow(prefix=prefix, windowName=windowName, width=winWidth, height=winHeight, icon=icon, shelfCommand=shelfCommand, annotation=annotation, dockable=dockable, menuBar=True) mainWindow.create() pm.columnLayout(prefix + '_columnLayout_main') # SETUP pm.button(l='Setup for Retopo', bgc=colorWheel.getColorRGB(ci), w=200, h=25, annotation='Setup a high res mesh for retopology', command=lambda *args: rtb_setup_live_mesh(highresListDropdown)) ci += 1 # List pm.rowColumnLayout(nc=3, cw=([1, 25], [2, 150], [3, 25])) pm.symbolButton( h=25, image=os.path.join(iconPath, 'reloadMeshList.png'), annotation='Reload the list of high res meshes', command=lambda *args: rtb_highres_list_populate(highresListDropdown)) highresListDropdown = pm.optionMenu( prefix + '_optionMenu_highres_list', w=150, h=23, bgc=[0.5, 0.5, 0.5], annotation='List of high res meshes in the scene') highresListDropdown.changeCommand( lambda *args: rtb_choose_active(highresListDropdown)) remove_mesh_button = pm.symbolButton( h=25, image=os.path.join(iconPath, 'removeMeshFromList.png'), annotation= 'Remove current high res mesh from the list and return it to a normal state', command=lambda *args: rtb_remove(highresListDropdown)) popup_remove_mesh = pm.popupMenu(parent=remove_mesh_button) pm.menuItem(l='Remove all live meshes', parent=popup_remove_mesh, command=lambda *args: rtb_remove_all(highresListDropdown)) pm.setParent(prefix + '_columnLayout_main') # Scale pm.rowColumnLayout(nc=4, cw=([1, 50], [2, 100], [3, 25], [4, 25])) pm.picture(prefix + '_picture_layer_mesh', image=os.path.join(iconPath, 'meshLayering.png'), annotation='Drag slider to change mesh layering') pm.floatSlider( prefix + '_floatSlider_layer_mesh', h=25, step=0.01, min=0, max=1, v=lct_cfg.get('lcRetopoBasicLayering'), dragCommand=lambda *args: rtb_scale_layer_mesh(highresListDropdown)) button_xray = pm.symbolButton( prefix + '_symbolButton_xray', h=25, image=os.path.join(iconPath, 'toggleXray.png'), bgc=[0.27, 0.27, 0.27], annotation='Toggle Mesh X-Ray', command=lambda *args: rtb_toggle_xray(highresListDropdown, 'active')) popup_xray = pm.popupMenu(parent=button_xray) pm.menuItem(l='xRay on/off all', parent=popup_xray, command=lambda *args: rtb_toggle_xray(highresListDropdown)) button_hide = pm.symbolButton( prefix + '_symbolButton_hide', h=25, image=os.path.join(iconPath, 'hideMesh.png'), bgc=[0.27, 0.27, 0.27], annotation='Hide/Show Current High-Res', command=lambda *args: rtb_toggle_hide(highresListDropdown, 'active')) popup_hide = pm.popupMenu(parent=button_hide) pm.menuItem( l='Hide/Show all', parent=popup_hide, command=lambda *args: rtb_toggle_hide(highresListDropdown, 'all')) pm.menuItem( l='Hide/Show others', parent=popup_hide, command=lambda *args: rtb_toggle_hide(highresListDropdown, 'others')) pm.setParent(prefix + '_columnLayout_main') # Shader pm.rowColumnLayout(nc=3, cw=([1, 50], [2, 100], [3, 50])) pm.picture(image=os.path.join(iconPath, 'shaderOpacity.png'), enable=False, annotation='Drag slider to change shader transparency') pm.floatSlider(prefix + '_floatSlider_topo_trans', h=25, step=0.1, min=0, max=1, v=lct_cfg.get('lcRetopoBasicShader'), dragCommand=lambda *args: rtb_update_topo_transparency()) pm.symbolButton( h=25, image=os.path.join(iconPath, 'assignShader.png'), bgc=[0.27, 0.27, 0.27], annotation= 'Create and/or assign a semi-transparent shader to selected low res mesh', command=lambda *args: rtb_create_retopo_shader()) pm.setParent(prefix + '_columnLayout_main') pm.separator(style='in', h=5) # Relax and Shrinkwrap pm.rowColumnLayout(nc=2) pm.button( l='Relax', bgc=colorWheel.getColorRGB(ci), w=100, h=25, annotation='Relax selected verts and shrink-wrap them to the live mesh', command=lambda *args: rtb_vert_ops(highresListDropdown, operation='relax')) ci += 1 pm.button(l='Shrink-Wrap', bgc=colorWheel.getColorRGB(ci), w=100, h=25, annotation='Shrink-wrap selected verts to the live mesh', command=lambda *args: rtb_vert_ops(highresListDropdown, operation='shrink')) ci += 1 pm.setParent(prefix + '_columnLayout_main') # PROG Bar pm.progressBar(prefix + '_progress_control', en=False, w=202, isInterruptable=True) pm.separator(style='in', h=5) # Tool List pm.gridLayout(nrc=[1, 5], cwh=[40, 40]) ##1 pm.symbolButton(prefix + '_symbolButton_select_mode', image='selectByComponent.png', c=lambda *args: rtb_toggle_select_mode(), annotation='Toggle Object/Component Modes') ##2 create_mesh = pm.symbolButton( image='polyCylinder.png', c=lambda *args: pm.polyCylinder( r=1, h=2, sx=8, sy=1, sz=1, ax=(0, 1, 0), rcp=0, cuv=3, ch=1), annotation='Create Poly Cylinder') popup_create_mesh = pm.popupMenu(parent=create_mesh) pm.menuItem(l='polyPlane', parent=popup_create_mesh, command=lambda *args: pm.polyPlane( w=2, h=2, sx=1, sy=1, ax=(0, 1, 0), cuv=2, ch=1)) pm.menuItem(l='polyCube', parent=popup_create_mesh, command=lambda *args: pm.polyCube( w=2, h=2, d=2, sx=1, sy=1, ax=(0, 1, 0), cuv=2, ch=1)) ##3 pm.symbolButton(image='polyUnite.png', command=lambda *args: lcGeometry.Geometry.merge_and_weld(), annotation='Combine and Weld') ##4 button_zeroX = pm.symbolButton(image=os.path.join(iconPath, 'zeroX.png'), command=lambda *args: rtb_zero('x'), annotation='Zero to world axis') popup_zeroX = pm.popupMenu(parent=button_zeroX) pm.menuItem(l='Zero X', parent=popup_zeroX, command=lambda *args: rtb_zero('x')) pm.menuItem(l='Zero Y', parent=popup_zeroX, command=lambda *args: rtb_zero('y')) pm.menuItem(l='Zero Z', parent=popup_zeroX, command=lambda *args: rtb_zero('z')) ##5 pm.symbolButton(image='modelToolkit.png', c=lambda *args: pm.mel.eval('ToggleModelingToolkit'), annotation='Modeling Toolkit') # if not asChildLayout: mainWindow.show() pm.window(mainWindow.mainWindow, edit=True, h=winHeight, w=winWidth) else: pm.setParent('..') pm.setParent('..') # edit menus optionsMenu, helpMenu = lcUI.UI.lcToolbox_child_menu_edit( asChildLayout, windowName) pm.menuItem(parent=optionsMenu, divider=True, dividerLabel=windowName) pm.menuItem(parent=optionsMenu, l='Remove all live meshes', command=lambda *args: rtb_remove_all(highresListDropdown)) # populate drowpdowns rtb_highres_list_populate(highresListDropdown) # restore interface selections highresListDropdown.setSelect(lct_cfg.get('lcRetopoBasicListItem')) rtb_choose_active(highresListDropdown) # vertex animation cache in viewport 2.0 must be disabled or the mesh will not update properly if pm.objExists('hardwareRenderingGlobals'): pm.PyNode('hardwareRenderingGlobals').vertexAnimationCache.set(0) rtb_init_select_mode() if not pm.scriptJob(ex=lct_cfg.get('lcRetopoBasicScriptJob') ) or lct_cfg.get('lcRetopoBasicScriptJob') == 0: jobNum = pm.scriptJob( e=["SelectModeChanged", lambda *args: rtb_init_select_mode()], protected=True) lct_cfg.set('lcRetopoBasicScriptJob', jobNum)
def __init__(self): # VAR SETUP# self.fileType = {0: "mayaAscii", 1: "mayaBinary"} self.filePath = os.path.abspath(cmds.file(q=True, sn=True)) self.origFolder = os.path.dirname(self.filePath) self.origFilename = self.filePath.split("/")[-2:][1].split(".")[0] self.username = gp.getuser() self.newFile = 0 self.folder_project = os.path.abspath(pm.workspace(q=True, rd=True)) self.shot = "_".join(self.folder_project.split(os.path.sep)[-2:][:-1]) self.folder_discipline = os.path.join("scenes", "model") self.optionalNote = "" self.versionOption_startup = 1 self._parseFileName() # UI SETUP# title = "AW_Save_Plus" self.go_green_cl = [0.1, 0.4, 0.2] self.title_blue_cl = [0.1, 0.15, 0.2] self.go_yellow_cl = [0.947, 0.638, 0.130] if pm.windowPref(title, q=True, ex=True): pm.windowPref(title, remove=True) if pm.window(title, q=True, ex=True): pm.deleteUI(title) self.window = pm.window(title, t=title, w=890, h=105) self.fl = pm.formLayout() self.title_tx = pm.symbolButton(image="save_105.png", w=105, h=105) self.col = pm.columnLayout(p=self.fl) pm.text(l="Saving to Directory:", fn="boldLabelFont") self._updateFile(False) self.filePath_tx = pm.text("filePath_tx", l=self.file) pm.text(l="") self.header = pm.text("header_tf", fn="boldLabelFont", l="Filename") self.origFile_om = wind.AW_optionMenu( label="", options=["Original Folder", "Auto-detect"], parent=self.col, cc=self._changeOrigFolder_om ) if self.newFile: self.origFile_om.setSelect(2) self.layout = pm.formLayout(nd=100) self.fileDescr_tf = pm.textField( "fileDescr_tf", text=self.fileDescr, p=self.layout, w=200, cc=self._changeFileDescr ) self.discipline_om = wind.AW_optionMenu( label="_", options=self.disciplines, parent=self.layout, cc=self._changeDiscipline ) self.spacer = pm.text(l="_v", p=self.layout, w=10) self.version_tf = pm.textField( "version_tf", text="%03d" % self.version, p=self.layout, w=30, cc=self._changeVersionNumber ) self.versionOptional_om = wind.AW_optionMenu( label="", options=[ "", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "y", "z", ], parent=self.layout, cc=self._changeVersionOptional_om, ) self.optionalNote_tf = pm.textField( "optionalNote_tf", text="(optional note)", p=self.layout, w=150, cc=self._changeOptionalNoteTx ) self.type = wind.AW_optionMenu(label="_", options=[".ma", ".mb"], parent=self.layout, cc=self._changeType_om) if self.initialFileType == "ma": self.type.setSelect(1) if self.initialFileType == "mb": self.type.setSelect(2) self.save_btn = pm.button(label="Save", command=self._save, h=20, bgc=self.go_yellow_cl) pm.formLayout( self.layout, e=True, af=[(self.fileDescr_tf, "left", 0), (self.spacer, "top", 5)], ac=[ (self.discipline_om.optionMenu, "left", 5, self.fileDescr_tf), (self.spacer, "left", 5, self.discipline_om.optionMenu), (self.version_tf, "left", 5, self.spacer), (self.versionOptional_om.optionMenu, "left", 5, self.version_tf), (self.optionalNote_tf, "left", 5, self.versionOptional_om.optionMenu), (self.type.optionMenu, "left", 5, self.optionalNote_tf), (self.save_btn, "left", 5, self.type.optionMenu), ], ) pm.formLayout(self.fl, e=True, af=[(self.col, "top", 10)], ac=[(self.col, "left", 10, self.title_tx)]) self._setVersionOption(self.versionOption_startup) self._getDiscipline() self._updateFilename() self._updateFilePathTx() self.window.show()
def __init__(self): #VAR SETUP# self.fileType={0:"mayaAscii", 1:"mayaBinary"} self.disciplines=['MDL','LAYOUT','ANIM','PREVIS','LGT','FX','MM','SHADING','TECHANIM','LOOKDEV','EXPORT','RP','RS','RB'] self.disciplineDirs={'MDL':'model','LAYOUT':'layout','ANIM':'anim','PREVIS':'previs','LGT':'lighting','LOOKDEV':'lighting','FX':'fx','MM':'matchmove','EXPORT':'export','SHADING':'shading','RP':'rigPuppet','RS':'rigSkeleton','RB':'rigBound','TECHANIM':'techAnim'} self.filePath = os.path.abspath( cmds.file(q=True, sn=True) ) self.origFolder = os.path.dirname(self.filePath) self.origFilename = self.filePath.split('/')[-2:][1].split('.')[0] self.username = gp.getuser() self.newFile=0 self.folder_project = os.path.abspath( pm.workspace( q=True, rd=True ) ) self.shot = '_'.join( self.folder_project.split( os.path.sep )[-2:][:-1] ) self.folder_discipline = os.path.join( 'scenes','model' ) self.optionalNote='' self.versionOption_startup=1 self._parseFileName() #UI SETUP# title='AW_Save_Plus' self.go_green_cl=[.1,.4,.2] self.title_blue_cl=[.1,.15,.2] self.go_yellow_cl=[0.947, 0.638, 0.130] if(pm.windowPref(title, q=True, ex=True)): pm.windowPref(title, remove=True) if(pm.window(title, q=True,ex=True)): pm.deleteUI(title) self.window = pm.window(title,t=title, w=890, h=105) self.fl = pm.formLayout() self.title_tx = pm.symbolButton(image='save_105.png', w=105, h=105) self.col = pm.columnLayout(p=self.fl) pm.text(l='Saving to Directory:', fn='boldLabelFont') self._updateFile(False) self.filePath_tx = pm.text('filePath_tx', l=self.file) pm.text(l='') self.header = pm.text('header_tf',fn='boldLabelFont', l='Filename') self.origFile_om = wind.AW_optionMenu(label='', options=['Original Folder', 'Auto-detect'], parent=self.col, cc=self._changeOrigFolder_om) if self.newFile: self.origFile_om.setSelect(2) self.layout = pm.formLayout(nd=100) self.fileDescr_tf = pm.textField('fileDescr_tf',text=self.fileDescr, p=self.layout, w=200, cc=self._changeFileDescr) self.discipline_om = wind.AW_optionMenu(label='_', options=self.disciplines, parent=self.layout, cc=self._changeDiscipline) self.spacer = pm.text(l='_v', p=self.layout,w=10) self.version_tf = pm.textField('version_tf',text='%03d'%self.version, p=self.layout, w=30, cc= self._changeVersionNumber) self.versionOptional_om = wind.AW_optionMenu(label='', options=['','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','x','y','z'], parent=self.layout, cc=self._changeVersionOptional_om) self.optionalNote_tf = pm.textField('optionalNote_tf', text='(optional note)', p=self.layout, w=150, cc=self._changeOptionalNoteTx) self.type = wind.AW_optionMenu(label='_', options=['.ma','.mb'], parent=self.layout, cc=self._changeType_om) if self.initialFileType=='ma': self.type.setSelect(1) if self.initialFileType=='mb': self.type.setSelect(2) self.save_btn = pm.button(label='Save', command=self._save,h=20, bgc=self.go_yellow_cl) pm.formLayout(self.layout, e=True, af=[(self.fileDescr_tf, 'left', 0), (self.spacer,'top',5)], ac=[(self.discipline_om.optionMenu, 'left',5, self.fileDescr_tf), (self.spacer, 'left',5, self.discipline_om.optionMenu), (self.version_tf, 'left',5, self.spacer), (self.versionOptional_om.optionMenu, 'left',5,self.version_tf), (self.optionalNote_tf, 'left',5,self.versionOptional_om.optionMenu), (self.type.optionMenu, 'left',5,self.optionalNote_tf), (self.save_btn, 'left',5,self.type.optionMenu)]) pm.formLayout(self.fl, e=True, af=[(self.col, 'top', 10)], ac=[(self.col, 'left',10, self.title_tx)]) self._setVersionOption(self.versionOption_startup) self._getDiscipline() self._updateFilename() self._updateFilePathTx() self.window.show()
def lcBatchBakeUI(dockable=False, asChildLayout=False, *args, **kwargs): ''' ''' global lct_cfg global prefix global defaultPath windowName = 'lcBatchBake' shelfCommand = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()'.format( windowName, prefix) commandString = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)'.format( windowName, prefix) icon = basePath + 'lcBatchBake.png' winWidth = 205 winHeight = 243 if pm.window(windowName, ex=True): pm.deleteUI(windowName) if not asChildLayout: lcUI.UI.lcToolbox_child_popout(prefix + '_columnLayout_main', windowName, height, commandString, iconPath, lct_cfg) mainWindow = lcUI.lcWindow(prefix=prefix, windowName=windowName, width=winWidth, height=winHeight, icon=icon, shelfCommand=shelfCommand, annotation=annotation, dockable=dockable, menuBar=True) mainWindow.create() # pm.columnLayout(prefix + '_columnLayout_main') # check for mental ray plugin mental_ray_available = lcPlugin.Plugin.reload_plugin(plugin='Mayatomr', autoload=True) if mental_ray_available: # pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100])) pm.button(l='Make Texture Set', bgc=colorWheel.getPrev(), w=100, h=35, annotation='Create a Texture bake set', command=lambda *args: lcBake_make_new_bake_set( bakeSetListDropdown, 'texture')) pm.button(l='Make Vertex Set', bgc=colorWheel.getPrev(), w=100, h=35, annotation='Create a Texture bake set', command=lambda *args: lcBake_make_new_bake_set( bakeSetListDropdown, 'vertex')) pm.setParent(prefix + '_columnLayout_main') # pm.rowColumnLayout(nc=3, cw=([1, 25], [2, 150], [3, 25])) pm.symbolButton(h=25, image=os.path.join(iconPath, 'reloadList.png'), annotation='Reload the bake set list', command=lambda *args: lcBake_populate_bake_set_list( bakeSetListDropdown)) bakeSetListDropdown = pm.optionMenu(prefix + '_optionMenu_bake_set_list', w=150, h=25, annotation='List of bake sets') bakeSetListDropdown.changeCommand( lambda *args: lcBake_choose_active(bakeSetListDropdown)) button_delete_sets = pm.symbolButton( h=25, image=os.path.join(iconPath, 'deleteItem.png'), annotation='Delete this bake set', command=lambda *args: lcBake_delete_current_bake_set( bakeSetListDropdown)) popup_delete_sets = pm.popupMenu(parent=button_delete_sets) pm.menuItem(l='Delete all bake sets', parent=popup_delete_sets, command=lambda *args: lcBake_delete_all_bake_sets( bakeSetListDropdown)) pm.setParent(prefix + '_columnLayout_main') # pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100])) #nc=3, cw=([1,50], [2,50], [3,100] ) ) pm.button(l='+ Add', bgc=colorWheel.getPrev(), w=100, h=25, annotation='Add geometry to bake set', command=lambda *args: lcBake_add_to_current_bake_set( bakeSetListDropdown)) # pm.button(l='- Rem', bgc=colorWheel.getPrev(), w=50, h=25, annotation='Remove geometry from bake set', command=lambda *args: lcBake_fake_command() ) # ci+=1 pm.button(l='Edit Options', bgc=colorWheel.getPrev(), w=100, h=25, annotation='Edit the bake set options', command=lambda *args: lcBake_show_bake_set_attrs( bakeSetListDropdown)) pm.setParent(prefix + '_columnLayout_main') # pm.rowColumnLayout(nc=2, cw=([1, 75], [2, 125])) pm.text(l='Bake Camera: ', al='right') cameraListDropdown = pm.optionMenu(prefix + '_optionMenu_camera_list', w=125, h=25, annotation='List of cameras') cameraListDropdown.changeCommand(lambda *args: lct_cfg.set( 'lcBatchBakeCamList', cameraListDropdown.getSelect())) pm.text(l='') pm.checkBox( prefix + '_checkBox_shadows', w=125, h=25, value=True, label='Shadows and AO?', annotation='Turn on to bake shadows and ambient occlusion', changeCommand=lambda *args: lct_cfg.set( 'lcBatchBakeShadows', pm.checkBox(prefix + '_checkBox_shadows', query=True, v=True))) pm.setParent(prefix + '_columnLayout_main') # pm.separator(style='none', h=10) lcUI.UI.lc_browse_field_button(width=200, textFieldName=prefix + '_textField_texture_path', lct_cfg=lct_cfg, configAttr='lcBatchBakePath', placeholderText=defaultPath, annotation='Choose an export directory') # pm.rowColumnLayout(nc=2, cw=([1,150], [2,50]) ) # pm.textField(prefix+'_textField_texture_path', tx=defaultPath, annotation='Output directory path', w=150, changeCommand=lambda *args: lct_cfg.set('lcBatchBakePath', pm.textField(prefix+'_textField_texture_path', query=True, tx=True))) # pm.button(prefix+'_button_browse_path', l='Browse', bgc=colorWheel.getPrev(), annotation='Choose a directory', w=50, command=lambda *args: lcBake_setExportPath() ) # ci+=1 pm.setParent(prefix + '_columnLayout_main') # pm.rowColumnLayout(nc=2, cw=([1, 150], [2, 50])) pm.button(l='Bake It !!', bgc=colorWheel.getPrev(), w=150, h=40, annotation='Bake to texture or vertex', command=lambda *args: lcBake_convert_lightmap( bakeSetListDropdown, cameraListDropdown)) pm.symbolButton(prefix + '_button_open_folder', bgc=(0.18, 0.18, 0.18), image=os.path.join(srcPath, 'icons', 'folder_med.png'), annotation='Open the export folder', command=lambda *args: lcBake_openExportPath()) # mental ray was not found! else: pm.text(l="Mental Ray plug-in not found", al='center', w=200, h=215, font='boldLabelFont') # if not asChildLayout: mainWindow.show() pm.window(mainWindow.mainWindow, edit=True, h=winHeight, w=winWidth) else: pm.setParent('..') pm.setParent('..') # if mental_ray_available: #edit menus optionsMenu, helpMenu = lcUI.UI.lcToolbox_child_menu_edit( asChildLayout, windowName) pm.menuItem(parent=optionsMenu, divider=True, dividerLabel=windowName) pm.menuItem(parent=optionsMenu, l='Delete All Bake Sets', command=lambda *args: lcBake_delete_all_bake_sets( bakeSetListDropdown)) #populate lists lcBake_populate_bake_set_list(bakeSetListDropdown) lcBake_populate_camera_list(cameraListDropdown) #Restore Interface Selections bakeSetListDropdown.setSelect(lct_cfg.get('lcBatchBakeSetList')) cameraListDropdown.setSelect(lct_cfg.get('lcBatchBakeCamList')) pm.checkBox(prefix + '_checkBox_shadows', edit=True, value=lct_cfg.get('lcBatchBakeShadows')) pm.textField(prefix + '_textField_texture_path', edit=True, text=lct_cfg.get('lcBatchBakePath')) #update interface highlighting if lct_cfg.get('lcBatchBakeSetList') > 1: lcBake_glow(bakeSetListDropdown) # validate export directory lcPath.Path.validatePathTextField(prefix + '_textField_texture_path', lct_cfg, 'lcBatchBakePath', defaultPath)
def sknTransferUI(): if pm.window('SkinTransfer', exists=True ): pm.deleteUI( 'SkinTransfer', window=True ) if pm.windowPref('SkinTransfer', exists=True ): pm.windowPref( 'SkinTransfer', r=True ) pm.window('SkinTransfer', title='Skin Transfer', iconName='Short Name', widthHeight=(336,150),s=0 ) form = pm.formLayout(numberOfDivisions=100,bgc =[(.294),(.294),(.294)]) source = pm.textField('sourcetxf',w=150,h=40) destination = pm.textScrollList('asd',h=40,w=150) sourceButton = pm.button(l='Source',w=150,bgc =[(.394),(.394),(.394)],c='sourceobjs()') destinationButton = pm.button(l='Destination',w=150,bgc =[(.394),(.394),(.394)],c='destinationObjs()') transfer = pm.button(l='Transfer',w=310,bgc =[(.2),(.5),(.4)],h=25,c='Transfer()') author = pm.symbolButton(i='UV_Freeze_Tool.png',c='author()') pm.formLayout(form,edit=True,attachForm=[ (source,'top',10), (destination,'top',11), (sourceButton,'top',60), (destinationButton,'top',60), (transfer,'top',91), (author,'top',120), (source,'left',12), (destination,'left',12), (sourceButton,'left',12), (destinationButton,'left',12), (transfer,'left',12), (author,'left',302), ], attachControl=[ (destination, 'left', 10, source), (sourceButton, 'bottom', 20, source), (destinationButton, 'left', 10, sourceButton), ] ) pm.showWindow('SkinTransfer')
import pymel.core as pm from pymel.core import * if window('TheRiggersToolkitX',ex=True): deleteUI('TheRiggersToolkitX') if window('ExamplaeWindow',ex=True): deleteUI('ExamplaeWindow') if pm.windowPref('TheRiggersToolkitX', exists=True ): pm.windowPref( 'TheRiggersToolkitX', r=1 ) template = uiTemplate('TheRiggersToolkitXtemplate', force=True) template.define(formLayout) wind = pm.window( 'TheRiggersToolkitX',t = 'RigToolkitX',w=300,h=330,s=1,bgc = [(.17),(.18),(.19)]) Tab = tabLayout('Tabs',p='TheRiggersToolkitX',tc =1,stb=1,snt=1,ntc = 'NewTab()') out = pm.formLayout('Outliner',p='Tabs',w=300,h=330) outpanel = pm.outlinerPanel(p = 'Outliner') outliner = pm.outlinerPanel(outpanel, query=True,outlinerEditor=True) pm.outlinerEditor( outliner, edit=True, mainListConnection='worldList', selectionConnection='modelList', showShapes=False, showReferenceNodes=False, showReferenceMembers=False, showAttributes=False, showConnected=False, showAnimCurvesOnly=False, autoExpand=False, showDagOnly=True, ignoreDagHierarchy=False, expandConnections=False, showNamespace=True, showCompounds=True, showNumericAttrsOnly=False, highlightActive=True, autoSelectNewObjects=False, doNotSelectNewObjects=False, transmitFilters=False, showSetMembers=True, setFilter='defaultSetFilter' ) pm.formLayout('Outliner',e =1,af=[(outpanel,'top',0),(outpanel,'left',0),(outpanel,'right',0),(outpanel,'bottom',0)]) channelbox = pm.channelBox('ChannelBox',p = 'Tabs',ac = [(.8),(.9),(1)],bc = [(.3),(.3),(.3)],ekf =1,fw=150,hlc=[(.2),(.6),(.4)],hol =1,ln=1,nn=0,m=1,pre = 5,) ScriptEdt = pm.scrollLayout('MelCmd',p='Tabs') pmhll = pm.cmdShell(p='MelCmd',w=290,h=260 , bgc = [(.17),(.18),(.19)]) clearBtn = pm.symbolButton('minusBtn',p = 'MelCmd',i = 'clearAll.png',w = 285,h=43,ebg =1 , bgc = [(.1),(.11),(.11)],en = 1,command=('cmds.cmdShell(\"' + cmdShll + '\", edit=True, clear=True)' )) pm.showWindow('TheRiggersToolkitX')
def rtb_glow(highresListDropdown, *args, **kwargs): ''' highlight dropdown list red if nothing is selected ''' global defaultString global lct_cfg rtb_update_high_res_shader(highresListDropdown) high = highresListDropdown.getValue() if high == defaultString: highresListDropdown.setBackgroundColor(colorWheel.darkgrey) pm.symbolButton(prefix + '_symbolButton_xray', edit=True, enableBackground=False, bgc=colorWheel.maya) pm.symbolButton(prefix + '_symbolButton_hide', edit=True, enableBackground=False, bgc=colorWheel.maya) else: highresListDropdown.setBackgroundColor(colorWheel.mayalight) high = pm.PyNode(high) vis = high.visibility.get() if not vis: pm.symbolButton(prefix + '_symbolButton_hide', edit=True, bgc=colorWheel.darkgrey) else: pm.symbolButton(prefix + '_symbolButton_hide', edit=True, enableBackground=False, bgc=colorWheel.maya) xRay = pm.displaySurface(high, query=True, xRay=True)[0] if xRay: pm.symbolButton(prefix + '_symbolButton_xray', edit=True, bgc=colorWheel.darkgrey) else: pm.symbolButton(prefix + '_symbolButton_xray', edit=True, enableBackground=False, bgc=colorWheel.maya)
def show(self, *args, **kwargs): ''' ''' width = 300 height = 200 if pm.window(self.name, ex=True): pm.deleteUI(self.name) self.window = pm.window(self.name, t=self.name, w=width, mxb=False, mnb=False, s=False, toolbox=True) pm.columnLayout('lcPrefs_column_main') pm.text(l='Maya Preferences', w=width, h=30, al='center', font='boldLabelFont') # Image Editing Applications # pm.text(l=' Image Editing Applications', font='boldLabelFont') pm.frameLayout(l='Image Editing Applications', w=width - 2) pm.separator(style='none', h=1) cw2 = 25 cw1 = width - cw2 - 4 ##Photoshop pm.text(l=' Photoshop (PSD) Files', w=width, al='left') pm.rowColumnLayout(nc=2, cw=([1, cw1], [2, cw2])) photoshop_dir = '' if pm.optionVar(query='PhotoshopDir') != 0: photoshop_dir = pm.optionVar(query='PhotoshopDir') pm.textField( 'lcPrefs_photosohp', w=cw2, text=photoshop_dir, changeCommand=lambda *args: self.browse_path('lcPrefs_photosohp')) pm.symbolButton( image='navButtonBrowse.png', w=cw2, command=lambda *args: self.browse_path('lcPrefs_photosohp', True)) pm.setParent('..') # pm.separator(style='none', h=10) ##Others pm.text(l=' Other Image Files', w=width, al='left') pm.rowColumnLayout(nc=2, cw=([1, cw1], [2, cw2])) edit_image_dir = '' if pm.optionVar(query='EditImageDir') != 0: edit_image_dir = pm.optionVar(query='EditImageDir') pm.textField( 'lcPrefs_image', w=cw2, text=edit_image_dir, changeCommand=lambda *args: self.browse_path('lcPrefs_image')) pm.symbolButton( image='navButtonBrowse.png', w=cw2, command=lambda *args: self.browse_path('lcPrefs_image', True)) pm.setParent('lcPrefs_column_main') # pm.separator(style='none', h=10) # Save and Close pm.separator(style='none', h=10) pm.button(l='Save and Close', w=width - 4, h=30, command=lambda *args: self.save_and_close()) self.window.show() pm.window(self.name, edit=True, w=width, h=height)
p='ControlsForm', w=105, h=40, bgc=[(.2), (.3), (.3)], en=1) intensityTxtFld = pm.floatField('intenTxf', min=.10, p='ControlsForm', v=.10, w=45, h=40, bgc=[(.17), (.18), (.19)]) plusBtn = pm.symbolButton('plusBtn', p='ControlsForm', i='UVTBAdd.png', w=40, h=40, ebg=1, bgc=[(.2), (.3), (.3)], en=1) minusBtn = pm.symbolButton('minusBtn', p='ControlsForm', i='UVTBRemove.png', w=40, h=40, ebg=1, bgc=[(.2), (.3), (.3)], en=1) pm.formLayout('ControlsForm', e=1, attachForm=[
def __init__(self): # Remove existing window if pm.window(GUIDE_UI_WINDOW_NAME, exists=True): print "deleting win" pm.deleteUI(GUIDE_UI_WINDOW_NAME) if pm.dockControl(GUIDE_DOCK_NAME, exists=True): print "deleting dock" pm.deleteUI(GUIDE_DOCK_NAME) panelWeight = 200 scrollHight = 600 # Create Window and main tab self.ui_window = pm.window(GUIDE_UI_WINDOW_NAME, width=panelWeight, title="Guide Tools", sizeable=True) self.ui_topLevelColumn = pm.columnLayout(adjustableColumn=True, columnAlign="center") # pm.columnLayout() pm.rowLayout(numberOfColumns=1, columnWidth=[(1, panelWeight)]) pm.button(label="Settings", w=panelWeight, h=30, bgc=[.042, .351, .615], command=partial(self.inspectSettings)) pm.setParent('..') pm.rowLayout(numberOfColumns=3, columnWidth=[(1, (panelWeight / 3) - 1), (2, (panelWeight / 3) - 1), (3, (panelWeight / 3) - 1)]) pm.button(label="Dupl.", w=(panelWeight / 3) - 1, h=23, bgc=[.311, .635, 0], command=partial(self.duplicate, False)) pm.button(label="Dupl. Sym", w=(panelWeight / 3) - 1, h=23, bgc=[.465, .785, .159], command=partial(self.duplicate, True)) pm.button(label="Extr. Ctl", w=(panelWeight / 3) - 1, h=23, bgc=[.835, .792, .042], command=partial(self.extractControls)) pm.setParent('..') pm.rowLayout(numberOfColumns=1, columnWidth=[(1, panelWeight)]) pm.button(label="Build from selection", w=panelWeight, h=30, bgc=[.912, .427, .176], command=partial(self.buildFromSelection)) pm.setParent('..') self.ui_tabs = pm.tabLayout(width=panelWeight, innerMarginWidth=5, innerMarginHeight=5) pm.tabLayout(self.ui_tabs, q=True, width=True) # self.ui_compColumn = pm.columnLayout(adj=True, rs=3) self.ui_compFrameLayout = pm.frameLayout(height=scrollHight, collapsable=False, borderVisible=False, labelVisible=False) self.ui_compList_Scroll = pm.scrollLayout(hst=0) self.ui_compList_column = pm.columnLayout(columnWidth=panelWeight, adj=True, rs=2) pm.separator() # List of components # doGrouping = 1 < len(shifter.COMPONENTS_DIRECTORIES.keys()) compDir = shifter.getComponentDirectories() trackLoadComponent = [] for path, comps in compDir.iteritems(): pm.text(align="center", label=os.path.basename(path)) pm.separator() for comp_name in comps: if comp_name in trackLoadComponent: pm.displayWarning( "Custom component name: %s, already in default components. Names should be unique. This component is not loaded" % comp_name) continue else: trackLoadComponent.append(comp_name) if not os.path.exists( os.path.join(path, comp_name, "__init__.py")): continue # module = __import__("mgear.maya.rig.component."+comp_name, globals(), locals(), ["*"], -1) module = shifter.importComponentGuide(comp_name) # print module # print dir(module) reload(module) image = os.path.join(path, comp_name, "icon.jpg") buttonSize = 25 textDesc = "Name: "+module.NAME+"\nType:: "+module.TYPE+"\n===========\nAuthor: "+module.AUTHOR+"\nWeb: "+module.URL+\ "\nEmail: "+module.EMAIL+"\n===========\nDescription:\n"+module.DESCRIPTION pm.rowLayout(numberOfColumns=2, columnWidth=([1, buttonSize]), adjustableColumn=2, columnAttach=([1, "both", 0], [2, "both", 5])) pm.symbolButton(ann=textDesc, width=buttonSize, height=buttonSize, bgc=[0, 0, 0], ebg=False, i=image, command=partial(self.drawComp, module.TYPE)) pm.columnLayout(columnAlign="center") pm.text(align="center", width=panelWeight * .6, label=module.TYPE, ann=textDesc, fn="plainLabelFont") pm.setParent(self.ui_compList_column) pm.separator() # Display the window pm.tabLayout(self.ui_tabs, edit=True, tabLabelIndex=([1, "Components"])) allowedAreas = ['right', 'left'] pm.dockControl(GUIDE_DOCK_NAME, area='right', content=self.ui_window, allowedArea=allowedAreas, width=panelWeight, s=True)
def _build_ik_tab(parent_layout): # Create column Layout for IK controls ik_tab_layout = pm.columnLayout('ikTab', adj=True, width=100) pm.gridLayout(numberOfColumns=3, cellWidth=72, cellHeight=126) # Flip robot base button pm.symbolButton(image='flipBaseIcon.png', command=mimic_utils.flip_robot_base, annotation='Changes IK solution by flipping robot\'s base') # Flip robot elbow button pm.symbolButton( image='flipElbowIcon.png', command=mimic_utils.flip_robot_elbow, annotation='Changes IK solution by flipping robot\'s elbow') # FLip robot wrist button pm.symbolButton( image='flipWristIcon.png', command=mimic_utils.flip_robot_wrist, annotation='Changes IK solution by flipping robot\'s wrist') pm.setParent(ik_tab_layout) # Set parent to IK tab column layout pm.gridLayout(numberOfColumns=2, cellWidth=108, cellHeight=52) # Invert Axis 4 button pm.symbolButton(image='flipA4Icon.png', command=pm.Callback(mimic_utils.invert_axis, 4), annotation='Inverts Axis 6 rotation +/- 360 degrees') # Invert Axis 6 button pm.symbolButton(image='flipA6Icon.png', command=pm.Callback(mimic_utils.invert_axis, 6), annotation='Inverts Axis 6 rotation +/- 360 degrees') pm.setParent(ik_tab_layout) # Set parent to IK tab column layout pm.separator(height=5, style='none') pm.separator(height=11, style='out') # Key Animation Tool checkbox pm.rowLayout(numberOfColumns=1) pm.checkBox('cb_keyToolCtrl', label="Key tool controller", annotation='If checked, Tool Controller\'s Translate ' \ 'and Rotate attributes will be keyed', value=1) pm.setParent(ik_tab_layout) # Set parent to IK tab column layout pm.separator(height=5, style='none') # Keyframe IK configuration button pm.button(label='Set IK Keyframe', command=mimic_utils.key_ik, annotation='Keyframes Robot\'s IK-FK hierarchy in IK mode:\n' \ 'target_CTRL:\n' \ ' ik = 1\n' \ ' visibility = 1\n' \ ' IK Solution 1, 2, and 3\n' \ 'a*FK_CTRL:\n' \ ' rotateX, Y, or Z\n' \ 'FK_CTRLS\n' \ ' visibility = 0') pm.setParent(parent_layout) return ik_tab_layout
def _build_fk_tab(parent_layout): # Create column Layout with embedded shelf layout in second tab fk_tab_layout = pm.columnLayout('fkTab', adjustableColumn=True) pm.separator(height=5, style='none') pm.gridLayout(numberOfColumns=3, numberOfRows=2, cellWidth=72, cellHeight=44) cmd_str = ('import pymel.core as pm; ' \ 'import mimic_utils; ' \ 'pm.setFocus("fkTab");') for i in range(6): axis = i + 1 sel_cmd_str = cmd_str + ' mimic_utils.select_fk_axis_handle({})' \ .format(axis) button_img = 'a{}FkIcon.png'.format(axis) button_ann = 'Selects Axis {} FK Controller'.format(axis) pm.symbolButton(image=button_img, command=sel_cmd_str, annotation=button_ann) pm.setParent('..') # UI spacing pm.separator(height=3, style='none') pm.separator(height=11, style='out') pm.rowLayout(numberOfColumns=7, adjustableColumn=7, columnAttach=(1, 'left', 3), columnWidth=[(1, 20), (2, 45), (3, 22), (4, 45), (5, 22), (6, 45)], height=20) pm.text(label='A1:') pm.textField("t_a1", font=FONT, rfc=pm.Callback(mimic_utils.select_fk_axis_handle, 1), changeCommand=pm.Callback(mimic_utils.set_axis, 1)) pm.text(label=' A2:') pm.textField("t_a2", font=FONT, rfc=pm.Callback(mimic_utils.select_fk_axis_handle, 2), changeCommand=pm.Callback(mimic_utils.set_axis, 2)) pm.text(label=' A3:') pm.textField("t_a3", font=FONT, rfc=pm.Callback(mimic_utils.select_fk_axis_handle, 3), changeCommand=pm.Callback(mimic_utils.set_axis, 3)) # UI spacing pm.text(label='') pm.setParent('..') pm.separator(height=2, style='none') pm.rowLayout(numberOfColumns=7, adjustableColumn=7, columnAttach=(1, 'left', 3), columnWidth=[(1, 20), (2, 45), (3, 22), (4, 45), (5, 22), (6, 45)], height=20) pm.text(label='A4:') pm.textField("t_a4", font=FONT, rfc=pm.Callback(mimic_utils.select_fk_axis_handle, 4), changeCommand=pm.Callback(mimic_utils.set_axis, 4)) pm.text(label=' A5:') pm.textField("t_a5", font=FONT, rfc=pm.Callback(mimic_utils.select_fk_axis_handle, 5), changeCommand=pm.Callback(mimic_utils.set_axis, 5)) pm.text(label=' A6:') pm.textField("t_a6", font=FONT, rfc=pm.Callback(mimic_utils.select_fk_axis_handle, 6), changeCommand=pm.Callback(mimic_utils.set_axis, 6)) # UI Spacing pm.text(label='') pm.setParent('..') pm.separator(height=7, style='none') # Get and set FK pose buttons pm.gridLayout(nc=2, cw=109, ch=25) pm.button(label="Get Pose", command=mimic_utils.get_fk_pose, annotation='Gets selected robot\'s current axis rotation ' \ 'values\nand prints them above') pm.button(label='Set Pose', command=mimic_utils.set_fk_pose, annotation='Sets selected robot\'s current axis rotation ' \ 'values\nto the input values above') pm.setParent('..') # Clear FK pose button pm.button(label='Clear', command=mimic_utils.clear_fk_pose_ui, annotation='Clears axis rotation input fields above') pm.separator(height=14, style='out') # Keyframe FK button pm.button(label="Set FK Keyframe", command=mimic_utils.key_fk, backgroundColor=[.7, .7, .7], annotation='Keyframes Robot\'s IK-FK hierarchy in FK mode:\n' \ 'target_CTRL:\n' \ ' ik = 0\n' \ ' visibility = 0\n' \ 'a*FK_CTRL:\n' \ ' rotateX, Y, or Z\n' \ 'FK_CTRLS\n' \ ' visibility = 1') pm.setParent(parent_layout) return fk_tab_layout
def _build_general_settings_tab(parent_layout): # Create column Layout for General settings general_settings_tab_layout = pm.columnLayout('generalSettings', adj=True, width=100) pm.separator(height=3, style='none') pm.rowLayout(numberOfColumns=3, columnWidth3=(55, 250, 30), adjustableColumn=2, columnAlign=[(1, 'left'), (2, 'left')], columnAttach=[(1, 'both', -1), (2, 'both', 0), (3, 'both', 0)]) pm.text(label="Directory:") pm.textField('t_programDirectoryText', text='', ed=False, font=FONT) pm.symbolButton('b_directoryImage', image="setDirectory_icon.png", width=32, height=20, command=mimic_utils.set_program_dir) pm.setParent('..') pm.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAttach=(1, 'left', -1), columnWidth=[(1, 90), (2, 100)], height=20) pm.text(label='Output name:') pm.textField('t_outputFileName', text=postproc_config.DEFAULT_OUTPUT_NAME, font=FONT) pm.setParent('..') pm.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAttach=(1, 'left', -1), columnWidth=[(1, 90), (2, 100)], height=20) pm.text(label='Template name:') pm.textField('t_templateFileName', text=postproc_config.DEFAULT_TEMPLATE_NAME, font=FONT) pm.setParent('..') # Sample rate radio buttons pm.separator(height=3, style='none') selected_units = postproc_config.DEFAULT_SAMPLE_RATE_UNITS selected_value = postproc_config.DEFAULT_SAMPLE_RATE_VALUE radio_indent = 3 pm.radioCollection('sample_rate_radio_collection') pm.rowLayout(numberOfColumns=3, adjustableColumn=3, columnAttach=(1, 'left', radio_indent), columnWidth=[(1, 90), (2, 45)], height=20) pm.radioButton('rb_timeInterval', label='Sample rate:', select=True) pm.textField('t_timeBetweenSamples', text=selected_value, font=FONT) pm.radioButtonGrp( 'time_unit_radio_group', labelArray2=['s', 'f'], annotation='Sample rate units: seconds or frames', numberOfRadioButtons=2, columnWidth2=[32, 30], select=1 if selected_units == 'seconds' else 2) # 1-based integer pm.setParent('..') pm.rowLayout(numberOfColumns=1, adjustableColumn=1, columnAttach=(1, 'left', radio_indent), height=20) pm.radioButton('rb_keyframesOnly', label='Sample keyframes only', enable=True) pm.setParent('..') pm.rowLayout(numberOfColumns=3, adjustableColumn=3, columnAttach=(1, 'left', -1), columnWidth=[(1, 132), (2, 40), (3, 30)], height=20) pm.text(label='Animation frame range:') pm.intField("i_programStartFrame", value=pm.playbackOptions(animationStartTime=True, query=True), minValue=-10, maxValue=100000, step=1) pm.intField("i_programEndFrame", value=pm.playbackOptions(animationEndTime=True, query=True), minValue=-10, maxValue=100000, step=1) pm.setParent('..') pm.separator(height=5, style='none') # Post processor option menu list pm.optionMenu('postProcessorList', label='Processor:', height=18, changeCommand=postproc_options.overwrite_options) # Get supported post-processors and fill option menu list supported_post_processors = postproc_setup.get_processor_names() for post in supported_post_processors: pm.menuItem(label=post) pm.separator(height=3, style='none') pm.setParent(parent_layout) return general_settings_tab_layout
pm.window("zenWindow", t="Zen Remember", resizeToFitChildren=True, s=True) zForm = pm.formLayout() zTabs = pm.tabLayout() pm.formLayout(zForm, edit=True, attachForm=[(zTabs, "top", 5), (zTabs, "bottom", 5), (zTabs, "left", 5), (zTabs, "right", 5)]) crtPose_layout = pm.columnLayout() poseShelf = pm.shelfLayout(w=400, h=550) #Images must have exact naming convention as they show in icons folder crtPose_body = pm.symbolButton(image="zenRemember_bodyIcon.png", w=150, h=150, c="saveToTab_body(bodyShelf)") crtPose_facial = pm.symbolButton(image="zenRemember_faceIcon.png", w=150, h=150, c="saveToTab_face(faceShelf)") crtPose_arm = pm.symbolButton(image="zenRemember_armsIcon.png", w=150, h=150, c="saveToTab_arm(armShelf)") crtPose_hands = pm.symbolButton(image="zenRemember_handIcon.png", w=150, h=150, c="saveToTab_hand(handShelf)") crtPose_legs = pm.symbolButton(image="zenRemember_legsIcon.png", w=150,
def lcTb_open_tool(windowName, heightAdjust, commandString='', *args, **kwargs): ''' ''' prefix = conf['prefix'] if lcUtility.Utility.maya_version_check(): if pm.columnLayout(prefix + '_columLayout_holder', exists=True): pm.deleteUI(prefix + '_columLayout_holder') if pm.formLayout('fl_form', exists=True): pm.deleteUI('fl_form') if pm.columnLayout('fl_form_shelf', exists=True): pm.deleteUI('fl_form_shelf') if pm.columnLayout('fl_form_tool', exists=True): pm.deleteUI('fl_form_tool') pm.setParent(prefix + '_columnLayout_main') pm.columnLayout(prefix + '_columLayout_holder', rowSpacing=0) pm.formLayout('fl_form', numberOfDivisions=100) pm.picture('fl_form_header', image=os.path.join( iconPath, 'header_{}.png'.format(lct_conf['release']))) if lct_conf['release'] == 'dev': pm.symbolButton('fl_form_reload', image=os.path.join(iconPath, 'reload.png'), command=functools.partial( lcTb_open_tool_new_window, shelfCommand)) pm.columnLayout('fl_form_shelf') shelfHeight = 32 fl_flow_layout = pm.flowLayout(width=204, height=shelfHeight + 4, wrap=True, columnSpacing=0) # list published tools except lcToolbox toolList = lcUtility.Utility.buildPublishList(inline=False) toolCount = 0 for item in toolList: if item[0] != 'lcToolbox': toolCount = toolCount + 1 toolName = item[0] toolPrefix = item[1] toolAnnotation = item[2] toolHeight = int(item[5]) toolIcon = os.path.normpath( os.path.join(srcPath, toolName, toolName + '.png')) shelfIcon = os.path.normpath( os.path.join(srcPath, toolName, 'icons', toolName + '_shelf.png')) toolShelfCommand = "import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()".format( toolName, toolPrefix) toolExecString = unicode( "import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)" .format(toolName, toolPrefix)) toolButton = pm.symbolButton(prefix + '_' + toolName, image=toolIcon, annotation=toolAnnotation, command=functools.partial( lcTb_open_tool, windowName, toolHeight, toolExecString)) popup = pm.popupMenu(prefix + '_' + toolName + 'popup', parent=toolButton) pm.menuItem(l='Open in new window', parent=popup, command=functools.partial( lcTb_open_tool_new_window, toolShelfCommand)) pm.menuItem(l='Add to shelf', parent=popup, command=functools.partial( lcShelf.Shelf.makeShelfButton, toolName, toolShelfCommand, shelfIcon, toolAnnotation)) if pm.window( toolName, ex=True ): # if i have the tool window open seperately use the return arrow icon pm.symbolButton( prefix + '_' + toolName, edit=True, image=os.path.normpath( os.path.join(srcPath, toolName, 'icons', toolName + '_Return.png')), command=functools.partial(lcTb_open_tool, windowName, toolHeight, toolExecString)) # if i am loading a specific tool back into the window update its icon to standard if commandString and toolName in commandString: pm.symbolButton( toolButton, edit=True, image=os.path.normpath( os.path.join(srcPath, toolName, 'icons', toolName + '_Release.png')), command=functools.partial(lcTb_open_tool_new_window, toolShelfCommand)) rowCount = max(1, math.ceil(toolCount / 5.0)) shelfHeight = shelfHeight * rowCount + 4 pm.flowLayout(fl_flow_layout, edit=True, height=shelfHeight) pm.setParent('fl_form') fl_form_tool = pm.columnLayout('fl_form_tool', width=224, columnOffset=('left', 10)) pm.separator(style='double', h=5, w=205) if not commandString: pm.picture(image=os.path.join(iconPath, 'none.png')) else: exec commandString in locals() lct_cfg.set('lcToolboxCurrentTool', commandString) lct_cfg.set('lcToolboxHeight', heightAdjust) if lct_conf['release'] == 'dev': pm.formLayout('fl_form', edit=True, attachForm=[('fl_form_header', 'top', 0), ('fl_form_shelf', 'top', 54), ('fl_form_shelf', 'left', 25), ('fl_form_reload', 'top', 0), ('fl_form_reload', 'left', 103)], attachControl=[(fl_form_tool, 'top', 0, 'fl_form_shelf')]) else: pm.formLayout('fl_form', edit=True, attachForm=[('fl_form_header', 'top', 0), ('fl_form_shelf', 'top', 54), ('fl_form_shelf', 'left', 25)], attachControl=[(fl_form_tool, 'top', 0, 'fl_form_shelf')]) pm.setParent(prefix + '_columLayout_holder') pm.picture('fl_form_footer', image=os.path.join( iconPath, 'footer_{}.png'.format(lct_conf['release']))) pm.window(windowName, edit=True, height=heightAdjust + shelfHeight + 122) # +conf['height'])#, width=mainWindow.width) else: pm.separator(style='none', h=30) pm.text(l='Your Maya Version:', al='center', w=231, h=25, font='boldLabelFont') pm.text(l='{}'.format(versions.shortName()), al='center', w=231, h=10, font='boldLabelFont') pm.separator(style='none', h=10) pm.text( l='You must have\nMaya 2014 or greater\nto run the\nLEOCOV Toolbox', al='center', w=231, h=60, font='boldLabelFont') pm.window(windowName, edit=True, height=231)
def _build_program_tab(self, controller, tab_name, parent_layout, parent=None): """ """ # TO-DO: Break this into smaller utility functions # Strip "_CTRL" from transform name for tab name ctrl = controller.ctrl ctrl_name = str(ctrl) if not parent: program_tab_columnLayout = pm.columnLayout(tab_name, adj=True) else: program_tab_columnLayout = pm.columnLayout(tab_name, adj=True, parent=parent) ## CONNECT FRAME ## # Define dynamic names based on ctrl input motor_api_optionMenu_name = '{}{}'.format(ctrl_name, MOTOR_API_OPTIONMENU_EXT) device_name_optionMenu_name = '{}{}'.format( ctrl_name, DEVICE_NAME_OPTION_MENU_EXT) connect_frameLayout = pm.frameLayout(label='Connect') pm.columnLayout(adj=True) pm.separator(height=5, style='none') TEXT_COL_WIDTH = 63 # API Selector Row pm.rowLayout( numberOfColumns=2, # columnAttach=[1, 'left', 3], columnWidth=[1, TEXT_COL_WIDTH], adjustableColumn2=2) pm.text('Motor API:') motor_api_optionMenu = pm.optionMenu(motor_api_optionMenu_name) # Get supported Motor APIs from the config and assign them to the option menu supported_apis = mFIZ_config.SUPPORTED_MOTOR_APIS for api in supported_apis: pm.menuItem(api) pm.setParent('..') # Device Name Selector Row devices = serial_utils.get_device_names() pm.rowLayout(numberOfColumns=5, columnAttach=[2, 'right', 3], columnWidth=[1, TEXT_COL_WIDTH], adjustableColumn=2) pm.text('Serial Port:') device_name_optionMenu = pm.optionMenu(device_name_optionMenu_name) for device in devices: pm.menuItem(device, label=device) pm.symbolButton(image='refresh_icon.png', width=20, height=20, command=self._refresh_port_optionMenus) connection_icon = pm.symbolButton(image=CONNECTION_ICON_NAMES[0], width=20, height=20, command=pm.Callback( self.connect, tab_name)) connection_indicator_field = pm.textField( 'connection_indicator_field', editable=False, height=20, width=10, backgroundColor=CONNECTION_INDICATOR_COLORS[0]) pm.setParent('..') pm.separator(height=5, style='none') pm.setParent(program_tab_columnLayout) pm.separator(height=5, style='none') ## CONTROL FRAME ## # Define dynamic names based on ctrl input control_frameLayout = pm.frameLayout(label='Control') pm.columnLayout(adj=True) pm.separator(height=5, style='none') BUTTON_COL_WIDTH = 21 FIZ_CONTROL_COL_HEIGHT = 70 # Creat a row layout that will hold two columns # First column will have the main FIZ controls and the second column # Will hold the "Keyfram All" command fiz_controls_rowLayout = pm.rowLayout(numberOfColumns=2, columnAttach=[2, 'left', -5], rowAttach=[2, 'top', 0], adjustableColumn=1) fiz_controls_columnLayout_1 = pm.columnLayout(adj=True) attrs = ['focus', 'iris', 'zoom'] for attr in attrs: # Create row layout for attribute slider group and "set keyfram" button attr_abbrev = attr[0].capitalize() pm.rowLayout( numberOfColumns=2, #columnAttach=[2, 'right', 3], columnWidth=[2, BUTTON_COL_WIDTH], adjustableColumn=1) pm.attrFieldSliderGrp(tab_name + '_attrFieldSliderGrp_' + attr_abbrev, l=attr_abbrev, min=0, max=1, columnAlign=[1, 'center'], columnWidth3=[15, 50, 0], adjustableColumn=3, attribute='{}.{}'.format(ctrl, attr)) pm.symbolButton(image='set_keyframe_icon.png', command=pm.Callback(self._set_keyframe, [attr])) pm.setParent('..') pm.setParent(fiz_controls_rowLayout) # Key All button fiz_controls_columnLayout_2 = pm.columnLayout(adj=True, width=BUTTON_COL_WIDTH, columnAlign='left') pm.symbolButton(image='keyframe_all_icon.png', width=BUTTON_COL_WIDTH, height=FIZ_CONTROL_COL_HEIGHT, command=self._set_keyframe) pm.setParent(parent_layout) # Add an OpenMaya.MMessage attributeChanged callback to handle UI stat # if a device becomes connected/disconnected node_name = str(controller.node) self._add_attribute_changed_callback(node_name) ## Save the tab data to the self.controls_tab_data dict tab_data = CONTROLS_TAB_DATA(controller, connection_indicator_field, connection_icon, motor_api_optionMenu, device_name_optionMenu) self.controls_tab_data[tab_name] = { 'tab_data': tab_data, 'connected': False } return program_tab_columnLayout
def lcObjToolsUI(dockable=False, asChildLayout=False, *args, **kwargs): ''' ''' global lct_cfg global prefix ci = 0 #color index iterator windowName = 'lcObjTools' shelfCommand = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()'.format(windowName, prefix) commandString = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)'.format(windowName, prefix) icon = os.path.normpath(os.path.join(basePath, 'lcObjTools.png')) winWidth = 205 winHeight = 158 if pm.window(windowName, ex=True): pm.deleteUI(windowName) if not asChildLayout: lcUI.UI.lcToolbox_child_popout(prefix+'_columnLayout_main', windowName, height, commandString, iconPath, lct_cfg) mainWindow = lcUI.lcWindow(prefix=prefix, windowName=windowName, width=winWidth, height=winHeight, icon=icon, shelfCommand=shelfCommand, annotation=annotation, dockable=dockable, menuBar=True) mainWindow.create() # pm.columnLayout(prefix+'_columnLayout_main') # lcUI.UI.lc_browse_field_button(width=200, textFieldName=prefix+'_textField_export_path', lct_cfg=lct_cfg, configAttr='lcObjToolsPath', placeholderText=defaultPath, annotation='Choose an OBJ export directory', fileMask='Wavefront Obj (*.obj)') pm.setParent(prefix+'_columnLayout_main') # pm.checkBox(prefix+'_checkBox_export_indi', l='Export Individual', v=True, changeCommand=lambda *args: lct_cfg.set('lcObjToolsExportIndividual', pm.checkBox(prefix+'_checkBox_export_indi', query=True, v=True))) pm.checkBox(prefix+'_checkBox_use_smooth', l='Use Smooth Preview', v=True, changeCommand=lambda *args: lct_cfg.set('lcObjToolsUseSmoothPreview', pm.checkBox(prefix+'_checkBox_use_smooth', query=True, v=True))) # pm.rowColumnLayout(nc=2, cw=([1,100], [2,100]) ) pm.textField(prefix+'_textField_prefix', w=100, tx=' ', changeCommand=lambda *args: lct_cfg.set('lcObjToolsPrefix', pm.textField(prefix+'_textField_prefix', query=True, tx=True))) pm.text(l=' Prefix_', al='left') pm.setParent(prefix+'_columnLayout_main') # pm.rowColumnLayout(nc=2, cw=([1,166], [2,34]) ) pm.columnLayout(w=169) pm.button(prefix+'_button_export', l='Export OBJ', bgc=colorWheel.getColorRGB(ci), annotation='Export the selected geometry', w=166, h=30, command=lambda *args: lcObj_exportObjs() ) ci+=1 pm.button(prefix+'_button_Import', l='Import Multiple OBJs', bgc=colorWheel.getColorRGB(ci), annotation='Clean import more than one obj', w=166, h=20, command=lambda *args: lcObj_importMultiple() ) ci+=1 pm.setParent('..') pm.columnLayout(w=31) pm.symbolButton(prefix+'_button_open_folder', w=30, h=50, bgc=(0.18,0.18,0.18), image=os.path.join(srcPath, 'icons', 'folder_med.png'), annotation='Open the export folder', command=lambda *args: lcObj_open_file_path(pm.textField(prefix+'_textField_export_path', query=True, text=True) ) ) ci+=1 # if not asChildLayout: mainWindow.show() pm.window(mainWindow.mainWindow, edit=True, h=winHeight, w=winWidth) else: pm.setParent('..') pm.setParent('..') #edit menus optionsMenu, helpMenu = lcUI.UI.lcToolbox_child_menu_edit(asChildLayout, windowName) pm.menuItem(parent=optionsMenu, divider=True, dividerLabel=windowName) pm.menuItem(parent=optionsMenu, l="Offset External .obj's", command=lambda *args: lcObj_offsetMultiple() ) #restore interface selections pm.checkBox(prefix+'_checkBox_export_indi', edit=True, value=lct_cfg.get('lcObjToolsExportIndividual')) pm.checkBox(prefix+'_checkBox_use_smooth', edit=True, value=lct_cfg.get('lcObjToolsUseSmoothPreview')) pm.textField(prefix+'_textField_export_path', edit=True, text=lct_cfg.get('lcObjToolsPath')) pm.textField(prefix+'_textField_prefix', edit=True, text=lct_cfg.get('lcObjToolsPrefix')) #run extra stuff lcPlugin.Plugin.reload_plugin(plugin='objExport', autoload=True) # validate export directory lcPath.Path.validatePathTextField(prefix+'_textField_export_path', lct_cfg, 'lcObjToolsPath', defaultPath)
def set_ui_connection_state(self, tab_names=[], connected=None): """ """ tab_layout = self.controls_tab_layout # Check if the window attached to the object exists, # If not, delete the callbacks as they're unnecessary if not pm.layout(tab_layout, exists=True): # If the scriptJob still exists, delete the scriptJob if self.time_change_scriptJob_id: pm.evalDeferred( 'import pymel.core as pm; pm.scriptJob(kill={})'.format( self.time_change_scriptJob_id)) return # If no tab is passed, set the state of every tab # Check the connected state by querrying the tab's associated node state # This combonation should always be passed together, otherwise, a single # tab_name and single connceted state should be passed if not tab_names: tab_names = pm.tabLayout(tab_layout, query=True, tabLabel=True) if 'Setup' in tab_names: tab_names.remove('Setup') # Remove the setup tab for tab_name in tab_names: tab = self.controls_tab_data[tab_name] # If no connection state is passed, check the dataSent attribute on the # associated mFIZ node if connected is None: node = self.controls_tab_data[tab_name][ 'tab_data'].controller.node # Get attribute value using OpenMaya and not getAttr() as the latter # causes recursion problems with the callback in some Maya versions sel = OpenMaya.MSelectionList() sel.add(str(node)) obj = sel.getDependNode(0) node_state = OpenMaya.MFnDependencyNode(obj).findPlug( 'dataSent', True).asBool() else: node_state = connected # Get the current state of the tab tab_state = tab['connected'] # If the tab and note state are different, update the tab state if tab_state != node_state: # Set the connection state in the tab data dict tab['connected'] = node_state # Set the color of the connection indicator field connection_indicator_field = tab[ 'tab_data'].connection_indicator_field pm.textField( connection_indicator_field, edit=True, backgroundColor=CONNECTION_INDICATOR_COLORS[node_state]) # Set the connect/disconnect icon connection_icon = tab['tab_data'].connection_icon pm.symbolButton(connection_icon, edit=True, image=CONNECTION_ICON_NAMES[node_state]) # If the node is disconnected, refresh the list of devices to remove # disconnected devices if not node_state: self._refresh_port_optionMenus()
def build(self): self.build_menu_bar( ) # Form layout for rest of window self.__form = pmc.formLayout( ) # Buttons for quick access to things # TODO: Enable layer ordering btn_move_layer_up = pmc.symbolButton( image = 'moveLayerUp.png', annotation = 'Move Layer up', command = self.move_layer_up, enable = False ) btn_move_layer_down = pmc.symbolButton( image = 'moveLayerDown.png', annotation = 'Move Layer down', command = self.move_layer_down, enable = False ) btn_new_empty_layer = pmc.symbolButton( image = 'newLayerEmpty.png', annotation = 'New Empty Bake Layer', command = self.new_empty ) btn_new_selected_layer = pmc.symbolButton( image = 'newLayerSelected.png', annotation = 'New Bake Layer from Selection', command = self.new_selected ) pmc.setParent( self.__form ) self.__layer_tree = pmc.treeView( parent = self.__form, width = 350, abr = False, numberOfButtons = 3 ) pmc.treeView( self.__layer_tree, e = True, selectCommand = self.button_layer_select ) pmc.treeView( self.__layer_tree, e = True, elc = self.button_layer_editor_rename ) pmc.treeView( self.__layer_tree, e = True, pc = ( 1, self.button_type_change ) ) pmc.treeView( self.__layer_tree, e = True, pc = ( 2, self.button_connection_edit ) ) pmc.treeView( self.__layer_tree, e = True, pc = ( 3, self.button_quick_edit_window ) ) left_click_menu = pmc.popupMenu( button = 3, parent = self.__layer_tree ) pmc.treeView( self.__layer_tree, e = True, contextMenuCommand = pmc.CallbackWithArgs( self.show_left_click_menu, left_click_menu ) ) self.__form.attachForm( btn_new_selected_layer, 'top', 1 ) self.__form.attachForm( btn_new_selected_layer, 'right', 2 ) self.__form.attachNone( btn_new_selected_layer, 'bottom' ) self.__form.attachNone( btn_new_selected_layer, 'left' ) self.__form.attachForm( btn_new_empty_layer, 'top', 1 ) self.__form.attachControl( btn_new_empty_layer, 'right', 1, btn_new_selected_layer ) self.__form.attachNone( btn_new_empty_layer, 'bottom' ) self.__form.attachNone( btn_new_empty_layer, 'left' ) self.__form.attachForm( btn_move_layer_down, 'top', 1 ) self.__form.attachControl( btn_move_layer_down, 'right', 4, btn_new_empty_layer ) self.__form.attachNone( btn_move_layer_down, 'bottom' ) self.__form.attachNone( btn_move_layer_down, 'left' ) self.__form.attachForm( btn_move_layer_up, 'top', 1 ) self.__form.attachControl( btn_move_layer_up, 'right', 1, btn_move_layer_down ) self.__form.attachNone( btn_move_layer_up, 'bottom' ) self.__form.attachNone( btn_move_layer_up, 'left' ) self.__form.attachControl( self.__layer_tree, 'top', 1, btn_new_empty_layer ) self.__form.attachForm( self.__layer_tree, 'left', 0 ) self.__form.attachForm( self.__layer_tree, 'bottom', 0 ) self.__form.attachForm( self.__layer_tree, 'right', 0 )
def __init__(self): self.file_parser = FilenameParser() # UI SETUP# title = "AW_Save_Plus" self.go_green_cl = [0.1, 0.4, 0.2] self.title_blue_cl = [0.1, 0.15, 0.2] self.go_yellow_cl = [0.947, 0.638, 0.130] if pm.windowPref(title, q=True, ex=True): pm.windowPref(title, remove=True) if pm.window(title, q=True, ex=True): pm.deleteUI(title) self.window = pm.window(title, t=title, w=890, h=105) self.fl = pm.formLayout() self.title_tx = pm.symbolButton(image="save_105.png", w=105, h=105) self.col = pm.columnLayout(p=self.fl) pm.text(l="Saving to Directory:", fn="boldLabelFont") self._updateFile(False) self.filePath_tx = pm.text("filePath_tx", l=self.file) pm.text(l="") self.header = pm.text("header_tf", fn="boldLabelFont", l="Filename") self.origFile_om = wind.AW_optionMenu( label="", options=["Original Folder", "Auto-detect"], parent=self.col, cc=self._changeOrigFolder_om ) if self.newFile: self.origFile_om.setSelect(2) self.layout = pm.formLayout(nd=100) self.fileDescr_tf = pm.textField( "fileDescr_tf", text=self.file_descr, p=self.layout, w=200, cc=self._changeFileDescr ) self.discipline_om = wind.AW_optionMenu( label="_", options=self.disciplines, parent=self.layout, cc=self._changeDiscipline ) self.spacer = pm.text(l="_v", p=self.layout, w=10) self.version_tf = pm.textField( "version_tf", text="%03d" % self.version, p=self.layout, w=30, cc=self._changeVersionNumber ) self.versionOptional_om = wind.AW_optionMenu( label="", options=[""] + [chr for chr in string.ascii_lowercase], parent=self.layout, cc=self._changeVersionOptional_om, ) self.optionalNote_tf = pm.textField( "optionalNote_tf", text="(optional note)", p=self.layout, w=150, cc=self._changeOptionalNoteTx ) self.type = wind.AW_optionMenu(label="_", options=[".ma", ".mb"], parent=self.layout, cc=self._changeType_om) if self.initialFileType == "ma": self.type.setSelect(1) if self.initialFileType == "mb": self.type.setSelect(2) self.save_btn = pm.button(label="Save", command=self._save, h=20, bgc=self.go_yellow_cl) pm.formLayout( self.layout, e=True, af=[(self.fileDescr_tf, "left", 0), (self.spacer, "top", 5)], ac=[ (self.discipline_om.optionMenu, "left", 5, self.fileDescr_tf), (self.spacer, "left", 5, self.discipline_om.optionMenu), (self.version_tf, "left", 5, self.spacer), (self.versionOptional_om.optionMenu, "left", 5, self.version_tf), (self.optionalNote_tf, "left", 5, self.versionOptional_om.optionMenu), (self.type.optionMenu, "left", 5, self.optionalNote_tf), (self.save_btn, "left", 5, self.type.optionMenu), ], ) pm.formLayout(self.fl, e=True, af=[(self.col, "top", 10)], ac=[(self.col, "left", 10, self.title_tx)]) self._setVersionOption(self.versionOption_startup) self._getDiscipline() self._updateFilename() self._updateFilePathTx() self.window.show()