def buildWorldSpaceMesh(): ''' ''' # Check SkinClusterData skinData = glTools.gl_global.glSkinClusterData if not skinData: return # Get Affected Geometry if not skinData._data.has_key('affectedGeometry'): raise Exception('No skin geometry data! Unable to rebuild worldSpace mesh...') skinGeo = skinData._data['affectedGeometry'][0] if not skinData._data.has_key(skinGeo): raise Exception('No skin geometry data for "'+skinGeo+'"! Unable to rebuild worldSpace mesh...') if skinData._data[skinGeo]['geometryType'] != 'mesh': raise Exception('Skin geometry "'+skinGeo+'" is not a mesh! Unable to rebuild worldSpace mesh...') if not skinData._data[skinGeo].has_key('mesh'): raise Exception('No world space data for "'+skinGeo+'"! Unable to rebuild worldSpace mesh...') # Rebuild Mesh mesh = skinData._data[skinGeo]['mesh'].rebuildMesh() if not mesh.endswith('_worldSpaceMesh'): mesh = mc.rename(mesh,skinGeo+'_worldSpaceMesh') # Update TextFieldGrp mc.textFieldGrp('skinCluster_wsMeshTFG',e=True,text=mesh) # Return Result return mesh
def particleLocatorsUI(): """ """ # Get current frame range start = cmds.playbackOptions(q=True, min=True) end = cmds.playbackOptions(q=True, max=True) # Define window particleLocatorsUI = 'particleLocatorsWindow' if cmds.window(particleLocatorsUI, q=True, ex=True): cmds.deleteUI(particleLocatorsUI) particleLocatorsUI = cmds.window(particleLocatorsUI, t='Generate Locators') # UI Layout cmds.columnLayout(adj=False, cal='left') partiTFG = cmds.textFieldGrp('partiLoc_particleTFG', label='Particle', text='', cw=[(1, 120)]) prefixTFG = cmds.textFieldGrp('partiLoc_prefixTFG', label='Prefix', text='', cw=[(1, 120)]) bakeAnicmdsBG = cmds.checkBoxGrp('partiLoc_bakeAnicmdsBG', label='Bake Animation', ncb=1, v1=0, cw=[(1, 120)]) startEndIFG = cmds.intFieldGrp('partiLoc_startEndISG', nf=2, label='Frame Range', v1=start, v2=end, cw=[(1, 120)]) rotateLocCBG = cmds.checkBoxGrp('partiLoc_rotateCBG', label='Rotate (rotatePP)', ncb=1, v1=0, cw=[(1, 120)]) scaleLocCBG = cmds.checkBoxGrp('partiLoc_scaleCBG', label='Scale (scalePP)', ncb=1, v1=0, cw=[(1, 120)]) cmds.button(l='Create Locators', c='glTools.tools.generateParticles.particleLocatorsFromUI()') # Popup menu cmds.popupMenu(parent=partiTFG) for p in cmds.ls(type=['particle', 'nParticle']): cmds.menuItem(p, c='cmds.textFieldGrp("' + partiTFG + '",e=True,text="' + p + '")') # Show Window cmds.showWindow(particleLocatorsUI)
def windowSHM(*args): if cmds.window("shdrmnWin", exists = 1): cmds.deleteUI("shdrmnWin") win = cmds.window("shdrmnWin", title = "Shader manager", w = 500, sizeable = 0) mainLayout = cmds.columnLayout (w = 500) cmds.rowColumnLayout(w = 500, nc = 4, parent = mainLayout ) cmds.textFieldGrp( 'getAiAttrField', text = 'mColor') cmds.button(label = "GET TX", w= 83, h = 50, c = getTextureFromShader ) cmds.button(label = "SHOW TX", w= 83, h = 50, c = assignPREVShader) cmds.button(label = "TILE UV", w= 83, h = 50, c = setTileUV) cmds.rowColumnLayout(w = 500, nc = 1, parent = mainLayout ) cmds.button(label = "DELETE PREVIEW", w= 500, h = 50, c = deleteShaders, parent = mainLayout ) cmds.separator(height=10, parent = mainLayout) cmds.rowColumnLayout(w = 500, nc = 2, parent = mainLayout ) cmds.button(label = "GET MATERIALS", w= 250, h = 50, c = getMaterial ) cmds.button(label = "ASSIGN MATERIALS", w= 250, h = 50, c = asignMaterial ) cmds.showWindow(win)
def storeWorldSpaceMesh(): ''' ''' # Check SkinClusterData skinData = glTools.gl_global.glSkinClusterData if not skinData: return # Get Affected Geometry if not skinData._data.has_key('affectedGeometry'): raise Exception('No skin geometry data! Unable to rebuild worldSpace mesh...') skinGeo = skinData._data['affectedGeometry'][0] if not skinData._data.has_key(skinGeo): raise Exception('No skin geometry data for "'+skinGeo+'"! Unable to rebuild worldSpace mesh...') if skinData._data[skinGeo]['geometryType'] != 'mesh': raise Exception('Skin geometry "'+skinGeo+'" is not a mesh! Unable to rebuild worldSpace mesh...') # Initialize MeshData if not skinData._data[skinGeo].has_key('mesh'): skinData._data[skinGeo]['mesh'] = meshData.MeshData() # Store MeshData worldSpaceMesh = mc.textFieldGrp('skinCluster_wsMeshTFG',q=True,text=True) if not mc.objExists(worldSpaceMesh): raise Exception('World space mesh "'+worldSpaceMesh+'" doesn`t exist!') skinData._data[skinGeo]['mesh'].buildData(worldSpaceMesh) # Delete World Space Mesh mc.delete(worldSpaceMesh) # Update TextFieldGrp mc.textFieldGrp('skinCluster_wsMeshTFG',e=True,text='')
def addMultiAttr(): #Create a variable for the window name winName = 'blend' winTitle = 'rh_addMultiAttr' #Delete the window if it exists if cmds.window(winName, exists=True): cmds.deleteUI(winName, window=True) #Build the main window cmds.window(winName, title=winTitle, sizeable=True) cmds.textFieldButtonGrp('Obj',label='Object :', text='', ed = False,buttonLabel='Load Sel',bc = 'sel()') cmds.columnLayout(adjustableColumn=True) cmds.textFieldGrp('Attr',l='Attribute:',text='') cmds.columnLayout(adjustableColumn=True) cmds.floatFieldGrp('minAttr', numberOfFields=1, label='Min Value', value1=0) cmds.columnLayout(adjustableColumn=True) cmds.floatFieldGrp('maxAttr', numberOfFields=1, label='Max Value', value1=0) cmds.columnLayout(adjustableColumn=True) cmds.button(label='Contact', command='Connect()') cmds.columnLayout(adjustableColumn=True) #Show the window cmds.showWindow(winName) cmds.window(winName, edit=True, width=300, height=120)
def loadDirectoryPath(textField,caption='Load Directory',startDir=None): ''' Select a file path to load into a specified textField. @param textField: TextField UI object to load file path to @type textField: str @param caption: File selection UI caption string @type caption: str @param startDir: Directory to start browsing from. In None, use the default or last selected directory. @type startDir: str ''' # Get File Path dirPath = mc.fileDialog2( dialogStyle=2, fileMode=3, caption=caption, okCaption='Load', startingDirectory=startDir ) # Check File Path if not dirPath: print('Invalid directory path!') return # Load File Path to TextField if mc.textField(textField,q=True,ex=True): mc.textField(textField,e=True,text=dirPath[0]) elif mc.textFieldGrp(textField,q=True,ex=True): mc.textFieldGrp(textField,e=True,text=dirPath[0]) elif mc.textFieldButtonGrp(textField,q=True,ex=True): mc.textFieldButtonGrp(textField,e=True,text=dirPath[0]) else: print('UI element "'+textField+'" is of type "'+mc.objectTypeUI(textField)+'"! Expected textField, textFieldGrp or textFieldButtonGrp.') return # Return Result return dirPath[0]
def strAttribute(mainSetting, setting): cmds.textFieldGrp(str(setting.keys()[0])+'_attribute', label=str(setting.keys()[0]).replace('_', ' '), text=str(setting.values()[0]), editable=True, cc="import dmptools.setup.settingsWindow as settingsWindow;settingsWindow.updateStrAttr('"+mainSetting+"')" )
def exportGeoCombinedFromUI(): ''' writeGeoCombineCache from UI ''' # Get UI info path = mc.textFieldButtonGrp('meshCache_pathTBG',q=True,text=True) name = mc.textFieldGrp('meshCache_nameTFG',q=True,text=True) start = mc.intFieldGrp('meshCache_rangeIFG',q=True,v1=True) end = mc.intFieldGrp('meshCache_rangeIFG',q=True,v2=True) pad = mc.intFieldGrp('meshCache_paddingIFG',q=True,v1=True) uvSet = mc.textFieldGrp('meshCache_uvSetTFG',q=True,text=True) worldSpace = bool(mc.radioButtonGrp('meshCache_spaceRBG',q=True,sl=True)-1) gz = mc.checkBoxGrp('meshCache_gzipCBG',q=True,v1=True) # Check Name if not name: print 'Provide valid cache name and try again!' return # Check UV Set if uvSet == 'default': uvSet = '' # Get selection sel = [i for i in mc.ls(sl=True,fl=True,o=True) if glTools.utils.mesh.isMesh(i)] if not sel: print 'No valid mesh objects selected for export!!' return # Write Combine Cache glTools.tools.meshCache.writeGeoCombineCache(path,name,sel,start,end,pad,uvSet,worldSpace,gz)
def pupMaya2mental(mentalVersion): destPath = os.getenv('DEST_PATH_WIN') rootPath, shadersPath = { 3.8:('c:/Program Files/Autodesk/mrstand3.8.1-adsk2011/bin', destPath + '/mental3.8.1'), 3.11:('c:/Program Files/Autodesk/mrstand3.11.1-adsk2014/bin', destPath + '/mental3.11.1') }[mentalVersion] os.putenv('RAY_COMMAND', '"' + rootPath + '/ray.exe"') os.putenv('MR_VERSION', str( mentalVersion ) ) miModulesPaths, binModulesPaths = modulesPath.getMiBinString() #os.putenv('MI_RAY_INCPATH', shadersPath + '/mi;' + miModulesPaths) #os.putenv('MI_LIBRARY_PATH', shadersPath + '/bin;' + binModulesPaths) #os.putenv('MI_ROOT', rootPath) mel.eval('pup_maya_2_mental(3);') mc.checkBoxGrp('pup_m2mrOverrideEnv', e=True, v1=1) mc.textFieldGrp('pup_m2mrMiRoot', e=True, tx= rootPath ) mc.textFieldGrp('pup_m2mrMiInclude', e=True, tx= shadersPath + '/mi;' + miModulesPaths ) mc.textFieldGrp('pup_m2mrMiLib', e=True, tx= shadersPath + '/bin;' + binModulesPaths ) mc.textFieldGrp('pup_m2mrMiDir', e=True, tx= "C:/Temp/" ) mc.optionMenuGrp('pup_m2mrVerboseM', e=True, sl=5) #mc.textFieldGrp('pup_m2mrCommandLine', e=True, tx= '-finalgather_passes 0 -memory 1000000' ) mc.textFieldGrp('pup_m2mrCommandLine', e=True, tx= '-memory 1000000' ) mc.checkBoxGrp('pup_m2mrUniqueMI', e=True, v1=1) mc.optionMenuGrp('pup_m2mrPriority', e=True, sl=3)
def executeFromUI(): """ """ # Set Default Values minValue = 0.0 maxValue = 1.0 # Get UI input values driveAttr = cmds.textFieldGrp('tdb_driveAttrTFG', q=True, text=True) blendShape = cmds.textFieldGrp('tdb_blendShapeTFG', q=True, text=True) target1 = cmds.textFieldGrp('tdb_target1TFG', q=True, text=True) target2 = cmds.textFieldGrp('tdb_target1TFG', q=True, text=True) weight1 = cmds.floatFieldGrp('tdb_weight1FFG', q=True, v1=True) weight2 = cmds.floatFieldGrp('tdb_weight2FFG', q=True, v1=True) overlap = cmds.floatFieldGrp('tdb_overlapFFG', q=True, v1=True) prefix = cmds.textFieldGrp('tdb_prefixTFG', q=True, text=True) # Check Arguments if not blendShape: raise Exception('No blendShape specified!') if not target1: raise Exception('Target 1 not specified!') if target1 and target2: minValue = weight1 maxValue = weight2 else: maxValue = weight1 # Execute Command if target1 and target2: glTools.tools.transformDrivenBlend.drive2Shapes(blendShape, target1, target2, driveAttr, minValue, maxValue, overlap, prefix) else: glTools.tools.transformDrivenBlend.driveShape(blendShape, target, driveAttr, minValue, maxValue, prefix)
def attachToSurfaceFromUI(close=True): """ Execute attachToSurface() from UI @param close: """ # Window window = 'attachToSurfaceUI' if not cmds.window(window, q=True, ex=1): raise UIError('AttachToSurface UI does not exist!!') # Get UI data surf = cmds.textFieldGrp('attachToSurfaceTFB', q=True, text=True) # Check surface if not glTools.utils.surface.isSurface(surf): raise UserInputError('Object "' + surf + '" is not a valid nurbs surface!!') trans = cmds.textFieldGrp('attachToSurfaceTransformTFB', q=True, text=True) pre = cmds.textFieldGrp('attachToSurfacePrefixTFG', q=True, text=True) uParam = cmds.floatFieldGrp('attachToSurfaceParamTFB', q=True, v1=True) vParam = cmds.floatFieldGrp('attachToSurfaceParamTFB', q=True, v2=True) closePnt = cmds.checkBoxGrp('attachToSurfaceClosePntCBG', q=True, v1=True) uAttr = cmds.textFieldGrp('attachToSurfaceUAttrTFG', q=True, text=True) vAttr = cmds.textFieldGrp('attachToSurfaceVAttrTFG', q=True, text=True) # Orient orient = cmds.checkBoxGrp('attachToSurfaceOrientCBG', q=True, v1=True) # Orient Options tanU = str.lower(str(cmds.optionMenuGrp('attachToSurfaceUAxisOMG', q=True, v=True))) tanV = str.lower(str(cmds.optionMenuGrp('attachToSurfaceVAxisOMG', q=True, v=True))) align = str.lower(str(cmds.optionMenuGrp('attachToSurfaceAlignToOMG', q=True, v=True))) # Execute command result = glTools.utils.attach.attachToSurface(surface=surf, transform=trans, uValue=uParam, vValue=vParam, useClosestPoint=closePnt, orient=orient, uAxis=tanU, vAxis=tanV, uAttr=uAttr, vAttr=vAttr, alignTo=align, prefix=pre) # Cleanup if close: cmds.deleteUI(window)
def renameHistoryNodesFromUI(): ''' ''' # Get node type and suffix lists nodeType = mc.textFieldGrp('renameHist_nodeTypeTFG',q=True,text=True) nodeSuffix = mc.textFieldGrp('renameHist_nodeSuffixTFG',q=True,text=True) stripSuffix = mc.checkBoxGrp('renameHist_stripSuffixCBG',q=True,v1=True) nodeTypeList = nodeType.split(' ') nodeSuffixList = nodeSuffix.split(' ') if len(nodeTypeList) != len(nodeSuffixList): if nodeSuffixList: raise Exception('Node type and suffix list length mis-match!') # Get scene selection sel = mc.ls(sl=1) # For each object in selection for obj in sel: # For each node type for i in range(len(nodeTypeList)): # Determine suffix nodeSuffix = '' if nodeSuffixList: nodeSuffix = nodeSuffixList[i] # Rename nodes glTools.utils.base.renameHistoryNodes(obj,nodeTypeList[i],suffix=nodeSuffix,stripOldSuffix=stripSuffix)
def refreshUI(): """ """ # Get UI input values blendShape = cmds.textFieldGrp('tdb_blendShapeTFG', q=True, text=True) target1 = cmds.textFieldGrp('tdb_target1TFG', q=True, text=True) target2 = cmds.textFieldGrp('tdb_target1TFG', q=True, text=True) # Update blendShape menu list blendShapeList = cmds.ls(type='blendShape') cmds.popupMenu('tdb_blendShapePUM', e=True, deleteAllItems=True) cmds.setParent('tdb_blendShapePUM', m=True) for item in blendShapeList: cmds.menuItem(label=item, c='cmds.textFieldGrp("tdb_blendShapeTFG",e=True,text="' + item + '");glTools.ui.transformDrivenBlend.refreshUI()') # Check BlendShape if blendShape and cmds.objExists('blendShape') and (cmds.objectType(blendShape) == 'blendShape'): targetList = cmds.listAttr(blendShape + '.w', m=True) cmds.popupMenu('tdb_target1PUM', e=True, deleteAllItems=True) cmds.popupMenu('tdb_target2PUM', e=True, deleteAllItems=True) for target in targetList: targetCon = cmds.listConnections(blendShape + '.' + target, s=True, d=False) if target == target1: targetCon = True if target == target2: targetCon = True cmds.setParent('tdb_target1PUM', m=True) cmds.menuItem(label=target, c='cmds.textFieldGrp("tdb_target1TFG",e=True,text="' + target + '");glTools.ui.transformDrivenBlend.refreshUI()', en=not bool(targetCon)) cmds.setParent('tdb_target2PUM', m=True) cmds.menuItem(label=target, c='cmds.textFieldGrp("tdb_target1TFG",e=True,text="' + target + '");glTools.ui.transformDrivenBlend.refreshUI()', en=not bool(targetCon))
def setTwinMatchAttrsFromUI(): ''' UI method for Pose Match setup tools Setup pose twin attributes from UI ''' # Get selection sel = mc.ls(sl=True,type=['transform','joint']) if not sel: return # Window win = 'matchRulesUI' if not mc.window(win,q=True,ex=True): raise UserInputError('Pose Match UI does not exist!!') # Pivot pivotObj = str(mc.textFieldButtonGrp('matchRulesPivotTFB',q=True,text=True)) # Axis axis = str(mc.optionMenuGrp('matchRulesAxisOMG',q=True,v=True)).lower() # Mode mode = mc.optionMenuGrp('matchRulesModeOMG',q=True,sl=True) - 1 # Search/Replace search = str(mc.textFieldGrp('matchRulesSearchTFG',q=True,text=True)) replace = str(mc.textFieldGrp('matchRulesReplaceTFG',q=True,text=True)) # Set match rules attributes glTools.common.match.Match().setTwinMatchAttrs(sel,pivotObj,axis,mode,search,replace)
def buildSDir03(sDir01, sDir02, currentAssetLibrary=ddConstants.ASSETLIBRARY): '''Build third subdirectory list. ''' tfg = "sDir03TFG" dataList = None if not sDir02 == "---": if currentAssetLibrary == ddConstants.CHAR_ASSETLIBRARY: # characters dataList = ["CPF (full, riggable)", "CPD (dirty, decimated)", "CPO (origami)", "CPS (segmented)"] else: # environments dirPath = os.path.join(currentAssetLibrary, sDir01, sDir02) if sDir02 in ["arc", "dom", "fx", "ter"]: dataList = {} else: dataList = [x for x in (os.listdir(dirPath) or []) if not (x == ".DS_Store") and not x.startswith("_")] dataList.sort() kids = cmds.textFieldGrp(tfg, query=True, popupMenuArray=True) if kids: cmds.deleteUI(kids) menu = cmds.popupMenu('%s_menu' % tfg, parent=tfg) if dataList: defaultLabel = "Select subfolder" if currentAssetLibrary == ddConstants.CHAR_ASSETLIBRARY: defaultLabel = "Select chesspiece type" cmds.menuItem(parent=menu, label=defaultLabel, command=partial(updateSDir03, defaultLabel, currentAssetLibrary)) for data in dataList: cmds.menuItem("%sMI" % data, parent=menu, label=data, command=partial(updateSDir03, data, currentAssetLibrary)) cmds.textFieldGrp(tfg, edit=True, text=defaultLabel) else: cmds.menuItem(parent=menu, label="---", command=partial(updateSDir03, "---", currentAssetLibrary)) cmds.textFieldGrp(tfg, edit=True, text="---")
def _buildRigTypeTFG(self, sel_char): ''' build rig type text field group menu list ''' data_list = None if sel_char != '---': data_list = self.RIG_TYPE_LIST self._clearOutPopupMenu(self._tfg_rig_type) self._tfg_rig_type_popup = mc.popupMenu(parent=self._tfg_rig_type) # setup right click menu items if data_list: # fill with found data items default_label = self.RIG_TYPE_LABEL mc.menuItem(parent=self._tfg_rig_type_popup, label=default_label, command=partial(self._updateRigTypeTFG, default_label)) for data in data_list: # get rig type abreviation for use with menu item name rtype = data.split(' ')[0] mc.menuItem('%sMI' % rtype, parent=self._tfg_rig_type_popup, label=data, command=partial(self._updateRigTypeTFG, data)) mc.textFieldGrp(self._tfg_rig_type, edit=True, text=default_label) else: # setup empty menu default_label = '---' mc.menuItem(parent=self._tfg_rig_type_popup, label=default_label, command=partial(self._updateRigTypeTFG, default_label)) mc.textFieldGrp(self._tfg_rig_type, edit=True, text=default_label)
def ui(): ''' ''' # Window window = 'transformDrivenBlendUI' if mc.window(window,q=True,ex=1): mc.deleteUI(window) window = mc.window(window,t='Transform Driven Blend') # Layout cl = mc.columnLayout() # UI Elements driveAttrTFG = mc.textFieldGrp('tdb_driveAttrTFG',label='Drive Attr', text='') blendShapeTFG = mc.textFieldGrp('tdb_blendShapeTFG',label='BlendShape', text='') target1TFG = mc.textFieldGrp('tdb_target1TFG',label='Target 1', text='',cc='glTools.ui.transformDrivenBlend.refreshUI()') target2TFG = mc.textFieldGrp('tdb_target2TFG',label='Target 2', text='',cc='glTools.ui.transformDrivenBlend.refreshUI()') weight1FFG = mc.floatFieldGrp('tdb_weight1FFG',numberOfFields=1,label='Weight 1',v1=1.0) weight2FFG = mc.floatFieldGrp('tdb_weight2FFG',numberOfFields=1,label='Weight 2',v1=-1.0) overlapFFG = mc.floatFieldGrp('tdb_overlapFFG',numberOfFields=1,label='Overlap',v1=0.0) prefixTFG = mc.textFieldGrp('tdb_prefixTFG',label='Prefix', text='') createB = mc.button('tdb_createB',label='Create',c='glTools.ui.transformDrivenBlend.executeFromUI()') refreshB = mc.button('tdb_refreshB',label='Refresh',c='glTools.ui.transformDrivenBlend.refreshUI()') cancelB = mc.button('tdb_cancelB',label='Cancel',c='mc.deleteUI('+window+')') # Popup Menus mc.popupMenu('tdb_blendShapePUM',p=blendShapeTFG) mc.popupMenu('tdb_target1PUM',p=target1TFG) mc.popupMenu('tdb_target2PUM',p=target2TFG) mc.popupMenu('tdb_driveAttrPUM',p=driveAttrTFG) mc.menuItem(label='Set from selected',c='glTools.ui.utils.loadChannelBoxSel("'+driveAttrTFG+'")') # Show Window refreshUI() mc.showWindow(window)
def csMainWindow(): csWin = "CreateSkeleton" if mc.window(csWin,q=True,ex=True): mc.deleteUI(csWin) mc.window(csWin,title = "Create Skeleton") mc.scrollLayout(horizontalScrollBarThickness=16) csMainCL = mc.columnLayout(columnAttach=("both",5),rowSpacing=10,columnWidth=320) #GUIDES CREATION csFL1 = mc.frameLayout(label="Create Guides",bs="etchedOut",w=300,mw=5,cll=1,p=csMainCL) csCL1= mc.columnLayout(rs=5,adj=1,p=csFL1) #Character Name mc.textFieldGrp("csChName",l="Character Name",tx="") #Number of Fingers/Toes #mc.intSliderGrp("csFingersNumber",label="Number of Fingers",field=True,minValue=1,maxValue=5,fieldMinValue=1,fieldMaxValue=5,value=4,cw3=(100,30,10),dc=csSetFingersNumber) #mc.checkBoxGrp("csHasThumb",numberOfCheckBoxes=1, label='Thumb?') #mc.intSliderGrp("csToesNumber",label="Number of Toes",field=True,minValue=1,maxValue=5,fieldMinValue=1,fieldMaxValue=5,value=4,cw3=(100,30,10),dc=csSetToesNumber) mc.button(l="Create Guides",c=csCreateGuides) #Character Scale Slider mc.floatSliderGrp("csScaleSlider",en=0,label="Guide scale",field=True,minValue=1,maxValue=100,fieldMinValue=1,fieldMaxValue=100,value=1,cw3=(70,30,10),dc=csScaleGuides) #Character Mirror mc.rowColumnLayout(nc=2,cw=[(1,138),(2,138)],p=csCL1); mc.button(l="Mirror left << ",al="right",c = functools.partial(csMirrorGuide,"left")) mc.button(l=">> Mirror right",al="left",c = functools.partial(csMirrorGuide,"right")); #END GUIDES CREATION #JOINTS CREATION csFL2 = mc.frameLayout(label="Create Joints",bs="etchedOut",w=300,mw=5,cll=1,p=csMainCL) csCL2 = mc.columnLayout(rs=5,adj=1,p=csFL2) mc.button(l="Create Joints",c =csCreateJoints) #floatSliderGrp -en 0 -label "THUMB Orient" -field true -minValue 0 -maxValue 180 -fieldMinValue 1 -fieldMaxValue 100 -value 0 -cw3 80 40 10 -dc csJointOrientX csJointXSlider; #END JOINTS CREATION mc.showWindow(csWin)
def _buildCharTypeTFG(self): ''' build character type text field group menu list ''' # check for and clear out any existing popup menu items self._clearOutPopupMenu(self._tfg_char_type) self._tfg_char_type_popup = mc.popupMenu(parent=self._tfg_char_type) ignore_list = list(set(self.IGNORE_LIST + ['old characters', 'reference_misc'])) # collect list of valid character type categories data_list = [x for x in (os.listdir(self.ASSET_LIB) or []) if not x in ignore_list and not x.startswith('_')] data_list.sort() default_label = self.CHAR_TYPE_LABEL # setup right click menu items mc.menuItem(parent=self._tfg_char_type_popup, label=default_label, command=partial(self._updateCharTypeTFG, default_label)) for data in data_list: mc.menuItem('%sMI' % data, parent=self._tfg_char_type_popup, label=data, command=partial(self._updateCharTypeTFG, data)) mc.textFieldGrp(self._tfg_char_type, edit=True, text=default_label)
def setArnoldAttr(*args): selection = cmds.ls(sl=True) selectionShapes = cmds.listRelatives(selection, shapes=True) asset = cmds.textFieldGrp('rename_asset', q=True, text=True) desc = cmds.textFieldGrp('rename_desc', q=True, text=True) category = cmds.textFieldGrp('rename_category', q=True, text=True) removeArnoldAttr() # add attr for sel in selectionShapes: # asset attribute attrname = 'rmanSassetName' selAttr = sel+'.'+attrname cmds.addAttr(sel, ln=attrname, nn='Rman Sasset Name', dt='string') cmds.setAttr(selAttr, asset, type='string') cmds.setAttr(selAttr, e=True, keyable=True) # desc attribute attrname = 'rmanSassetDesc' selAttr = sel+'.'+attrname cmds.addAttr(sel, ln=attrname, nn='Rman Sasset Desc', dt='string') cmds.setAttr(selAttr, desc, type='string') cmds.setAttr(selAttr, e=True, keyable=True) # category attribute attrname = 'rmanSassetCategory' selAttr = sel+'.'+attrname cmds.addAttr(sel, ln=attrname, nn='Rman Sasset Category', dt='string') cmds.setAttr(selAttr, category, type='string') cmds.setAttr(selAttr, e=True, keyable=True) saveSettings()
def saveSettings(*args): """ stuff to save """ counter = cmds.textFieldGrp('rename_counter', q=True, text=True) padding = cmds.textFieldGrp('rename_padding', q=True, text=True) step = cmds.textFieldGrp('rename_step', q=True, text=True) name = cmds.textFieldGrp('rename_nameField', q=True, text=True) namePreview = cmds.textFieldGrp('rename_namePreview', q=True, text=True) searchfor = cmds.textFieldGrp('rename_search', q=True, text=True) replaceby = cmds.textFieldGrp('rename_replace', q=True, text=True) asset = cmds.textFieldGrp('rename_asset', q=True, text=True) desc = cmds.textFieldGrp('rename_desc', q=True, text=True) category = cmds.textFieldGrp('rename_category', q=True, text=True) # save SETTINGS.add('counter', counter) SETTINGS.add('padding', padding) SETTINGS.add('step', step) SETTINGS.add('name', name) SETTINGS.add('namePreview', namePreview) SETTINGS.add('searchfor', searchfor) SETTINGS.add('replaceby', replaceby) SETTINGS.add('asset', asset) SETTINGS.add('desc', desc) SETTINGS.add('category', category)
def attachToMeshFromUI(close=False): ''' Execute attachToMesh() from UI ''' # Window window = 'attachToMeshUI' if not mc.window(window,q=True,ex=1): raise UIError('SnapToSurface UI does not exist!!') # Get UI data mesh = mc.textFieldGrp('attachToMeshTFB',q=True,text=True) # Check surface if not glTools.utils.mesh.isMesh(mesh): raise Exception('Object "'+surface+'" is not a valid nurbs surface!!') # Transform obj = mc.textFieldGrp('attachToMeshTransformTFB',q=True,text=True) # Prefix pre = mc.textFieldGrp('attachToMeshPrefixTFG',q=True,text=True) # Orient orient = mc.checkBoxGrp('attachToMeshOrientCBG',q=True,v1=True) # Orient Options normAx = str.lower(str(mc.optionMenuGrp('attachToMeshNormOMG',q=True,v=True))) tanAx = str.lower(str(mc.optionMenuGrp('attachToMeshTanOMG',q=True,v=True))) # Execute command glTools.utils.attach.attachToMesh(mesh=mesh,transform=obj,useClosestPoint=True,orient=orient,normAxis=normAx,tangentAxis=tanAx,prefix=pre) # Cleanup if close: mc.deleteUI(window)
def stretchyIkSplineFromUI(close=False): ''' ''' # Window window = 'stretchyIkSplineUI' if not mc.window(window,q=True,ex=1): raise UIError('StretchyIkSpline UI does not exist!!') # Get UI data ik = mc.textFieldButtonGrp('stretchyIkSplineTFB',q=True,text=True) pre = mc.textFieldGrp('stretchyIkSplinePrefixTFG',q=True,text=True) scaleAxis = str.lower(str(mc.optionMenuGrp('stretchyIkSplineAxisOMG',q=True,v=True))) scaleAttr = mc.textFieldButtonGrp('stretchyIkSplineScaleAttrTFB',q=True,text=True) blendCtrl = mc.textFieldButtonGrp('stretchyIkSplineBlendCtrlTFB',q=True,text=True) blendAttr = mc.textFieldGrp('stretchyIkSplineBlendAttrTFG',q=True,text=True) method = mc.optionMenuGrp('stretchyIkSplineMethodOMG',q=True,sl=True)-1 minPercent = mc.floatSliderGrp('stretchyIkSplineMinPFSG',q=True,v=True) maxPercent = mc.floatSliderGrp('stretchyIkSplineMaxPFSG',q=True,v=True) # Execute command if method: # Parametric glTools.builder.stretchyIkSpline_parametric.StretchyIkSpline_parametric().build(ikHandle=ik,scaleAttr=scaleAttr,blendControl=blendCtrl,blendAttr=blendAttr,scaleAxis=scaleAxis,minPercent=minPercent,maxPercent=maxPercent,prefix=pre) else: # Arc Length glTools.builder.stretchyIkSpline_arcLength.StretchyIkSpline_arcLength().build(ikHandle=ik,scaleAttr=scaleAttr,blendControl=blendCtrl,blendAttr=blendAttr,scaleAxis=scaleAxis,prefix=pre) # Cleanup if close: mc.deleteUI(window)
def bdMainWindow(): bdWin = "CreateSkeleton" if cmds.window(bdWin,q=True,ex=True): cmds.deleteUI(bdWin) cmds.window(bdWin,title = "Create Skeleton") cmds.scrollLayout(horizontalScrollBarThickness=16) bdMainCL = cmds.columnLayout(columnAttach=("both",5),rowSpacing=10,columnWidth=320) #GUIDES CREATION bdFL1 = cmds.frameLayout(label="Template Guides",bs="etchedOut",w=300,mw=5,cll=1,p=bdMainCL) bdCL1= cmds.columnLayout(rs=5,adj=1,p=bdFL1) #Character Name cmds.textFieldGrp("bdChName",l="Character Name",tx="") #Number of Fingers/Toes #cmds.intSliderGrp("bdFingersNumber",label="Number of Fingers",field=True,minValue=1,maxValue=5,fieldMinValue=1,fieldMaxValue=5,value=4,cw3=(100,30,10),dc=bdSetFingersNumber) #cmds.checkBoxGrp("bdHasThumb",numberOfCheckBoxes=1, label='Thumb?') #cmds.intSliderGrp("bdToesNumber",label="Number of Toes",field=True,minValue=1,maxValue=5,fieldMinValue=1,fieldMaxValue=5,value=4,cw3=(100,30,10),dc=bdSetToesNumber) cmds.button(l="Import Template",c=bdImportTemplate) #Character Scale Slider cmds.floatSliderGrp("bdScaleSlider",en=0,label="Guide scale",field=True,minValue=1,maxValue=100,fieldMinValue=1,fieldMaxValue=100,value=1,cw3=(70,30,10),dc=bdScaleGuides) #Character Mirror cmds.rowColumnLayout(nc=2,cw=[(1,138),(2,138)],p=bdCL1); cmds.button(l="Mirror left << ",al="right",c = functools.partial(bdMirrorGuide,"left")) cmds.button(l=">> Mirror right",al="left",c = functools.partial(bdMirrorGuide,"right")); #END GUIDES CREATION #JOINTS CREATION bdFL2 = cmds.frameLayout(label="Create Joints",bs="etchedOut",w=300,mw=5,cll=1,p=bdMainCL) bdCL2 = cmds.columnLayout(rs=5,adj=1,p=bdFL2) cmds.button(l="Create Joints",c =bdCreateSkeleton) #floatSliderGrp -en 0 -label "THUMB Orient" -field true -minValue 0 -maxValue 180 -fieldMinValue 1 -fieldMaxValue 100 -value 0 -cw3 80 40 10 -dc bdJointOrientX bdJointXSlider; #END JOINTS CREATION cmds.showWindow(bdWin)
def mirrorClusterCmd(self): """""" sels = cmds.ls(sl=1, ap=1) if not sels: cmds.error("Please select clusters or joints!") # Prepare parameters axisBtn = cmds.radioCollection(self.axisCol, q=1, sl=1) axisId = cmds.radioButton(axisBtn, q=1, l=1).lower() axises = scData.getAxisMap(axisId) mirrorPivot = cmds.textField(self.mirPivTxFld, q=1, tx=1) tol = float(cmds.textFieldGrp(self.tolTxFld, q=1, tx=1)) search = cmds.textFieldGrp(self.searchTxFld, q=1, tx=1) replace = cmds.textFieldGrp(self.replaceTxFld, q=1, tx=1) # Deal with mirror pivot matrix if mirrorPivot: pivotMatrixList = cmds.xform(mirrorPivot, q=1, ws=1, m=1) else: pivotMatrixList = scData.getWorldMatrixList() start = clock() for sel in sels: if cmds.objectType( sel, isType='joint' ): scData.JointFn.mirrorJnt(sel, pivotMatrixList, axises, search, replace, tol) elif cmds.listRelatives(sel, s=1, typ='clusterHandle'): scData.ClusterFn.mirrorCluster(sel, pivotMatrixList, axises, search, replace, tol) else: cmds.warning("%s is skipped!" % sel) finish = clock() om.MGlobal.displayInfo( "Mirror Time Cost: %fs" % (finish-start) )
def editItem(*args): """ first edit the item in the edit/remove UI then edit the item in the shelf and last edit the item in the settings file """ # get edited item values itemName = cmds.textFieldGrp('edit_customname', q=True, text=True) itemCommand = cmds.textFieldGrp('edit_customCommand', q=True, text=True) value = cmds.radioButtonGrp('edit_customSourceRadioButton', q=True, select=True) if not itemName or not itemCommand or not value: raise UserWarning('You need to fill all the fields!') if value == 1: sourceType = 'python' else: sourceType = 'mel' itemFull = itemName+' - '+itemCommand+' - '+sourceType # delete the edit item window cmds.deleteUI('edit_customEditItem', window=True) # delete the old scrollList entry and insert the new one at the same place scrollItemSelected = cmds.textScrollList('item_list', q=True, si=True)[0] scrollItemIndex = cmds.textScrollList('item_list', q=True, sii=True)[0] cmds.textScrollList('item_list', e=True, ri=scrollItemSelected) cmds.textScrollList('item_list', e=True, appendPosition=[scrollItemIndex, itemFull], doubleClickCommand=editItemUI) # get the path of the shelf item to edit for item in SETTINGS.getAll(): if item.values()[0][0] == scrollItemSelected.split(' - ')[0]: menuItemPath = item.keys()[0] cmds.menuItem(menuItemPath, e=True, label=itemName, command=itemCommand, sourceType=sourceType) SETTINGS.add(menuItemPath, [itemName, itemCommand, sourceType])
def extendUI(*args): """UI for the script""" #UI if cmds.window("curbWin", exists=True): cmds.deleteUI("curbWin") cmds.window("curbWin", t="zbw_polyExtender", w=200, h=200) cmds.columnLayout("colLO") cmds.frameLayout("topFrame", l="Covert Edge", cll=True, bgc=(.2,.2,.2)) cmds.text("Select poly edge to convert") cmds.button("convertBut", l="Convert!", w=200, h=30, bgc=(.8, .8,.6), c=convertEdge) cmds.separator(h=5) cmds.setParent("colLO") cmds.frameLayout("midFrame", l="Create Poly", cll=True, bgc=(.2,.2,.2)) cmds.text("Select curve") cmds.separator(h=5) cmds.textFieldGrp("name", l="Name", w=200, cw=[(1,30), (2,170)], tx="newPoly") cmds.checkBox("curbCB", l="Positive Direction", v=True) # cmds.checkBox("bumpCB", l="Add vertical hump?", v=True) cmds.floatFieldGrp("curbFFG", l="Curb Width", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=10) cmds.intFieldGrp("UDivIFG", l="Width Subdivisions", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=1) cmds.intFieldGrp("VDivIFG", l="Length Subdivisions", cal=((1, "left"),(2,"left")), cw=([1,75],[2,50]), v1=1) cmds.checkBox("polyHistory", l="Keep history on final poly?", v=False) cmds.checkBox("history", l="Keep history objects?", v=True, cc=enableHistory) cmds.separator(h=5) cmds.button("curbBut", l="Create Curb", h=40, w=200, bgc=(.6, .8, .6), c=extendPoly) cmds.showWindow("curbWin") cmds.window("curbWin", e=True, h=150, w=200)
def import2dTrackUI(): """ """ # Build UI Window window = 'import2dTrackUI' if cmds.window(window, q=True, ex=True): cmds.deleteUI(window) window = cmds.window(window, title='Import 2D Track', wh=[500, 350]) # Build UI Elements cmds.columnLayout(adjustableColumn=True) perspCamListTSL = cmds.textScrollList('importTrack_camListTSL', numberOfRows=8, ams=False) fileTFB = cmds.textFieldButtonGrp('importTrack_fileTFB', label='2D Track File', buttonLabel='Browse') cmds.textFieldButtonGrp(fileTFB, e=True, bc='glTools.ui.utils.loadFilePath("' + fileTFB + '",fileFilter="*.*")') cmds.textFieldGrp('importTrack_nameTFG', label="Point Name", text='trackPoint1') cmds.floatFieldGrp('importTrack_widthFFG', numberOfFields=1, label='Source Pixel Width', value1=2348) cmds.floatFieldGrp('importTrack_heightFFG', numberOfFields=1, label='Source Pixel Height', value1=1566) cmds.button(label='Import Track', c='import glTools.tools.import2dTrack;reload(glTools.tools.import2dTrack);glTools.tools.import2dTrack.import2dTrack()') cmds.button(label='Close', c='cmds.deleteUI("' + window + '")') # Build Camera List camList = cmds.listCameras(p=True) for cam in camList: cmds.textScrollList(perspCamListTSL, e=True, a=cam) # Show Window cmds.showWindow(window)
def create(self): if cmds.window( self.winName, ex=1 ): cmds.deleteUI( self.winName, wnd=1 ) cmds.window( self.winName, title= self.title ) cmds.columnLayout() columnWidth = self.width - 2 firstWidth = ( columnWidth -2 )* 0.23 secondWidth = ( columnWidth -2 ) - firstWidth cmds.rowColumnLayout( nc=1, cw=[(1,columnWidth)] ) cmds.text( l='', h=5 ) fd_cutName = cmds.textFieldGrp( l='Cut Path : ', cw=[(1,firstWidth),(2,secondWidth)], cc=self.cmdChangeCutName ) pu_cutName = cmds.popupMenu() cmds.text( l='', h=5 ) cmds.separator() cmds.text( l='', h=5 ) fd_sceneName = cmds.textFieldGrp( l='Scene Path : ', cw=[(1,firstWidth),(2,secondWidth)], cc=self.cmdChangeSceneName ) pu_sceneName = cmds.popupMenu() cmds.window( self.winName, e=1, w = self.width, h = self.height ) cmds.showWindow( self.winName ) self.fd_cutName = fd_cutName self.pu_cutName = pu_cutName
def ren_gui(*ars): gui = 'ren_gui' if cmds.window(gui, q=1, ex=1): cmds.deleteUI(gui) cmds.window(gui,t="Render Layer name changer v1.0") cmds.columnLayout(adjustableColumn = True) cmds.button("Select Render Layer", bgc=(.3,.1,.1), h = 25,c=ren_gui) rl = cmds.ls(typ="renderLayer") rls = filter (lambda x:x !="defaultRenderLayer", rl) cmds.rowColumnLayout(numberOfColumns = 2) cmds.textScrollList('rl_list', append=rls, ams=False, sc=img_name) cmds.textScrollList('img_list', append="", ams=False) cmds.setParent("..") cmds.button('bCh', label="RENDER LAYER RENAME", bgc=(0.5,0.7,0.9), c=ch_name) cmds.textFieldGrp('ch_name', label="Input new name:",cal=(1,"left") ,cw=(1,95)) cmds.textFieldGrp('ch_fname', label="Img name suffix:",cal=(1,"left") ,cw=(1,95)) cmds.window(gui, e=1, width=360, height = 120) cmds.showWindow(gui)
def Bind(): charName = cmds.textFieldGrp(NameInput, q=True, text=True) cmds.select(charName + '_Joints_01', hi=True) # if charName+'_Geo_01' null print 'put your model in Main>Geo group' cmds.select(charName + '_Geo_01', hi=True, add=True) cmds.bindSkin()
def main(cls, *args): srcDrvrs = cmds.textScrollList(UI.widgets['srcDrvrObjTxtScrList'], q=True, selectItem=True) spcfSrcDrvn = cmds.textFieldButtonGrp( UI.widgets['srcDrvnObjTxtFldBtnGrp'], q=True, text=True) spcfTrgDrvr = cmds.textFieldButtonGrp( UI.widgets['trgDrvrObjTxtFldBtnGrp'], q=True, text=True) spcfTrgDrvn = cmds.textFieldButtonGrp( UI.widgets['trgDrvnObjTxtFldBtnGrp'], q=True, text=True) drvrObjSrch = cmds.textFieldGrp(UI.widgets['drvrObjSrchTxtFldGrp'], q=True, text=True) drvrObjRplc = cmds.textFieldGrp(UI.widgets['drvrObjRplcTxtFldGrp'], q=True, text=True) drvrAttrSrch = cmds.textFieldGrp(UI.widgets['drvrAttrSrchTxtFldGrp'], q=True, text=True) drvrAttrRplc = cmds.textFieldGrp(UI.widgets['drvrAttrRplcTxtFldGrp'], q=True, text=True) drvnObjSrch = cmds.textFieldGrp(UI.widgets['drvnObjSrchTxtFldGrp'], q=True, text=True) drvnObjRplc = cmds.textFieldGrp(UI.widgets['drvnObjRplcTxtFldGrp'], q=True, text=True) drvnAttrSrch = cmds.textFieldGrp(UI.widgets['drvnAttrSrchTxtFldGrp'], q=True, text=True) drvnAttrRplc = cmds.textFieldGrp(UI.widgets['drvnAttrRplcTxtFldGrp'], q=True, text=True) trnsMirXOpt = cmds.checkBoxGrp(UI.widgets['trnsMirChkBoxGrp'], q=True, value1=True) trnsMirYOpt = cmds.checkBoxGrp(UI.widgets['trnsMirChkBoxGrp'], q=True, value2=True) trnsMirZOpt = cmds.checkBoxGrp(UI.widgets['trnsMirChkBoxGrp'], q=True, value3=True) rotateMirXOpt = cmds.checkBoxGrp(UI.widgets['rotateMirChkBoxGrp'], q=True, value1=True) rotateMirYOpt = cmds.checkBoxGrp(UI.widgets['rotateMirChkBoxGrp'], q=True, value2=True) rotateMirZOpt = cmds.checkBoxGrp(UI.widgets['rotateMirChkBoxGrp'], q=True, value3=True) mirBhvrOpt = cmds.checkBox(UI.widgets['mirBhvrChkBoxGrp'], q=True, value=True) copyBhvrOpt = cmds.checkBox(UI.widgets['copyBhvrChkBoxGrp'], q=True, value=True) trnsMirXVal = 1 trnsMirYVal = 1 trnsMirZVal = 1 if trnsMirXOpt: trnsMirXVal = -1 if trnsMirYOpt: trnsMirYVal = -1 if trnsMirZOpt: trnsMirZVal = -1 rotateMirXVal = 1 rotateMirYVal = 1 rotaeMirZVal = 1 if rotateMirXOpt: rotateMirXVal = -1 if rotateMirYOpt: rotateMirYVal = -1 if rotateMirZOpt: rotaeMirZVal = -1 # Get diver and driven object and attributes. drvrAttrList = cmds.textScrollList(UI.widgets['srcDrvrAttrTxtScrList'], q=True, selectItem=True) for srcDrvr in srcDrvrs: for drvrAttr in drvrAttrList: animCrvNodes = cmds.listConnections('%s.%s' % (srcDrvr, drvrAttr), scn=True, d=True, s=False) # print 'Animation curve nodes are %s' %animCrvNodes if animCrvNodes: for animNode in animCrvNodes: print 'Animation Node is %s' % animNode conNodes = cmds.listConnections(animNode, scn=True, d=True, s=False) if not conNodes: continue # Process for conected nodes on animation curve node to find target driven object and attributes. if len(conNodes) == 1 and 'hyperLayout' in str( conNodes): continue # Remove 'hyperLaout' node in conNodes conNodes = cls.rmvHpLoInLs(conNodes) for node in conNodes: print '%s is connected to %s' % (node, animNode) if cmds.objectType(node) == 'blendWeighted': dNodes = cmds.listConnections( node, scn=True, d=True, s=False, plugs=True) # Destination nodes # When blendWeighted nodes destination is multiple. if len(dNodes) > 1: srcDrvn = cls.rmvHpLoInLs(dNodes)[0].split( '.')[0] drvnAttr = cls.rmvHpLoInLs( dNodes)[0].split('.')[-1] else: srcDrvn = cmds.listConnections( node, scn=True, d=True, s=False, plugs=True)[0].split('.')[0] drvnAttr = cmds.listConnections( node, scn=True, d=True, s=False, plugs=True)[0].split('.')[-1] elif cmds.objectType(node) == 'transform': srcDrvn = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True, type='transform')[0].split('.')[0] drvnAttr = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True, type='transform')[0].split('.')[-1] elif cmds.objectType(node) == 'blendShape': srcDrvn = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True)[0].split('.')[0] drvnAttr = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True)[0].split('.')[-1] elif cmds.objectType(node) == 'parentConstraint': srcDrvn = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True, type='parentConstraint')[0].split('.')[0] drvnAttr = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True, type='parentConstraint')[0].split('.')[-1] elif cmds.objectType(node) == 'joint': srcDrvn = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True, type='joint')[0].split('.')[0] drvnAttr = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True, type='joint')[0].split('.')[-1] else: srcDrvn = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True)[0].split('.')[0] drvnAttr = cmds.listConnections( animNode, scn=True, d=True, s=False, plugs=True)[0].split('.')[-1] # If specific source driven object exists, process for only specific source driven object. if spcfSrcDrvn and not spcfSrcDrvn in srcDrvn: continue # Search and replace string to define target objects automatically. if drvrObjSrch: trgDrvr = re.sub(drvrObjSrch, drvrObjRplc, srcDrvr) if drvrAttrSrch: drvrAttr = re.sub(drvrAttrSrch, drvrAttrRplc, drvrAttr) if drvnObjSrch: trgDrvn = re.sub(drvnObjSrch, drvnObjRplc, srcDrvn) # When there is no target driven object skip to the next animCurve. if srcDrvn == trgDrvn: continue if drvnAttrSrch: drvnAttr = re.sub(drvnAttrSrch, drvnAttrRplc, drvnAttr) # If specific target object exists, replace target objects. if spcfTrgDrvn: trgDrvn = spcfTrgDrvn if spcfTrgDrvr: trgDrvr = spcfTrgDrvr # Get driver and driven value with animation curve node. drvrVals = cmds.keyframe(animNode, q=True, fc=True) drvnVals = cmds.keyframe(animNode, q=True, vc=True) print '%s.%s' % (trgDrvr, drvrAttr), drvrVals, '%s.%s' % ( trgDrvn, drvnAttr), drvnVals for i in xrange(len(drvrVals)): drvrVal = drvrVals[i] drvnVal = drvnVals[i] # Set driven key with origianl value. print '%s.%s' % (trgDrvr, drvrAttr), drvrVal, '%s.%s' % ( trgDrvn, drvnAttr), drvnVal if 'scale' in drvnAttr: cmds.setDrivenKeyframe( '%s.%s' % (trgDrvn, drvnAttr), cd='%s.%s' % (trgDrvr, drvrAttr), dv=drvrVal, v=drvnVal) continue if 'translateX' in drvnAttr: drvnVal = drvnVals[i] * trnsMirXVal if 'translateY' in drvnAttr: drvnVal = drvnVals[i] * trnsMirYVal if 'translateZ' in drvnAttr: drvnVal = drvnVals[i] * trnsMirZVal if 'rotateX' in drvnAttr: drvnVal = drvnVals[i] * rotateMirXVal if 'rotateY' in drvnAttr: drvnVal = drvnVals[i] * rotateMirYVal if 'rotateZ' in drvnAttr: drvnVal = drvnVals[i] * rotaeMirZVal cmds.setDrivenKeyframe( '%s.%s' % (trgDrvn, drvnAttr), cd='%s.%s' % (trgDrvr, drvrAttr), dv=drvrVal, v=drvnVal) # Set driven key with mirrored value. print '%s.%s' % (trgDrvr, drvrAttr), drvrVal, '%s.%s' % ( trgDrvn, drvnAttr), drvnVal
def optionsWindow(): """This function creates an options window for the am_hipConstraint command. When executing it, first select the hip to which you are constraining, then add the object to be constrained to your selection.""" # create the main interface if cmds.window(kConstraintOptionsWindow, q=True, ex=True): cmds.deleteUI(kConstraintOptionsWindow) mainWindow = cmds.window(kConstraintOptionsWindow, title='%s Options' % kToolName, menuBar=True, wh=(545, 350)) # build the menu bar cmds.menu(label='Help') amui.helpMenuItem(kToolName, __file__) amui.aboutMenuItem(kToolName, kVersionNumber, kVersionDate) mainForm = cmds.formLayout(nd=100) # build the section to get information for the hip constraint mainFrame = cmds.formLayout(nd=100) # attempt to guess what the pelvis is if there is a selection when the GUI is created pelvisText = 'CenterRoot' sel = cmds.ls(sl=True, l=True, type='transform') if sel and len( sel ) > 0: # BUG: in Maya 8.5, a selection of length 0 returns None rather than an empty list try: pelvis = cmds.listRelatives( sel[0], p=True, f=True ) # the hip should be the first object in the selection list pelvisText = pelvis[0] except: pass if_pelvis = cmds.textFieldGrp(label='Pelvis Object:', tx=pelvisText) if_hipAimAxis = cmds.floatFieldGrp(v1=1, v2=0, v3=0, nf=3, pre=4, label='Hip Aim Axis:') if_hipFrontAxis = cmds.floatFieldGrp(v1=0, v2=0, v3=1, nf=3, pre=4, label='Hip Front Axis:') if_pelvisAimAxis = cmds.floatFieldGrp(v1=0, v2=1, v3=0, nf=3, pre=4, label='Pelvis Aim Axis:') if_pelvisFrontAxis = cmds.floatFieldGrp(v1=0, v2=0, v3=1, nf=3, pre=4, label='Pelvis Front Axis:') # position the input fields for the hip constraint cmds.formLayout(mainFrame, edit=True, attachForm=[(if_pelvis, 'left', 30), (if_pelvis, 'top', 5)], attachNone=[(if_pelvis, 'right'), (if_pelvis, 'bottom')]) cmds.formLayout(mainFrame, edit=True, attachForm=[(if_hipAimAxis, 'left', 30)], attachNone=[(if_hipAimAxis, 'right'), (if_hipAimAxis, 'bottom')], attachControl=[(if_hipAimAxis, 'top', 5, if_pelvis)]) cmds.formLayout(mainFrame, edit=True, attachForm=[(if_hipFrontAxis, 'left', 30)], attachNone=[(if_hipFrontAxis, 'right'), (if_hipFrontAxis, 'bottom')], attachControl=[(if_hipFrontAxis, 'top', 5, if_hipAimAxis)]) cmds.formLayout(mainFrame, edit=True, attachForm=[(if_pelvisAimAxis, 'left', 30)], attachNone=[(if_pelvisAimAxis, 'right'), (if_pelvisAimAxis, 'bottom')], attachControl=[(if_pelvisAimAxis, 'top', 5, if_hipFrontAxis)]) cmds.formLayout(mainFrame, edit=True, attachForm=[(if_pelvisFrontAxis, 'left', 30)], attachNone=[(if_pelvisFrontAxis, 'right'), (if_pelvisFrontAxis, 'bottom')], attachControl=[(if_pelvisFrontAxis, 'top', 5, if_pelvisAimAxis)]) cmds.setParent('..') # go up to mainFrame # create the buttons to execute the hcript cmd_create = 'amTools.rigging.hipConstraint.doOptions (\"%s\", \"%s\", \"%s\", \"%s\", \"%s\")' % ( if_pelvis, if_hipAimAxis, if_hipFrontAxis, if_pelvisAimAxis, if_pelvisFrontAxis) utils.ui.threeButtonLayout(mainForm, mainWindow, cmd_create) cmds.showWindow(mainWindow)
def setupControl(self,*args): #Load variables name = cmds.textFieldGrp(self.nameField,q=True,text=True) control = cmds.textFieldButtonGrp(self.controlField,q=True,text=True) rivet = cmds.textFieldButtonGrp(self.rivetField,q=True,text=True) constObj = cmds.textFieldButtonGrp(self.jointField,q=True,text=True) #Load selection verts = cmds.ls(sl=True,fl=True) #Create Cluster clusterName,clusterHandle = cmds.cluster(rel=True,n=name+'_clstr') #Delete Rivet's aim constraint because it causes flipping if the rivets lofted nurbs plane flips. #Add parent constraint to object.(constObj) """ try: temp = cmds.listConnections(rivet) cmds.delete(temp[1]) except: # No constraint to delete on rivet pass """ #Rivet WS location rivetLocation = cmds.xform(rivet,q=True,ws=True,t=True) #Snap Cluster pivots to rivetLocation self.move(clusterHandle, rivetLocation,t=False,sp=True,rp=True) #Snap Controls pivots to rivetLocation self.move(control, rivetLocation,t=False,sp=True,rp=True) #Group Cluster clusterGrp = cmds.group(clusterHandle) clusterGrp = cmds.rename(clusterGrp, name + 'Cluster_' + clusterHandle) #Create over ride group or_grp = cmds.group(em=True,name=name+"OR1") or2_grp = cmds.group(em=True,name=name+"OR2") #Parent override group to rivet cmds.parent(or_grp,or2_grp) cmds.parent(or2_grp,rivet) #Freeze transforms on override group cmds.makeIdentity(or_grp,apply=True,t=True,r=True,s=True,n=True) #Zero Control zeroNode = cmds.group(em=True,n=name + "nullGrp") pos = cmds.xform( control, q=1, ws=True, t=1) cmds.xform( zeroNode, ws=True, t=[pos[0], pos[1], pos[2]]) rot = cmds.xform( control, q=1, ws=True, ro=1) cmds.xform( zeroNode, ws=True, ro=[rot[0], rot[1], rot[2]]) scale = cmds.xform( control, q=1, r=1, s=1) cmds.xform( zeroNode, ws=True, s=[scale[0], scale[1], scale[2]]) #Snap zeroNode pivot to control controlLocation = cmds.xform(control,q=True,ws=True,rp=True) self.move(zeroNode, controlLocation, t=False, sp=True, rp=True) #parent control to OverRide group cmds.parent(control, zeroNode, a=True) cmds.parent(zeroNode,or_grp) #Connect control t,r,s to cluster, then hide the cluster and rivet group cmds.connectAttr(control + ".translate", clusterHandle + ".translate") cmds.connectAttr(control + ".rotate", clusterHandle + ".rotate") cmds.connectAttr(control + ".scale", clusterHandle + ".scale") #Create utility node and negate double transform #by reversing the transformation of or_grp <---- Cause of double transforms mdNode = cmds.createNode("multiplyDivide") nodeName = name + "_MD" cmds.rename(mdNode,nodeName) mdNode = nodeName #Unparent control cmds.parent(zeroNode,w=True) #Set up the MD node cmds.setAttr( "%s.input2X"%mdNode, -1) cmds.setAttr( "%s.input2Y"%mdNode, -1) cmds.setAttr( "%s.input2Z"%mdNode, -1) #Connect the nodes # control ---> mdNode cmds.connectAttr("%s.translateX"%control,"%s.input1X"%mdNode,f=True) cmds.connectAttr("%s.translateY"%control,"%s.input1Y"%mdNode,f=True) cmds.connectAttr("%s.translateZ"%control,"%s.input1Z"%mdNode,f=True) #mdNode ---> or_grp cmds.connectAttr("%s.outputX"%mdNode,"%s.translateX"%or_grp,f=True) cmds.connectAttr("%s.outputY"%mdNode,"%s.translateY"%or_grp,f=True) cmds.connectAttr("%s.outputZ"%mdNode,"%s.translateZ"%or_grp,f=True) #Reparent control cmds.parent(zeroNode,or_grp) #Get mesh name # ex. "meshName.vtx[35]" mesh = verts[0].split('.')[0] #Get meshDeformer meshDeformer = None try: meshDeformer = mel.eval('findRelatedSkinCluster("%s");'%mesh) except: pass """ history = cmds.listHistory(mesh) for each in history: #print " History: " + each if("skinCluster" in str(each)): #Possible match for meshDeformer if("Group" not in str(each)): meshDeformer = each if("cMuscleSystem" in str(each)): if("Group" not in str(each)): meshDeformer = each """ #Reorder deformer nodes if meshDeformer: #Move cluster + meshDeformer to top of deformer stack cmds.reorderDeformers(clusterHandle,meshDeformer,mesh) #Move meshDeformer to top of deformer stack cmds.reorderDeformers(meshDeformer,clusterHandle,mesh) #Create final group topGrp = cmds.group(em=True,name=name+"_followCnt_grp") cmds.parent(clusterGrp,rivet,topGrp) #Orient constrain rivet to constrain object if constObj: cmds.orientConstraint(constObj,rivet,mo=True) #Hide cluster grp cmds.setAttr(clusterGrp + ".visibility",0) #Hide the rivet rivetShape = cmds.listRelatives(rivet,shapes=True) cmds.setAttr(rivetShape[0] + ".visibility",0) # Add cluster atttribute to control cmds.addAttr(control,ln='cluster',min=0.0,max=1.0,dv=1.0) cmds.setAttr('%s.cluster'%control,l=False,k=True) # Connect it to the deformer cmds.connectAttr('%s.cluster'%control,'%s.envelope'%clusterName,f=True) #Clear selection cmds.select(clear=True)
def shotStage(self, *args): stageCheck = cmds.textFieldGrp(self.stageCheck, query=True, tx=True) sSelectedNodes = cmds.selectedNodes() print stageCheck
def buildUI(self): fileName = 'capture' adj = 10 if cmds.objExists(self.camName): cmds.setAttr((self.camName + ".farClipPlane"), k=True) cmds.setAttr((self.camName + ".nearClipPlane"), k=True) cmds.select(clear=True) if cmds.window('User Viewer', query=True, exists=True): cmds.deleteUI('User Viewer') renderViewID = cmds.window('User Viewer', s=True, t='User Viewer' + ': ' + self.camName.split('Shape')[0]) masterLayout = cmds.columnLayout(adj=True) viewer = cmds.paneLayout(w=self.W, h=self.H) self.panel = cmds.modelPanel(mbv=0, label="Custom Viewer", cam=self.camName) tempLayout = cmds.modelPanel(self.panel, q=1, bl=True) cmds.modelEditor(self.panel, e=True, grid=0, da="smoothShaded") cmds.modelEditor(self.panel, e=True, allObjects=1, nurbsSurfaces=1, polymeshes=1, subdivSurfaces=1, nurbsCurves=1, cv=1, hulls=1, planes=1, cameras=1, imagePlane=1, joints=0, ikHandles=0, deformers=1, dynamics=0, fluids=1, hairSystems=1, follicles=1, nCloths=1, nParticles=1, nRigids=1, dynamicConstraints=1, locators=1, dimensions=1, pivots=1, handles=1, textures=1, strokes=1, motionTrails=1, pluginShapes=1, clipGhosts=1, greasePencils=1, manipulators=1, hud=1) cmds.setParent(masterLayout) self.bts.makeSeparator(h=5, w=self.W) nc = 15 cmds.rowColumnLayout(nc=nc, cw=self.bts.cwE(nc=nc, w=self.W, adj=adj), h=25) cmds.checkBox(label="Grid", v=False, onc=(partial(self.changeSetting, 'grid', 1)), ofc=(partial(self.changeSetting, 'grid', 0))) cmds.checkBox(label="Nurbs", align="left", v=True, onc=(partial(self.changeSetting, 'nurbsSurfaces', 1)), ofc=(partial(self.changeSetting, 'nurbsSurfaces', 0))) cmds.checkBox(label="Polys", align="left", v=True, onc=(partial(self.changeSetting, 'polymeshes', 1)), ofc=(partial(self.changeSetting, 'polymeshes', 0))) cmds.checkBox(label="Curves", align="left", v=True, onc=(partial(self.changeSetting, 'nurbsCurves', 1)), ofc=(partial(self.changeSetting, 'nurbsCurves', 0))) cmds.checkBox(label="Joints", align="left", v=False, onc=(partial(self.changeSetting, 'joints', 1)), ofc=(partial(self.changeSetting, 'joints', 0))) cmds.checkBox(label="HUD", align="left", v=True, onc=(partial(self.changeSetting, 'hud', 1)), ofc=(partial(self.changeSetting, 'hud', 0))) cmds.checkBox(label="Viewport2", align="left", v=True, onc=(partial(self.changeSetting, 'rnm', 'vp2Renderer')), ofc=(partial(self.changeSetting, 'rnm', 'base_OpenGL_Renderer'))) focalLst = [12, 20, 27, 35, 45, 50, 80, 100, 125] cmds.optionMenu("RS_lensOpt", label="Lens", w=80) for i in focalLst: cmds.menuItem(l=str(i)) cmds.optionMenu("RS_lensOpt", edit=True, v="35") cmds.setAttr((self.camName + ".focalLength"), 35) cmds.optionMenu("RS_lensOpt", edit=True, cc=self.setFocallength) cmds.setParent(masterLayout) self.bts.makeSeparator(h=5, w=self.W) nc = 4 mainSetting = cmds.rowColumnLayout(nc=nc, cw=self.bts.cwE(nc=nc, w=self.W, adj=adj)) cmds.columnLayout(adj=True) cmds.frameLayout(bv=True, lv=False) self.seqNumber = cmds.intFieldGrp(l='Sequence Number') self.shotNumber = cmds.intFieldGrp(l='Shot Number') self.stageCheck = cmds.textFieldGrp(l='Shot Stage', tx='') nc = 2 cmds.rowColumnLayout(nc=nc, cw=self.bts.cwE(nc=nc, w=(self.W - adj) / 4, adj=adj / 2)) self.bts.makeAcoolButton('Create Shot Display', 'Create Shot Display', self.shotHUD) self.bts.makeAcoolButton('Delete Shot Display', 'Delete', self.delHUD) cmds.setParent(mainSetting) cmds.columnLayout(adj=True) cmds.frameLayout(bv=True, lv=False) cmds.optionMenu('ActiveCam', l='Camera', w=80) for cam in self.camLst: if cmds.objExists(cam): print cam for i in self.camLst: cmds.menuItem(l=str(i)) cmds.optionMenu('ActiveCam', edit=True, cc=self.changeActiveCamera) cmds.setParent(mainSetting) cmds.setParent(masterLayout) self.bts.makeSeparator(h=5, w=self.W) self.bts.makeAcoolButton('Capture this frame', "Capture", partial(self.captureImage, fileName)) cmds.control(tempLayout, e=1, visible=False) cmds.showWindow(renderViewID) logger.info(renderViewID)
def Anim(): charName = cmds.textFieldGrp(NameInput, q=True, text=True) SetKeyAnimation(charName + '_Chest_Ctrl_01', 7, 'translateX', -8) SetKeyAnimation(charName + '_Chest_Ctrl_01', 19, 'translateX', 8) SetKeyAnimation(charName + '_Chest_Ctrl_01', 31, 'translateX', -8) SetKeyAnimation(charName + '_Chest_Ctrl_01', 1, 'translateZ', 0) SetKeyAnimation(charName + '_Chest_Ctrl_01', 13, 'translateZ', 5) SetKeyAnimation(charName + '_Chest_Ctrl_01', 25, 'translateZ', 0) SetKeyAnimation(charName + '_Chest_Ctrl_01', 1, 'rotateY', -5) SetKeyAnimation(charName + '_Chest_Ctrl_01', 13, 'rotateY', 5) SetKeyAnimation(charName + '_Chest_Ctrl_01', 1, 'rotateY', -5) SetKeyAnimation(charName + '_Arm_L_Crl', 1, 'translateX', -10) SetKeyAnimation(charName + '_Arm_L_Crl', 13, 'translateX', -5) SetKeyAnimation(charName + '_Arm_L_Crl', 25, 'translateX', -10) SetKeyAnimation(charName + '_Arm_L_Crl', 1, 'translateY', 10) SetKeyAnimation(charName + '_Arm_L_Crl', 13, 'translateY', 5) SetKeyAnimation(charName + '_Arm_L_Crl', 25, 'translateY', 10) SetKeyAnimation(charName + '_Arm_L_Crl', 1, 'translateZ', 15) SetKeyAnimation(charName + '_Arm_L_Crl', 13, 'translateZ', -25) SetKeyAnimation(charName + '_Arm_L_Crl', 25, 'translateZ', 15) SetKeyAnimation(charName + '_Elbow_L_Crl', 1, 'translateX', 20) SetKeyAnimation(charName + '_Elbow_L_Crl', 13, 'translateX', -10) SetKeyAnimation(charName + '_Elbow_L_Crl', 25, 'translateX', 20) SetKeyAnimation(charName + '_Arm_R_Crl', 1, 'translateY', 5) SetKeyAnimation(charName + '_Arm_R_Crl', 13, 'translateY', 10) SetKeyAnimation(charName + '_Arm_R_Crl', 25, 'translateY', 5) SetKeyAnimation(charName + '_Arm_R_Crl', 1, 'translateZ', 5) SetKeyAnimation(charName + '_Arm_R_Crl', 13, 'translateZ', 10) SetKeyAnimation(charName + '_Arm_R_Crl', 25, 'translateZ', 5) SetKeyAnimation(charName + '_Elbow_R_Crl', 1, 'translateX', 10) SetKeyAnimation(charName + '_Elbow_R_Crl', 13, 'translateX', -20) SetKeyAnimation(charName + '_Elbow_R_Crl', 25, 'translateX', 10) SetKeyAnimation(charName + '_Foot_L_Crl', 1, 'translateY', 0) SetKeyAnimation(charName + '_Foot_L_Crl', 7, 'translateY', 15) SetKeyAnimation(charName + '_Foot_L_Crl', 13, 'translateY', 0) SetKeyAnimation(charName + '_Foot_L_Crl', 19, 'translateY', 0) SetKeyAnimation(charName + '_Foot_L_Crl', 1, 'translateZ', -20) SetKeyAnimation(charName + '_Foot_L_Crl', 13, 'translateZ', 20) SetKeyAnimation(charName + '_Foot_L_Crl', 25, 'translateZ', -20) SetKeyAnimation(charName + '_Foot_L_Crl', 1, 'rotateX', 20) SetKeyAnimation(charName + '_Foot_L_Crl', 13, 'rotateX', -15) SetKeyAnimation(charName + '_Foot_L_Crl', 16, 'rotateX', 0) SetKeyAnimation(charName + '_Foot_L_Crl', 19, 'rotateX', 0) SetKeyAnimation(charName + '_Foot_L_Crl', 25, 'rotateX', 20) SetKeyAnimation(charName + '_Chest_Ctrl_02', 1, 'translateZ', -10) SetKeyAnimation(charName + '_Chest_Ctrl_02', 13, 'translateZ', -5) SetKeyAnimation(charName + '_Chest_Ctrl_02', 25, 'translateZ', -10) SetKeyAnimation(charName + '_Foot_R_Crl', 7, 'translateY', 0) SetKeyAnimation(charName + '_Foot_R_Crl', 13, 'translateY', 0) SetKeyAnimation(charName + '_Foot_R_Crl', 19, 'translateY', 15) SetKeyAnimation(charName + '_Foot_R_Crl', 25, 'translateY', 0) SetKeyAnimation(charName + '_Foot_R_Crl', 1, 'translateZ', 20) SetKeyAnimation(charName + '_Foot_R_Crl', 13, 'translateZ', -20) SetKeyAnimation(charName + '_Foot_R_Crl', 25, 'translateZ', 20) SetKeyAnimation(charName + '_Foot_R_Crl', 1, 'rotateX', -20) SetKeyAnimation(charName + '_Foot_R_Crl', 4, 'rotateX', 0) SetKeyAnimation(charName + '_Foot_R_Crl', 7, 'rotateX', 0) SetKeyAnimation(charName + '_Foot_R_Crl', 13, 'rotateX', 15) SetKeyAnimation(charName + '_Foot_R_Crl', 25, 'rotateX', -20) SetKeyAnimation(charName + '_Spline_Ctrl_01', 7, 'translateX', -8) SetKeyAnimation(charName + '_Spline_Ctrl_01', 19, 'translateX', 8) SetKeyAnimation(charName + '_Spline_Ctrl_01', 31, 'translateX', -8) SetKeyAnimation(charName + '_Spline_Ctrl_01', 1, 'rotateX', -2) SetKeyAnimation(charName + '_Spline_Ctrl_01', 7, 'rotateX', 10) SetKeyAnimation(charName + '_Spline_Ctrl_01', 13, 'rotateX', -2) SetKeyAnimation(charName + '_Spline_Ctrl_01', 7, 'rotateX', 10) SetKeyAnimation(charName + '_Spline_Ctrl_01', 1, 'rotateY', 15) SetKeyAnimation(charName + '_Spline_Ctrl_01', 13, 'rotateY', -15) SetKeyAnimation(charName + '_Spline_Ctrl_01', 25, 'rotateY', 15) SetKeyAnimation(charName + '_Hip_Ctrl_01', 4, 'translateY', -2) SetKeyAnimation(charName + '_Hip_Ctrl_01', 10, 'translateY', 2) SetKeyAnimation(charName + '_Hip_Ctrl_01', 16, 'translateY', -2) SetKeyAnimation(charName + '_Hip_Ctrl_01', 7, 'rotateX', 10) SetKeyAnimation(charName + '_Hip_Ctrl_01', 13, 'rotateX', -2) SetKeyAnimation(charName + '_Hip_Ctrl_01', 19, 'rotateX', 10)
def CreateJoints(): charName = cmds.textFieldGrp(NameInput, q=True, text=True) if charName == "": print("Write your character name") else: #Create directory listDirectory = [['_Joints_', '_Controls_', '_ikHandle_'], '_GlobalControl_', '_Geo_'] cmds.group(em=True, n=charName + '_Main_01') for i in range(len(listDirectory) - 1): cmds.group(em=True, n=charName + listDirectory[i + 1] + '01') cmds.parent(charName + listDirectory[i + 1] + '01', charName + '_Main_01') for i in range(len(listDirectory[0])): cmds.group(em=True, n=charName + listDirectory[0][i] + '01') cmds.parent(charName + listDirectory[0][i] + '01', charName + listDirectory[1] + '01') cmds.select(d=True) global locXYZ locXYZ = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] for i in range(len(list)): locXYZ[i][0] = cmds.getAttr('Loc_' + list[i] + '.translateX') print('translateX calcule done') locXYZ[i][1] = cmds.getAttr('Loc_' + list[i] + '.translateY') print('translateY calcule done') locXYZ[i][2] = cmds.getAttr('Loc_' + list[i] + '.translateZ') print('translateZ calcule done') #total length between root and neck lengthY = locXYZ[1][1] - locXYZ[0][1] lengthZ = abs(locXYZ[0][2]) + abs(locXYZ[1][2]) #length between root and toe legY = locXYZ[0][1] - locXYZ[5][1] lengthY = locXYZ[1][1] - locXYZ[0][1] lengthZ = abs(locXYZ[0][2]) + abs(locXYZ[1][2]) #length between root and toe legY = locXYZ[0][1] - locXYZ[5][1] cmds.joint(p=(locXYZ[0][0], locXYZ[0][1], locXYZ[0][2]), n=charName + '_root' + '_Jnt_01') def PlaceJoint(OrientThisJoint, x, y, z, jointName, o): cmds.joint(p=(x, y, z), n=jointName) cmds.joint(OrientThisJoint, e=True, zso=True, oj='xyz', sao=o + 'up') #place spline-head joint PlaceJoint(charName + '_root' + '_Jnt_01', 0, locXYZ[0][1] + lengthY * 0.43, locXYZ[0][2] + lengthZ * 0.43, charName + '_spline' + '_Jnt_01', 'x') PlaceJoint(charName + '_spline' + '_Jnt_01', 0, locXYZ[0][1] + lengthY * 0.8, locXYZ[0][2] + lengthZ * 0.18, charName + '_spline' + '_Jnt_02', 'x') PlaceJoint(charName + '_spline' + '_Jnt_02', locXYZ[1][0], locXYZ[1][1], locXYZ[1][2], charName + '_spline' + '_Jnt_03', 'x') PlaceJoint(charName + '_spline' + '_Jnt_03', locXYZ[1][0], locXYZ[1][1] + lengthY * 0.1, locXYZ[1][2] + lengthY * 0.05, charName + '_neck' + '_Jnt_01', 'x') PlaceJoint(charName + '_neck' + '_Jnt_01', (locXYZ[1][0] + locXYZ[1][0]) / 2, locXYZ[1][1] + lengthY / 4, (locXYZ[1][2] + locXYZ[0][2] + lengthY * 0.15) / 2, charName + '_jaw' + '_Jnt_01', 'x') PlaceJoint(charName + '_jaw' + '_Jnt_01', (locXYZ[1][0] + locXYZ[1][0]) / 4, locXYZ[1][1] + lengthY / 2.8, (locXYZ[1][2] + locXYZ[0][2] + lengthY * 0.15) / 2, charName + '_eye' + '_Jnt_01', 'x') PlaceJoint(charName + '_eye' + '_Jnt_01', 0, locXYZ[1][1] + lengthY / 1.8, locXYZ[0][2] + lengthY * 0.03, charName + '_head' + '_Jnt_01', 'x') cmds.joint(charName + '_head' + '_Jnt_01', e=True, oj='none', ch=True, zso=True) #place arm joint cmds.select(d=True) cmds.joint(charName + '_spline' + '_Jnt_03', p=(locXYZ[0][0] + lengthY * 0.1, locXYZ[1][1], locXYZ[0][2] + lengthZ * 0.1), n=charName + '_L' + '_shoulder' + '_Jnt_01') PlaceJoint(charName + '_L' + '_shoulder' + '_Jnt_01', locXYZ[0][0] + lengthY * 0.24, locXYZ[1][1] - lengthY * 0.05, locXYZ[0][2] - lengthZ * 0.2, charName + '_L' + '_shoulder' + '_Jnt_02', 'y') PlaceJoint( charName + '_L' + '_shoulder' + '_Jnt_02', (locXYZ[0][0] + lengthY * 0.24 + locXYZ[2][0] - lengthZ * 0.1) / 2, (locXYZ[1][1] - lengthY * 0.05 + locXYZ[2][1] + lengthZ * 0.1) / 2, (locXYZ[0][2] - lengthZ * 0.2 + locXYZ[2][2]) / 2, charName + '_L' + '_arm' + '_Jnt_01', 'y') PlaceJoint(charName + '_L' + '_arm' + '_Jnt_01', locXYZ[2][0] - lengthZ * 0.1, locXYZ[2][1] + lengthZ * 0.1, locXYZ[2][2], charName + '_L' + '_arm' + '_Jnt_02', 'y') PlaceJoint(charName + '_L' + '_arm' + '_Jnt_02', locXYZ[2][0] + lengthZ * 0.1, locXYZ[2][1] - lengthZ * 0.1, locXYZ[2][2], charName + '_L' + '_arm' + '_Jnt_03', 'y') PlaceJoint(charName + '_L' + '_arm' + '_Jnt_03', (locXYZ[2][0] + lengthZ * 0.1 + locXYZ[3][0]) / 2, (locXYZ[2][1] - lengthZ * 0.1 + locXYZ[3][1]) / 2, (locXYZ[2][2] + locXYZ[3][2]) / 2, charName + '_L' + '_arm' + '_Jnt_04', 'y') PlaceJoint(charName + '_L' + '_arm' + '_Jnt_04', locXYZ[3][0], locXYZ[3][1], locXYZ[3][2], charName + '_L' + '_wrist' + '_Jnt_01', 'y') PlaceJoint(charName + '_L' + '_wrist' + '_Jnt_01', locXYZ[3][0], locXYZ[3][1] + lengthY * -0.20, locXYZ[3][2], charName + '_L' + '_hand' + '_Jnt_01', 'y') cmds.joint(charName + '_L' + '_hand' + '_Jnt_01', e=True, oj='none', ch=True, zso=True) #place leg joint cmds.select(d=True) cmds.joint(charName + '_root' + '_Jnt_01', p=(locXYZ[0][0] + lengthY * 0.08, locXYZ[0][1], locXYZ[0][2] - lengthZ / 3.9), n=charName + '_L' + '_hip' + '_Jnt_01') PlaceJoint(charName + '_L' + '_hip' + '_Jnt_01', locXYZ[0][0] + lengthY * 0.21, locXYZ[0][1] + legY * 0.03, locXYZ[0][2] - lengthZ / 1.86, charName + '_L' + '_thigh' + '_Jnt_01', 'x') PlaceJoint(charName + '_L' + '_thigh' + '_Jnt_01', locXYZ[4][0] - legY * 0.005, locXYZ[4][1] + legY * 0.05, locXYZ[4][2], charName + '_L' + '_knee' + '_Jnt_01', 'x') PlaceJoint(charName + '_L' + '_knee' + '_Jnt_01', locXYZ[4][0] + legY * 0.005, locXYZ[4][1] - legY * 0.05, locXYZ[4][2] - legY * 0.03, charName + '_L' + '_knee' + '_Jnt_02', 'x') PlaceJoint( charName + '_L' + '_knee' + '_Jnt_02', locXYZ[5][0] - locXYZ[4][0] * 0.3, locXYZ[5][1] + locXYZ[4][1] * 0.17, locXYZ[4][2] - legY * 0.03 - (locXYZ[5][2] - locXYZ[4][2]) / 6, charName + '_L' + '_ankie' + '_Jnt_01', 'x') PlaceJoint(charName + '_L' + '_ankie' + '_Jnt_01', (locXYZ[5][0] - locXYZ[4][0] * 0.3 + locXYZ[5][0]) / 2, locXYZ[5][1], locXYZ[4][2] + locXYZ[5][2] / 1.9, charName + '_L' + '_ball' + '_Jnt_01', 'x') PlaceJoint(charName + '_L' + '_ball' + '_Jnt_01', locXYZ[5][0], locXYZ[5][1], locXYZ[5][2], charName + '_L' + '_toe' + '_Jnt_01', 'x') cmds.joint(charName + '_L' + '_toe' + '_Jnt_01', e=True, oj='none', ch=True, zso=True)
#cmds.setAttr('men_alembic:men_alembic_AlembicNode.cycleType',1) #Interface cmds.window("Generator de foule", w=300, h=600) cmds.columnLayout(adj=True) imagePath = cmds.workspace(q=True, rd=True) + "/scripts/image_2.jpg" cmds.image(w=300, h=100, image=imagePath) cmds.rowLayout(numberOfColumns=1, columnWidth3=(80, 75, 300), adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (3, 'both', 0)]) #cmds.button( label='Import character',command= 'ImportOBJ()') NameInput = cmds.textFieldGrp(label="Character Name", editable=True) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') cmds.frameLayout(label='Auto Rig', collapsable=True, collapse=False) cmds.rowColumnLayout(numberOfColumns=5, columnWidth=[(1, 80), (2, 80), (3, 80), (4, 80), (5, 80)]) cmds.button(label='Create locators', command='CreationLoc()') cmds.button(label='Create joints', command='CreateJoints()') cmds.button(label='Mirror', command='MirrorJoints()') cmds.button(label='Controllers', command='Controllers()') cmds.button(label='bindSkin', command='Bind()') cmds.setParent('..') cmds.setParent('..')
def Controllers(): charName = cmds.textFieldGrp(NameInput, q=True, text=True) lengthY = locXYZ[1][1] - locXYZ[0][1] lengthZ = abs(locXYZ[0][2]) + abs(locXYZ[1][2]) legY = locXYZ[0][1] - locXYZ[5][1] side = ['_L_', '_R_'] nb = [1, -1] for i in range(len(side)): cmds.ikHandle(n=charName + '_Leg' + side[i] + 'ikHandle', sj=charName + side[i] + 'thigh_Jnt_01', ee=charName + side[i] + 'ankie_Jnt_01') cmds.spaceLocator(n=charName + '_poleVector' + side[i] + 'leg', p=(nb[i] * locXYZ[4][0] - legY * 0.005, locXYZ[4][1] + legY * 0.05, locXYZ[4][2])) cmds.xform(centerPivots=1) # aims the pole vector of 1 at 2. cmds.poleVectorConstraint(charName + '_poleVector' + side[i] + 'leg', charName + '_Leg' + side[i] + 'ikHandle') cmds.move(nb[i] * lengthY * 0.75, -lengthY * 0.75, charName + '_poleVector' + side[i] + 'leg', moveXY=True) cmds.setAttr(charName + '_Leg' + side[i] + 'ikHandle.twist', nb[i] * 90) cmds.ParentConstraint(charName + 'controllerfoot', charName + '_poleVector' + side[i] + 'leg') cmds.parent(charName + '_poleVector' + side[i] + 'leg', charName + '_Leg' + side[i] + 'ikHandle', relative=True) cmds.ikHandle(n=charName + '_Foot' + side[i] + 'ball_ikHandle', sj=charName + side[i] + 'ankie' + '_Jnt_01', ee=charName + side[i] + 'ball' + '_Jnt_01') cmds.ikHandle(n=charName + '_Foot' + side[i] + 'toe_ikHandle', sj=charName + side[i] + 'ball' + '_Jnt_01', ee=charName + side[i] + 'toe' + '_Jnt_01') cmds.group(charName + '_Leg' + side[i] + 'ikHandle', n=charName + '_Foot' + side[i] + 'heelPeel') #change pivot position Xpos = cmds.getAttr(charName + '_Foot' + side[i] + 'ball_ikHandle.translateX') Ypos = cmds.getAttr(charName + '_Foot' + side[i] + 'ball_ikHandle.translateY') Zpos = cmds.getAttr(charName + '_Foot' + side[i] + 'ball_ikHandle.translateZ') cmds.move(Xpos, Ypos, Zpos, charName + '_Foot' + side[i] + 'heelPeel.scalePivot', charName + '_Foot' + side[i] + 'heelPeel.rotatePivot', absolute=True) cmds.group(charName + '_Foot' + side[i] + 'ball_ikHandle', charName + '_Foot' + side[i] + 'toe_ikHandle', n=charName + '_Foot' + side[i] + 'toeTap') cmds.move(Xpos, Ypos, Zpos, charName + '_Foot' + side[i] + 'toeTap.scalePivot', charName + '_Foot' + side[i] + 'toeTap.rotatePivot', absolute=True) cmds.group(charName + '_Foot' + side[i] + 'ball_ikHandle', charName + '_Foot' + side[i] + 'toeTap', n=charName + '_Foot' + side[i] + 'TipToe') cmds.group(n=charName + '_Foot' + side[i] + '1', em=True) cmds.parent(charName + '_Foot' + side[i] + 'heelPeel', charName + '_Foot' + side[i] + 'TipToe', charName + '_Foot' + side[i] + '1', relative=True) cmds.move(Xpos, Ypos, Zpos, charName + '_Foot' + side[i] + '1.scalePivot', charName + '_Foot' + side[i] + '1.rotatePivot', absolute=True) Xpos = cmds.getAttr(charName + '_Foot' + side[i] + 'ball_ikHandle.translateX') Ypos = cmds.getAttr(charName + '_Foot' + side[i] + 'ball_ikHandle.translateY') Zpos = cmds.getAttr(charName + '_Foot' + side[i] + 'ball_ikHandle.translateZ') CreateCtr(charName + '_Foot' + side[i] + 'Crl', charName + '_Foot' + side[i] + '1', (Xpos, Ypos, Zpos), (lengthY / 60 * 10, lengthY / 60 * 10, lengthY / 60 * 16), (0, 0, 0)) #left Arm for i in range(len(side)): cmds.ikHandle(n=charName + '_Arm' + str(side[i]) + 'ikHandle', sj=charName + str(side[i]) + 'shoulder' + '_Jnt_02', ee=charName + str(side[i]) + 'wrist' + '_Jnt_01') cmds.CreateNURBSCircle() cmds.rename('nurbsCircle1', charName + '_Elbow' + str(side[i]) + 'Crl') cmds.move(nb[i] * locXYZ[2][0], locXYZ[2][1], locXYZ[2][2] * 30) cmds.scale(2, 2, 3) cmds.rotate(90, 0, 0) cmds.move(nb[i] * locXYZ[2][0], locXYZ[2][1], locXYZ[2][2], charName + '_Elbow' + str(side[i]) + 'Crl.scalePivot', charName + '_Elbow' + str(side[i]) + 'Crl.rotatePivot', absolute=True) cmds.makeIdentity(apply=True) cmds.xform(centerPivots=1) cmds.poleVectorConstraint( charName + '_Elbow' + str(side[i]) + 'Crl', charName + '_Arm' + str(side[i]) + 'ikHandle') #left Arm controller CreateCtr(charName + '_Arm' + side[i] + 'Crl', charName + '_Arm' + side[i] + 'ikHandle', (nb[i] * locXYZ[3][0], locXYZ[3][1], locXYZ[3][2]), (lengthY / 60 * 5, lengthY / 60 * 5, lengthY / 60 * 8), (0, 0, nb[i] * 30)) #spline cmds.parent(charName + '_R_shoulder_Jnt_01', w=True) cmds.parent(charName + '_L_shoulder_Jnt_01', w=True) cmds.select(d=True) cmds.select(charName + '_spline_Jnt_03') cmds.DisconnectJoint(charName + '_spline_Jnt_03') cmds.rename(charName + '_spline_Jnt_03', charName + '_neck_Jnt_00') cmds.rename('joint1', charName + '_spline_Jnt_03') cmds.rename(charName + '_root' + '_Jnt_01', charName + '_spline_Jnt_00') cmds.parent(charName + '_R_hip_Jnt_01', w=True) cmds.parent(charName + '_L_hip_Jnt_01', w=True) cmds.select(d=True) cmds.joint(p=(locXYZ[0][0], locXYZ[0][1], locXYZ[0][2]), n=charName + '_root' + '_Jnt_01') cmds.parent(charName + '_L_hip_Jnt_01') cmds.select(charName + '_root' + '_Jnt_01') cmds.parent(charName + '_R_hip_Jnt_01') cmds.curve(n=charName + '_SplineIK_Crv_01', p=[(locXYZ[0][0], locXYZ[0][1], locXYZ[0][2]), (0.0, locXYZ[0][1] + lengthY * 0.43, locXYZ[0][2] + lengthZ * 0.43), (0.0, locXYZ[0][1] + lengthY * 0.8, locXYZ[0][2] + lengthZ * 0.18), (locXYZ[1][0], locXYZ[1][1], locXYZ[1][2])]) cmds.ikHandle(n=charName + 'SplineIK_01', sj=charName + '_spline_Jnt_00', ee=charName + '_spline_Jnt_03', curve=charName + '_SplineIK_Crv_01', sol='ikSplineSolver', createCurve=False, parentCurve=False) for i in range(4): cmds.select(charName + '_SplineIK_Crv_01' + '.cv[' + str(i) + ']') cmds.cluster(n='cluster_' + str(i + 1)) CreateCtr(charName + '_Spline_Ctrl_01', 'cluster_1Handle', (0, locXYZ[0][1] * 1.05, 0), (lengthY / 60 * 25, lengthY / 60 * 25, lengthY / 60 * 25), (0, 0, 0)) cmds.parentConstraint(charName + '_Spline_Ctrl_01', charName + '_root_Jnt_01', maintainOffset=True) CreateCtr(charName + '_Chest_Ctrl_01', 'cluster_4Handle', (0, locXYZ[1][1], 0), (lengthY / 60 * 25, lengthY / 60 * 25, lengthY / 60 * 25), (0, 0, 0)) for i in range(len(side)): cmds.parentConstraint(charName + '_Chest_Ctrl_01', charName + side[i] + 'shoulder_Jnt_01', maintainOffset=True) cmds.parent(charName + '_Arm' + side[i] + 'Crl_grp', charName + '_Chest_Ctrl_01') cmds.parent(charName + '_Elbow' + side[i] + 'Crl', charName + '_Chest_Ctrl_01') CreateCtr(charName + '_Chest_Ctrl_02', 'cluster_2Handle', (0, (locXYZ[0][1] + locXYZ[1][1]) / 2, 0), (lengthY / 60 * 20, lengthY / 60 * 20, lengthY / 60 * 20), (0, 0, 0)) cmds.parentConstraint(charName + '_Chest_Ctrl_01', charName + '_neck_Jnt_00', maintainOffset=True, w=1) cmds.parentConstraint(charName + '_Chest_Ctrl_01', 'cluster_3Handle', maintainOffset=True, weight=0.5) cmds.parentConstraint(charName + '_Chest_Ctrl_01', charName + '_Chest_Ctrl_02_grp', maintainOffset=True, weight=0.5) cmds.parentConstraint(charName + '_Spline_Ctrl_01', charName + '_Chest_Ctrl_02_grp', maintainOffset=True, weight=0.5) cmds.CreateNURBSCircle() cmds.rename('nurbsCircle1', charName + '_Hip_Ctrl_01') cmds.move(0, locXYZ[0][1], 0) cmds.scale(lengthY / 60 * 30, lengthY / 60 * 30, lengthY / 60 * 30) cmds.makeIdentity(apply=True) cmds.parentConstraint(charName + '_Hip_Ctrl_01', charName + '_Spline_Ctrl_01', maintainOffset=True, weight=0.5) cmds.parentConstraint(charName + '_Hip_Ctrl_01', charName + '_Chest_Ctrl_01', maintainOffset=True, weight=0.5) #clean for i in range(len(side)): cmds.parent(charName + side[i] + 'shoulder_Jnt_01', charName + '_Joints_01') cmds.parent(charName + '_Chest_Ctrl_0' + str(i + 1) + '_grp', charName + '_Controls_01') cmds.parent(charName + '_Foot' + side[i] + '1', charName + '_Controls_01') cmds.parent(charName + '_Foot' + side[i] + 'Crl_grp', charName + '_Controls_01') cmds.parent(charName + '_Arm' + side[i] + 'ikHandle', charName + '_ikHandle_01') cmds.parent('cluster_' + str(i + 1) + 'Handle', charName + '_ikHandle_01') cmds.parent('cluster_' + str(i + 3) + 'Handle', charName + '_ikHandle_01') cmds.parent(charName + 'SplineIK_01', charName + '_ikHandle_01') cmds.parent(charName + '_SplineIK_Crv_01', charName + '_ikHandle_01') cmds.parent(charName + '_neck_Jnt_00', charName + '_Joints_01') cmds.parent(charName + '_root_Jnt_01', charName + '_Joints_01') cmds.parent(charName + '_spline_Jnt_00', charName + '_Joints_01') cmds.parent(charName + '_Spline_Ctrl_01_grp', charName + '_Controls_01') cmds.parent(charName + '_Hip_Ctrl_01', charName + '_Controls_01')
def version(self): return mc.textFieldGrp(self._tfg_version, query=True, text=True)
def Check(): charName = cmds.textFieldGrp(NameInput, q=True, text=True)
def character(self): return mc.textFieldGrp(self._tfg_char, query=True, text=True)
def _build_ui(self): ''' build gui window with base controls ''' # build window self._window = mc.window(self.WIN_NAME, title='dd Rig Publisher', sizeable=False, resizeToFitChildren=True, widthHeight=(625, 135)) self._main_flayout = mc.formLayout(numberOfDivisions=100) self._tfg_rlayout = mc.rowLayout(numberOfColumns=4, cw4=[200, 200, 200, 150], height=25, parent=self._main_flayout) self._tfg_char_type = mc.textFieldGrp( editable=False, label='', cw2=[10, 190], text='', parent=self._tfg_rlayout, annotation="Select character type category") self._tfg_char_type_popup = mc.popupMenu(parent=self._tfg_char_type) self._tfg_char = mc.textFieldGrp( editable=False, label='', cw2=[10, 190], text='', parent=self._tfg_rlayout, annotation="Select character to publish rig as") self._tfg_char_popup = mc.popupMenu(parent=self._tfg_char) self._tfg_rig_type = mc.textFieldGrp( editable=False, label='', cw2=[10, 190], text='', parent=self._tfg_rlayout, annotation="Select type of rig being published") self._tfg_rig_type_popup = mc.popupMenu(parent=self._tfg_rig_type) self._tfg_version = mc.textFieldGrp( editable=True, label='Version Number ', cw2=[100, 25], columnAlign2=['right', 'left'], text='1', parent=self._tfg_rlayout, annotation="Enter rig version to attempt publish as") self._publish_btn = mc.button(label='Publish', height=30, parent=self._main_flayout, command=self.kick_off_publish) mc.formLayout(self._main_flayout, edit=True, attachForm=[(self._tfg_rlayout, 'top', 15), (self._tfg_rlayout, 'left', 10), (self._tfg_rlayout, 'right', 10), (self._publish_btn, 'left', 15), (self._publish_btn, 'right', 15), (self._publish_btn, 'bottom', 15)]) mc.window(self._window, edit=True, widthHeight=(755, 100)) self._buildCharTypeTFG()
def loadRod(self, *args): sel = mc.ls(sl=True) mc.textFieldGrp(self.rodFld, edit=True, text=sel[0])
def rig_type(self): return mc.textFieldGrp(self._tfg_rig_type, query=True, text=True)
def OCT_RenderSet_zwz_UI(): if mc.windowPref('RenderSet_zwz', exists=True): mc.windowPref('RenderSet_zwz', remove=True) if mc.window('RenderSet_zwz', exists=True): mc.deleteUI('RenderSet_zwz', window=True) allCameras = mc.listCameras(p=True) myStartFrameV = mc.getAttr("defaultRenderGlobals.startFrame") myEndFrameV = mc.getAttr("defaultRenderGlobals.endFrame") myRenderwidth = mc.getAttr("defaultResolution.width") myRenderheight = mc.getAttr("defaultResolution.height") mc.window("RenderSet_zwz", title=u"OCT_RenderSet_zwz", menuBar=True, widthHeight=(350, 340), resizeToFitChildren=True, sizeable=True) mc.formLayout('formLyt', numberOfDivisions=100) one = mc.columnLayout('First_Set', parent='formLyt') mc.rowLayout('projectRow', numberOfColumns=3, columnAttach3=['left', 'left', 'left'], columnWidth3=[5, 260, 35], columnOffset3=[2, 2, 2], adjustableColumn3=True, parent='First_Set') mc.text(label=u'工程地址:', w=68, parent='projectRow') mc.textField('ProjectAddress', text='', width=250, alwaysInvokeEnterCommandOnReturn=True, parent='projectRow') mc.button(label=u'设置', width=35, command='OCT_generel.OCT_RenderSet_zwz.SetProjectAddress_zwz()', backgroundColor=(0.9, 0.5, 0), annotation=u"请输入工程层名", parent='projectRow') mc.rowLayout('oneRow', numberOfColumns=3, columnAttach3=['left', 'left', 'left'], columnWidth3=[5, 260, 35], columnOffset3=[2, 2, 2], adjustableColumn3=True, parent='First_Set') mc.text(label=u'一般渲染名:', w=68, parent='oneRow') mc.textField( 'RederAddress', text= '<Scene>/<RenderLayer>/<Camera>/<RenderPass>/<Camera>.<RenderPass>', width=250, alwaysInvokeEnterCommandOnReturn=True, parent='oneRow') mc.button(label=u'设置', width=35, command='OCT_generel.OCT_RenderSet_zwz.SetRenderAddress_zwz()', backgroundColor=(0.9, 0.5, 0), annotation=u"请输入渲染层名", parent='oneRow') mc.rowLayout('twoRow', numberOfColumns=3, columnAttach3=['left', 'left', 'left'], columnWidth3=[5, 260, 35], columnOffset3=[2, 2, 2], adjustableColumn3=True, parent='First_Set') mc.text(label=u'Vray渲染名:', w=68, parent='twoRow') mc.textField('VrayRederAddress', text='<Scene>/<Layer>/<Camera>/<Camera>', width=250, alwaysInvokeEnterCommandOnReturn=True, parent='twoRow') mc.button( label=u'设置', width=35, command='OCT_generel.OCT_RenderSet_zwz.SetVrayRenderAddress_zwz()', backgroundColor=(0.9, 0.5, 0), annotation=u"请输入渲染层名", parent='twoRow') mc.rowLayout('threeRow', numberOfColumns=2, columnAttach2=['left', 'left'], columnWidth2=[260, 35], columnOffset2=[2, 1], columnAlign=[1, 'left'], cw2=[334, 35], parent='First_Set') mc.radioButtonGrp( 'FormatSet', label=u'渲染格式设置:', labelArray2=['Software/Mental Ray (iff)', 'Arnold (Tiff)'], numberOfRadioButtons=2, columnAlign=[1, 'left'], columnAlign2=['left', 'left'], cw3=[85, 160, 90], sl=1, parent='threeRow') mc.button(label=u'设置', width=35, command='OCT_generel.OCT_RenderSet_zwz.SetRenderFormat_zwz()', backgroundColor=(0.9, 0.5, 0), annotation=u"请输入需要选择物体的名字", parent='threeRow') mc.rowLayout('fourRow', numberOfColumns=5, columnAttach5=['left', 'left', 'left', 'left', 'left'], columnWidth5=[5, 68, 70, 88, 80], columnOffset5=[2, 2, 10, 15, 24], adjustableColumn5=True, parent='First_Set') mc.text(label=u'开始帧:', w=68, parent='fourRow') mc.textField('startFrame', text=myStartFrameV, width=60, alwaysInvokeEnterCommandOnReturn=True, parent='fourRow') mc.text(label=u'结束帧:', w=68, parent='fourRow') mc.textField('endFrame', text=myEndFrameV, width=60, alwaysInvokeEnterCommandOnReturn=True, parent='fourRow') mc.button(label=u'设置', width=35, command='OCT_generel.OCT_RenderSet_zwz.SetRenderStarFram_zwz()', backgroundColor=(0.9, 0.5, 0), annotation=u"请输入帧数范围", parent='fourRow') mc.rowLayout('fiveRow', numberOfColumns=5, columnAttach5=['left', 'left', 'left', 'left', 'left'], columnWidth5=[5, 68, 70, 88, 80], columnOffset5=[2, 2, 10, 15, 24], adjustableColumn5=True, parent='First_Set') mc.text(label=u'宽:', w=68, parent='fiveRow') mc.textField('RenderWidth', text=myRenderwidth, width=60, alwaysInvokeEnterCommandOnReturn=True, parent='fiveRow') mc.text(label=u'高:', w=68, parent='fiveRow') mc.textField('RenderHeight', text=myRenderheight, width=60, alwaysInvokeEnterCommandOnReturn=True, parent='fiveRow') mc.button(label=u'设置', width=35, command='OCT_generel.OCT_RenderSet_zwz.SetRenderWH_zwz()', backgroundColor=(0.9, 0.5, 0), annotation=u"请输入渲染尺寸", parent='fiveRow') two = mc.frameLayout('Cameras_Set', label=u'设置渲染摄像机(面板可拉伸)', labelAlign='top', borderStyle='etchedOut', w=300, h=100, parent='formLyt') mc.textScrollList('selectCameras', append=allCameras, allowMultiSelection=True, h=100, parent='Cameras_Set') three = mc.columnLayout('Second_Set', parent='formLyt') mc.rowLayout('CamerasButton', numberOfColumns=2, columnWidth2=(190, 190), columnAlign2=('center', 'center'), height=30, parent='Second_Set') mc.button('loadCameras', label=u'设置摄像机', width=170, command='OCT_generel.OCT_RenderSet_zwz.SetAllmyCameras_zwz()', backgroundColor=(0.9, 0.5, 0), parent='CamerasButton') mc.button('clearCameras', label=u'清除所有摄像机', width=170, command='OCT_generel.OCT_RenderSet_zwz.CleanAllCameras_zwz()', backgroundColor=(0.9, 0.3, 0.3), parent='CamerasButton') mc.button( 'SetAll', label=u'设置以上所有选项', width=362, h=25, command='OCT_generel.OCT_RenderSet_zwz.SetAllmyRenderSetting_zwz()', backgroundColor=(0.2, 0.8, 0.3), parent='Second_Set') four = mc.frameLayout('clipPlane_Set', label=u'设置所有摄像机距离值', labelAlign='top', w=362, bv=0, cll=True, cl=True, parent='formLyt') mc.columnLayout(parent=four) mc.checkBox('cheackClip', label='Auto Render Clip Plane', w=135) mc.textFieldGrp('nearClip', label='Near Clip Plane', text='0.100', cw2=[85, 100], cal=[1, 'left']) mc.textFieldGrp('farClip', label='Far Clip Plane', text='10000000.000', cw2=[85, 100], cal=[1, 'left']) mc.button( label=u'设置所有摄像机距离值', width=365, command='OCT_generel.OCT_RenderSet_zwz.setAllmyCmaerasClip_zwz()', backgroundColor=(0.9, 0.5, 0)) mc.formLayout('formLyt', e=True, attachForm=[(one, 'top', 5), (one, 'left', 5), (two, 'right', 5), (two, 'top', 155), (two, 'left', 5), (three, 'left', 5), (four, 'left', 5), (four, 'bottom', 5)], attachControl=[(two, 'bottom', 1, three), (three, 'bottom', 1, four)], attachNone=[(three, 'top')], attachPosition=[(one, 'left', 0, 0), (one, 'top', 0, 0)]) mayaversions = mc.about(v=True) if mayaversions.find('2009') >= 0: mc.radioButtonGrp('FormatSet', e=True, enable2=False) mc.showWindow('RenderSet_zwz')
def _updateRigTypeTFG(self, data, arg=None): ''' update rig type text field group menu list ''' mc.textFieldGrp(self._tfg_rig_type, edit=True, text=data)
def save_file(self, *args): # assemble file name sel = [] if self.selBased: sel = cmds.ls(sl=True) if not sel: cmds.warning( "fileManager.save_as_new: You haven't selected anything! Make a selection and try again!" ) return () currscene = cmds.file(q=True, sn=True) if currscene: saveScene = cmds.confirmDialog( t="Save?", m="Should I save the current scene before writing new file?", button=["Yes", "No", "Cancel"], defaultButton="Yes", cancelButton="Cancel", dismissString="Cancel") if saveScene == "Yes": print "Saving current scene: {0}".format(currscene) cmds.file(s=True, f=True) elif saveScene == "No": pass elif saveScene == "Cancel": cmds.warning("Cancelling Save As New!") return () else: pass # cmds.warning("You must be in a named scene to continue!") # return() filepath = None assettype = cmds.optionMenu(self.assetTypeOM, q=True, value=True) if assettype == "Stages": basepath = "{0}/Stages".format(self.projEnvPath) else: basepath = "{0}/Assets/3D/{1}".format(self.projEnvPath, assettype) asset = cmds.optionMenu(self.assetOM, q=True, value=True) variant = cmds.textFieldGrp(self.variant, q=True, tx=True) if not uf.check_for_good_name(variant): cmds.warning("No underscores allowed in variant names!") return () phase = cmds.optionMenu(self.phaseOM, q=True, value=True) if assettype == "Stages": filepath = "{0}/{1}/{2}/Production/Maya/scenes/{3}_{4}_{5}_Work_v0001.mb".format( basepath, asset, phase, asset, variant, phase) else: filepath = "{0}/{1}/{2}/Work/Maya/scenes/{3}_{4}_{5}_Work_v0001.mb".format( basepath, asset, phase, asset, variant, phase) # confirm and save # export to temp, open that tempScene = None if self.selBased: tempScene = create_temp_scene(filepath) if tempScene: cmds.file(tempScene, open=True, f=True) else: return () write = "Cancel" confirm = cmds.confirmDialog( title="Save Confirmation", message="You are about to 'version up':\n{0}\n\nShould we continue?" .format(filepath[:-9]), button=("Create", "Cancel"), defaultButton="Save", cancelButton="Cancel", dismissString="Cancel", bgc=(.6, .5, .5)) if confirm == "Create": write == "Save" print "Saving. . .: ", filepath else: write == "Cancel" print "Canceling. . ." cmds.deleteUI(self.win) if write: ver = vf.versionClass() ver.versionUp(filepath) cmds.deleteUI(self.win) if tempScene and os.path.isfile(tempScene): print "saveNewWindows.save_file: Cleaning up temp scene {0}".format( tempScene) os.remove(tempScene) cmds.confirmDialog( m="Save successful! You're now in file:\n{0}".format( cmds.file(q=True, sn=True))) # Try to refresh the file manager window if cmds.window("fileWin", exists=True): fm.fileManager()
def loadCasing(self, *args): sel = mc.ls(sl=True) mc.textFieldGrp(self.casingFld, edit=True, text=sel[0])
def onCreate(self, *args): # Metadata: PrimPath # The prim path is for display purposes only - it is not editable, but we # allow keyboard focus so you copy the value. self.primPath = cmds.textFieldGrp(label='Prim Path', editable=False, enableKeyboardFocus=True) # Metadata: Kind # We add the known Kind types, in a certain order ("model hierarchy") and then any # extra ones that were added by extending the kind registry. # Note: we remove the "model" kind because in the USD docs it states, # "No prim should have the exact kind "model". allKinds = Kind.Registry.GetAllKinds() allKinds.remove(Kind.Tokens.model) knownKinds = [ Kind.Tokens.group, Kind.Tokens.assembly, Kind.Tokens.component, Kind.Tokens.subcomponent ] temp1 = [ele for ele in allKinds if ele not in knownKinds] knownKinds.extend(temp1) # If this prim's kind is not registered, we need to manually # add it to the list. model = Usd.ModelAPI(self.prim) primKind = model.GetKind() if primKind not in knownKinds: knownKinds.insert(0, primKind) if '' not in knownKinds: knownKinds.insert(0, '') # Set metadata value to "" (or empty). self.kind = cmds.optionMenuGrp( label='Kind', cc=self._onKindChanged, ann= 'Kind is a type of metadata (a pre-loaded string value) used to classify prims in USD. Set the classification value from the dropdown to assign a kind category to a prim. Set a kind value to activate selection by kind.' ) for ele in knownKinds: cmds.menuItem(label=ele) # Metadata: Active self.active = cmds.checkBoxGrp( label='Active', ncb=1, cc1=self._onActiveChanged, ann= "If selected, the prim is set to active and contributes to the composition of a stage. If a prim is set to inactive, it doesn't contribute to the composition of a stage (it gets striked out in the Outliner and is deactivated from the Viewport)." ) # Metadata: Instanceable self.instan = cmds.checkBoxGrp( label='Instanceable', ncb=1, cc1=self._onInstanceableChanged, ann= 'If selected, instanceable is set to true for the prim and the prim is considered a candidate for instancing. If deselected, instanceable is set to false.' ) # Get all the other Metadata and remove the ones above, as well as a few # we don't ever want to show. allMetadata = self.prim.GetAllMetadata() keysToDelete = [ 'kind', 'active', 'instanceable', 'typeName', 'documentation' ] for key in keysToDelete: allMetadata.pop(key, None) if allMetadata: cmds.separator(h=10, style='single', hr=True) for k in allMetadata: # All extra metadata is for display purposes only - it is not editable, but we # allow keyboard focus so you copy the value. mdLabel = getPrettyName(k) if self.useNiceName else k self.extraMetadata[k] = cmds.textFieldGrp( label=mdLabel, editable=False, enableKeyboardFocus=True) # Update all metadata values. self.refresh()
def saveAs_UI(self): if cmds.window("saveAsWin", exists=True): cmds.deleteUI("saveAsWin") self.win = cmds.window("saveAsWin", t="Save New", w=220, h=220) self.form = cmds.formLayout(w=220, h=220) t1 = cmds.text(l="Save As New Destination Options:") t2 = cmds.text(l="Project: {0}".format( os.environ["MAYA_CURRENT_PROJECT"]), font="boldLabelFont") self.assetTypeOM = cmds.optionMenu(l="Asset Type:", w=200, cc=self.change_asset_type) cmds.menuItem(l="Character", p=self.assetTypeOM) cmds.menuItem(l="Props", p=self.assetTypeOM) cmds.menuItem(l="Sets", p=self.assetTypeOM) cmds.menuItem(l="Stages", p=self.assetTypeOM) if self.pp.compatible: cmds.optionMenu(self.assetTypeOM, e=True, value=self.pp.assetType) self.phaseOM = cmds.optionMenu(l="Asset Phase:", w=200) self.anm = cmds.menuItem(l="Animation", p=self.phaseOM) self.mdl = cmds.menuItem(l="Modeling", p=self.phaseOM) self.rig = cmds.menuItem(l="Rigging", p=self.phaseOM) self.lgt = cmds.menuItem(l="Lighting", p=self.phaseOM) self.txt = cmds.menuItem(l="Texturing", p=self.phaseOM) self.assetOM = cmds.optionMenu(l="Asset:", w=200) self.change_asset_type() if self.pp.compatible: cmds.optionMenu(self.assetOM, e=True, value=self.pp.name) if self.pp.compatible: cmds.optionMenu(self.phaseOM, e=True, value=self.pp.phase) self.variant = cmds.textFieldGrp(l="Variant:", tx="main", cw=[(1, 50), (2, 150)], cal=[(1, "left"), (2, "left")]) if self.pp.compatible: cmds.textFieldGrp(self.variant, e=True, tx=self.pp.variant) if self.pp.compatible: if self.assetType == "Stages": cmds.menuItem(self.mdl, e=True, en=False) cmds.menuItem(self.txt, e=True, en=False) cmds.menuItem(self.rig, e=True, en=False) self.but = cmds.button(l="Save File!", bgc=(.5, .7, .5), w=100, h=30, c=self.save_file) self.cancel = cmds.button(l="Cancel", bgc=(.7, .5, .5), w=100, h=30, c=self.cancel) cmds.formLayout(self.form, e=True, attachForm=[ (t1, "top", 2), (t1, "left", 5), (t2, "top", 20), (t2, "left", 5), (self.assetTypeOM, "top", 45), (self.assetTypeOM, "left", 5), (self.assetOM, "top", 75), (self.assetOM, "left", 5), (self.variant, "top", 105), (self.variant, "left", 5), (self.phaseOM, "top", 135), (self.phaseOM, "left", 5), (self.but, "top", 175), (self.but, "left", 5), (self.cancel, "top", 175), (self.cancel, "left", 120), ]) cmds.window(self.win, e=True, w=230, h=220, rtf=True, s=False) cmds.showWindow(self.win)
def skinClusterDataUI(): ''' ''' # Window win = 'skinClusterDataUI' if mc.window(win, q=True, ex=True): mc.deleteUI(win) win = mc.window(win, t='SkinClusterData') # =============== # - UI Elements - # =============== cw1 = (1, 120) # Form Layout mainFL = mc.formLayout(numberOfDivisions=100) # Load/Buld Buttons loadB = mc.button(label='Load Data...', c='glTools.ui.skinClusterData.loadData()') buildB = mc.button(label='Build Data (from selected)', c='glTools.ui.skinClusterData.buildData()') rebuildB = mc.button(label='Rebuild SkinCluster', c='glTools.ui.skinClusterData.rebuildSkinCluster()') saveB = mc.button(label='Save Data', c='glTools.ui.skinClusterData.saveData()') closeB = mc.button(label='Close', c='mc.deleteUI("' + win + '")') # Scroll Layout scrollLayout = mc.scrollLayout(horizontalScrollBarThickness=16, verticalScrollBarThickness=16, cr=1) # SkinCluster Name skinClusterNameTFG = mc.textFieldGrp('skinCluster_nameTFG', label='SkinCluster', text='', cw=cw1) # Scroll FL scrollFL = mc.formLayout(numberOfDivisions=100) # ============== # - Basic Data - # ============== basicDataFRL = mc.frameLayout(label='SkinCluster Data', collapsable=True, p=scrollFL) basicDataFL = mc.formLayout(numberOfDivisions=100) # Affected Geometry skinClusterGeoTFB = mc.textFieldButtonGrp('skinCluster_geoTFB', label='Geometry', text='', editable=False, buttonLabel='Remap', cw=cw1) skinClusterMethodOMG = mc.optionMenuGrp('skinCluster_methodOMG', label='Skinning Method', cw=cw1) mc.menuItem('Classic Linear') mc.menuItem('Dual Quaternion') mc.menuItem('Weight Blended') skinClusterComponentCBG = mc.checkBoxGrp('skinCluster_componentCBG', label='Use Components', cw=cw1) skinClusterNormalizeOMG = mc.optionMenuGrp('skinCluster_normalizeOMG', label='Normalize Weights', cw=cw1) mc.menuItem('None') mc.menuItem('Interactive') mc.menuItem('Post') skinClusterDeformNormCBG = mc.checkBoxGrp('skinCluster_deformNormCBG', label='Deform User Normals', cw=cw1) mc.formLayout(basicDataFL, e=True, af=[(skinClusterGeoTFB, 'top', 5), (skinClusterGeoTFB, 'left', 5), (skinClusterGeoTFB, 'right', 5)]) mc.formLayout(basicDataFL, e=True, ac=[(skinClusterMethodOMG, 'top', 5, skinClusterGeoTFB)], af=[(skinClusterMethodOMG, 'left', 5), (skinClusterMethodOMG, 'right', 5)]) mc.formLayout(basicDataFL, e=True, ac=[(skinClusterComponentCBG, 'top', 5, skinClusterMethodOMG) ], af=[(skinClusterComponentCBG, 'left', 5), (skinClusterComponentCBG, 'right', 5)]) mc.formLayout(basicDataFL, e=True, ac=[(skinClusterNormalizeOMG, 'top', 5, skinClusterComponentCBG)], af=[(skinClusterNormalizeOMG, 'left', 5), (skinClusterNormalizeOMG, 'right', 5)]) mc.formLayout(basicDataFL, e=True, ac=[(skinClusterDeformNormCBG, 'top', 5, skinClusterNormalizeOMG)], af=[(skinClusterDeformNormCBG, 'left', 5), (skinClusterDeformNormCBG, 'right', 5)]) # ================== # - Influence Data - # ================== influenceDataFRL = mc.frameLayout(label='Influence Data', collapsable=True, p=scrollFL) influenceDataFL = mc.formLayout(numberOfDivisions=100) skinCluster_infTXT = mc.text(label='Influence List') skinCluster_infTSL = mc.textScrollList('skinCluster_infTSL', numberOfRows=15, allowMultiSelection=True) skinCluster_wtTXT = mc.text(label='Influence Weights') skinCluster_wtTSL = mc.textScrollList('skinCluster_wtTSL', numberOfRows=15, allowMultiSelection=True) mc.formLayout(influenceDataFL, e=True, af=[(skinCluster_infTXT, 'top', 5), (skinCluster_infTXT, 'left', 5), (skinCluster_infTXT, 'right', 5)]) mc.formLayout(influenceDataFL, e=True, ac=[(skinCluster_infTSL, 'top', 5, skinCluster_infTXT)], af=[(skinCluster_infTSL, 'left', 5), (skinCluster_infTSL, 'right', 5)]) mc.formLayout(influenceDataFL, e=True, ac=[(skinCluster_wtTXT, 'top', 5, skinCluster_infTSL)], af=[(skinCluster_wtTXT, 'left', 5), (skinCluster_wtTXT, 'right', 5)]) mc.formLayout(influenceDataFL, e=True, ac=[(skinCluster_wtTSL, 'top', 5, skinCluster_wtTXT)], af=[(skinCluster_wtTSL, 'left', 5), (skinCluster_wtTSL, 'right', 5)]) # ==================== # - World Space Data - # ==================== worldSpaceDataFRL = mc.frameLayout(label='World Space Data', collapsable=True, p=scrollFL) worldSpaceDataFL = mc.formLayout(numberOfDivisions=100) buildWorldSpaceMeshB = mc.button( label='Build World Space Mesh', c='glTools.ui.skinClusterData.buildWorldSpaceMesh()') storeWorldSpaceMeshB = mc.button( label='Store World Space Mesh', c='glTools.ui.skinClusterData.storeWorldSpaceMesh()') rebuildWorldSpaceDataB = mc.button( label='Rebuild World Space Data', c='glTools.ui.skinClusterData.rebuildWorldSpaceData()') worldSpaceMeshTFG = mc.textFieldGrp('skinCluster_wsMeshTFG', label='World Space Mesh', text='', editable=False, cw=cw1) mc.formLayout(worldSpaceDataFL, e=True, af=[(buildWorldSpaceMeshB, 'top', 5), (buildWorldSpaceMeshB, 'left', 5), (buildWorldSpaceMeshB, 'right', 5)]) mc.formLayout(worldSpaceDataFL, e=True, ac=[(storeWorldSpaceMeshB, 'top', 5, buildWorldSpaceMeshB)], af=[(storeWorldSpaceMeshB, 'left', 5), (storeWorldSpaceMeshB, 'right', 5)]) mc.formLayout(worldSpaceDataFL, e=True, ac=[(rebuildWorldSpaceDataB, 'top', 5, storeWorldSpaceMeshB) ], af=[(rebuildWorldSpaceDataB, 'left', 5), (rebuildWorldSpaceDataB, 'right', 5)]) mc.formLayout(worldSpaceDataFL, e=True, ac=[(worldSpaceMeshTFG, 'top', 5, rebuildWorldSpaceDataB)], af=[(worldSpaceMeshTFG, 'left', 5), (worldSpaceMeshTFG, 'right', 5)]) # ==================== # - PopUp Menu Items - # ==================== # Influence Menu mc.popupMenu(parent=skinCluster_infTSL) mc.menuItem(label='Remap Influence', c='glTools.ui.skinClusterData.remapSelectedInfluence()') mc.menuItem(label='Combine Influences', c='glTools.ui.skinClusterData.combineSelectedInfluences()') mc.menuItem(label='Swap Weights', c='glTools.ui.skinClusterData.swapInfluenceWeights()') mc.menuItem(label='Move Weights', c='glTools.ui.skinClusterData.moveInfluenceWeights()') mc.popupMenu(parent=skinCluster_wtTSL) # ======================== # - UI Callback Commands - # ======================== mc.textFieldGrp(skinClusterNameTFG, e=True, cc='glTools.ui.skinClusterData.renameSkinCluster()') mc.textFieldButtonGrp(skinClusterGeoTFB, e=True, bc='glTools.ui.skinClusterData.remapGeometry()') mc.optionMenuGrp(skinClusterMethodOMG, e=True, cc='glTools.ui.skinClusterData.updateBasicData()') mc.checkBoxGrp(skinClusterComponentCBG, e=True, cc='glTools.ui.skinClusterData.updateBasicData()') mc.optionMenuGrp(skinClusterNormalizeOMG, e=True, cc='glTools.ui.skinClusterData.updateBasicData()') mc.checkBoxGrp(skinClusterDeformNormCBG, e=True, cc='glTools.ui.skinClusterData.updateBasicData()') mc.textScrollList( skinCluster_infTSL, e=True, sc= 'glTools.ui.skinClusterData.selectInfluencesFromUI();glTools.ui.skinClusterData.displayWeightList()' ) # ================ # - Form Layouts - # ================ mc.formLayout(mainFL, e=True, af=[(loadB, 'top', 5), (loadB, 'left', 5)], ap=[(loadB, 'right', 5, 50)]) mc.formLayout(mainFL, e=True, af=[(buildB, 'top', 5), (buildB, 'right', 5)], ap=[(buildB, 'left', 5, 50)]) mc.formLayout(mainFL, e=True, af=[(saveB, 'bottom', 5), (saveB, 'left', 5)], ap=[(saveB, 'right', 5, 50)]) mc.formLayout(mainFL, e=True, af=[(closeB, 'bottom', 5), (closeB, 'right', 5)], ap=[(closeB, 'left', 5, 50)]) mc.formLayout(mainFL, e=True, ac=[(rebuildB, 'bottom', 5, closeB)], af=[(rebuildB, 'right', 5), (rebuildB, 'left', 5)]) mc.formLayout(mainFL, e=True, ac=[(scrollLayout, 'top', 5, loadB), (scrollLayout, 'bottom', 5, rebuildB)], af=[(scrollLayout, 'left', 5), (scrollLayout, 'right', 5)]) mc.formLayout(scrollFL, e=True, af=[(basicDataFRL, 'top', 5), (basicDataFRL, 'left', 5), (basicDataFRL, 'right', 5)]) mc.formLayout(scrollFL, e=True, ac=[(influenceDataFRL, 'top', 5, basicDataFRL)], af=[(influenceDataFRL, 'left', 5), (influenceDataFRL, 'right', 5)]) mc.formLayout(scrollFL, e=True, ac=[(worldSpaceDataFRL, 'top', 5, influenceDataFRL)], af=[(worldSpaceDataFRL, 'left', 5), (worldSpaceDataFRL, 'right', 5)]) # =============== # - Show Window - # =============== reloadUI() mc.showWindow(win)
def reset_to_defaults(*args, **kwargs): """Reset the cvWrap option box widgets to their defaults.""" cmds.textFieldGrp(NAME_WIDGET, e=True, text='cvWrap#') cmds.floatSliderGrp(RADIUS_WIDGET, e=True, value=0) cmds.textFieldButtonGrp(BIND_FILE_WIDGET, e=True, text='') cmds.checkBoxGrp(NEW_BIND_MESH_WIDGET, e=True, v1=False)
def setEnabled(self, enabled): if (self.rootUI is not None): if (enabled): cmds.textFieldGrp(self.xField, edit=True, enable=True) cmds.textFieldGrp(self.yField, edit=True, enable=True) cmds.textFieldGrp(self.zField, edit=True, enable=True) cmds.button(self.fromSelectionsButton, edit=True, enable=True) else: cmds.textFieldGrp(self.xField, edit=True, enable=False) cmds.textFieldGrp(self.yField, edit=True, enable=False) cmds.textFieldGrp(self.zField, edit=True, enable=False) cmds.button(self.fromSelectionsButton, edit=True, enable=False)
def buildGUI(self, *args): """ Create the Maya GUI """ if (cmds.window("BlastMasterWin", exists=True)): cmds.deleteUI("BlastMasterWin", window=True) cmds.window("BlastMasterWin", title="Blast Master", menuBar=True, rtf=1, w=200, h=300) ###Help Menu cmds.menu(label='Help', helpMenu=True) cmds.menuItem( 'Wiki Link', label= 'Wiki Help: http://www.crudephysics.com/greeksWiki/index.php?title=BlastMaster', annotation="Displays online help URL.") cmds.columnLayout() cmds.text(' ') self.nameField = cmds.textFieldGrp(label='Artist Name:', cl2=('right', 'right'), cw2=(90, 100)) #Saving absolute dag paths to layout objects for Form layout placement slateLayout = cmds.rowLayout(nc=2, cw2=(5, 100)) cmds.text(' ') self.commentField = cmds.textFieldGrp(label=' Slate Comment:', cw2=(85, 200)) cmds.setParent('..') cmds.text(' ') cameraLayout = cmds.rowLayout(nc=2, cw2=(50, 100)) cmds.text(' ') self.camMenu = cmds.optionMenu(label='Camera:') self.addCameras() cmds.setParent('..') phaseLayout = cmds.rowLayout(nc=2, cw2=(50, 100)) cmds.text(' ') self.phaseMenu = cmds.optionMenu(label='Phase: ') cmds.menuItem(label='Layout') cmds.setParent('..') cmds.text(' ') self.dirField = cmds.textFieldGrp(label=' Save to directory:', cw2=(110, 220), text=cmds.workspace(query=True, dir=True)) self.imageField = cmds.textFieldButtonGrp(label='16_9_overscan.png:', bl='Browse', bc=self.loadImageDir, cw3=(110, 200, 100)) self.slateField = cmds.textFieldButtonGrp(label='Slate.png:', bl='Browse', bc=self.loadSlateDir, cw3=(110, 200, 100)) cmds.text(' ') buttonLayout = cmds.rowLayout(nc=2, cw2=(130, 100)) cmds.text(' ') cmds.button(label=' Play Blast', command=self.playBlast, w=100) cmds.setParent('..') #Layout onto the form layout """ cmds.formLayout(form, edit=True, attachForm = [(self.sequenceField,'left',5), (self.sequenceField,'right',5), (self.shotField, 'left',5), (self.shotField,'right',5), (self.takeField, 'left',5), (self.takeField,'right',5), (self.nameField, 'left',5), (self.nameField,'right',5), (slateLayout, 'left',5), (slateLayout,'right',5), (cameraLayout, 'left',5), (cameraLayout,'right',5), (phaseLayout, 'left',5), (phaseLayout,'right',5), (self.dirField, 'left',5), (self.dirField,'right',5), (self.imageField, 'left',5), (self.imageField,'right',5), (buttonLayout,'right',5), (buttonLayout,'left',5), (buttonLayout,'bottom',5)], attachControl = [(self.sequenceField,'bottom',5,self.shotField), (self.shotField,'bottom',5,self.takeField), (self.takeField,'bottom',5,self.nameField), (self.nameField,'bottom',5,slateLayout), (slateLayout,'bottom',5,cameraLayout), (cameraLayout,'bottom',5,phaseLayout), (phaseLayout,'bottom',5,self.imageField), (self.imageField,'bottom',5,self.dirField), (self.dirField,'bottom',5,buttonLayout)], attachNone = [(buttonLayout,'top')] ) """ #Set field values name = cmds.getAttr('TG_BM_NODE.name') layout_camera = cmds.getAttr('TG_BM_NODE.layout_cam') image = cmds.getAttr('TG_BM_NODE.mask_image_dir') slate = cmds.getAttr('TG_BM_NODE.slate_image_dir') dir = cmds.getAttr('TG_BM_NODE.dir') try: cmds.textFieldGrp(self.nameField, edit=True, text=name) except: pass try: cmds.textFieldButtonGrp(self.slateField, edit=True, text=slate) except: pass try: cmds.optionMenu(self.camMenu, edit=True, value=layout_camera) except: pass try: cmds.textFieldButtonGrp(self.imageField, edit=True, text=image) except: pass try: cmds.textFieldGrp(self.dirField, edit=True, text=dir) except: pass cmds.showWindow("BlastMasterWin")
def backToUpfolder(path, *args): path = path.replace('\\', '/') path = '/'.join(path.split('/')[:-1]) cmds.textFieldGrp(textField, e=1, tx=path) updatePopupMenu(textField, popupMenu, updateTextFieldCmd)
#Organizing and limit Info cmds.parent(CirculoGrupo, CirculoMover) cmds.select(Circulo[0]) cmds.transformLimits(tx=(0, 0), etx=(1, 1)) cmds.transformLimits(ty=(-Size, Size), ety=(1, 1)) cmds.transformLimits(tz=(0, 0), etz=(1, 1)) #Window cmds.window("RdMSqureSlider", width=250, title="RdMSqureSlider") cmds.columnLayout(adjustableColumn=True) cmds.separator() NameGRP = cmds.textFieldGrp(l='Name', editable=True, hlc=(1, 1, 1), tx='Slider') cmds.separator() SizeSlider = cmds.intSliderGrp(l='Size: ', min=1, max=20, field=True, v=5, hlc=(1, 1, 1)) cmds.separator() cmds.text(label='Create Slider') cmds.rowLayout(nc=2, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 80), (2, 'both', 0)]) cmds.button(label='Vertical', command=VerticalSlider, w=50, h=120)
def RenameSel(renameBtnNewName, renameBtnNewSuffix): newName = cmds.textFieldGrp(renameBtnNewName, q=True, text=True) suffix = cmds.textFieldGrp(renameBtnNewSuffix, q=True, text=True) import RenameItems_py_Hite as RI RI.rename_select(newName, suffix)
def updateTextField(path, *args): cmds.textFieldGrp(textField, e=1, tx=path) updateTextFieldCmd(textField, popupMenu)