def Cas_massCopyWeight_UI(): Cas_massCopyWeightWin = "Cas_massCopyWeightWindow" if cmds.window(Cas_massCopyWeightWin, ex = True): cmds.deleteUI(Cas_massCopyWeightWin) cmds.window(Cas_massCopyWeightWin, title = "Cas_CopyWeight v4.0",wh=[176,180],s=False) cmds.columnLayout() cmds.rowColumnLayout( numberOfColumns=2 , columnWidth=[(1, 117), (2, 50)]) cmds.text(l="Weight prune value",al="center") globals()["Cas_MCW_pruneValueCT"]=cmds.floatField(v=0.01,max = 1,min=0) cmds.setParent( ".." ) globals()["Cas_MCW_convertRidgidToSoftCheckCT"]=cmds.checkBox(v=False,l="Auto convert rigid to soft skin") globals()["Cas_MCW_autoDeleteJointClusterCheckCT"]=cmds.checkBox(v=False,l="Auto delete rigid joint clusters") Cas_MCW_convertRidgidToSoftCT=cmds.button(l="Convert rigid skin to soft skin",h=30,al="center",w=170) Cas_MCW_deleteRidgidJointClusterCT=cmds.button(l="Delete rigid skin joint clusters",h=30,al="center",w=170) Cas_MCW_massWeightCopyCT=cmds.button(l="Perform Copy Weight",w=170,h=40) #commands cmds.button(Cas_MCW_massWeightCopyCT,e=True,c="Cas_massCopyWeight_python.Cas_MCW_massCopyWeight_cmd()") cmds.button(Cas_MCW_convertRidgidToSoftCT,e=True,c="Cas_massCopyWeight_python.Cas_MCW_convertRidgidToSoftButton_cmd()") cmds.button(Cas_MCW_deleteRidgidJointClusterCT,e=True,c="Cas_massCopyWeight_python.Cas_MCW_deleteRidgidJointCluster_cmd()") #print cmds.ls(sl=True , tr= 1) cmds.window(Cas_massCopyWeightWin,edit=True,wh=[176,180]) cmds.showWindow(Cas_massCopyWeightWin)
def UI_custom(self): cmds.rowLayout(nc=2, columnWidth=[1, 100], adj=2) cmds.text(label="Number Of Joints:") numJoints = len(self.jointInfo) self.numberOfJointsField = cmds.intField(value=numJoints, min=2, changeCommand=self.changeNumberOfJoints) cmds.setParent("..") joints = self.getJoints() self.createRotationOrderUIControl(joints[0]) cmds.separator() cmds.text(label="Orientation:", align="left") cmds.rowLayout(nc=3) cmds.attrEnumOptionMenu(attribute=self.moduleNamespace+":module_grp.sao_local", label="Local:") cmds.text(label="will be oriented to") cmds.attrEnumOptionMenu(attribute=self.moduleNamespace+":module_grp.sao_world", label="World:") cmds.setParent("..") cmds.separator() interpolating = False if cmds.objExists(self.moduleNamespace+":interpolation_container"): interpolating = True cmds.rowLayout(nc=2, columnWidth=[1, 80], adj=2) cmds.text(label="Interpolate:") cmds.checkBox(label="", value=interpolating, onc=partial(self.setup_interpolation, True), ofc=self.delete_interpolation)
def create(self): try:frame = cmds.frameLayout( l='Follow Area', bgs=1, bgc=[0.2,0.2,.4] ) except:frame = cmds.frameLayout( l='Follow Area', bgc=[0.2,0.2,.4] ) form = cmds.formLayout() text = cmds.text( l='Select Ik And Set' ) root = cmds.checkBox( l='Root', v=1 ) fly = cmds.checkBox( l='Fly', v=1 ) move = cmds.checkBox( l='Move', v=1 ) world = cmds.checkBox( l='World', v=1 ) btSet = cmds.button( l='Set', c= Win_Cmd.addFollow ) cmds.setParent( '..' ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af=[ ( text, 'left', 0 ), ( text, 'right', 0 ), ( text, 'top', 0 ), ( root, 'left', 0 ), ( world, 'right', 0 ), ( btSet, 'left', 0 ), ( btSet, 'right', 0 ) ], ac=[ ( root, 'top', 5, text ), ( fly, 'top', 5, text ), ( move, 'top', 5, text ), ( world, 'top', 5, text ), ( btSet, 'top', 5, move ) ], ap=[ ( root, 'right', 0, 25 ), ( fly, 'left', 0, 25 ), ( fly, 'right', 0, 50 ), ( move, 'left', 0, 50 ), ( move, 'right', 0, 75 ), ( world, 'left', 0, 75 ) ] ) Win_Global.rootfollow = root Win_Global.flyfollow = fly Win_Global.movefollow = move Win_Global.worldfollow = world return frame
def mainModule(self): cmds.rowColumnLayout(nc=2,cw =[(1,130),(2,285)]) #etchedOut rowlumnLayout.str# cmds.frameLayout(label=self.moduleLabel,mw =1 ,mh =3,bs="etchedOut",cl= 0,cll=0 ,h=self.hgt) cmds.symbolButton(h= 80,image= 'sphere.png' ) #cmds.rowColumnLayout( numberOfRows=1 ) #Side rowlumnLayout.str# #cmds.setParent('..') #Side rowlumnLayout.end# cmds.setParent('..') #etchedOut rowlumnLayout.end# cmds.frameLayout(label='options:',mw =1 ,mh =3,bs="etchedOut",cl= 0,cll=0 ,h= self.hgt) #optionsForm = cmds.formLayout() cmds.rowColumnLayout(nc=5,cw =[(1,50),(2,50),(3,50),(4,50),(5,50)]) cmds.text(l='joint:') cmds.text(l='fingers:') cmds.text(l='no:') cmds.text(l='segment:') cmds.text(l='symmetry:') cmds.textField() cmds.checkBox(l ="" ) cmds.textField() cmds.textField() cmds.checkBox(l ="" ) #cmds.formLayout(optionsForm ,e=1,) cmds.setParent('..') cmds.rowColumnLayout( numberOfRows=1 )#Side: .str cmds.text(l=' Side: ') cmds.radioButtonGrp(nrb=2 ,la2=["L","R"] ,cw2=[30 ,30],sl =1) cmds.scrollField(wordWrap =1,text ="creates arm skeleton template setup. ideal use: any arm Humans, Insects.." ,editable= 0,h=80,w=180) cmds.setParent('..')##Side: .end cmds.setParent('..') cmds.setParent('..') cmds.separator(height =3 ,style= "none" )
def OnKeyChange( self, *args ): checks = [ cmds.checkBox( self.cXKey, query = True, value = True ), cmds.checkBox( self.cYKey, query = True, value = True ), cmds.checkBox( self.cZKey, query = True, value = True ) ] attribs = [ ".translateX", ".translateY", ".translateZ" ] # ... se quieren cambios? ... sequence = next( ( seq for seq in self.SequenceInfo if seq.GetNode() == self.ActiveNode ), None ) frameInfo = sequence.GetFrameInfo( self.ActiveManip.GetFrame() ) # ... refreshCurve = False frame = self.ActiveManip.GetFrame() + self.StartFrame for i in range( 0, 3 ): if ( checks[ i ] != frameInfo.HasTranslationKeyAxis( i ) ): if ( checks[ i ] ): # ... se crea la key ... cmds.setKeyframe( self.ActiveNode + attribs[ i ], insert = True, time = ( frame, frame ) ) frameInfo.SetTranslationKey( i ) else: # ... se borra la key ... #cmds.selectKey( self.ActiveNode + attribs[ i ], add = True, keyframe = True, time = ( frame, frame ) ) cmds.cutKey( self.ActiveNode + attribs[ i ], time = ( frame, frame ), option = "keys" ) frameInfo.RemoveTranslationKey( i ) refreshCurve = True # ... if ( refreshCurve ): self.CreateCurve()
def dup(*args): neg = cmds.checkBox("negChck", q=True, v=True) mrge = cmds.checkBox("mrgChck", q=True, v=True) dupAx = cmds.radioButtonGrp("axChck", q=True, sl=True) selected = cmds.ls(sl=True) print(mrge) if(dupAx==1): scaD = ".scaleX" if(dupAx==2): scaD = ".scaleY" if(dupAx==3): scaD = ".scaleZ" if(neg==1): scaVal = -1 else: scaVal = 1 newDup = cmds.duplicate(rr=True) cmds.setAttr(newDup[0] + scaD, scaVal) if (mrge==1): cmds.polyUnite(selected, newDup[0]) cmds.polyMergeVertex(d=1) else: None
def drawCheckBox(self,elem,x,y,w=None,h=None): """ Draw a checkBox @type elem: dictionary @param elem: the button dictionary @type x: int @param x: position on x in the gui windows @type y: int @param y: position on y in the gui windows @type w: int @param w: force the width of the item @type h: int @param h: force the height of the item """ # cmds.iconTextCheckBox( label='Sticks',style='iconAndTextHorizontal', # image1=ICONSDIR+'bs.xpm', cc=self._displayBS ) name = elem["name"] if elem["label"] != None: name = elem["label"] if elem["value"] is None : elem["value"] = False print (name,elem["value"],bool(elem["value"]),elem["width"]*self.scale,elem["height"]*self.scale,self.scale) if elem["action"] is not None : elem["id"] = cmds.checkBox(label=name,cc=elem["action"], v=bool(elem["value"]),w=elem["width"]*self.scale, h=elem["height"]*self.scale,recomputeSize=False) else : elem["id"] = cmds.checkBox(label=name,v=bool(elem["value"]), w=elem["width"]*self.scale, h=elem["height"]*self.scale,recomputeSize=False)
def read_windowInfo(): import cPickle import sgBFunction_fileAndPath if not os.path.exists( WinA_Global.infoPath ): sgBFunction_fileAndPath.makeFile( WinA_Global.infoPath ) sgBFunction_fileAndPath.makeFile( WinA_Global.infoPathPath ) try: f = open( WinA_Global.infoPath, 'r' ) data = cPickle.load( f ) f.close() except: return None if not data: return None try:exportPath, exportType, searchFor, searchForType, splitStringAndSerchCheck, splitStringAndSearchString = data except: return None cmds.textField( WinA_Global.exportPath_txf, e=1, tx= exportPath ) items = cmds.radioCollection( WinA_Global.exportType_radio, q=1, cia=1 ) cmds.radioButton( items[ exportType ], e=1, sl=1 ) cmds.textField( WinA_Global.searchFor_txf, e=1, tx=searchFor ) items = cmds.radioCollection( WinA_Global.searchForType_radio, q=1, cia=1 ) cmds.radioButton( items[ searchForType ], e=1, sl=1 ) cmds.checkBox( WinA_Global.searchForType_check, e=1, v=splitStringAndSerchCheck ) cmds.textField( WinA_Global.searchForType_txf, e=1, tx=splitStringAndSearchString )
def loadHotkeys(self, defaults=False): allHotkeys = hotkeys.getHotkeys() hotkeysDict = [] for n, loopHotkey in enumerate(allHotkeys): for loopItem in loopHotkey: hotkeysDict.append(loopItem) for loopIndex, loopCommand in enumerate(hotkeysDict): command = loopCommand["command"] name = loopCommand["name"] key = loopCommand["hotkey"] alt = loopCommand["alt"] ctl = loopCommand["ctl"] toolTip = loopCommand["toolTip"] if not defaults: hotkeyData = aToolsMod.loadInfoWithUser("hotkeys", name) if hotkeyData != None: key = hotkeyData[0] alt = hotkeyData[1] ctl = hotkeyData[2] cmds.checkBox('ctl%s'%name, edit=True, value=ctl) cmds.checkBox('alt%s'%name, edit=True, value=alt) cmds.scrollField('key%s'%name, edit=True, text=key) self.updateHotkeyCheck(name)
def rsChangeCheck(i_b_state, i_s_floatField): if i_s_floatField == "rsMinField": i_b_state = cmds.checkBox("rsMinBox", query=True, value=True) else: i_b_state = cmds.checkBox("rsMaxBox", query=True, value=True) l_oSels = rsObjList() if i_b_state == True: if i_s_floatField == "rsMinField": b_minimum = cmds.attributeQuery(l_oSels[1], node=l_oSels[0], minExists=True) f_atValue = 0.0 if b_minimum == 1: f_atValue = (cmds.attributeQuery(l_oSels[1], node=l_oSels[0], minimum=True))[0] else: cmds.addAttr(l_oSels[2], edit=True, hasMinValue=True) if i_s_floatField == "rsMaxField": b_maximum = cmds.attributeQuery(l_oSels[1], node=l_oSels[0], maxExists=True) f_atValue = 1.0 if b_maximum == 1: f_atValue = (cmds.attributeQuery(l_oSels[1], node=l_oSels[0], maximum=True))[0] else: cmds.addAttr(l_oSels[2], edit=True, hasMaxValue=True) cmds.addAttr(l_oSels[2], edit=True, maxValue=f_atValue) cmds.floatField(i_s_floatField, edit=True, value=f_atValue, enable=True) else: cmds.floatField(i_s_floatField, edit=True, value=0, enable=False) if i_s_floatField == "rsMinField": cmds.addAttr(l_oSels[2], edit=True, hasMinValue=False) else: cmds.addAttr(l_oSels[2], edit=True, hasMaxValue=False) return True
def displayUI(self): windowName = 'LCMTUIWindow' if cmds.window(windowName, exists=True): cmds.deleteUI(windowName) window = cmds.window(windowName, menuBar = True,t="LCMT v3.1.1") fileMenu = cmds.menu( label='Manage Light Types') cmds.menuItem( label='Add More Light Types',command=lambda *args:self.addLightTypes()) cmds.menuItem( label='See Current Light Types', command=lambda *args:self.displayLightTypes()) cmds.menuItem( label='Reset Light Types to Default Values', command=lambda *args:self.resetLightTypesToDefault()) cmds.paneLayout( configuration='vertical2' ) lightStageColumn = cmds.columnLayout(adjustableColumn=True) cmds.text('Lights in the SCENE') lights = cmds.ls(dag =True,visible=True,lights=True, type='mentalrayIblShape') lightList = cmds.iconTextScrollList(allowMultiSelection=True, append=lights) cmds.rowLayout(numberOfColumns = 2) useGroupLights = cmds.checkBox( label='Group Lights', onCommand = lambda *args: self.updateScollList(True, lightList), offCommand = lambda *args: self.updateScollList(False, lightList)) cmds.checkBox( label='Save Images?', cc = lambda *args: self.toggleSaveImages()) cmds.setParent('..') cmds.iconTextScrollList(lightList,edit=True,selectCommand=lambda *args: cmds.select(self.getElementsFromLightScrollList(lightList,useGroupLights),vis=True)) cmds.button(label='Render Lights!', command = lambda *args: self.renderAllLights(self.getElementsFromLightScrollList(lightList,useGroupLights),cmds.checkBox(useGroupLights, query=True, value=True))) cmds.setParent('..') renderLayersColumn = cmds.columnLayout(adjustableColumn=True) #new column cmds.text('Geometry in the SCENE') geometry = cmds.ls(geometry=True) #take out the ibl shapes from the geo selection geometry = list(set(geometry) - set(lights)) geoList = cmds.iconTextScrollList(allowMultiSelection=True, append=geometry,selectCommand=lambda *args: cmds.select(cmds.iconTextScrollList(geoList, query=True, si=True )) ) cmds.text('Create Render Layers from selected geometry and lights') cmds.button(label='Create Render Layers!', command = lambda *args: self.createLayersFromLights(cmds.iconTextScrollList(geoList, query=True, si=True ),self.getElementsFromLightScrollList(lightList,useGroupLights))) cmds.setParent('..') cmds.showWindow()
def update(self, *args ): self.repairString = '' cmds.scrollField( self.scrollField, e=1, text='' ) checkUIs = [] checkUIs.append( cmds.rowColumnLayout( self.assetCheck, q=1, ca=1 ) ) checkUIs.append( cmds.rowColumnLayout( self.layoutCheck, q=1, ca=1 ) ) checkUIs.append( cmds.rowColumnLayout( self.productionCheck, q=1, ca=1 ) ) for cuCheckUIs in checkUIs: repairTitle = cmds.frameLayout( cmds.rowColumnLayout( cmds.checkBox( cuCheckUIs[0], q=1, p=1 ), q=1, p=1 ), q=1, l=1 ) onCheckBoxEx = False for checkBox in cuCheckUIs: if not checkBox in self.checkBoxs: continue if cmds.checkBox( checkBox, q=1, v=1 ): if not onCheckBoxEx: self.repairString += repairTitle+' : ' onCheckBoxEx = True self.addRepairString( cmds.checkBox( checkBox, q=1, l=1 ) ) if onCheckBoxEx: self.repairString += u' 수정\n' self.editFieldString()
def create(self): if cmds.window( self.winName, ex=1 ): cmds.deleteUI( self.winName, wnd=1 ) cmds.window( self.winName, title=self.title ) form = cmds.formLayout() form_cloneTarget = self.uiCloneTargets.create() form_cloneLabel = self.uiCloneLabel.create() chk_shapeOn = cmds.checkBox( l='Shape On', v=1 ) chk_connectionOn = cmds.checkBox( l='Connection On', v=0 ) bt_createClone = cmds.button( l='C R E A T E C L O N E', h=25, c = WinA_Cmd.cmdCreateClone ) cmds.setParent( '..' ) cmds.formLayout( form, e=1, af = [( form_cloneTarget, 'top', 5 ), ( form_cloneTarget, 'left', 5 ), ( form_cloneTarget, 'right', 5 ), ( form_cloneLabel, 'top', 5 ), ( form_cloneLabel, 'left', 5 ), ( form_cloneLabel, 'right', 5 ), ( chk_shapeOn, 'left', 50 ), ( bt_createClone, 'left', 0 ),( bt_createClone, 'right', 0 )], ac = [( form_cloneLabel, 'top', 10, form_cloneTarget ), ( chk_shapeOn, 'top', 10, form_cloneLabel ), ( chk_connectionOn, 'top', 10, form_cloneLabel ), ( chk_connectionOn, 'left', 30, chk_shapeOn ), ( bt_createClone, 'top', 10, chk_connectionOn )] ) cmds.window( self.winName, e=1, wh=[ self.width, self.height ], rtf=1 ) cmds.showWindow( self.winName ) WinA_Global.ui_clones = self.uiCloneTargets WinA_Global.chk_shapeOn = chk_shapeOn WinA_Global.chk_connectionOn = chk_connectionOn
def createUI(self): if cmds.window(self.winName, exists=True): cmds.deleteUI(self.winName) cmds.window(self.winName, title=self.winTitle, maximizeButton=False, minimizeButton=False, resizeToFitChildren=True) self.mainCol = cmds.columnLayout( adjustableColumn=True ) cmds.gridLayout(numberOfRowsColumns=[2,2], cellWidthHeight=[120,20]) cmds.text('OSC port') self.ui_oscport = cmds.intField(minValue=0, maxValue=65535, value=self.osc_port, changeCommand=partial(self.set_port), enable=not self.ServerStarted) cmds.text('Scale') self.ui_scaling = cmds.floatField(minValue=0, maxValue=1000, value=self.scaling, changeCommand=partial(self.set_scaling)) cmds.setParent(upLevel=True) self.nullsbox = cmds.checkBox( value=self.create, label='Create locators based on received data', changeCommand=partial(self.set_create) ) self.recbox = cmds.checkBox( value=self.record, label='Record motion capture', changeCommand=partial(self.set_record) ) self.rootbox = cmds.checkBox(value=self.createRoot, label='Parent locators to a root object', changeCommand=partial(self.set_createRoot)) if self.ServerStarted: self.receiveButton = cmds.button( label='Stop Receiving', command=partial(self.toggle_server) ) else: self.receiveButton = cmds.button( label='Start Receiving', command=partial(self.toggle_server) ) cmds.showWindow( self.winName )
def assignCustomMateColorUI( self, colorMat = 'RL_SOMECOLOR', col = (1,1,1)): mc.columnLayout() mc.colorSliderGrp( 'customColorColorSlider', rgb = col ) mc.checkBox( 'customAlpha_chb', l = 'With Alpha', v = True ) mc.rowColumnLayout( nc = 2 ) mc.button( l = 'Create', w = 120, c = self.assignNewMateColorUi ) mc.button( l = 'Cancel', w = 120, c = self.dismissCustomColorUI )
def buildGUI(self): if cmds.window(self.name, q=True, exists=True): cmds.deleteUI(self.name) cmds.window(self.name, title=self.title, sizeable=False, mxb=False, mnb=False, toolbox=False, w=100, h=30) cmds.columnLayout("mainLayout", adj=True, parent=self.name, co=("left", 5)) # Add onClose Event cmds.scriptJob(uiDeleted=(self.name, self.onClose)) # Help Menu cmds.menuBarLayout("menuBar") cmds.menu(label="Show Help", helpMenu =True, pmc=self.showHelp) # Import paths cmds.textFieldButtonGrp("tfbDBPath", label="Links: ", bl="Set Link Path", cw=(1,50), parent="mainLayout", bc=self.setDBPath) cmds.textFieldButtonGrp("tfbShaderPath", label="Shaders: ", bl="Set Shader Path", cw=(1,50), parent="mainLayout", bc=self.setShaderPath) cmds.checkBox("cbSelection", label="Use Selection", parent="mainLayout") cmds.checkBox("cbSubstring", label="Substring prefix", parent="mainLayout", value=True) cmds.textField("tfSubstring", parent="mainLayout", text="s100_char") cmds.separator(h=10, style="none", parent="mainLayout") # Buttons cmds.rowColumnLayout("buttonsLayout", numberOfColumns=2, parent="mainLayout") cmds.button("bExportLinks", label = "Export Links", w=200, h=30, parent="buttonsLayout", c=self.exportLinks) cmds.button("bImportShader", label="Link Shaders", w=200, h=30, parent="buttonsLayout", c=self.linkShaders) cmds.showWindow(self.name)
def loadUI(self, ui_file): """ Loads the UI and does an post-load commands """ # monkey patch the cmds module for use when the UI gets loaded cmds.submit_callb = partial(self.get_initial_value, self) cmds.do_submit_callb = partial(self.submit, self) if cmds.window('SubmitDialog', q=True, ex=True): cmds.deleteUI('SubmitDialog') name = cmds.loadUI(f=ui_file) cmds.textScrollList('layers', e=True, append=self.layers) # check for existing projects to determine how project selection should # be displayed num_existing_projs = cmds.optionMenu('existing_project_name', q=True, ni=True) if num_existing_projs == 0: cmds.radioButton('existing_project', e=True, en=False) else: cmds.radioButton('existing_project', e=True, en=True) # callbacks cmds.checkBox('upload_only', e=True, changeCommand=self.upload_only_toggle) cmds.checkBox('distributed', e=True, changeCommand=self.distributed_toggle) cmds.optionMenu('renderer', e=True, changeCommand=self.change_renderer) cmds.radioButton('new_project', e=True, onCommand=self.select_new_project) cmds.radioButton('existing_project', e=True, onCommand=self.select_existing_project) self.change_renderer( self.renderer ) self.select_new_project( True ) return name
def updateData(self, useRootOffsetData=False): if useRootOffsetData: #Take out offset useZ = cmds.checkBox(g_rootOffsetZBox, q=True, value=True) useY = cmds.checkBox(g_rootOffsetYBox, q=True, value=True) rootPosition = cmds.xform('Root', q=True, t=True) boxPosition = cmds.xform( self.m_name, q=True, t=True) #zero X because we don't care boxPosition[0] = 0 if useZ and useY: #Both Axis offset boxPosition[1] = boxPosition[1] - rootPosition[1] boxPosition[2] = boxPosition[2] - rootPosition[2] elif useZ and not useY: boxPosition[2] = boxPosition[2] - rootPosition[2] elif not useZ and useY: boxPosition[1] = boxPosition[1] - boxPosition[1] self.m_position = boxPosition self.m_position = (round(self.m_position[0]),round(self.m_position[1]),round(self.m_position[2])) self.m_scale = cmds.xform( self.m_name, q=True, s=True, relative=True ) self.m_width = round(cmds.polyCube( self.m_name, q=True, w=True ) * abs(self.m_scale[0]),2) self.m_height = round(cmds.polyCube( self.m_name, q=True, h=True ) * abs(self.m_scale[1]),2) else: self.m_position = cmds.xform( self.m_name, q=True, t=True ) #Finds the translation, we should probably be finding the point of hte bottom left corner?? self.m_position = (round(self.m_position[0]),round(self.m_position[1]),round(self.m_position[2])) self.m_scale = cmds.xform( self.m_name, q=True, s=True, relative=True ) self.m_width = round(cmds.polyCube( self.m_name, q=True, w=True ) * abs(self.m_scale[0]),2) self.m_height = round(cmds.polyCube( self.m_name, q=True, h=True ) * abs(self.m_scale[1]),2)
def setAnimationNameToAttackFormat(): if cmds.checkBox(g_isAttackAnimation, q=True, value=True): generatedName = '' if cmds.checkBox(g_isGroundAttackCheckBox, q=True, value=True): generatedName += 'Ground_' else: generatedName += 'Air_' if cmds.checkBox(g_isMeleeAttackCheckBox, q=True, value=True): generatedName += 'Melee_' else: #is a special weapon anim selectedSpecial = cmds.textScrollList(g_specialWeaponType, q=True, si=True)[0] if selectedSpecial == 'Elemental Gauntlets': generatedName += 'Elemental_' elif selectedSpecial == 'Flux Rifle': generatedName += 'Flux_' elif selectedSpecial == 'Traps': generatedName += 'Traps_' selectedDirection = cmds.textScrollList(g_attackDirection, q=True, si=True)[0] if selectedDirection == 'Forward': generatedName += 'Forward' elif selectedDirection == 'Backward': generatedName += 'Backward' elif selectedDirection == 'Lunge': generatedName += 'Lunge' elif selectedDirection == 'Up': generatedName += 'Up' elif selectedDirection == 'Down': generatedName += 'Down' elif selectedDirection == 'Neutral': generatedName += 'Neutral' cmds.textField(g_animationNameField, e=True, tx=generatedName)
def UI_custom(self): cmds.rowLayout(nc=2,columnWidth=[1,100],adj=2) cmds.text(label='Number of Joints :') numJoints = len(self.jointInfo) self.numberOfJointsField = cmds.intField(value=numJoints, min=2, changeCommand=self.changeNumberOfJoints) cmds.setParent('..') joints = self.getJoints() self.createRotationOrderUIControl(joints[0]) cmds.separator() cmds.text(label='Orientation:', align='left') cmds.rowLayout(nc=3) cmds.attrEnumOptionMenu(attribute=self.moduleNamespace+':module_grp.sao_local',label='Local:') cmds.text(label=' will be oriented to ') cmds.attrEnumOptionMenu(attribute=self.moduleNamespace+':module_grp.sao_world',label='World:') cmds.setParent('..') cmds.separator() interpolating = False if cmds.objExists(self.moduleNamespace+':interpolation_container'): interpolating = True cmds.rowLayout(nc=2,columnWidth=[1,80], adj=2) cmds.text(label='Interpolate:') cmds.checkBox(label='',value=interpolating, onc=partial(self.setup_interpolation, True),ofc=self.delete_interpolation)
def refreshFloatField(self, *args ): timeControl = cmds.textScrollList( self._timeControl, q=1, si=1 ) if not timeControl: return None timeControl = timeControl[-1] weight = cmds.getAttr( timeControl+'.weight' ) offset = cmds.getAttr( timeControl+'.offset' ) mult = cmds.getAttr( timeControl+'.mult' ) limitAble = cmds.getAttr( timeControl+'.limitAble' ) minTime = cmds.getAttr( timeControl+'.minTime' ) maxTime = cmds.getAttr( timeControl+'.maxTime' ) cmds.floatField( self._weight, e=1, v=weight ) cmds.floatField( self._offset, e=1, v=offset ) cmds.floatField( self._mult, e=1, v=mult ) cmds.checkBox( self._limitAble, e=1, v=limitAble ) cmds.floatField( self._minTime, e=1, v=minTime ) cmds.floatField( self._maxTime, e=1, v=maxTime ) if cmds.checkBox( self._limitAble, q=1, v=1 ): cmds.rowColumnLayout( self._limitAbleLay, e=1, en=1 ) else: cmds.rowColumnLayout( self._limitAbleLay, e=1, en=0 ) for popup in self._popupList: popup.updateCondition()
def handlePB(*args): percent = cmds.floatField("playblastValue", q=True, v=True) #check to see if sequence option is selected seqTag = cmds.checkBox("sequenceOption", query=True, value =True) #check for auto review submission revTag = cmds.checkBox("reviewOption", query=True, value =True) runPB(percent, seqTag, revTag)
def read_windowInfo(): import cPickle import sgBFunction_fileAndPath sgBFunction_fileAndPath.makeFile( WinA_Global.keyExportInfoFile, False ) sgBFunction_fileAndPath.makeFile( WinA_Global.cacheExportInfoFile, False ) sgBFunction_fileAndPath.makeFile( WinA_Global.infoPath, False ) import sgBModel_aniScene upFolderNum, addPath = sgBModel_aniScene.exportCachePathFromAni sceneName = cmds.file( q=1, sceneName=1 ) sceneFolder = '/'.join( sceneName.split( '/' )[:-1+upFolderNum] ) cacheExportPath = sceneFolder + addPath upFolderNum, addPath = sgBModel_aniScene.exportKeyPathFromAni sceneName = cmds.file( q=1, sceneName=1 ) sceneFolder = '/'.join( sceneName.split( '/' )[:-1+upFolderNum] ) keyExportPath = sceneFolder + addPath cmds.textField( WinA_Global.exportKeyPath_txf, e=1, tx=keyExportPath ) cmds.textField( WinA_Global.exportCachePath_txf, e=1, tx=cacheExportPath ) try: f = open( WinA_Global.infoPath, 'r' ) data = cPickle.load( f ) f.close() cacheTypeIndex = data[0] exportByMatrix = data[1] cmds.optionMenu( WinA_Global.optionMenu, e=1, sl=cacheTypeIndex ) cmds.checkBox( WinA_Global.chk_exportByMatrix , e=1, v=exportByMatrix ) except: return None
def __init__(self): self.name = "pythant" self.title = "Pythant" #creates the ui window, replacing any existing ui windows if (cmds.window(self.name, q=1, exists=1)): cmds.deleteUI(self.name) self.window = cmds.window(self.name, title=self.title) self.form = cmds.columnLayout(adjustableColumn=True, columnAlign="center", rowSpacing=10) cmds.intFieldGrp("numAnts", label="Number of ants:", value1=1, cal=[1,"left"]) cmds.intFieldGrp("startFrame", label="Start frame:", value1=1, nf=1,cal=[1,"left"]) cmds.intFieldGrp("endFrame", label="End frame:",nf=1,value1=50,cal=[1,"left"]) cmds.text( label="Select the curves:",align="left") cmds.textScrollList("curves",numberOfRows=3,allowMultiSelection=True,h=100) cmds.button(label="OK",w=20, align="left",c=self.getCurves) cmds.textFieldButtonGrp("groundObj", label="Select the Ground:",buttonLabel='OK', bc=self.getGround,cal=[1,"left"]) cmds.checkBox("isFlat",label="Is this a flat ground",value=1) cmds.floatSliderGrp("Velocity",field=True, label="Velocity (mm/s):",min=1, max=40,value=20, cal=[1,"left"]) #cmds.floatSliderGrp("strideFreq",field=True, label="Stride Frequency:",min=1, max=10,value=5, cal=[1,"left"]) cmds.floatSliderGrp("load",field=True, label="Load (mg):",min=0, max=4,value=0, cal=[1,"left"]) # cmds.textFieldButtonGrp("force", label="External Force", buttonLabel='OK', bc = self.getForce, cal=[1, "left"]) cmds.text( label='The external force is setup with a directional light named forceVector.') cmds.text( label='The force magnitude (N) is specified with the custom attribute "Force Magnitude".') cmds.text(label='The lighting direction is the force direction.') cmds.button(label='Run', w=100, c=self.accept) cmds.button(label='Reset', w=100, c=self.reset) cmds.showWindow(self.window) cmds.window(self.window, edit = True, widthHeight=(415, 580))
def unfoldBand_window(): """ This definition creates the 'Unfold Band' main window. """ cmds.windowPref(enableAll=False) if (cmds.window("unfoldBand_window", exists=True)): cmds.deleteUI("unfoldBand_window") cmds.window("unfoldBand_window", title="Unfold Band", width=384) spacing = 5 cmds.columnLayout(adjustableColumn=True, rowSpacing=spacing) cmds.separator(height=10, style="singleDash") cmds.intSliderGrp("divisions_intSliderGrp", label="Divisions", field=True, minValue=0, maxValue=10, fieldMinValue=0, fieldMaxValue=65535, value=2) cmds.separator(style="single") cmds.columnLayout(columnOffset=("left", 140)) cmds.checkBox("keepConstructionHistory_checkBox", label="Keep Construction History", v=True) cmds.setParent(topLevel=True) cmds.separator(height=10, style="singleDash") cmds.button("unfoldBand_button", label="Unfold Band!", command=unfoldBand_button_OnClicked) cmds.showWindow("unfoldBand_window") cmds.windowPref(enableAll=True)
def changeAssetStatus(self,stageVar): #get asset name assetNameVar=cmds.textScrollList('assetTextScroll',q=True,si=True) if assetNameVar==None: cmds.confirmDialog(icn='warning', t='Error', m='No asset selected from asset list.', button=['Ok']) self.populateTable() raise StandardError, 'error : no asset selected from asset list' assetNameVar=assetNameVar[0] #parsing stage and change the status respectively if stageVar=='model': statusVar=cmds.checkBox('assetTrackModelCheck',q=True,v=True) if statusVar==True: statusVar=2 else: statusVar=0 veRegCore.updateAssetRecord(name=assetNameVar,modelStat=statusVar) elif stageVar=='shader': statusVar=cmds.checkBox('assetTrackShaderCheck',q=True,v=True) if statusVar==True: statusVar=2 else: statusVar=0 veRegCore.updateAssetRecord(name=assetNameVar,shaderStat=statusVar) elif stageVar=='rig': statusVar=cmds.checkBox('assetTrackRigCheck',q=True,v=True) if statusVar==True: statusVar=2 else: statusVar=0 veRegCore.updateAssetRecord(name=assetNameVar,rigStat=statusVar) self.listLegacyAndPicture() return
def checkEachEdit( *args ): for chk in WinA_Global.checkList: if not cmds.checkBox( chk, q=1, v=1 ): cmds.checkBox( WinA_Global.chk_all, e=1, v=0 ) return None cmds.checkBox( WinA_Global.chk_all, e=1, v=1 )
def floatUI(): # Check to see if window exists if cmds.window("PBQuality", exists=True): cmds.deleteUI("PBQuality") # Create window window = cmds.window("PBQuality", title="DPA Playblast", w=300, h=100, mnb=False, mxb=False, sizeable=False) # Create a main layout mainLayout = cmds.columnLayout(adj=True) blastLayout = cmds.columnLayout("blastLayout", p=mainLayout, w=260, adj=False, rs=5, cat=('left', 5)) cmds.separator(p=blastLayout) cmds.text(label="Enter desired playbast quality:", p=blastLayout) qualityField = cmds.floatField("playblastValue", p=blastLayout, w=250, min=50, max=100, pre=0, step=1, v=90, ed=True) qualitySlider = cmds.floatSlider("playblastPercentage", p=blastLayout, w=250, min=50, max=100, step=1, v=90, dc=updatePercent) cmds.separator(p=blastLayout) sequenceOption = cmds.checkBox("sequenceOption", label="From Sequence", value=False) reviewOption = cmds.checkBox("reviewOption", label="Auto-bot review submission", value=False) cmds.separator(p=blastLayout) confirmLayout = cmds.rowColumnLayout("confirmLayout", p=mainLayout, w=250, nc=2, rs=(5, 5), co=[(1, 'left', 5), (2, 'right', 5)], cw=[(1, 125), (2, 125)]) cancelButton = cmds.button("cancelButton", p=confirmLayout, label="Cancel", c="cmds.deleteUI('PBQuality')", w=80, h=30) pbButton = cmds.button("pbButton", p=confirmLayout, label="Playblast", c=handlePB, w=100, h=30) cmds.separator(p=confirmLayout) cmds.showWindow(window)
def setObjectToShatterCmd(self, *args): ''' ''' if not (cmds.draggerContext(self._IScontextTool._mContext, exists = True)): iMinTime = cmds.playbackOptions(query = True, minTime = True) cmds.currentTime(iMinTime, edit = True) polySelection = cmds.filterExpand(selectionMask = 12) if polySelection: if len(polySelection) > 0: mBreakNode = cmds.listConnections(polySelection[0], sh = True, type = 'fxBreakGeometry') if not mBreakNode: cmds.button(self._ISaddBtn, edit = True, label = 'Please wait... checking mesh toplogy') self._IScontextTool.checkForNonManifoldMeshes(polySelection[0]) cmds.delete(polySelection[0], ch = True) self.resetIShatterGUI() self._IScontextTool._mVoroObject = polySelection[0] cmds.button(self._ISaddBtn, edit = True, label = polySelection[0]) cmds.button(self._ISdelBtn, edit = True, enable = True) cmds.button(self._ISprocessBtn, edit = True, enable = True) cmds.checkBox(self._ISborderEdgesCbx, edit = True, enable = True) cmds.checkBox(self._IShideObjectsCbx, edit = True, enable = True) else: cmds.confirmDialog(title = 'Oups... IShatter Error', message = 'You must select one mesh object first !', button = 'OK', defaultButton = 'Yes', cancelButton = 'No', dismissString = 'No')
def __init__(self): if cmds.window('renderSceneGenerator', exists=True): cmds.deleteUI('renderSceneGenerator', wnd=True) cmds.window('renderSceneGenerator', t='Render Scene Generator', s=False) cmas = cmds.columnLayout(adj=True) f1 = cmds.frameLayout(l='Scene Browse', w=200) cmds.columnLayout(adj=True) cmds.text(l='Episode Name:', al='left', fn='boldLabelFont', w=200) cmds.textScrollList('episodeName', w=200, h=80, sc=self.episodeChange) cmds.text(l='Sequence Name:', al='left', fn='boldLabelFont') cmds.textScrollList('sequenceName', w=200, h=80, en=False, sc=self.sequenceChange) f2 = cmds.frameLayout(l='Exported MCC Data', p=cmas) cmds.columnLayout(adj=True) cmds.textScrollList('serverMccData2',w=200, h=100, ams=True, en=False) f3 = cmds.frameLayout(l='Camera', p=cmas) cmds.columnLayout(adj=True) cmds.checkBox('includeCamera', l='Include Scene Camera', v=0) cmds.separator(p=cmas) cmds.button(l='GENERATE WITH ALL MCC', p=cmas, bgc=[1.0,0.643835616566,0.0], h=40,\ c=self.mccProcessAll) cmds.button(l='GENERATE WITH SELECTED MCC', p=cmas, c=self.mccProcessSingle) cmds.button(l='REFRESH', p=cmas, c=self.refresh) cmds.showWindow() #populate episode for item in os.listdir(SEQUENCE_ROOT+'/'+PRJ_NAME+'/EPISODES'): cmds.textScrollList('episodeName', e=True, a=item) return
def createWindow(name, callback): # check if the window exists already if cmds.window("mayaExporterReady", exists=True): cmds.deleteUI("mayaExporterReady") _win = cmds.window("mayaExporterReady", title=name) cmds.rowColumnLayout("global", adjustableColumn=True, columnOffset=[1, "both", storage.globalColumnOffset]) cmds.shelfTabLayout('mainShelfTab', w=storage.shelfWidth) # GENERAL PANEL cmds.columnLayout("General", adj=False, columnOffset=["both", storage.inShelfOffset]) cmds.text(l='<span style="font-size:18px">General options</span>', font="boldLabelFont") cmds.text(l="") cmds.checkBox( "freezeTransform", l="Freeze transformations", ann="Allow the script to freeze the transformation of your selection", v=storage.values.freezeTransform) cmds.checkBox( "deleteHistory", l="Delete history", ann= "Allow the script to delete the construction history of your selection", v=storage.values.deleteHistory) cmds.checkBox( "selectionOnly", l="Selection only", ann= "Restrict the script to process only your selection\nIf false, the all scene will be processed", v=storage.values.selectionOnly) cmds.checkBox("cleanUpMesh", l="Clean up meshes", ann="Allow the script to go through a clean up your meshes", v=storage.values.cleanUpMesh) cmds.checkBox( "checkNonManyfold", l="Check for non-manyfold meshes", ann= "Allow the script to check non-manifold meshes and giving feedback if found", v=storage.values.checkNonManyfold) cmds.text(l="") cmds.setParent('..') # NORMAL PANEL cmds.columnLayout("Normal", adj=False, columnOffset=["both", storage.inShelfOffset]) cmds.text(l='<span style="font-size:18px">Normals options</span>', font="boldLabelFont") cmds.text(l="") cmds.checkBox( "conformNormals", l="Conform normals", ann= "Conform the normals of your meshes.\nSet the normal to the average normal direction", v=storage.values.conformNormals) cmds.checkBox( "rebuildNormals", l="Rebuild normals", ann= "Rebuilds all normals of the mesh with custom angles\nSoft: angle = 30\nHard: angle = 0", v=storage.values.rebuildNormals, cc=enableRebuildOption) cmds.text(label="") cmds.text(label="Rebuild options:", align="left") cmds.radioButtonGrp("rebuildNormalOption", labelArray3=['Soft', 'Hard', 'Custom'], numberOfRadioButtons=3, select=storage.values.rebuildNormalOption, vertical=True, enable=storage.values.rebuildNormals, cc=enableCustomAngle) cmds.intField("customNormalAngle", min=0, max=180, v=storage.values.customNormalAngle, enable=getRebuildOption()) cmds.text(l="") cmds.setParent('..') # PIVOT PANEL cmds.columnLayout("Pivot", adj=False, columnOffset=["both", storage.inShelfOffset]) cmds.text(l='<span style="font-size:18px">Pivot options</span>', font="boldLabelFont") cmds.text(l="") cmds.radioButtonGrp( "pivotOption", labelArray4=[ 'Untouched', 'Mesh center', 'Scene center', 'Base center' ], numberOfRadioButtons=4, an1="Don't modify the pivot parameters", an2="Set the pivot position at the center of every meshes", an3="Set the pivot of every meshes at the center of the scene", an4= "Set the pivot of every meshes at the center of the mesh for XZ coordinates\nand at the lowest vertex position for the Y coordinate", select=storage.values.pivotOption, vertical=True) cmds.text(l="") cmds.setParent('..') # EXPORT PANEL cmds.columnLayout("Export", adj=False, columnOffset=["both", storage.inShelfOffset]) cmds.text(l='<span style="font-size:18px">Export settings</span>', font="boldLabelFont") cmds.text(l="") cmds.checkBox("exportResult", l="Export result", ann="Allow the script to export the result of the process", v=storage.values.exportResult, cc=onEnableExport) cmds.checkBox( "exportAsOneObject", l="Export as one object", ann="The script will export the selection as one only object", v=storage.values.exportAsOneObject, cc=updateExportNameLabel) cmds.text(l="") cmds.text("exportFolderInput", l="Export path:") cmds.rowLayout(adjustableColumn=2, numberOfColumns=2) cmds.textField("exportFolderInput", ann="Path of the folder where the exported files will drop", fi=storage.values.exportFolder, w=300, h=26, cc=checkExportFolder) cmds.button("exportFolderBrowserButton", ann="Open dialog to search an export folder", l="Browse", c=searchExportFolder) cmds.setParent('..') cmds.text(l="") cmds.text("exportNameLabel", l="") cmds.text("exportNameLabel", e=True, l=updateExportNameLabel(storage.values.exportAsOneObject)) storage.scene = cmds.file(q=True, sn=True) storage.sceneName, storage.sceneExt = os.path.splitext( os.path.basename(storage.scene)) # print("sceneName", storage.sceneName) cmds.textField( "exportNameInput", text=storage.values.exportName, ann="Name that will have the folder or the file that will be exported", w=351, h=26, cc=updateExportName, pht=storage.sceneName if storage.sceneName != "" else "untitled") cmds.text(l="") cmds.radioCollection("exportExtension") cmds.text("radioColExtentionLabel", l="Export as") cmds.radioButton("exportFbx", ann="The script will export the meshes as FBX", l="FBX", onCommand=onFbxExtension) cmds.radioButton("exportObj", ann="The script will export the meshes as OBJ", l="OBJ", onCommand=onObjExtension) cmds.radioCollection("exportExtension", e=True, select=storage.values.exportExtension) onEnableExport(cmds.checkBox("exportResult", q=True, v=True)) cmds.text(l="") cmds.setParent('..') # REFERENCE PANEL cmds.columnLayout("References", adj=False, columnOffset=["both", storage.inShelfOffset]) cmds.text( l='<span style="font-size:18px">Search and import references</span>', font="boldLabelFont") cmds.columnLayout("refWraper") cmds.setParent('..') cmds.rowLayout(adjustableColumn=2, numberOfColumns=2) cmds.button( label="Search", ann="Open dialog to search a folder with\nFBX or OBJ files in it", c=searchRefs, w=150) cmds.button('unityImportRef', l='Import reference', ann="Import the selected reference into the active scene", c=importRef, w=150) cmds.setParent('..') cmds.text(l="") displayRefs(storage.values.unityRefDir) cmds.setParent('..') # SETTINGS PANEL cmds.columnLayout("Settings", adj=False, columnOffset=["both", storage.inShelfOffset]) cmds.text(l='<span style="font-size:18px">Settings options</span>', font="boldLabelFont") cmds.text(l="") cmds.checkBox( "alwaysOverrideExport", l="Override existing export file", ann= "The script will override, by default, the corresponding export file if it exists", v=storage.values.alwaysOverrideExport) cmds.checkBox( "stayInScene", l="Stay in active scene", ann= "True: the script will end on the active scene\nFalse:the script will end on the export file of the active scene", v=storage.values.stayInScene) cmds.checkBox( "displayInfo", l="Display informations", ann= "Allow the script to gives you mass informations on what is happening during the process", v=storage.values.displayInfo) cmds.text(l="") cmds.text(l="Preferences:") cmds.button("saveAsPrefs", l="Save settings", c=savePreferences, w=125) cmds.text(l="") cmds.button("resetToPrefs", l="Reset to preferences", c=resetToPrefs, w=125) cmds.text(l="") cmds.setParent('|') cmds.text(l="") cmds.button(l="Go", c=callback) cmds.rowColumnLayout("global", e=True, rowOffset=[(1, "top", storage.globalRowOffset), (len( cmds.rowColumnLayout("global", q=True, childArray=True)), "bottom", storage.globalRowOffset)]) # Display the window cmds.showWindow(_win) return _win
def createAltGUI(self, strongest, ranIntensity2, ranTime): strongestDict = self.flattenDictToVals(self.strongestShapes) newShapes = self.flattenDictToVals(self.newShapes) print strongestDict selectionUI = 'altGUI' import maya.cmds as cmds selectionUI = 'altUI' if cmds.window(selectionUI, exists=True): cmds.deleteUI(selectionUI) cmds.window(selectionUI, width=1000, height=100) form = cmds.formLayout() tabs = cmds.tabLayout(innerMarginWidth=10, innerMarginHeight=10, mcw=400, width=1000, height=300) cmds.formLayout(form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0))) child1 = cmds.gridLayout(numberOfColumns=4, cellWidthHeight=(250, 32)) cmds.text("Set Source Shapes:", font="boldLabelFont", al="center") cmds.text("Set Target Curve:", font="boldLabelFont", al="center") cmds.text("Set Intensity:", font="boldLabelFont", al="center") cmds.text("Set Timing Offset:", font="boldLabelFont", al="center") controlGroupSource = cmds.optionMenu("controlGroupSource") cmds.menuItem(label='All') for key1 in newShapes: cmds.menuItem(label=key1) controlGroupTarget = cmds.optionMenu("controlGroupTarget") cmds.menuItem(label=strongest) for key in strongestDict: cmds.menuItem(label=key) cmds.rowLayout(numberOfColumns=3, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'both', 0), (3, 'right', 0)]) # cmds.button(label='Set') cmds.floatSliderGrp(field=True, minValue=-1.0, maxValue=1.0, fieldMinValue=-1.0, fieldMaxValue=1.0, value=ranIntensity2, cw=[(1, 50), (2, 120)]) cmds.button(label='Set') cmds.setParent('..') cmds.rowLayout(numberOfColumns=3, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'both', 0), (3, 'right', 0)]) cmds.intSliderGrp(field=True, minValue=-20, maxValue=20, fieldMinValue=-100, fieldMaxValue=100, value=ranTime, cw=[(1, 50), (2, 120)]) cmds.button(label='Set') cmds.setParent('..') cmds.separator() cmds.separator() cmds.separator() cmds.separator() cmds.text(" ") cmds.text("Random Curve:", font="boldLabelFont", al="center") cmds.text("Sample Intensity:", font="boldLabelFont", al="center") cmds.text("Sample Timing Offset:", font="boldLabelFont", al="center") cmds.text(" ") cmds.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'right', 0)]) cmds.text("") cmds.button(label='Sample', width=50) cmds.setParent('..') cmds.rowLayout(numberOfColumns=3, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'both', 0), (3, 'right', 0)]) cmds.floatSliderGrp(field=True, minValue=-1.0, maxValue=1.0, fieldMinValue=-1.0, fieldMaxValue=1.0, value=0.25, cw=[(1, 50), (2, 120)]) cmds.button(label='Sample') cmds.setParent('..') cmds.rowLayout(numberOfColumns=3, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'both', 0), (3, 'right', 0)]) cmds.intSliderGrp(field=True, minValue=-20, maxValue=20, fieldMinValue=-100, fieldMaxValue=100, value=20, cw=[(1, 50), (2, 120)]) cmds.button(label='Sample') cmds.setParent('..') cmds.separator() cmds.separator() cmds.separator() cmds.separator() cmds.text('Current Elite', font="boldLabelFont", al="center") cmds.button(label='Add to Selection') cmds.button(label='Add to Selection') cmds.button(label='Add to Selection') cmds.setParent('..') child2 = cmds.gridLayout(numberOfColumns=3, cellWidthHeight=(250, 40)) cmds.text("FACE 1:", font="boldLabelFont", al="center") cmds.text("FACE 2:", font="boldLabelFont", al="center") cmds.text("FACE 3:", font="boldLabelFont", al="center") str1 = "Sample Curve = %s\nIntensity = %f\nTiming Offset = %i" % ( "brows_l_CTL", 0.52, 15) cmds.text(str1, font="boldLabelFont", al="center") cmds.text(str1, font="boldLabelFont", al="center") cmds.text(str1, font="boldLabelFont", al="center") cmds.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'right', 0)]) cmds.text(" ") cmds.checkBox(editable=True, label=" Select") cmds.setParent('..') cmds.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'right', 0)]) cmds.text(" ") cmds.checkBox(editable=True, label=" Select") cmds.setParent('..') cmds.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'right', 0)]) cmds.text(" ") cmds.checkBox(editable=True, label=" Select") cmds.setParent('..') cmds.separator() cmds.separator() cmds.separator() cmds.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'right', 0)]) cmds.button(label=" < Previous ") cmds.text(" ") cmds.setParent('..') cmds.rowLayout(numberOfColumns=3, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'both', 0), (3, 'right', 0)]) cmds.text("Select Elite:") cmds.intField(minValue=1, maxValue=100, value=20, editable=True) cmds.button(label='Breed Next Gen') cmds.setParent('..') cmds.rowLayout(numberOfColumns=2, adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'left', 0), (2, 'right', 0)]) cmds.text(" ") cmds.button(label=" Next > ") cmds.setParent('..') cmds.setParent('..') cmds.tabLayout( tabs, edit=True, tabLabel=((child1, '\t\t\t\t\t\t\t\t\tSampling\t\t\t\t\t\t\t\t\t'), (child2, '\t\t\t\t\t\t\t\t\tEvolution\t\t\t\t\t\t\t\t\t'))) cmds.showWindow()
def __init__(self, CTL_TREE, allStartingWeights, allNeutralWeights, allCurrentGenWeights, strongestShapes, minMaxWeights, allSymmetryNames, OTHER_FACE_IDS): self.ctlTree = CTL_TREE self.allStartingWeights = allStartingWeights self.allCurrentGenWeights = allCurrentGenWeights self.allCurrentWeights = allCurrentGenWeights self.allNeutralWeights = allNeutralWeights self.allMinMaxWeights = minMaxWeights self.strongestShapes = strongestShapes self.generationSelection = [] self.nextGeneration = [] self.allSymmetryNames = allSymmetryNames self.buttonList = [] self.newShapes = {} self.startingCurves = {} self.currentGenCurves = {} self.OTHER_FACE_IDS = OTHER_FACE_IDS self.originalStrongest = strongestShapes winID = 'rigUI' if cmds.window(winID, exists=True): cmds.deleteUI(winID) cmds.window(winID, width=100, height=100) cmds.columnLayout("columnLayout") controlGroup = cmds.optionMenu("controlGroup", label='Control Group') cmds.menuItem(label='All') for key in self.ctlTree: cmds.menuItem(label=key) cmds.text(label="Symmetry On:") symFlag = cmds.checkBox("symFlag", label='symFlag', align='right', editable=True) # Add controls into this Layout cmds.text(label="Number of Shapes to mutate:") numShapes = cmds.intField("numShapes", minValue=1, maxValue=10, value=3, editable=True, parent="columnLayout") cmds.text(label="Mutate Rate Upper:") mRateUpper = cmds.floatField("mRateUpper", minValue=0.0, maxValue=1.0, value=0.25, editable=True, parent="columnLayout") cmds.text(label="Constrain to Active Shapes:") constrainFlag = cmds.checkBox(label='constrainFlag', align='right', editable=True) cmds.text(label="Sample around Current Weight:") sampleFlag = cmds.checkBox(label='sampleWeight', align='right', editable=True, value=True) cmds.button(label='Random Sample from Current', command=partial(self.randomMizeCTLs, numShapes, mRateUpper, constrainFlag, sampleFlag, controlGroup, symFlag)) cmds.button(label='Reset To Gen', command=partial(self.updateRig, 'currentGen')) cmds.button(label='Reset To Starting', command=partial(self.updateRig, 'starting')) cmds.button(label='Reset To Neutral', command=partial(self.updateRig, 'neutral')) cmds.button(label='Set Current as Next Gen', command=partial(self.setCurrentGen)) cmds.button(label='Add to selection', command=partial(self.addCurrentToSelection)) cmds.text(label="Elite from Selection:") eliteId = cmds.intField("eliteId", minValue=1, maxValue=10, value=1, editable=True, parent="columnLayout") cmds.button(label='Spawn Next Gen from Selection', command=partial(self.spawnNextGen, eliteId, numShapes, mRateUpper, constrainFlag, sampleFlag, controlGroup, symFlag)) cmds.button(label='Next', command=partial(self.displayNext)) cmds.button(label='Set Keyframe', command=partial(self.setKeyframes)) minTime = cmds.playbackOptions(minTime=True, query=True) maxTime = cmds.playbackOptions(maxTime=True, query=True) startTime = cmds.intField("startTime", minValue=0, value=minTime, editable=True, parent="columnLayout") endTime = cmds.intField("endTime", value=maxTime, editable=True, parent="columnLayout") cmds.button(label='Next Curve sample', command=partial(self.sampleNewCurvesFromOld)) # Display the window cmds.showWindow()
def spawnNextGen(self, eliteId, numShapes, mRateUpper, cFlag, cGroup, *args): print "Spawning next gen" cmds.showWindow('rigUI') eliteNum = cmds.intField(eliteId, query=True, value=True) - 1 numSampleShapes = cmds.intField(numShapes, query=True, value=True) upperLim = cmds.floatField(mRateUpper, query=True, value=True) constrainFlag = cmds.checkBox(cFlag, query=True, value=True) controlGroup = cmds.optionMenu("controlGroup", query=True, value=True) symFlag = cmds.checkBox("symFlag", query=True, value=True) genSelectionAll = self.generationSelection nextGeneration = self.nextGeneration print genSelectionAll selectedIds = self.getSelectedFromWindow() print "SelectedIds: %s" % selectedIds genSelection = [ x for i, x in enumerate(genSelectionAll) if i in selectedIds ] # print genSelection for child in genSelection: print child for i in range(20): # Small mutations around Elite if i < 5: eliteCTLtree = copy.deepcopy(genSelectionAll[eliteNum]) randEliteTree = self.randomCTLweights(eliteCTLtree, numSampleShapes, upperLim, True, True, controlGroup, symFlag) nextGeneration.append(randEliteTree) # Breeding of Elite and Other Selected elif i < 10: eliteCTLtree = copy.deepcopy(genSelectionAll[eliteNum]) secondTree = random.choice(genSelection) bredTree = self.breedTrees(eliteCTLtree, secondTree, controlGroup) nextGeneration.append(bredTree) # Breeding of Elite and Other Selected + Mutation elif i < 15: eliteCTLtree = copy.deepcopy(genSelectionAll[eliteNum]) secondTree = random.choice(genSelection) bredTree = self.breedTrees(eliteCTLtree, secondTree, controlGroup) randEliteTree = self.randomCTLweights(bredTree, numSampleShapes, upperLim, True, False, controlGroup, symFlag) nextGeneration.append(randEliteTree) # Less constrained mutation else: eliteCTLtree = copy.deepcopy(genSelectionAll[eliteNum]) randEliteTree = self.randomCTLweights(eliteCTLtree, 2, upperLim, False, False, controlGroup, symFlag) nextGeneration.append(randEliteTree) #Add elite face at end self.allCurrentGenWeights = eliteCTLtree self.updateRig('currentGen')
def __init__(self, parent, name, **kwds): self.data = TMSet() self.name = name self.form = mc.formLayout(parent=parent) self.showcheck = lambda: self.data.nodes is not None self.checkbox = mc.checkBox(parent=self.form, label="", manage=self.showcheck()) self.label = mc.text(parent=self.form, label=self.name, width=90, manage=SETTINGS["show_label"]) mode = SETTINGS["show_mode"] self.slider = mc.floatSlider(parent=self.form, min=-100, max=100, value=0, manage=mode in ["both", "slider"], changeCommand=self.tween_slider, dragCommand=self.update_field) self.field = mc.floatField(parent=self.form, min=-100, max=100, value=0, width=50, pre=1, step=1, changeCommand=self.tween_field, enterCommand=self.tween_field, dragCommand=self.tween_field) # Attach the checkbox mc.formLayout(self.form, e=True, attachForm=[(self.checkbox, "left", 5), (self.checkbox, "top", 0)]) # Attach the label mc.formLayout(self.form, e=True, attachControl=[(self.label, "left", 5, self.checkbox)]) mc.formLayout(self.form, e=True, attachForm=[(self.label, "top", 3)]) labelOffset = 90 * int(SETTINGS["show_label"]) # Attach the field mc.formLayout(self.form, e=True, attachForm=[(self.field, "left", labelOffset), (self.field, "top", 0)]) # Attach the slider mc.formLayout(self.form, e=True, attachForm=[(self.slider, "left", labelOffset + 55), (self.slider, "right", 5), (self.slider, "top", 3)]) # Build and attach the button row self.buttonrow = TMButtonRowUI(self, self.form, **kwds) mc.formLayout(self.buttonrow.form, e=True, manage=mode in ["both", "buttons"]) mc.formLayout(self.form, e=True, attachForm=[(self.buttonrow.form, "left", labelOffset + 55), (self.buttonrow.form, "top", 5 + (20 * int(mode != "buttons"))), (self.buttonrow.form, "right", 5)]) # If overshoot mode is active, then force-toggle the overshoot if SETTINGS["use_overshoot"]: self.toggle_overshoot()
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # create lists to be integrated: # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp + ".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp + ".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0] + '_', self.mirrorNames[len(self.mirrorNames) - 1] + '_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate( self.moduleGrp, name=side + self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side + self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side + self.userGuideName + '_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename( self.mirrorGrp, side + self.userGuideName + '_' + self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr( side + self.userGuideName + '_' + self.mirrorGrp + '.scale' + axis, -1) # joint labelling: jointLabelAdd = 1 else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName + '_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName + "_" + item) self.mirrorGrp = cmds.group(self.userGuideName + '_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName + '_' + self.mirrorGrp) # joint labelling: jointLabelAdd = 0 # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): # redeclaring variables: self.base = side + self.userGuideName + "_Guide_Base" self.cvFootLoc = side + self.userGuideName + "_Guide_Foot" self.cvRFALoc = side + self.userGuideName + "_Guide_RfA" self.cvRFBLoc = side + self.userGuideName + "_Guide_RfB" self.cvRFCLoc = side + self.userGuideName + "_Guide_RfC" self.cvRFDLoc = side + self.userGuideName + "_Guide_RfD" self.cvRFELoc = side + self.userGuideName + "_Guide_RfE" self.cvEndJoint = side + self.userGuideName + "_Guide_JointEnd" # declaring attributes reading from dictionary: ankleRFAttr = self.langDic[self.langName]['c009_leg_extrem'] middleRFAttr = self.langDic[ self.langName]['c017_RevFoot_middle'] outsideRFAttr = self.langDic[self.langName]['c010_RevFoot_A'] insideRFAttr = self.langDic[self.langName]['c011_RevFoot_B'] heelRFAttr = self.langDic[self.langName]['c012_RevFoot_C'] toeRFAttr = self.langDic[self.langName]['c013_RevFoot_D'] ballRFAttr = self.langDic[self.langName]['c014_RevFoot_E'] footRFAttr = self.langDic[self.langName]['c015_RevFoot_F'] sideRFAttr = self.langDic[self.langName]['c016_RevFoot_G'] rfRoll = self.langDic[ self.langName]['c018_RevFoot_roll'].capitalize() rfSpin = self.langDic[ self.langName]['c019_RevFoot_spin'].capitalize() rfTurn = self.langDic[ self.langName]['c020_RevFoot_turn'].capitalize() rfAngle = self.langDic[ self.langName]['c102_angle'].capitalize() rfPlant = self.langDic[ self.langName]['c103_plant'].capitalize() showCtrlsAttr = self.langDic[ self.langName]['c021_showControls'] # creating joints: cmds.select(clear=True) self.footJnt = cmds.joint(name=side + self.userGuideName + "_" + ankleRFAttr.capitalize() + "_Jnt") utils.setJointLabel( self.footJnt, s + jointLabelAdd, 18, self.userGuideName + "_" + ankleRFAttr.capitalize()) self.middleFootJxt = cmds.joint( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_Jxt") self.endJnt = cmds.joint(name=side + self.userGuideName + "_JEnd") cmds.select(clear=True) self.middleFootJnt = cmds.joint( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_Jnt") utils.setJointLabel( self.middleFootJnt, s + jointLabelAdd, 18, self.userGuideName + "_" + middleRFAttr.capitalize()) self.endBJnt = cmds.joint(name=side + self.userGuideName + "B_JEnd") cmds.parent(self.middleFootJnt, self.middleFootJxt) cmds.addAttr(self.footJnt, longName='dpAR_joint', attributeType='float', keyable=False) cmds.addAttr(self.middleFootJnt, longName='dpAR_joint', attributeType='float', keyable=False) cmds.select(clear=True) ''' Deactivate the segment scale compensate on the bone to prevent scaling problem in maya 2016 It will prevent a double scale problem that will come from the upper parent in the rig ''' if (int(cmds.about(version=True)[:4]) >= 2016): cmds.setAttr(self.footJnt + ".segmentScaleCompensate", 0) cmds.setAttr( self.middleFootJxt + ".segmentScaleCompensate", 0) cmds.setAttr( self.middleFootJnt + ".segmentScaleCompensate", 0) # reverse foot controls: self.RFACtrl = self.ctrls.cvControl( "id_018_FootReverse", side + self.userGuideName + "_" + outsideRFAttr.capitalize() + "_Ctrl", r=(self.ctrlRadius * 0.1), d=self.curveDegree) self.RFBCtrl = self.ctrls.cvControl( "id_018_FootReverse", side + self.userGuideName + "_" + insideRFAttr.capitalize() + "_Ctrl", r=(self.ctrlRadius * 0.1), d=self.curveDegree) self.RFCCtrl = self.ctrls.cvControl( "id_018_FootReverse", side + self.userGuideName + "_" + heelRFAttr.capitalize() + "_Ctrl", r=(self.ctrlRadius * 0.1), d=self.curveDegree, dir="+Y", rot=(0, 90, 0)) self.RFDCtrl = self.ctrls.cvControl( "id_018_FootReverse", side + self.userGuideName + "_" + toeRFAttr.capitalize() + "_Ctrl", r=(self.ctrlRadius * 0.1), d=self.curveDegree, dir="+Y", rot=(0, 90, 0)) self.RFECtrl = self.ctrls.cvControl( "id_019_FootReverseE", side + self.userGuideName + "_" + ballRFAttr.capitalize() + "_Ctrl", r=(self.ctrlRadius * 0.1), d=self.curveDegree, rot=(0, 90, 0)) # reverse foot groups: self.RFAGrp = cmds.group(self.RFACtrl, name=self.RFACtrl + "_Grp") self.RFBGrp = cmds.group(self.RFBCtrl, name=self.RFBCtrl + "_Grp") self.RFCGrp = cmds.group(self.RFCCtrl, name=self.RFCCtrl + "_Grp") self.RFDGrp = cmds.group(self.RFDCtrl, name=self.RFDCtrl + "_Grp") self.RFEGrp = cmds.group(self.RFECtrl, name=self.RFECtrl + "_Grp") rfGrpList = [ self.RFAGrp, self.RFBGrp, self.RFCGrp, self.RFDGrp, self.RFEGrp ] self.ballRFList.append(self.RFEGrp) # putting groups in the correct place: tempToDelA = cmds.parentConstraint(self.cvFootLoc, self.footJnt, maintainOffset=False) tempToDelB = cmds.parentConstraint(self.cvRFELoc, self.middleFootJxt, maintainOffset=False) tempToDelC = cmds.parentConstraint(self.cvEndJoint, self.endJnt, maintainOffset=False) tempToDelD = cmds.parentConstraint(self.cvEndJoint, self.endBJnt, maintainOffset=False) tempToDelE = cmds.parentConstraint(self.cvRFALoc, self.RFAGrp, maintainOffset=False) tempToDelF = cmds.parentConstraint(self.cvRFBLoc, self.RFBGrp, maintainOffset=False) tempToDelG = cmds.parentConstraint(self.cvRFCLoc, self.RFCGrp, maintainOffset=False) tempToDelH = cmds.parentConstraint(self.cvRFDLoc, self.RFDGrp, maintainOffset=False) tempToDelI = cmds.parentConstraint(self.cvRFELoc, self.RFEGrp, maintainOffset=False) cmds.delete(tempToDelA, tempToDelB, tempToDelC, tempToDelD, tempToDelE, tempToDelF, tempToDelG, tempToDelH, tempToDelI) # mounting hierarchy: cmds.parent(self.RFBGrp, self.RFACtrl) cmds.parent(self.RFCGrp, self.RFBCtrl) cmds.parent(self.RFDGrp, self.RFCCtrl) cmds.parent(self.RFEGrp, self.RFDCtrl) # reverse foot zero out groups: self.RFEZero = utils.zeroOut([self.RFEGrp])[0] self.RFEZeroExtra = utils.zeroOut([self.RFEZero])[0] self.RFDZero = utils.zeroOut([self.RFDGrp])[0] self.RFCZero = utils.zeroOut([self.RFCGrp])[0] self.RFBZero = utils.zeroOut([self.RFBGrp])[0] self.RFAZero = utils.zeroOut([self.RFAGrp])[0] self.RFAZeroExtra = utils.zeroOut([self.RFAZero])[0] rfJointZeroList = [ self.RFAZero, self.RFBZero, self.RFCZero, self.RFDZero, self.RFEZero ] # fixing side rool rotation order: cmds.setAttr(self.RFBZero + ".rotateOrder", 5) # creating ikHandles: ikHandleAnkleList = cmds.ikHandle( name=side + self.userGuideName + "_" + ankleRFAttr.capitalize() + "_IkHandle", startJoint=self.footJnt, endEffector=self.middleFootJxt, solver='ikSCsolver') ikHandleMiddleList = cmds.ikHandle( name=side + self.userGuideName + "_" + middleRFAttr.capitalize() + "_IkHandle", startJoint=self.middleFootJxt, endEffector=self.endJnt, solver='ikSCsolver') cmds.rename(ikHandleAnkleList[1], ikHandleAnkleList[0] + "_Effector") cmds.rename(ikHandleMiddleList[1], ikHandleMiddleList[0] + "_Effector") cmds.setAttr(ikHandleAnkleList[0] + '.visibility', 0) cmds.setAttr(ikHandleMiddleList[0] + '.visibility', 0) # creating Fk controls: self.footCtrl = self.ctrls.cvControl( "id_020_FootFk", side + self.userGuideName + "_" + self.langDic[self.langName]['c009_leg_extrem'] + "_Ctrl", r=(self.ctrlRadius * 0.5), d=self.curveDegree, dir="+Z") self.footCtrlList.append(self.footCtrl) cmds.setAttr(self.footCtrl + ".rotateOrder", 1) self.revFootCtrlShapeList.append( cmds.listRelatives(self.footCtrl, children=True, type='nurbsCurve')[0]) self.middleFootCtrl = self.ctrls.cvControl( "id_021_FootMiddle", side + self.userGuideName + "_" + self.langDic[ self.langName]['c017_RevFoot_middle'].capitalize() + "_Ctrl", r=(self.ctrlRadius * 0.5), d=self.curveDegree) cmds.setAttr(self.middleFootCtrl + '.overrideEnabled', 1) cmds.setAttr(self.middleFootCtrl + ".rotateOrder", 4) tempToDelA = cmds.parentConstraint(self.cvFootLoc, self.footCtrl, maintainOffset=False) tempToDelB = cmds.parentConstraint(self.cvRFELoc, self.middleFootCtrl, maintainOffset=False) cmds.delete(tempToDelA, tempToDelB) if s == 1: cmds.setAttr(self.middleFootCtrl + ".scaleX", -1) cmds.setAttr(self.middleFootCtrl + ".scaleY", -1) cmds.setAttr(self.middleFootCtrl + ".scaleZ", -1) self.footCtrlZeroList = utils.zeroOut( [self.footCtrl, self.middleFootCtrl]) self.middleFootCtrlList.append(self.middleFootCtrl) # mount hierarchy: cmds.parent(self.footCtrlZeroList[1], self.RFDCtrl, absolute=True) cmds.parent(ikHandleMiddleList[0], self.middleFootCtrl, absolute=True) self.toLimbIkHandleGrp = cmds.group( empty=True, name=side + self.userGuideName + "_" + self.langDic[self.langName]['c009_leg_extrem'] + "_Grp") self.toLimbIkHandleGrpList.append(self.toLimbIkHandleGrp) cmds.parent(ikHandleAnkleList[0], self.toLimbIkHandleGrp, self.RFECtrl, absolute=True) cmds.makeIdentity(self.toLimbIkHandleGrp, apply=True, translate=True, rotate=True, scale=True) parentConst = cmds.parentConstraint(self.RFECtrl, self.footJnt, maintainOffset=True, name=self.footJnt + "_ParentConstraint")[0] self.parentConstList.append(parentConst) self.footJntList.append(self.footJnt) cmds.parent(self.RFAZeroExtra, self.footCtrl, absolute=True) scaleConst = cmds.scaleConstraint(self.footCtrl, self.footJnt, maintainOffset=True, name=self.footJnt + "_ScaleConstraint") self.scaleConstList.append(scaleConst) cmds.parentConstraint(self.middleFootCtrl, self.middleFootJnt, maintainOffset=True, name=self.middleFootJnt + "_ParentConstraint") cmds.scaleConstraint(self.middleFootCtrl, self.middleFootJnt, maintainOffset=True, name=self.middleFootJnt + "_ScaleConstraint") # add attributes to footCtrl and connect them to reverseFoot groups rotation: rfAttrList = [ outsideRFAttr, insideRFAttr, heelRFAttr, toeRFAttr, ballRFAttr ] rfTypeAttrList = [rfRoll, rfSpin] for j, rfAttr in enumerate(rfAttrList): for t, rfType in enumerate(rfTypeAttrList): if t == 1 and j == (len(rfAttrList) - 1): # create turn attr to ball cmds.addAttr(self.footCtrl, longName=rfAttr + rfTurn, attributeType='float', keyable=True) cmds.connectAttr(self.footCtrl + "." + rfAttr + rfTurn, rfGrpList[j] + ".rotateZ", force=True) self.reverseFootAttrList.append(rfAttr + rfTurn) cmds.addAttr(self.footCtrl, longName=rfAttr + rfType, attributeType='float', keyable=True) self.reverseFootAttrList.append(rfAttr + rfType) if t == 0: if j > 1: cmds.connectAttr(self.footCtrl + "." + rfAttr + rfType, rfGrpList[j] + ".rotateX", force=True) else: cmds.connectAttr(self.footCtrl + "." + rfAttr + rfType, rfGrpList[j] + ".rotateZ", force=True) else: cmds.connectAttr(self.footCtrl + "." + rfAttr + rfType, rfGrpList[j] + ".rotateY", force=True) # creating the originedFrom attributes (in order to permit integrated parents in the future): utils.originedFrom(objName=self.footCtrl, attrString=self.base + ";" + self.cvFootLoc + ";" + self.cvRFALoc + ";" + self.cvRFBLoc + ";" + self.cvRFCLoc + ";" + self.cvRFDLoc) utils.originedFrom(objName=self.middleFootCtrl, attrString=self.cvRFELoc + ";" + self.cvEndJoint) # creating pre-defined attributes for footRoll and sideRoll attributes, also rollAngle: cmds.addAttr(self.footCtrl, longName=footRFAttr + rfRoll, attributeType='float', keyable=True) cmds.addAttr(self.footCtrl, longName=footRFAttr + rfRoll + rfAngle, attributeType='float', defaultValue=30, keyable=True) cmds.addAttr(self.footCtrl, longName=footRFAttr + rfRoll + rfPlant, attributeType='float', defaultValue=0, keyable=True) cmds.addAttr(self.footCtrl, longName=sideRFAttr + rfRoll, attributeType='float', keyable=True) # create clampNodes in order to limit the side rotations: sideClamp = cmds.createNode("clamp", name=side + self.userGuideName + "_Side_Clp") # outside values in R cmds.setAttr(sideClamp + ".minR", -360) # inside values in G cmds.setAttr(sideClamp + ".maxG", 360) # inverting sideRoll values: sideMD = cmds.createNode("multiplyDivide", name=side + self.userGuideName + "_Side_MD") cmds.setAttr(sideMD + ".input2X", -1) # connections: cmds.connectAttr(self.footCtrl + "." + sideRFAttr + rfRoll, sideMD + ".input1X", force=True) cmds.connectAttr(sideMD + ".outputX", sideClamp + ".inputR", force=True) cmds.connectAttr(sideMD + ".outputX", sideClamp + ".inputG", force=True) cmds.connectAttr(sideClamp + ".outputR", self.RFAZero + ".rotateZ", force=True) cmds.connectAttr(sideClamp + ".outputG", self.RFBZero + ".rotateZ", force=True) # for footRoll: footHeelClp = cmds.createNode("clamp", name=side + self.userGuideName + "_Roll_Heel_Clp") # heel values in R cmds.setAttr(footHeelClp + ".minR", -360) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll, footHeelClp + ".inputR", force=True) cmds.connectAttr(footHeelClp + ".outputR", self.RFCZero + ".rotateX", force=True) # footRoll with angle limit: footPMA = cmds.createNode("plusMinusAverage", name=side + self.userGuideName + "_Roll_PMA") footSR = cmds.createNode("setRange", name=side + self.userGuideName + "_Roll_SR") cmds.setAttr(footSR + ".oldMaxY", 180) cmds.setAttr(footPMA + ".input1D[0]", 180) cmds.setAttr(footPMA + ".operation", 2) #substract cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll, footSR + ".valueX", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll, footSR + ".valueY", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfAngle, footSR + ".maxX", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfAngle, footSR + ".oldMinY", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfAngle, footSR + ".oldMaxX", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfAngle, footPMA + ".input1D[1]", force=True) cmds.connectAttr(footPMA + ".output1D", footSR + ".maxY", force=True) # plant angle for foot roll: footPlantClp = cmds.createNode("clamp", name=side + self.userGuideName + "_Roll_Plant_Clp") footPlantCnd = cmds.createNode("condition", name=side + self.userGuideName + "_Roll_Plant_Cnd") cmds.setAttr(footPlantCnd + ".operation", 4) #less than cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll, footPlantClp + ".inputR", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfPlant, footPlantClp + ".maxR", force=True) cmds.connectAttr(footPlantClp + ".outputR", footPlantCnd + ".firstTerm", force=True) cmds.connectAttr(footPlantClp + ".outputR", footPlantCnd + ".colorIfTrueR", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfPlant, footPlantCnd + ".secondTerm", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfPlant, footPlantCnd + ".colorIfFalseR", force=True) # back to zero footRoll when greather then angle plus plant values: anglePlantPMA = cmds.createNode( "plusMinusAverage", name=side + self.userGuideName + "_AnglePlant_PMA") anglePlantMD = cmds.createNode("multiplyDivide", name=side + self.userGuideName + "_AnglePlant_MD") anglePlantRmV = cmds.createNode( "remapValue", name=side + self.userGuideName + "_AnglePlant_RmV") anglePlantCnd = cmds.createNode( "condition", name=side + self.userGuideName + "_AnglePlant_Cnd") cmds.setAttr(anglePlantMD + ".input2X", -1) cmds.setAttr(anglePlantRmV + ".inputMax", 90) cmds.setAttr(anglePlantRmV + ".value[0].value_Interp", 3) #spline cmds.setAttr(anglePlantRmV + ".value[1].value_Interp", 3) #spline cmds.setAttr(anglePlantCnd + ".operation", 2) #greather than cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfAngle, anglePlantPMA + ".input1D[0]", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll + rfPlant, anglePlantPMA + ".input1D[1]", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll, anglePlantCnd + ".firstTerm", force=True) cmds.connectAttr(anglePlantPMA + ".output1D", anglePlantCnd + ".secondTerm", force=True) cmds.connectAttr(anglePlantPMA + ".output1D", anglePlantMD + ".input1X", force=True) cmds.connectAttr(anglePlantPMA + ".output1D", anglePlantRmV + ".inputMin", force=True) cmds.connectAttr(anglePlantMD + ".outputX", anglePlantRmV + ".outputMax", force=True) cmds.connectAttr(self.footCtrl + "." + footRFAttr + rfRoll, anglePlantRmV + ".inputValue", force=True) cmds.connectAttr(anglePlantRmV + ".outColorR", anglePlantCnd + ".colorIfTrueR", force=True) cmds.connectAttr(anglePlantCnd + ".outColorR", self.RFEZeroExtra + ".rotateX", force=True) # connect to groups in order to rotate them: cmds.connectAttr(footSR + ".outValueY", self.RFDZero + ".rotateX", force=True) cmds.connectAttr(footSR + ".outValueX", self.RFEZero + ".rotateX", force=True) if s == 0: #left cmds.connectAttr(footPlantCnd + ".outColorR", self.footCtrlZeroList[1] + ".rotateX", force=True) else: #fix right side mirror footPlantInvMD = cmds.createNode( "multiplyDivide", name=side + self.userGuideName + "_Plant_Inv_MD") cmds.setAttr(footPlantInvMD + ".input2X", -1) cmds.connectAttr(footPlantCnd + ".outColorR", footPlantInvMD + ".input1X", force=True) cmds.connectAttr(footPlantInvMD + ".outputX", self.footCtrlZeroList[1] + ".rotateX", force=True) # organizing keyable attributes: self.ctrls.setLockHide([self.middleFootCtrl, self.footCtrl], ['v'], l=False) # show or hide reverseFoot controls: cmds.addAttr(self.footCtrl, longName=showCtrlsAttr, attributeType='long', min=0, max=1, defaultValue=1) cmds.setAttr(self.footCtrl + "." + showCtrlsAttr, keyable=False, channelBox=True) showHideCtrlList = [ self.RFACtrl, self.RFBCtrl, self.RFCCtrl, self.RFDCtrl ] for rfCtrl in showHideCtrlList: rfCtrlShape = cmds.listRelatives(rfCtrl, children=True, type='nurbsCurve')[0] cmds.connectAttr(self.footCtrl + "." + showCtrlsAttr, rfCtrlShape + ".visibility", force=True) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group( self.footCtrlZeroList[0], name=side + self.userGuideName + "_Control_Grp") self.revFootCtrlGrpFinalList.append(self.toCtrlHookGrp) self.toScalableHookGrp = cmds.createNode( "transform", name=side + self.userGuideName + "_Joint_Grp") mWorldFoot = cmds.getAttr(self.footJnt + ".worldMatrix") cmds.xform(self.toScalableHookGrp, matrix=mWorldFoot, worldSpace=True) cmds.parent(self.footJnt, self.toScalableHookGrp, absolute=True) #Remove the Joint orient to make sure the bone is at the same orientation than it's parent cmds.setAttr(self.footJnt + ".jointOrientX", 0) cmds.setAttr(self.footJnt + ".jointOrientY", 0) cmds.setAttr(self.footJnt + ".jointOrientZ", 0) self.aScalableGrp.append(self.toScalableHookGrp) self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, name=side + self.userGuideName + "_Grp") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp + ".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp + '.dpAR_count', dpAR_count) # create a locator in order to avoid delete static group loc = cmds.spaceLocator(name=side + self.userGuideName + "_DO_NOT_DELETE")[0] cmds.parent(loc, self.toStaticHookGrp, absolute=True) cmds.setAttr(loc + ".visibility", 0) self.ctrls.setLockHide([loc], [ 'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v' ]) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') if hideJoints: cmds.setAttr(self.toScalableHookGrp + ".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side + self.userGuideName + '_' + self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def getRebuildOption(): return cmds.radioButtonGrp("rebuildNormalOption", q=True, select=True) == 3 and cmds.checkBox( "rebuildNormals", q=True, v=True)
def check_all(self, *args): """ checks all of the caches in the UI """ for box in self.checkBoxes: cmds.checkBox(box, e=1, v=1)
def BuildUI(self): #global spineValue ########################################### # Create the basic window ## ########################################### # Create a window with the name Auto Rigger base.window("Auto Rigger") form = base.formLayout() tabs = base.tabLayout(imh = 5, imw = 5) base.formLayout(form, edit = True, attachForm=((tabs, 'top',0), (tabs,'left', 0), (tabs, 'right', 0), (tabs, 'bottom',0))) # set the layout of the window ch1 = base.rowColumnLayout(nc = 1, cal = (1, 'right'), adjustableColumn = True) base.image(w = 400, h = 100, image = os.path.dirname(os.path.realpath(__file__))+"\logo.jpg") settingsText = base.text('Settings', l = 'Rig Settings') base.separator(st = 'none') #base.text(l = 'Prefix', w = 100) self.prefix = base.textFieldGrp(w = 100, text = 'test', editable = True) self.spineCount = base.intSliderGrp(l = "Spine Count", min = 1, max = 10, value = 4, step = 1, field = True) #spineCount = base.intField(minValue = 1, maxValue = 10, value = 4) self.fingerCount = base.intSliderGrp(l = "Finger Count", min = 1, max = 10, value = 5, step = 1, field = True) #fingerCount = base.intField(minValue = 0, maxValue = 10, value = 5) base.separator(h = 10, st = 'none') self.doubleElbow = base.checkBox(l = 'Double Elbow', align = 'left' ) base.setParent('..') ch2 = base.rowColumnLayout(nc = 1, cal = (1, 'right'), adjustableColumn = True) base.separator(h = 10, st = 'none') base.button(l = "Create Base Locators", w = 200, c = self.DoLocators) base.separator(st = 'none') base.button(l = "Create Secondary Locators", w = 200, c = "SL.SecondaryLocators()") base.separator(st = 'none') base.button(l = "Mirror L->R", w = 200, c = "Locators.mirrorLocators()") base.separator(st = 'none', h = 20) base.button(l = "Create Facial Locators", w = 200, c = self.FaceLocators) base.separator(st = 'none') base.button(l = "Delete All Locators", w = 200, c = "Locators.deleteLocators()") base.setParent('..') ch3 = base.rowColumnLayout(nc = 1, cal = (1, 'right'), adjustableColumn = True) base.separator(st = 'none') base.button(l = "Joints Window", w = 200, c = "Joints.CreateJointsWindow()") base.separator(st = 'none') base.setParent('..') ch4 = base.rowColumnLayout(nc = 1, cal = (1, 'right'), adjustableColumn = True) base.button(l = "Add Facial Joints", w = 200, c = self.FaceJoints) base.separator(st = 'none') base.setParent('..') ch5 = base.rowColumnLayout(nc = 1, cal = (1, 'right'), adjustableColumn = True) base.button(l = "Finalize Rig", w = 200, c = self.FinalizeRig) base.separator(st = 'none') base.button(l = "Bind Skin", w = 200, c = "Constraints.BindSkin()") base.separator(st = 'none') base.button(l = "Clear Locators", w = 200, c = self.ClearScene) base.setParent('..') base.tabLayout(tabs, edit = True, tabLabel = ((ch1, 'Settings'), (ch2, 'Locators'), (ch3, 'Body Rig'), (ch4, 'Face Rig'), (ch5, 'Finalize') )) # show the actual window base.showWindow()
def check_none(self, *args): """ unchecks all of the caches in the UI """ for box in self.checkBoxes: cmds.checkBox(box, e=1, v=0)
def snapIt(*args): """does the snapping by xform. Should work with any rotation order, etc""" mode = cmds.radioButtonGrp(widgets["avgRBG"], q=True, sl=True) translate = cmds.checkBoxGrp(widgets["cbg"], q=True, v1=True) rotate = cmds.checkBoxGrp(widgets["cbg"], q=True, v2=True) pivot = cmds.checkBox(widgets["rpCB"], q=True, v=True) sel = cmds.ls(sl=True) if mode == 1: target = sel[0] objects = sel[1:] for obj in objects: if translate: if pivot: targetPos = cmds.xform(target, ws=True, q=True, rp=True) else: targetPos = cmds.xform(target, ws=True, q=True, t=True) cmds.xform(obj, ws=True, t=targetPos) if rotate: #get rot order of obj tarRot = cmds.xform(target, ws=True, q=True, ro=True) objRO = cmds.xform(obj, q=True, roo=True) tarRO = cmds.xform(target, q=True, roo=True) cmds.xform(obj, roo=tarRO) cmds.xform(obj, ws=True, ro=tarRot) cmds.xform(obj, roo=objRO, p=True) cmds.select(objects) else: if (len(sel) >= 2): targets = sel[0:-1] object = sel[-1:][0] objRO = cmds.xform(object, q=True, roo=True) # tarPosList = [] # tarRotList = [] txList = [] tyList = [] tzList = [] rxList = [] ryList = [] rzList = [] TX, TY, TZ, RX, RY, RZ = 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 for tar in targets: if pivot: tarPos = cmds.xform(tar, q=True, ws=True, rp=True) else: tarPos = cmds.xform(tar, q=True, ws=True, t=True) txList.append(tarPos[0]) tyList.append(tarPos[1]) tzList.append(tarPos[2]) #convert it to the rot order of the object tarRO = cmds.xform(tar, q=True, roo=True) cmds.xform(tar, p=True, roo=objRO) #get the rotation tarRot = cmds.xform(tar, q=True, ws=True, ro=True) rxList.append(tarRot[0]) ryList.append(tarRot[1]) rzList.append(tarRot[2]) #convert it back cmds.xform(tar, p=True, roo=tarRO) #now average them all for tx in txList: TX += tx for ty in tyList: TY += ty for tz in tzList: TZ += tz for rx in rxList: RX += rx for ry in ryList: RY += ry for rz in rzList: RZ += rz avgTx = TX / len(txList) avgTy = TY / len(tyList) avgTz = TZ / len(tzList) avgRx = RX / len(rxList) avgRy = RY / len(ryList) avgRz = RZ / len(rzList) if translate: cmds.xform(object, ws=True, t=(avgTx, avgTy, avgTz)) if rotate: cmds.xform(object, ws=True, ro=(avgRx, avgRy, avgRz)) else: cmds.warning("You need to select two objects or more!")
def __init__(self): #get access to our maya tools toolsPath = cmds.internalVar(usd=True) + "mayaTools.txt" if os.path.exists(toolsPath): f = open(toolsPath, 'r') self.mayaToolsDir = f.readline() f.close() #check to see if window exists, if so, delete if cmds.window("AnimationRiggingTool_SettingsUI", exists=True): cmds.deleteUI("AnimationRiggingTool_SettingsUI") self.path = self.mayaToolsDir self.widgets = {} #create the window self.widgets["window"] = cmds.window("AnimationRiggingTool_SettingsUI", w=400, h=300, titleBarMenu=False, title="Settings", sizeable=False) #main layout self.widgets["main"] = cmds.formLayout(w=400, h=300) #background image image = self.mayaToolsDir + "/General/Icons/ART/settings.jpg" self.widgets["background"] = cmds.image(w=400, h=300, parent=self.widgets["main"], image=image) #close button self.widgets["closeButton"] = cmds.symbolButton( w=26, h=20, parent=self.widgets["main"], image=self.mayaToolsDir + "/General/Icons/ART/xbutton.bmp", c=self.close) cmds.formLayout(self.widgets["main"], edit=True, af=[(self.widgets["closeButton"], "top", 2), (self.widgets["closeButton"], "right", 2)]) #tools path self.widgets["toolsPathLabel"] = cmds.text(h=40, w=100, label="Tools Path: ", font="boldLabelFont", parent=self.widgets["main"]) self.widgets["toolsPathField"] = cmds.textField( h=40, w=225, text="", parent=self.widgets["main"], editable=False) self.widgets["toolsPathBrowseButton"] = cmds.symbolButton( w=40, h=40, parent=self.widgets["main"], image=self.mayaToolsDir + "/General/Icons/ART/browse.bmp", c=self.browseNewToolsPath) cmds.formLayout(self.widgets["main"], edit=True, af=[(self.widgets["toolsPathLabel"], "top", 40), (self.widgets["toolsPathLabel"], "left", 10)]) cmds.formLayout(self.widgets["main"], edit=True, af=[(self.widgets["toolsPathField"], "top", 40), (self.widgets["toolsPathField"], "right", 50)]) cmds.formLayout(self.widgets["main"], edit=True, af=[(self.widgets["toolsPathBrowseButton"], "top", 40), (self.widgets["toolsPathBrowseButton"], "right", 5) ]) #Source control settings divider = cmds.separator(w=400, h=10, style="out") self.widgets["useSourceControl"] = cmds.checkBox( h=40, label="Use Source Control", v=False, parent=self.widgets["main"], onc=partial(self.useSourceControl, True), ofc=partial(self.useSourceControl, False)) cmds.formLayout(self.widgets["main"], edit=True, af=[(divider, "top", 95), (divider, "left", 0)]) cmds.formLayout(self.widgets["main"], edit=True, af=[(self.widgets["useSourceControl"], "top", 105), (self.widgets["useSourceControl"], "left", 10)]) #source control test button self.widgets["testConnection"] = cmds.button( w=225, h=40, label="Test Perforce Connection", parent=self.widgets["main"], enable=False, c=self.testConnection) cmds.formLayout(self.widgets["main"], edit=True, af=[(self.widgets["testConnection"], "top", 105), (self.widgets["testConnection"], "right", 25)]) #favorite project option favoriteProjLabel = cmds.text(label="Set Favorite Project: ", parent=self.widgets["main"]) cmds.formLayout(self.widgets["main"], edit=True, af=[(favoriteProjLabel, "top", 170), (favoriteProjLabel, "left", 10)]) self.widgets["favoriteProject_OM"] = cmds.optionMenu( w=225, h=40, label="", parent=self.widgets["main"]) cmds.menuItem(label="None", parent=self.widgets["favoriteProject_OM"]) cmds.formLayout(self.widgets["main"], edit=True, af=[(self.widgets["favoriteProject_OM"], "top", 160), (self.widgets["favoriteProject_OM"], "right", 25)]) #get projects and add to menu self.findProjects() #save settings button self.widgets["saveSettings"] = cmds.button( w=380, h=40, label="Save Settings and Close", parent=self.widgets["main"], c=self.saveSettings) cmds.formLayout(self.widgets["main"], edit=True, af=[(self.widgets["saveSettings"], "bottom", 10), (self.widgets["saveSettings"], "right", 10)]) #show window cmds.showWindow(self.widgets["window"]) #get tools path self.getToolsPath() #load settings from disk settingsLocation = self.mayaToolsDir + "/General/Scripts/projectSettings.txt" if os.path.exists(settingsLocation): f = open(settingsLocation, 'r') settings = cPickle.load(f) useSource = settings.get("UseSourceControl") favoriteProject = settings.get("FavoriteProject") f.close() try: #set the checkbox to the settings value cmds.checkBox(self.widgets["useSourceControl"], edit=True, v=useSource) self.useSourceControl(useSource) except: pass try: #set the optionMenu to favorite project cmds.optionMenu(self.widgets["favoriteProject_OM"], edit=True, v=favoriteProject) except: pass
def _UI(self): if cmds.window(self.win, exists=True): cmds.deleteUI(self.win, window=True) cmds.window(self.win, title=self.win, menuBar=True, sizeable=False, widthHeight=(300,380)) cmds.menu(label='Help') cmds.menuItem(label='Watch MasterClass Video', c=lambda x:self._contactDetails(opentype='vimeo')) cmds.menuItem(label='Contact', c=r9Setup.red9ContactInfo) #cmds.menuItem(label='Contact', c=lambda x:self._contactDetails(opentype='email')) cmds.menuItem(label='Blog', c=r9Setup.red9_blog) cmds.menuItem(label='Red9HomePage', c=r9Setup.red9_website_home) cmds.columnLayout(adjustableColumn=True) cmds.text(fn="boldLabelFont", label="Advanced Bind Options") cmds.separator(h=15, style="none") cmds.rowColumnLayout(numberOfColumns=2, cw=((1,150),(2,150)),cs=((1,10))) cmds.checkBox(value=self.settings.BindRots, label="BindRots", ann="Bind only the Rotates of the given Controller", al="left", \ onc=lambda x:self.settings.__setattr__('BindRots', True), \ ofc=lambda x:self.settings.__setattr__('BindRots', False)) cmds.checkBox(value=self.settings.BindTrans, label="BindTrans", ann="Bind only the Translates of the given Controller", al="left", \ onc=lambda x:self.settings.__setattr__('BindTrans', True), \ ofc=lambda x:self.settings.__setattr__('BindTrans', False)) cmds.checkBox(value=1, label="AlignRots CtrSpace", ann="Force the BindLocator to the position of the Controller", al="left", \ onc=lambda x:self.settings.__setattr__('AlignToControlRots', True), \ ofc=lambda x:self.settings.__setattr__('AlignToSourceRots', True)) cmds.checkBox(value=1, label="AlignTrans CtrSpace", ann="Force the BindLocator to the position of the Controller", al="left", \ onc=lambda x:self.settings.__setattr__('AlignToControlTrans', True), \ ofc=lambda x:self.settings.__setattr__('AlignToSourceTrans', True)) cmds.checkBox(value=self.settings.ResetRotates, label="Reset Rots Offsets", ann="Reset any Offset during bind, snapping the systems together", al="left", \ onc=lambda x:self.settings.__setattr__('ResetRotates', True), \ ofc=lambda x:self.settings.__setattr__('ResetRotates', False)) cmds.checkBox(value=self.settings.ResetTranslates, label="Reset Trans Offsets", ann="Reset any Offset during bind, snapping the systems together", al="left", \ onc=lambda x:self.settings.__setattr__('ResetTranslates', True), \ ofc=lambda x:self.settings.__setattr__('ResetTranslates', False)) cmds.setParent('..') cmds.separator(h=10, style="none") cmds.button(label="BasicBind", al="center",\ ann="Select the Joint on the driving Skeleton then the Controller to be driven", \ c=lambda x:BindNodeBase(pm.selected()[0], pm.selected()[1], settings=self.settings).AddBinderNode()) cmds.button(label="ComplexBind", al="center",\ ann="Select the Joint on the driving Skeleton then the Controller to be driven", \ c=lambda x:BindNodeTwin(pm.selected()[0], pm.selected()[1], settings=self.settings).AddBinderNode()) cmds.button(label="AimerBind", al="center",\ ann="Select the Joint on the driving Skeleton to AIM at, then the Controller to be driven, finally a node on the driven skeleton to use as UpVector", \ c=lambda x:BindNodeAim(pm.selected()[0], pm.selected()[1], pm.selected()[2], settings=self.settings).AddBinderNode()) cmds.separator(h=15, style="none") cmds.rowColumnLayout(numberOfColumns=2,columnWidth=[(1,147),(2,147)]) cmds.button(label="Add BakeMarker", al="center", \ ann="Add the BoundCtrl / Bake Marker to the selected nodes", \ c=lambda x:addBindMarkers(cmds.ls(sl=True,l=True))) cmds.button(label="remove BakeMarker", al="center", \ ann="Remove the BoundCtrl / Bake Marker from the selected nodes", \ c=lambda x:removeBindMarker(cmds.ls(sl=True,l=True))) cmds.button(label="Select BindNodes", al="center", \ ann="Select Top Group Node of the Source Binder", \ c=lambda x:pm.select(GetBindNodes(cmds.ls(sl=True,l=True)))) cmds.button(label="Select BoundControls", al="center", \ ann="Select Top Group Node of the Bound Rig", \ c=lambda x:pm.select(GetBoundControls(cmds.ls(sl=True,l=True)))) cmds.setParent('..') cmds.rowColumnLayout(numberOfColumns=2,columnWidth=[(1,200),(2,74)], columnSpacing=[(2,5)]) cmds.button(label="Bake Binder", al="center", \ ann="Select Top Group Node of the Bound Rig", \ c=lambda x:BakeBinderData(cmds.ls(sl=True,l=True), self.settings.BakeDebug)) cmds.checkBox(value=self.settings.BakeDebug, label="Debug View", ann="Keep viewport active to observe the baking process", al="left", \ onc=lambda x:self.settings.__setattr__('BakeDebug', True), \ ofc=lambda x:self.settings.__setattr__('BakeDebug', False)) cmds.setParent('..') cmds.separator(h=10, style="none") cmds.button(label="Link Skeleton Hierarchies - Direct Connect", al="center", \ ann="Select Root joints of the source and destination skeletons to be connected - connect via attrs", \ c=lambda x:BindSkeletons(cmds.ls(sl=True)[0], cmds.ls(sl=True)[1], method='connect')) cmds.button(label="Link Skeleton Hierarchies - Constraints", al="center", \ ann="Select Root joints of the source and destination skeletons to be connected - connect via parentConstraints", \ c=lambda x:BindSkeletons(cmds.ls(sl=True)[0], cmds.ls(sl=True)[1], method='constrain')) cmds.separator(h=10, style="none") cmds.button(label="MakeStabilizer", al="center", \ ann="Select the nodes you want to extract the motion data from", \ c=lambda x:MakeStabilizedNode()) cmds.separator(h=20, style="none") cmds.iconTextButton(style='iconOnly', bgc=(0.7,0,0), image1='Rocket9_buttonStrap2.bmp', c=lambda *args:(r9Setup.red9ContactInfo()),h=22,w=200) cmds.showWindow(self.win) cmds.window(self.win,e=True,h=400)
def DoLocators(self, void): _spineCount = base.intSliderGrp(self.spineCount, q = True, v = True) _fingerCount = base.intSliderGrp(self.fingerCount, q = True, v = True) _doubleElbow = base.checkBox(self.doubleElbow, q = True, v = True) Locators.CreateLocators(_spineCount, _fingerCount, _doubleElbow)
def buildUI(self): if cmds.dockControl("cityGenerator_dockControl", exists = True): cmds.deleteUI("cityGenerator_dockControl") if cmds.window("cityGenerator_UI", exists = True): cmds.deleteUI("cityGenerator_UI") self.widgets["window"] = cmds.window("cityGenerator_UI", title = "City Generator", mnb = False, mxb = False) self.widgets["scrollLayout"] = cmds.scrollLayout(hst = 0, w = 300, cr = True) self.widgets["mainLayout"] = cmds.columnLayout(adj = True, columnAttach=('both', 0)) self.widgets["menuBarLayout"] = cmds.menuBarLayout() cmds.menu(label='Help' ) cmds.menuItem(label='Help') cmds.menuItem(label='About') #==========================================Input Files======================================================== self.widgets["inputFiles_frameLayout"] = cmds.frameLayout(label = "Input Files", collapsable = True, parent = self.widgets["mainLayout"]) self.widgets["inputFiles_formLayout"] = cmds.formLayout(h = 130, parent = self.widgets["inputFiles_frameLayout"]) self.widgets["osmFileLabel"] = cmds.text(w = 45, h= 20, label = "OSM File") self.widgets["wrfFileLabel"] = cmds.text(w = 45, h= 20, label = "WRF File") self.widgets["demFileLabel"] = cmds.text(w = 45, h= 20, label = "DEM File") self.widgets["osmFileTextField"] = cmds.textField(w = 180, h= 20, text = "") self.widgets["wrfFileTextField"] = cmds.textField(w = 180, h= 20, text = "") self.widgets["demFileTextField"] = cmds.textField(w = 180, h= 20, text = "") self.widgets["wrfCheckBox"] = cmds.checkBox(label = "Raw WRF input") self.widgets["demCheckBox"] = cmds.checkBox(label = "Raw DEM input") self.widgets["osmFileButton"] = cmds.button(w = 20, h= 20, label = "...", c = lambda x:self.openFileDialog("OSM XML (*.osm)", 1, "osmFileTextField")) self.widgets["wrfFileButton"] = cmds.button(w = 20, h= 20, label = "...", c = lambda x:self.openFileDialog("Raw WRF Data (*.nc)" if cmds.checkBox(self.widgets["wrfCheckBox"], q=True, v=True) else "Preprocessed WRF Data (*.txt)", 1, "wrfFileTextField")) self.widgets["demFileButton"] = cmds.button(w = 20, h= 20, label = "...", c = lambda x:self.openFileDialog("Raw DEM Data (*.tif)" if cmds.checkBox(self.widgets["demCheckBox"], q=True, v=True) else "Preprocessed DEM Data (*.txt)", 1, "demFileTextField")) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["osmFileLabel"], 'top', 5),(self.widgets["osmFileLabel"], 'left', 0)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["osmFileTextField"], 'top', 5),(self.widgets["osmFileTextField"], 'left', 50)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["osmFileButton"], 'top', 5),(self.widgets["osmFileButton"], 'left', 235)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["wrfFileLabel"], 'top', 30),(self.widgets["wrfFileLabel"], 'left', 0)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["wrfFileTextField"], 'top', 30),(self.widgets["wrfFileTextField"], 'left', 50)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["wrfFileButton"], 'top', 30),(self.widgets["wrfFileButton"], 'left', 235)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["wrfCheckBox"], 'top', 55),(self.widgets["wrfCheckBox"], 'left', 10)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["demFileLabel"], 'top', 80),(self.widgets["demFileLabel"], 'left', 0)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["demFileTextField"], 'top', 80),(self.widgets["demFileTextField"], 'left', 50)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["demFileButton"], 'top', 80),(self.widgets["demFileButton"], 'left', 235)]) cmds.formLayout(self.widgets["inputFiles_formLayout"], edit = True, af = [(self.widgets["demCheckBox"], 'top', 105),(self.widgets["demCheckBox"], 'left', 10)]) #==========================================Generator Settings================================================= self.widgets["generatorSettings_frameLayout"] = cmds.frameLayout(label = "Generator Settings", collapsable = True, collapse = True, parent = self.widgets["mainLayout"]) self.widgets["generatorSettings_formLayout"] = cmds.formLayout(h = 130, parent = self.widgets["generatorSettings_frameLayout"]) self.widgets["sizeMultLabel"] = cmds.text(w = 135, h= 20, label = "Size Multiplier (m/mdu)") self.widgets["sizeMultTextField"] = cmds.textField(w = 50, h= 20, text = "100") self.widgets["emitMultLabel"] = cmds.text(w = 135, h= 20, label = "Emitter Multiplier") self.widgets["emitMultTextField"] = cmds.textField(w = 50, h= 20, text = "10") self.widgets["haslLabel"] = cmds.text(w = 135, h= 20, label = "Height above sea level (m)") self.widgets["haslTextField"] = cmds.textField(w = 50, h= 20, text = "190") self.widgets["generateButton"] = cmds.button(w = 250, h= 40, label = "Generate City", c = self.generateCity) cmds.formLayout(self.widgets["generatorSettings_formLayout"], edit = True, af = [(self.widgets["sizeMultLabel"], 'top', 5),(self.widgets["sizeMultLabel"], 'left', 0)]) cmds.formLayout(self.widgets["generatorSettings_formLayout"], edit = True, af = [(self.widgets["sizeMultTextField"], 'top', 5),(self.widgets["sizeMultTextField"], 'left', 140)]) cmds.formLayout(self.widgets["generatorSettings_formLayout"], edit = True, af = [(self.widgets["haslLabel"], 'top', 30),(self.widgets["haslLabel"], 'left', 0)]) cmds.formLayout(self.widgets["generatorSettings_formLayout"], edit = True, af = [(self.widgets["haslTextField"], 'top', 30),(self.widgets["haslTextField"], 'left', 140)]) cmds.formLayout(self.widgets["generatorSettings_formLayout"], edit = True, af = [(self.widgets["emitMultLabel"], 'top', 55),(self.widgets["emitMultLabel"], 'left', 0)]) cmds.formLayout(self.widgets["generatorSettings_formLayout"], edit = True, af = [(self.widgets["emitMultTextField"], 'top', 55),(self.widgets["emitMultTextField"], 'left', 140)]) cmds.formLayout(self.widgets["generatorSettings_formLayout"], edit = True, af = [(self.widgets["generateButton"], 'top', 80),(self.widgets["generateButton"], 'left', 20)]) #==========================================Render Settings===================================================== self.widgets["renderSettings_frameLayout"] = cmds.frameLayout(label = "Render Settings", collapsable = True, collapse = True, parent = self.widgets["mainLayout"]) self.widgets["renderSettings_formLayout"] = cmds.formLayout(h = 210, parent = self.widgets["renderSettings_frameLayout"]) self.widgets["cameraDistLabel"] = cmds.text(w = 125, h= 20, label = "Camera distance (m)") self.widgets["cameraDistTextField"] = cmds.textField(w = 50, h= 20, text = "100") self.widgets["cameraHeightLabel"] = cmds.text(w = 125, h= 20, label = "Camera height (m)") self.widgets["cameraHeightTextField"] = cmds.textField(w = 50, h= 20, text = "200") self.widgets["cameraAngleLabel"] = cmds.text(w = 125, h= 20, label = "Camera angle (grad)") self.widgets["cameraAngleTextField"] = cmds.textField(w = 50, h= 20, text = "25") self.widgets["playbackTimeLabel"] = cmds.text(w = 125, h= 20, label = "Playback time (frames)") self.widgets["playbackTimeTextField"] = cmds.textField(w = 50, h= 20, text = "720") self.widgets["createCameraButton"] = cmds.button(w = 250, h= 40, label = "Create Camera", c = self.createCamera) self.widgets["pauseRenderButton"] = cmds.button(w = 120, h= 40, label = "Pause render", c = self.pauseRender) self.widgets["resumeRenderButton"] = cmds.button(w = 120, h= 40, label = "Resume render", c = self.resumeRender) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["cameraDistLabel"], 'top', 5),(self.widgets["cameraDistLabel"], 'left', 0)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["cameraDistTextField"], 'top', 5),(self.widgets["cameraDistTextField"], 'left', 130)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["cameraHeightLabel"], 'top', 30),(self.widgets["cameraHeightLabel"], 'left', 0)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["cameraHeightTextField"], 'top', 30),(self.widgets["cameraHeightTextField"], 'left', 130)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["cameraAngleLabel"], 'top', 55),(self.widgets["cameraAngleLabel"], 'left', 0)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["cameraAngleTextField"], 'top', 55),(self.widgets["cameraAngleTextField"], 'left', 130)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["playbackTimeLabel"], 'top', 80),(self.widgets["playbackTimeLabel"], 'left', 0)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["playbackTimeTextField"], 'top', 80),(self.widgets["playbackTimeTextField"], 'left', 130)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["createCameraButton"], 'top', 110),(self.widgets["createCameraButton"], 'left', 20)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["pauseRenderButton"], 'top', 160),(self.widgets["pauseRenderButton"], 'left', 20)]) cmds.formLayout(self.widgets["renderSettings_formLayout"], edit = True, af = [(self.widgets["resumeRenderButton"], 'top', 160),(self.widgets["resumeRenderButton"], 'left', 150)]) #===========================================Yandex Jams======================================================= self.widgets["yandexJams_frameLayout"] = cmds.frameLayout(label = "Yandex Jams", collapsable = True, collapse = True, parent = self.widgets["mainLayout"]) self.widgets["yandexJams_formLayout"] = cmds.formLayout(h = 30, parent = self.widgets["yandexJams_frameLayout"]) self.widgets["jamsFileLabel"] = cmds.text(w = 45, h= 20, label = "Jams File") self.widgets["jamsFileTextField"] = cmds.textField(w = 180, h= 20, text = "") self.widgets["jamsFileButton"] = cmds.button(w = 20, h= 20, label = "...", c = lambda x:self.openFileDialog("Traffic Data (*.dat)", 1, "jamsFileTextField")) cmds.formLayout(self.widgets["yandexJams_formLayout"], edit = True, af = [(self.widgets["jamsFileLabel"], 'top', 5),(self.widgets["jamsFileLabel"], 'left', 0)]) cmds.formLayout(self.widgets["yandexJams_formLayout"], edit = True, af = [(self.widgets["jamsFileTextField"], 'top', 5),(self.widgets["jamsFileTextField"], 'left', 50)]) cmds.formLayout(self.widgets["yandexJams_formLayout"], edit = True, af = [(self.widgets["jamsFileButton"], 'top', 5),(self.widgets["jamsFileButton"], 'left', 235)]) #===========================================OSM======================================================================== self.widgets["osm_frameLayout"] = cmds.frameLayout(label = "Open Street Map", collapsable = True, collapse = True, parent = self.widgets["mainLayout"]) self.widgets["osm_formLayout"] = cmds.formLayout(h = 160, parent = self.widgets["osm_frameLayout"]) self.widgets["osmTopTextField"] = cmds.textField(w = 70, h= 30, text = "55.7858") self.widgets["osmBotTextField"] = cmds.textField(w = 70, h= 30, text = "55.7771") self.widgets["osmLeftTextField"] = cmds.textField(w = 70, h= 30, text = "37.7178") self.widgets["osmRightTextField"] = cmds.textField(w = 70, h= 30, text = "37.7356") self.widgets["osmImportButton"] = cmds.button(w = 80, h= 40, label = "Import", c = self.downloadOSM) cmds.formLayout(self.widgets["osm_formLayout"], edit = True, af = [(self.widgets["osmTopTextField"], 'top', 5),(self.widgets["osmTopTextField"], 'left', 110)]) cmds.formLayout(self.widgets["osm_formLayout"], edit = True, af = [(self.widgets["osmBotTextField"], 'top', 60),(self.widgets["osmBotTextField"], 'left', 110)]) cmds.formLayout(self.widgets["osm_formLayout"], edit = True, af = [(self.widgets["osmLeftTextField"], 'top', 33),(self.widgets["osmLeftTextField"], 'left', 20)]) cmds.formLayout(self.widgets["osm_formLayout"], edit = True, af = [(self.widgets["osmRightTextField"], 'top', 33),(self.widgets["osmRightTextField"], 'left', 200)]) cmds.formLayout(self.widgets["osm_formLayout"], edit = True, af = [(self.widgets["osmImportButton"], 'top', 100),(self.widgets["osmImportButton"], 'left', 105)]) #============================================================================================================== cmds.dockControl("cityGenerator_dockControl", label = "City Generator", area = 'right', allowedArea = 'right', content = self.widgets["window"])
def draw_warning(pWindowTitle, pbContinue, setTempCam): """Draw the warning window.""" destroyWindow() cmds.window( windowID, title=pWindowTitle, sizeable=True, resizeToFitChildren=True ) rowcol = cmds.rowColumnLayout( numberOfColumns=1, columnWidth=[(1, 250)], columnOffset=[(1, 'both', 5)] ) cmds.text(label='You are trying to playblast from a default camera!') cmds.separator(h=10, style='none') cmds.rowLayout( parent=rowcol, numberOfColumns=3, columnAttach=[ (1, 'left', 1), (2, 'left', 1), (3, 'both', 1) ], columnWidth=[ (1, 35), # Total == 250 - margins (2, 85), (3, 112) ] ) cmds.button(label='Help', command=helpCall) makeDefault = cmds.checkBox(label='Make Default') makeDefaultMenu = cmds.optionMenu(label='', changeCommand=setTempCam) cmds.menuItem(label='') for camera in cmds.listRelatives(cmds.ls(type="camera"), parent=True): if camera in stockCamNames: if camera == "persp": cmds.menuItem(label=camera) continue else: continue else: cmds.menuItem(label=camera) cmds.rowLayout( parent=rowcol, numberOfColumns=3, columnAttach=[ (1, 'both', 2), (2, 'both', 2), (3, 'both', 2) ], columnWidth=[ (1, 123), (2, 50), (3, 60) ] ) cmds.separator(h=10, style='none') cmds.button(label='OK!', command=partial(pbContinue, makeDefault, makeDefaultMenu)) cmds.button(label='Continue', command=blast) cmds.showWindow()
def installToolboxWindow(): installForm = cmds.formLayout() textLabel = cmds.text(label='Shelf') shelfNameText = cmds.textField('shelfNameText',width=200,tx='Custom') scriptsMenu = cmds.optionMenu('scriptsMenu') jsonPathText = cmds.textField('jsonPathText',ed=False,pht='path to json') jsonPathBtn = cmds.button('jsonPathBtn',width=50,label='...',c='browseForFile()') separator = ';' if cmds.about(nt=True): print 'its windows' else: separator = ':' scriptsPaths = os.getenv('MAYA_SCRIPT_PATH') allparts = scriptsPaths.split(separator) for i, part in enumerate(allparts): if (i==0): cmds.menuItem( label='Manually install scripts' ) if (i<7): isSystemPath = FilterOutSystemPaths(part) if (isSystemPath == 0): cmds.menuItem( label=part ) iconsMenu = cmds.optionMenu('iconsMenu') iconsPaths = os.getenv('XBMLANGPATH') iconsParts = iconsPaths.split(separator) for i, part in enumerate(iconsParts): if (i<6): isSystemPath = FilterOutSystemPaths(part) if (isSystemPath == 0): cmds.menuItem( label=part ) progressControl = cmds.progressBar('progressControl',maxValue=10, vis=False, width=250) btn1 = cmds.button(height=50,label='Install',c='CheckText()') btn2 = cmds.button(height=50,label='Close',c='cmds.deleteUI(\'Install Toolbox\')') listLayout = cmds.columnLayout('listLayout',adjustableColumn=True ) try: dirname = os.path.dirname(__file__) except: print 'running in test environment' dirname = 'C:/Users/Admin/Documents/Toolbox' JSONPath = dirname+'/toolboxShelf.json' try: data = json.load(open(JSONPath), object_pairs_hook=OrderedDict) cmds.textField('jsonPathText',e=True, text=JSONPath) for k in data: cb = cmds.checkBox(h=20, label=k,v=1) try: if data[k]["checkStatus"] == 0: cmds.checkBox(cb, e=True,v=0) if data[k]["checkStatus"] == 2: cmds.checkBox(cb, e=True,v=1,ed=0) except: pass except: pass cmds.formLayout(installForm, edit=True, attachForm=[ (textLabel, 'top', 15), (textLabel, 'left', 10), (shelfNameText, 'top', 10), (shelfNameText, 'right', 10), (scriptsMenu, 'right', 10), (iconsMenu, 'right', 10), (jsonPathBtn, 'right', 10), (progressControl, 'left', 10), (progressControl, 'right', 10), (btn1, 'bottom', 0), (btn1, 'left', 0), (btn2, 'bottom', 0), (btn2, 'right', 0) ], attachControl=[ (shelfNameText, 'left', 10,textLabel), (scriptsMenu, 'top', 10,textLabel), (scriptsMenu, 'left', 10,textLabel), (iconsMenu, 'top', 10,scriptsMenu), (iconsMenu, 'left', 10,textLabel), (jsonPathText, 'top', 10,iconsMenu), (jsonPathBtn, 'top', 10,iconsMenu), (jsonPathText, 'left', 10,textLabel), (jsonPathText, 'right', 10,jsonPathBtn), (progressControl, 'top', 20,jsonPathText), (progressControl, 'left', 10,textLabel), (listLayout, 'top', 20,jsonPathText), (listLayout, 'left', 10,textLabel), (btn2, 'left', 0,btn1) ], attachPosition=[ (btn1, 'right', 0, 50) ] ) shelfName = '' #get current tab names = cmds.layout('ShelfLayout',q=True,ca=True) shelfIndex = cmds.shelfTabLayout('ShelfLayout', query=True, selectTabIndex=True) #set text selectionString = (names[shelfIndex-1]) cmds.textField(shelfNameText,edit=True,tx=selectionString)
def generateCity(self, *args): map_file = cmds.textField(self.widgets["osmFileTextField"], q = True, fi = True) winds_file = cmds.textField(self.widgets["wrfFileTextField"], q = True, fi = True) heights_file = cmds.textField(self.widgets["demFileTextField"], q = True, fi = True) jams_file = cmds.textField(self.widgets["jamsFileTextField"], q = True, fi = True) raw_wrf = cmds.checkBox(self.widgets["wrfCheckBox"], q=True, v=True) raw_dem = cmds.checkBox(self.widgets["demCheckBox"], q=True, v=True) if raw_wrf: if platform.system() == 'Windows': s = subprocess.check_output(["where", "python"], shell=True) else: s = subprocess.check_output(["which", "python"], shell=False) python_path = s.splitlines()[-1] script_dir = os.path.dirname(os.path.realpath(__file__)) winds_file = subprocess.check_output([python_path, script_dir + "\NetCDF_converter.py", map_file, winds_file], shell=False).rstrip() if raw_dem: if platform.system() == 'Windows': s = subprocess.check_output(["where", "python"], shell=True) else: s = subprocess.check_output(["which", "python"], shell=False) python_path = s.splitlines()[-1] script_dir = os.path.dirname(os.path.realpath(__file__)) heights_file = subprocess.check_output([python_path, script_dir + "\DEM_converter.py", map_file, heights_file], shell=False).rstrip() if cmds.objExists('city'): cmds.delete('city') def calc_emmiter_level(waypoints): if (jams_file == ""): return 0 jams_data = open(jams_file, 'r') sum_jams_level = 0 jams_points = 0 shift_lat = -0.00766 shift_lon = 0.006868 for waypoint in waypoints: for line in jams_data: tmp = line.split(' ') lon = float(tmp[0]) - shift_lon lat = float(tmp[1]) - shift_lat if lat < minlat or lat > maxlat or lon < minlon or lon > maxlon: continue data = float(tmp[2]) jams_point = convert_coordinates(lon, lat) dist = math.sqrt(math.pow(waypoint[0]-jams_point[0], 2)+math.pow(waypoint[2]-jams_point[2], 2)) if dist < (25.0/size_multiplier): sum_jams_level += data jams_points += 1 if jams_points >= (len(waypoints) * 0.5): return 1.0*sum_jams_level/jams_points else: return 0 jams_data.close() def convert_coordinates(lon, lat): centered_lat = (lat-minlat) - (maxlat-minlat)/2 centered_lon = (lon-minlon) - (maxlon-minlon)/2 normalized_lat = centered_lat * norm_lat normalized_lon = centered_lon * norm_lon return [normalized_lon, 0, -normalized_lat] #meters size_multiplier = float(cmds.textField(self.widgets["sizeMultTextField"], q = True, tx = True)) emit_multiplier = float(cmds.textField(self.widgets["emitMultTextField"], q = True, tx = True)) hasl = float(cmds.textField(self.widgets["haslTextField"], q = True, tx = True)) xmlData = xml.dom.minidom.parse(map_file) points_ids = [] points = [] heights = [] bounds = xmlData.getElementsByTagName("bounds")[0] minlat = float(bounds.getAttribute('minlat')) maxlat = float(bounds.getAttribute('maxlat')) minlon = float(bounds.getAttribute('minlon')) maxlon = float(bounds.getAttribute('maxlon')) dist_lon = self.coordinates_dist(minlon, minlat, maxlon, minlat) dist_lat = self.coordinates_dist(minlon, minlat, minlon, maxlat) norm_lat = (dist_lat/size_multiplier)/(maxlat-minlat) norm_lon = (dist_lon/size_multiplier)/(maxlon-minlon) #============================Get heights=================================== heights_data = open(heights_file, 'r') rows = 0 cols = 0 start_lon = 0 start_lat = 0 delta_lon = 0 delta_lat = 0 heights_matrix = [] for line in heights_data: tmp = line.strip().split(' ') if rows == 0: rows = float(tmp[0]) cols = float(tmp[1]) elif start_lon == 0: start_lon = float(tmp[0]) start_lat = float(tmp[1]) elif delta_lon == 0: delta_lon = float(tmp[0]) delta_lat = float(tmp[1]) else: row = [] for cell in tmp: row.append(int(cell)-hasl) heights_matrix.append(row) #========================================================================== maxprogress = 0 ways = xmlData.getElementsByTagName('way') for way in ways: tags = way.getElementsByTagName('tag') for tag in tags: tag_type = str(tag.getAttribute('k')) if (tag_type == 'highway'): subtype = str(tag.getAttribute('v')) if not(subtype == 'pedestrian') and not(subtype == 'steps') and not(subtype == 'footway') and not(subtype == 'cycleway'): maxprogress += 1 if (tag_type == 'building'): maxprogress += 1 progress = 0 cmds.progressWindow(title='Generating city', min = 0, max = maxprogress, progress = progress, status = 'Processing nodes', isInterruptable = False) #============================Handle nodes================================== nodes = xmlData.getElementsByTagName('node') for node in nodes: lat = float(node.getAttribute('lat')) lon = float(node.getAttribute('lon')) if lat < minlat or lat > maxlat or lon < minlon or lon > maxlon: continue point = convert_coordinates(lon, lat) points_ids.append(int(node.getAttribute('id'))) points.append(point) heights.append(heights_matrix[int(math.floor((lon-start_lon)/delta_lon))][int(math.floor((lat-start_lat)/delta_lat))]) #========================================================================== #=============================Handle ways================================== roads = 0 buildings = 0 emitter = 0 cmds.particle(n='nParticle') cmds.particle('nParticle', e=True, at='mass', order=0, fv=1e-5) cmds.setAttr('nParticleShape.lifespanMode', 2) cmds.setAttr('nParticleShape.lifespan', 6) cmds.setAttr('nParticleShape.lifespanRandom', 2) cmds.select('nParticleShape', r=True) cmds.addAttr(longName='betterIllumination', at='bool', defaultValue=False ) cmds.addAttr(longName='surfaceShading', at='float', defaultValue=0, minValue=0, maxValue=1) cmds.addAttr(longName='threshold', at='float', defaultValue=0, minValue=0, maxValue=10) cmds.addAttr(longName='radius', at='float', defaultValue=1, minValue=0, maxValue=20) cmds.addAttr(longName='flatShaded', at='bool', defaultValue=False) cmds.setAttr('nParticleShape.particleRenderType', 8) cmds.setAttr('nParticleShape.radius', 0.06) cmds.setAttr('particleCloud1.transparency', 0.53, 0.53, 0.53, type='double3') cmds.setAttr('particleCloud1.color', 1.0, 0.0, 0.483, type='double3') cmds.setAttr('particleCloud1.incandescence', 1.0, 0.0, 0.850, type='double3') cmds.setAttr('particleCloud1.glowIntensity', 0.111) ways = xmlData.getElementsByTagName('way') for way in ways: waypoints = [] heights_sum = 0 nodes = way.getElementsByTagName('nd') tags = way.getElementsByTagName('tag') for node in nodes: ref = int(node.getAttribute('ref')) try: index = points_ids.index(ref) except ValueError: index = -1 if index != -1: waypoints.append(points[index]) heights_sum += heights[index] for tag in tags: tag_type = str(tag.getAttribute('k')) if tag_type == 'highway': subtype = str(tag.getAttribute('v')) if not(subtype == 'pedestrian') and not(subtype == 'steps') and not(subtype == 'footway') and not(subtype == 'cycleway'): roads += 1 progress += 1 cmds.progressWindow(edit=True, progress = progress, status='Generating road: ' + str(roads)) lanes = 2 for tag in tags: tag_type = str(tag.getAttribute('k')) if tag_type == 'lanes': lanes = float(str(tag.getAttribute('v'))) if len(waypoints) >= 2: cmds.curve(n='pathcurve_' + str(roads), p=waypoints, d=1) sx = waypoints[0][0] sz = waypoints[0][2] dx = waypoints[0][2]-waypoints[1][2] dz = waypoints[1][0]-waypoints[0][0] ln = math.sqrt(math.pow(2*dx, 2) + math.pow(2*dz, 2)) dx /= (ln*size_multiplier)/(3*lanes) dz /= (ln*size_multiplier)/(3*lanes) ln = 0 for i in range(0, len(waypoints)-2): ln += math.trunc(math.sqrt(math.pow(waypoints[i+1][0]-waypoints[i][0], 2) + math.pow(waypoints[i+1][2]-waypoints[i][2], 2))) + 1 cmds.curve(n='extrudecurve_' + str(roads), p=[(sx-dx, 0, sz-dz), (sx+dx, 0, sz+dz)], d=1) cmds.rebuildCurve('pathcurve_' + str(roads), rt=0, s=200) cmds.nurbsToPolygonsPref(f=2, pt=1, ut=1, un=2, vt=1, vn=ln * 5 + 30) cmds.extrude('extrudecurve_' + str(roads), 'pathcurve_' + str(roads), n='road_' + str(roads), et=2, po=1) cmds.delete('extrudecurve_' + str(roads),) emitter_level = calc_emmiter_level(waypoints) if emitter_level > 0: emitter += 1 cmds.select('pathcurve_' + str(roads), r=True) cmds.move(0, 0.03, 0) cmds.emitter(n='emitter_' + str(emitter), type='omni', r=emit_multiplier*emitter_level, spd=0.1, srn=0, sp=0) cmds.connectDynamic('nParticle', em='emitter_' + str(emitter)) cmds.select('road_' + str(roads), r=True) cmds.move(0, 0.004, 0) elif tag_type == 'building': temp = str(tag.getAttribute('v')) if temp == 'yes': buildings += 1 progress += 1 cmds.progressWindow(edit=True, progress = progress, status='Generating building: ' + str(buildings)) if len(waypoints) >= 3: cmds.polyCreateFacet(n='building_' + str(buildings), p=waypoints) cmds.select('building_' + str(buildings), r=True) normal = cmds.polyInfo(fn=True)[0].partition('0: ')[2].split(' ')[1] if float(normal) < 0: cmds.polyMirrorFace(direction=2, p=(0, 0, 0), mergeMode=0, worldSpace=1) cmds.polyDelFacet('building_' + str(buildings) + '.f[0]') avg_height = heights_sum / len(waypoints) cmds.polyExtrudeFacet('building_' + str(buildings) + '.f[0]', ltz=(1.0 * avg_height/size_multiplier)) cmds.select('building_' + str(buildings), r=True) cmds.collision('building_' + str(buildings), 'nParticle') #========================================================================== #============================Handle winds================================== winds_data = open(winds_file, 'r') winds = 0 cmds.progressWindow(edit=True, progress = progress, status='Setting winds') for line in winds_data: winds += 1 tmp = line.split(' ') lon = float(tmp[0]) lat = float(tmp[1]) x = float(tmp[2]) y = float(tmp[3]) z = float(tmp[4]) magn = math.sqrt(math.pow(x, 2) + math.pow(y, 2) + math.pow(z, 2)) max_dist = self.coordinates_dist(0, 0, 0.006364, 0.006364)/size_multiplier volume_size = self.coordinates_dist(0, 0, 0.0045, 0.0045)/size_multiplier position = convert_coordinates(lon, lat) cmds.air(n='wind_' + str(winds), pos=position, wns=True, dx=x, dy=y, dz=z, m=magn, s=1, mxd=max_dist) cmds.setAttr('wind_' + str(winds) + '.volumeShape', 1) cmds.setAttr('wind_' + str(winds) + '.volumeOffsetY', 1) cmds.scale(volume_size, volume_size/2, volume_size, 'wind_' + str(winds)) cmds.connectDynamic('nParticle', f='wind_' + str(winds)) cmds.select(cl=True) #========================================================================== cmds.gravity(n='gravity', m=9.8*1e-5) cmds.connectDynamic('nParticle', f='gravity') cmds.polyPlane(n='ground', sx=(maxlon-minlon), sy=(maxlat-minlat), w=(maxlon-minlon)*norm_lon, h=(maxlat-minlat)*norm_lat) cmds.collision('ground', 'nParticle') cmds.select('building_*', r=True) cmds.select('road_*', tgl=True) cmds.select('ground', tgl=True) cmds.select('nParticle', tgl=True) cmds.editRenderLayerGlobals(currentRenderLayer='AOLayer') cmds.editRenderLayerMembers('AOLayer') cmds.select('road_*', r=True) cmds.group(n='roads') cmds.select('building_*', r=True) cmds.group(n='buildings') cmds.select('pathcurve_*', r=True) cmds.group(n='emitters') cmds.select('roads', r=True) cmds.select('buildings', tgl=True) cmds.select('emitters', tgl=True) cmds.select('nParticle', tgl=True) cmds.select('gravity', tgl=True) cmds.select('ground', tgl=True) cmds.select('wind_1', tgl=True) cmds.group(n='city') xmlData.unlink() winds_data.close() heights_data.close() if raw_wrf: os.remove(winds_file) if raw_dem: os.remove(heights_file) cmds.progressWindow(endProgress = True)
def createUI(self): cmds.setParent(self.window) cmds.columnLayout('columnLayout01', width=290, height=470, adjustableColumn=False) cmds.columnLayout(parent='columnLayout01', adjustableColumn=True) cmds.frameLayout(label='Channels', width=288, borderStyle='in') ChannelsRadioCollection = cmds.radioCollection() cmds.rowLayout(nc=4) cmds.text(label='', width=2, align='left') cmds.radioButton('AllKeyable', label=u'AllKeyable', sl=True, onc=self.toRadioButtonAllKeyable) cmds.radioButton('FromAttributes', label=u'FromAttributes', onc=self.toRadioButtonFromAttributes) cmds.radioButton('FromChannelBox', label=u'FromChannelBox', onc=self.toRadioButtonFromChannelBox) cmds.setParent('..') cmds.setParent('..') cmds.frameLayout(label='Select Attributes', width=288, borderStyle='in', collapse=True, collapsable=True, parent='columnLayout01') cmds.rowLayout(nc=6) cmds.text(label=' Translate:', width=80, align='left') cmds.checkBox('trans_x', label=u'X', value=True, enable=False, ofc=self.toCheckBoxTAll) cmds.checkBox('trans_y', label=u'Y', value=True, enable=False, ofc=self.toCheckBoxTAll) cmds.checkBox('trans_z', label=u'Z', value=True, enable=False, ofc=self.toCheckBoxTAll) cmds.checkBox('trans_All', label=u'All', value=True, enable=False, onc=self.toCheckBoxTTrue, ofc=self.toCheckBoxTFalse) cmds.setParent('..') cmds.columnLayout(adjustableColumn=True) cmds.separator(st='in') cmds.setParent('..') cmds.rowLayout(nc=5) cmds.text(label=' Rotate:', width=80, align='left') cmds.checkBox('rot_x', label=u'X', value=True, enable=False, ofc=self.toCheckBoxRAll) cmds.checkBox('rot_y', label=u'Y', value=True, enable=False, ofc=self.toCheckBoxRAll) cmds.checkBox('rot_z', label=u'Z', value=True, enable=False, ofc=self.toCheckBoxRAll) cmds.checkBox('rot_All', label=u'All', value=True, enable=False, onc=self.toCheckBoxRTrue, ofc=self.toCheckBoxRFalse) cmds.setParent('..') cmds.columnLayout(adjustableColumn=True) cmds.separator(st='in') cmds.setParent('..') cmds.rowLayout(nc=5) cmds.text(label=' Scale:', width=80, align='left') cmds.checkBox('scl_x', label=u'X', value=True, enable=False, ofc=self.toCheckBoxZAll) cmds.checkBox('scl_y', label=u'Y', value=True, enable=False, ofc=self.toCheckBoxZAll) cmds.checkBox('scl_z', label=u'Z', value=True, enable=False, ofc=self.toCheckBoxZAll) cmds.checkBox('scl_All', label=u'All', value=True, enable=False, onc=self.toCheckBoxZTrue, ofc=self.toCheckBoxZFalse) cmds.setParent('..') cmds.columnLayout(adjustableColumn=True) cmds.separator(st='in') cmds.setParent('..') cmds.columnLayout(parent='columnLayout01', width=288, adjustableColumn=True) cmds.frameLayout(label='Time Range', borderStyle='in') TimeRangeRadioCollection = cmds.radioCollection() cmds.rowLayout(nc=5) cmds.text(label='', width=2, align='left') cmds.radioButton('TimeSlider', label='TimeSlider', sl=True, onc=self.toRadioButtonTimeSlider) cmds.radioButton('StartEnd', label='Start/End:', width=80, onc=self.toRadioButtonStartEnd) cmds.floatField('StartTime', value=0, precision=3, step=1, enable=False) cmds.floatField('EndTime', value=10, precision=3, step=1, enable=False) cmds.setParent('..') cmds.columnLayout(parent='columnLayout01', width=288, adjustableColumn=True) cmds.frameLayout(label='Bake Simulation', borderStyle='in') cmds.rowLayout(nc=4) cmds.text(label='', width=5) cmds.checkBox('POK', label=u'Keep Unbaked', value=True) cmds.checkBox('Euler', label=u'Euler Filter', value=False) cmds.checkBox('Sim', label=u'Simulation', value=False) cmds.setParent('..') cmds.rowLayout(nc=4) cmds.text(label=' SampleBy:', width=70, align='left') cmds.floatField('bakeSample', value=1, precision=3, step=1, width=60) cmds.text(label='', width=45, align='left') cmds.button('Key Bake', width=100, label='Key Bake', c=self.toBake) cmds.setParent('..') cmds.columnLayout(parent='columnLayout01', width=288, adjustableColumn=True, cal='left') cmds.frameLayout(label='Delete static Key', borderStyle='in') cmds.rowLayout(nc=2) cmds.text(label=' Sample:', width=70, align='left') cmds.floatSliderGrp('DelstaticSample', field=True, min=0, max=0.1, precision=3, step=0.001, value=0.01, width=210, cw=(1, 60), cal=(1, 'left')) cmds.setParent('..') cmds.rowLayout(nc=2) cmds.text(label='', width=180, align='left') cmds.button('DelStaticKey', width=100, label='Del Static Key', c=self.toDelStatic) cmds.setParent('..') cmds.columnLayout(parent='columnLayout01', width=288, adjustableColumn=True) cmds.frameLayout(label='Key Reduction (0= flat and linear only)', borderStyle='in') cmds.rowLayout(nc=2) cmds.text(label='', width=5) cmds.checkBox('LockSelectedKey', label=u'Lock Selected Key', value=False) cmds.setParent('..') cmds.rowLayout(nc=2) cmds.text(label=' Sample:', width=70, align='left') cmds.floatSliderGrp('ReductKeySample', field=True, min=0.00, max=1.00, precision=3, step=0.01, value=0.5, width=210, cw=(1, 60), cal=(1, 'left')) cmds.setParent('..') cmds.rowLayout(nc=2) cmds.text(label='', width=180, align='left') cmds.button('ReductKey', width=100, label='Key Reduction', c=self.toReductKey) cmds.setParent('..')
def rigModule(self, *args): Base.StartClass.rigModule(self) # verify if the guide exists: if cmds.objExists(self.moduleGrp): try: hideJoints = cmds.checkBox('hideJointsCB', query=True, value=True) except: hideJoints = 1 # declare lists to store names and attributes: self.worldRefList, self.headCtrlList = [], [] self.aCtrls, self.aLCtrls, self.aRCtrls = [], [], [] # start as no having mirror: sideList = [""] # analisys the mirror module: self.mirrorAxis = cmds.getAttr(self.moduleGrp+".mirrorAxis") if self.mirrorAxis != 'off': # get rigs names: self.mirrorNames = cmds.getAttr(self.moduleGrp+".mirrorName") # get first and last letters to use as side initials (prefix): sideList = [ self.mirrorNames[0]+'_', self.mirrorNames[len(self.mirrorNames)-1]+'_' ] for s, side in enumerate(sideList): duplicated = cmds.duplicate(self.moduleGrp, name=side+self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, side+self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(name="Guide_Base_Grp", empty=True) cmds.parent(side+self.userGuideName+'_Guide_Base', self.mirrorGrp, absolute=True) # re-rename grp: cmds.rename(self.mirrorGrp, side+self.userGuideName+'_'+self.mirrorGrp) # do a group mirror with negative scaling: if s == 1: for axis in self.mirrorAxis: cmds.setAttr(side+self.userGuideName+'_'+self.mirrorGrp+'.scale'+axis, -1) else: # if not mirror: duplicated = cmds.duplicate(self.moduleGrp, name=self.userGuideName+'_Guide_Base')[0] allGuideList = cmds.listRelatives(duplicated, allDescendents=True) for item in allGuideList: cmds.rename(item, self.userGuideName+"_"+item) self.mirrorGrp = cmds.group(self.userGuideName+'_Guide_Base', name="Guide_Base_Grp", relative=True) # re-rename grp: cmds.rename(self.mirrorGrp, self.userGuideName+'_'+self.mirrorGrp) # store the number of this guide by module type dpAR_count = utils.findModuleLastNumber(CLASS_NAME, "dpAR_type") + 1 # run for all sides for s, side in enumerate(sideList): # redeclaring variables: self.base = side+self.userGuideName+"_Guide_Base" self.cvNeckLoc = side+self.userGuideName+"_Guide_neck" self.cvHeadLoc = side+self.userGuideName+"_Guide_head" self.cvJawLoc = side+self.userGuideName+"_Guide_jaw" self.cvChinLoc = side+self.userGuideName+"_Guide_chin" self.cvLLipLoc = side+self.userGuideName+"_Guide_lLip" self.cvRLipLoc = side+self.userGuideName+"_Guide_rLip" self.cvEndJoint = side+self.userGuideName+"_Guide_JointEnd" # creating joints: self.neckJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_neck']+"_Jnt") self.headJxt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_head']+"_Jxt") cmds.select(clear=True) self.headJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_head']+"_Jnt", scaleCompensate=False) self.jawJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_jaw']+"_Jnt", scaleCompensate=False) self.chinJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['c_chin']+"_Jnt", scaleCompensate=False) self.endJnt = cmds.joint(name=side+self.userGuideName+"_JEnd", scaleCompensate=False) cmds.select(clear=True) self.lLipJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['p002_left']+"_"+self.langDic[self.langName]['c_lip']+"_Jnt", scaleCompensate=False) cmds.select(clear=True) self.rLipJnt = cmds.joint(name=side+self.userGuideName+"_"+self.langDic[self.langName]['p003_right']+"_"+self.langDic[self.langName]['c_lip']+"_Jnt", scaleCompensate=False) dpARJointList = [self.neckJnt, self.headJnt, self.jawJnt, self.chinJnt, self.lLipJnt, self.rLipJnt] for dpARJoint in dpARJointList: cmds.addAttr(dpARJoint, longName='dpAR_joint', attributeType='float', keyable=False) # creating controls: self.neckCtrl = ctrls.cvNeck(ctrlName=side+self.userGuideName+"_"+self.langDic[self.langName]['c_neck']+"_Ctrl", r=self.ctrlRadius/2.0) self.headCtrl = ctrls.cvHead(ctrlName=side+self.userGuideName+"_"+self.langDic[self.langName]['c_head']+"_Ctrl", r=self.ctrlRadius/2.0) self.jawCtrl = ctrls.cvJaw( ctrlName=side+self.userGuideName+"_"+self.langDic[self.langName]['c_jaw']+"_Ctrl", r=self.ctrlRadius/2.0) self.chinCtrl = ctrls.cvChin(ctrlName=side+self.userGuideName+"_"+self.langDic[self.langName]['c_chin']+"_Ctrl", r=self.ctrlRadius/2.0) self.lLipCtrl = cmds.circle(name=self.langDic[self.langName]['p002_left']+"_"+side+self.userGuideName+"_"+self.langDic[self.langName]['c_lip']+"_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=3, s=8, radius=(self.ctrlRadius * 0.25))[0] self.rLipCtrl = cmds.circle(name=self.langDic[self.langName]['p003_right']+"_"+side+self.userGuideName+"_"+self.langDic[self.langName]['c_lip']+"_Ctrl", ch=False, o=True, nr=(0, 0, 1), d=3, s=8, radius=(self.ctrlRadius * 0.25))[0] self.headCtrlList.append(self.headCtrl) self.aCtrls.append([self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl]) self.aLCtrls.append([self.lLipCtrl]) self.aRCtrls.append([self.rLipCtrl]) #Setup Axis Order if self.rigType == Base.RigType.quadruped: cmds.setAttr(self.neckCtrl + ".rotateOrder", 1) cmds.setAttr(self.headCtrl + ".rotateOrder", 1) cmds.setAttr(self.jawCtrl + ".rotateOrder", 1) else: cmds.setAttr(self.neckCtrl + ".rotateOrder", 3) cmds.setAttr(self.headCtrl + ".rotateOrder", 3) cmds.setAttr(self.jawCtrl + ".rotateOrder", 3) # creating the originedFrom attributes (in order to permit integrated parents in the future): utils.originedFrom(objName=self.neckCtrl, attrString=self.base+";"+self.cvNeckLoc) utils.originedFrom(objName=self.headCtrl, attrString=self.cvHeadLoc) utils.originedFrom(objName=self.jawCtrl, attrString=self.cvJawLoc) utils.originedFrom(objName=self.chinCtrl, attrString=self.cvChinLoc+";"+self.cvEndJoint) # edit the mirror shape to a good direction of controls: ctrlList = [ self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl ] if s == 1: for ctrl in ctrlList: if self.mirrorAxis == 'X': cmds.setAttr(ctrl+'.rotateY', 180) elif self.mirrorAxis == 'Y': cmds.setAttr(ctrl+'.rotateY', 180) elif self.mirrorAxis == 'Z': cmds.setAttr(ctrl+'.rotateX', 180) cmds.setAttr(ctrl+'.rotateZ', 180) elif self.mirrorAxis == 'XYZ': cmds.setAttr(ctrl+'.rotateX', 180) cmds.setAttr(ctrl+'.rotateZ', 180) cmds.makeIdentity(ctrlList, apply=True, translate=False, rotate=True, scale=False) # temporary parentConstraints: tempDelNeck = cmds.parentConstraint(self.cvNeckLoc, self.neckCtrl, maintainOffset=False) tempDelHead = cmds.parentConstraint(self.cvHeadLoc, self.headCtrl, maintainOffset=False) tempDelJaw = cmds.parentConstraint(self.cvJawLoc, self.jawCtrl, maintainOffset=False) tempDelChin = cmds.parentConstraint(self.cvChinLoc, self.chinCtrl, maintainOffset=False) tempDelLLip = cmds.parentConstraint(self.cvLLipLoc, self.lLipCtrl, maintainOffset=False) tempDelRLip = cmds.parentConstraint(self.cvRLipLoc, self.rLipCtrl, maintainOffset=False) cmds.delete(tempDelNeck, tempDelHead, tempDelJaw, tempDelChin, tempDelLLip, tempDelRLip) # zeroOut controls: self.zeroLipCtrlList = utils.zeroOut([self.lLipCtrl, self.rLipCtrl]) self.lLipGrp = cmds.group(self.lLipCtrl, name=self.lLipCtrl+"_Grp") self.rLipGrp = cmds.group(self.rLipCtrl, name=self.rLipCtrl+"_Grp") self.zeroCtrlList = utils.zeroOut([self.neckCtrl, self.headCtrl, self.jawCtrl, self.chinCtrl, self.zeroLipCtrlList[0], self.zeroLipCtrlList[1]]) # make joints be ride by controls: cmds.makeIdentity(self.neckJnt, self.headJxt, self.headJnt, self.jawJnt, self.chinJnt, self.endJnt, rotate=True, apply=True) cmds.parentConstraint(self.neckCtrl, self.neckJnt, maintainOffset=False, name=self.neckJnt+"_ParentConstraint") cmds.scaleConstraint(self.neckCtrl, self.neckJnt, maintainOffset=False, name=self.neckJnt+"_ScaleConstraint") cmds.delete(cmds.parentConstraint(self.headCtrl, self.headJxt, maintainOffset=False)) cmds.parentConstraint(self.headCtrl, self.headJnt, maintainOffset=False, name=self.headJnt+"_ParentConstraint") cmds.parentConstraint(self.jawCtrl, self.jawJnt, maintainOffset=False, name=self.jawJnt+"_ParentConstraint") cmds.parentConstraint(self.chinCtrl, self.chinJnt, maintainOffset=False, name=self.chinJnt+"_ParentConstraint") cmds.parentConstraint(self.lLipCtrl, self.lLipJnt, maintainOffset=False, name=self.lLipJnt+"_ParentConstraint") cmds.parentConstraint(self.rLipCtrl, self.rLipJnt, maintainOffset=False, name=self.rLipJnt+"_ParentConstraint") cmds.scaleConstraint(self.headCtrl, self.headJnt, maintainOffset=False, name=self.headJnt+"_ScaleConstraint") cmds.scaleConstraint(self.jawCtrl, self.jawJnt, maintainOffset=False, name=self.jawJnt+"_ScaleConstraint") cmds.scaleConstraint(self.chinCtrl, self.chinJnt, maintainOffset=False, name=self.chinJnt+"_ScaleConstraint") cmds.scaleConstraint(self.lLipCtrl, self.lLipJnt, maintainOffset=False, name=self.lLipJnt+"_ScaleConstraint") cmds.scaleConstraint(self.rLipCtrl, self.rLipJnt, maintainOffset=False, name=self.rLipJnt+"_ScaleConstraint") cmds.delete(cmds.parentConstraint(self.cvEndJoint, self.endJnt, maintainOffset=False)) cmds.setAttr(self.jawJnt+".segmentScaleCompensate", 0) cmds.setAttr(self.chinJnt+".segmentScaleCompensate", 0) # create interations between neck and head: self.grpNeck = cmds.group(self.zeroCtrlList[0], name=self.neckCtrl+"_Grp") self.grpHeadA = cmds.group(empty=True, name=self.headCtrl+"_A_Grp") self.grpHead = cmds.group(self.grpHeadA, name=self.headCtrl+"_Grp") # arrange pivots: self.neckPivot = cmds.xform(self.neckCtrl, query=True, worldSpace=True, translation=True) self.headPivot = cmds.xform(self.headCtrl, query=True, worldSpace=True, translation=True) cmds.xform(self.grpNeck, pivots=(self.neckPivot[0], self.neckPivot[1], self.neckPivot[2])) cmds.xform(self.grpHead, self.grpHeadA, pivots=(self.headPivot[0], self.headPivot[1], self.headPivot[2])) self.worldRef = cmds.group(empty=True, name=side+self.userGuideName+"_WorldRef") self.worldRefList.append(self.worldRef) cmds.delete(cmds.parentConstraint(self.neckCtrl, self.worldRef, maintainOffset=False)) cmds.parentConstraint(self.neckCtrl, self.grpHeadA, maintainOffset=True, skipRotate=["x", "y", "z"], name=self.grpHeadA+"_ParentConstraint") orientConst = cmds.orientConstraint(self.neckCtrl, self.worldRef, self.grpHeadA, maintainOffset=False, name=self.grpHeadA+"_OrientConstraint")[0] cmds.scaleConstraint(self.neckCtrl, self.grpHeadA, maintainOffset=True, name=self.grpHeadA+"_ScaleConstraint") cmds.parent(self.zeroCtrlList[1], self.grpHeadA, absolute=True) # connect reverseNode: cmds.addAttr(self.headCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, keyable=True) cmds.connectAttr(self.headCtrl+'.'+self.langDic[self.langName]['c_Follow'], orientConst+"."+self.neckCtrl+"W0", force=True) self.headRevNode = cmds.createNode('reverse', name=side+self.userGuideName+"_Rev") cmds.connectAttr(self.headCtrl+'.'+self.langDic[self.langName]['c_Follow'], self.headRevNode+".inputX", force=True) cmds.connectAttr(self.headRevNode+'.outputX', orientConst+"."+self.worldRef+"W1", force=True) # mount controls hierarchy: cmds.parent(self.zeroCtrlList[3], self.jawCtrl, absolute=True) # jaw follow head or root ctrl (using worldRef) jawParentConst = cmds.parentConstraint(self.headCtrl, self.worldRef, self.zeroCtrlList[2], maintainOffset=True, name=self.zeroCtrlList[2]+"_ParentConstraint")[0] cmds.setAttr(jawParentConst+".interpType", 2) #Shortest, no flip cause problem with scrubing cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType="float", minValue=0, maxValue=1, defaultValue=1, keyable=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_Follow'], jawParentConst+"."+self.headCtrl+"W0", force=True) jawFollowRev = cmds.createNode("reverse", name=self.jawCtrl+"_Rev") cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_Follow'], jawFollowRev+".inputX", force=True) cmds.connectAttr(jawFollowRev+".outputX", jawParentConst+"."+self.worldRef+"W1", force=True) cmds.scaleConstraint(self.headCtrl, self.zeroCtrlList[2], maintainOffset=True, name=self.zeroCtrlList[2]+"_ScaleConstraint")[0] # setup jaw auto translation self.jawSdkGrp = cmds.group(self.jawCtrl, name=self.jawCtrl+"_SDK_Grp") cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_moveIntensity']+"Y", attributeType='float', keyable=True) cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_moveIntensity']+"Z", attributeType='float', keyable=True) cmds.addAttr(self.jawCtrl, longName=self.langDic[self.langName]['c_moveStartRotation'], attributeType='float', keyable=True) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Y", keyable=False, channelBox=True) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Z", keyable=False, channelBox=True) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveStartRotation'], keyable=False, channelBox=True) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Y", 1) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Z", 2) cmds.setAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveStartRotation'], 10) self.jawIntensityFixUnitMD = cmds.createNode('multiplyDivide', name="JawMoveIntensityFixUnit_MD") self.jawIntensityMD = cmds.createNode('multiplyDivide', name="JawMoveIntensity_MD") self.jawIntensityZMD = cmds.createNode('multiplyDivide', name="JawMoveIntensityZ_MD") self.jawStartIntensityMD = cmds.createNode('multiplyDivide', name="JawMoveIntensityStart_MD") self.jawIntensityPMA = cmds.createNode('plusMinusAverage', name="JawMoveIntensity_PMA") self.jawIntensityCnd = cmds.createNode('condition', name="JawMoveIntensity_Cnd") cmds.connectAttr(self.jawCtrl+".rotateX", self.jawIntensityMD+".input1Y", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Y", self.jawIntensityFixUnitMD+".input1Y", force=True) cmds.connectAttr(self.jawIntensityFixUnitMD+".outputY", self.jawIntensityMD+".input2Y", force=True) cmds.setAttr(self.jawIntensityFixUnitMD+".input2Y", -0.01) cmds.connectAttr(self.jawIntensityFixUnitMD+".outputY", self.jawStartIntensityMD+".input1X", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveStartRotation'], self.jawStartIntensityMD+".input2X", force=True) cmds.setAttr(self.jawIntensityPMA+".operation", 2) cmds.connectAttr(self.jawIntensityMD+".outputY", self.jawIntensityPMA+".input1D[0]", force=True) cmds.connectAttr(self.jawStartIntensityMD+".outputX", self.jawIntensityPMA+".input1D[1]", force=True) cmds.connectAttr(self.jawIntensityPMA+".output1D", self.jawIntensityCnd+".colorIfTrueG", force=True) cmds.connectAttr(self.jawCtrl+".rotateX", self.jawIntensityCnd+".firstTerm", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveStartRotation'], self.jawIntensityCnd+".secondTerm", force=True) cmds.setAttr(self.jawIntensityCnd+".operation", 2) cmds.setAttr(self.jawIntensityCnd+".colorIfFalseG", 0) cmds.connectAttr(self.jawIntensityCnd+".outColorG", self.jawSdkGrp+".translateY", force=True) cmds.connectAttr(self.jawIntensityCnd+".outColorG", self.jawIntensityZMD+".input1Z", force=True) cmds.connectAttr(self.jawCtrl+"."+self.langDic[self.langName]['c_moveIntensity']+"Z", self.jawIntensityFixUnitMD+".input1Z", force=True) cmds.setAttr(self.jawIntensityFixUnitMD+".input2Z", -0.1) cmds.connectAttr(self.jawIntensityFixUnitMD+".outputZ", self.jawIntensityZMD+".input2Z", force=True) cmds.connectAttr(self.jawIntensityZMD+".outputZ", self.jawSdkGrp+".translateZ", force=True) # create lip setup: # left side lip: lLipParentConst = cmds.parentConstraint(self.jawCtrl, self.headCtrl, self.lLipGrp, maintainOffset=True, name=self.lLipGrp+"_ParentConstraint")[0] cmds.setAttr(lLipParentConst+".interpType", 2) cmds.addAttr(self.lLipCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, defaultValue=0.5, keyable=True) cmds.connectAttr(self.lLipCtrl+'.'+self.langDic[self.langName]['c_Follow'], lLipParentConst+"."+self.jawCtrl+"W0", force=True) self.lLipRevNode = cmds.createNode('reverse', name=side+self.userGuideName+"_"+self.langDic[self.langName]['p002_left']+"_"+self.langDic[self.langName]['c_lip']+"_Rev") cmds.connectAttr(self.lLipCtrl+'.'+self.langDic[self.langName]['c_Follow'], self.lLipRevNode+".inputX", force=True) cmds.connectAttr(self.lLipRevNode+'.outputX', lLipParentConst+"."+self.headCtrl+"W1", force=True) cmds.scaleConstraint(self.headCtrl, self.lLipGrp, maintainOffset=True, name=self.lLipGrp+"_ScaleConstraint")[0] # right side lip: rLipParentConst = cmds.parentConstraint(self.jawCtrl, self.headCtrl, self.rLipGrp, maintainOffset=True, name=self.rLipGrp+"_ParentConstraint")[0] cmds.setAttr(rLipParentConst+".interpType", 2) cmds.addAttr(self.rLipCtrl, longName=self.langDic[self.langName]['c_Follow'], attributeType='float', minValue=0, maxValue=1, defaultValue=0.5, keyable=True) cmds.connectAttr(self.rLipCtrl+'.'+self.langDic[self.langName]['c_Follow'], rLipParentConst+"."+self.jawCtrl+"W0", force=True) self.rLipRevNode = cmds.createNode('reverse', name=side+self.userGuideName+"_"+self.langDic[self.langName]['p003_right']+"_"+self.langDic[self.langName]['c_lip']+"_Rev") cmds.connectAttr(self.rLipCtrl+'.'+self.langDic[self.langName]['c_Follow'], self.rLipRevNode+".inputX", force=True) cmds.connectAttr(self.rLipRevNode+'.outputX', rLipParentConst+"."+self.headCtrl+"W1", force=True) cmds.scaleConstraint(self.headCtrl, self.rLipGrp, maintainOffset=True, name=self.rLipGrp+"_ScaleConstraint")[0] # create a locator in order to avoid delete static group loc = cmds.spaceLocator(name=side+self.userGuideName+"_DO_NOT_DELETE")[0] cmds.parent(loc, self.worldRef, absolute=True) cmds.setAttr(loc+".visibility", 0) ctrls.setLockHide([loc], ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']) # hiding visibility attributes: ctrls.setLockHide([self.headCtrl, self.neckCtrl, self.jawCtrl, self.chinCtrl], ['v'], l=False) # create a masterModuleGrp to be checked if this rig exists: self.toCtrlHookGrp = cmds.group(self.grpNeck, self.grpHead, self.zeroCtrlList[2], self.zeroCtrlList[4], self.zeroCtrlList[5], name=side+self.userGuideName+"_Control_Grp") self.toScalableHookGrp = cmds.group(self.neckJnt, self.headJnt, self.lLipJnt, self.rLipJnt, name=side+self.userGuideName+"_Joint_Grp") self.toStaticHookGrp = cmds.group(self.toCtrlHookGrp, self.toScalableHookGrp, self.grpHead, self.worldRef, name=side+self.userGuideName+"_Grp") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_name", dataType="string") cmds.addAttr(self.toStaticHookGrp, longName="dpAR_type", dataType="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_name", self.userGuideName, type="string") cmds.setAttr(self.toStaticHookGrp+".dpAR_type", CLASS_NAME, type="string") # add module type counter value cmds.addAttr(self.toStaticHookGrp, longName='dpAR_count', attributeType='long', keyable=False) cmds.setAttr(self.toStaticHookGrp+'.dpAR_count', dpAR_count) # add hook attributes to be read when rigging integrated modules: utils.addHook(objName=self.toCtrlHookGrp, hookType='ctrlHook') utils.addHook(objName=self.grpHead, hookType='rootHook') utils.addHook(objName=self.toScalableHookGrp, hookType='scalableHook') utils.addHook(objName=self.toStaticHookGrp, hookType='staticHook') #Ensure head Jxt matrix mHead = cmds.getAttr(self.headCtrl + ".worldMatrix") cmds.xform(self.headJxt, m=mHead, ws=True) if hideJoints: cmds.setAttr(self.toScalableHookGrp+".visibility", 0) # delete duplicated group for side (mirror): cmds.delete(side+self.userGuideName+'_'+self.mirrorGrp) # finalize this rig: self.integratingInfo() cmds.select(clear=True) # delete UI (moduleLayout), GUIDE and moduleInstance namespace: self.deleteModule()
def checkBoxStatus(Status, Event): if "T" == Status: cmds.checkBox('trans_x', e=True, value=Event) cmds.checkBox('trans_y', e=True, value=Event) cmds.checkBox('trans_z', e=True, value=Event) elif "R" == Status: cmds.checkBox('rot_x', e=True, value=Event) cmds.checkBox('rot_y', e=True, value=Event) cmds.checkBox('rot_z', e=True, value=Event) elif "S" == Status: cmds.checkBox('scl_x', e=True, value=Event) cmds.checkBox('scl_y', e=True, value=Event) cmds.checkBox('scl_z', e=True, value=Event) elif "TAll" == Status: cmds.checkBox('trans_All', e=True, value=Event) elif "RAll" == Status: cmds.checkBox('rot_All', e=True, value=Event) elif "SAll" == Status: cmds.checkBox('scl_All', e=True, value=Event)
def heyWitch_makeInfluenceWindow(self, infMshName, infMshSknClstr, *args): tempInfWindow = InfluenceWindow() tempInfWindow.skin_cluster = infMshSknClstr tempInfWindow.inf_mesh_name = infMshName self.global_work_space['miscData']['infWindowStorage'][ 'temp'] = tempInfWindow infWindowBld = cmds.window(title='Influence Window Builder', widthHeight=(500, 400)) infScroll = cmds.scrollLayout() infWinRows = cmds.rowLayout(numberOfColumns=100) self.helper.heyWitch_tidyRows(infWinRows) cmds.setParent('..') utilityFrame = cmds.frameLayout(label='Influence Picker for ' + tempInfWindow.skin_cluster, collapsable=True) infToAdd = [] infList = cmds.skinCluster(tempInfWindow.skin_cluster, query=True, influence=True) tempInfWindow.full_influence_list = infList infPickRows = cmds.rowLayout(numberOfColumns=2) self.helper.heyWitch_tidyRows(infPickRows) infPickColumn = cmds.columnLayout() for infJnt in infList: cmds.checkBox(label=infJnt, onc=partial(self.heyWitch_addCheckedInfToList, infJnt, infToAdd), ofc=partial(self.heyWitch_removeCheckedInfToList, infJnt, infToAdd)) cmds.setAttr(infJnt + '.lockInfluenceWeights', 1) cmds.setParent('..') cmds.columnLayout() cmds.text(label='Enter New Influence Window Name:') infWinTxtFld = cmds.textField() cmds.button(label='+SaveSetup', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_saveTempInfStorage, infWinTxtFld, tempInfWindow)) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') infColA = cmds.columnLayout(parent=infWinRows, annotation='infColA') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColA, infPickColumn)) cmds.setParent('..') infColB = cmds.columnLayout(parent=infWinRows, annotation='infColB') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColB, infPickColumn)) cmds.setParent('..') infColC = cmds.columnLayout(parent=infWinRows, annotation='infColC') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColC, infPickColumn)) cmds.setParent('..') infColD = cmds.columnLayout(parent=infWinRows, annotation='infColD') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColD, infPickColumn)) cmds.setParent('..') infColE = cmds.columnLayout(parent=infWinRows, annotation='infColE') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColE, infPickColumn)) cmds.setParent('..') infColF = cmds.columnLayout(parent=infWinRows, annotation='infColF') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColF, infPickColumn)) cmds.setParent('..') infColG = cmds.columnLayout(parent=infWinRows, annotation='infColG') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColG, infPickColumn)) cmds.setParent('..') infColH = cmds.columnLayout(parent=infWinRows, annotation='infColH') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColH, infPickColumn)) cmds.setParent('..') infColI = cmds.columnLayout(parent=infWinRows, annotation='infColI') cmds.button(label='+AddInfs', height=25, backgroundColor=[0.35, 0.35, 0.35], command=partial(self.heyWitch_addCheckedInfsToCol, infToAdd, infColI, infPickColumn)) cmds.setParent('..') cmds.setParent('..') cmds.showWindow(infWindowBld)
def ReductKeyFunction(): cmds.commandEcho(ln=False) #define UI information channelCheck = getChannelCheck() channelBox_attrs = channelBoxList(channelCheck) appliedChannels = appliedChannelList(channelCheck) [start, end] = defineTimeRange() #create objLists objLists = cmds.ls(sl=True) if cmds.checkBox('LockSelectedKey', q=True, value=True) == True: #create L_KeyNameLists L_KeyNameLists = cmds.keyframe(q=True, n=True) [L_Name, L_keyTimes, L_keyValues, L_keyOutTangents, L_keyTangentTypes] = lockedKeyframe(L_KeyNameLists) else: L_Name = [] L_keyTimes = [] L_keyValues = [] L_keyOutTangents = [] L_keyTangentTypes = [] #undo cmds.undoInfo(openChunk=True) for obj in objLists: #define channels [keyable_channels, channels] = common(obj, channelCheck, channelBox_attrs, appliedChannels, start, end) if len(channels) != 0: for channel in channels: #get key information key_times = cmds.keyframe('{0}.{1}'.format(obj, channel), q=True, t=(start, end), timeChange=True) key_values = cmds.keyframe('{0}.{1}'.format(obj, channel), q=True, t=(start, end), valueChange=True) key_numbers = cmds.keyframe('{0}.{1}'.format(obj, channel), q=True, t=(start, end), iv=True) key_outTangents = cmds.keyTangent('{0}.{1}'.format( obj, channel), q=True, t=(start, end), outAngle=True) key_tangentTypes = cmds.keyTangent('{0}.{1}'.format( obj, channel), q=True, t=(start, end), ott=True) #fixed keyTangent fixed_index = fixedKey(key_tangentTypes, key_numbers) if len(fixed_index) != 0: cmds.keyTangent('{0}.{1}'.format(obj, channel), e=True, index=fixed_index, itt='fixed', ott='fixed') else: continue if len(key_outTangents) == 1: continue else: reduct_index = getReduct_index(key_outTangents, key_values, key_numbers, key_times) if len(reduct_index) != 0: cmds.cutKey(obj, at=channel, clear=True, index=reduct_index) else: continue else: continue if cmds.checkBox('LockSelectedKey', q=True, value=True) == True: if len(L_Name) != 0: for (i, L_name) in enumerate(L_Name): L_Times = L_keyTimes[i] L_values = L_keyValues[i] L_OutTangents = L_keyOutTangents[i] L_TangentTypes = L_keyTangentTypes[i] for (j, L_Time) in enumerate(L_Times): cmds.setKeyframe(L_name, t=(L_Time, L_Time), value=L_values[j]) cmds.keyTangent(L_name, e=True, time=(L_Time, L_Time), ia=L_OutTangents[j], oa=L_OutTangents[j], itt=L_TangentTypes[j], ott=L_TangentTypes[j]) cmds.undoInfo(closeChunk=True)
def radioButtonStatus(Status): if "AllKeyable" == Status: cmds.checkBox('trans_x', e=True, value=True, enable=False) cmds.checkBox('trans_y', e=True, value=True, enable=False) cmds.checkBox('trans_z', e=True, value=True, enable=False) cmds.checkBox('trans_All', e=True, value=True, enable=False) cmds.checkBox('rot_x', e=True, value=True, enable=False) cmds.checkBox('rot_y', e=True, value=True, enable=False) cmds.checkBox('rot_z', e=True, value=True, enable=False) cmds.checkBox('rot_All', e=True, value=True, enable=False) cmds.checkBox('scl_x', e=True, value=True, enable=False) cmds.checkBox('scl_y', e=True, value=True, enable=False) cmds.checkBox('scl_z', e=True, value=True, enable=False) cmds.checkBox('scl_All', e=True, value=True, enable=False) elif "FromAttributes" == Status: cmds.checkBox('trans_x', e=True, enable=True) cmds.checkBox('trans_y', e=True, enable=True) cmds.checkBox('trans_z', e=True, enable=True) cmds.checkBox('trans_All', e=True, enable=True) cmds.checkBox('rot_x', e=True, enable=True) cmds.checkBox('rot_y', e=True, enable=True) cmds.checkBox('rot_z', e=True, enable=True) cmds.checkBox('rot_All', e=True, enable=True) cmds.checkBox('scl_x', e=True, enable=True) cmds.checkBox('scl_y', e=True, enable=True) cmds.checkBox('scl_z', e=True, enable=True) cmds.checkBox('scl_All', e=True, enable=True) elif "FromChannelBox" == Status: cmds.checkBox('trans_x', e=True, enable=False) cmds.checkBox('trans_y', e=True, enable=False) cmds.checkBox('trans_z', e=True, enable=False) cmds.checkBox('trans_All', e=True, enable=False) cmds.checkBox('rot_x', e=True, enable=False) cmds.checkBox('rot_y', e=True, enable=False) cmds.checkBox('rot_z', e=True, enable=False) cmds.checkBox('rot_All', e=True, enable=False) cmds.checkBox('scl_x', e=True, enable=False) cmds.checkBox('scl_y', e=True, enable=False) cmds.checkBox('scl_z', e=True, enable=False) cmds.checkBox('scl_All', e=True, enable=False) elif "TimeSlider" == Status: cmds.floatField('StartTime', e=True, enable=False) cmds.floatField('EndTime', e=True, enable=False) elif "StartEnd" == Status: cmds.floatField('StartTime', e=True, enable=True) cmds.floatField('EndTime', e=True, enable=True)
def w19_do_cmd(self, *args): parName = cmds.textFieldButtonGrp('w19_parName', q=True, text=True) initialState = cmds.checkBox('w19_initialState', q=True, v=True) qm.objsToPar(parName, initialState)
def BakeFunction(): cmds.commandEcho(ln=False) #define UI information channelCheck = getChannelCheck() channelBox_attrs = channelBoxList(channelCheck) appliedChannels = appliedChannelList(channelCheck) [start, end] = defineTimeRange() b_sample = cmds.floatField('bakeSample', q=True, value=True) #create objLists objLists = cmds.ls(sl=True) #undo cmds.undoInfo(openChunk=True) bake_channels = bake_channel(channelCheck, channelBox_attrs, appliedChannels) if cmds.checkBox('Euler', q=True, value=True) == True: if cmds.checkBox('Sim', q=True, value=True) == True: cmds.bakeResults(objLists, at=bake_channels, simulation=True, t=(start, end), sb=b_sample, pok=True) cmds.setKeyframe(objLists, t=(-10000, -10000)) cmds.setKeyframe(objLists, t=(-10001, -10001), value=0) cmds.filterCurve(objLists) cmds.cutKey(obj, at=bake_channels, t=(-10001, -10000)) else: cmds.bakeResults(objLists, at=bake_channels, t=(start, end), sb=b_sample, pok=True) cmds.setKeyframe(objLists, t=(-10000, -10000)) cmds.setKeyframe(objLists, t=(-10001, -10001), value=0) cmds.filterCurve(objLists) cmds.cutKey(objLists, at=bake_channels, t=(-10001, -10000)) else: if cmds.checkBox('Sim', q=True, value=True) == True: cmds.bakeResults(objLists, at=bake_channels, simulation=True, t=(start, end), sb=b_sample, pok=True) else: cmds.bakeResults(objLists, at=bake_channels, t=(start, end), sb=b_sample, pok=True) if cmds.checkBox('POK', q=True, value=True) == False: cmds.cutKey(objLists, at=bake_channels, clear=True, t=(-100000, start - 1)) cmds.cutKey(objLists, at=bake_channels, clear=True, t=(end + 1, 100000)) else: pass cmds.undoInfo(closeChunk=True)
def loadPreset(reset=False, *args): scriptPath = mc.internalVar(usd=1) DW_MaterialManagerPath = scriptPath + r'DW_MaterialManager' if not reset: presetFilePath = os.path.join(DW_MaterialManagerPath, 'presets', 'UI_lastPreset.json') else: presetFilePath = os.path.join(DW_MaterialManagerPath, 'presets', 'UI_defaultPreset.json') presetFilePath = presetFilePath.replace('/', '\\') with open(presetFilePath, "r") as fp: contentDict = json.load(fp) mc.frameLayout('MaterialImport', e=1, cl=contentDict['MaterialImport']) mc.optionMenuGrp('createMaterial', e=1, v=contentDict['createMaterial']) mc.optionMenuGrp('useTemplate', e=1, v=contentDict['useTemplate']) mc.checkBox('udim', e=1, v=contentDict['udim']) mc.checkBox('usingMayaColorManagement', e=1, v=contentDict['usingMayaColorManagement']) mc.checkBox('openGLNormal', e=1, v=contentDict['openGLNormal']) mc.textFieldGrp('zeroHeight', e=1, tx=contentDict['zeroHeight']) mc.textFieldGrp('heightDepth', e=1, tx=contentDict['heightDepth']) mc.checkBox('heightMap_8bit', e=1, v=contentDict['heightMap_8bit']) mc.checkBox('heightMapAsDisplacement', e=1, v=contentDict['heightMapAsDisplacement']) mc.textFieldGrp('userDefinedPathTextField', e=1, tx=contentDict['userDefinedPathTextField']) mc.textFieldGrp('materialNameInput', e=1, tx=contentDict['materialNameInput']) mc.frameLayout('MaterialConverter', e=1, cl=contentDict['MaterialConverter']) mc.optionMenuGrp('convertFromOptionMenu', e=1, v=contentDict['convertFromOptionMenu']) mc.optionMenuGrp('convertToOptionMenu', e=1, v=contentDict['convertToOptionMenu']) mc.frameLayout('LinearWorkFlow', e=1, cl=contentDict['LinearWorkFlow']) mc.checkBox('affectColorSwatch', e=1, v=contentDict['affectColorSwatch']) mc.radioCollection('origRadioCollection', e=1, sl=contentDict['origRadioCollection']) mc.radioCollection('targetRadioCollection', e=1, sl=contentDict['targetRadioCollection']) mc.textFieldGrp('diffuseColor', e=1, tx=contentDict['diffuseColor']) mc.textFieldGrp('metalness', e=1, tx=contentDict['metalness']) mc.textFieldGrp('reflectionColor', e=1, tx=contentDict['reflectionColor']) mc.textFieldGrp('glossiness', e=1, tx=contentDict['glossiness']) mc.textFieldGrp('f0', e=1, tx=contentDict['f0']) mc.textFieldGrp('ior', e=1, tx=contentDict['ior']) mc.textFieldGrp('emissive', e=1, tx=contentDict['emissive']) mc.textFieldGrp('normal', e=1, tx=contentDict['normal']) mc.textFieldGrp('height', e=1, tx=contentDict['height']) mc.frameLayout('MaterialAssign', e=1, cl=contentDict['MaterialAssign']) mc.checkBox('enableSubdiv_dis', e=1, v=contentDict['enableSubdiv_dis']) changeUseTemplate()
def globalModify_reference_ui(): if cm.window('gmr_win',ex=True): cm.deleteUI('gmr_win') gmr_window=cm.window('gmr_win',t='GlobalModify v1.0',wh=(200,300)) gmr_maincol=cm.columnLayout('g_main_col',cat=["both",3],adj=True) gmr_aw_f=cm.frameLayout('g_aw_frame',label='AO / WorldNormal',cll=True,borderStyle='etchedOut',\ ec=lambda *args:resizeWindowH('gmr_win','g_zd_frame','g_id_frame',688,571,505,388),\ cc=lambda *args:resizeWindowH('gmr_win','g_zd_frame','g_id_frame',362,245,179,62)) gmr_faw_col=cm.columnLayout('g_faw_col',cat=["both",3],adj=True) gmr_samples=cm.intFieldGrp('g_samp', l='Samples', value1=45,cl2=['right','left'],cw2=[80,70]) gmr_brig=cm.colorSliderGrp('g_brig',label='Bright', rgb=(1, 1, 1) ,cl3=['right','left','left'],cw3=[80,70,120]) gmr_dark=cm.colorSliderGrp('g_dark',label='Dark', rgb=(0, 0, 0) ,cl3=['right','left','left'],cw3=[80,70,120]) gmr_spread=cm.floatFieldGrp('g_spre', l='Spread', value1=0.8,cl2=['right','left'],cw2=[80,70]) gmr_maxD=cm.floatFieldGrp('g_maxD', l='Max Distance', value1=25,cl2=['right','left'],cw2=[80,70]) gmr_re_col=cm.columnLayout('g_re_col',cat=["both",83],adj=True) gmr_reflective=cm.checkBox('g_reflective',l='Reflective') cm.setParent('g_faw_col') gmr_outputM=cm.intSliderGrp('g_outputM',field=True, label='Output Mode', minValue=0, maxValue=3, fieldMinValue=0, fieldMaxValue=100, value=0 ,cl3=['right','left','left'],cw3=[80,70,120]) gmr_oIA_col=cm.columnLayout('g_oIA_col',cat=["left",83],adj=True) gmr_OIA=cm.checkBox('g_OIA',l='Occlusion In Alpha') cm.setParent('g_faw_col') gmr_fallo=cm.floatFieldGrp('g_fallo', l='Falloff', value1=0.5,cl2=['right','left'],cw2=[80,70]) gmr_idIncl=cm.intFieldGrp('g_idIncl', l='Id Inclexcl', value1=-1,cl2=['right','left'],cw2=[80,70]) gmr_idNonself=cm.intFieldGrp('g_idNonself', l='Id Nonself', value1=1,cl2=['right','left'],cw2=[80,70]) cm.separator('g_separ_up', height=10, style='in' ) gmr_AO_col=cm.columnLayout('g_AO_col',cat=["left",83],adj=True) gmr_AO=cm.checkBox('g_AO',l='AO',v=True,onc=lambda *args:openCheckBox('g_WN',45,0.8,25,0,0.5,-1,1,1,0)) gmr_WN=cm.checkBox('g_WN',l='World Normal',onc=lambda *args:openCheckBox('g_AO',0,0,0,3,1,1,1,1,0)) cm.setParent('g_faw_col') cm.separator('g_separ_down', height=10, style='in' ) gmr_mAWn=cm.button('g_mAWn',l='Modify AO /worldNormal...',h=30,bgc=[0.3,0.5,0.8],c=lambda *args:getAoAndWnM()) cm.separator('g_separ_xiadown', height=10, style='in' ) cm.setParent('g_main_col') gmr_zd_f=cm.frameLayout('g_zd_frame',label='Zdepth',cll=True,borderStyle='etchedOut',\ ec=lambda *args:resizeWindowH('gmr_win','g_aw_frame','g_id_frame',688,362,505,179),\ cc=lambda *args:resizeWindowH('gmr_win','g_aw_frame','g_id_frame',571,245,388,62)) gmr_fzd_col=cm.columnLayout('g_fzd_col',cat=["both",3],adj=True) gmr_NCP=cm.floatFieldGrp('g_NCP', l='Near Clip Plane', value1=1,cl2=['right','left'],cw2=[120,70]) gmr_FCP=cm.floatFieldGrp('g_FCP', l='Far Clip Plane', value1=20,cl2=['right','left'],cw2=[120,70]) gmr_in_col=cm.columnLayout('g_in_col',cat=["left",123],adj=True) #gmr_invert=cm.checkBox('g_invert',l='Invert Result',v=True) cm.setParent('g_fzd_col') cm.separator('g_separ_zd_down', height=25, style='in' ) gmr_zdepth=cm.button('g_zdepth',l='Modify Zdepth...',h=30,bgc=[0.3,0.5,0.8],c=lambda *args:getZdepthAndM()) cm.separator('g_separ_zd_xiadown', height=10, style='in' ) cm.setParent('g_main_col') gmr_id_f=cm.frameLayout('g_id_frame',label='ID',cll=True,borderStyle='etchedOut',\ ec=lambda *args:resizeWindowH('gmr_win','g_aw_frame','g_zd_frame',688,360,571,245),\ cc=lambda *args:resizeWindowH('gmr_win','g_aw_frame','g_zd_frame',505,179,388,62)) gmr_fid_col=cm.columnLayout('g_fid_col',cat=["both",3],adj=True) gmr_asset=cm.colorSliderGrp('g_asset',label='Asset Object ID', rgb=(0, 0, 0) ,cl3=['right','left','left'],cw3=[80,70,120]) gmr_mat=cm.colorSliderGrp('g_mat',label='Material ID', rgb=(0, 0, 0) ,cl3=['right','left','left'],cw3=[80,70,120]) gmr_asset_col=cm.columnLayout('g_asset_col',cat=["left",123],adj=True) gmr_asset_c=cm.checkBox('g_asset_c',l='AssetID',v=1) gmr_mat_c=cm.checkBox('g_mat_c',l='MatID',v=1) cm.setParent('g_fid_col') cm.separator('g_separ_id_down', height=10, style='in' ) gmr_id=cm.button('g_id',l='Modify ID...',h=30,bgc=[0.3,0.5,0.8],c=lambda *args:modifyID()) cm.separator('g_g_separ_id_xiadown', height=10, style='in' ) gmr_g_asset_col=cm.columnLayout('g_g_asset_col',cat=["left",10],adj=True) gmr_g_asset_c=cm.checkBox('g_g_asset_c',l='Reference Level (on: top && off: down)',v=1) cm.setParent('g_fid_col') gmr_r_id=cm.button('g_r_id',l='Random ID...',h=30,bgc=[0.3,0.5,0.8],c=lambda *args:modifyRandomID()) cm.separator('g_separ_id_xiadown', height=10, style='in' ) cm.window('gmr_win',e=True,wh=(320,688)) cm.showWindow('gmr_win')
def savePreset(*args): contentDict = {} mc.frameLayout('MaterialImport', q=1, cl=1) contentDict['MaterialImport'] = mc.frameLayout('MaterialImport', q=1, cl=1) contentDict['createMaterial'] = mc.optionMenuGrp('createMaterial', q=1, v=1) contentDict['useTemplate'] = mc.optionMenuGrp('useTemplate', q=1, v=1) contentDict['udim'] = mc.checkBox('udim', q=1, v=1) contentDict['usingMayaColorManagement'] = mc.checkBox( 'usingMayaColorManagement', q=1, v=1) contentDict['openGLNormal'] = mc.checkBox('openGLNormal', q=1, v=1) contentDict['zeroHeight'] = mc.textFieldGrp('zeroHeight', q=1, tx=1) contentDict['heightDepth'] = mc.textFieldGrp('heightDepth', q=1, tx=1) contentDict['heightMap_8bit'] = mc.checkBox('heightMap_8bit', q=1, v=1) contentDict['heightMapAsDisplacement'] = mc.checkBox( 'heightMapAsDisplacement', q=1, v=1) contentDict['userDefinedPathTextField'] = mc.textFieldGrp( 'userDefinedPathTextField', q=1, tx=1) contentDict['materialNameInput'] = mc.textFieldGrp('materialNameInput', q=1, tx=1) contentDict['MaterialConverter'] = mc.frameLayout('MaterialConverter', q=1, cl=1) contentDict['convertFromOptionMenu'] = mc.optionMenuGrp( 'convertFromOptionMenu', q=1, v=1) contentDict['convertToOptionMenu'] = mc.optionMenuGrp( 'convertToOptionMenu', q=1, v=1) contentDict['LinearWorkFlow'] = mc.frameLayout('LinearWorkFlow', q=1, cl=1) contentDict['affectColorSwatch'] = mc.checkBox('affectColorSwatch', q=1, v=1) contentDict['origRadioCollection'] = mc.radioCollection( 'origRadioCollection', q=1, sl=1) contentDict['targetRadioCollection'] = mc.radioCollection( 'targetRadioCollection', q=1, sl=1) contentDict['diffuseColor'] = mc.textFieldGrp('diffuseColor', q=1, tx=1) contentDict['metalness'] = mc.textFieldGrp('metalness', q=1, tx=1) contentDict['reflectionColor'] = mc.textFieldGrp('reflectionColor', q=1, tx=1) contentDict['glossiness'] = mc.textFieldGrp('glossiness', q=1, tx=1) contentDict['f0'] = mc.textFieldGrp('f0', q=1, tx=1) contentDict['ior'] = mc.textFieldGrp('ior', q=1, tx=1) contentDict['emissive'] = mc.textFieldGrp('emissive', q=1, tx=1) contentDict['normal'] = mc.textFieldGrp('normal', q=1, tx=1) contentDict['height'] = mc.textFieldGrp('height', q=1, tx=1) contentDict['MaterialAssign'] = mc.frameLayout('MaterialAssign', q=1, cl=1) contentDict['enableSubdiv_dis'] = mc.checkBox('enableSubdiv_dis', q=1, v=1) scriptPath = mc.internalVar(usd=1) DW_MaterialManagerPath = scriptPath + r'DW_MaterialManager' presetFilePath = os.path.join(DW_MaterialManagerPath, 'presets', 'UI_lastPreset.json') presetFilePath = presetFilePath.replace('\\', '/') with open(presetFilePath, "w") as fp: json.dump(contentDict, fp, indent=2)
def UI(): offsetFromLeft = 80 if mc.dockControl('DW_MaterialManager_dockControl', ex=1): mc.deleteUI('DW_MaterialManager_dockControl') mc.window('DW_MaterialManager', t='DW_MaterialManager', menuBar=1) mc.showWindow() mainRCL = mc.rowColumnLayout(w=450, numberOfColumns=1) mc.dockControl('DW_MaterialManager_dockControl', area='left', content='DW_MaterialManager', fl=1, l='DW_MaterialManager') #mc.separator(style = 'none',h = 20) mc.menu(label='UI', tearOff=0) mc.menuItem(label='save preset', c=savePreset) mc.menuItem(label='reset to default', c=partial(loadPreset, True)) #mc.rowColumnLayout(co = (1,'left',300)) mc.menu(label='Help', tearOff=0, hm=1) mc.menuItem(label='how to use', c=partial(openWeb, r'https://zhuanlan.zhihu.com/p/27649330')) mc.menuItem(label='checkNewVersion', c=partial(openWeb, r'https://trello.com/b/Zphjhcpo')) mc.menuItem(label='aboutAuthor', c=partial(openWeb, r'http://weibo.com/david376 ')) ################################################################################################################################################## #the UI used to choose renderer tabLayout = mc.tabLayout() frame01 = mc.frameLayout('MaterialImport', l='Material Importer', cll=1, cl=0, w=400, cc=savePreset, ec=savePreset_changeUseTemplate, p=tabLayout) mc.separator(style='none', h=1) createMaterial = mc.optionMenuGrp('createMaterial', l='CreateMaterial', cc=savePreset, cw2=[offsetFromLeft, 100]) for supportedMaterial in supportedMaterials: mc.menuItem(supportedMaterial) useTemplate = mc.optionMenuGrp('useTemplate', l='UseTemplate', cc=changeUseTemplate, cw2=[offsetFromLeft, 100]) for template in supportedTemplates: mc.menuItem(template) mc.separator('customTemplateStart') mc.textFieldGrp('diffuseColor', l='diffuseColor', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) mc.textFieldGrp('metalness', l='metalness', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) mc.textFieldGrp('reflectionColor', l='reflectionColor', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) mc.textFieldGrp('glossiness', l='glossiness', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) mc.textFieldGrp('f0', l='f0', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) mc.textFieldGrp('ior', l='ior', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) mc.textFieldGrp('emissive', l='emissive', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) mc.textFieldGrp('normal', l='normal', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) mc.textFieldGrp('height', l='height', cl2=['right', 'left'], cw2=[offsetFromLeft, 100], cc=savePreset_saveCustomTemplate) #buttonRCL00 = mc.rowColumnLayout(co = (1,'left',offsetFromLeft + 2)) #mc.button('saveCustom',l = 'saveCustom',w = 100,h = 30,c = saveCustomTemplate) mc.separator('customTemplateEnd', p=frame01) mc.rowColumnLayout(co=(1, 'left', offsetFromLeft + 4), p=frame01) mc.separator(h=20) mc.separator(style='out') mc.checkBox('udim', l='udim textures', align='right', cc=savePreset) #mc.checkBox(l = 'true reflection',onc = trueReflection_on,ofc = trueReflection_off,align = 'right') # if 2016 and above version maya, usingMayaColorManagement as default. # if 2015 and lower version maya, don't use mayaColorManagement if mayaVersion > 2015: usingMayaColorManagement = True else: usingMayaColorManagement = False mc.checkBox('usingMayaColorManagement', l='usingMayaColorManagement', align='right', v=usingMayaColorManagement, cc=savePreset) mc.checkBox('openGLNormal', l='openGLNormal (uncheck means directX normal)', align='right', v=1, cc=savePreset) mc.separator(h=1, p=frame01) #mc.rowColumnLayout(co = (1,'left',offsetFromLeft + 4)) #heightMapText = mc.text('heightMap:',al = 'left') mc.rowColumnLayout(p=frame01, h=45) mc.textFieldGrp('zeroHeight', l='zeroHeight', cl2=['right', 'left'], cw2=[80, 100], tx=0.5, cc=savePreset) mc.textFieldGrp('heightDepth', l='heightDepth', cl2=['right', 'left'], cw2=[80, 100], tx=0.05, cc=savePreset) mc.rowColumnLayout(co=(1, 'left', offsetFromLeft + 4), p=frame01, h=40) mc.checkBox('heightMap_8bit', l='heightMap_8bit', align='right', v=1, ofc=heightMap_32bit, onc=heightMap_8bit, cc=savePreset) mc.checkBox('heightMapAsDisplacement', l='heightMapAsDisplacement', align='right', v=1, cc=changeHeightMapAsDisplacement) mc.separator(h=1, p=frame01) inputRCL = mc.rowColumnLayout(p=mainRCL, w=430) userDefinedPathTextField = mc.textFieldGrp('userDefinedPathTextField', l='TexturesPath', cw2=[offsetFromLeft, 320], p=frame01, cc=savePreset) mc.iconTextButton(style='iconOnly', image='xgBrowse.png', p=userDefinedPathTextField, c=openDirectory) materialNameInput = mc.textFieldGrp('materialNameInput',l = 'MaterialName',cw2 = [offsetFromLeft,320],p = frame01,\ tx = '',cc = savePreset) buttonRCL01 = mc.rowColumnLayout(co=(1, 'left', offsetFromLeft + 2), p=frame01) convertButton = mc.button('import', l='import / assign', w=320, h=50, c=materialImporter.import_replaceMaterialsByName, p=buttonRCL01) #convertButton = mc.button('replace',l = 'import / replaceByName',w = 320,h = 50,c = materialImporter.main,p = buttonRCL01) mc.separator(style='none', h=5, p=frame01) ################################################################################################################################################## frame02 = mc.frameLayout('MaterialAssign', l='Material Assign', cll=1, cl=0, w=430, p=tabLayout, cc=savePreset, ec=savePreset) mc.separator(h=5, style='none') mc.rowColumnLayout(nc=2, cs=[2, 10]) mc.text('tempMaterial:') mc.text('tempMaterial', l='') mc.separator(h=3, p=frame02) buttonRCL02 = mc.rowColumnLayout(co=(1, 'left', offsetFromLeft + 2), nc=2, cs=[2, 10], p=frame02) mc.checkBox('enableSubdiv_dis', l='enableSubdiv_dis', v=1, cc=savePreset) mc.separator(h=1, style='none') mc.button('getMaterial', l='getMaterial', w=150, h=50, c=getMaterialFromSelectedAndStore) mc.button('assignTempMaterial', l='assignTempMaterial', w=150, h=50, c=assignMaterialToSelected) mc.separator(h=20) #################################################################################################################################################################### frame03 = mc.frameLayout('MaterialConverter', l='Material Converter', cll=1, cl=0, w=230, cc=savePreset, ec=savePreset, p=tabLayout) mc.separator(style='none', h=1) convertFromOptionMenu = mc.optionMenuGrp('convertFromOptionMenu', l='from: ', cc=changeConvertFrom, cw2=[30, 165], cal=[1, 'left'], cl2=['left', 'left']) for supportedMaterial in supportedMaterials: mc.menuItem(supportedMaterial) convertToOptionMenu = mc.optionMenuGrp('convertToOptionMenu', l='to :', p=convertFromOptionMenu, cal=[(1, 'left')], cw2=[20, 165], cc=changeConvertTo) for supportedMaterial in supportedMaterials: mc.menuItem(supportedMaterial) def __switchMaterial(): global convertFrom global convertTo temp = '' temp = convertTo convertTo = convertFrom convertFrom = temp convertFromOptionMenu mc.optionMenuGrp('convertFromOptionMenu', e=1, v=convertFrom) mc.optionMenuGrp('convertToOptionMenu', e=1, v=convertTo) mc.iconTextButton(style='iconOnly', image='iGroom_reset.png', p=convertToOptionMenu, c=__switchMaterial) buttonRCL03 = mc.rowColumnLayout(co=(1, 'left', 30 + 4)) def __LWF_frameLayout(): frame04 = mc.frameLayout('LinearWorkFlow', l='LinearWorkFlow', cll=1, cl=0, w=340, cc=savePreset, ec=savePreset) mc.rowColumnLayout(numberOfRows=3, co=(2, 'left', 60)) origRadioCollection = mc.radioCollection('origRadioCollection') mc.radioButton('orig_use_maya_colorSpace', l='use maya colorSpace', sl=1, ofc=changeOrigColorSpace) mc.radioButton('orig_classic_gamma_2point2', l='classic gamma 2.2', ofc=changeOrigColorSpace) mc.radioButton('orig_classic_Raw', l='classic Raw', ofc=changeOrigColorSpace) targetRadioCollection = mc.radioCollection('targetRadioCollection') mc.radioButton('target_use_maya_colorSpace', l='use maya colorSpace', sl=1, ofc=changeTargetColorSpace) mc.radioButton('target_classic_gamma_2point2', l='classic gamma 2.2', ofc=changeTargetColorSpace) mc.radioButton('target_classic_Raw', l='classic Raw', ofc=changeTargetColorSpace) mc.separator(h=1, p=frame04) mc.checkBox('affectColorSwatch', l='affect color swatch', cc=savePreset_changeAffectColorSwitch, p=frame04) mc.separator(h=5, p=frame04) __LWF_frameLayout() #for changeConvertFrom function will change UI settings ,we should loadPreset before it loadPreset() changeConvertFrom() changeConvertTo() changeUseTemplate() changeAffectColorSwitch() changeHeightMapAsDisplacement() mc.separator(style='none', h=20) convertButton = mc.button('convert', l='convert', w=340, h=50, c=materialConvert, p=buttonRCL03) #mc.columnLayout(p = mainRCL,w = 300) mc.rowColumnLayout(co=(1, 'left', 250), p=mainRCL, w=300) mc.text(l='DW_MaterialManager_v2.03b', w=160, al='right', hyperlink=1, ww=1, ann='the version of the script') mc.separator(h=10)