def retime(): # create window shatter = 'Shatter' try: cmds.deleteUI(shatter) except: pass window = cmds.window(shatter, title='Shatter Retime') # cmds.scrollLayout(horizontalScrollBarThickness=16, verticalScrollBarThickness=16, cr=True) cmds.columnLayout(adjustableColumn=True) sliders = [] # asset references row cmds.rowLayout(numberOfColumns=14, columnAlign=(1, 'center'), adj=6, columnAttach=[(1, 'left', 0), (2, 'right', 0)]) w = 70 ww = w - 20 cmds.text(l='REFERENCE:', al='left', w=80) cmds.text(l='Sim ', al='left', w=50) cmds.button(label=' Shatters ', c='import placeShatters as ps\nps.place()', w=ww) cmds.button(label=' Cloud ', c='import placeShatters as ps\nps.refCloud()', w=ww) cmds.button(label=' Wind ', c='import placeShatters as ps\nps.refWind()', w=ww) cmds.text(l=' Geo ', al='right') cmds.button(label=' Vl Cornhill ', c='import placeShatters as ps\nps.refValeCornhill()', w=w) cmds.button(label=' Tm Cornhill ', c='import placeShatters as ps\nps.refTomCornhill()', w=w) cmds.button(label=' Bengal ', c='import placeShatters as ps\nps.refBengal()', w=w) cmds.button(label=' Birchin ', c='import placeShatters as ps\nps.refBirchin()', w=w) cmds.text(l=' Full Setup ', al='right') cmds.button(label=' Vale Setup ', c='import placeShatters as ps\nps.refValeSetup()', w=w, ann='setup from 137_snd_2200') cmds.button(label=' Tom Setup ', c='import placeShatters as ps\nps.refTomSetup()', w=w, ann='setup from 137_snd_7300') cmds.setParent('..') cmds.separator(height=10, style='in') # vis settings cmds.rowLayout(numberOfColumns=8, columnAlign=(1, 'center'), adj=8, columnAttach=[(1, 'left', 0), (2, 'right', 0)]) w = 70 cmds.text(l='VISIBILITY:', al='left', w=80) cmds.text(l='Toggle ', al='left', w=50) cmds.button(label=' Puffs ', c='import placeShatters as ps\nps.togglePuffs()', w=ww) cmds.button(label=' Glass ', c='import placeShatters as ps\nps.toggleGlass()', w=ww) cmds.button(label=' Grains ', c='import placeShatters as ps\nps.toggleGrains()', w=ww) cmds.button(label=' Grains + ', c='import placeShatters as ps\nps.toggleDenseGrains()', w=ww) cmds.button(label=' Cracks ', c='import placeShatters as ps\nps.toggleCracks()', w=ww) cmds.setParent('..') cmds.separator(height=10, style='in') # selection offset cmds.rowLayout(numberOfColumns=13, columnAlign=(1, 'center'), adj=9, columnAttach=[(1, 'left', 0), (2, 'right', 0)]) w = 70 cmds.text(l='TIMING:', al='left', w=80) cmds.text(l='Shift cache of selected glass ', al='left', w=150) cmds.button(label=' <<< 10 ', c='import placeShatters as ps\nps.shiftSelected(v=-10)', w=w) cmds.button(label=' << 5 ', c='import placeShatters as ps\nps.shiftSelected(v=-5)', w=w) cmds.button(label=' < 1 ', c='import placeShatters as ps\nps.shiftSelected(v=-1)', w=w) cmds.button(label=' 1 > ', c='import placeShatters as ps\nps.shiftSelected(v=1)', w=w) cmds.button(label=' 5 >> ', c='import placeShatters as ps\nps.shiftSelected(v=5)', w=w) cmds.button(label=' 10 >>> ', c='import placeShatters as ps\nps.shiftSelected(v=10)', w=w) cmds.text(l=' Randomize ', al='right') cmds.button(label=' +/- ', c='import placeShatters as ps\nps.offsetRandom(rng=3)', w=w) cmds.text(l=' Glass Cracks Anim ', al='right') cmds.button(label=' Import ', c='import placeShatters as ps\nps.crackVisAnim(shift=10)', w=w) cmds.setParent('..') cmds.separator(height=10, style='in') cmds.scrollLayout(horizontalScrollBarThickness=16, verticalScrollBarThickness=16, cr=True, h=700) cmds.columnLayout(adjustableColumn=True) grey = [0.24, 0.24, 0.24] greyD = [0.23, 0.23, 0.23] bg = [grey, greyD] tgl = 0 # alembic section # get alembics from refs minV = cmds.playbackOptions(q=True, minTime=True) - 80 maxV = cmds.playbackOptions(q=True, maxTime=True) + 80 almb = cmds.ls(type='AlembicNode') almbShtr = [] for a in almb: if 'shatter__' in a: almbShtr.append(a) if almbShtr: for a in almbShtr: # row cmds.rowLayout(numberOfColumns=3, adjustableColumn=3, columnAlign=(1, 'left'), columnAttach=[(1, 'left', 0), (2, 'left', 0)]) # button conn = cmds.listConnections(a, s=0, d=1) cmd = None for c in conn: if cmds.nodeType(c) == 'transform': cmd = 'import maya.cmds as cmds\ncmds.select("%s")' % c cmdTgl = 'import maya.cmds as cmds\ncmds.select("%s", tgl=True)' % c if cmd: bgc = [0.32, 0.32, 0.32] cmds.button(label='select', c=cmd) cmds.button(label='toggle', c=cmdTgl) else: cmds.button(label='None') # slider group v = cmds.getAttr(a + '.offset') # print v attr = '%s.offset' % a sl = cmds.attrFieldSliderGrp(at=attr, label=a.split(':')[0], smn=minV, smx=maxV, fieldMinValue=0, fieldMaxValue=2000, ann=a, pre=3, s=1.0, adj=3, columnWidth3=(75, 75, 100), columnAlign=(1, 'left'), columnAttach=[(1, 'left', 0), (2, 'left', 0), (3, 'both', 0)]) # print sl sliders.append(sl) cmds.setParent('..') if tgl == 0: tgl = 1 else: tgl = 0 else: message('No shatter alembics found', warning=True) # show window cmds.showWindow(window)
def expose_component(self,tabAnchor,rootData): attrib_link = rootData[0] ctrlHgt = 24 nodeData = attrib_link.split('.') typeChk = mc.attributeQuery( nodeData[-1], node=nodeData[0], attributeType=True ) numericType = ['float','double','short','long','int','bool','enum','string'] clm = mc.columnLayout( adjustableColumn=True, rs=5 ,p=tabAnchor, w=420 -30 ) stringType = mc.getAttr(attrib_link,type=True) fildCaption = mc.textField( tx=rootData[1],ed=False,w=410 -30 ,p=clm , font="boldLabelFont",bgc=[0.8,0.8,0.8]) mc.popupMenu( button=3 ,p=fildCaption) mc.menuItem(l='Open in connection Editor' ) if stringType == 'string': attrFld = mc.textField( ed=True,w=410 -30 ,p=clm ) mc.connectControl( attrFld, attrib_link ) else: if typeChk in numericType: mc.attrFieldSliderGrp( attribute=rootData[0],p=clm ) else: flw = mc.flowLayout( columnSpacing=4 , p=clm ) fldLnk = mc.textField( tx=rootData[0],ed=False ,w=385,h=ctrlHgt,p=flw) mc.button( label='<',p=flw)
def update(self, *args): """ Sets the controls to selected object's setting """ try: shapes = cmds.ls(sl=True, o=True, dag=True, s=True) if len(shapes) > 0: self.shadEngine = str(cmds.listConnections(shapes, type="shadingEngine")[0]) # connected materials self.materials = str(cmds.ls(cmds.listConnections(self.shadEngine), materials=True)[0]) # check if connected material is a surface shader or Maya material if cmds.nodeType(self.materials) == "surfaceShader": wireframeColor = cmds.attrColorSliderGrp( "wireframeColor", edit=True, at=self.materials + ".outColor", sb=True ) wireColorSlider = cmds.attrColorSliderGrp( "wireColorSlider", edit=True, at=self.shadEngine + ".miContourColor" ) wirewidthControl = cmds.attrFieldSliderGrp( "wirewidthControl", edit=True, at=self.shadEngine + ".miContourWidth" ) else: wireframeColor = cmds.attrColorSliderGrp( "wireframeColor", edit=True, at=self.materials + ".color", sb=True ) wireColorSlider = cmds.attrColorSliderGrp( "wireColorSlider", edit=True, at=self.shadEngine + ".miContourColor" ) wirewidthControl = cmds.attrFieldSliderGrp( "wirewidthControl", edit=True, at=self.shadEngine + ".miContourWidth" ) except TypeError, UnboundLocalError: pass
def modeChanged(self, *args): try: if cmds.getAttr(self.nodeAttr('aiMode')) == 1: cmds.attrFieldSliderGrp("NurbsCurveTemplateMinPixelWidth", edit=True, enable=False) else: cmds.attrFieldSliderGrp("NurbsCurveTemplateMinPixelWidth", edit=True, enable=True) except RuntimeError: # this callback runs immediately, before NurbsCurveTemplateMinPixelWidth exists pass
def updateLightColorTemperatureUI(self, attrName): isEnabled = True isEnabled = cmds.getAttr(self.nodeAttr('aiUseColorTemperature')) aeUtils.attrBoolControlGrp(self.checkBoxName, edit=True, attribute=self.nodeAttr('aiUseColorTemperature'), changeCommand=self.updateUseColorTemperature) cmds.attrFieldSliderGrp(self.sliderName, edit=True, attribute=self.nodeAttr('aiColorTemperature'), enable=isEnabled, changeCommand=self.updateColorTemperature) colorTemp = cmds.arnoldTemperatureToColor(cmds.getAttr(self.nodeAttr('aiColorTemperature'))) cmds.canvas(self.canvasName, edit=True, rgbValue=colorTemp)
def setupActiveModuleControls(self): existingControls = cmds.columnLayout(self.UIElements['activeModuleColumn'],q=True, childArray=True) if existingControls != None: cmds.deleteUI(existingControls) cmds.setParent(self.UIElements['activeModuleColumn']) largeButtonSize = 100 enumOptionWidth = 2*largeButtonSize self.settingsLocator = self.selectedBlueprintModule + ':SETTINGS' activeModuleAttribute = self.settingsLocator + '.activeModule' currentEntries = cmds.attributeQuery('activeModule', n=self.settingsLocator, listEnum=True) enable = True if currentEntries[0] == 'None': enable = False self.UIElements['activeModule_rowLayout'] = cmds.rowLayout(nc=3, adjustableColumn=1, ct3=('both','both','both'),cw3=(enumOptionWidth, largeButtonSize, largeButtonSize)) attributes = cmds.listAttr(self.settingsLocator, keyable=False) weightAttributes = [] for attr in attributes: if attr.find('_weight') != -1: weightAttributes.append(attr) self.UIElements['activeModule'] = cmds.attrEnumOptionMenu(label='Active Module', width=enumOptionWidth, attribute=activeModuleAttribute, changeCommand=partial(self.activeModule_enumCallback, weightAttributes),enable=enable) self.UIElements['keyModuleWeights'] = cmds.button(label='Key All',c=partial(self.keyModuleWeights, weightAttributes),enable=enable) self.UIElements['graphModuleWeights'] = cmds.button(label='Graph Weights',c=self.graphModuleWeights,enable=enable) cmds.setParent(self.UIElements['activeModuleColumn']) #self.UIElements['moduleWeights_frameLayout'] = cmds.frameLayout(collapsable=True, collapse=False, label='Module Weights', height=100, collapseCommand=self.moduleWeights_UICollapse, expandCommand=self.moduleWeights_UIExpand) self.UIElements["moduleWeights_frameLayout"] = cmds.frameLayout(collapsable=True, collapse=False, label="Module Weights") cmds.scrollLayout(hst=0) cmds.columnLayout(adj=True) cmds.attrFieldSliderGrp(at=self.settingsLocator + '.creationPoseWeight', enable=False) cmds.separator() for attr in weightAttributes: self.UIElements[attr] = cmds.floatSliderGrp(label=attr, field=True, precision=4, minValue=0.0, maxValue=1.0, value=cmds.getAttr(self.settingsLocator + '.' + attr),cc=partial(self.moduleWeights_sliderCallback,attr, weightAttributes)) parentUIElement = self.UIElements['moduleWeights_frameLayout'] self.create_moduleWeightsScriptJob(parentUIElement, weightAttributes) self.moduleWeights_updateMatchingButton()
def setupActiveModuleControls(self): existingControls = cmds.columnLayout(self.UIElements["activeModuleColumn"], q=True, childArray=True) if existingControls != None: cmds.deleteUI(existingControls) cmds.setParent(self.UIElements["activeModuleColumn"]) largeButtonSize = 100 enumOptionWidth = self.windowWidth - 2*largeButtonSize self.settingsLocator = self.selectedBlueprintModule + ":SETTINGS" activeModuleAttribute = self.settingsLocator + ".activeModule" currentEntries = cmds.attributeQuery("activeModule", n=self.settingsLocator, listEnum=True) enable = True if currentEntries[0] == "None": enable=False self.UIElements["activeModule_rowLayout"] = cmds.rowLayout(nc=3, adjustableColumn=1, ct3=("both", "both", "both"), cw3= (enumOptionWidth, largeButtonSize, largeButtonSize)) attributes = cmds.listAttr(self.settingsLocator, keyable=False) weightAttributes = [] for attr in attributes: if attr.find("_weight") != -1: weightAttributes.append(attr) self.UIElements["activeModule"] = cmds.attrEnumOptionMenu(label="Active Module", width=enumOptionWidth, attribute=activeModuleAttribute, changeCommand=partial(self.activeModule_enumCallback, weightAttributes), enable=enable) self.UIElements["keyModuleWeights"] = cmds.button(label= "Key All", c=partial(self.keyModuleWeights, weightAttributes), annotation='Key Control Switching', enable=enable) self.UIElements["graphModuleWeights"] = cmds.button(label="Graph Weights", c=self.graphModuleWeights, enable=enable) cmds.setParent(self.UIElements["activeModuleColumn"]) self.UIElements["moduleWeights_frameLayout"] = cmds.frameLayout(collapsable=True, collapse=False, label="Module Weights", height=100, collapseCommand = self.moduleWeight_UICollapse, expandCommand=self.moduleWeight_UIExpand) cmds.scrollLayout(hst=0) cmds.columnLayout(adj=True) cmds.attrFieldSliderGrp(at=self.settingsLocator+".creationPoseWeight", enable=False) cmds.separator for attr in weightAttributes: self.UIElements[attr] = cmds.floatSliderGrp(label=attr, field=True, precision=4, minValue=0.0, maxValue=1.0, value=cmds.getAttr(self.settingsLocator+"."+attr), cc=partial(self.moduleWeights_sliderCallback, attr, weightAttributes)) parentUIElements = self.UIElements["moduleWeights_frameLayout"] self.create_moduleWeightsScriptJob(parentUIElements, weightAttributes) self.moduleWeights_updateMatchingButton()
def createLightColorTemperatureUI(self, attrName): cmds.setUITemplate('attributeEditorPresetsTemplate', pushTemplate=True) isEnabled = True isEnabled = cmds.getAttr(self.nodeAttr('aiUseColorTemperature')) aeUtils.attrBoolControlGrp(self.checkBoxName, attribute=self.nodeAttr('aiUseColorTemperature'), label='Use Color Temperature', changeCommand=self.updateUseColorTemperature) cmds.setParent('..') cmds.rowLayout(numberOfColumns=2, columnWidth2=(80,220), adjustableColumn=2, columnAttach=[(1, 'left', 0), (2, 'left', -10)]) cmds.canvas(self.canvasName, width=65, height=12) cmds.attrFieldSliderGrp(self.sliderName, label='Temperature', width=220, attribute=self.nodeAttr('aiColorTemperature'), enable=isEnabled, precision=0, columnWidth=[(1, 70), (2, 70), (3, 80)], changeCommand=self.updateColorTemperature) cmds.setParent('..') colorTemp = cmds.arnoldTemperatureToColor(cmds.getAttr(self.nodeAttr('aiColorTemperature'))) cmds.canvas(self.canvasName, edit=True, rgbValue=colorTemp) cmds.setUITemplate(popTemplate=True)
def createAttrSlider(name, myLabel, attr, MaxValue, MinValue, Step): # Using attrSlider instead of floatSlider... attrSlider = cmds.attrFieldSliderGrp(name, label = myLabel, w = 280, at = attr, columnWidth = [(1, 80), (2, 80)], columnAttach = [(2, "left", 10), (3, "left", 10)], fieldMaxValue = MaxValue, fieldMinValue = MinValue, fieldStep = Step, sliderMaxValue = MaxValue, sliderMinValue = MinValue, sliderStep = Step, columnAlign = [(1, "left"), (2, "center"), (3, "right")], cc = partial(setFactorFunc, attr)) return attrSlider
def __init__(self, node, label="Max Distance", collapse=True): self.controls = [] self.connectControls = [] def attr(attr): return "%s.%s" % (node, attr) self.node = node if cmds.frameLayout(label=label, collapse=collapse, collapsable=True): if cmds.columnLayout(adj=True): self.use_max_dist = cmds.checkBoxGrp( label="", label1="Use Max Distance", columnWidth=columnWidthData, cc=self.value_changed) self.connectControls.append( ("use_max_dist", self.use_max_dist, 2)) cmds.connectControl(self.use_max_dist, attr("use_max_dist"), index=2) self.max_dist = cmds.attrFieldSliderGrp( attribute=attr("max_dist"), label="Max Dist", columnWidth=columnWidthData) self.controls.append( ("max_dist", self.max_dist, cmds.attrFieldSliderGrp)) self.use_color = cmds.checkBoxGrp( label="", label1="Use Color", columnWidth=columnWidthData, cc=self.value_changed) self.connectControls.append( ("use_max_dist_color", self.use_color, 2)) cmds.connectControl(self.use_color, attr("use_max_dist_color"), index=2) self.color = cmds.attrColorSliderGrp( attribute=attr("max_dist_color"), label="Color", columnWidth=columnWidthData) self.controls.append(("max_dist_color", self.color, cmds.attrColorSliderGrp)) cmds.setParent("..") cmds.setParent("..") self.value_changed()
def update(self, *args): """ Sets the controls to selected object's setting """ try: shapes = cmds.ls(sl=True, o=True, dag=True, s=True) if len(shapes) > 0: self.shadEngine = str(cmds.listConnections(shapes, type ="shadingEngine")[0]) # connected materials self.materials = str(cmds.ls(cmds.listConnections(self.shadEngine), materials = True)[0]) # check if connected material is a surface shader or Maya material if cmds.nodeType(self.materials)=='surfaceShader': wireframeColor=cmds.attrColorSliderGrp("wireframeColor", edit= True, at=self.materials+'.outColor', sb=True ) wireColorSlider=cmds.attrColorSliderGrp("wireColorSlider", edit= True, at=self.shadEngine+'.miContourColor') wirewidthControl=cmds.attrFieldSliderGrp("wirewidthControl", edit= True, at=self.shadEngine+'.miContourWidth' ) else: wireframeColor=cmds.attrColorSliderGrp("wireframeColor", edit= True, at=self.materials+'.color', sb=True ) wireColorSlider=cmds.attrColorSliderGrp("wireColorSlider", edit= True, at=self.shadEngine+'.miContourColor') wirewidthControl=cmds.attrFieldSliderGrp("wirewidthControl", edit= True, at=self.shadEngine+'.miContourWidth') except TypeError,UnboundLocalError: pass
def createUI(self,winName,dock): ##if Maya version is 2011 or above, create a doclable window, ##else create a floating window. if dock==True: if cmds.dockControl("%s_dock" % winName, q=True, exists=True): cmds.deleteUI("%s_dock" % winName) else: if cmds.window(winName, q=True, exists=True): cmds.deleteUI(winName) try: ###create window self.widgets["window"]=cmds.window(title="Render Wireframe", width=350, mnb=False,mxb=False) self.widgets["mainLayout"]=cmds.columnLayout("mainLayout",width=340,height=400,adj=True) self.widgets["scrolFldRprtr"]=cmds.cmdScrollFieldReporter("scrolFldRprtr",w=350,eac=False,fst="python") cmds.separator(h=5,style="none") cmds.separator(h=5,style="none") self.widgets["Amb_Occlus"]=cmds.text( label='Press CTRL button & hit the shelfbar button to render with AO' ) self.widgets["rowColumnLayout"]=cmds.rowColumnLayout(nc=2,cw=[(1,180),(2,140)],columnOffset=[(1,"both",5),(2,"both",2)]) self.widgets["aoCheck"]=cmds.checkBox("aoCheck",label='Render with Ambient Occlusion' , value=self.FLAG) self.widgets["mtrlSg_Attrib_Contrls"]= cmds.frameLayout('mtrlSg_Attrib_Contrls',w=340, label='Change Color and Wire Width', borderStyle='in',parent=self.widgets["mainLayout"] ) self.widgets["formLayout"] = cmds.formLayout("formLayout",numberOfDivisions=100) self.widgets["wireframeColor"]=cmds.attrColorSliderGrp('wireframeColor', sb=True, at='lambert1.outColor', l='Object Color') self.widgets["wireColorSlider"]=cmds.attrColorSliderGrp("wireColorSlider", l='Wire Color', at='initialShadingGroup.miContourColor', ann='the Wires will only show up in Render', sb=False) self.widgets["wirewidthControl"]=cmds.attrFieldSliderGrp("wirewidthControl",at=self.shadEngine+'.miContourWidth', ann='keep value between .5 and .8', min=0.0, max=1.50,l='Wire Width' ) self.widgets["antiAliasControl"]=cmds.floatSliderGrp("antiAliasControl", label='Anti Alias', cc=partial(self._change), field=True, minValue=0.01, maxValue=1.0, ann="change anti-alias contrast", value=cmds.getAttr("miDefaultOptions.contrastR") ) cmds.setParent('..') self.widgets["rowColumnRenLayout"]=cmds.rowColumnLayout( nc=2,cw=[(1,180),(2,140)],columnOffset=[(1,"both",5),(2,"both",2)]) self.widgets["renderSelected"]=cmds.iconTextButton('renderSelbtn', al='left',h=25,image='WireFrameOnShaded.png',ann='Wireframe selected object', style='iconAndTextHorizontal',label='Wireframe Selected',c=self._restrictUiReload) self.widgets["renderBtn"]=cmds.iconTextButton('renderBtn', align="right", h=25, width=100 , ann='Click here to take a test Render Preview\n For good quality use high resolution', c=cmds.RenderIntoNewWindow, style='iconAndTextHorizontal', image='menuIconRender.png', label='Render Preview') self.widgets["mainLayout_btns"]=cmds.columnLayout("mainLayout_btns", width=340, height=400) self.widgets["showSGbtn"]=cmds.button(c=self.showSGroup, l="Show Material", ann="Opens Attribute Editor and displays material of the selected object") self.widgets["formLayout"]=cmds.formLayout("formLayout", edit=True, af=[("wireframeColor",'top',0), ("wireframeColor",'left', -70)]) self.widgets["formLayout"]=cmds.formLayout("formLayout", edit=True, af=[("wireColorSlider",'top',20), ("wireColorSlider",'left', -70)]) self.widgets["formLayout"]=cmds.formLayout("formLayout", edit=True, af=[("wirewidthControl",'top',40), ("wirewidthControl",'left', -70)]) self.widgets["formLayout"]=cmds.formLayout("formLayout", edit=True, af=[("antiAliasControl",'top',60), ("antiAliasControl",'left', -70)]) cmds.scriptJob(parent=self.widgets["window"], e=["SelectionChanged",self.update]) except RuntimeError, err: print err
def updateLayerTolerance(self): aovList = aovs.getAOVs(enabled=True) deepexrToleranceTemplates[:] = [tup for tup in deepexrToleranceTemplates if cmds.columnLayout(tup, exists=True)] for templateName in deepexrToleranceTemplates: cmds.setParent(templateName) for child in cmds.columnLayout(templateName, query=True, childArray=True) or []: cmds.deleteUI(child) cmds.attrFieldSliderGrp(label='alpha' , at='defaultArnoldDriver.alphaTolerance' ) cmds.attrFieldSliderGrp(label='depth' , at='defaultArnoldDriver.depthTolerance' ) cmds.attrFieldSliderGrp(label='beauty' , at='defaultArnoldDriver.layerTolerance[0]' ) for i in range(0,len(aovList)): if aovList[i].node.attr('outputs')[0].driver.inputs()[0].name() == 'defaultArnoldDriver': labelStr = aovList[i].name attrStr = 'defaultArnoldDriver.layerTolerance['+str(i+1)+']' cmds.attrFieldSliderGrp(label=labelStr , at=attrStr )
def ScaleAdjust(): # Draw interface name = "ScaleControl" myLabel = "Scale Factor: " attr = "Galaxy_Star.scaleX" MaxValue = 10 MinValue = 0 Step = 0.1 ScaleSlider = cmds.attrFieldSliderGrp(name, label = myLabel, w = 280, at = attr, columnWidth = [(1, 80), (2, 80)], columnAttach = [(2, "left", 10), (3, "left", 10)], fieldMaxValue = MaxValue, fieldMinValue = MinValue, fieldStep = Step, sliderMaxValue = MaxValue, sliderMinValue = MinValue, sliderStep = Step, columnAlign = [(1, "left"), (2, "center"), (3, "right")], cc = setScaleFactor)
def refreshControls(self): if cmds.columnLayout(self.column, exists=True): cmds.setParent(self.column) for rowChild in cmds.columnLayout(self.column, query=True, childArray=True) or []: row = self.column+"|"+rowChild cmds.deleteUI(rowChild) for element in self.listElements: elementName = element[1] cmds.rowLayout(numberOfColumns=6, adjustableColumn=2, columnWidth6=[50, 160, 160, 180, 180, 110], columnAttach=[(1, 'both', 5), (2, 'both', 5), (3, 'both', 5), (4, 'both', 5), (5, 'both', 5), (6, 'both', -5)] ) selectCommand='import maya.cmds as cmds\ncmds.select(\''+elementName+'\')' cmds.nodeIconButton( style='iconOnly', command=selectCommand, image1=element[0]+'.png' ) cmds.text(label=elementName, align='left') cmds.attrColorSliderGrp(label='C:', at=elementName+'.color', columnWidth4=[15,30,70,40], columnAlign=[1,"center"]) if element[0] == 'MeshLightShelf': cmds.attrFieldSliderGrp(label='I:', at=elementName+'.intensity', columnWidth2=[15,45], columnAlign=[1,"center"]) cmds.attrFieldSliderGrp(label='E:', at=elementName+'.aiExposure', columnWidth3=[15,45,70], columnAlign=[1,"center"]) else: cmds.attrFieldSliderGrp(label='I:', at=elementName+'.intensity', columnWidth4=[15,45,70,40], columnAlign=[1,"center"]) cmds.attrFieldSliderGrp(label='E:', at=elementName+'.aiExposure', columnWidth4=[15,45,70,40], columnAlign=[1,"center"]) cmds.rowLayout(numberOfColumns=2, columnWidth2=[60, 50], columnAttach=[(1, 'both', 0), (2, 'both', 5)] ) cmds.intFieldGrp('lightManager_samples_'+elementName, label='S:', columnWidth2=[20,30], columnAlign2=['center','center']) cmds.connectControl('lightManager_samples_'+elementName, elementName+'.aiSamples', index=1) cmds.connectControl('lightManager_samples_'+elementName, elementName+'.aiSamples', index=2) cmds.checkBoxGrp('lightManager_visibility_'+elementName, label="E:", columnWidth2=[18,22]) try: cmds.connectControl('lightManager_visibility_'+elementName, elementName+'.visibility', index=1) cmds.connectControl('lightManager_visibility_'+elementName, elementName+'.visibility', index=2) except: pass cmds.setParent('..') cmds.setParent('..')
def refreshControls(self): if cmds.columnLayout(self.column, exists=True): cmds.setParent(self.column) for rowChild in cmds.columnLayout( self.column, query=True, childArray=True) or []: row = self.column + "|" + rowChild cmds.deleteUI(rowChild) for element in self.listElements: elementName = element[1] cmds.rowLayout(numberOfColumns=6, adjustableColumn=2, columnWidth6=[50, 160, 160, 180, 180, 110], columnAttach=[(1, 'both', 5), (2, 'both', 5), (3, 'both', 5), (4, 'both', 5), (5, 'both', 5), (6, 'both', -5)]) selectCommand = 'import maya.cmds as cmds\ncmds.select(\'' + elementName + '\')' cmds.nodeIconButton(style='iconOnly', command=selectCommand, image1=element[0] + '.png') cmds.text(label=elementName, align='left') cmds.attrColorSliderGrp(label='C:', at=elementName + '.color', columnWidth4=[15, 30, 70, 40], columnAlign=[1, "center"]) if element[0] == 'MeshLightShelf': cmds.attrFieldSliderGrp(label='I:', at=elementName + '.intensity', columnWidth2=[15, 45], columnAlign=[1, "center"]) cmds.attrFieldSliderGrp(label='E:', at=elementName + '.aiExposure', columnWidth3=[15, 45, 70], columnAlign=[1, "center"]) else: cmds.attrFieldSliderGrp(label='I:', at=elementName + '.intensity', columnWidth4=[15, 45, 70, 40], columnAlign=[1, "center"]) cmds.attrFieldSliderGrp(label='E:', at=elementName + '.aiExposure', columnWidth4=[15, 45, 70, 40], columnAlign=[1, "center"]) cmds.rowLayout(numberOfColumns=2, columnWidth2=[60, 50], columnAttach=[(1, 'both', 0), (2, 'both', 5)]) cmds.intFieldGrp('lightManager_samples_' + elementName, label='S:', columnWidth2=[20, 30], columnAlign2=['center', 'center']) cmds.connectControl('lightManager_samples_' + elementName, elementName + '.aiSamples', index=1) cmds.connectControl('lightManager_samples_' + elementName, elementName + '.aiSamples', index=2) cmds.checkBoxGrp('lightManager_visibility_' + elementName, label="E:", columnWidth2=[18, 22]) try: cmds.connectControl('lightManager_visibility_' + elementName, elementName + '.visibility', index=1) cmds.connectControl('lightManager_visibility_' + elementName, elementName + '.visibility', index=2) except: pass cmds.setParent('..') cmds.setParent('..')
def __init__(self, node): super(AE_mila_scatter_template, self).__init__(node) if cmds.frameLayout(label="Front Scatter", collapsable=True): if cmds.columnLayout(adj=True): self.addControl( "front_tint", cmds.attrColorSliderGrp(attribute=self.attr("front_tint"), label="Tint", columnWidth=columnWidthData), cmds.attrColorSliderGrp) self.addControl( "front_weight", cmds.attrFieldSliderGrp( attribute=self.attr("front_weight"), label="Weight", columnWidth=columnWidthData), cmds.attrFieldSliderGrp) self.addControl( "front_radius", cmds.attrFieldGrp(attribute=self.attr("front_radius"), label="Radius", columnWidth=columnWidthData3), cmds.attrFieldGrp) self.addControl( "front_radius_mod", cmds.attrColorSliderGrp( attribute=self.attr("front_radius_mod"), label="Radius Mod", columnWidth=columnWidthData), cmds.attrColorSliderGrp) cmds.setParent("..") cmds.setParent("..") if cmds.frameLayout(label="Back Scatter", collapsable=True): if cmds.columnLayout(adj=True): self.addControl( "back_tint", cmds.attrColorSliderGrp(attribute=self.attr("back_tint"), label="Tint", columnWidth=columnWidthData), cmds.attrColorSliderGrp) self.addControl( "back_weight", cmds.attrFieldSliderGrp(attribute=self.attr("back_weight"), label="Weight", columnWidth=columnWidthData), cmds.attrFieldSliderGrp) self.addControl( "back_radius", cmds.attrFieldGrp(attribute=self.attr("back_radius"), label="Radius", columnWidth=columnWidthData3), cmds.attrFieldGrp) self.addControl( "back_radius_mod", cmds.attrColorSliderGrp( attribute=self.attr("back_radius_mod"), label="Radius Mod", columnWidth=columnWidthData), cmds.attrColorSliderGrp) self.addControl( "back_depth", cmds.attrFieldSliderGrp(attribute=self.attr("back_depth"), label="Depth", columnWidth=columnWidthData), cmds.attrFieldSliderGrp) cmds.setParent("..") cmds.setParent("..") if cmds.frameLayout(label="Storage And Optimization", collapsable=True): if cmds.columnLayout(adj=True): self.addControl( "scale_conversion", cmds.attrFieldSliderGrp( attribute=self.attr("scale_conversion"), label="Scale", columnWidth=columnWidthData), cmds.attrFieldSliderGrp) self.addControl( "sampling_radius_mult", cmds.attrFieldSliderGrp( attribute=self.attr("sampling_radius_mult"), label="Sampling Factor", columnWidth=columnWidthData), cmds.attrFieldSliderGrp) self.addControl( "resolution", cmds.attrEnumOptionMenuGrp( attribute=self.attr("resolution"), label='Resolution', columnWidth=columnWidthData3, ei=[(0, "2 x Image"), (1, "1 x Image"), (2, "1/2 x Image"), (3, "1/3 x Image"), (4, "1/4 x Image"), (5, "1/5 x Image")]), cmds.attrEnumOptionMenuGrp) self.addControl( "light_storage_gamma", cmds.attrFieldSliderGrp( attribute=self.attr("light_storage_gamma"), label="Gamma", columnWidth=columnWidthData), cmds.attrFieldSliderGrp) cmds.setParent("..") cmds.setParent("..") self.controls += AE_contribution_template(node)
def __init__(self, node): super(AE_mila_layer_template, self).__init__(node) # LAYER / MIX if cmds.frameLayout(label="Layer", collapsable=True): if cmds.columnLayout(adj=True): # self.on = cmds.attrControlGrp( attribute = self.attr("on")) self.weight = cmds.attrFieldSliderGrp( attribute=self.attr("weight"), label="Weight", columnWidth=columnWidthData) self.addControl("weight", self.weight, cmds.attrFieldSliderGrp) self.weight_tint = cmds.attrColorSliderGrp( attribute=self.attr("weight_tint"), label="Weight Tint", columnWidth=columnWidthData) self.addControl("weight_tint", self.weight_tint, cmds.attrColorSliderGrp) self.fresnelLayout = cmds.formLayout() if self.fresnelLayout: self.directionalWeight = cmds.optionMenuGrp( label="Fresnel", columnWidth=columnWidthData, cc=self._setDirectionalMode) if self.directionalWeight: cmds.menuItem("Constant") cmds.menuItem("IOR") cmds.menuItem("Custom") self.scriptJobA = cmds.scriptJob( replacePrevious=True, parent=self.directionalWeight, attributeChange=(self.attr("directional_weight_mode"), self._directionalModeChanged)) self.scriptJobB = cmds.scriptJob( replacePrevious=True, parent=self.fresnelLayout, attributeChange=(self.attr("use_directional_weight"), self._directionalModeChanged)) self.scriptJobs.append( ("directional_weight_mode", self.directionalWeight, "attributeChange", self._directionalModeChanged)) self.scriptJobs.append( ("use_directional_weight", self.fresnelLayout, "attributeChange", self._directionalModeChanged)) self.showCurve = cmds.checkBox(label="Show Curve", cc=self._showCurveChanged, width=10, value=True) self.ior = cmds.attrFieldSliderGrp( attribute=self.attr("ior"), label="IOR", columnWidth=columnWidthData, cc=self.iorFresnelChanged) self.addControl("ior", self.ior, cmds.attrFieldSliderGrp) self.normal_reflectivity = cmds.attrFieldSliderGrp( attribute=self.attr("normal_reflectivity"), label="0 degree", columnWidth=columnWidthData, cc=self.customFresnelChanged) self.addControl("normal_reflectivity", self.normal_reflectivity, cmds.attrFieldSliderGrp) self.grazing_reflectivity = cmds.attrFieldSliderGrp( attribute=self.attr("grazing_reflectivity"), label="90 degree", columnWidth=columnWidthData, cc=self.customFresnelChanged) self.addControl("grazing_reflectivity", self.grazing_reflectivity, cmds.attrFieldSliderGrp) self.exponent = cmds.attrFieldSliderGrp( attribute=self.attr("exponent"), label="Exponent", columnWidth=columnWidthData, cc=self.customFresnelChanged) self.addControl("exponent", self.exponent, cmds.attrFieldSliderGrp) col = cmds.columnLayout(adj=True) if col: self.graphWidget = graphWidgetUI() cmds.setParent("..") cmds.setParent("..") cmds.formLayout( self.fresnelLayout, edit=True, attachForm=[[self.directionalWeight, "top", 2], [self.directionalWeight, "left", 0], [self.showCurve, "top", 2], [self.showCurve, "right", 0], [self.ior, "left", 0], [self.normal_reflectivity, "left", 0], [self.grazing_reflectivity, "left", 0], [self.exponent, "left", 0], [col, "right", 12], [col, "bottom", 10], [col, "left", 190]], attachControl=[ [self.showCurve, "left", 2, self.directionalWeight], [col, "top", 4, self.showCurve], [self.ior, "top", 2, self.directionalWeight], [ self.normal_reflectivity, "top", 2, self.directionalWeight ], [ self.grazing_reflectivity, "top", 2, self.normal_reflectivity ], [self.exponent, "top", 2, self.grazing_reflectivity], ], attachNone=[[self.directionalWeight, "right"], [self.directionalWeight, "bottom"], [self.showCurve, "bottom"], [self.ior, "bottom"], [self.ior, "right"], [self.normal_reflectivity, "right"], [self.normal_reflectivity, "bottom"], [self.grazing_reflectivity, "right"], [self.grazing_reflectivity, "bottom"], [self.exponent, "right"], [self.exponent, "bottom"]], ) self.bump = AE_bump_template(self.node) cmds.setParent("..") cmds.setParent("..") self._directionalModeChanged()
def minPixelUpdate(self, attrName): isEnabled = not (cmds.getAttr("%s.aiMode" % (attrName.split(".")[0])) is 1) cmds.attrFieldSliderGrp("NurbsCurveTemplateMinPixelWidth", edit=True, attribute=attrName, enable=isEnabled)
def updateUseColorTemperature(self, *args): try: cmds.attrFieldSliderGrp(self.sliderName, edit=True, enable=cmds.getAttr(self.nodeAttr('aiUseColorTemperature'))) except: pass
def minPixelCreate(self, attrName): cmds.setUITemplate('attributeEditorPresetsTemplate', pushTemplate=True) isEnabled = not (cmds.getAttr("%s.aiMode" % (attrName.split(".")[0])) is 1) cmds.attrFieldSliderGrp("NurbsCurveTemplateMinPixelWidth", label="Min Pixel Width", attribute=attrName, enable=isEnabled) cmds.setUITemplate(popTemplate=True)
def indirectDiffuseUpdate(self, attrName): isEnabled = not (cmds.getAttr("%s.aiMode" % (attrName.split(".")[0])) is 1) cmds.attrFieldSliderGrp("HairTemplateIndirectDiffuse", edit=True, attribute=attrName, enable=isEnabled)
def indirectDiffuseCreate(self, attrName): cmds.setUITemplate('attributeEditorPresetsTemplate', pushTemplate=True) isEnabled = not (cmds.getAttr("%s.aiMode" % (attrName.split(".")[0])) is 1) cmds.attrFieldSliderGrp("HairTemplateIndirectDiffuse", label="Indirect Diffuse", attribute=attrName, enable=isEnabled) cmds.setUITemplate(popTemplate=True)
def createUI(self, winName, dock): ##if Maya version is 2011 or above, create a doclable window, ##else create a floating window. if dock == True: if cmds.dockControl(winName + "_dock", q=True, exists=True): cmds.deleteUI(winName + "_dock") else: if cmds.window(winName, q=True, exists=True): cmds.deleteUI(winName) try: ###create window self.widgets["window"] = cmds.window(title="Render Wireframe", width=350, mnb=False, mxb=False) self.widgets["mainLayout"] = cmds.columnLayout("mainLayout", width=340, height=400, adj=True) self.widgets["scrolFldRprtr"] = cmds.cmdScrollFieldReporter("scrolFldRprtr", w=350, eac=False, fst="python") cmds.separator(h=5, style="none") cmds.separator(h=5, style="none") self.widgets["Amb_Occlus"] = cmds.text( label="Press CTRL button & hit the shelfbar button to render with AO" ) self.widgets["rowColumnLayout"] = cmds.rowColumnLayout( nc=2, cw=[(1, 180), (2, 140)], columnOffset=[(1, "both", 5), (2, "both", 2)] ) self.widgets["aoCheck"] = cmds.checkBox("aoCheck", label="Render with Ambient Occlusion", value=self.FLAG) self.widgets["mtrlSg_Attrib_Contrls"] = cmds.frameLayout( "mtrlSg_Attrib_Contrls", w=340, label="Change Color and Wire Width", borderStyle="in", parent=self.widgets["mainLayout"], ) self.widgets["formLayout"] = cmds.formLayout("formLayout", numberOfDivisions=100) self.widgets["wireframeColor"] = cmds.attrColorSliderGrp( "wireframeColor", sb=True, at="lambert1.outColor", l="Object Color" ) self.widgets["wireColorSlider"] = cmds.attrColorSliderGrp( "wireColorSlider", l="Wire Color", at="initialShadingGroup.miContourColor", ann="the Wires will only show up in Render", sb=False, ) self.widgets["wirewidthControl"] = cmds.attrFieldSliderGrp( "wirewidthControl", at=self.shadEngine + ".miContourWidth", ann="keep value between .5 and .8", min=0.0, max=1.50, l="Wire Width", ) self.widgets["antiAliasControl"] = cmds.floatSliderGrp( "antiAliasControl", label="Anti Alias", cc=partial(self.change), field=True, minValue=0.01, maxValue=1.0, ann="change anti-alias contrast", value=cmds.getAttr("miDefaultOptions.contrastR"), ) cmds.setParent("..") self.widgets["rowColumnRenLayout"] = cmds.rowColumnLayout( nc=2, cw=[(1, 180), (2, 140)], columnOffset=[(1, "both", 5), (2, "both", 2)] ) self.widgets["renderSelected"] = cmds.iconTextButton( "renderSelbtn", al="left", h=25, image="WireFrameOnShaded.png", ann="Wireframe selected object", style="iconAndTextHorizontal", label="Wireframe Selected", c=self.wfSeltd, ) self.widgets["renderBtn"] = cmds.iconTextButton( "renderBtn", align="right", h=25, width=100, ann="Click here to take a test Render Preview\n For good quality use high resolution", c=cmds.RenderIntoNewWindow, style="iconAndTextHorizontal", image="menuIconRender.png", label="Render Preview", ) self.widgets["mainLayout_btns"] = cmds.columnLayout("mainLayout_btns", width=340, height=400) self.widgets["showSGbtn"] = cmds.button( c=self.showSGroup, l="Show Material", ann="Opens Attribute Editor and displays material of the selected object", ) self.widgets["formLayout"] = cmds.formLayout( "formLayout", edit=True, af=[("wireframeColor", "top", 0), ("wireframeColor", "left", -70)] ) self.widgets["formLayout"] = cmds.formLayout( "formLayout", edit=True, af=[("wireColorSlider", "top", 20), ("wireColorSlider", "left", -70)] ) self.widgets["formLayout"] = cmds.formLayout( "formLayout", edit=True, af=[("wirewidthControl", "top", 40), ("wirewidthControl", "left", -70)] ) self.widgets["formLayout"] = cmds.formLayout( "formLayout", edit=True, af=[("antiAliasControl", "top", 60), ("antiAliasControl", "left", -70)] ) cmds.scriptJob(parent=self.widgets["window"], e=["SelectionChanged", self.update]) except RuntimeError, err: print err
def createUI(self): myWindow = cmds.window(self.windowName, h=800, w=1000, menuBar=True, s=True) mainLayout = cmds.formLayout(numberOfDivisions=100) selectionLayout = cmds.columnLayout(adj=True, h=45) cmds.text(label="Selection Constraint") self.selectionModeRadioButton = cmds.radioButtonGrp( labelArray4=['None', 'Shell', 'Border', 'Internal'], numberOfRadioButtons=4, select=1, cw4=[100, 100, 100, 100], on1=partial(self.changeSelectionConstraint, 1), on2=partial(self.changeSelectionConstraint, 2), on3=partial(self.changeSelectionConstraint, 3), on4=partial(self.changeSelectionConstraint, 4)) cmds.setParent('..') # selectionLayout shaderLayout = cmds.formLayout() uvRepeatSlider = cmds.attrFieldSliderGrp(label="Repeat", min=0.0, max=20.0, parent=shaderLayout) if cmds.objExists("uvShaderPlace2dTexture"): cmds.attrFieldSliderGrp(uvRepeatSlider, edit=True, at='uvShaderPlace2dTexture.repeatU') else: pass uvShaderButton = cmds.button(label="Create UV shader", command=partial(commands.createUVshader, self.uvTexturePath, uvRepeatSlider)) uvShaderAssignButton = cmds.button(label="Assgin UV shader", command=partial( commands.assignUVshader)) cmds.setParent('..') cmds.formLayout(shaderLayout, edit=True, attachForm=[(uvShaderButton, 'top', 2), (uvShaderButton, 'left', 2), (uvShaderAssignButton, 'top', 2), (uvRepeatSlider, 'bottom', 2), (uvRepeatSlider, 'left', 2), (uvRepeatSlider, 'right', 2)], attachControl=[(uvShaderAssignButton, 'left', 2, uvShaderButton)]) # ### LEFT LAYOUT #### leftLayout = cmds.columnLayout(adj=True, w=120) cmds.gridLayout(numberOfColumns=3, cellWidthHeight=(40, 40)) cmds.iconTextButton(image="%s/upLeft.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v 1;')") cmds.iconTextButton(image="%s/up.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 0 -v 1;')") cmds.iconTextButton(image="%s/upRight.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v 1;')") cmds.iconTextButton(image="%s/left.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v 0;')") cmds.iconTextButton() cmds.iconTextButton(image="%s/right.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v 0;')") cmds.iconTextButton(image="%s/bottomLeft.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v -1;')") cmds.iconTextButton(image="%s/bottom.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 0 -v -1;')") cmds.iconTextButton(image="%s/bottomRight.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v -1;')") cmds.setParent('..') # gridLayout cmds.button(label="UV Centric", command="cmds.UVCentricUVLinkingEditor()") cmds.button(label="UV Set Editor", command="cmds.UVSetEditor()") cmds.button(label="Transfer Attr", command=miUvUtils.transferAttributesOptions) cmds.separator(h=20) cmds.text(label="Transfer UVs") uvSpaceTransferRadioButton = cmds.radioButtonGrp( labelArray2=["World", "Comp"], numberOfRadioButtons=2, select=2, cw2=[60, 60]) cmds.button(label="TRANSFER UVs", command=partial(self.radioButtonCommand, uvSpaceTransferRadioButton, commands.transferUVs)) cmds.text(label="*Select source mesh \nfirst, then targets") cmds.separator(h=20) cmds.text(label="Symmetrize UVs") uvSymRadioButton = cmds.radioButtonGrp(labelArray3=["X", "Y", "Z"], numberOfRadioButtons=3, select=1, cw3=[40, 40, 40]) cmds.text(label="*Select target \nvertices") cmds.button(label="MIRROR UVs", command=partial(self.radioButtonCommand, uvSymRadioButton, commands.mirroringUVs)) cmds.separator(h=20) cmds.button(label="Fix UV radio", command=partial(commands.fixUVscale)) cmds.button(label="Copy UVs to map1", command=partial(commands.copyUVsToMap1)) cmds.button(label="Flip UVs by world", command=partial(commands.flipUVsByWorld)) cmds.button(label="Flip selected UVs", command=miUvUtils.flipUVs) cmds.button(label="Grid UVs", enable=False) cmds.button(label="Delete History", command="cmds.DeleteHistory()") cmds.separator(h=20) cmds.text(label="Repeat UVs") self.uMax = cmds.textField(h=25, text="type number of U here") cmds.button(label="UV horizontal repeat", enable=True, command=self.repeatUVs) cmds.separator(h=20) cmds.gridLayout(numberOfColumns=3, cellWidthHeight=(40, 40)) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___X", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='x', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___Y", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='y', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___Z", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='z', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___X", olc=[1, 1, 0], command=("cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, rx=90)"), commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___Y", olc=[1, 1, 0], command=("cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, ry=90)"), commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___Z", olc=[1, 1, 0], command=("cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, rz=90)"), commandRepeatable=True) cmds.iconTextButton(image="polyAutoProj.png", imageOverlayLabel="Auto", olc=[1, 1, 0], commandRepeatable=True, command="mel.eval('performPolyAutoProj 0;')") cmds.iconTextButton( image="polyAutoProj.png", imageOverlayLabel="Cam", olc=[1, 1, 0], commandRepeatable=True, command="cmds.polyProjection(type='planar', md='p')") cmds.setParent('..') # gridLayout cmds.setParent('..') # leftLayout # #### BOTTOM LAYOUT ##### bottomLayout = cmds.rowColumnLayout(numberOfColumns=6, h=45, columnWidth=[(1, 500), (2, 40), (3, 60), (4, 60), (5, 60), (6, 60)]) cmds.text(label="QuickSnapShot", align="left") cmds.text(label="Browes", align="left") cmds.text(label="Size", align="left") cmds.text(label="Tile Num", align="left") cmds.text(label="format", align="left") cmds.text(label="") self.uvImagePath = cmds.textField(h=2) initialPath = os.path.join(self.homeDir, "testImage.tif") cmds.textField(self.uvImagePath, edit=True, text=initialPath) cmds.symbolButton(w=25, h=25, image="menuIconFile.png", command=self.browseDirectoryPath) self.uvImageResolution = cmds.optionMenuGrp(enable=True) cmds.menuItem(label="8k") cmds.menuItem(label="4k") cmds.menuItem(label="2k") cmds.menuItem(label="1k") cmds.menuItem(label="512") self.uvImageTileNumber = cmds.optionMenuGrp(h=25, enable=True) for i in range(100): tileNumber = "1" + str(i + 1).zfill(3) cmds.menuItem(label=tileNumber) self.uvImageFormat = cmds.optionMenuGrp(enable=True) cmds.menuItem(label="tif") cmds.menuItem(label="jpg") cmds.menuItem(label="iff") cmds.menuItem(label="sgi") cmds.menuItem(label="pic") cmds.menuItem(label="als") cmds.menuItem(label="gif") cmds.menuItem(label="rla") cmds.button(label="Export", h=30, command=self.takeUvSnapshot) cmds.setParent('..') # #### TEXTURE WINDOW LAYOUT ##### textureLayout = cmds.paneLayout(configuration='single') pane = cmds.paneLayout(configuration="vertical2") cmds.paneLayout(pane, e=True, paneSize=(1, 0, 0)) cmds.modelPanel(cam="perspShape", tearOff=False) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') # mainLayout # ## UNPARENT CURRENT UV TEXTURE EDITOR AND RE-PARENT TO MY EIDTOR ### texturePanel = cmds.getPanel(scriptType='polyTexturePlacementPanel')[0] cmds.scriptedPanel(texturePanel, edit=True, unParent=True) mel.eval("fillEmptyPanes;") cmds.scriptedPanel(texturePanel, edit=True, parent=pane) # FORM LAYOUT cmds.formLayout(mainLayout, e=True, attachForm=[(selectionLayout, 'top', 2), (shaderLayout, 'top', 2), (shaderLayout, 'right', 2), (shaderLayout, 'right', 2), (leftLayout, 'left', 2), (leftLayout, 'top', 2), (leftLayout, 'bottom', 2), (textureLayout, 'left', 2), (textureLayout, 'top', 2), (textureLayout, 'right', 2), (textureLayout, 'bottom', 2), (bottomLayout, 'bottom', 2), (bottomLayout, 'left', 2)], attachControl=[ (selectionLayout, 'left', 2, leftLayout), (leftLayout, 'bottom', 2, bottomLayout), (shaderLayout, 'left', 2, selectionLayout), (textureLayout, 'top', 2, selectionLayout), (textureLayout, 'bottom', 2, bottomLayout), (textureLayout, 'left', 2, leftLayout) ]) # SHOW WINDOW cmds.showWindow(myWindow)
def createUI(self): myWindow = cmds.window( self.windowName, h=800, w=1000, menuBar=True, s=True) mainLayout = cmds.formLayout(numberOfDivisions=100) selectionLayout = cmds.columnLayout(adj=True, h=45) cmds.text(label="Selection Constraint") self.selectionModeRadioButton = cmds.radioButtonGrp( labelArray4=['None', 'Shell', 'Border', 'Internal'], numberOfRadioButtons=4, select=1, cw4=[100, 100, 100, 100], on1=partial(self.changeSelectionConstraint, 1), on2=partial(self.changeSelectionConstraint, 2), on3=partial(self.changeSelectionConstraint, 3), on4=partial(self.changeSelectionConstraint, 4)) cmds.setParent('..') # selectionLayout shaderLayout = cmds.formLayout() uvRepeatSlider = cmds.attrFieldSliderGrp( label="Repeat", min=0.0, max=20.0, parent=shaderLayout) if cmds.objExists("uvShaderPlace2dTexture"): cmds.attrFieldSliderGrp( uvRepeatSlider, edit=True, at='uvShaderPlace2dTexture.repeatU') else: pass uvShaderButton = cmds.button( label="Create UV shader", command=partial( commands.createUVshader, self.uvTexturePath, uvRepeatSlider)) uvShaderAssignButton = cmds.button( label="Assgin UV shader", command=partial( commands.assignUVshader)) cmds.setParent('..') cmds.formLayout( shaderLayout, edit=True, attachForm=[ (uvShaderButton, 'top', 2), (uvShaderButton, 'left', 2), (uvShaderAssignButton, 'top', 2), (uvRepeatSlider, 'bottom', 2), (uvRepeatSlider, 'left', 2), (uvRepeatSlider, 'right', 2) ], attachControl=[(uvShaderAssignButton, 'left', 2, uvShaderButton)]) # ### LEFT LAYOUT #### leftLayout = cmds.columnLayout(adj=True, w=120) cmds.gridLayout(numberOfColumns=3, cellWidthHeight=(40, 40)) cmds.iconTextButton( image="%s/upLeft.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v 1;')") cmds.iconTextButton( image="%s/up.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 0 -v 1;')") cmds.iconTextButton( image="%s/upRight.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v 1;')") cmds.iconTextButton( image="%s/left.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v 0;')") cmds.iconTextButton() cmds.iconTextButton( image="%s/right.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v 0;')") cmds.iconTextButton( image="%s/bottomLeft.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v -1;')") cmds.iconTextButton( image="%s/bottom.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 0 -v -1;')") cmds.iconTextButton( image="%s/bottomRight.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v -1;')") cmds.setParent('..') # gridLayout cmds.button( label="UV Centric", command="cmds.UVCentricUVLinkingEditor()") cmds.button(label="UV Set Editor", command="cmds.UVSetEditor()") cmds.button( label="Transfer Attr", command=miUvUtils.transferAttributesOptions) cmds.separator(h=20) cmds.text(label="Transfer UVs") uvSpaceTransferRadioButton = cmds.radioButtonGrp( labelArray2=["World", "Comp"], numberOfRadioButtons=2, select=2, cw2=[60, 60]) cmds.button( label="TRANSFER UVs", command=partial( self.radioButtonCommand, uvSpaceTransferRadioButton, commands.transferUVs)) cmds.text(label="*Select source mesh \nfirst, then targets") cmds.separator(h=20) cmds.text(label="Symmetrize UVs") uvSymRadioButton = cmds.radioButtonGrp( labelArray3=["X", "Y", "Z"], numberOfRadioButtons=3, select=1, cw3=[40, 40, 40]) cmds.text(label="*Select target \nvertices") cmds.button( label="MIRROR UVs", command=partial( self.radioButtonCommand, uvSymRadioButton, commands.mirroringUVs)) cmds.separator(h=20) cmds.button( label="Fix UV radio", command=partial(commands.fixUVscale)) cmds.button( label="Copy UVs to map1", command=partial(commands.copyUVsToMap1)) cmds.button( label="Flip UVs by world", command=partial(commands.flipUVsByWorld)) cmds.button( label="Flip selected UVs", command=miUvUtils.flipUVs) cmds.button( label="Grid UVs", enable=False) cmds.button( label="Delete History", command="cmds.DeleteHistory()") cmds.separator(h=20) cmds.text(label="Repeat UVs") self.uMax = cmds.textField(h=25, text="type number of U here") cmds.button( label="UV horizontal repeat", enable=True, command=self.repeatUVs) cmds.separator(h=20) cmds.gridLayout(numberOfColumns=3, cellWidthHeight=(40, 40)) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___X", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='x', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___Y", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='y', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___Z", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='z', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___X", olc=[1, 1, 0], command=( "cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, rx=90)"), commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___Y", olc=[1, 1, 0], command=( "cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, ry=90)"), commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___Z", olc=[1, 1, 0], command=( "cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, rz=90)"), commandRepeatable=True) cmds.iconTextButton( image="polyAutoProj.png", imageOverlayLabel="Auto", olc=[1, 1, 0], commandRepeatable=True, command="mel.eval('performPolyAutoProj 0;')") cmds.iconTextButton( image="polyAutoProj.png", imageOverlayLabel="Cam", olc=[1, 1, 0], commandRepeatable=True, command="cmds.polyProjection(type='planar', md='p')") cmds.setParent('..') # gridLayout cmds.setParent('..') # leftLayout # #### BOTTOM LAYOUT ##### bottomLayout = cmds.rowColumnLayout( numberOfColumns=6, h=45, columnWidth=[ (1, 500), (2, 40), (3, 60), (4, 60), (5, 60), (6, 60)]) cmds.text(label="QuickSnapShot", align="left") cmds.text(label="Browes", align="left") cmds.text(label="Size", align="left") cmds.text(label="Tile Num", align="left") cmds.text(label="format", align="left") cmds.text(label="") self.uvImagePath = cmds.textField(h=2) initialPath = os.path.join(self.homeDir, "testImage.tif") cmds.textField(self.uvImagePath, edit=True, text=initialPath) cmds.symbolButton( w=25, h=25, image="menuIconFile.png", command=self.browseDirectoryPath) self.uvImageResolution = cmds.optionMenuGrp(enable=True) cmds.menuItem(label="8k") cmds.menuItem(label="4k") cmds.menuItem(label="2k") cmds.menuItem(label="1k") cmds.menuItem(label="512") self.uvImageTileNumber = cmds.optionMenuGrp(h=25, enable=True) for i in range(100): tileNumber = "1" + str(i + 1).zfill(3) cmds.menuItem(label=tileNumber) self.uvImageFormat = cmds.optionMenuGrp(enable=True) cmds.menuItem(label="tif") cmds.menuItem(label="jpg") cmds.menuItem(label="iff") cmds.menuItem(label="sgi") cmds.menuItem(label="pic") cmds.menuItem(label="als") cmds.menuItem(label="gif") cmds.menuItem(label="rla") cmds.button( label="Export", h=30, command=self.takeUvSnapshot) cmds.setParent('..') # #### TEXTURE WINDOW LAYOUT ##### textureLayout = cmds.paneLayout(configuration='single') pane = cmds.paneLayout(configuration="vertical2") cmds.paneLayout(pane, e=True, paneSize=(1, 0, 0)) cmds.modelPanel(cam="perspShape", tearOff=False) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') # mainLayout # ## UNPARENT CURRENT UV TEXTURE EDITOR AND RE-PARENT TO MY EIDTOR ### texturePanel = cmds.getPanel(scriptType='polyTexturePlacementPanel')[0] cmds.scriptedPanel(texturePanel, edit=True, unParent=True) mel.eval("fillEmptyPanes;") cmds.scriptedPanel(texturePanel, edit=True, parent=pane) # FORM LAYOUT cmds.formLayout( mainLayout, e=True, attachForm=[ (selectionLayout, 'top', 2), (shaderLayout, 'top', 2), (shaderLayout, 'right', 2), (shaderLayout, 'right', 2), (leftLayout, 'left', 2), (leftLayout, 'top', 2), (leftLayout, 'bottom', 2), (textureLayout, 'left', 2), (textureLayout, 'top', 2), (textureLayout, 'right', 2), (textureLayout, 'bottom', 2), (bottomLayout, 'bottom', 2), (bottomLayout, 'left', 2)], attachControl=[ (selectionLayout, 'left', 2, leftLayout), (leftLayout, 'bottom', 2, bottomLayout), (shaderLayout, 'left', 2, selectionLayout), (textureLayout, 'top', 2, selectionLayout), (textureLayout, 'bottom', 2, bottomLayout), (textureLayout, 'left', 2, leftLayout)]) # SHOW WINDOW cmds.showWindow(myWindow)
colonne = cmds.polyCylinder(r=radiusCylindre, h=hauteurCylindre, name='colonne') cmds.move(0, hauteurSocle + hauteurCylindre / 2, 0) bas = cmds.polyCube(w=largeurSocle, d=epaisseurSocle, h=hauteurSocle, name='bas') cmds.move(0, hauteurSocle / 2, 0, 'bas') #Création d'une interface cmds.window(title=" Temple 3.0 © ATI ") cmds.columnLayout() cmds.attrFieldSliderGrp(label=" Taille X du socle de la colonne ", min=0.1, max=10.0, at='bas.sx') cmds.attrFieldSliderGrp(label=" Taille Y du socle de la colonne ", min=0.1, max=10.0, at='bas.sy') cmds.attrFieldSliderGrp(label=" Taille z du socle de la colonne ", min=0.1, max=10.0, at='bas.sz') cmds.attrFieldSliderGrp(label=" Taille X du haut de la colonne ", min=0.1, max=10.0, at='haut.sx') cmds.attrFieldSliderGrp(label=" Taille Y du haut de la colonne ",