def setupVariables(self): self.LocinatorUpdateObjectsOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,'cgmVar_LocinatorUpdateMode') self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateObjectsBuffer',defaultValue = ['']) guiFactory.appendOptionVarList(self,'cgmVar_LocinatorUpdateObjectsBuffer') self.DebugModeOptionVar = OptionVarFactory('cgmVar_LocinatorDebug',defaultValue=0) guiFactory.appendOptionVarList(self,self.DebugModeOptionVar.name) self.SnapModeOptionVar = OptionVarFactory('cgmVar_SnapMatchMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.SnapModeOptionVar.name) #Old method...clean up at some point if not mc.optionVar( ex='cgmVar_ForceBoundingBoxState' ): mc.optionVar( iv=('cgmVar_ForceBoundingBoxState', 0) ) if not mc.optionVar( ex='cgmVar_LocinatorShowHelp' ): mc.optionVar( iv=('cgmVar_LocinatorShowHelp', 0) ) if not mc.optionVar( ex='cgmVar_LocinatorCurrentFrameOnly' ): mc.optionVar( iv=('cgmVar_LocinatorCurrentFrameOnly', 0) ) if not mc.optionVar( ex='cgmVar_LocinatorBakingMode' ): mc.optionVar( iv=('cgmVar_LocinatorBakingMode', 0) ) guiFactory.appendOptionVarList(self,'cgmVar_LocinatorShowHelp')
def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] self.IsClickedOptionVar = OptionVarFactory("cgmVar_IsClicked", "int", 0) self.mmActionOptionVar = OptionVarFactory("cgmVar_mmAction", "int", 0) self.setupVariables() panel = mc.getPanel(up=True) if panel: # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes' if "MayaWindow" in mc.panel(panel, q=True, ctl=True): panel = "viewPanes" sel = search.selectCheck() self.IsClickedOptionVar.set(0) self.mmActionOptionVar.set(0) if mc.popupMenu("cgmMM", ex=True): mc.deleteUI("cgmMM") if panel: if mc.control(panel, ex=True): try: mc.popupMenu( "cgmMM", ctl=0, alt=0, sh=0, mm=1, b=1, aob=1, p=panel, pmc=lambda *a: self.createUI("cgmMM") ) except: guiFactory.warning("cgm.setMenu failed!")
def setupVariables(self): self.LocinatorUpdateObjectsOptionVar = OptionVarFactory( 'cgmVar_AnimToolsUpdateMode', defaultValue=0) guiFactory.appendOptionVarList( self, self.LocinatorUpdateObjectsOptionVar.name) self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=['']) guiFactory.appendOptionVarList( self, self.LocinatorUpdateObjectsBufferOptionVar.name) self.DebugModeOptionVar = OptionVarFactory('cgmVar_AnimToolsDebug', defaultValue=0) guiFactory.appendOptionVarList(self, self.DebugModeOptionVar.name) #Old method...clean up at some point if not mc.optionVar(ex='cgmVar_ForceBoundingBoxState'): mc.optionVar(iv=('cgmVar_ForceBoundingBoxState', 0)) if not mc.optionVar(ex='cgmVar_ForceEveryFrame'): mc.optionVar(iv=('cgmVar_ForceEveryFrame', 0)) if not mc.optionVar(ex='cgmVar_animToolsShowHelp'): mc.optionVar(iv=('cgmVar_animToolsShowHelp', 0)) if not mc.optionVar(ex='cgmVar_CurrentFrameOnly'): mc.optionVar(iv=('cgmVar_CurrentFrameOnly', 0)) if not mc.optionVar(ex='cgmVar_animToolsShowHelp'): mc.optionVar(iv=('cgmVar_animToolsShowHelp', 0)) guiFactory.appendOptionVarList(self, 'cgmVar_animToolsShowHelp')
def buildAttrConversionRow(self, parent): #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Attr type row #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> self.attrConvertTypes = [ 'string', 'float', 'int', 'bool', 'enum', 'message' ] self.attrConvertShortTypes = [ 'str', 'float', 'int', 'bool', 'enum', 'msg' ] self.ConvertAttrTypeRadioCollection = MelRadioCollection() self.ConvertAttrTypeRadioCollectionChoices = [] self.ConvertAttrTypeOptionVar = OptionVarFactory( 'cgmVar_ActiveAttrConversionState', 'int') guiFactory.appendOptionVarList(self, self.ConvertAttrTypeOptionVar.name) self.ConvertAttrTypeOptionVar.set(0) #build our sub section options self.AttrConvertRow = MelHLayout(self.containerName, ut='cgmUISubTemplate', padding=5) for cnt, item in enumerate(self.attrConvertTypes): self.ConvertAttrTypeRadioCollectionChoices.append( self.ConvertAttrTypeRadioCollection.createButton( self.AttrConvertRow, label=self.attrConvertShortTypes[cnt], onCommand=Callback(attrToolsLib.uiConvertLoadedAttr, self, item))) MelSpacer(self.AttrConvertRow, w=2) self.AttrConvertRow.layout()
def setKey(): KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue=0) KeyModeOptionVar = OptionVarFactory('cgmVar_KeyMode', defaultValue=0) if not KeyModeOptionVar.value: #This is default maya keying mode selection = mc.ls(sl=True) or [] if not selection: return guiFactory.warning('Nothing selected!') if not KeyTypeOptionVar.value: mc.setKeyframe(selection) else: mc.setKeyframe(breakdown=True) else: #Let's check the channel box for objects print 'cb mode' selection = search.returnSelectedAttributesFromChannelBox(False) or [] if not selection: selection = mc.ls(sl=True) or [] if not selection: return guiFactory.warning('Nothing selected!') if not KeyTypeOptionVar.value: mc.setKeyframe(selection) else: mc.setKeyframe(selection, breakdown=True)
def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] self.IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked','int',0) self.mmActionOptionVar = OptionVarFactory('cgmVar_mmAction','int',0) self.setupVariables() panel = mc.getPanel(up = True) if panel: # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes' if 'MayaWindow' in mc.panel(panel,q = True,ctl = True): panel = 'viewPanes' sel = search.selectCheck() self.IsClickedOptionVar.set(0) self.mmActionOptionVar.set(0) if mc.popupMenu('cgmMM',ex = True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex = True): try: mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel, pmc = lambda *a: self.createUI('cgmMM')) except: guiFactory.warning('cgm.setMenu failed!')
def setupVariables(self): self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue = 0) guiFactory.appendOptionVarList(self,self.KeyTypeOptionVar.name) self.KeyModeOptionVar = OptionVarFactory('cgmVar_KeyMode', defaultValue = 0) guiFactory.appendOptionVarList(self,self.KeyModeOptionVar.name) self.mmActionOptionVar = OptionVarFactory('cgmVar_mmAction')
def killUI(): IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction') sel = search.selectCheck() if mc.popupMenu('cgmMM', ex=True): mc.deleteUI('cgmMM') if sel: if not mmActionOptionVar.value: setKey()
def killUI(): IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction') sel = search.selectCheck() if mc.popupMenu('cgmMM', ex=True): mc.deleteUI('cgmMM') if sel: if not mmActionOptionVar.value: print mmActionOptionVar.value mel.eval('performSetKeyframeArgList 1 {"0", "animationList"};')
def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] self.toolName = 'cgm.snapMM' IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') surfaceSnapAimModeVar = OptionVarFactory('cgmVar_SurfaceSnapAimMode', 'int') UpdateRotateOrderOnTagVar = OptionVarFactory('cgmVar_TaggingUpdateRO', 'int') self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateObjectsBuffer',defaultValue = ['']) self.LocinatorUpdateObjectsOptionVar = OptionVarFactory('cgmVar_SnapMMUpdateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.LocinatorUpdateObjectsOptionVar.name) self.SnapModeOptionVar = OptionVarFactory('cgmVar_SnapMatchMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.SnapModeOptionVar.name) panel = mc.getPanel(up = True) sel = search.selectCheck() IsClickedOptionVar.set(0) mmActionOptionVar.set(0) if mc.popupMenu('cgmMM',ex = True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex = True): mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = 'viewPanes', pmc = lambda *a: self.createUI('cgmMM'))
def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 0) mmActionOptionVar = OptionVarFactory('cgmVar_mmAction',0) panel = mc.getPanel(up = True) if panel: # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes' if 'MayaWindow' in mc.panel(panel,q = True,ctl = True): panel = 'viewPanes' sel = search.selectCheck() IsClickedOptionVar.set(0) mmActionOptionVar.set(0) if mc.popupMenu('cgmMM',ex = True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex = True): try: mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel, pmc = lambda *a: self.createUI('cgmMM')) except: guiFactory.warning('Exception on set key marking menu') mel.eval('performSetKeyframeArgList 1 {"0", "animationList"};')
def __init__( self): self.toolName = 'cgm.bufferTools' self.description = 'This is a series of tools for working with cgm Buffers' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.version = __version__ self.optionVars = [] self.activeObjectBuffersOptionVar = OptionVarFactory('cgmVar_activeObjectBuffers','string') guiFactory.appendOptionVarList(self,'cgmVar_activeObjectBuffers') self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] self.objectBuffers = [] bufferToolsLib.updateObjectBuffers(self) #Menu self.setupVariables self.UI_OptionsMenu = MelMenu( l='Options', pmc=self.buildOptionsMenu) self.UI_HelpMenu = MelMenu( l='Help', pmc=self.buildHelpMenu) self.ShowHelpOption = mc.optionVar( q='cgmVar_AnimToolsShowHelp' ) #GUI self.Main_buildLayout(self) self.show()
def buildAttributeTool(self,parent,vis=True): OptionList = ['Tools','Manager','Utilities'] RadioCollectionName ='AttributeMode' RadioOptionList = 'AttributeModeSelectionChoicesList' ShowHelpOption = mc.optionVar( q='cgmVar_TDToolsShowHelp' ) self.AttributeModeOptionVar = OptionVarFactory( 'cgmVar_AttributeMode',defaultValue = OptionList[0]) MelSeparator(parent,ut = 'cgmUIHeaderTemplate',h=5) #Mode Change row self.ModeSetRow = MelHLayout(parent,ut='cgmUISubTemplate',padding = 0) MelLabel(self.ModeSetRow, label = 'Choose Mode: ',align='right') self.RadioCollectionName = MelRadioCollection() self.RadioOptionList = [] #build our sub section options self.ContainerList = [] self.ContainerList.append( self.buildAttributeEditingTool(parent,vis=False) ) self.ContainerList.append( self.buildAttributeManagerTool( parent,vis=False) ) self.ContainerList.append( self.buildAttributeUtilitiesTool( parent,vis=False) ) for item in OptionList: self.RadioOptionList.append(self.RadioCollectionName.createButton(self.ModeSetRow,label=item, onCommand = Callback(guiFactory.toggleModeState,item,OptionList,self.AttributeModeOptionVar.name,self.ContainerList))) self.ModeSetRow.layout() mc.radioCollection(self.RadioCollectionName,edit=True, sl=self.RadioOptionList[OptionList.index(self.AttributeModeOptionVar.value)])
def killUI(): IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') if mc.popupMenu('cgmMM', ex=True): mc.deleteUI('cgmMM') IsClickedOptionVar.set(0) mmActionOptionVar.set(0)
def setupVariables(self): self.SortModifyOptionVar = OptionVarFactory('cgmVar_attrToolsSortModfiy', defaultValue = 0) guiFactory.appendOptionVarList(self,self.SortModifyOptionVar.name) self.HideTransformsOptionVar = OptionVarFactory('cgmVar_attrToolsHideTransform', defaultValue = 0) guiFactory.appendOptionVarList(self,self.HideTransformsOptionVar.name) self.HideUserDefinedOptionVar = OptionVarFactory('cgmVar_attrToolsHideUserDefined', defaultValue = 0) guiFactory.appendOptionVarList(self,self.HideUserDefinedOptionVar.name) self.HideParentAttrsOptionVar = OptionVarFactory('cgmVar_attrToolsHideParentAttrs', defaultValue = 0) guiFactory.appendOptionVarList(self,self.HideParentAttrsOptionVar.name) self.HideCGMAttrsOptionVar = OptionVarFactory('cgmVar_attrToolsHideCGMAttrs', defaultValue = 1) guiFactory.appendOptionVarList(self,self.HideCGMAttrsOptionVar.name) self.HideNonstandardOptionVar = OptionVarFactory('cgmVar_attrToolsHideNonStandard', defaultValue = 1) guiFactory.appendOptionVarList(self,self.HideNonstandardOptionVar.name) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_attrToolsShowHelp', defaultValue = 0) guiFactory.appendOptionVarList(self,self.ShowHelpOptionVar.name) self.SourceObjectOptionVar = OptionVarFactory('cgmVar_AttributeSourceObject', defaultValue= '') guiFactory.appendOptionVarList(self,self.SourceObjectOptionVar.name) self.CopyAttrModeOptionVar = OptionVarFactory('cgmVar_CopyAttributeMode', defaultValue = 0) guiFactory.appendOptionVarList(self,self.CopyAttrModeOptionVar.name) self.CopyAttrOptionsOptionVar = OptionVarFactory('cgmVar_CopyAttributeOptions', defaultValue = 1) guiFactory.appendOptionVarList(self,self.CopyAttrOptionsOptionVar.name) self.TransferValueOptionVar = OptionVarFactory('cgmVar_AttributeTransferValueState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferValueOptionVar.name) self.TransferIncomingOptionVar = OptionVarFactory('cgmVar_AttributeTransferInConnectionState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferIncomingOptionVar.name) self.TransferOutgoingOptionVar = OptionVarFactory('cgmVar_AttributeTransferOutConnectionState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferOutgoingOptionVar.name) self.TransferKeepSourceOptionVar = OptionVarFactory('cgmVar_AttributeTransferKeepSourceState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferKeepSourceOptionVar.name) self.TransferConvertStateOptionVar = OptionVarFactory('cgmVar_AttributeTransferConvertState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferConvertStateOptionVar.name) self.TransferDriveSourceStateOptionVar = OptionVarFactory('cgmVar_AttributeTransferConnectToSourceState', defaultValue = 0) guiFactory.appendOptionVarList(self,self.TransferDriveSourceStateOptionVar.name) self.CreateAttrTypeOptionVar = OptionVarFactory('cgmVar_AttrCreateType',defaultValue='') guiFactory.appendOptionVarList(self,self.CreateAttrTypeOptionVar.name) self.DebugModeOptionVar = OptionVarFactory('cgmVar_AttrToolsDebug',defaultValue=0) guiFactory.appendOptionVarList(self,self.DebugModeOptionVar.name)
def setupVariables(self): self.LocinatorUpdateObjectsOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateMode', defaultValue=0) guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorUpdateMode') self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=['']) guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorUpdateObjectsBuffer') if not mc.optionVar(ex='cgmVar_ForceBoundingBoxState'): mc.optionVar(iv=('cgmVar_ForceBoundingBoxState', 0)) if not mc.optionVar(ex='cgmVar_LocinatorShowHelp'): mc.optionVar(iv=('cgmVar_LocinatorShowHelp', 0)) if not mc.optionVar(ex='cgmVar_LocinatorCurrentFrameOnly'): mc.optionVar(iv=('cgmVar_LocinatorCurrentFrameOnly', 0)) if not mc.optionVar(ex='cgmVar_LocinatorBakingMode'): mc.optionVar(iv=('cgmVar_LocinatorBakingMode', 0)) guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorShowHelp')
def setupVariables(self): self.PuppetModeOptionVar = OptionVarFactory('cgmVar_PuppetCreateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.PuppetModeOptionVar.name) self.PuppetAimOptionVar = OptionVarFactory('cgmVar_PuppetAimAxis',defaultValue = 2) guiFactory.appendOptionVarList(self,self.PuppetAimOptionVar.name) self.PuppetUpOptionVar = OptionVarFactory('cgmVar_PuppetUpAxis',defaultValue = 1) guiFactory.appendOptionVarList(self,self.PuppetUpOptionVar.name) self.PuppetOutOptionVar = OptionVarFactory('cgmVar_PuppetOutAxis',defaultValue = 0) guiFactory.appendOptionVarList(self,self.PuppetOutOptionVar.name) self.ActiveObjectSetsOptionVar = OptionVarFactory('cgmVar_activeObjectSets',defaultValue = ['']) self.ActiveRefsOptionVar = OptionVarFactory('cgmVar_activeRefs',defaultValue = ['']) self.ActiveTypesOptionVar = OptionVarFactory('cgmVar_activeTypes',defaultValue = ['']) self.SetToolsModeOptionVar = OptionVarFactory('cgmVar_puppetBoxMode', defaultValue = 0) self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue = 0) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_puppetBoxShowHelp', defaultValue = 0) self.MaintainLocalSetGroupOptionVar = OptionVarFactory('cgmVar_MaintainLocalSetGroup', defaultValue = 1) self.HideSetGroupOptionVar = OptionVarFactory('cgmVar_HideSetGroups', defaultValue = 1) self.HideAnimLayerSetsOptionVar = OptionVarFactory('cgmVar_HideAnimLayerSets', defaultValue = 1) self.HideMayaSetsOptionVar = OptionVarFactory('cgmVar_HideMayaSets', defaultValue = 1) self.dockOptionVar = OptionVarFactory('cgmVar_PuppetBoxDock', defaultValue = 1) guiFactory.appendOptionVarList(self,self.ActiveObjectSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveRefsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveTypesOptionVar.name) guiFactory.appendOptionVarList(self,self.SetToolsModeOptionVar.name) guiFactory.appendOptionVarList(self,self.ShowHelpOptionVar.name) guiFactory.appendOptionVarList(self,self.KeyTypeOptionVar.name) guiFactory.appendOptionVarList(self,self.HideSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.MaintainLocalSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.HideAnimLayerSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.HideMayaSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.dockOptionVar.name) self.DebugModeOptionVar = OptionVarFactory('cgmVar_PuppetBoxDebug',defaultValue=0) guiFactory.appendOptionVarList(self,self.DebugModeOptionVar.name)
def killUI(): IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') if mc.popupMenu('cgmMM',ex = True): mc.deleteUI('cgmMM') IsClickedOptionVar.set(0) mmActionOptionVar.set(0)
def killUI(): IsClickedOptionVar = OptionVarFactory("cgmVar_IsClicked", "int") mmActionOptionVar = OptionVarFactory("cgmVar_mmAction", "int") if mc.popupMenu("cgmMM", ex=True): mc.deleteUI("cgmMM") IsClickedOptionVar.set(0) mmActionOptionVar.set(0)
def setupVariables(self): self.ActiveObjectSetsOptionVar = OptionVarFactory('cgmVar_activeObjectSets',defaultValue = ['']) self.ActiveRefsOptionVar = OptionVarFactory('cgmVar_activeRefs',defaultValue = ['']) self.ActiveTypesOptionVar = OptionVarFactory('cgmVar_activeTypes',defaultValue = ['']) self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue = 0) self.HideSetGroupOptionVar = OptionVarFactory('cgmVar_HideSetGroups', defaultValue = 1) self.HideNonQssOptionVar = OptionVarFactory('cgmVar_HideNonQss', defaultValue = 1) self.HideAnimLayerSetsOptionVar = OptionVarFactory('cgmVar_HideAnimLayerSets', defaultValue = 1) self.HideMayaSetsOptionVar = OptionVarFactory('cgmVar_HideMayaSets', defaultValue = 1) guiFactory.appendOptionVarList(self,self.ActiveObjectSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveRefsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveTypesOptionVar.name) guiFactory.appendOptionVarList(self,self.KeyTypeOptionVar.name) guiFactory.appendOptionVarList(self,self.HideSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.HideNonQssOptionVar.name) guiFactory.appendOptionVarList(self,self.HideAnimLayerSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.HideMayaSetsOptionVar.name)
def buildAttrConversionRow(self,parent): #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Attr type row #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> self.attrConvertTypes = ['string','float','int','bool','enum','message'] self.attrConvertShortTypes = ['str','float','int','bool','enum','msg'] self.ConvertAttrTypeRadioCollection = MelRadioCollection() self.ConvertAttrTypeRadioCollectionChoices = [] self.ConvertAttrTypeOptionVar = OptionVarFactory('cgmVar_ActiveAttrConversionState','int') guiFactory.appendOptionVarList(self,self.ConvertAttrTypeOptionVar.name) self.ConvertAttrTypeOptionVar.set(0) #build our sub section options self.AttrConvertRow = MelHLayout(self.containerName,ut='cgmUISubTemplate',padding = 5) for cnt,item in enumerate(self.attrConvertTypes): self.ConvertAttrTypeRadioCollectionChoices.append(self.ConvertAttrTypeRadioCollection.createButton(self.AttrConvertRow,label=self.attrConvertShortTypes[cnt], onCommand = Callback(attrToolsLib.uiConvertLoadedAttr,self,item))) MelSpacer(self.AttrConvertRow,w=2) self.AttrConvertRow.layout()
class puppetBoxClass(BaseMelWindow): from cgm.lib import guiFactory guiFactory.initializeTemplates() USE_Template = 'cgmUITemplate' WINDOW_NAME = 'cgmPuppetBoxWindow' WINDOW_TITLE = 'cgm.puppetBox - %s'%__version__ DEFAULT_SIZE = 250, 400 DEFAULT_MENU = None RETAIN = True MIN_BUTTON = True MAX_BUTTON = False FORCE_DEFAULT_SIZE = False #always resets the size of the window when its re-created global cgmPuppet def __init__( self): self.toolName = 'cgm.puppetBox' self.description = 'This is a series of tools for working with cgm Sets' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.dockCnt = 'cgmPuppetBoxDoc' self.version = __version__ self.optionVars = [] self.scenePuppets = [] self.Puppet = False self.PuppetBridge = {} self.puppetStateOptions = ['define'] self.puppetStateOptions.extend(ModuleFactory.moduleStates) #self.addModules = ['Spine','Leg','Arm','Limb','Finger','Foot','Neck','Head','Spine'] self.addModules = ['Segment'] self.moduleFrames = {} self.moduleBaseNameFields = {} self.moduleHandleFields = {} self.moduleRollFields = {} self.moduleCurveFields = {} self.moduleStiffIndexFields = {} self.moduleDirectionMenus = {} self.modulePositionMenus = {} self.moduleDirections = ['none','left','right'] self.modulePositions = ['none','front','rear','forward','back','top','bottom'] self.setModes = ['<<< All Loaded Sets >>>','<<< Active Sets >>>'] self.scenePuppets = modules.returnPuppetObjects() self.UI_StateRows = {'define':[],'template':[],'skeleton':[],'rig':[]} self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] #Menu self.setupVariables() self.UI_PuppetMenu = MelMenu( l='Puppet', pmc=self.buildPuppetMenu) self.UI_AddModulesMenu = MelMenu( l='Add', pmc=self.buildAddModulesMenu) self.UI_OptionsMenu = MelMenu( l='Options', pmc=self.buildOptionsMenu) self.UI_HelpMenu = MelMenu( l='Help', pmc=self.buildHelpMenu) self.ShowHelpOption = mc.optionVar( q='cgmVar_AnimToolsShowHelp' ) #GUI self.Main_buildLayout(self) if self.Puppet: puppetBoxLib.updateUIPuppet(self) if self.scenePuppets: puppetBoxLib.activatePuppet(self,self.scenePuppets[0]) #==================== # Show and Dock #==================== #Maya2011 QT docking - from Red9's examples try: #'Maya2011 dock delete' if mc.dockControl(self.dockCnt, exists=True): mc.deleteUI(self.dockCnt, control=True) except: pass if self.dockOptionVar.value: try: allowedAreas = ['right', 'left'] mc.dockControl(self.dockCnt, area='right', label=self.WINDOW_TITLE, content=self.WINDOW_NAME, floating=False, allowedArea=allowedAreas, width=400) except: #Dock failed, opening standard Window self.show() else:self.show() def setupVariables(self): self.PuppetModeOptionVar = OptionVarFactory('cgmVar_PuppetCreateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.PuppetModeOptionVar.name) self.PuppetAimOptionVar = OptionVarFactory('cgmVar_PuppetAimAxis',defaultValue = 2) guiFactory.appendOptionVarList(self,self.PuppetAimOptionVar.name) self.PuppetUpOptionVar = OptionVarFactory('cgmVar_PuppetUpAxis',defaultValue = 1) guiFactory.appendOptionVarList(self,self.PuppetUpOptionVar.name) self.PuppetOutOptionVar = OptionVarFactory('cgmVar_PuppetOutAxis',defaultValue = 0) guiFactory.appendOptionVarList(self,self.PuppetOutOptionVar.name) self.ActiveObjectSetsOptionVar = OptionVarFactory('cgmVar_activeObjectSets',defaultValue = ['']) self.ActiveRefsOptionVar = OptionVarFactory('cgmVar_activeRefs',defaultValue = ['']) self.ActiveTypesOptionVar = OptionVarFactory('cgmVar_activeTypes',defaultValue = ['']) self.SetToolsModeOptionVar = OptionVarFactory('cgmVar_puppetBoxMode', defaultValue = 0) self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue = 0) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_puppetBoxShowHelp', defaultValue = 0) self.MaintainLocalSetGroupOptionVar = OptionVarFactory('cgmVar_MaintainLocalSetGroup', defaultValue = 1) self.HideSetGroupOptionVar = OptionVarFactory('cgmVar_HideSetGroups', defaultValue = 1) self.HideAnimLayerSetsOptionVar = OptionVarFactory('cgmVar_HideAnimLayerSets', defaultValue = 1) self.HideMayaSetsOptionVar = OptionVarFactory('cgmVar_HideMayaSets', defaultValue = 1) self.dockOptionVar = OptionVarFactory('cgmVar_PuppetBoxDock', defaultValue = 1) guiFactory.appendOptionVarList(self,self.ActiveObjectSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveRefsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveTypesOptionVar.name) guiFactory.appendOptionVarList(self,self.SetToolsModeOptionVar.name) guiFactory.appendOptionVarList(self,self.ShowHelpOptionVar.name) guiFactory.appendOptionVarList(self,self.KeyTypeOptionVar.name) guiFactory.appendOptionVarList(self,self.HideSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.MaintainLocalSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.HideAnimLayerSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.HideMayaSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.dockOptionVar.name) self.DebugModeOptionVar = OptionVarFactory('cgmVar_PuppetBoxDebug',defaultValue=0) guiFactory.appendOptionVarList(self,self.DebugModeOptionVar.name) def updateModulesUI(self): def optionMenuSet(item): print item #puppetBoxLib.uiModuleSetCGMTag(self,tag,item,index) """ i = self.setModes.index(item) self.SetToolsModeOptionVar.set( i ) self.setMode = i""" #deleteExisting self.ModuleListColumn.clear() if self.Puppet: for i,b in enumerate(self.Puppet.ModulesBuffer.bufferList): # NEED to get colors #Build label for Frame self.moduleFrames[i] = MelFrameLayout(self.ModuleListColumn,l='', collapse=True, collapsable=True, marginHeight=0, marginWidth=0, bgc = dictionary.guiDirectionColors['center']) puppetBoxLib.uiModuleUpdateFrameLabel(self,i) #Build Naming Row tmpNameRow = MelFormLayout(self.moduleFrames[i], h=25, ) tmpNameLabel = MelLabel(tmpNameRow,l='base:',align='right') self.moduleBaseNameFields[i] = MelTextField(tmpNameRow,text=self.Puppet.Module[i].nameBase or '', ec = Callback(puppetBoxLib.uiUpdateBaseName,self,i), w=50, h=20) tmpDirLabel = MelLabel(tmpNameRow,l='dir:',align='right') self.moduleDirectionMenus[i] = MelOptionMenu(tmpNameRow, cc = Callback(puppetBoxLib.uiModuleOptionMenuSet,self,self.moduleDirectionMenus,self.moduleDirections,'cgmDirection',i)) for cnt,o in enumerate(self.moduleDirections): self.moduleDirectionMenus[i].append(o) if o == self.Puppet.Module[i].ModuleNull.cgm['cgmDirection']: self.moduleDirectionMenus[i](edit = True, select = cnt + 1) tmpPosLabel = MelLabel(tmpNameRow,l='pos:',align='right') self.modulePositionMenus[i] = MelOptionMenu(tmpNameRow, cc = Callback(puppetBoxLib.uiModuleOptionMenuSet,self,self.modulePositionMenus,self.modulePositions,'cgmPosition',i)) for cnt,o in enumerate(self.modulePositions): self.modulePositionMenus[i].append(o) if o == self.Puppet.Module[i].ModuleNull.cgm['cgmPosition']: self.modulePositionMenus[i](edit = True, select = cnt + 1) mc.formLayout(tmpNameRow, edit = True, af = [(tmpNameLabel, "left", 10), (self.modulePositionMenus[i],"right",10)], ac = [(self.moduleBaseNameFields[i],"left",5,tmpNameLabel), (self.moduleBaseNameFields[i],"right",5,tmpDirLabel), (tmpDirLabel,"right",5,self.moduleDirectionMenus[i]), (self.moduleDirectionMenus[i],"right",5,tmpPosLabel), (tmpPosLabel,"right",5,self.modulePositionMenus[i] ), ]) #>>>>>>>>>>>>>>>>>>>>> if self.Puppet.Module[i].moduleClass == 'Limb': #Build Int Settings Row tmpIntRow = MelHSingleStretchLayout(self.moduleFrames[i], h=25, ) tmpIntRow.setStretchWidget(MelSpacer(tmpIntRow,w=5)) MelLabel(tmpIntRow,l='Handles:') self.moduleHandleFields[i] = MelIntField(tmpIntRow, v = self.Puppet.Module[i].optionHandles.value, bgc = dictionary.returnStateColor('normal'), ec = Callback(puppetBoxLib.uiModuleUpdateIntAttrFromField,self,self.moduleHandleFields,'optionHandles',i), h = 20, w = 35) MelLabel(tmpIntRow,l='Roll:') self.moduleRollFields[i] = MelIntField(tmpIntRow, v = self.Puppet.Module[i].optionRollJoints.value, bgc = dictionary.returnStateColor('normal'), ec = Callback(puppetBoxLib.uiModuleUpdateIntAttrFromField,self,self.moduleRollFields,'optionRollJoints',i), h = 20, w = 35) MelLabel(tmpIntRow,l='Stiff Index:') self.moduleStiffIndexFields[i] = MelIntField(tmpIntRow, v = self.Puppet.Module[i].optionStiffIndex.value, bgc = dictionary.returnStateColor('normal'), ec = Callback(puppetBoxLib.uiModuleUpdateIntAttrFromField,self,self.moduleStiffIndexFields,'optionStiffIndex',i), h = 20, w = 35) MelLabel(tmpIntRow,l='Curve:') self.moduleCurveFields[i] = MelIntField(tmpIntRow, v = self.Puppet.Module[i].optionCurveDegree.value, bgc = dictionary.returnStateColor('normal'), ec = Callback(puppetBoxLib.uiModuleUpdateIntAttrFromField,self,self.moduleCurveFields,'optionCurveDegree',i), h = 20, w = 35) MelSpacer(tmpIntRow,w=10) tmpIntRow.layout() #PopUp Menu! popUpMenu = MelPopupMenu(self.moduleFrames[i],button = 3) MelMenuItem(popUpMenu, label = "cls: %s"%self.Puppet.Module[i].moduleClass, enable = False) #Parent/MIrror MelMenuItem(popUpMenu, label = "Set Parent>", enable = False) MelMenuItem(popUpMenu, label = "Set Mirror>", enable = False) if self.Puppet.Module[i].moduleClass == 'Limb': MelMenuItem(popUpMenu, label = 'FK', cb = self.Puppet.Module[i].optionFK.value, c = Callback(puppetBoxLib.uiModuleToggleBool,self,'optionFK',i)) MelMenuItem(popUpMenu, label = 'IK', cb = self.Puppet.Module[i].optionIK.value, c = Callback(puppetBoxLib.uiModuleToggleBool,self,'optionIK',i)) MelMenuItem(popUpMenu, label = 'Stretchy', cb = self.Puppet.Module[i].optionStretchy.value, c = Callback(puppetBoxLib.uiModuleToggleBool,self,'optionStretchy',i)) MelMenuItem(popUpMenu, label = 'Bendy', cb = self.Puppet.Module[i].optionBendy.value, c = Callback(puppetBoxLib.uiModuleToggleBool,self,'optionBendy',i)) MelMenuItemDiv(popUpMenu) # Object Aim Menu ObjectAimMenu = MelMenuItem(popUpMenu, l='Aim:', subMenu=True) self.ObjectAimCollection = MelRadioMenuCollection() for index,axis in enumerate(dictionary.axisDirectionsByString): if self.Puppet.Module[i].optionAimAxis.get() == index: checkState = True else: checkState = False self.ObjectAimCollection.createButton(ObjectAimMenu,l=axis, c= Callback(puppetBoxLib.doSetAxisAndUpdateModule,self,functions.doSetAimAxis,self.Puppet.Module[i],index), rb = checkState) ObjectUpMenu = MelMenuItem(popUpMenu, l='Up:', subMenu=True) self.ObjectUpCollection = MelRadioMenuCollection() for index,axis in enumerate(dictionary.axisDirectionsByString): if self.Puppet.Module[i].optionUpAxis.get() == index: checkState = True else: checkState = False self.ObjectUpCollection.createButton(ObjectUpMenu,l=axis, c= Callback(puppetBoxLib.doSetAxisAndUpdateModule,self,functions.doSetUpAxis,self.Puppet.Module[i],index), rb = checkState) ObjectOutMenu = MelMenuItem(popUpMenu, l='Out:', subMenu=True) self.ObjectOutCollection = MelRadioMenuCollection() for index,axis in enumerate(dictionary.axisDirectionsByString): if self.Puppet.Module[i].optionOutAxis.get() == index: checkState = True else: checkState = False self.ObjectOutCollection.createButton(ObjectOutMenu,l=axis, c= Callback(puppetBoxLib.doSetAxisAndUpdateModule,self,functions.doSetOutAxis,self.Puppet.Module[i],index), rb = checkState) ObjectOutMenu = MelMenuItem(popUpMenu, l='Copy from Parent', c= Callback(puppetBoxLib.doCopyAxisFromParent,self,self.Puppet.Module[i])) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu , label = 'Remove', c = Callback(puppetBoxLib.doRemoveModule,self,i)) MelMenuItem(popUpMenu , label = 'Delete', c = Callback(puppetBoxLib.doDeleteModule,self,i)) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Menus #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildPuppetMenu( self, *a ): self.UI_PuppetMenu.clear() #>>> Puppet Options MelMenuItem( self.UI_PuppetMenu, l="New", c=lambda *a:puppetBoxLib.doPuppetCreate(self)) #Build load menu self.scenePuppets = modules.returnPuppetObjects() loadMenu = MelMenuItem( self.UI_PuppetMenu, l='Pick Puppet:', subMenu=True) if self.scenePuppets: for i,m in enumerate(self.scenePuppets): MelMenuItem( loadMenu, l="%s"%m, c= Callback(puppetBoxLib.activatePuppet,self,m)) else: MelMenuItem( loadMenu, l="None found") if self.Puppet: MelMenuItemDiv( self.UI_PuppetMenu ) MelMenuItem( self.UI_PuppetMenu, l="Initialize", c=lambda *a:puppetBoxLib.initializePuppet(self)) if not self.Puppet.refState: MelMenuItem( self.UI_PuppetMenu, l="Verify", c=lambda *a:puppetBoxLib.verifyPuppet(self)) MelMenuItem( self.UI_PuppetMenu, l="Delete", c=lambda *a:puppetBoxLib.deletePuppet(self)) #>>> Reset Options MelMenuItemDiv( self.UI_PuppetMenu ) MelMenuItem( self.UI_PuppetMenu, l="Reload", c=lambda *a: self.reload()) MelMenuItem( self.UI_PuppetMenu, l="Reset", c=lambda *a: self.reset()) def buildAddModulesMenu( self, *a ): self.UI_AddModulesMenu.clear() for i,m in enumerate(self.addModules): MelMenuItem( self.UI_AddModulesMenu, l="%s"%m, c=lambda *a:puppetBoxLib.addModule(self,m)) MelMenuItemDiv( self.UI_AddModulesMenu ) def buildOptionsMenu( self, *a ): self.UI_OptionsMenu.clear() MelMenuItem( self.UI_OptionsMenu, l="Force module menu reload", c=lambda *a:puppetBoxLib.uiForceModuleUpdateUI(self)) def reset(self): Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars,run)) def reload(self): run() def buildHelpMenu( self, *a ): self.UI_HelpMenu.clear() MelMenuItem( self.UI_HelpMenu, l="Show Help", cb=self.ShowHelpOptionVar.value, c= lambda *a: self.do_showHelpToggle()) MelMenuItem( self.UI_HelpMenu, l="Print Set Report", c=lambda *a: self.printReport() ) MelMenuItem( self.UI_HelpMenu, l="Print Tools Help", c=lambda *a: self.printHelp() ) MelMenuItemDiv( self.UI_HelpMenu ) MelMenuItem( self.UI_HelpMenu, l="About", c=lambda *a: self.showAbout() ) MelMenuItem( self.UI_HelpMenu, l="Debug", cb=self.DebugModeOptionVar.value, c= lambda *a: self.DebugModeOptionVar.toggle()) def do_showHelpToggle( self): guiFactory.toggleMenuShowState(self.ShowHelpOptionVar.value,self.helpBlurbs) self.ShowHelpOptionVar.toggle() def showAbout(self): window = mc.window( title="About", iconName='About', ut = 'cgmUITemplate',resizeToFitChildren=True ) mc.columnLayout( adjustableColumn=True ) guiFactory.header(self.toolName,overrideUpper = True) mc.text(label='>>>A Part of the cgmTools Collection<<<', ut = 'cgmUIInstructionsTemplate') guiFactory.headerBreak() guiFactory.lineBreak() descriptionBlock = guiFactory.textBlock(self.description) guiFactory.lineBreak() mc.text(label=('%s%s' %('Written by: ',self.author))) mc.text(label=('%s%s%s' %('Copyright ',self.owner,', 2011'))) guiFactory.lineBreak() mc.text(label='Version: %s' % self.version) mc.text(label='') guiFactory.doButton('Visit Tool Webpage', 'import webbrowser;webbrowser.open(" http://www.cgmonks.com/tools/maya-tools/puppetBox/")') guiFactory.doButton('Close', 'import maya.cmds as mc;mc.deleteUI(\"' + window + '\", window=True)') mc.setParent( '..' ) mc.showWindow( window ) def printHelp(self): help(puppetBoxLib) def printReport(self): puppetBoxLib.printReport(self) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Layouts #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def Main_buildLayout(self,parent): def modeSet( item ): i = self.setModes.index(item) self.SetToolsModeOptionVar.set( i ) self.setMode = i MainForm = MelFormLayout(parent) TopSection = MelColumnLayout(MainForm) SetHeader = guiFactory.header('Puppet') #>>> Top Section #Report self.puppetReport = MelLabel(TopSection, bgc = dictionary.returnStateColor('help'), align = 'center', label = '...', h=20) MelSeparator(TopSection,ut='cgmUITemplate',h=5) #Edit name and state mode buttons MasterPuppetRow = MelHSingleStretchLayout(TopSection,padding = 5) MelSpacer(MasterPuppetRow,w=5) self.MasterPuppetTF = MelTextField(MasterPuppetRow, bgc = [1,1,1], ec = lambda *a:puppetBoxLib.updatePuppetName(self)) MasterPuppetRow.setStretchWidget(self.MasterPuppetTF) self.puppetStateButtonsDict = {} for i,s in enumerate(self.puppetStateOptions): self.puppetStateButtonsDict[i] = guiFactory.doButton2(MasterPuppetRow,s.capitalize(), "print '%s'"%s, enable = False) MelSpacer(MasterPuppetRow,w=20) MasterPuppetRow.layout() #MelSeparator(TopSection,ut='cgmUITemplate',h=2) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Define State Rows #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #Initial State Mode Row self.PuppetModeCollection = MelRadioCollection() self.PuppetModeCollectionChoices = [] self.InitialStateModeRow = MelHSingleStretchLayout(TopSection,padding = 2,vis=False) MelSpacer(self.InitialStateModeRow,w=5) MelLabel(self.InitialStateModeRow,l='Template Modes') Spacer = MelSeparator(self.InitialStateModeRow,w=10) for i,item in enumerate(CharacterTypes): self.PuppetModeCollectionChoices.append(self.PuppetModeCollection.createButton(self.InitialStateModeRow,label=item, onCommand = Callback(puppetBoxLib.setPuppetBaseMode,self,i))) MelSpacer(self.InitialStateModeRow,w=3) self.InitialStateModeRow.setStretchWidget( Spacer ) MelSpacer(self.InitialStateModeRow,w=2) self.InitialStateModeRow.layout() mc.radioCollection(self.PuppetModeCollection ,edit=True,sl= (self.PuppetModeCollectionChoices[ (self.PuppetModeOptionVar.value) ])) self.UI_StateRows['define'].append(self.InitialStateModeRow) self.AxisFrame = MelFrameLayout(TopSection,label = 'Axis',vis=False, collapse=True, collapsable=True, ut = 'cgmUIHeaderTemplate') self.UI_StateRows['define'].append(self.AxisFrame) MelSeparator(TopSection,style='none',h=5) #Aim Axis Mode Row self.AimAxisCollection = MelRadioCollection() self.AimAxisCollectionChoices = [] self.AimAxisRow = MelHSingleStretchLayout(self.AxisFrame,padding = 2,vis=False) MelSpacer(self.AimAxisRow,w=5) MelLabel(self.AimAxisRow,l='Aim ') Spacer = MelSeparator(self.AimAxisRow,w=10) for i,item in enumerate(axisDirectionsByString): self.AimAxisCollectionChoices.append(self.AimAxisCollection.createButton(self.AimAxisRow,label=item, onCommand = Callback(puppetBoxLib.setPuppetAxisAim,self,i))) MelSpacer(self.AimAxisRow,w=3) self.AimAxisRow.setStretchWidget( Spacer ) MelSpacer(self.AimAxisRow,w=2) self.AimAxisRow.layout() #Up Axis Mode Row self.UpAxisCollection = MelRadioCollection() self.UpAxisCollectionChoices = [] self.UpAxisRow = MelHSingleStretchLayout(self.AxisFrame,padding = 2,vis=False) MelSpacer(self.UpAxisRow,w=5) MelLabel(self.UpAxisRow,l='Up ') Spacer = MelSeparator(self.UpAxisRow,w=10) for i,item in enumerate(axisDirectionsByString): self.UpAxisCollectionChoices.append(self.UpAxisCollection.createButton(self.UpAxisRow,label=item, onCommand = Callback(puppetBoxLib.setPuppetAxisUp,self,i))) MelSpacer(self.UpAxisRow,w=3) self.UpAxisRow.setStretchWidget( Spacer ) MelSpacer(self.UpAxisRow,w=2) self.UpAxisRow.layout() #Out Axis Mode Row self.OutAxisCollection = MelRadioCollection() self.OutAxisCollectionChoices = [] self.OutAxisRow = MelHSingleStretchLayout(self.AxisFrame,padding = 2,vis=False) MelSpacer(self.OutAxisRow,w=5) MelLabel(self.OutAxisRow,l='Out ') Spacer = MelSeparator(self.OutAxisRow,w=10) for i,item in enumerate(axisDirectionsByString): self.OutAxisCollectionChoices.append(self.OutAxisCollection.createButton(self.OutAxisRow,label=item, onCommand = Callback(puppetBoxLib.setPuppetAxisOut,self,i))) MelSpacer(self.OutAxisRow,w=3) self.OutAxisRow.setStretchWidget( Spacer ) MelSpacer(self.OutAxisRow,w=2) self.OutAxisRow.layout() #Set toggles on menu mc.radioCollection(self.AimAxisCollection ,edit=True,sl= (self.AimAxisCollectionChoices[ (self.PuppetAimOptionVar.value) ])) mc.radioCollection(self.UpAxisCollection ,edit=True,sl= (self.UpAxisCollectionChoices[ (self.PuppetUpOptionVar.value) ])) mc.radioCollection(self.OutAxisCollection ,edit=True,sl= (self.OutAxisCollectionChoices[ (self.PuppetOutOptionVar.value) ])) #Initial State Button Row self.InitialStateButtonRow = MelHLayout(TopSection, h = 20,vis=False,padding = 5) guiFactory.doButton2(self.InitialStateButtonRow,'Add Geo', lambda *a:puppetBoxLib.doAddGeo(self)) guiFactory.doButton2(self.InitialStateButtonRow,'Build Size Template', lambda *a:puppetBoxLib.doBuildSizeTemplate(self)) self.InitialStateButtonRow.layout() self.UI_StateRows['define'].append(self.InitialStateButtonRow) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Multi Module #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> All Sets menu AllModulesRow = MelFormLayout(MainForm,height = 20) activeState = True i = 1 tmpActive = MelCheckBox(AllModulesRow, annotation = 'Sets all sets active', value = activeState, onCommand = Callback(puppetBoxLib.doSetAllSetsAsActive,self), offCommand = Callback(puppetBoxLib.doSetAllSetsAsInactive,self)) tmpSel = guiFactory.doButton2(AllModulesRow, ' s ', 'Select All Loaded/Active Sets') # Mode toggle box self.ModuleModeOptionMenu = MelOptionMenu(AllModulesRow, cc = modeSet) tmpKey = guiFactory.doButton2(AllModulesRow, ' k ', 'Key All Sets') tmpDeleteKey = guiFactory.doButton2(AllModulesRow, ' d ', 'Delete All Set Keys') tmpReset = guiFactory.doButton2(AllModulesRow, ' r ', 'Reset All Set Keys') mc.formLayout(AllModulesRow, edit = True, af = [(tmpActive, "left", 10), (tmpReset,"right",10)], ac = [(tmpSel,"left",0,tmpActive), (self.ModuleModeOptionMenu,"left",4,tmpSel), (self.ModuleModeOptionMenu,"right",4,tmpKey), (tmpKey,"right",2,tmpDeleteKey), (tmpDeleteKey,"right",2,tmpReset) ]) #>>> Sets building section allPopUpMenu = MelPopupMenu(self.ModuleModeOptionMenu ,button = 3) allCategoryMenu = MelMenuItem(allPopUpMenu, label = 'Make Type:', sm = True) #>>> Sets building section ModuleListScroll = MelScrollLayout(MainForm,cr = 1, ut = 'cgmUISubTemplate') ModuleMasterForm = MelFormLayout(ModuleListScroll) self.ModuleListColumn = MelColumnLayout(ModuleMasterForm,ut = 'cgmUIInstructionsTemplate', adj = True, rowSpacing = 2) self.helpInfo = MelLabel(MainForm, h=20, l = "Add a Puppet", ut = 'cgmUIInstructionsTemplate', al = 'center', ww = True,vis = self.ShowHelpOptionVar.value) self.helpBlurbs.extend([self.helpInfo ]) VerifyRow = guiFactory.doButton2(MainForm, 'Check Puppet', 'Create new buffer from selected buffer') ModuleMasterForm(edit = True, af = [(self.ModuleListColumn,"top",0), (self.ModuleListColumn,"left",0), (self.ModuleListColumn,"right",0), (self.ModuleListColumn,"bottom",0)]) MainForm(edit = True, af = [(TopSection,"top",0), (TopSection,"left",0), (TopSection,"right",0), (AllModulesRow,"left",0), (AllModulesRow,"right",0), (ModuleListScroll,"left",0), (ModuleListScroll,"right",0), (ModuleListScroll,"left",0), (ModuleListScroll,"right",0), (self.helpInfo,"left",8), (self.helpInfo,"right",8), (VerifyRow,"left",4), (VerifyRow,"right",4), (VerifyRow,"bottom",4)], ac = [(AllModulesRow,"top",2,TopSection), (ModuleListScroll,"top",2,AllModulesRow), (ModuleListScroll,"bottom",0,self.helpInfo), (self.helpInfo,"bottom",0,VerifyRow)], attachNone = [(VerifyRow,"top")])
class setKeyMarkingMenu(BaseMelWindow): _DEFAULT_MENU_PARENT = 'viewPanes' def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 0) mmActionOptionVar = OptionVarFactory('cgmVar_mmAction',0) panel = mc.getPanel(up = True) if panel: # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes' if 'MayaWindow' in mc.panel(panel,q = True,ctl = True): panel = 'viewPanes' sel = search.selectCheck() IsClickedOptionVar.set(0) mmActionOptionVar.set(0) if mc.popupMenu('cgmMM',ex = True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex = True): try: mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel, pmc = lambda *a: self.createUI('cgmMM')) except: guiFactory.warning('Exception on set key marking menu') mel.eval('performSetKeyframeArgList 1 {"0", "animationList"};') def setupVariables(self): self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue = 0) guiFactory.appendOptionVarList(self,self.KeyTypeOptionVar.name) self.KeyModeOptionVar = OptionVarFactory('cgmVar_KeyMode', defaultValue = 0) guiFactory.appendOptionVarList(self,self.KeyModeOptionVar.name) self.mmActionOptionVar = OptionVarFactory('cgmVar_mmAction') def createUI(self,parent): """ Create the UI """ IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked',value = 0) self.setupVariables() def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ self.mmActionOptionVar.set(1) command killUI() sel = search.selectCheck() selPair = search.checkSelectionLength(2) ShowMatch = search.matchObjectCheck() IsClickedOptionVar.set(1) mc.menu(parent,e = True, deleteAllItems = True) MelMenuItem(parent, en = sel, l = 'Reset Selected', c = lambda *a:buttonAction(animToolsLib.ml_resetChannelsCall()), rp = 'N') MelMenuItem(parent, en = sel, l = 'dragBreakdown', c = lambda *a:buttonAction(animToolsLib.ml_breakdownDraggerCall()), rp = 'S') #>>> Keying Options KeyMenu = MelMenuItem( parent, l='Key type', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyTypeOptionVar.value == 0: regKeyOption = True bdKeyOption = False else: regKeyOption = False bdKeyOption = True KeyMenuCollection.createButton(KeyMenu,l=' Reg ', c= Callback(self.toggleVarAndReset,self.KeyTypeOptionVar), rb= regKeyOption ) KeyMenuCollection.createButton(KeyMenu,l=' Breakdown ', c= Callback(self.toggleVarAndReset,self.KeyTypeOptionVar), rb= bdKeyOption ) #>>> Keying Mode KeyMenu = MelMenuItem( parent, l='Key Mode', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyModeOptionVar.value == 0: regModeOption = True cbModeOption = False else: regModeOption = False cbModeOption = True KeyMenuCollection.createButton(KeyMenu,l=' Default ', c= Callback(self.toggleVarAndReset,self.KeyModeOptionVar), rb= regModeOption ) KeyMenuCollection.createButton(KeyMenu,l=' Channelbox ', c= Callback(self.toggleVarAndReset,self.KeyModeOptionVar), rb= cbModeOption ) MelMenuItemDiv(parent) MelMenuItem(parent,l = 'autoTangent', c = lambda *a: buttonAction(mel.eval('autoTangent'))) MelMenuItem(parent,l = 'tweenMachine', c = lambda *a: buttonAction(mel.eval('tweenMachine'))) MelMenuItem(parent, l = 'cgm.animTools', c = lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItemDiv(parent) MelMenuItem(parent,l = 'ml Set Key', c = lambda *a: buttonAction(animToolsLib.ml_setKeyCall())) MelMenuItem(parent,l = 'ml Hold', c = lambda *a: buttonAction(animToolsLib.ml_holdCall())) MelMenuItem(parent,l = 'ml Delete Key', c = lambda *a: buttonAction(animToolsLib.ml_deleteKeyCall())) MelMenuItem(parent,l = 'ml Arc Tracer', c = lambda *a: buttonAction(animToolsLib.ml_arcTracerCall())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars(self.optionVars)) def toggleVarAndReset(self, optionVar): try: optionVar.toggle() self.reload() except: print "MM change var and reset failed!"
class locinatorClass(BaseMelWindow): from cgm.lib import guiFactory guiFactory.initializeTemplates() USE_Template = 'cgmUITemplate' WINDOW_NAME = 'cgmLocinatorWindow' WINDOW_TITLE = 'cgm.locinator - %s'%__version__ DEFAULT_SIZE = 180, 275 DEFAULT_MENU = None RETAIN = True MIN_BUTTON = True MAX_BUTTON = False FORCE_DEFAULT_SIZE = True #always resets the size of the window when its re-created def __init__(self): self.toolName = 'cgm.locinator' self.description = 'This tool makes locators based on selection types and provides ways to update those locators over time' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.version = __version__ self.optionVars = [] self.currentFrameOnly = True self.startFrame = '' self.endFrame = '' self.startFrameField = '' self.endFrameField = '' self.forceBoundingBoxState = False self.forceEveryFrame = False self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] self.showTimeSubMenu = False self.timeSubMenu = [] #Menu self.setupVariables() self.UI_OptionsMenu = MelMenu( l='Options', pmc=self.buildOptionsMenu) self.UI_BufferMenu = MelMenu( l = 'Buffer', pmc=self.buildBufferMenu) self.UI_HelpMenu = MelMenu( l='Help', pmc=self.buildHelpMenu) self.ShowHelpOption = mc.optionVar( q='cgmVar_LocinatorShowHelp' ) #Tabs tabs = MelTabLayout( self ) TabBasic = MelColumnLayout(tabs) TabSpecial = MelColumnLayout( tabs ) TabMatch = MelColumnLayout( tabs ) n = 0 for tab in 'Basic','Special','Match': tabs.setLabel(n,tab) n+=1 self.buildBasicLayout(TabBasic) self.buildSpecialLayout(TabSpecial) self.buildMatchLayout(TabMatch) self.show() def setupVariables(self): self.LocinatorUpdateObjectsOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,'cgmVar_LocinatorUpdateMode') self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateObjectsBuffer',defaultValue = ['']) guiFactory.appendOptionVarList(self,'cgmVar_LocinatorUpdateObjectsBuffer') self.DebugModeOptionVar = OptionVarFactory('cgmVar_LocinatorDebug',defaultValue=0) guiFactory.appendOptionVarList(self,self.DebugModeOptionVar.name) self.SnapModeOptionVar = OptionVarFactory('cgmVar_SnapMatchMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.SnapModeOptionVar.name) #Old method...clean up at some point if not mc.optionVar( ex='cgmVar_ForceBoundingBoxState' ): mc.optionVar( iv=('cgmVar_ForceBoundingBoxState', 0) ) if not mc.optionVar( ex='cgmVar_LocinatorShowHelp' ): mc.optionVar( iv=('cgmVar_LocinatorShowHelp', 0) ) if not mc.optionVar( ex='cgmVar_LocinatorCurrentFrameOnly' ): mc.optionVar( iv=('cgmVar_LocinatorCurrentFrameOnly', 0) ) if not mc.optionVar( ex='cgmVar_LocinatorBakingMode' ): mc.optionVar( iv=('cgmVar_LocinatorBakingMode', 0) ) guiFactory.appendOptionVarList(self,'cgmVar_LocinatorShowHelp') #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Menus #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildOptionsMenu( self, *a ): self.UI_OptionsMenu.clear() #>>>Match Mode MatchModeMenu = MelMenuItem( self.UI_OptionsMenu, l='Match Mode', subMenu=True) self.MatchModeOptions = ['parent','point','orient'] self.MatchModeCollection = MelRadioMenuCollection() self.MatchModeCollectionChoices = [] self.SnapModeOptionVar.update()#Incase another tool changed self.matchMode = self.SnapModeOptionVar.value for c,item in enumerate(self.MatchModeOptions): if self.matchMode == c: rbValue = True else: rbValue = False self.MatchModeCollectionChoices.append(self.MatchModeCollection.createButton(MatchModeMenu,label=item, rb = rbValue, command = Callback(self.SnapModeOptionVar.set,c))) # Placement Menu PlacementMenu = MelMenuItem( self.UI_OptionsMenu, l='Placement', subMenu=True) PlacementMenuCollection = MelRadioMenuCollection() if mc.optionVar( q='cgmVar_ForceBoundingBoxState' ) == 0: cgmOption = False pivotOption = True else: cgmOption = True pivotOption = False PlacementMenuCollection.createButton(PlacementMenu,l='Bounding Box Center', c=lambda *a: mc.optionVar( iv=('cgmVar_ForceBoundingBoxState', 1)), rb=cgmOption ) PlacementMenuCollection.createButton(PlacementMenu,l='Pivot', c=lambda *a: mc.optionVar( iv=('cgmVar_ForceBoundingBoxState', 0)), rb=pivotOption ) # Tagging options AutoloadMenu = MelMenuItem( self.UI_OptionsMenu, l='Tagging', subMenu=True) if not mc.optionVar( ex='cgmVar_TaggingUpdateRO' ): mc.optionVar( iv=('cgmVar_TaggingUpdateRO', 1) ) guiFactory.appendOptionVarList(self,'cgmVar_TaggingUpdateRO') RenameOnUpdateState = mc.optionVar( q='cgmVar_TaggingUpdateRO' ) MelMenuItem( AutoloadMenu, l="Update Rotation Order", cb= mc.optionVar( q='cgmVar_TaggingUpdateRO' ), c= lambda *a: guiFactory.doToggleIntOptionVariable('cgmVar_TaggingUpdateRO')) # Update Mode UpdateMenu = MelMenuItem( self.UI_OptionsMenu, l='Update Mode', subMenu=True) UpdateMenuCollection = MelRadioMenuCollection() if self.LocinatorUpdateObjectsOptionVar.value == 0: slMode = True bufferMode = False else: slMode = False bufferMode = True UpdateMenuCollection.createButton(UpdateMenu,l='Selected', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(0), rb=slMode ) UpdateMenuCollection.createButton(UpdateMenu,l='Buffer', c=lambda *a:self.LocinatorUpdateObjectsOptionVar.set(1), rb=bufferMode ) MelMenuItemDiv( self.UI_OptionsMenu ) MelMenuItem( self.UI_OptionsMenu, l="Reset", c=lambda *a: self.reset()) def reset(self): Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars,run)) def reload(self): run() def buildBufferMenu( self, *a ): self.UI_BufferMenu.clear() MelMenuItem( self.UI_BufferMenu, l="Define", c= lambda *a: locinatorLib.defineObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( self.UI_BufferMenu, l="Add Selected", c= lambda *a: locinatorLib.addSelectedToObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( self.UI_BufferMenu, l="Remove Selected", c= lambda *a: locinatorLib.removeSelectedFromObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv( self.UI_BufferMenu ) MelMenuItem( self.UI_BufferMenu, l="Select Members", c= lambda *a: locinatorLib.selectObjBufferMembers(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( self.UI_BufferMenu, l="Clear", c= lambda *a: locinatorLib.clearObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) def buildHelpMenu( self, *a ): self.UI_HelpMenu.clear() MelMenuItem( self.UI_HelpMenu, l="Show Help", cb=self.ShowHelpOption, c= lambda *a: self.do_showHelpToggle()) MelMenuItem( self.UI_HelpMenu, l="Print Tools Help", c=lambda *a: self.printHelp() ) MelMenuItemDiv( self.UI_HelpMenu ) MelMenuItem( self.UI_HelpMenu, l="About", c=lambda *a: self.showAbout() ) MelMenuItem( self.UI_HelpMenu, l="Debug", cb=self.DebugModeOptionVar.value, c= lambda *a: self.DebugModeOptionVar.toggle()) def do_showHelpToggle( self): guiFactory.toggleMenuShowState(self.ShowHelpOption,self.helpBlurbs) mc.optionVar( iv=('cgmVar_LocinatorShowHelp', not self.ShowHelpOption)) self.ShowHelpOption = mc.optionVar( q='cgmVar_LocinatorShowHelp' ) def do_showTimeSubMenuToggleOn( self): guiFactory.toggleMenuShowState(1,self.timeSubMenu) mc.optionVar( iv=('cgmVar_LocinatorCurrentFrameOnly', 1)) def do_showTimeSubMenuToggleOff( self): guiFactory.toggleMenuShowState(0,self.timeSubMenu) mc.optionVar( iv=('cgmVar_LocinatorCurrentFrameOnly', 0)) def showAbout(self): window = mc.window( title="About", iconName='About', ut = 'cgmUITemplate',resizeToFitChildren=True ) mc.columnLayout( adjustableColumn=True ) guiFactory.header(self.toolName,overrideUpper = True) mc.text(label='>>>A Part of the cgmTools Collection<<<', ut = 'cgmUIInstructionsTemplate') guiFactory.headerBreak() guiFactory.lineBreak() descriptionBlock = guiFactory.textBlock(self.description) guiFactory.lineBreak() mc.text(label=('%s%s' %('Written by: ',self.author))) mc.text(label=('%s%s%s' %('Copyright ',self.owner,', 2011'))) guiFactory.lineBreak() mc.text(label='Version: %s' % self.version) mc.text(label='') guiFactory.doButton('Visit Tool Webpage', 'import webbrowser;webbrowser.open(" http://www.cgmonks.com/tools/maya-tools/locinator/")') guiFactory.doButton('Close', 'import maya.cmds as mc;mc.deleteUI(\"' + window + '\", window=True)') mc.setParent( '..' ) mc.showWindow( window ) def printHelp(self): import locinatorLib help(locinatorLib) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Layouts #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildPlaceHolder(self,parent): self.containerName = MelColumnLayout(parent,ut='cgmUISubTemplate') return self.containerName def buildTimeSubMenu(self,parent): self.containerName = MelColumnLayout(parent,ut='cgmUISubTemplate') # Time Submenu mc.setParent(self.containerName) self.helpBlurbs.extend(guiFactory.instructions(" Set your time range",vis = self.ShowHelpOption)) timelineInfo = search.returnTimelineInfo() # TimeInput Row TimeInputRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate') self.timeSubMenu.append( TimeInputRow ) MelSpacer(TimeInputRow) MelLabel(TimeInputRow,l='start') self.startFrameField = MelIntField(TimeInputRow,'cgmLocWinStartFrameField', width = 40, value= timelineInfo['rangeStart']) TimeInputRow.setStretchWidget( MelSpacer(TimeInputRow) ) MelLabel(TimeInputRow,l='end') self.endFrameField = MelIntField(TimeInputRow,'cgmLocWinEndFrameField', width = 40, value= timelineInfo['rangeEnd']) MelSpacer(TimeInputRow) TimeInputRow.layout() MelSeparator(self.containerName,ut = 'cgmUISubTemplate',style='none',height = 5) # Button Row TimeButtonRow = MelHSingleStretchLayout(self.containerName,padding = 1, ut='cgmUISubTemplate') MelSpacer(TimeButtonRow,w=2) currentRangeButton = guiFactory.doButton2(TimeButtonRow,'Current Range', lambda *a: locinatorLib.setGUITimeRangeToCurrent(self), 'Sets the time range to the current slider range') TimeButtonRow.setStretchWidget( MelSpacer(TimeButtonRow,w=2) ) sceneRangeButton = guiFactory.doButton2(TimeButtonRow,'Scene Range', lambda *a: locinatorLib.setGUITimeRangeToScene(self), 'Sets the time range to the current slider range') MelSpacer(TimeButtonRow,w=2) TimeButtonRow.layout() #>>> Base Settings Flags self.KeyingModeCollection = MelRadioCollection() self.KeyingModeCollectionChoices = [] if not mc.optionVar( ex='cgmVar_LocinatorKeyingMode' ): mc.optionVar( iv=('cgmVar_LocinatorKeyingMode', 0) ) guiFactory.appendOptionVarList(self,'cgmVar_LocinatorKeyingMode') KeysSettingsFlagsRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',padding = 2) MelSpacer(KeysSettingsFlagsRow,w=2) KeysSettingsFlagsRow.setStretchWidget( MelLabel(KeysSettingsFlagsRow,l='Anim Option: ',align='right') ) self.keyingOptions = ['Keys','All'] for item in self.keyingOptions: cnt = self.keyingOptions.index(item) self.KeyingModeCollectionChoices.append(self.KeyingModeCollection.createButton(KeysSettingsFlagsRow,label=self.keyingOptions[cnt], onCommand = Callback(guiFactory.toggleOptionVarState,self.keyingOptions[cnt],self.keyingOptions,'cgmVar_LocinatorKeyingMode',True))) MelSpacer(KeysSettingsFlagsRow,w=5) mc.radioCollection(self.KeyingModeCollection ,edit=True,sl= (self.KeyingModeCollectionChoices[ (mc.optionVar(q='cgmVar_LocinatorKeyingMode')) ])) KeysSettingsFlagsRow.layout() #>>> Base Settings Flags self.KeyingTargetCollection = MelRadioCollection() self.KeyingTargetCollectionChoices = [] if not mc.optionVar( ex='cgmVar_LocinatorKeyingTarget' ): mc.optionVar( iv=('cgmVar_LocinatorKeyingTarget', 0) ) guiFactory.appendOptionVarList(self,'cgmVar_LocinatorKeyingTarget') BakeSettingsFlagsRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',padding = 2) MelSpacer(BakeSettingsFlagsRow,w=2) BakeSettingsFlagsRow.setStretchWidget( MelLabel(BakeSettingsFlagsRow,l='From: ',align='right') ) MelSpacer(BakeSettingsFlagsRow) self.keyTargetOptions = ['source','self'] for item in self.keyTargetOptions: cnt = self.keyTargetOptions.index(item) self.KeyingTargetCollectionChoices.append(self.KeyingTargetCollection.createButton(BakeSettingsFlagsRow,label=self.keyTargetOptions[cnt], onCommand = Callback(guiFactory.toggleOptionVarState,self.keyTargetOptions[cnt],self.keyTargetOptions,'cgmVar_LocinatorKeyingTarget',True))) MelSpacer(BakeSettingsFlagsRow,w=5) mc.radioCollection(self.KeyingTargetCollection ,edit=True,sl= (self.KeyingTargetCollectionChoices[ (mc.optionVar(q='cgmVar_LocinatorKeyingTarget')) ])) BakeSettingsFlagsRow.layout() return self.containerName def buildBasicLayout(self,parent): mc.setParent(parent) guiFactory.header('Update') #>>>Time Section UpdateOptionRadioCollection = MelRadioCollection() EveryFrameOption = mc.optionVar( q='cgmVar_LocinatorBakeState' ) mc.setParent(parent) guiFactory.lineSubBreak() #>>> Time Menu Container self.BakeModeOptionList = ['Current Frame','Bake'] cgmVar_Name = 'cgmVar_LocinatorBakeState' guiFactory.appendOptionVarList(self,'cgmVar_LocinatorBakeState') if not mc.optionVar( ex=cgmVar_Name ): mc.optionVar( iv=(cgmVar_Name, 0) ) #build our sub section options self.ContainerList = [] #Mode Change row ModeSetRow = MelHSingleStretchLayout(parent,ut='cgmUISubTemplate') self.BakeModeRadioCollection = MelRadioCollection() self.BakeModeChoiceList = [] MelSpacer(ModeSetRow,w=2) self.BakeModeChoiceList.append(self.BakeModeRadioCollection.createButton(ModeSetRow,label=self.BakeModeOptionList[0], onCommand = Callback(guiFactory.toggleModeState,self.BakeModeOptionList[0],self.BakeModeOptionList,cgmVar_Name,self.ContainerList,True))) ModeSetRow.setStretchWidget( MelSpacer(ModeSetRow) ) self.BakeModeChoiceList.append(self.BakeModeRadioCollection.createButton(ModeSetRow,label=self.BakeModeOptionList[1], onCommand = Callback(guiFactory.toggleModeState,self.BakeModeOptionList[1],self.BakeModeOptionList,cgmVar_Name,self.ContainerList,True))) ModeSetRow.layout() #>>> self.ContainerList.append( self.buildPlaceHolder(parent) ) self.ContainerList.append( self.buildTimeSubMenu( parent) ) mc.radioCollection(self.BakeModeRadioCollection,edit=True, sl=self.BakeModeChoiceList[mc.optionVar(q=cgmVar_Name)]) #>>> mc.setParent(parent) guiFactory.doButton2(parent,'Do it!', lambda *a: locinatorLib.doUpdateLoc(self), 'Update a locator at a particular frame or through a timeline') guiFactory.lineSubBreak() #>>> Loc Me Section guiFactory.lineBreak() guiFactory.lineSubBreak() guiFactory.doButton2(parent,'Just Loc Selected', lambda *a: locinatorLib.doLocMe(self), 'Create an updateable locator based off the selection and options') def buildSpecialLayout(self,parent): SpecialColumn = MelColumnLayout(parent) #>>> Center Section guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'Locate Center', lambda *a: locinatorLib.doLocCenter(self), 'Find the center point from a selection set') #>>> Closest Point Section guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'Locate Closest Point', lambda *a: locinatorLib.doLocClosest(self), 'Select the proximity object(s), then the object to find point on. Accepted target object types are - nurbsCurves and surfaces and poly objects') #>>> Curves Section guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'Loc CVs of curve', lambda *a: locinatorLib.doLocCVsOfObject(), "Locs the cv's at the cv coordinates") guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'Loc CVs on the curve', lambda *a: locinatorLib.doLocCVsOnObject(), "Locs cv's at closest point on the curve") guiFactory.lineBreak() #>>> Update Section guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'Update Selected', lambda *a: locinatorLib.doUpdateLoc(self), "Only works with locators created with this tool") def buildMatchLayout(self,parent): MatchColumn = MelColumnLayout(parent) #>>> Tag Section guiFactory.lineSubBreak() guiFactory.doButton2(MatchColumn,'Tag it', lambda *a: locinatorLib.doTagObjects(self), "Tag the selected objects to the first locator in the selection set. After this relationship is set up, you can match objects to that locator.") #>>> Purge Section guiFactory.lineSubBreak() self.helpBlurbs.extend(guiFactory.instructions(" Purge all traces of cgmThinga tools from the object",vis = self.ShowHelpOption)) guiFactory.doButton2(MatchColumn,'Purge it', lambda *a: locinatorLib.doPurgeCGMAttrs(self), "Clean it") guiFactory.lineBreak() #>>> Update Section guiFactory.lineSubBreak() guiFactory.doButton2(MatchColumn,'Update Selected', lambda *a: locinatorLib.doUpdateLoc(self), "Only works with locators created with this tool")
class setKeyMarkingMenu(BaseMelWindow): _DEFAULT_MENU_PARENT = 'viewPanes' def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 0) mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 0) panel = mc.getPanel(up=True) if panel: # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes' if 'MayaWindow' in mc.panel(panel, q=True, ctl=True): panel = 'viewPanes' sel = search.selectCheck() IsClickedOptionVar.set(0) mmActionOptionVar.set(0) if mc.popupMenu('cgmMM', ex=True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex=True): try: mc.popupMenu('cgmMM', ctl=0, alt=0, sh=0, mm=1, b=1, aob=1, p=panel, pmc=lambda *a: self.createUI('cgmMM')) except: guiFactory.warning('Exception on set key marking menu') mel.eval( 'performSetKeyframeArgList 1 {"0", "animationList"};') def setupVariables(self): self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue=0) guiFactory.appendOptionVarList(self, self.KeyTypeOptionVar.name) self.KeyModeOptionVar = OptionVarFactory('cgmVar_KeyMode', defaultValue=0) guiFactory.appendOptionVarList(self, self.KeyModeOptionVar.name) self.mmActionOptionVar = OptionVarFactory('cgmVar_mmAction') def createUI(self, parent): """ Create the UI """ IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', value=0) self.setupVariables() def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ self.mmActionOptionVar.set(1) command killUI() sel = search.selectCheck() selPair = search.checkSelectionLength(2) ShowMatch = search.matchObjectCheck() IsClickedOptionVar.set(1) mc.menu(parent, e=True, deleteAllItems=True) MelMenuItem( parent, en=sel, l='Reset Selected', c=lambda *a: buttonAction(animToolsLib.ml_resetChannelsCall()), rp='N') MelMenuItem( parent, en=sel, l='dragBreakdown', c=lambda *a: buttonAction(animToolsLib.ml_breakdownDraggerCall()), rp='S') #>>> Keying Options KeyMenu = MelMenuItem(parent, l='Key type', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyTypeOptionVar.value == 0: regKeyOption = True bdKeyOption = False else: regKeyOption = False bdKeyOption = True KeyMenuCollection.createButton(KeyMenu, l=' Reg ', c=Callback(self.toggleVarAndReset, self.KeyTypeOptionVar), rb=regKeyOption) KeyMenuCollection.createButton(KeyMenu, l=' Breakdown ', c=Callback(self.toggleVarAndReset, self.KeyTypeOptionVar), rb=bdKeyOption) #>>> Keying Mode KeyMenu = MelMenuItem(parent, l='Key Mode', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyModeOptionVar.value == 0: regModeOption = True cbModeOption = False else: regModeOption = False cbModeOption = True KeyMenuCollection.createButton(KeyMenu, l=' Default ', c=Callback(self.toggleVarAndReset, self.KeyModeOptionVar), rb=regModeOption) KeyMenuCollection.createButton(KeyMenu, l=' Channelbox ', c=Callback(self.toggleVarAndReset, self.KeyModeOptionVar), rb=cbModeOption) MelMenuItemDiv(parent) MelMenuItem(parent, l='autoTangent', c=lambda *a: buttonAction(mel.eval('autoTangent'))) MelMenuItem(parent, l='tweenMachine', c=lambda *a: buttonAction(mel.eval('tweenMachine'))) MelMenuItem(parent, l='cgm.animTools', c=lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItemDiv(parent) MelMenuItem(parent, l='ml Set Key', c=lambda *a: buttonAction(animToolsLib.ml_setKeyCall())) MelMenuItem(parent, l='ml Hold', c=lambda *a: buttonAction(animToolsLib.ml_holdCall())) MelMenuItem(parent, l='ml Delete Key', c=lambda *a: buttonAction(animToolsLib.ml_deleteKeyCall())) MelMenuItem(parent, l='ml Arc Tracer', c=lambda *a: buttonAction(animToolsLib.ml_arcTracerCall())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars( self.optionVars)) def toggleVarAndReset(self, optionVar): try: optionVar.toggle() self.reload() except: print "MM change var and reset failed!"
class setToolsMarkingMenu(BaseMelWindow): _DEFAULT_MENU_PARENT = 'viewPanes' def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] self.IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked','int',0) self.mmActionOptionVar = OptionVarFactory('cgmVar_mmAction','int',0) self.setupVariables() panel = mc.getPanel(up = True) if panel: # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes' if 'MayaWindow' in mc.panel(panel,q = True,ctl = True): panel = 'viewPanes' sel = search.selectCheck() self.IsClickedOptionVar.set(0) self.mmActionOptionVar.set(0) if mc.popupMenu('cgmMM',ex = True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex = True): try: mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = panel, pmc = lambda *a: self.createUI('cgmMM')) except: guiFactory.warning('cgm.setMenu failed!') def createUI(self,parent): """ Create the UI """ def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ killUI() command mmActionOptionVar.set(1) self.setTypes = ['NONE', 'animation', 'layout', 'modeling', 'td', 'fx', 'lighting'] self.setModes = ['<<< All Loaded Sets >>>','<<< Active Sets >>>'] setToolsLib.updateObjectSets(self) loadedCheck = False if self.objectSets: loadedCheck = True activeCheck = False if self.activeSets: activeCheck = True self.IsClickedOptionVar.set(1) mc.menu(parent,e = True, deleteAllItems = True) MelMenuItem(parent, en = loadedCheck, l = 'Select Loaded', c = Callback(setToolsLib.doSelectMultiSets,self,0), rp = 'N') MelMenuItem(parent, en = activeCheck, l = 'Select Active', c = Callback(setToolsLib.doSelectMultiSets,self,1), rp = 'S') MelMenuItem(parent, en = loadedCheck, l = 'Key Loaded', c = Callback(setToolsLib.doKeyMultiSets,self,0), rp = 'NE') MelMenuItem(parent, en = activeCheck, l = 'Key Active', c = Callback(setToolsLib.doKeyMultiSets,self,1), rp = 'SE') MelMenuItem(parent, en = loadedCheck, l = 'Delete Key (Loaded)', c = Callback(setToolsLib.doDeleteMultiCurrentKeys,self,0), rp = 'NW') MelMenuItem(parent, en = activeCheck, l = 'Delete Key (Active)', c = Callback(setToolsLib.doDeleteMultiCurrentKeys,self,1), rp = 'SW') MelMenuItemDiv(parent) MelMenuItem(parent,l = 'Show Gui', c = lambda *a: self.reset()) #>>> Keying Options KeyMenu = MelMenuItem( parent, l='Key type', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyTypeOptionVar.value == 0: regKeyOption = True bdKeyOption = False else: regKeyOption = False bdKeyOption = True KeyMenuCollection.createButton(KeyMenu,l=' Reg ', c= Callback(self.toggleVarAndReset,self.KeyTypeOptionVar), rb= regKeyOption ) KeyMenuCollection.createButton(KeyMenu,l=' Breakdown ', c= Callback(self.toggleVarAndReset,self.KeyTypeOptionVar), rb= bdKeyOption ) #Ref menu self.refPrefixDict = {} self.activeRefsCBDict = {} if self.refPrefixes and len(self.refPrefixes) > 1: refMenu = MelMenuItem( parent, l='Load Refs:', subMenu=True) MelMenuItem( refMenu, l = 'All', c = Callback(setToolsLib.doSetAllRefState,self,True)) MelMenuItemDiv( refMenu ) for i,n in enumerate(self.refPrefixes): self.refPrefixDict[i] = n activeState = False if self.ActiveRefsOptionVar.value: if n in self.ActiveRefsOptionVar.value: activeState = True tmp = MelMenuItem( refMenu, l = n, cb = activeState, c = Callback(setToolsLib.doSetRefState,self,i,not activeState)) self.activeRefsCBDict[i] = tmp MelMenuItemDiv( refMenu ) MelMenuItem( refMenu, l = 'Clear', c = Callback(setToolsLib.doSetAllRefState,self,False)) #Types menu self.typeDict = {} self.activeTypesCBDict = {} if self.setTypes: typeMenu = MelMenuItem( parent, l='Load Types: ', subMenu=True) MelMenuItem( typeMenu, l = 'All', c = Callback(setToolsLib.doSetAllTypeState,self,True)) MelMenuItemDiv( typeMenu ) for i,n in enumerate(self.setTypes): self.typeDict[i] = n activeState = False if self.ActiveTypesOptionVar.value: if n in self.ActiveTypesOptionVar.value: activeState = True tmp = MelMenuItem( typeMenu, l = n, cb = activeState, c = Callback(setToolsLib.doSetTypeState,self,i,not activeState)) self.activeTypesCBDict[i] = tmp MelMenuItemDiv( typeMenu ) MelMenuItem( typeMenu, l = 'Clear', c = Callback(setToolsLib.doSetAllTypeState,self,False)) #>>> Autohide Options HidingMenu = MelMenuItem( parent, l='Auto Hide', subMenu=True) #guiFactory.appendOptionVarList(self,'cgmVar_MaintainLocalSetGroup') MelMenuItem( HidingMenu, l="Anim Layer Sets", cb= self.HideAnimLayerSetsOptionVar.value, c= lambda *a: setToolsLib.uiToggleOptionCB(self,self.HideAnimLayerSetsOptionVar)) MelMenuItem( HidingMenu, l="Maya Sets", cb= self.HideMayaSetsOptionVar.value, c= lambda *a: setToolsLib.uiToggleOptionCB(self,self.HideMayaSetsOptionVar)) MelMenuItem( HidingMenu, l="Non Qss Sets", cb= self.HideNonQssOptionVar.value, c= lambda *a: setToolsLib.uiToggleOptionCB(self,self.HideNonQssOptionVar)) MelMenuItem( HidingMenu, l="Set Groups", cb= self.HideSetGroupOptionVar.value, c= lambda *a: setToolsLib.uiToggleOptionCB(self,self.HideSetGroupOptionVar)) MelMenuItemDiv(parent) self.objectSetsDict = {} self.activeSetsCBDict = {} maxSets = 10 for i,b in enumerate(self.objectSets[:maxSets]): #Store the info to a dict self.objectSetsDict[i] = b sInstance = SetFactory(b) #Get check box state activeState = False if b in self.ActiveObjectSetsOptionVar.value: activeState = True tmpActive = MelMenuItem(parent, l = b, annotation = 'Toggle active state and select', cb = activeState, c = Callback(setToolsLib.doSelectSetObjects,self,i) ) self.activeSetsCBDict[i] = tmpActive if len(self.objectSets) >= maxSets: MelMenuItem(parent,l = 'More sets...see menu', ) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: self.reset()) def setupVariables(self): self.ActiveObjectSetsOptionVar = OptionVarFactory('cgmVar_activeObjectSets',defaultValue = ['']) self.ActiveRefsOptionVar = OptionVarFactory('cgmVar_activeRefs',defaultValue = ['']) self.ActiveTypesOptionVar = OptionVarFactory('cgmVar_activeTypes',defaultValue = ['']) self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue = 0) self.HideSetGroupOptionVar = OptionVarFactory('cgmVar_HideSetGroups', defaultValue = 1) self.HideNonQssOptionVar = OptionVarFactory('cgmVar_HideNonQss', defaultValue = 1) self.HideAnimLayerSetsOptionVar = OptionVarFactory('cgmVar_HideAnimLayerSets', defaultValue = 1) self.HideMayaSetsOptionVar = OptionVarFactory('cgmVar_HideMayaSets', defaultValue = 1) guiFactory.appendOptionVarList(self,self.ActiveObjectSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveRefsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveTypesOptionVar.name) guiFactory.appendOptionVarList(self,self.KeyTypeOptionVar.name) guiFactory.appendOptionVarList(self,self.HideSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.HideNonQssOptionVar.name) guiFactory.appendOptionVarList(self,self.HideAnimLayerSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.HideMayaSetsOptionVar.name) def reset(self): guiFactory.purgeOptionVars(self.optionVars) setTools.run() def reload(self): setTools.run() def toggleVarAndReset(self, optionVar): try: optionVar.toggle() self.reload() except: print "MM change var and reset failed!"
def setupVariables(self): self.PuppetModeOptionVar = OptionVarFactory('cgmVar_PuppetCreateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.PuppetModeOptionVar.name) self.PuppetAimOptionVar = OptionVarFactory('cgmVar_PuppetAimAxis',defaultValue = 2) guiFactory.appendOptionVarList(self,self.PuppetAimOptionVar.name) self.PuppetUpOptionVar = OptionVarFactory('cgmVar_PuppetUpAxis',defaultValue = 1) guiFactory.appendOptionVarList(self,self.PuppetUpOptionVar.name) self.PuppetOutOptionVar = OptionVarFactory('cgmVar_PuppetOutAxis',defaultValue = 0) guiFactory.appendOptionVarList(self,self.PuppetOutOptionVar.name) self.ActiveObjectSetsOptionVar = OptionVarFactory('cgmVar_activeObjectSets',defaultValue = ['']) self.ActiveRefsOptionVar = OptionVarFactory('cgmVar_activeRefs',defaultValue = ['']) self.ActiveTypesOptionVar = OptionVarFactory('cgmVar_activeTypes',defaultValue = ['']) self.SetToolsModeOptionVar = OptionVarFactory('cgmVar_puppetBoxMode', defaultValue = 0) self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue = 0) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_puppetBoxShowHelp', defaultValue = 0) self.MaintainLocalSetGroupOptionVar = OptionVarFactory('cgmVar_MaintainLocalSetGroup', defaultValue = 1) self.HideSetGroupOptionVar = OptionVarFactory('cgmVar_HideSetGroups', defaultValue = 1) self.HideAnimLayerSetsOptionVar = OptionVarFactory('cgmVar_HideAnimLayerSets', defaultValue = 1) self.HideMayaSetsOptionVar = OptionVarFactory('cgmVar_HideMayaSets', defaultValue = 1) guiFactory.appendOptionVarList(self,self.ActiveObjectSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveRefsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveTypesOptionVar.name) guiFactory.appendOptionVarList(self,self.SetToolsModeOptionVar.name) guiFactory.appendOptionVarList(self,self.ShowHelpOptionVar.name) guiFactory.appendOptionVarList(self,self.KeyTypeOptionVar.name) guiFactory.appendOptionVarList(self,self.HideSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.MaintainLocalSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.HideAnimLayerSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.HideMayaSetsOptionVar.name)
def setBufferAsActive(optionVar,bufferName): tmp = OptionVarFactory(optionVar,'string') if '' in tmp.value: tmp.remove('') tmp.append(bufferName)
class animToolsClass(BaseMelWindow): from cgm.lib import guiFactory guiFactory.initializeTemplates() USE_Template = 'cgmUITemplate' WINDOW_NAME = 'cgmAnimToolsWindow' WINDOW_TITLE = 'cgm.animTools - %s'%__version__ DEFAULT_SIZE = 180, 350 DEFAULT_MENU = None RETAIN = True MIN_BUTTON = True MAX_BUTTON = False FORCE_DEFAULT_SIZE = True #always resets the size of the window when its re-created def __init__( self): self.toolName = 'cgm.animTools' self.description = 'This is a series of tools for basic animation functions' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.version = __version__ self.optionVars = [] self.currentFrameOnly = True self.startFrame = '' self.endFrame = '' self.startFrameField = '' self.endFrameField = '' self.forceBoundingBoxState = False self.forceEveryFrame = False self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] self.showTimeSubMenu = False self.timeSubMenu = [] #Menu self.setupVariables() self.UI_OptionsMenu = MelMenu( l='Options', pmc=self.buildOptionsMenu) self.UI_BufferMenu = MelMenu( l = 'Buffer', pmc=self.buildBufferMenu) self.UI_HelpMenu = MelMenu( l='Help', pmc=self.buildHelpMenu) self.ShowHelpOption = mc.optionVar( q='cgmVar_AnimToolsShowHelp' ) #Tabs tabs = MelTabLayout( self ) MatchTab = MelColumnLayout(tabs) SnapTab = MelColumnLayout( tabs ) KeysTab = MelColumnLayout( tabs ) n = 0 for tab in 'Match','Snap','Keys': tabs.setLabel(n,tab) n+=1 self.Match_buildLayout(MatchTab) self.Snap_buildLayout(SnapTab) self.Keys_buildLayout(KeysTab) self.show() def setupVariables(self): self.LocinatorUpdateObjectsOptionVar = OptionVarFactory('cgmVar_AnimToolsUpdateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.LocinatorUpdateObjectsOptionVar.name) self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateObjectsBuffer',defaultValue = ['']) guiFactory.appendOptionVarList(self,self.LocinatorUpdateObjectsBufferOptionVar.name) self.DebugModeOptionVar = OptionVarFactory('cgmVar_AnimToolsDebug',defaultValue=0) guiFactory.appendOptionVarList(self,self.DebugModeOptionVar.name) #Old method...clean up at some point if not mc.optionVar( ex='cgmVar_ForceBoundingBoxState' ): mc.optionVar( iv=('cgmVar_ForceBoundingBoxState', 0) ) if not mc.optionVar( ex='cgmVar_ForceEveryFrame' ): mc.optionVar( iv=('cgmVar_ForceEveryFrame', 0) ) if not mc.optionVar( ex='cgmVar_animToolsShowHelp' ): mc.optionVar( iv=('cgmVar_animToolsShowHelp', 0) ) if not mc.optionVar( ex='cgmVar_CurrentFrameOnly' ): mc.optionVar( iv=('cgmVar_CurrentFrameOnly', 0) ) if not mc.optionVar( ex='cgmVar_animToolsShowHelp' ): mc.optionVar( iv=('cgmVar_animToolsShowHelp', 0) ) guiFactory.appendOptionVarList(self,'cgmVar_animToolsShowHelp') #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Menus #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildOptionsMenu( self, *a ): self.UI_OptionsMenu.clear() # Placement Menu PlacementMenu = MelMenuItem( self.UI_OptionsMenu, l='Placement', subMenu=True) PlacementMenuCollection = MelRadioMenuCollection() if mc.optionVar( q='cgmVar_ForceBoundingBoxState' ) == 0: cgmOption = False pivotOption = True else: cgmOption = True pivotOption = False PlacementMenuCollection.createButton(PlacementMenu,l='Bounding Box Center', c=lambda *a: mc.optionVar( iv=('cgmVar_ForceBoundingBoxState', 1)), rb=cgmOption ) PlacementMenuCollection.createButton(PlacementMenu,l='Pivot', c=lambda *a: mc.optionVar( iv=('cgmVar_ForceBoundingBoxState', 0)), rb=pivotOption ) # Tagging options AutoloadMenu = MelMenuItem( self.UI_OptionsMenu, l='Tagging', subMenu=True) if not mc.optionVar( ex='cgmVar_TaggingUpdateRO' ): mc.optionVar( iv=('cgmVar_TaggingUpdateRO', 1) ) guiFactory.appendOptionVarList(self,'cgmVar_TaggingUpdateRO') RenameOnUpdateState = mc.optionVar( q='cgmVar_TaggingUpdateRO' ) MelMenuItem( AutoloadMenu, l="Update Rotation Order", cb= mc.optionVar( q='cgmVar_TaggingUpdateRO' ), c= lambda *a: guiFactory.doToggleIntOptionVariable('cgmVar_TaggingUpdateRO')) # Update Mode UpdateMenu = MelMenuItem( self.UI_OptionsMenu, l='Update Mode', subMenu=True) UpdateMenuCollection = MelRadioMenuCollection() if self.LocinatorUpdateObjectsOptionVar.value == 0: slMode = True bufferMode = False else: slMode = False bufferMode = True UpdateMenuCollection.createButton(UpdateMenu,l='Selected', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(0), rb=slMode ) UpdateMenuCollection.createButton(UpdateMenu,l='Buffer', c=lambda *a:self.LocinatorUpdateObjectsOptionVar.set(1), rb=bufferMode ) MelMenuItemDiv( self.UI_OptionsMenu ) MelMenuItem( self.UI_OptionsMenu, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars(self.optionVars,run)) def buildBufferMenu( self, *a ): self.UI_BufferMenu.clear() MelMenuItem( self.UI_BufferMenu, l="Define", c= lambda *a: locinatorLib.defineObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( self.UI_BufferMenu, l="Add Selected", c= lambda *a: locinatorLib.addSelectedToObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( self.UI_BufferMenu, l="Remove Selected", c= lambda *a: locinatorLib.removeSelectedFromObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv( self.UI_BufferMenu ) MelMenuItem( self.UI_BufferMenu, l="Select Members", c= lambda *a: locinatorLib.selectObjBufferMembers(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( self.UI_BufferMenu, l="Clear", c= lambda *a: locinatorLib.clearObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) def buildHelpMenu( self, *a ): self.UI_HelpMenu.clear() MelMenuItem( self.UI_HelpMenu, l="Show Help", cb=self.ShowHelpOption, c= lambda *a: self.do_showHelpToggle()) MelMenuItem( self.UI_HelpMenu, l="Print Tools Help", c=lambda *a: self.printHelp() ) MelMenuItemDiv( self.UI_HelpMenu ) MelMenuItem( self.UI_HelpMenu, l="About", c=lambda *a: self.showAbout() ) MelMenuItem( self.UI_HelpMenu, l="Debug", cb=self.DebugModeOptionVar.value, c= lambda *a: self.DebugModeOptionVar.toggle()) def do_showHelpToggle( self): guiFactory.toggleMenuShowState(self.ShowHelpOption,self.helpBlurbs) mc.optionVar( iv=('cgmVar_animToolsShowHelp', not self.ShowHelpOption)) self.ShowHelpOption = mc.optionVar( q='cgmVar_animToolsShowHelp' ) def do_showTimeSubMenuToggleOn( self): guiFactory.toggleMenuShowState(1,self.timeSubMenu) mc.optionVar( iv=('cgmVar_CurrentFrameOnly', 1)) def do_showTimeSubMenuToggleOff( self): guiFactory.toggleMenuShowState(0,self.timeSubMenu) mc.optionVar( iv=('cgmVar_CurrentFrameOnly', 0)) def showAbout(self): window = mc.window( title="About", iconName='About', ut = 'cgmUITemplate',resizeToFitChildren=True ) mc.columnLayout( adjustableColumn=True ) guiFactory.header(self.toolName,overrideUpper = True) mc.text(label='>>>A Part of the cgmTools Collection<<<', ut = 'cgmUIInstructionsTemplate') guiFactory.headerBreak() guiFactory.lineBreak() descriptionBlock = guiFactory.textBlock(self.description) guiFactory.lineBreak() mc.text(label=('%s%s' %('Written by: ',self.author))) mc.text(label=('%s%s%s' %('Copyright ',self.owner,', 2011'))) guiFactory.lineBreak() mc.text(label='Version: %s' % self.version) mc.text(label='') guiFactory.doButton('Visit Tool Webpage', 'import webbrowser;webbrowser.open(" http://www.cgmonks.com/tools/maya-tools/animTools/")') guiFactory.doButton('Close', 'import maya.cmds as mc;mc.deleteUI(\"' + window + '\", window=True)') mc.setParent( '..' ) mc.showWindow( window ) def printHelp(self): import animToolsLib help(animToolsLib) def do_everyFrameToggle( self): EveryFrameOption = mc.optionVar( q='cgmVar_ForceEveryFrame' ) guiFactory.toggleMenuShowState(EveryFrameOption,self.timeSubMenu) mc.optionVar( iv=('cgmVar_ForceEveryFrame', not EveryFrameOption)) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Layouts #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildPlaceHolder(self,parent): self.containerName = MelColumnLayout(parent,ut='cgmUISubTemplate') return self.containerName def buildTimeSubMenu(self,parent): self.containerName = MelColumnLayout(parent,ut='cgmUISubTemplate') # Time Submenu mc.setParent(self.containerName) self.helpBlurbs.extend(guiFactory.instructions(" Set your time range",vis = self.ShowHelpOption)) timelineInfo = search.returnTimelineInfo() # TimeInput Row TimeInputRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate') self.timeSubMenu.append( TimeInputRow ) MelSpacer(TimeInputRow) MelLabel(TimeInputRow,l='start') self.startFrameField = MelIntField(TimeInputRow,'cgmLocWinStartFrameField', width = 40, value= timelineInfo['rangeStart']) TimeInputRow.setStretchWidget( MelSpacer(TimeInputRow) ) MelLabel(TimeInputRow,l='end') self.endFrameField = MelIntField(TimeInputRow,'cgmLocWinEndFrameField', width = 40, value= timelineInfo['rangeEnd']) MelSpacer(TimeInputRow) TimeInputRow.layout() MelSeparator(self.containerName,ut = 'cgmUISubTemplate',style='none',height = 5) # Button Row TimeButtonRow = MelHSingleStretchLayout(self.containerName,padding = 1, ut='cgmUISubTemplate') MelSpacer(TimeButtonRow,w=2) currentRangeButton = guiFactory.doButton2(TimeButtonRow,'Current Range', lambda *a: locinatorLib.setGUITimeRangeToCurrent(self), 'Sets the time range to the current slider range') TimeButtonRow.setStretchWidget( MelSpacer(TimeButtonRow,w=2) ) sceneRangeButton = guiFactory.doButton2(TimeButtonRow,'Scene Range', lambda *a: locinatorLib.setGUITimeRangeToScene(self), 'Sets the time range to the current slider range') MelSpacer(TimeButtonRow,w=2) TimeButtonRow.layout() #>>> Base Settings Flags self.KeyingModeCollection = MelRadioCollection() self.KeyingModeCollectionChoices = [] if not mc.optionVar( ex='cgmVar_AnimToolsKeyingMode' ): mc.optionVar( iv=('cgmVar_AnimToolsKeyingMode', 0) ) guiFactory.appendOptionVarList(self,'cgmVar_AnimToolsKeyingMode') KeysSettingsFlagsRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',padding = 2) MelSpacer(KeysSettingsFlagsRow,w=2) KeysSettingsFlagsRow.setStretchWidget( MelLabel(KeysSettingsFlagsRow,l='Anim Option: ',align='right') ) self.keyingOptions = ['Keys','All'] for item in self.keyingOptions: cnt = self.keyingOptions.index(item) self.KeyingModeCollectionChoices.append(self.KeyingModeCollection.createButton(KeysSettingsFlagsRow,label=self.keyingOptions[cnt], onCommand = Callback(guiFactory.toggleOptionVarState,self.keyingOptions[cnt],self.keyingOptions,'cgmVar_AnimToolsKeyingMode',True))) MelSpacer(KeysSettingsFlagsRow,w=5) mc.radioCollection(self.KeyingModeCollection ,edit=True,sl= (self.KeyingModeCollectionChoices[ (mc.optionVar(q='cgmVar_AnimToolsKeyingMode')) ])) KeysSettingsFlagsRow.layout() #>>> Base Settings Flags self.KeyingTargetCollection = MelRadioCollection() self.KeyingTargetCollectionChoices = [] if not mc.optionVar( ex='cgmVar_AnimToolsKeyingTarget' ): mc.optionVar( iv=('cgmVar_AnimToolsKeyingTarget', 0) ) guiFactory.appendOptionVarList(self,'cgmVar_AnimToolsKeyingTarget') BakeSettingsFlagsRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',padding = 2) MelSpacer(BakeSettingsFlagsRow,w=2) BakeSettingsFlagsRow.setStretchWidget( MelLabel(BakeSettingsFlagsRow,l='From: ',align='right') ) MelSpacer(BakeSettingsFlagsRow) self.keyTargetOptions = ['source','self'] for item in self.keyTargetOptions: cnt = self.keyTargetOptions.index(item) self.KeyingTargetCollectionChoices.append(self.KeyingTargetCollection.createButton(BakeSettingsFlagsRow,label=self.keyTargetOptions[cnt], onCommand = Callback(guiFactory.toggleOptionVarState,self.keyTargetOptions[cnt],self.keyTargetOptions,'cgmVar_AnimToolsKeyingTarget',True))) MelSpacer(BakeSettingsFlagsRow,w=5) mc.radioCollection(self.KeyingTargetCollection ,edit=True,sl= (self.KeyingTargetCollectionChoices[ (mc.optionVar(q='cgmVar_AnimToolsKeyingTarget')) ])) BakeSettingsFlagsRow.layout() return self.containerName def Match_buildLayout(self,parent): mc.setParent(parent) guiFactory.header('Update') #>>>Match Mode self.MatchModeCollection = MelRadioCollection() self.MatchModeCollectionChoices = [] if not mc.optionVar( ex='cgmVar_AnimToolsMatchMode' ): mc.optionVar( iv=('cgmVar_AnimToolsMatchMode', 0) ) guiFactory.appendOptionVarList(self,'cgmVar_AnimToolsMatchMode') #MatchModeFlagsRow = MelHLayout(parent,ut='cgmUISubTemplate',padding = 2) MatchModeFlagsRow = MelHSingleStretchLayout(parent,ut='cgmUIReservedTemplate',padding = 2) MelSpacer(MatchModeFlagsRow,w=2) self.MatchModeOptions = ['parent','point','orient'] for item in self.MatchModeOptions: cnt = self.MatchModeOptions.index(item) self.MatchModeCollectionChoices.append(self.MatchModeCollection.createButton(MatchModeFlagsRow,label=self.MatchModeOptions[cnt], onCommand = Callback(guiFactory.toggleOptionVarState,self.MatchModeOptions[cnt],self.MatchModeOptions,'cgmVar_AnimToolsMatchMode',True))) MelSpacer(MatchModeFlagsRow,w=3) MatchModeFlagsRow.setStretchWidget( self.MatchModeCollectionChoices[-1] ) MelSpacer(MatchModeFlagsRow,w=2) MatchModeFlagsRow.layout() mc.radioCollection(self.MatchModeCollection ,edit=True,sl= (self.MatchModeCollectionChoices[ (mc.optionVar(q='cgmVar_AnimToolsMatchMode')) ])) #>>>Time Section UpdateOptionRadioCollection = MelRadioCollection() #>>> Time Menu Container self.BakeModeOptionList = ['Current Frame','Bake'] cgmVar_Name = 'cgmVar_AnimToolsBakeState' if not mc.optionVar( ex=cgmVar_Name ): mc.optionVar( iv=(cgmVar_Name, 0) ) EveryFrameOption = mc.optionVar( q='cgmVar_AnimToolsBakeState' ) guiFactory.appendOptionVarList(self,'cgmVar_AnimToolsBakeState') #build our sub section options self.ContainerList = [] #Mode Change row ModeSetRow = MelHSingleStretchLayout(parent,ut='cgmUISubTemplate') self.BakeModeRadioCollection = MelRadioCollection() self.BakeModeChoiceList = [] MelSpacer(ModeSetRow,w=2) self.BakeModeChoiceList.append(self.BakeModeRadioCollection.createButton(ModeSetRow,label=self.BakeModeOptionList[0], onCommand = Callback(guiFactory.toggleModeState,self.BakeModeOptionList[0],self.BakeModeOptionList,cgmVar_Name,self.ContainerList,True))) ModeSetRow.setStretchWidget( MelSpacer(ModeSetRow) ) self.BakeModeChoiceList.append(self.BakeModeRadioCollection.createButton(ModeSetRow,label=self.BakeModeOptionList[1], onCommand = Callback(guiFactory.toggleModeState,self.BakeModeOptionList[1],self.BakeModeOptionList,cgmVar_Name,self.ContainerList,True))) ModeSetRow.layout() #>>> self.ContainerList.append( self.buildPlaceHolder(parent) ) self.ContainerList.append( self.buildTimeSubMenu( parent) ) mc.radioCollection(self.BakeModeRadioCollection,edit=True, sl=self.BakeModeChoiceList[mc.optionVar(q=cgmVar_Name)]) #>>> mc.setParent(parent) guiFactory.doButton2(parent,'Do it!', lambda *a: locinatorLib.doUpdateLoc(self), 'Update an obj or locator at a particular frame or through a timeline') guiFactory.lineSubBreak() #>>> Loc Me Section guiFactory.lineBreak() guiFactory.lineSubBreak() guiFactory.doButton2(parent,'Just Loc Selected', lambda *a: locinatorLib.doLocMe(self), 'Create an updateable locator based off the selection and options') #>>> Tag Section guiFactory.lineSubBreak() guiFactory.doButton2(parent,'Tag it', lambda *a: locinatorLib.doTagObjects(self), "Tag the selected objects to the first locator in the selection set. After this relationship is set up, you can match objects to that locator.") def Keys_buildLayout(self,parent): SpecialColumn = MelColumnLayout(parent) #>>> Center Section guiFactory.header('Tangents') guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'autoTangent', lambda *a: mel.eval('autoTangent'), 'Fantastic script courtesy of Michael Comet') guiFactory.lineBreak() guiFactory.header('Breakdowns') guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'tweenMachine', lambda *a: mel.eval('tweenMachine'), 'Breakdown tool courtesy of Justin Barrett') guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'breakdownDragger', lambda *a: animToolsLib.ml_breakdownDraggerCall(), 'Breakdown tool courtesy of Morgan Loomis') guiFactory.lineBreak() guiFactory.header('Utilities') guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'arcTracr', lambda *a: animToolsLib.ml_arcTracerCall(), 'Path tracing tool courtesy of Morgan Loomis') guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'copy Anim', lambda *a: animToolsLib.ml_copyAnimCall(), 'Animation copy tool courtesy of Morgan Loomis') guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'convert Rotation Order', lambda *a: animToolsLib.ml_convertRotationOrderCall(), 'Rotation Order Conversion tool courtesy of Morgan Loomis') guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn,'stopwatch', lambda *a: animToolsLib.ml_stopwatchCall(), 'Stop Watch tool courtesy of Morgan Loomis') def Snap_buildLayout(self,parent): SnapColumn = MelColumnLayout(parent) #>>> Snap Section guiFactory.lineSubBreak() guiFactory.doButton2(SnapColumn,'Parent Snap', lambda *a: tdToolsLib.doParentSnap(), "Basic Parent Snap") guiFactory.lineSubBreak() guiFactory.doButton2(SnapColumn,'Point Snap', lambda *a: tdToolsLib.doPointSnap(), "Basic Point Snap") guiFactory.lineSubBreak() guiFactory.doButton2(SnapColumn,'Orient Snap', lambda *a: tdToolsLib.doOrientSnap(), "Basic Orient Snap")
def setBufferAsInactive(optionVar,bufferName): tmp = OptionVarFactory(optionVar,'string') tmp.remove(bufferName)
class attrToolsClass(BaseMelWindow): from cgm.lib import guiFactory guiFactory.initializeTemplates() USE_Template = 'cgmUITemplate' WINDOW_NAME = 'attrTools' WINDOW_TITLE = 'cgm.attrTools - %s'%__version__ DEFAULT_SIZE = 375, 350 DEFAULT_MENU = None RETAIN = True MIN_BUTTON = True MAX_BUTTON = False FORCE_DEFAULT_SIZE = True #always resets the size of the window when its re-created def __init__( self): # Basic variables self.window = '' self.activeTab = '' self.toolName = 'attrTools' self.module = 'tdTools' self.winName = 'attrToolsWin' self.optionVars = [] self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] self.showTimeSubMenu = False self.timeSubMenu = [] self.setupVariables() self.loadAttrs = [] # About Window self.description = 'Tools for working with attributes' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.version = __version__ # About Window #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Build #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #Menu self.UI_OptionsMenu = MelMenu( l='Options', pmc=self.buildOptionsMenu) self.UI_HelpMenu = MelMenu( l='Help', pmc=self.buildHelpMenu) WindowForm = MelColumnLayout(self) self.buildAttributeTool(WindowForm) if mc.ls(sl=True): attrToolsLib.uiLoadSourceObject(self) self.show() def setupVariables(self): self.SortModifyOptionVar = OptionVarFactory('cgmVar_attrToolsSortModfiy', defaultValue = 0) guiFactory.appendOptionVarList(self,self.SortModifyOptionVar.name) self.HideTransformsOptionVar = OptionVarFactory('cgmVar_attrToolsHideTransform', defaultValue = 0) guiFactory.appendOptionVarList(self,self.HideTransformsOptionVar.name) self.HideUserDefinedOptionVar = OptionVarFactory('cgmVar_attrToolsHideUserDefined', defaultValue = 0) guiFactory.appendOptionVarList(self,self.HideUserDefinedOptionVar.name) self.HideParentAttrsOptionVar = OptionVarFactory('cgmVar_attrToolsHideParentAttrs', defaultValue = 0) guiFactory.appendOptionVarList(self,self.HideParentAttrsOptionVar.name) self.HideCGMAttrsOptionVar = OptionVarFactory('cgmVar_attrToolsHideCGMAttrs', defaultValue = 1) guiFactory.appendOptionVarList(self,self.HideCGMAttrsOptionVar.name) self.HideNonstandardOptionVar = OptionVarFactory('cgmVar_attrToolsHideNonStandard', defaultValue = 1) guiFactory.appendOptionVarList(self,self.HideNonstandardOptionVar.name) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_attrToolsShowHelp', defaultValue = 0) guiFactory.appendOptionVarList(self,self.ShowHelpOptionVar.name) self.SourceObjectOptionVar = OptionVarFactory('cgmVar_AttributeSourceObject', defaultValue= '') guiFactory.appendOptionVarList(self,self.SourceObjectOptionVar.name) self.CopyAttrModeOptionVar = OptionVarFactory('cgmVar_CopyAttributeMode', defaultValue = 0) guiFactory.appendOptionVarList(self,self.CopyAttrModeOptionVar.name) self.CopyAttrOptionsOptionVar = OptionVarFactory('cgmVar_CopyAttributeOptions', defaultValue = 1) guiFactory.appendOptionVarList(self,self.CopyAttrOptionsOptionVar.name) self.TransferValueOptionVar = OptionVarFactory('cgmVar_AttributeTransferValueState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferValueOptionVar.name) self.TransferIncomingOptionVar = OptionVarFactory('cgmVar_AttributeTransferInConnectionState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferIncomingOptionVar.name) self.TransferOutgoingOptionVar = OptionVarFactory('cgmVar_AttributeTransferOutConnectionState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferOutgoingOptionVar.name) self.TransferKeepSourceOptionVar = OptionVarFactory('cgmVar_AttributeTransferKeepSourceState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferKeepSourceOptionVar.name) self.TransferConvertStateOptionVar = OptionVarFactory('cgmVar_AttributeTransferConvertState', defaultValue = 1) guiFactory.appendOptionVarList(self,self.TransferConvertStateOptionVar.name) self.TransferDriveSourceStateOptionVar = OptionVarFactory('cgmVar_AttributeTransferConnectToSourceState', defaultValue = 0) guiFactory.appendOptionVarList(self,self.TransferDriveSourceStateOptionVar.name) self.CreateAttrTypeOptionVar = OptionVarFactory('cgmVar_AttrCreateType',defaultValue='') guiFactory.appendOptionVarList(self,self.CreateAttrTypeOptionVar.name) self.DebugModeOptionVar = OptionVarFactory('cgmVar_AttrToolsDebug',defaultValue=0) guiFactory.appendOptionVarList(self,self.DebugModeOptionVar.name) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Menus #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildHelpMenu(self, *a ): self.UI_HelpMenu.clear() MelMenuItem( self.UI_HelpMenu, l="Print Tools Help", c=lambda *a: self.printHelp() ) MelMenuItem( self.UI_HelpMenu, l="About", c=lambda *a: self.showAbout() ) MelMenuItemDiv( self.UI_HelpMenu ) MelMenuItem( self.UI_HelpMenu, l="Debug", cb=self.DebugModeOptionVar.value, c= lambda *a: self.DebugModeOptionVar.toggle()) def buildOptionsMenu( self, *a ): self.UI_OptionsMenu.clear() #>>> Grouping Options HidingMenu = MelMenuItem( self.UI_OptionsMenu, l='Autohide:', subMenu=True) MelMenuItem( self.UI_OptionsMenu, l="Sort Modify", cb=self.SortModifyOptionVar.value, annotation = "Sort the list of attributes in/nthe modify section alphabetically", c = lambda *a: attrToolsLib.uiToggleOptionCB(self,self.SortModifyOptionVar)) #guiFactory.appendOptionVarList(self,'cgmVar_MaintainLocalSetGroup') MelMenuItem( HidingMenu, l="Transforms", cb= self.HideTransformsOptionVar.value, c= lambda *a: attrToolsLib.uiToggleOptionCB(self,self.HideTransformsOptionVar)) MelMenuItem( HidingMenu, l="User Defined", cb= self.HideUserDefinedOptionVar.value, c= lambda *a: attrToolsLib.uiToggleOptionCB(self,self.HideUserDefinedOptionVar)) MelMenuItem( HidingMenu, l="Parent Attributes", cb= self.HideParentAttrsOptionVar.value, c= lambda *a: attrToolsLib.uiToggleOptionCB(self,self.HideParentAttrsOptionVar)) MelMenuItem( HidingMenu, l="CGM Attributes", cb= self.HideCGMAttrsOptionVar.value, c= lambda *a: attrToolsLib.uiToggleOptionCB(self,self.HideCGMAttrsOptionVar)) MelMenuItem( HidingMenu, l="Nonstandard", cb= self.HideNonstandardOptionVar.value, c= lambda *a: attrToolsLib.uiToggleOptionCB(self,self.HideNonstandardOptionVar)) #>>> Reset Options MelMenuItemDiv( self.UI_OptionsMenu ) MelMenuItem( self.UI_OptionsMenu, l="Reload", c=lambda *a: self.reload()) MelMenuItem( self.UI_OptionsMenu, l="Reset", c=lambda *a: self.reset()) def showAbout(self): window = mc.window( title="About", iconName='About', ut = 'cgmUITemplate',resizeToFitChildren=True ) mc.columnLayout( adjustableColumn=True ) guiFactory.header(self.toolName,overrideUpper = True) mc.text(label='>>>A Part of the cgmTools Collection<<<', ut = 'cgmUIInstructionsTemplate') guiFactory.headerBreak() guiFactory.lineBreak() descriptionBlock = guiFactory.textBlock(self.description) guiFactory.lineBreak() mc.text(label=('%s%s' %('Written by: ',self.author))) mc.text(label=('%s%s%s' %('Copyright ',self.owner,', 2011'))) guiFactory.lineBreak() mc.text(label='Version: %s' % self.version) mc.text(label='') guiFactory.doButton('Visit Website', 'import webbrowser;webbrowser.open("http://www.cgmonks.com/tools/maya-tools/attrtools/")') guiFactory.doButton('Close', 'import maya.cmds as mc;mc.deleteUI(\"' + window + '\", window=True)') mc.setParent( '..' ) mc.showWindow( window ) def printHelp(self): from cgm.tools.lib import attrToolsLib help(attrToolsLib) def reset(self): Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars,run)) def reload(self): run() #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Tools #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildAttributeTool(self,parent,vis=True): OptionList = ['Tools','Manager','Utilities'] RadioCollectionName ='AttributeMode' RadioOptionList = 'AttributeModeSelectionChoicesList' ShowHelpOption = mc.optionVar( q='cgmVar_TDToolsShowHelp' ) self.AttributeModeOptionVar = OptionVarFactory( 'cgmVar_AttributeMode',defaultValue = OptionList[0]) MelSeparator(parent,ut = 'cgmUIHeaderTemplate',h=5) #Mode Change row self.ModeSetRow = MelHLayout(parent,ut='cgmUISubTemplate',padding = 0) MelLabel(self.ModeSetRow, label = 'Choose Mode: ',align='right') self.RadioCollectionName = MelRadioCollection() self.RadioOptionList = [] #build our sub section options self.ContainerList = [] self.ContainerList.append( self.buildAttributeEditingTool(parent,vis=False) ) self.ContainerList.append( self.buildAttributeManagerTool( parent,vis=False) ) self.ContainerList.append( self.buildAttributeUtilitiesTool( parent,vis=False) ) for item in OptionList: self.RadioOptionList.append(self.RadioCollectionName.createButton(self.ModeSetRow,label=item, onCommand = Callback(guiFactory.toggleModeState,item,OptionList,self.AttributeModeOptionVar.name,self.ContainerList))) self.ModeSetRow.layout() mc.radioCollection(self.RadioCollectionName,edit=True, sl=self.RadioOptionList[OptionList.index(self.AttributeModeOptionVar.value)]) def buildAttributeEditingTool(self,parent, vis=True): #Container containerName = 'Attributes Constainer' self.containerName = MelColumn(parent,vis=vis) ###Create mc.setParent(self.containerName) guiFactory.header('Create') guiFactory.lineSubBreak() #>>>Create Row attrCreateRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',padding = 5) MelSpacer(attrCreateRow) MelLabel(attrCreateRow,l='Names:',align='right') self.AttrNamesTextField = MelTextField(attrCreateRow,backgroundColor = [1,1,1],h=20, ec = lambda *a: attrToolsLib.doAddAttributesToSelected(self), annotation = "Names for the attributes. Create multiple with a ';'. \n Message nodes try to connect to the last object in a selection \n For example: 'Test1;Test2;Test3'") guiFactory.doButton2(attrCreateRow,'Add', lambda *a: attrToolsLib.doAddAttributesToSelected(self), "Add the attribute names from the text field") MelSpacer(attrCreateRow,w=2) attrCreateRow.setStretchWidget(self.AttrNamesTextField) attrCreateRow.layout() #>>> modify Section self.buildAttrTypeRow(self.containerName) MelSeparator(self.containerName,ut = 'cgmUIHeaderTemplate',h=2) MelSeparator(self.containerName,ut = 'cgmUITemplate',h=10) ###Modify mc.setParent(self.containerName) guiFactory.header('Modify') AttrReportRow = MelHLayout(self.containerName ,ut='cgmUIInstructionsTemplate',h=20) self.AttrReportField = MelLabel(AttrReportRow, bgc = dictionary.returnStateColor('help'), align = 'center', label = '...', h=20) AttrReportRow.layout() MelSeparator(self.containerName,ut = 'cgmUISubTemplate',h=5) #>>> Load To Field LoadAttributeObjectRow = MelHSingleStretchLayout(self.containerName ,ut='cgmUISubTemplate',padding = 5) MelSpacer(LoadAttributeObjectRow,w=5) guiFactory.doButton2(LoadAttributeObjectRow,'>>', lambda *a:attrToolsLib.uiLoadSourceObject(self), 'Load to field') self.SourceObjectField = MelTextField(LoadAttributeObjectRow, w= 125, h=20, ut = 'cgmUIReservedTemplate', editable = False) LoadAttributeObjectRow.setStretchWidget(self.SourceObjectField ) MelLabel(LoadAttributeObjectRow, l=' . ') self.ObjectAttributesOptionMenu = MelOptionMenu(LoadAttributeObjectRow, w = 100) self.DeleteAttrButton = guiFactory.doButton2(LoadAttributeObjectRow,'X', lambda *a:attrToolsLib.uiDeleteAttr(self,self.ObjectAttributesOptionMenu), 'Delete attribute', w = 25, en = False) MelSpacer(LoadAttributeObjectRow,w=5) LoadAttributeObjectRow.layout() #>>> Standard Flags BasicAttrFlagsRow = MelHLayout(self.containerName ,ut='cgmUISubTemplate',padding = 2) MelSpacer(BasicAttrFlagsRow,w=5) self.KeyableAttrCB = MelCheckBox(BasicAttrFlagsRow,label = 'Keyable',en=False) MelSpacer(BasicAttrFlagsRow,w=5) self.HiddenAttrCB = MelCheckBox(BasicAttrFlagsRow,label = 'Hidden',en=False) MelSpacer(BasicAttrFlagsRow,w=5) self.LockedAttrCB = MelCheckBox(BasicAttrFlagsRow,label = 'Locked',en=False) MelSpacer(BasicAttrFlagsRow,w=5) BasicAttrFlagsRow.layout() #>>> Name Row self.EditNameSettingsRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate') self.EditNameSettingsRow.setStretchWidget(MelSpacer(self.EditNameSettingsRow,w=5)) NameLabel = MelLabel(self.EditNameSettingsRow,label = 'Name: ') self.NameField = MelTextField(self.EditNameSettingsRow,en = False, bgc = dictionary.returnStateColor('normal'), ec = lambda *a: attrToolsLib.uiRenameAttr(self), h=20, w = 75) NiceNameLabel = MelLabel(self.EditNameSettingsRow,label = 'Nice: ') self.NiceNameField = MelTextField(self.EditNameSettingsRow,en = False, bgc = dictionary.returnStateColor('normal'), ec = lambda *a: attrToolsLib.uiUpdateNiceName(self), h=20, w = 75) AliasLabel = MelLabel(self.EditNameSettingsRow,label = 'Alias: ') self.AliasField = MelTextField(self.EditNameSettingsRow,en = False, bgc = dictionary.returnStateColor('normal'), ec = lambda *a: attrToolsLib.uiUpdateAlias(self), h=20, w = 75) MelSpacer(self.EditNameSettingsRow,w=5) self.EditNameSettingsRow.layout() """mc.formLayout(self.EditNameSettingsRow, edit = True, af = [(NameLabel, "left", 5), (self.AliasField,"right",5)], ac = [(self.NameField,"left",2,NameLabel), (NiceNameLabel,"left",2,self.NameField), (self.NiceNameField,"left",2,NiceNameLabel), (AliasLabel,"left",2,self.NiceNameField), (self.AliasField,"left",2,AliasLabel), ])""" #>>> Int Row #self.EditDigitSettingsRow = MelFormLayout(self.containerName,ut='cgmUISubTemplate',vis = False) self.EditDigitSettingsRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',vis = False) self.EditDigitSettingsRow.setStretchWidget(MelSpacer(self.EditDigitSettingsRow,w=5)) MinLabel = MelLabel(self.EditDigitSettingsRow,label = 'Min:') self.MinField = MelTextField(self.EditDigitSettingsRow, bgc = dictionary.returnStateColor('normal'), ec = lambda *a: attrToolsLib.uiUpdateMinValue(self), h = 20, w = 35) MaxLabel = MelLabel(self.EditDigitSettingsRow,label = 'Max:') self.MaxField = MelTextField(self.EditDigitSettingsRow, bgc = dictionary.returnStateColor('normal'), ec = lambda *a: attrToolsLib.uiUpdateMaxValue(self), h = 20, w = 35) DefaultLabel = MelLabel(self.EditDigitSettingsRow,label = 'dv:') self.DefaultField = MelTextField(self.EditDigitSettingsRow, bgc = dictionary.returnStateColor('normal'), ec = lambda *a: attrToolsLib.uiUpdateDefaultValue(self), h = 20, w = 35) SoftMinLabel = MelLabel(self.EditDigitSettingsRow,label = 'sMin:') self.SoftMinField = MelTextField(self.EditDigitSettingsRow, bgc = dictionary.returnStateColor('normal'), ec = lambda *a: attrToolsLib.uiUpdateSoftMinValue(self), h = 20, w = 35) SoftMaxLabel = MelLabel(self.EditDigitSettingsRow,label = 'sMax:') self.SoftMaxField = MelTextField(self.EditDigitSettingsRow, bgc = dictionary.returnStateColor('normal'), ec = lambda *a: attrToolsLib.uiUpdateSoftMaxValue(self), h = 20, w = 35) MelSpacer(self.EditDigitSettingsRow,w=5) self.EditDigitSettingsRow.layout() """mc.formLayout(self.EditDigitSettingsRow, edit = True, af = [(MinLabel, "left", 20), (self.SoftMinField,"right",20)], ac = [(self.MinField,"left",2,MinLabel), (MaxLabel,"left",2,self.MinField), (self.MaxField,"left",2,MaxLabel), (DefaultLabel,"left",2,self.MaxField), (self.DefaultField,"left",2,DefaultLabel), (SoftMaxLabel,"left",2,self.DefaultField), (self.SoftMaxField,"left",2,SoftMaxLabel), (SoftMinLabel,"left",2,self.SoftMaxField), (self.SoftMinField,"left",2,SoftMinLabel) ])""" #>>> Enum self.EditEnumRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',padding = 5, vis = False) MelSpacer(self.EditEnumRow,w=10) MelLabel(self.EditEnumRow,label = 'Enum: ') self.EnumField = MelTextField(self.EditEnumRow, annotation = "Options divided by ':'. \n Set values with '=' \n For example: 'off:on=1:maybe=23'", bgc = dictionary.returnStateColor('normal'), h = 20, w = 75) MelSpacer(self.EditEnumRow,w=10) self.EditEnumRow.setStretchWidget(self.EnumField) self.EditEnumRow.layout() #>>> String self.EditStringRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',padding = 5, vis = False) MelSpacer(self.EditStringRow,w=10) MelLabel(self.EditStringRow,label = 'String: ') self.StringField = MelTextField(self.EditStringRow, h=20, bgc = dictionary.returnStateColor('normal'), w = 75) MelSpacer(self.EditStringRow,w=10) self.EditStringRow.setStretchWidget(self.StringField) self.EditStringRow.layout() #>>> Message self.EditMessageRow = MelHSingleStretchLayout(self.containerName,ut='cgmUISubTemplate',padding = 5, vis = False) MelSpacer(self.EditMessageRow,w=10) MelLabel(self.EditMessageRow,label = 'Message: ') self.MessageField = MelTextField(self.EditMessageRow, h=20, enable = False, bgc = dictionary.returnStateColor('locked'), ec = lambda *a: tdToolsLib.uiUpdateAutoNameTag(self,'cgmPosition'), w = 75) self.LoadMessageButton = guiFactory.doButton2(self.EditMessageRow,'<<', lambda *a:attrToolsLib.uiUpdateMessage(self), 'Load to message') MelSpacer(self.EditMessageRow,w=10) self.EditMessageRow.setStretchWidget(self.MessageField) self.EditMessageRow.layout() #>>> Conversion self.buildAttrConversionRow(self.containerName) self.AttrConvertRow(e=True, vis = False) #>>> Connect Report self.ConnectionReportRow = MelHLayout(self.containerName ,ut='cgmUIInstructionsTemplate',h=20,vis=False) self.ConnectionReportField = MelLabel(self.ConnectionReportRow,vis=False, bgc = dictionary.returnStateColor('help'), align = 'center', label = '...', h=20) self.ConnectionReportRow.layout() self.ConnectedPopUpMenu = MelPopupMenu(self.ConnectionReportRow,button = 3) MelSeparator(self.containerName,ut = 'cgmUIHeaderTemplate',h=2) mc.setParent(self.containerName ) guiFactory.lineBreak() return self.containerName def buildAttrTypeRow(self,parent): #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Attr type row #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> self.attrTypes = ['string','float','int','double3','bool','enum','message'] attrShortTypes = ['str','float','int','[000]','bool','enum','msg'] self.CreateAttrTypeRadioCollection = MelRadioCollection() self.CreateAttrTypeRadioCollectionChoices = [] #build our sub section options AttrTypeRow = MelHLayout(self.containerName,ut='cgmUISubTemplate',padding = 5) for cnt,item in enumerate(self.attrTypes): self.CreateAttrTypeRadioCollectionChoices.append(self.CreateAttrTypeRadioCollection.createButton(AttrTypeRow,label=attrShortTypes[cnt], onCommand = Callback(self.CreateAttrTypeOptionVar.set,item))) MelSpacer(AttrTypeRow,w=2) if self.CreateAttrTypeOptionVar.value: mc.radioCollection(self.CreateAttrTypeRadioCollection ,edit=True,sl= (self.CreateAttrTypeRadioCollectionChoices[ self.attrTypes.index(self.CreateAttrTypeOptionVar.value) ])) AttrTypeRow.layout() def buildAttrConversionRow(self,parent): #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Attr type row #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> self.attrConvertTypes = ['string','float','int','bool','enum','message'] self.attrConvertShortTypes = ['str','float','int','bool','enum','msg'] self.ConvertAttrTypeRadioCollection = MelRadioCollection() self.ConvertAttrTypeRadioCollectionChoices = [] self.ConvertAttrTypeOptionVar = OptionVarFactory('cgmVar_ActiveAttrConversionState','int') guiFactory.appendOptionVarList(self,self.ConvertAttrTypeOptionVar.name) self.ConvertAttrTypeOptionVar.set(0) #build our sub section options self.AttrConvertRow = MelHLayout(self.containerName,ut='cgmUISubTemplate',padding = 5) for cnt,item in enumerate(self.attrConvertTypes): self.ConvertAttrTypeRadioCollectionChoices.append(self.ConvertAttrTypeRadioCollection.createButton(self.AttrConvertRow,label=self.attrConvertShortTypes[cnt], onCommand = Callback(attrToolsLib.uiConvertLoadedAttr,self,item))) MelSpacer(self.AttrConvertRow,w=2) self.AttrConvertRow.layout() def buildAttributeManagerTool(self,parent, vis=True): self.ManageForm = MelFormLayout(self.Get(),ut='cgmUITemplate') ManageHeader = guiFactory.header('Manage Attributes') #>>> Manager load frow ManagerLoadObjectRow = MelHSingleStretchLayout(self.ManageForm ,padding = 5) MelSpacer(ManagerLoadObjectRow,w=5) guiFactory.doButton2(ManagerLoadObjectRow,'>>', lambda *a:attrToolsLib.uiLoadSourceObject(self), 'Load to field') self.ManagerSourceObjectField = MelTextField(ManagerLoadObjectRow, w= 125, h=20, ut = 'cgmUIReservedTemplate', editable = False) ManagerLoadObjectRow.setStretchWidget(self.ManagerSourceObjectField ) MelSpacer(ManagerLoadObjectRow,w=5) ManagerLoadObjectRow.layout() #>>> Attribute List self.ManageAttrList = MelObjectScrollList(self.ManageForm, allowMultiSelection=True ) #>>> Reorder Button ReorderButtonsRow = MelHLayout(self.ManageForm,padding = 5) guiFactory.doButton2(ReorderButtonsRow, 'Move Up', lambda *a: attrToolsLib.uiReorderAttributes(self,0), 'Create new buffer from selected buffer') guiFactory.doButton2(ReorderButtonsRow, 'Move Down', lambda *a: attrToolsLib.uiReorderAttributes(self,1), 'Create new buffer from selected buffer') ReorderButtonsRow.layout() #>>>Transfer Options self.TransferModeCollection = MelRadioCollection() self.TransferModeCollectionChoices = [] TransferModeFlagsRow = MelHSingleStretchLayout(self.ManageForm,padding = 2) MelLabel(TransferModeFlagsRow,l='Modes') Spacer = MelSeparator(TransferModeFlagsRow,w=10) self.TransferModeOptions = ['Connect','Copy','Transfer'] for i,item in enumerate(self.TransferModeOptions): self.TransferModeCollectionChoices.append(self.TransferModeCollection.createButton(TransferModeFlagsRow,label=item, onCommand = Callback(self.CopyAttrModeOptionVar.set,i))) MelSpacer(TransferModeFlagsRow,w=3) TransferModeFlagsRow.setStretchWidget( Spacer ) MelSpacer(TransferModeFlagsRow,w=2) TransferModeFlagsRow.layout() mc.radioCollection(self.TransferModeCollection ,edit=True,sl= (self.TransferModeCollectionChoices[ (self.CopyAttrModeOptionVar.value) ])) #>>>Transfer Options self.TransferOptionsCollection = MelRadioCollection() self.TransferOptionsCollectionChoices = [] TransferOptionsFlagsRow = MelHSingleStretchLayout(self.ManageForm,padding = 0) Spacer = MelSpacer(TransferOptionsFlagsRow) TransferOptionsFlagsRow.setStretchWidget( Spacer ) self.ConvertCB = MelCheckBox(TransferOptionsFlagsRow,label = 'Convert', annotation = "Converts if necessary to finish the copy process", value = self.TransferConvertStateOptionVar.value, onCommand = Callback(self.TransferConvertStateOptionVar.set,1), offCommand = Callback(self.TransferConvertStateOptionVar.set,0)) self.ValueCB = MelCheckBox(TransferOptionsFlagsRow,label = 'Value', annotation = "Copy values", value = self.TransferValueOptionVar.value, onCommand = Callback(self.TransferValueOptionVar.set,1), offCommand = Callback(self.TransferValueOptionVar.set,0)) self.IncomingCB = MelCheckBox(TransferOptionsFlagsRow,label = 'In', annotation = "Copy or transfer incoming connections", value = self.TransferIncomingOptionVar.value, onCommand = Callback(self.TransferIncomingOptionVar.set,1), offCommand = Callback(self.TransferIncomingOptionVar.set,0)) self.OutgoingCB = MelCheckBox(TransferOptionsFlagsRow,label = 'Out', annotation = "Copy or transfer incoming connections", value = self.TransferOutgoingOptionVar.value, onCommand = Callback(self.TransferOutgoingOptionVar.set,1), offCommand = Callback(self.TransferOutgoingOptionVar.set,0)) self.KeepSourceCB = MelCheckBox(TransferOptionsFlagsRow,label = 'Keep', annotation = "Keep source connections when copying", value = self.TransferKeepSourceOptionVar.value, onCommand = Callback(self.TransferKeepSourceOptionVar.set,1), offCommand = Callback(self.TransferKeepSourceOptionVar.set,0)) self.DriveSourceCB = MelCheckBox(TransferOptionsFlagsRow,label = 'Drive', annotation = "Connect the source attr \nto selected or created attribute", value = self.TransferDriveSourceStateOptionVar.value, onCommand = Callback(self.TransferDriveSourceStateOptionVar.set,1), offCommand = Callback(self.TransferDriveSourceStateOptionVar.set,0)) self.AttrOptionsCB = MelCheckBox(TransferOptionsFlagsRow,label = 'Options', annotation = "Copies the attributes basic flags\n(locked,keyable,hidden)", value = self.CopyAttrOptionsOptionVar.value, onCommand = Callback(self.CopyAttrOptionsOptionVar.set,1), offCommand = Callback(self.TransferDriveSourceStateOptionVar.set,0)) TransferOptionsFlagsRow.layout() BottomButtonRow = guiFactory.doButton2(self.ManageForm, 'Connect/Copy/Transfer', lambda *a: attrToolsLib.uiTransferAttributes(self), 'Create new buffer from selected buffer') self.ManageForm(edit = True, af = [(ManageHeader,"top",0), (ManageHeader,"left",0), (ManageHeader,"right",0), (self.ManageAttrList,"left",0), (self.ManageAttrList,"right",0), (ManagerLoadObjectRow,"left",5), (ManagerLoadObjectRow,"right",5), (ReorderButtonsRow,"left",0), (ReorderButtonsRow,"right",0), (TransferModeFlagsRow,"left",5), (TransferModeFlagsRow,"right",5), (BottomButtonRow,"left",5), (BottomButtonRow,"right",5), (TransferOptionsFlagsRow,"left",2), (TransferOptionsFlagsRow,"right",2), (TransferOptionsFlagsRow,"bottom",4)], ac = [(ManagerLoadObjectRow,"top",5,ManageHeader), (self.ManageAttrList,"top",5,ManagerLoadObjectRow), (self.ManageAttrList,"bottom",5,ReorderButtonsRow), (ReorderButtonsRow,"bottom",5,BottomButtonRow), (BottomButtonRow,"bottom",5,TransferModeFlagsRow), (TransferModeFlagsRow,"bottom",5,TransferOptionsFlagsRow)], attachNone = [(TransferOptionsFlagsRow,"top")]) #Build pop up for attribute list field popUpMenu = MelPopupMenu(self.ManageAttrList,button = 3) MelMenuItem(popUpMenu , label = 'Make Keyable', c = lambda *a: attrToolsLib.uiManageAttrsKeyable(self)) MelMenuItem(popUpMenu , label = 'Make Unkeyable', c = lambda *a: attrToolsLib.uiManageAttrsUnkeyable(self)) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu , label = 'Hide', c = lambda *a: attrToolsLib.uiManageAttrsHide(self)) MelMenuItem(popUpMenu , label = 'Unhide', c = lambda *a: attrToolsLib.uiManageAttrsUnhide(self)) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu , label = 'Lock', c = lambda *a: attrToolsLib.uiManageAttrsLocked(self)) MelMenuItem(popUpMenu , label = 'Unlock', c = lambda *a: attrToolsLib.uiManageAttrsUnlocked(self)) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu , label = 'Delete', c = lambda *a: attrToolsLib.uiManageAttrsDelete(self)) return self.ManageForm def buildAttributeUtilitiesTool(self,parent, vis=True): containerName = 'Utilities Container' self.containerName = MelColumn(parent,vis=vis) #>>> Tag Labels mc.setParent(self.containerName) guiFactory.header('Short cuts') guiFactory.lineSubBreak() AttributeUtilityRow1 = MelHLayout(self.containerName,ut='cgmUISubTemplate',padding = 2) guiFactory.doButton2(AttributeUtilityRow1,'cgmName to Float', lambda *a:tdToolsLib.doCGMNameToFloat(), 'Makes an animatalbe float attribute using the cgmName tag') mc.setParent(self.containerName) guiFactory.lineSubBreak() AttributeUtilityRow1.layout() #>>> SDK tools mc.setParent(self.containerName) guiFactory.lineBreak() guiFactory.header('SDK Tools') guiFactory.lineSubBreak() sdkRow = MelHLayout(self.containerName ,ut='cgmUISubTemplate',padding = 2) guiFactory.doButton2(sdkRow,'Select Driven Joints', lambda *a:tdToolsLib.doSelectDrivenJoints(self), "Selects driven joints from an sdk attribute") sdkRow.layout() mc.setParent(self.containerName) guiFactory.lineSubBreak() return self.containerName
def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] self.toolName = 'cgm.snapMM' IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') surfaceSnapAimModeVar = OptionVarFactory('cgmVar_SurfaceSnapAimMode', 'int') UpdateRotateOrderOnTagVar = OptionVarFactory('cgmVar_TaggingUpdateRO', 'int') self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=['']) self.LocinatorUpdateObjectsOptionVar = OptionVarFactory( 'cgmVar_SnapMMUpdateMode', defaultValue=0) guiFactory.appendOptionVarList( self, self.LocinatorUpdateObjectsOptionVar.name) self.SnapModeOptionVar = OptionVarFactory('cgmVar_SnapMatchMode', defaultValue=0) guiFactory.appendOptionVarList(self, self.SnapModeOptionVar.name) panel = mc.getPanel(up=True) sel = search.selectCheck() IsClickedOptionVar.set(0) mmActionOptionVar.set(0) if mc.popupMenu('cgmMM', ex=True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex=True): mc.popupMenu('cgmMM', ctl=0, alt=0, sh=0, mm=1, b=1, aob=1, p='viewPanes', pmc=lambda *a: self.createUI('cgmMM'))
class puppetBoxClass(BaseMelWindow): from cgm.lib import guiFactory guiFactory.initializeTemplates() USE_Template = 'cgmUITemplate' WINDOW_NAME = 'cgmPuppetBoxWindow' WINDOW_TITLE = 'cgm.puppetBox' DEFAULT_SIZE = 250, 400 DEFAULT_MENU = None RETAIN = True MIN_BUTTON = True MAX_BUTTON = False FORCE_DEFAULT_SIZE = False #always resets the size of the window when its re-created global cgmPuppet def __init__( self): self.toolName = 'cgm.puppetBox' self.description = 'This is a series of tools for working with cgm Sets' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.version = __version__ self.optionVars = [] self.scenePuppets = [] self.Puppet = False self.PuppetBridge = {} self.puppetStateOptions = ['define'] self.puppetStateOptions.extend(ModuleFactory.moduleStates) #self.addModules = ['Spine','Leg','Arm','Limb','Finger','Foot','Neck','Head','Spine'] self.addModules = ['Segment'] self.moduleFrames = {} self.moduleBaseNameFields = {} self.moduleHandleFields = {} self.moduleRollFields = {} self.moduleCurveFields = {} self.moduleStiffIndexFields = {} self.moduleDirectionMenus = {} self.modulePositionMenus = {} self.moduleDirections = ['none','left','right'] self.modulePositions = ['none','front','rear','forward','back','top','bottom'] self.setModes = ['<<< All Loaded Sets >>>','<<< Active Sets >>>'] self.scenePuppets = modules.returnPuppetObjects() self.UI_StateRows = {'define':[],'template':[],'skeleton':[],'rig':[]} self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] #Menu self.setupVariables() self.UI_PuppetMenu = MelMenu( l='Puppet', pmc=self.buildPuppetMenu) self.UI_AddModulesMenu = MelMenu( l='Add', pmc=self.buildAddModulesMenu) self.UI_OptionsMenu = MelMenu( l='Options', pmc=self.buildOptionsMenu) self.UI_HelpMenu = MelMenu( l='Help', pmc=self.buildHelpMenu) self.ShowHelpOption = mc.optionVar( q='cgmVar_AnimToolsShowHelp' ) #GUI self.Main_buildLayout(self) if self.Puppet: puppetBoxLib.updateUIPuppet(self) if self.scenePuppets: puppetBoxLib.activatePuppet(self,self.scenePuppets[0]) self.show() def setupVariables(self): self.PuppetModeOptionVar = OptionVarFactory('cgmVar_PuppetCreateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.PuppetModeOptionVar.name) self.PuppetAimOptionVar = OptionVarFactory('cgmVar_PuppetAimAxis',defaultValue = 2) guiFactory.appendOptionVarList(self,self.PuppetAimOptionVar.name) self.PuppetUpOptionVar = OptionVarFactory('cgmVar_PuppetUpAxis',defaultValue = 1) guiFactory.appendOptionVarList(self,self.PuppetUpOptionVar.name) self.PuppetOutOptionVar = OptionVarFactory('cgmVar_PuppetOutAxis',defaultValue = 0) guiFactory.appendOptionVarList(self,self.PuppetOutOptionVar.name) self.ActiveObjectSetsOptionVar = OptionVarFactory('cgmVar_activeObjectSets',defaultValue = ['']) self.ActiveRefsOptionVar = OptionVarFactory('cgmVar_activeRefs',defaultValue = ['']) self.ActiveTypesOptionVar = OptionVarFactory('cgmVar_activeTypes',defaultValue = ['']) self.SetToolsModeOptionVar = OptionVarFactory('cgmVar_puppetBoxMode', defaultValue = 0) self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue = 0) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_puppetBoxShowHelp', defaultValue = 0) self.MaintainLocalSetGroupOptionVar = OptionVarFactory('cgmVar_MaintainLocalSetGroup', defaultValue = 1) self.HideSetGroupOptionVar = OptionVarFactory('cgmVar_HideSetGroups', defaultValue = 1) self.HideAnimLayerSetsOptionVar = OptionVarFactory('cgmVar_HideAnimLayerSets', defaultValue = 1) self.HideMayaSetsOptionVar = OptionVarFactory('cgmVar_HideMayaSets', defaultValue = 1) guiFactory.appendOptionVarList(self,self.ActiveObjectSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveRefsOptionVar.name) guiFactory.appendOptionVarList(self,self.ActiveTypesOptionVar.name) guiFactory.appendOptionVarList(self,self.SetToolsModeOptionVar.name) guiFactory.appendOptionVarList(self,self.ShowHelpOptionVar.name) guiFactory.appendOptionVarList(self,self.KeyTypeOptionVar.name) guiFactory.appendOptionVarList(self,self.HideSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.MaintainLocalSetGroupOptionVar.name) guiFactory.appendOptionVarList(self,self.HideAnimLayerSetsOptionVar.name) guiFactory.appendOptionVarList(self,self.HideMayaSetsOptionVar.name) def updateModulesUI(self): def optionMenuSet(item): print item #puppetBoxLib.uiModuleSetCGMTag(self,tag,item,index) """ i = self.setModes.index(item) self.SetToolsModeOptionVar.set( i ) self.setMode = i""" #deleteExisting self.ModuleListColumn.clear() if self.Puppet: for i,b in enumerate(self.Puppet.ModulesBuffer.bufferList): # NEED to get colors #Build label for Frame self.moduleFrames[i] = MelFrameLayout(self.ModuleListColumn,l='', collapse=True, collapsable=True, marginHeight=0, marginWidth=0, bgc = dictionary.guiDirectionColors['center']) puppetBoxLib.uiModuleUpdateFrameLabel(self,i) #Build Naming Row tmpNameRow = MelFormLayout(self.moduleFrames[i], h=25, ) tmpNameLabel = MelLabel(tmpNameRow,l='base:',align='right') self.moduleBaseNameFields[i] = MelTextField(tmpNameRow,text=self.Puppet.Module[i].nameBase or '', ec = Callback(puppetBoxLib.uiUpdateBaseName,self,i), w=50, h=20) tmpDirLabel = MelLabel(tmpNameRow,l='dir:',align='right') self.moduleDirectionMenus[i] = MelOptionMenu(tmpNameRow, cc = Callback(puppetBoxLib.uiModuleOptionMenuSet,self,self.moduleDirectionMenus,self.moduleDirections,'cgmDirection',i)) for cnt,o in enumerate(self.moduleDirections): self.moduleDirectionMenus[i].append(o) if o == self.Puppet.Module[i].ModuleNull.cgm['cgmDirection']: self.moduleDirectionMenus[i](edit = True, select = cnt + 1) tmpPosLabel = MelLabel(tmpNameRow,l='pos:',align='right') self.modulePositionMenus[i] = MelOptionMenu(tmpNameRow, cc = Callback(puppetBoxLib.uiModuleOptionMenuSet,self,self.modulePositionMenus,self.modulePositions,'cgmPosition',i)) for cnt,o in enumerate(self.modulePositions): self.modulePositionMenus[i].append(o) if o == self.Puppet.Module[i].ModuleNull.cgm['cgmPosition']: self.modulePositionMenus[i](edit = True, select = cnt + 1) mc.formLayout(tmpNameRow, edit = True, af = [(tmpNameLabel, "left", 10), (self.modulePositionMenus[i],"right",10)], ac = [(self.moduleBaseNameFields[i],"left",5,tmpNameLabel), (self.moduleBaseNameFields[i],"right",5,tmpDirLabel), (tmpDirLabel,"right",5,self.moduleDirectionMenus[i]), (self.moduleDirectionMenus[i],"right",5,tmpPosLabel), (tmpPosLabel,"right",5,self.modulePositionMenus[i] ), ]) #>>>>>>>>>>>>>>>>>>>>> if self.Puppet.Module[i].moduleClass == 'Limb': #Build Int Settings Row tmpIntRow = MelHSingleStretchLayout(self.moduleFrames[i], h=25, ) tmpIntRow.setStretchWidget(MelSpacer(tmpIntRow,w=5)) MelLabel(tmpIntRow,l='Handles:') self.moduleHandleFields[i] = MelIntField(tmpIntRow, v = self.Puppet.Module[i].optionHandles.value, bgc = dictionary.returnStateColor('normal'), ec = Callback(puppetBoxLib.uiModuleUpdateIntAttrFromField,self,self.moduleHandleFields,'optionHandles',i), h = 20, w = 35) MelLabel(tmpIntRow,l='Roll:') self.moduleRollFields[i] = MelIntField(tmpIntRow, v = self.Puppet.Module[i].optionRollJoints.value, bgc = dictionary.returnStateColor('normal'), ec = Callback(puppetBoxLib.uiModuleUpdateIntAttrFromField,self,self.moduleRollFields,'optionRollJoints',i), h = 20, w = 35) MelLabel(tmpIntRow,l='Stiff Index:') self.moduleStiffIndexFields[i] = MelIntField(tmpIntRow, v = self.Puppet.Module[i].optionStiffIndex.value, bgc = dictionary.returnStateColor('normal'), ec = Callback(puppetBoxLib.uiModuleUpdateIntAttrFromField,self,self.moduleStiffIndexFields,'optionStiffIndex',i), h = 20, w = 35) MelLabel(tmpIntRow,l='Curve:') self.moduleCurveFields[i] = MelIntField(tmpIntRow, v = self.Puppet.Module[i].optionCurveDegree.value, bgc = dictionary.returnStateColor('normal'), ec = Callback(puppetBoxLib.uiModuleUpdateIntAttrFromField,self,self.moduleCurveFields,'optionCurveDegree',i), h = 20, w = 35) MelSpacer(tmpIntRow,w=10) tmpIntRow.layout() #PopUp Menu! popUpMenu = MelPopupMenu(self.moduleFrames[i],button = 3) MelMenuItem(popUpMenu, label = "cls: %s"%self.Puppet.Module[i].moduleClass, enable = False) #Parent/MIrror MelMenuItem(popUpMenu, label = "Set Parent>", enable = False) MelMenuItem(popUpMenu, label = "Set Mirror>", enable = False) if self.Puppet.Module[i].moduleClass == 'Limb': MelMenuItem(popUpMenu, label = 'FK', cb = self.Puppet.Module[i].optionFK.value, c = Callback(puppetBoxLib.uiModuleToggleBool,self,'optionFK',i)) MelMenuItem(popUpMenu, label = 'IK', cb = self.Puppet.Module[i].optionIK.value, c = Callback(puppetBoxLib.uiModuleToggleBool,self,'optionIK',i)) MelMenuItem(popUpMenu, label = 'Stretchy', cb = self.Puppet.Module[i].optionStretchy.value, c = Callback(puppetBoxLib.uiModuleToggleBool,self,'optionStretchy',i)) MelMenuItem(popUpMenu, label = 'Bendy', cb = self.Puppet.Module[i].optionBendy.value, c = Callback(puppetBoxLib.uiModuleToggleBool,self,'optionBendy',i)) MelMenuItemDiv(popUpMenu) # Object Aim Menu ObjectAimMenu = MelMenuItem(popUpMenu, l='Aim:', subMenu=True) self.ObjectAimCollection = MelRadioMenuCollection() for index,axis in enumerate(dictionary.axisDirectionsByString): if self.Puppet.Module[i].optionAimAxis.get() == index: checkState = True else: checkState = False self.ObjectAimCollection.createButton(ObjectAimMenu,l=axis, c= Callback(puppetBoxLib.doSetAxisAndUpdateModule,self,functions.doSetAimAxis,self.Puppet.Module[i],index), rb = checkState) ObjectUpMenu = MelMenuItem(popUpMenu, l='Up:', subMenu=True) self.ObjectUpCollection = MelRadioMenuCollection() for index,axis in enumerate(dictionary.axisDirectionsByString): if self.Puppet.Module[i].optionUpAxis.get() == index: checkState = True else: checkState = False self.ObjectUpCollection.createButton(ObjectUpMenu,l=axis, c= Callback(puppetBoxLib.doSetAxisAndUpdateModule,self,functions.doSetUpAxis,self.Puppet.Module[i],index), rb = checkState) ObjectOutMenu = MelMenuItem(popUpMenu, l='Out:', subMenu=True) self.ObjectOutCollection = MelRadioMenuCollection() for index,axis in enumerate(dictionary.axisDirectionsByString): if self.Puppet.Module[i].optionOutAxis.get() == index: checkState = True else: checkState = False self.ObjectOutCollection.createButton(ObjectOutMenu,l=axis, c= Callback(puppetBoxLib.doSetAxisAndUpdateModule,self,functions.doSetOutAxis,self.Puppet.Module[i],index), rb = checkState) ObjectOutMenu = MelMenuItem(popUpMenu, l='Copy from Parent', c= Callback(puppetBoxLib.doCopyAxisFromParent,self,self.Puppet.Module[i])) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu , label = 'Remove', c = Callback(puppetBoxLib.doRemoveModule,self,i)) MelMenuItem(popUpMenu , label = 'Delete', c = Callback(puppetBoxLib.doDeleteModule,self,i)) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Menus #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildPuppetMenu( self, *a ): self.UI_PuppetMenu.clear() #>>> Puppet Options MelMenuItem( self.UI_PuppetMenu, l="New", c=lambda *a:puppetBoxLib.doPuppetCreate(self)) #Build load menu self.scenePuppets = modules.returnPuppetObjects() loadMenu = MelMenuItem( self.UI_PuppetMenu, l='Pick Puppet:', subMenu=True) if self.scenePuppets: for i,m in enumerate(self.scenePuppets): MelMenuItem( loadMenu, l="%s"%m, c= Callback(puppetBoxLib.activatePuppet,self,m)) else: MelMenuItem( loadMenu, l="None found") if self.Puppet: MelMenuItemDiv( self.UI_PuppetMenu ) MelMenuItem( self.UI_PuppetMenu, l="Initialize", c=lambda *a:puppetBoxLib.initializePuppet(self)) if not self.Puppet.refState: MelMenuItem( self.UI_PuppetMenu, l="Verify", c=lambda *a:puppetBoxLib.verifyPuppet(self)) MelMenuItem( self.UI_PuppetMenu, l="Delete", c=lambda *a:puppetBoxLib.deletePuppet(self)) #>>> Reset Options MelMenuItemDiv( self.UI_PuppetMenu ) MelMenuItem( self.UI_PuppetMenu, l="Reload", c=lambda *a: self.reload()) MelMenuItem( self.UI_PuppetMenu, l="Reset", c=lambda *a: self.reset()) def buildAddModulesMenu( self, *a ): self.UI_AddModulesMenu.clear() for i,m in enumerate(self.addModules): MelMenuItem( self.UI_AddModulesMenu, l="%s"%m, c=lambda *a:puppetBoxLib.addModule(self,m)) MelMenuItemDiv( self.UI_AddModulesMenu ) def buildOptionsMenu( self, *a ): self.UI_OptionsMenu.clear() MelMenuItem( self.UI_OptionsMenu, l="Force module menu reload", c=lambda *a:puppetBoxLib.uiForceModuleUpdateUI(self)) def reset(self): Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars,run)) def reload(self): run() def buildHelpMenu( self, *a ): self.UI_HelpMenu.clear() MelMenuItem( self.UI_HelpMenu, l="Show Help", cb=self.ShowHelpOptionVar.value, c= lambda *a: self.do_showHelpToggle()) MelMenuItem( self.UI_HelpMenu, l="Print Set Report", c=lambda *a: self.printReport() ) MelMenuItem( self.UI_HelpMenu, l="Print Tools Help", c=lambda *a: self.printHelp() ) MelMenuItemDiv( self.UI_HelpMenu ) MelMenuItem( self.UI_HelpMenu, l="About", c=lambda *a: self.showAbout() ) def do_showHelpToggle( self): guiFactory.toggleMenuShowState(self.ShowHelpOptionVar.value,self.helpBlurbs) self.ShowHelpOptionVar.toggle() def showAbout(self): window = mc.window( title="About", iconName='About', ut = 'cgmUITemplate',resizeToFitChildren=True ) mc.columnLayout( adjustableColumn=True ) guiFactory.header(self.toolName,overrideUpper = True) mc.text(label='>>>A Part of the cgmTools Collection<<<', ut = 'cgmUIInstructionsTemplate') guiFactory.headerBreak() guiFactory.lineBreak() descriptionBlock = guiFactory.textBlock(self.description) guiFactory.lineBreak() mc.text(label=('%s%s' %('Written by: ',self.author))) mc.text(label=('%s%s%s' %('Copyright ',self.owner,', 2011'))) guiFactory.lineBreak() mc.text(label='Version: %s' % self.version) mc.text(label='') guiFactory.doButton('Visit Tool Webpage', 'import webbrowser;webbrowser.open(" http://www.cgmonks.com/tools/maya-tools/puppetBox/")') guiFactory.doButton('Close', 'import maya.cmds as mc;mc.deleteUI(\"' + window + '\", window=True)') mc.setParent( '..' ) mc.showWindow( window ) def printHelp(self): help(puppetBoxLib) def printReport(self): puppetBoxLib.printReport(self) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Layouts #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def Main_buildLayout(self,parent): def modeSet( item ): i = self.setModes.index(item) self.SetToolsModeOptionVar.set( i ) self.setMode = i MainForm = MelFormLayout(parent) TopSection = MelColumnLayout(MainForm) SetHeader = guiFactory.header('Puppet') #>>> Top Section #Report self.puppetReport = MelLabel(TopSection, bgc = dictionary.returnStateColor('help'), align = 'center', label = '...', h=20) MelSeparator(TopSection,ut='cgmUITemplate',h=5) #Edit name and state mode buttons MasterPuppetRow = MelHSingleStretchLayout(TopSection,padding = 5) MelSpacer(MasterPuppetRow,w=5) self.MasterPuppetTF = MelTextField(MasterPuppetRow, bgc = [1,1,1], ec = lambda *a:puppetBoxLib.updatePuppetName(self)) MasterPuppetRow.setStretchWidget(self.MasterPuppetTF) self.puppetStateButtonsDict = {} for i,s in enumerate(self.puppetStateOptions): self.puppetStateButtonsDict[i] = guiFactory.doButton2(MasterPuppetRow,s.capitalize(), "print '%s'"%s, enable = False) MelSpacer(MasterPuppetRow,w=20) MasterPuppetRow.layout() #MelSeparator(TopSection,ut='cgmUITemplate',h=2) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Define State Rows #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #Initial State Mode Row self.PuppetModeCollection = MelRadioCollection() self.PuppetModeCollectionChoices = [] self.InitialStateModeRow = MelHSingleStretchLayout(TopSection,padding = 2,vis=False) MelSpacer(self.InitialStateModeRow,w=5) MelLabel(self.InitialStateModeRow,l='Template Modes') Spacer = MelSeparator(self.InitialStateModeRow,w=10) for i,item in enumerate(CharacterTypes): self.PuppetModeCollectionChoices.append(self.PuppetModeCollection.createButton(self.InitialStateModeRow,label=item, onCommand = Callback(puppetBoxLib.setPuppetBaseMode,self,i))) MelSpacer(self.InitialStateModeRow,w=3) self.InitialStateModeRow.setStretchWidget( Spacer ) MelSpacer(self.InitialStateModeRow,w=2) self.InitialStateModeRow.layout() mc.radioCollection(self.PuppetModeCollection ,edit=True,sl= (self.PuppetModeCollectionChoices[ (self.PuppetModeOptionVar.value) ])) self.UI_StateRows['define'].append(self.InitialStateModeRow) self.AxisFrame = MelFrameLayout(TopSection,label = 'Axis',vis=False, collapse=True, collapsable=True, ut = 'cgmUIHeaderTemplate') self.UI_StateRows['define'].append(self.AxisFrame) MelSeparator(TopSection,style='none',h=5) #Aim Axis Mode Row self.AimAxisCollection = MelRadioCollection() self.AimAxisCollectionChoices = [] self.AimAxisRow = MelHSingleStretchLayout(self.AxisFrame,padding = 2,vis=False) MelSpacer(self.AimAxisRow,w=5) MelLabel(self.AimAxisRow,l='Aim ') Spacer = MelSeparator(self.AimAxisRow,w=10) for i,item in enumerate(axisDirectionsByString): self.AimAxisCollectionChoices.append(self.AimAxisCollection.createButton(self.AimAxisRow,label=item, onCommand = Callback(puppetBoxLib.setPuppetAxisAim,self,i))) MelSpacer(self.AimAxisRow,w=3) self.AimAxisRow.setStretchWidget( Spacer ) MelSpacer(self.AimAxisRow,w=2) self.AimAxisRow.layout() #Up Axis Mode Row self.UpAxisCollection = MelRadioCollection() self.UpAxisCollectionChoices = [] self.UpAxisRow = MelHSingleStretchLayout(self.AxisFrame,padding = 2,vis=False) MelSpacer(self.UpAxisRow,w=5) MelLabel(self.UpAxisRow,l='Up ') Spacer = MelSeparator(self.UpAxisRow,w=10) for i,item in enumerate(axisDirectionsByString): self.UpAxisCollectionChoices.append(self.UpAxisCollection.createButton(self.UpAxisRow,label=item, onCommand = Callback(puppetBoxLib.setPuppetAxisUp,self,i))) MelSpacer(self.UpAxisRow,w=3) self.UpAxisRow.setStretchWidget( Spacer ) MelSpacer(self.UpAxisRow,w=2) self.UpAxisRow.layout() #Out Axis Mode Row self.OutAxisCollection = MelRadioCollection() self.OutAxisCollectionChoices = [] self.OutAxisRow = MelHSingleStretchLayout(self.AxisFrame,padding = 2,vis=False) MelSpacer(self.OutAxisRow,w=5) MelLabel(self.OutAxisRow,l='Out ') Spacer = MelSeparator(self.OutAxisRow,w=10) for i,item in enumerate(axisDirectionsByString): self.OutAxisCollectionChoices.append(self.OutAxisCollection.createButton(self.OutAxisRow,label=item, onCommand = Callback(puppetBoxLib.setPuppetAxisOut,self,i))) MelSpacer(self.OutAxisRow,w=3) self.OutAxisRow.setStretchWidget( Spacer ) MelSpacer(self.OutAxisRow,w=2) self.OutAxisRow.layout() #Set toggles on menu mc.radioCollection(self.AimAxisCollection ,edit=True,sl= (self.AimAxisCollectionChoices[ (self.PuppetAimOptionVar.value) ])) mc.radioCollection(self.UpAxisCollection ,edit=True,sl= (self.UpAxisCollectionChoices[ (self.PuppetUpOptionVar.value) ])) mc.radioCollection(self.OutAxisCollection ,edit=True,sl= (self.OutAxisCollectionChoices[ (self.PuppetOutOptionVar.value) ])) #Initial State Button Row self.InitialStateButtonRow = MelHLayout(TopSection, h = 20,vis=False,padding = 5) guiFactory.doButton2(self.InitialStateButtonRow,'Add Geo', lambda *a:puppetBoxLib.doAddGeo(self)) guiFactory.doButton2(self.InitialStateButtonRow,'Build Size Template', lambda *a:puppetBoxLib.doBuildSizeTemplate(self)) self.InitialStateButtonRow.layout() self.UI_StateRows['define'].append(self.InitialStateButtonRow) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Multi Module #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> All Sets menu AllModulesRow = MelFormLayout(MainForm,height = 20) activeState = True i = 1 tmpActive = MelCheckBox(AllModulesRow, annotation = 'Sets all sets active', value = activeState, onCommand = Callback(puppetBoxLib.doSetAllSetsAsActive,self), offCommand = Callback(puppetBoxLib.doSetAllSetsAsInactive,self)) tmpSel = guiFactory.doButton2(AllModulesRow, ' s ', 'Select All Loaded/Active Sets') # Mode toggle box self.ModuleModeOptionMenu = MelOptionMenu(AllModulesRow, cc = modeSet) tmpKey = guiFactory.doButton2(AllModulesRow, ' k ', 'Key All Sets') tmpDeleteKey = guiFactory.doButton2(AllModulesRow, ' d ', 'Delete All Set Keys') tmpReset = guiFactory.doButton2(AllModulesRow, ' r ', 'Reset All Set Keys') mc.formLayout(AllModulesRow, edit = True, af = [(tmpActive, "left", 10), (tmpReset,"right",10)], ac = [(tmpSel,"left",0,tmpActive), (self.ModuleModeOptionMenu,"left",4,tmpSel), (self.ModuleModeOptionMenu,"right",4,tmpKey), (tmpKey,"right",2,tmpDeleteKey), (tmpDeleteKey,"right",2,tmpReset) ]) #>>> Sets building section allPopUpMenu = MelPopupMenu(self.ModuleModeOptionMenu ,button = 3) allCategoryMenu = MelMenuItem(allPopUpMenu, label = 'Make Type:', sm = True) #>>> Sets building section ModuleListScroll = MelScrollLayout(MainForm,cr = 1, ut = 'cgmUISubTemplate') ModuleMasterForm = MelFormLayout(ModuleListScroll) self.ModuleListColumn = MelColumnLayout(ModuleMasterForm,ut = 'cgmUIInstructionsTemplate', adj = True, rowSpacing = 2) self.helpInfo = MelLabel(MainForm, h=20, l = "Add a Puppet", ut = 'cgmUIInstructionsTemplate', al = 'center', ww = True,vis = self.ShowHelpOptionVar.value) self.helpBlurbs.extend([self.helpInfo ]) VerifyRow = guiFactory.doButton2(MainForm, 'Check Puppet', 'Create new buffer from selected buffer') ModuleMasterForm(edit = True, af = [(self.ModuleListColumn,"top",0), (self.ModuleListColumn,"left",0), (self.ModuleListColumn,"right",0), (self.ModuleListColumn,"bottom",0)]) MainForm(edit = True, af = [(TopSection,"top",0), (TopSection,"left",0), (TopSection,"right",0), (AllModulesRow,"left",0), (AllModulesRow,"right",0), (ModuleListScroll,"left",0), (ModuleListScroll,"right",0), (ModuleListScroll,"left",0), (ModuleListScroll,"right",0), (self.helpInfo,"left",8), (self.helpInfo,"right",8), (VerifyRow,"left",4), (VerifyRow,"right",4), (VerifyRow,"bottom",4)], ac = [(AllModulesRow,"top",2,TopSection), (ModuleListScroll,"top",2,AllModulesRow), (ModuleListScroll,"bottom",0,self.helpInfo), (self.helpInfo,"bottom",0,VerifyRow)], attachNone = [(VerifyRow,"top")])
def createUI(self,parent): """ Create the UI """ IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked',value = 0) self.setupVariables() def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ self.mmActionOptionVar.set(1) command killUI() sel = search.selectCheck() selPair = search.checkSelectionLength(2) ShowMatch = search.matchObjectCheck() IsClickedOptionVar.set(1) mc.menu(parent,e = True, deleteAllItems = True) MelMenuItem(parent, en = sel, l = 'Reset Selected', c = lambda *a:buttonAction(animToolsLib.ml_resetChannelsCall()), rp = 'N') MelMenuItem(parent, en = sel, l = 'dragBreakdown', c = lambda *a:buttonAction(animToolsLib.ml_breakdownDraggerCall()), rp = 'S') #>>> Keying Options KeyMenu = MelMenuItem( parent, l='Key type', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyTypeOptionVar.value == 0: regKeyOption = True bdKeyOption = False else: regKeyOption = False bdKeyOption = True KeyMenuCollection.createButton(KeyMenu,l=' Reg ', c= Callback(self.toggleVarAndReset,self.KeyTypeOptionVar), rb= regKeyOption ) KeyMenuCollection.createButton(KeyMenu,l=' Breakdown ', c= Callback(self.toggleVarAndReset,self.KeyTypeOptionVar), rb= bdKeyOption ) #>>> Keying Mode KeyMenu = MelMenuItem( parent, l='Key Mode', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyModeOptionVar.value == 0: regModeOption = True cbModeOption = False else: regModeOption = False cbModeOption = True KeyMenuCollection.createButton(KeyMenu,l=' Default ', c= Callback(self.toggleVarAndReset,self.KeyModeOptionVar), rb= regModeOption ) KeyMenuCollection.createButton(KeyMenu,l=' Channelbox ', c= Callback(self.toggleVarAndReset,self.KeyModeOptionVar), rb= cbModeOption ) MelMenuItemDiv(parent) MelMenuItem(parent,l = 'autoTangent', c = lambda *a: buttonAction(mel.eval('autoTangent'))) MelMenuItem(parent,l = 'tweenMachine', c = lambda *a: buttonAction(mel.eval('tweenMachine'))) MelMenuItem(parent, l = 'cgm.animTools', c = lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItemDiv(parent) MelMenuItem(parent,l = 'ml Set Key', c = lambda *a: buttonAction(animToolsLib.ml_setKeyCall())) MelMenuItem(parent,l = 'ml Hold', c = lambda *a: buttonAction(animToolsLib.ml_holdCall())) MelMenuItem(parent,l = 'ml Delete Key', c = lambda *a: buttonAction(animToolsLib.ml_deleteKeyCall())) MelMenuItem(parent,l = 'ml Arc Tracer', c = lambda *a: buttonAction(animToolsLib.ml_arcTracerCall())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars(self.optionVars))
def createUI(self, parent): """ Create the UI """ IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked') self.mmActionOptionVar = OptionVarFactory('cgmVar_mmAction') def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ self.mmActionOptionVar.set(1) command killUI() sel = search.selectCheck() selPair = search.checkSelectionLength(2) ShowMatch = search.matchObjectCheck() IsClickedOptionVar.set(1) mc.menu(parent, e=True, deleteAllItems=True) MelMenuItem( parent, en=sel, l='Reset Selected', c=lambda *a: buttonAction(animToolsLib.ml_resetChannelsCall()), rp='N') MelMenuItem( parent, en=sel, l='dragBreakdown', c=lambda *a: buttonAction(animToolsLib.ml_breakdownDraggerCall()), rp='S') MelMenuItemDiv(parent) MelMenuItem(parent, l='autoTangent', c=lambda *a: buttonAction(mel.eval('autoTangent'))) MelMenuItem(parent, l='tweenMachine', c=lambda *a: buttonAction(mel.eval('tweenMachine'))) MelMenuItem(parent, l='cgm.animTools', c=lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItemDiv(parent) MelMenuItem(parent, l='ml Set Key', c=lambda *a: buttonAction(animToolsLib.ml_setKeyCall())) MelMenuItem(parent, l='ml Hold', c=lambda *a: buttonAction(animToolsLib.ml_holdCall())) MelMenuItem(parent, l='ml Delete Key', c=lambda *a: buttonAction(animToolsLib.ml_deleteKeyCall())) MelMenuItem(parent, l='ml Arc Tracer', c=lambda *a: buttonAction(animToolsLib.ml_arcTracerCall())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars( self.optionVars))
class setToolsClass(BaseMelWindow): from cgm.lib import guiFactory guiFactory.initializeTemplates() USE_Template = 'cgmUITemplate' WINDOW_NAME = 'cgmSetToolsWindow' WINDOW_TITLE = 'cgm.setTools - %s' % __version__ DEFAULT_SIZE = 275, 400 DEFAULT_MENU = None RETAIN = True MIN_BUTTON = True MAX_BUTTON = False FORCE_DEFAULT_SIZE = False #always resets the size of the window when its re-created def __init__(self): self.toolName = 'cgm.setTools' self.description = 'This is a series of tools for working with cgm Sets' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.version = __version__ self.optionVars = [] self.setTypes = [ 'NONE', 'animation', 'layout', 'modeling', 'td', 'fx', 'lighting' ] self.setModes = ['<<< All Loaded Sets >>>', '<<< Active Sets >>>'] self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] self.objectSets = [] #Menu self.setupVariables() self.setMode = self.SetToolsModeOptionVar.value setToolsLib.updateObjectSets(self) self.UI_OptionsMenu = MelMenu(l='Options', pmc=self.buildOptionsMenu) self.UI_HelpMenu = MelMenu(l='Help', pmc=self.buildHelpMenu) self.ShowHelpOption = mc.optionVar(q='cgmVar_AnimToolsShowHelp') #GUI self.Main_buildLayout(self) self.show() def setupVariables(self): self.ActiveObjectSetsOptionVar = OptionVarFactory( 'cgmVar_activeObjectSets', defaultValue=['']) self.ActiveRefsOptionVar = OptionVarFactory('cgmVar_activeRefs', defaultValue=['']) self.ActiveTypesOptionVar = OptionVarFactory('cgmVar_activeTypes', defaultValue=['']) self.SetToolsModeOptionVar = OptionVarFactory('cgmVar_setToolsMode', defaultValue=0) self.KeyTypeOptionVar = OptionVarFactory('cgmVar_KeyType', defaultValue=0) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_setToolsShowHelp', defaultValue=0) self.MaintainLocalSetGroupOptionVar = OptionVarFactory( 'cgmVar_MaintainLocalSetGroup', defaultValue=0) self.HideSetGroupOptionVar = OptionVarFactory('cgmVar_HideSetGroups', defaultValue=1) self.HideNonQssOptionVar = OptionVarFactory('cgmVar_HideNonQss', defaultValue=1) self.HideAnimLayerSetsOptionVar = OptionVarFactory( 'cgmVar_HideAnimLayerSets', defaultValue=1) self.HideMayaSetsOptionVar = OptionVarFactory('cgmVar_HideMayaSets', defaultValue=1) guiFactory.appendOptionVarList(self, self.ActiveObjectSetsOptionVar.name) guiFactory.appendOptionVarList(self, self.ActiveRefsOptionVar.name) guiFactory.appendOptionVarList(self, self.ActiveTypesOptionVar.name) guiFactory.appendOptionVarList(self, self.SetToolsModeOptionVar.name) guiFactory.appendOptionVarList(self, self.ShowHelpOptionVar.name) guiFactory.appendOptionVarList(self, self.KeyTypeOptionVar.name) guiFactory.appendOptionVarList(self, self.HideSetGroupOptionVar.name) guiFactory.appendOptionVarList(self, self.HideNonQssOptionVar.name) guiFactory.appendOptionVarList( self, self.MaintainLocalSetGroupOptionVar.name) guiFactory.appendOptionVarList(self, self.HideAnimLayerSetsOptionVar.name) guiFactory.appendOptionVarList(self, self.HideMayaSetsOptionVar.name) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Menus #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildOptionsMenu(self, *a): self.UI_OptionsMenu.clear() #Ref menu self.refPrefixDict = {} self.activeRefsCBDict = {} if self.refPrefixes and len(self.refPrefixes) > 1: refMenu = MelMenuItem(self.UI_OptionsMenu, l='Load Refs:', subMenu=True) MelMenuItem(refMenu, l='All', c=Callback(setToolsLib.doSetAllRefState, self, True)) MelMenuItemDiv(refMenu) for i, n in enumerate(self.refPrefixes): self.refPrefixDict[i] = n activeState = False if self.ActiveRefsOptionVar.value: if n in self.ActiveRefsOptionVar.value: activeState = True tmp = MelMenuItem(refMenu, l=n, cb=activeState, c=Callback(setToolsLib.doSetRefState, self, i, not activeState)) self.activeRefsCBDict[i] = tmp MelMenuItemDiv(refMenu) MelMenuItem(refMenu, l='Clear', c=Callback(setToolsLib.doSetAllRefState, self, False)) #Types menu self.typeDict = {} self.activeTypesCBDict = {} if self.setTypes: typeMenu = MelMenuItem(self.UI_OptionsMenu, l='Load Types: ', subMenu=True) MelMenuItem(typeMenu, l='All', c=Callback(setToolsLib.doSetAllTypeState, self, True)) MelMenuItemDiv(typeMenu) for i, n in enumerate(self.setTypes): self.typeDict[i] = n activeState = False if self.ActiveTypesOptionVar.value: if n in self.ActiveTypesOptionVar.value: activeState = True tmp = MelMenuItem(typeMenu, l=n, cb=activeState, c=Callback(setToolsLib.doSetTypeState, self, i, not activeState)) self.activeTypesCBDict[i] = tmp MelMenuItemDiv(typeMenu) MelMenuItem(typeMenu, l='Clear', c=Callback(setToolsLib.doSetAllTypeState, self, False)) #>>> Grouping Options GroupingMenu = MelMenuItem(self.UI_OptionsMenu, l='Grouping', subMenu=True) #guiFactory.appendOptionVarList(self,'cgmVar_MaintainLocalSetGroup') MelMenuItem(GroupingMenu, l="Group Local", c=lambda *a: setToolsLib.doGroupLocal(self)) MelMenuItem(GroupingMenu, l="Maintain Local Set Group", cb=mc.optionVar(q='cgmVar_MaintainLocalSetGroup'), c=lambda *a: setToolsLib.doSetMaintainLocalSetGroup(self)) #>>> Autohide Options HidingMenu = MelMenuItem(self.UI_OptionsMenu, l='Auto Hide', subMenu=True) #guiFactory.appendOptionVarList(self,'cgmVar_MaintainLocalSetGroup') MelMenuItem(HidingMenu, l="Anim Layer Sets", cb=self.HideAnimLayerSetsOptionVar.value, c=lambda *a: setToolsLib.uiToggleOptionCB( self, self.HideAnimLayerSetsOptionVar)) MelMenuItem(HidingMenu, l="Maya Sets", cb=self.HideMayaSetsOptionVar.value, c=lambda *a: setToolsLib.uiToggleOptionCB( self, self.HideMayaSetsOptionVar)) MelMenuItem(HidingMenu, l="Non Qss Sets", cb=self.HideNonQssOptionVar.value, c=lambda *a: setToolsLib.uiToggleOptionCB( self, self.HideNonQssOptionVar)) MelMenuItem(HidingMenu, l="Set Groups", cb=self.HideSetGroupOptionVar.value, c=lambda *a: setToolsLib.uiToggleOptionCB( self, self.HideSetGroupOptionVar)) #>>> Keying Options KeyMenu = MelMenuItem(self.UI_OptionsMenu, l='Key type', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyTypeOptionVar.value == 0: regKeyOption = True bdKeyOption = False else: regKeyOption = False bdKeyOption = True KeyMenuCollection.createButton( KeyMenu, l=' Reg ', c=lambda *a: self.KeyTypeOptionVar.set(0), rb=regKeyOption) KeyMenuCollection.createButton( KeyMenu, l=' Breakdown ', c=lambda *a: self.KeyTypeOptionVar.set(1), rb=bdKeyOption) #>>> Reset Options MelMenuItemDiv(self.UI_OptionsMenu) MelMenuItem(self.UI_OptionsMenu, l="Reload", c=lambda *a: self.reload()) MelMenuItem(self.UI_OptionsMenu, l="Reset", c=lambda *a: self.reset()) def reset(self): Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars, run)) def reload(self): run() def buildHelpMenu(self, *a): self.UI_HelpMenu.clear() MelMenuItem(self.UI_HelpMenu, l="Show Help", cb=self.ShowHelpOption, c=lambda *a: self.do_showHelpToggle()) MelMenuItem(self.UI_HelpMenu, l="Print Set Report", c=lambda *a: self.printReport()) MelMenuItem(self.UI_HelpMenu, l="Print Tools Help", c=lambda *a: self.printHelp()) MelMenuItemDiv(self.UI_HelpMenu) MelMenuItem(self.UI_HelpMenu, l="About", c=lambda *a: self.showAbout()) def do_showHelpToggle(self): guiFactory.toggleMenuShowState(self.ShowHelpOption, self.helpBlurbs) mc.optionVar(iv=('cgmVar_setToolsShowHelp', not self.ShowHelpOption)) self.ShowHelpOption = mc.optionVar(q='cgmVar_setToolsShowHelp') def showAbout(self): window = mc.window(title="About", iconName='About', ut='cgmUITemplate', resizeToFitChildren=True) mc.columnLayout(adjustableColumn=True) guiFactory.header(self.toolName, overrideUpper=True) mc.text(label='>>>A Part of the cgmTools Collection<<<', ut='cgmUIInstructionsTemplate') guiFactory.headerBreak() guiFactory.lineBreak() descriptionBlock = guiFactory.textBlock(self.description) guiFactory.lineBreak() mc.text(label=('%s%s' % ('Written by: ', self.author))) mc.text(label=('%s%s%s' % ('Copyright ', self.owner, ', 2011'))) guiFactory.lineBreak() mc.text(label='Version: %s' % self.version) mc.text(label='') guiFactory.doButton( 'Visit Tool Webpage', 'import webbrowser;webbrowser.open(" http://www.cgmonks.com/tools/maya-tools/setTools/")' ) guiFactory.doButton( 'Close', 'import maya.cmds as mc;mc.deleteUI(\"' + window + '\", window=True)') mc.setParent('..') mc.showWindow(window) def printHelp(self): help(setToolsLib) def printReport(self): setToolsLib.printReport(self) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Layouts #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def Main_buildLayout(self, parent): def modeSet(item): i = self.setModes.index(item) self.SetToolsModeOptionVar.set(i) self.setMode = i MainForm = MelFormLayout(parent) #>>> Snap Section SetHeader = guiFactory.header('Sets') HelpInfo = MelLabel( MainForm, l= " Set buffer options: Set active, select, change name,add,remove,key,purge", ut='cgmUIInstructionsTemplate', al='center', ww=True, vis=self.ShowHelpOption) self.helpBlurbs.extend([HelpInfo]) #>>> All Sets menu AllSetsRow = MelFormLayout(MainForm, height=20) activeState = True i = 1 if self.objectSets: for b in self.objectSets: if b not in self.ActiveObjectSetsOptionVar.value: activeState = False else: activeState = False tmpActive = MelCheckBox( AllSetsRow, annotation='Sets all sets active', value=activeState, onCommand=Callback(setToolsLib.doSetAllSetsAsActive, self), offCommand=Callback(setToolsLib.doSetAllSetsAsInactive, self)) tmpSel = guiFactory.doButton2( AllSetsRow, ' s ', lambda *a: setToolsLib.doSelectMultiSets( self, self.SetToolsModeOptionVar.value), 'Select All Loaded/Active Sets') # Mode toggle box self.SetModeOptionMenu = MelOptionMenu(AllSetsRow, cc=modeSet) for m in self.setModes: self.SetModeOptionMenu.append(m) self.SetModeOptionMenu.selectByIdx(self.setMode, False) tmpKey = guiFactory.doButton2( AllSetsRow, ' k ', lambda *a: setToolsLib.doKeyMultiSets( self, self.SetToolsModeOptionVar.value), 'Key All Sets') tmpDeleteKey = guiFactory.doButton2( AllSetsRow, ' d ', lambda *a: setToolsLib.doDeleteMultiCurrentKeys( self, self.SetToolsModeOptionVar.value), 'Delete All Set Keys') tmpReset = guiFactory.doButton2( AllSetsRow, ' r ', lambda *a: setToolsLib.doResetMultiSets( self, self.SetToolsModeOptionVar.value), 'Reset All Set Keys') mc.formLayout(AllSetsRow, edit=True, af=[(tmpActive, "left", 10), (tmpReset, "right", 10)], ac=[(tmpSel, "left", 0, tmpActive), (self.SetModeOptionMenu, "left", 4, tmpSel), (self.SetModeOptionMenu, "right", 4, tmpKey), (tmpKey, "right", 2, tmpDeleteKey), (tmpDeleteKey, "right", 2, tmpReset)]) #>>> Sets building section allPopUpMenu = MelPopupMenu(self.SetModeOptionMenu, button=3) allCategoryMenu = MelMenuItem(allPopUpMenu, label='Make Type:', sm=True) multiMakeQssMenu = MelMenuItem(allPopUpMenu, label='Make Qss', c=Callback(setToolsLib.doMultiSetQss, self, True)) multiMakeNotQssMenu = MelMenuItem(allPopUpMenu, label='Clear Qss State', c=Callback(setToolsLib.doMultiSetQss, self, False)) #Mulit set type for n in self.setTypes: MelMenuItem(allCategoryMenu, label=n, c=Callback(setToolsLib.doMultiSetType, self, self.SetToolsModeOptionVar.value, n)) #>>> Sets building section SetListScroll = MelScrollLayout(MainForm, cr=1, ut='cgmUISubTemplate') SetMasterForm = MelFormLayout(SetListScroll) SetListColumn = MelColumnLayout(SetMasterForm, adj=True, rowSpacing=3) self.objectSetsDict = {} self.activeSetsCBDict = {} for b in self.objectSets: #Store the info to a dict try: i = self.setInstancesFastIndex[b] # get the index sInstance = self.setInstances[i] # fast link to the instance except: raise StandardError("'%s' failed to query an active instance" % b) #see if the no no fields are enabled enabledMenuLogic = True if sInstance.mayaSetState or sInstance.refState: enabledMenuLogic = False tmpSetRow = MelFormLayout(SetListColumn, height=20) #Get check box state activeState = False if sInstance.nameShort in self.ActiveObjectSetsOptionVar.value: activeState = True tmpActive = MelCheckBox( tmpSetRow, annotation='make set as active', value=activeState, onCommand=Callback(setToolsLib.doSetSetAsActive, self, i), offCommand=Callback(setToolsLib.doSetSetAsInactive, self, i)) self.activeSetsCBDict[i] = tmpActive tmpSel = guiFactory.doButton2( tmpSetRow, ' s ', Callback(setToolsLib.doSelectSetObjects, self, i), 'Select the set objects') tmpName = MelTextField(tmpSetRow, w=100, ut='cgmUIReservedTemplate', text=sInstance.nameShort, editable=enabledMenuLogic) tmpName(edit=True, ec=Callback(setToolsLib.doUpdateSetName, self, tmpName, i)) tmpAdd = guiFactory.doButton2(tmpSetRow, '+', Callback(setToolsLib.doAddSelected, self, i), 'Add selected to the set', en=not sInstance.refState) tmpRem = guiFactory.doButton2(tmpSetRow, '-', Callback( setToolsLib.doRemoveSelected, self, i), 'Remove selected to the set', en=not sInstance.refState) tmpKey = guiFactory.doButton2( tmpSetRow, 'k', Callback(setToolsLib.doKeySet, self, i), 'Key set') tmpDeleteKey = guiFactory.doButton2( tmpSetRow, 'd', Callback(setToolsLib.doDeleteCurrentSetKey, self, i), 'delete set key') tmpReset = guiFactory.doButton2( tmpSetRow, 'r', Callback(setToolsLib.doResetSet, self, i), 'Reset Set') mc.formLayout(tmpSetRow, edit=True, af=[(tmpActive, "left", 4), (tmpReset, "right", 2)], ac=[(tmpSel, "left", 0, tmpActive), (tmpName, "left", 2, tmpSel), (tmpName, "right", 4, tmpAdd), (tmpAdd, "right", 2, tmpRem), (tmpRem, "right", 2, tmpKey), (tmpKey, "right", 2, tmpDeleteKey), (tmpDeleteKey, "right", 2, tmpReset)]) MelSpacer(tmpSetRow, w=2) #Build pop up for text field popUpMenu = MelPopupMenu(tmpName, button=3) MelMenuItem(popUpMenu, label="<<<%s>>>" % b, enable=False) if not enabledMenuLogic: if sInstance.mayaSetState: MelMenuItem(popUpMenu, label="<Maya Default Set>", enable=False) if sInstance.refState: MelMenuItem(popUpMenu, label="<Referenced>", enable=False) qssState = sInstance.qssState qssMenu = MelMenuItem(popUpMenu, label='Qss', cb=qssState, en=enabledMenuLogic, c=Callback(self.setInstances[i].isQss, not qssState)) categoryMenu = MelMenuItem(popUpMenu, label='Make Type:', sm=True, en=enabledMenuLogic) for n in self.setTypes: MelMenuItem(categoryMenu, label=n, c=Callback(setToolsLib.guiDoSetType, self, i, n)) MelMenuItem(popUpMenu, label='Copy Set', c=Callback(setToolsLib.doCopySet, self, i)) MelMenuItem(popUpMenu, label='Purge', en=enabledMenuLogic, c=Callback(setToolsLib.doPurgeSet, self, i)) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu, label='Delete', en=enabledMenuLogic, c=Callback(setToolsLib.doDeleteSet, self, i)) NewSetRow = guiFactory.doButton2( MainForm, 'Create Set', lambda *a: setToolsLib.doCreateSet(self), 'Create new buffer from selected buffer') SetMasterForm(edit=True, af=[(SetListColumn, "top", 0), (SetListColumn, "left", 0), (SetListColumn, "right", 0), (SetListColumn, "bottom", 0)]) MainForm(edit=True, af=[(SetHeader, "top", 0), (SetHeader, "left", 0), (SetHeader, "right", 0), (HelpInfo, "left", 0), (HelpInfo, "right", 0), (AllSetsRow, "left", 0), (AllSetsRow, "right", 0), (SetListScroll, "left", 0), (SetListScroll, "right", 0), (NewSetRow, "left", 4), (NewSetRow, "right", 4), (NewSetRow, "bottom", 4)], ac=[(HelpInfo, "top", 0, SetHeader), (AllSetsRow, "top", 2, HelpInfo), (SetListScroll, "top", 2, AllSetsRow), (SetListScroll, "bottom", 0, NewSetRow)], attachNone=[(NewSetRow, "top")])
class setKeyMarkingMenu(BaseMelWindow): _DEFAULT_MENU_PARENT = 'viewPanes' def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 0) mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 0) panel = mc.getPanel(up=True) if panel: # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes' if 'MayaWindow' in mc.panel(panel, q=True, ctl=True): panel = 'viewPanes' sel = search.selectCheck() IsClickedOptionVar.set(0) mmActionOptionVar.set(0) if mc.popupMenu('cgmMM', ex=True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex=True): try: mc.popupMenu('cgmMM', ctl=0, alt=0, sh=0, mm=1, b=1, aob=1, p=panel, pmc=lambda *a: self.createUI('cgmMM')) except: guiFactory.warning('Exception on set key marking menu') mel.eval( 'performSetKeyframeArgList 1 {"0", "animationList"};') def createUI(self, parent): """ Create the UI """ IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked') self.mmActionOptionVar = OptionVarFactory('cgmVar_mmAction') def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ self.mmActionOptionVar.set(1) command killUI() sel = search.selectCheck() selPair = search.checkSelectionLength(2) ShowMatch = search.matchObjectCheck() IsClickedOptionVar.set(1) mc.menu(parent, e=True, deleteAllItems=True) MelMenuItem( parent, en=sel, l='Reset Selected', c=lambda *a: buttonAction(animToolsLib.ml_resetChannelsCall()), rp='N') MelMenuItem( parent, en=sel, l='dragBreakdown', c=lambda *a: buttonAction(animToolsLib.ml_breakdownDraggerCall()), rp='S') MelMenuItemDiv(parent) MelMenuItem(parent, l='autoTangent', c=lambda *a: buttonAction(mel.eval('autoTangent'))) MelMenuItem(parent, l='tweenMachine', c=lambda *a: buttonAction(mel.eval('tweenMachine'))) MelMenuItem(parent, l='cgm.animTools', c=lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItemDiv(parent) MelMenuItem(parent, l='ml Set Key', c=lambda *a: buttonAction(animToolsLib.ml_setKeyCall())) MelMenuItem(parent, l='ml Hold', c=lambda *a: buttonAction(animToolsLib.ml_holdCall())) MelMenuItem(parent, l='ml Delete Key', c=lambda *a: buttonAction(animToolsLib.ml_deleteKeyCall())) MelMenuItem(parent, l='ml Arc Tracer', c=lambda *a: buttonAction(animToolsLib.ml_arcTracerCall())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars( self.optionVars))
def createUI(self, parent): """ Create the UI """ IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', value=0) self.setupVariables() def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ self.mmActionOptionVar.set(1) command killUI() sel = search.selectCheck() selPair = search.checkSelectionLength(2) ShowMatch = search.matchObjectCheck() IsClickedOptionVar.set(1) mc.menu(parent, e=True, deleteAllItems=True) MelMenuItem( parent, en=sel, l='Reset Selected', c=lambda *a: buttonAction(animToolsLib.ml_resetChannelsCall()), rp='N') MelMenuItem( parent, en=sel, l='dragBreakdown', c=lambda *a: buttonAction(animToolsLib.ml_breakdownDraggerCall()), rp='S') #>>> Keying Options KeyMenu = MelMenuItem(parent, l='Key type', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyTypeOptionVar.value == 0: regKeyOption = True bdKeyOption = False else: regKeyOption = False bdKeyOption = True KeyMenuCollection.createButton(KeyMenu, l=' Reg ', c=Callback(self.toggleVarAndReset, self.KeyTypeOptionVar), rb=regKeyOption) KeyMenuCollection.createButton(KeyMenu, l=' Breakdown ', c=Callback(self.toggleVarAndReset, self.KeyTypeOptionVar), rb=bdKeyOption) #>>> Keying Mode KeyMenu = MelMenuItem(parent, l='Key Mode', subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyModeOptionVar.value == 0: regModeOption = True cbModeOption = False else: regModeOption = False cbModeOption = True KeyMenuCollection.createButton(KeyMenu, l=' Default ', c=Callback(self.toggleVarAndReset, self.KeyModeOptionVar), rb=regModeOption) KeyMenuCollection.createButton(KeyMenu, l=' Channelbox ', c=Callback(self.toggleVarAndReset, self.KeyModeOptionVar), rb=cbModeOption) MelMenuItemDiv(parent) MelMenuItem(parent, l='autoTangent', c=lambda *a: buttonAction(mel.eval('autoTangent'))) MelMenuItem(parent, l='tweenMachine', c=lambda *a: buttonAction(mel.eval('tweenMachine'))) MelMenuItem(parent, l='cgm.animTools', c=lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItemDiv(parent) MelMenuItem(parent, l='ml Set Key', c=lambda *a: buttonAction(animToolsLib.ml_setKeyCall())) MelMenuItem(parent, l='ml Hold', c=lambda *a: buttonAction(animToolsLib.ml_holdCall())) MelMenuItem(parent, l='ml Delete Key', c=lambda *a: buttonAction(animToolsLib.ml_deleteKeyCall())) MelMenuItem(parent, l='ml Arc Tracer', c=lambda *a: buttonAction(animToolsLib.ml_arcTracerCall())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars( self.optionVars))
class setToolsMarkingMenu(BaseMelWindow): _DEFAULT_MENU_PARENT = "viewPanes" def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] self.IsClickedOptionVar = OptionVarFactory("cgmVar_IsClicked", "int", 0) self.mmActionOptionVar = OptionVarFactory("cgmVar_mmAction", "int", 0) self.setupVariables() panel = mc.getPanel(up=True) if panel: # Attempt at fixing a bug of some tools not working when the pop up parent isn't 'viewPanes' if "MayaWindow" in mc.panel(panel, q=True, ctl=True): panel = "viewPanes" sel = search.selectCheck() self.IsClickedOptionVar.set(0) self.mmActionOptionVar.set(0) if mc.popupMenu("cgmMM", ex=True): mc.deleteUI("cgmMM") if panel: if mc.control(panel, ex=True): try: mc.popupMenu( "cgmMM", ctl=0, alt=0, sh=0, mm=1, b=1, aob=1, p=panel, pmc=lambda *a: self.createUI("cgmMM") ) except: guiFactory.warning("cgm.setMenu failed!") def createUI(self, parent): """ Create the UI """ def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ killUI() command mmActionOptionVar.set(1) self.setTypes = ["NONE", "animation", "layout", "modeling", "td", "fx", "lighting"] self.setModes = ["<<< All Loaded Sets >>>", "<<< Active Sets >>>"] setToolsLib.updateObjectSets(self) loadedCheck = False if self.objectSets: loadedCheck = True activeCheck = False if self.activeSets: activeCheck = True self.IsClickedOptionVar.set(1) mc.menu(parent, e=True, deleteAllItems=True) MelMenuItem( parent, en=loadedCheck, l="Select Loaded", c=Callback(setToolsLib.doSelectMultiSets, self, 0), rp="N" ) MelMenuItem( parent, en=activeCheck, l="Select Active", c=Callback(setToolsLib.doSelectMultiSets, self, 1), rp="S" ) MelMenuItem(parent, en=loadedCheck, l="Key Loaded", c=Callback(setToolsLib.doKeyMultiSets, self, 0), rp="NE") MelMenuItem(parent, en=activeCheck, l="Key Active", c=Callback(setToolsLib.doKeyMultiSets, self, 1), rp="SE") MelMenuItem( parent, en=loadedCheck, l="Delete Key (Loaded)", c=Callback(setToolsLib.doDeleteMultiCurrentKeys, self, 0), rp="NW", ) MelMenuItem( parent, en=activeCheck, l="Delete Key (Active)", c=Callback(setToolsLib.doDeleteMultiCurrentKeys, self, 1), rp="SW", ) MelMenuItemDiv(parent) MelMenuItem(parent, l="Show Gui", c=lambda *a: self.reset()) # >>> Keying Options KeyMenu = MelMenuItem(parent, l="Key type", subMenu=True) KeyMenuCollection = MelRadioMenuCollection() if self.KeyTypeOptionVar.value == 0: regKeyOption = True bdKeyOption = False else: regKeyOption = False bdKeyOption = True KeyMenuCollection.createButton( KeyMenu, l=" Reg ", c=Callback(self.toggleVarAndReset, self.KeyTypeOptionVar), rb=regKeyOption ) KeyMenuCollection.createButton( KeyMenu, l=" Breakdown ", c=Callback(self.toggleVarAndReset, self.KeyTypeOptionVar), rb=bdKeyOption ) # Ref menu self.refPrefixDict = {} self.activeRefsCBDict = {} if self.refPrefixes and len(self.refPrefixes) > 1: refMenu = MelMenuItem(parent, l="Load Refs:", subMenu=True) MelMenuItem(refMenu, l="All", c=Callback(setToolsLib.doSetAllRefState, self, True)) MelMenuItemDiv(refMenu) for i, n in enumerate(self.refPrefixes): self.refPrefixDict[i] = n activeState = False if self.ActiveRefsOptionVar.value: if n in self.ActiveRefsOptionVar.value: activeState = True tmp = MelMenuItem( refMenu, l=n, cb=activeState, c=Callback(setToolsLib.doSetRefState, self, i, not activeState) ) self.activeRefsCBDict[i] = tmp MelMenuItemDiv(refMenu) MelMenuItem(refMenu, l="Clear", c=Callback(setToolsLib.doSetAllRefState, self, False)) # Types menu self.typeDict = {} self.activeTypesCBDict = {} if self.setTypes: typeMenu = MelMenuItem(parent, l="Load Types: ", subMenu=True) MelMenuItem(typeMenu, l="All", c=Callback(setToolsLib.doSetAllTypeState, self, True)) MelMenuItemDiv(typeMenu) for i, n in enumerate(self.setTypes): self.typeDict[i] = n activeState = False if self.ActiveTypesOptionVar.value: if n in self.ActiveTypesOptionVar.value: activeState = True tmp = MelMenuItem( typeMenu, l=n, cb=activeState, c=Callback(setToolsLib.doSetTypeState, self, i, not activeState) ) self.activeTypesCBDict[i] = tmp MelMenuItemDiv(typeMenu) MelMenuItem(typeMenu, l="Clear", c=Callback(setToolsLib.doSetAllTypeState, self, False)) # >>> Autohide Options HidingMenu = MelMenuItem(parent, l="Auto Hide", subMenu=True) # guiFactory.appendOptionVarList(self,'cgmVar_MaintainLocalSetGroup') MelMenuItem( HidingMenu, l="Anim Layer Sets", cb=self.HideAnimLayerSetsOptionVar.value, c=lambda *a: setToolsLib.uiToggleOptionCB(self, self.HideAnimLayerSetsOptionVar), ) MelMenuItem( HidingMenu, l="Maya Sets", cb=self.HideMayaSetsOptionVar.value, c=lambda *a: setToolsLib.uiToggleOptionCB(self, self.HideMayaSetsOptionVar), ) MelMenuItem( HidingMenu, l="Non Qss Sets", cb=self.HideNonQssOptionVar.value, c=lambda *a: setToolsLib.uiToggleOptionCB(self, self.HideNonQssOptionVar), ) MelMenuItem( HidingMenu, l="Set Groups", cb=self.HideSetGroupOptionVar.value, c=lambda *a: setToolsLib.uiToggleOptionCB(self, self.HideSetGroupOptionVar), ) MelMenuItemDiv(parent) self.objectSetsDict = {} self.activeSetsCBDict = {} maxSets = 10 for i, b in enumerate(self.objectSets[:maxSets]): # Store the info to a dict self.objectSetsDict[i] = b sInstance = SetFactory(b) # Get check box state activeState = False if b in self.ActiveObjectSetsOptionVar.value: activeState = True tmpActive = MelMenuItem( parent, l=b, annotation="Toggle active state and select", cb=activeState, c=Callback(setToolsLib.doSelectSetObjects, self, i), ) self.activeSetsCBDict[i] = tmpActive if len(self.objectSets) >= maxSets: MelMenuItem(parent, l="More sets...see menu") MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: self.reset()) def setupVariables(self): self.ActiveObjectSetsOptionVar = OptionVarFactory("cgmVar_activeObjectSets", defaultValue=[""]) self.ActiveRefsOptionVar = OptionVarFactory("cgmVar_activeRefs", defaultValue=[""]) self.ActiveTypesOptionVar = OptionVarFactory("cgmVar_activeTypes", defaultValue=[""]) self.KeyTypeOptionVar = OptionVarFactory("cgmVar_KeyType", defaultValue=0) self.HideSetGroupOptionVar = OptionVarFactory("cgmVar_HideSetGroups", defaultValue=1) self.HideNonQssOptionVar = OptionVarFactory("cgmVar_HideNonQss", defaultValue=1) self.HideAnimLayerSetsOptionVar = OptionVarFactory("cgmVar_HideAnimLayerSets", defaultValue=1) self.HideMayaSetsOptionVar = OptionVarFactory("cgmVar_HideMayaSets", defaultValue=1) guiFactory.appendOptionVarList(self, self.ActiveObjectSetsOptionVar.name) guiFactory.appendOptionVarList(self, self.ActiveRefsOptionVar.name) guiFactory.appendOptionVarList(self, self.ActiveTypesOptionVar.name) guiFactory.appendOptionVarList(self, self.KeyTypeOptionVar.name) guiFactory.appendOptionVarList(self, self.HideSetGroupOptionVar.name) guiFactory.appendOptionVarList(self, self.HideNonQssOptionVar.name) guiFactory.appendOptionVarList(self, self.HideAnimLayerSetsOptionVar.name) guiFactory.appendOptionVarList(self, self.HideMayaSetsOptionVar.name) def reset(self): guiFactory.purgeOptionVars(self.optionVars) setTools.run() def reload(self): setTools.run() def toggleVarAndReset(self, optionVar): try: optionVar.toggle() self.reload() except: print "MM change var and reset failed!"
def createUI(self,parent): """ Create the UI """ def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ killUI() command mmActionOptionVar.set(1) self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateObjectsBuffer',defaultValue = ['']) IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') self.SnapModeOptionVar.update()#Check if another tool has changed this setting sel = search.selectCheck() selPair = search.checkSelectionLength(2) IsClickedOptionVar.set(1) mc.menu(parent,e = True, deleteAllItems = True) MelMenuItem(parent, en = selPair, l = 'Point Snap', c = lambda *a:buttonAction(tdToolsLib.doPointSnap()), rp = 'NW') MelMenuItem(parent, en = selPair, l = 'Parent Snap', c = lambda *a:buttonAction(tdToolsLib.doParentSnap()), rp = 'N') MelMenuItem(parent, en = selPair, l = 'Orient Snap', c = lambda *a:buttonAction(tdToolsLib.doOrientSnap()), rp = 'NE') MelMenuItem(parent, en = selPair, l = 'Surface Snap', c = lambda *a:buttonAction(tdToolsLib.doSnapClosestPointToSurface(False)), rp = 'W') if self.LocinatorUpdateObjectsOptionVar.value: ShowMatch = False if self.LocinatorUpdateObjectsBufferOptionVar.value: ShowMatch = True MelMenuItem(parent, en = ShowMatch, l = 'Buffer Snap', c = lambda *a:buttonAction(locinatorLib.doUpdateLoc(self,True)), rp = 'S') else: ShowMatch = search.matchObjectCheck() MelMenuItem(parent, en = ShowMatch, l = 'Match Snap', c = lambda *a:buttonAction(locinatorLib.doUpdateSelectedObjects(self)), rp = 'S') MelMenuItem(parent, en = 0, l = 'Mirror', c = lambda *a:buttonAction(locinatorLib.doUpdateObj(self,True)), rp = 'SW') MelMenuItemDiv(parent) MelMenuItem(parent,l = 'Loc Me', c = lambda *a: buttonAction(locinatorLib.doLocMe(self))) MelMenuItem(parent, l = 'Tag Loc to Object',en = selPair, c = lambda *a: buttonAction(locinatorLib.doTagObjects(self))) # Update Mode UpdateMenu = MelMenuItem(parent, l='Update Mode', subMenu=True) UpdateMenuCollection = MelRadioMenuCollection() if self.LocinatorUpdateObjectsOptionVar.value == 0: slMode = True bufferMode = False else: slMode = False bufferMode = True UpdateMenuCollection.createButton(UpdateMenu,l='Selected', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(0), rb=slMode ) UpdateMenuCollection.createButton(UpdateMenu,l='Buffer', c=lambda *a:self.LocinatorUpdateObjectsOptionVar.set(1), rb=bufferMode ) #>>>Match Mode self.MatchModeOptions = ['parent','point','orient'] self.MatchModeCollection = MelRadioMenuCollection() self.MatchModeCollectionChoices = [] MatchModeMenu = MelMenuItem( parent, l='Match Mode', subMenu=True) self.matchMode = self.SnapModeOptionVar.value for c,item in enumerate(self.MatchModeOptions): if self.matchMode == c: rbValue = True else: rbValue = False self.MatchModeCollectionChoices.append(self.MatchModeCollection.createButton(MatchModeMenu,label=item, rb = rbValue, command = Callback(self.SnapModeOptionVar.set,c))) #>>> Define DefineMenu = MelMenuItem( parent, l='Buffer', subMenu=True) MelMenuItem( DefineMenu, l="Define", c= lambda *a: locinatorLib.defineObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( DefineMenu, l="Add Selected", c= lambda *a: locinatorLib.addSelectedToObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( DefineMenu, l="Remove Selected", c= lambda *a: locinatorLib.removeSelectedFromObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv( DefineMenu ) MelMenuItem( DefineMenu, l="Select Members", c= lambda *a: locinatorLib.selectObjBufferMembers(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( DefineMenu, l="Clear", c= lambda *a: locinatorLib.clearObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv(parent) MelMenuItem(parent, l = 'Locinator', c = lambda *a: buttonAction(cgmToolbox.loadLocinator())) MelMenuItem(parent, l = 'cgm.animTools', c = lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItem(parent, l = 'cgm.tdTools', c = lambda *a: buttonAction(cgmToolbox.loadTDTools())) MelMenuItem(parent, l = 'cgm.attrTools', c = lambda *a: buttonAction(cgmToolbox.loadAttrTools())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars(self.optionVars))
class snapMarkingMenu(BaseMelWindow): _DEFAULT_MENU_PARENT = 'viewPanes' def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] self.toolName = 'cgm.snapMM' IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') surfaceSnapAimModeVar = OptionVarFactory('cgmVar_SurfaceSnapAimMode', 'int') UpdateRotateOrderOnTagVar = OptionVarFactory('cgmVar_TaggingUpdateRO', 'int') self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateObjectsBuffer',defaultValue = ['']) self.LocinatorUpdateObjectsOptionVar = OptionVarFactory('cgmVar_SnapMMUpdateMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.LocinatorUpdateObjectsOptionVar.name) self.SnapModeOptionVar = OptionVarFactory('cgmVar_SnapMatchMode',defaultValue = 0) guiFactory.appendOptionVarList(self,self.SnapModeOptionVar.name) panel = mc.getPanel(up = True) sel = search.selectCheck() IsClickedOptionVar.set(0) mmActionOptionVar.set(0) if mc.popupMenu('cgmMM',ex = True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex = True): mc.popupMenu('cgmMM', ctl = 0, alt = 0, sh = 0, mm = 1, b =1, aob = 1, p = 'viewPanes', pmc = lambda *a: self.createUI('cgmMM')) def createUI(self,parent): """ Create the UI """ def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ killUI() command mmActionOptionVar.set(1) self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory('cgmVar_LocinatorUpdateObjectsBuffer',defaultValue = ['']) IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') self.SnapModeOptionVar.update()#Check if another tool has changed this setting sel = search.selectCheck() selPair = search.checkSelectionLength(2) IsClickedOptionVar.set(1) mc.menu(parent,e = True, deleteAllItems = True) MelMenuItem(parent, en = selPair, l = 'Point Snap', c = lambda *a:buttonAction(tdToolsLib.doPointSnap()), rp = 'NW') MelMenuItem(parent, en = selPair, l = 'Parent Snap', c = lambda *a:buttonAction(tdToolsLib.doParentSnap()), rp = 'N') MelMenuItem(parent, en = selPair, l = 'Orient Snap', c = lambda *a:buttonAction(tdToolsLib.doOrientSnap()), rp = 'NE') MelMenuItem(parent, en = selPair, l = 'Surface Snap', c = lambda *a:buttonAction(tdToolsLib.doSnapClosestPointToSurface(False)), rp = 'W') if self.LocinatorUpdateObjectsOptionVar.value: ShowMatch = False if self.LocinatorUpdateObjectsBufferOptionVar.value: ShowMatch = True MelMenuItem(parent, en = ShowMatch, l = 'Buffer Snap', c = lambda *a:buttonAction(locinatorLib.doUpdateLoc(self,True)), rp = 'S') else: ShowMatch = search.matchObjectCheck() MelMenuItem(parent, en = ShowMatch, l = 'Match Snap', c = lambda *a:buttonAction(locinatorLib.doUpdateSelectedObjects(self)), rp = 'S') MelMenuItem(parent, en = 0, l = 'Mirror', c = lambda *a:buttonAction(locinatorLib.doUpdateObj(self,True)), rp = 'SW') MelMenuItemDiv(parent) MelMenuItem(parent,l = 'Loc Me', c = lambda *a: buttonAction(locinatorLib.doLocMe(self))) MelMenuItem(parent, l = 'Tag Loc to Object',en = selPair, c = lambda *a: buttonAction(locinatorLib.doTagObjects(self))) # Update Mode UpdateMenu = MelMenuItem(parent, l='Update Mode', subMenu=True) UpdateMenuCollection = MelRadioMenuCollection() if self.LocinatorUpdateObjectsOptionVar.value == 0: slMode = True bufferMode = False else: slMode = False bufferMode = True UpdateMenuCollection.createButton(UpdateMenu,l='Selected', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(0), rb=slMode ) UpdateMenuCollection.createButton(UpdateMenu,l='Buffer', c=lambda *a:self.LocinatorUpdateObjectsOptionVar.set(1), rb=bufferMode ) #>>>Match Mode self.MatchModeOptions = ['parent','point','orient'] self.MatchModeCollection = MelRadioMenuCollection() self.MatchModeCollectionChoices = [] MatchModeMenu = MelMenuItem( parent, l='Match Mode', subMenu=True) self.matchMode = self.SnapModeOptionVar.value for c,item in enumerate(self.MatchModeOptions): if self.matchMode == c: rbValue = True else: rbValue = False self.MatchModeCollectionChoices.append(self.MatchModeCollection.createButton(MatchModeMenu,label=item, rb = rbValue, command = Callback(self.SnapModeOptionVar.set,c))) #>>> Define DefineMenu = MelMenuItem( parent, l='Buffer', subMenu=True) MelMenuItem( DefineMenu, l="Define", c= lambda *a: locinatorLib.defineObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( DefineMenu, l="Add Selected", c= lambda *a: locinatorLib.addSelectedToObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( DefineMenu, l="Remove Selected", c= lambda *a: locinatorLib.removeSelectedFromObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv( DefineMenu ) MelMenuItem( DefineMenu, l="Select Members", c= lambda *a: locinatorLib.selectObjBufferMembers(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem( DefineMenu, l="Clear", c= lambda *a: locinatorLib.clearObjBuffer(self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv(parent) MelMenuItem(parent, l = 'Locinator', c = lambda *a: buttonAction(cgmToolbox.loadLocinator())) MelMenuItem(parent, l = 'cgm.animTools', c = lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItem(parent, l = 'cgm.tdTools', c = lambda *a: buttonAction(cgmToolbox.loadTDTools())) MelMenuItem(parent, l = 'cgm.attrTools', c = lambda *a: buttonAction(cgmToolbox.loadAttrTools())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars(self.optionVars))
class locinatorClass(BaseMelWindow): from cgm.lib import guiFactory guiFactory.initializeTemplates() USE_Template = 'cgmUITemplate' WINDOW_NAME = 'cgmLocinatorWindow' WINDOW_TITLE = 'cgm.locinator - %s' % __version__ DEFAULT_SIZE = 180, 275 DEFAULT_MENU = None RETAIN = True MIN_BUTTON = True MAX_BUTTON = False FORCE_DEFAULT_SIZE = True #always resets the size of the window when its re-created def __init__(self): self.toolName = 'cgm.locinator' self.description = 'This tool makes locators based on selection types and provides ways to update those locators over time' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.version = __version__ self.optionVars = [] self.currentFrameOnly = True self.startFrame = '' self.endFrame = '' self.startFrameField = '' self.endFrameField = '' self.forceBoundingBoxState = False self.forceEveryFrame = False self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] self.showTimeSubMenu = False self.timeSubMenu = [] #Menu self.setupVariables() self.UI_OptionsMenu = MelMenu(l='Options', pmc=self.buildOptionsMenu) self.UI_BufferMenu = MelMenu(l='Buffer', pmc=self.buildBufferMenu) self.UI_HelpMenu = MelMenu(l='Help', pmc=self.buildHelpMenu) self.ShowHelpOption = mc.optionVar(q='cgmVar_LocinatorShowHelp') #Tabs tabs = MelTabLayout(self) TabBasic = MelColumnLayout(tabs) TabSpecial = MelColumnLayout(tabs) TabMatch = MelColumnLayout(tabs) n = 0 for tab in 'Basic', 'Special', 'Match': tabs.setLabel(n, tab) n += 1 self.buildBasicLayout(TabBasic) self.buildSpecialLayout(TabSpecial) self.buildMatchLayout(TabMatch) self.show() def setupVariables(self): self.LocinatorUpdateObjectsOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateMode', defaultValue=0) guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorUpdateMode') self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=['']) guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorUpdateObjectsBuffer') self.DebugModeOptionVar = OptionVarFactory('cgmVar_LocinatorDebug', defaultValue=0) guiFactory.appendOptionVarList(self, self.DebugModeOptionVar.name) self.SnapModeOptionVar = OptionVarFactory('cgmVar_SnapMatchMode', defaultValue=0) guiFactory.appendOptionVarList(self, self.SnapModeOptionVar.name) #Old method...clean up at some point if not mc.optionVar(ex='cgmVar_ForceBoundingBoxState'): mc.optionVar(iv=('cgmVar_ForceBoundingBoxState', 0)) if not mc.optionVar(ex='cgmVar_LocinatorShowHelp'): mc.optionVar(iv=('cgmVar_LocinatorShowHelp', 0)) if not mc.optionVar(ex='cgmVar_LocinatorCurrentFrameOnly'): mc.optionVar(iv=('cgmVar_LocinatorCurrentFrameOnly', 0)) if not mc.optionVar(ex='cgmVar_LocinatorBakingMode'): mc.optionVar(iv=('cgmVar_LocinatorBakingMode', 0)) guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorShowHelp') #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Menus #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildOptionsMenu(self, *a): self.UI_OptionsMenu.clear() #>>>Match Mode MatchModeMenu = MelMenuItem(self.UI_OptionsMenu, l='Match Mode', subMenu=True) self.MatchModeOptions = ['parent', 'point', 'orient'] self.MatchModeCollection = MelRadioMenuCollection() self.MatchModeCollectionChoices = [] self.SnapModeOptionVar.update() #Incase another tool changed self.matchMode = self.SnapModeOptionVar.value for c, item in enumerate(self.MatchModeOptions): if self.matchMode == c: rbValue = True else: rbValue = False self.MatchModeCollectionChoices.append( self.MatchModeCollection.createButton( MatchModeMenu, label=item, rb=rbValue, command=Callback(self.SnapModeOptionVar.set, c))) # Placement Menu PlacementMenu = MelMenuItem(self.UI_OptionsMenu, l='Placement', subMenu=True) PlacementMenuCollection = MelRadioMenuCollection() if mc.optionVar(q='cgmVar_ForceBoundingBoxState') == 0: cgmOption = False pivotOption = True else: cgmOption = True pivotOption = False PlacementMenuCollection.createButton( PlacementMenu, l='Bounding Box Center', c=lambda *a: mc.optionVar(iv=('cgmVar_ForceBoundingBoxState', 1)), rb=cgmOption) PlacementMenuCollection.createButton( PlacementMenu, l='Pivot', c=lambda *a: mc.optionVar(iv=('cgmVar_ForceBoundingBoxState', 0)), rb=pivotOption) # Tagging options AutoloadMenu = MelMenuItem(self.UI_OptionsMenu, l='Tagging', subMenu=True) if not mc.optionVar(ex='cgmVar_TaggingUpdateRO'): mc.optionVar(iv=('cgmVar_TaggingUpdateRO', 1)) guiFactory.appendOptionVarList(self, 'cgmVar_TaggingUpdateRO') RenameOnUpdateState = mc.optionVar(q='cgmVar_TaggingUpdateRO') MelMenuItem(AutoloadMenu, l="Update Rotation Order", cb=mc.optionVar(q='cgmVar_TaggingUpdateRO'), c=lambda *a: guiFactory.doToggleIntOptionVariable( 'cgmVar_TaggingUpdateRO')) # Update Mode UpdateMenu = MelMenuItem(self.UI_OptionsMenu, l='Update Mode', subMenu=True) UpdateMenuCollection = MelRadioMenuCollection() if self.LocinatorUpdateObjectsOptionVar.value == 0: slMode = True bufferMode = False else: slMode = False bufferMode = True UpdateMenuCollection.createButton( UpdateMenu, l='Selected', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(0), rb=slMode) UpdateMenuCollection.createButton( UpdateMenu, l='Buffer', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(1), rb=bufferMode) MelMenuItemDiv(self.UI_OptionsMenu) MelMenuItem(self.UI_OptionsMenu, l="Reset", c=lambda *a: self.reset()) def reset(self): Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars, run)) def reload(self): run() def buildBufferMenu(self, *a): self.UI_BufferMenu.clear() MelMenuItem(self.UI_BufferMenu, l="Define", c=lambda *a: locinatorLib.defineObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(self.UI_BufferMenu, l="Add Selected", c=lambda *a: locinatorLib.addSelectedToObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(self.UI_BufferMenu, l="Remove Selected", c=lambda *a: locinatorLib.removeSelectedFromObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv(self.UI_BufferMenu) MelMenuItem(self.UI_BufferMenu, l="Select Members", c=lambda *a: locinatorLib.selectObjBufferMembers( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(self.UI_BufferMenu, l="Clear", c=lambda *a: locinatorLib.clearObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) def buildHelpMenu(self, *a): self.UI_HelpMenu.clear() MelMenuItem(self.UI_HelpMenu, l="Show Help", cb=self.ShowHelpOption, c=lambda *a: self.do_showHelpToggle()) MelMenuItem(self.UI_HelpMenu, l="Print Tools Help", c=lambda *a: self.printHelp()) MelMenuItemDiv(self.UI_HelpMenu) MelMenuItem(self.UI_HelpMenu, l="About", c=lambda *a: self.showAbout()) MelMenuItem(self.UI_HelpMenu, l="Debug", cb=self.DebugModeOptionVar.value, c=lambda *a: self.DebugModeOptionVar.toggle()) def do_showHelpToggle(self): guiFactory.toggleMenuShowState(self.ShowHelpOption, self.helpBlurbs) mc.optionVar(iv=('cgmVar_LocinatorShowHelp', not self.ShowHelpOption)) self.ShowHelpOption = mc.optionVar(q='cgmVar_LocinatorShowHelp') def do_showTimeSubMenuToggleOn(self): guiFactory.toggleMenuShowState(1, self.timeSubMenu) mc.optionVar(iv=('cgmVar_LocinatorCurrentFrameOnly', 1)) def do_showTimeSubMenuToggleOff(self): guiFactory.toggleMenuShowState(0, self.timeSubMenu) mc.optionVar(iv=('cgmVar_LocinatorCurrentFrameOnly', 0)) def showAbout(self): window = mc.window(title="About", iconName='About', ut='cgmUITemplate', resizeToFitChildren=True) mc.columnLayout(adjustableColumn=True) guiFactory.header(self.toolName, overrideUpper=True) mc.text(label='>>>A Part of the cgmTools Collection<<<', ut='cgmUIInstructionsTemplate') guiFactory.headerBreak() guiFactory.lineBreak() descriptionBlock = guiFactory.textBlock(self.description) guiFactory.lineBreak() mc.text(label=('%s%s' % ('Written by: ', self.author))) mc.text(label=('%s%s%s' % ('Copyright ', self.owner, ', 2011'))) guiFactory.lineBreak() mc.text(label='Version: %s' % self.version) mc.text(label='') guiFactory.doButton( 'Visit Tool Webpage', 'import webbrowser;webbrowser.open(" http://www.cgmonks.com/tools/maya-tools/locinator/")' ) guiFactory.doButton( 'Close', 'import maya.cmds as mc;mc.deleteUI(\"' + window + '\", window=True)') mc.setParent('..') mc.showWindow(window) def printHelp(self): import locinatorLib help(locinatorLib) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Layouts #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildPlaceHolder(self, parent): self.containerName = MelColumnLayout(parent, ut='cgmUISubTemplate') return self.containerName def buildTimeSubMenu(self, parent): self.containerName = MelColumnLayout(parent, ut='cgmUISubTemplate') # Time Submenu mc.setParent(self.containerName) self.helpBlurbs.extend( guiFactory.instructions(" Set your time range", vis=self.ShowHelpOption)) timelineInfo = search.returnTimelineInfo() # TimeInput Row TimeInputRow = MelHSingleStretchLayout(self.containerName, ut='cgmUISubTemplate') self.timeSubMenu.append(TimeInputRow) MelSpacer(TimeInputRow) MelLabel(TimeInputRow, l='start') self.startFrameField = MelIntField(TimeInputRow, 'cgmLocWinStartFrameField', width=40, value=timelineInfo['rangeStart']) TimeInputRow.setStretchWidget(MelSpacer(TimeInputRow)) MelLabel(TimeInputRow, l='end') self.endFrameField = MelIntField(TimeInputRow, 'cgmLocWinEndFrameField', width=40, value=timelineInfo['rangeEnd']) MelSpacer(TimeInputRow) TimeInputRow.layout() MelSeparator(self.containerName, ut='cgmUISubTemplate', style='none', height=5) # Button Row TimeButtonRow = MelHSingleStretchLayout(self.containerName, padding=1, ut='cgmUISubTemplate') MelSpacer(TimeButtonRow, w=2) currentRangeButton = guiFactory.doButton2( TimeButtonRow, 'Current Range', lambda *a: locinatorLib.setGUITimeRangeToCurrent(self), 'Sets the time range to the current slider range') TimeButtonRow.setStretchWidget(MelSpacer(TimeButtonRow, w=2)) sceneRangeButton = guiFactory.doButton2( TimeButtonRow, 'Scene Range', lambda *a: locinatorLib.setGUITimeRangeToScene(self), 'Sets the time range to the current slider range') MelSpacer(TimeButtonRow, w=2) TimeButtonRow.layout() #>>> Base Settings Flags self.KeyingModeCollection = MelRadioCollection() self.KeyingModeCollectionChoices = [] if not mc.optionVar(ex='cgmVar_LocinatorKeyingMode'): mc.optionVar(iv=('cgmVar_LocinatorKeyingMode', 0)) guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorKeyingMode') KeysSettingsFlagsRow = MelHSingleStretchLayout(self.containerName, ut='cgmUISubTemplate', padding=2) MelSpacer(KeysSettingsFlagsRow, w=2) KeysSettingsFlagsRow.setStretchWidget( MelLabel(KeysSettingsFlagsRow, l='Anim Option: ', align='right')) self.keyingOptions = ['Keys', 'All'] for item in self.keyingOptions: cnt = self.keyingOptions.index(item) self.KeyingModeCollectionChoices.append( self.KeyingModeCollection.createButton( KeysSettingsFlagsRow, label=self.keyingOptions[cnt], onCommand=Callback(guiFactory.toggleOptionVarState, self.keyingOptions[cnt], self.keyingOptions, 'cgmVar_LocinatorKeyingMode', True))) MelSpacer(KeysSettingsFlagsRow, w=5) mc.radioCollection(self.KeyingModeCollection, edit=True, sl=(self.KeyingModeCollectionChoices[(mc.optionVar( q='cgmVar_LocinatorKeyingMode'))])) KeysSettingsFlagsRow.layout() #>>> Base Settings Flags self.KeyingTargetCollection = MelRadioCollection() self.KeyingTargetCollectionChoices = [] if not mc.optionVar(ex='cgmVar_LocinatorKeyingTarget'): mc.optionVar(iv=('cgmVar_LocinatorKeyingTarget', 0)) guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorKeyingTarget') BakeSettingsFlagsRow = MelHSingleStretchLayout(self.containerName, ut='cgmUISubTemplate', padding=2) MelSpacer(BakeSettingsFlagsRow, w=2) BakeSettingsFlagsRow.setStretchWidget( MelLabel(BakeSettingsFlagsRow, l='From: ', align='right')) MelSpacer(BakeSettingsFlagsRow) self.keyTargetOptions = ['source', 'self'] for item in self.keyTargetOptions: cnt = self.keyTargetOptions.index(item) self.KeyingTargetCollectionChoices.append( self.KeyingTargetCollection.createButton( BakeSettingsFlagsRow, label=self.keyTargetOptions[cnt], onCommand=Callback(guiFactory.toggleOptionVarState, self.keyTargetOptions[cnt], self.keyTargetOptions, 'cgmVar_LocinatorKeyingTarget', True))) MelSpacer(BakeSettingsFlagsRow, w=5) mc.radioCollection( self.KeyingTargetCollection, edit=True, sl=(self.KeyingTargetCollectionChoices[(mc.optionVar( q='cgmVar_LocinatorKeyingTarget'))])) BakeSettingsFlagsRow.layout() return self.containerName def buildBasicLayout(self, parent): mc.setParent(parent) guiFactory.header('Update') #>>>Time Section UpdateOptionRadioCollection = MelRadioCollection() EveryFrameOption = mc.optionVar(q='cgmVar_LocinatorBakeState') mc.setParent(parent) guiFactory.lineSubBreak() #>>> Time Menu Container self.BakeModeOptionList = ['Current Frame', 'Bake'] cgmVar_Name = 'cgmVar_LocinatorBakeState' guiFactory.appendOptionVarList(self, 'cgmVar_LocinatorBakeState') if not mc.optionVar(ex=cgmVar_Name): mc.optionVar(iv=(cgmVar_Name, 0)) #build our sub section options self.ContainerList = [] #Mode Change row ModeSetRow = MelHSingleStretchLayout(parent, ut='cgmUISubTemplate') self.BakeModeRadioCollection = MelRadioCollection() self.BakeModeChoiceList = [] MelSpacer(ModeSetRow, w=2) self.BakeModeChoiceList.append( self.BakeModeRadioCollection.createButton( ModeSetRow, label=self.BakeModeOptionList[0], onCommand=Callback(guiFactory.toggleModeState, self.BakeModeOptionList[0], self.BakeModeOptionList, cgmVar_Name, self.ContainerList, True))) ModeSetRow.setStretchWidget(MelSpacer(ModeSetRow)) self.BakeModeChoiceList.append( self.BakeModeRadioCollection.createButton( ModeSetRow, label=self.BakeModeOptionList[1], onCommand=Callback(guiFactory.toggleModeState, self.BakeModeOptionList[1], self.BakeModeOptionList, cgmVar_Name, self.ContainerList, True))) ModeSetRow.layout() #>>> self.ContainerList.append(self.buildPlaceHolder(parent)) self.ContainerList.append(self.buildTimeSubMenu(parent)) mc.radioCollection( self.BakeModeRadioCollection, edit=True, sl=self.BakeModeChoiceList[mc.optionVar(q=cgmVar_Name)]) #>>> mc.setParent(parent) guiFactory.doButton2( parent, 'Do it!', lambda *a: locinatorLib.doUpdateLoc(self), 'Update a locator at a particular frame or through a timeline') guiFactory.lineSubBreak() #>>> Loc Me Section guiFactory.lineBreak() guiFactory.lineSubBreak() guiFactory.doButton2( parent, 'Just Loc Selected', lambda *a: locinatorLib.doLocMe(self), 'Create an updateable locator based off the selection and options') def buildSpecialLayout(self, parent): SpecialColumn = MelColumnLayout(parent) #>>> Center Section guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn, 'Locate Center', lambda *a: locinatorLib.doLocCenter(self), 'Find the center point from a selection set') #>>> Closest Point Section guiFactory.lineSubBreak() guiFactory.doButton2( SpecialColumn, 'Locate Closest Point', lambda *a: locinatorLib.doLocClosest(self), 'Select the proximity object(s), then the object to find point on. Accepted target object types are - nurbsCurves and surfaces and poly objects' ) #>>> Curves Section guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn, 'Loc CVs of curve', lambda *a: locinatorLib.doLocCVsOfObject(), "Locs the cv's at the cv coordinates") guiFactory.lineSubBreak() guiFactory.doButton2(SpecialColumn, 'Loc CVs on the curve', lambda *a: locinatorLib.doLocCVsOnObject(), "Locs cv's at closest point on the curve") guiFactory.lineBreak() #>>> Update Section guiFactory.lineSubBreak() guiFactory.doButton2( SpecialColumn, 'Update Selected', lambda *a: locinatorLib.doUpdateLoc(self), "Only works with locators created with this tool") def buildMatchLayout(self, parent): MatchColumn = MelColumnLayout(parent) #>>> Tag Section guiFactory.lineSubBreak() guiFactory.doButton2( MatchColumn, 'Tag it', lambda *a: locinatorLib.doTagObjects(self), "Tag the selected objects to the first locator in the selection set. After this relationship is set up, you can match objects to that locator." ) #>>> Purge Section guiFactory.lineSubBreak() self.helpBlurbs.extend( guiFactory.instructions( " Purge all traces of cgmThinga tools from the object", vis=self.ShowHelpOption)) guiFactory.doButton2(MatchColumn, 'Purge it', lambda *a: locinatorLib.doPurgeCGMAttrs(self), "Clean it") guiFactory.lineBreak() #>>> Update Section guiFactory.lineSubBreak() guiFactory.doButton2( MatchColumn, 'Update Selected', lambda *a: locinatorLib.doUpdateLoc(self), "Only works with locators created with this tool")
def setupVariables(self): self.SortModifyOptionVar = OptionVarFactory( 'cgmVar_attrToolsSortModfiy', defaultValue=0) guiFactory.appendOptionVarList(self, self.SortModifyOptionVar.name) self.HideTransformsOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideTransform', defaultValue=0) guiFactory.appendOptionVarList(self, self.HideTransformsOptionVar.name) self.HideUserDefinedOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideUserDefined', defaultValue=0) guiFactory.appendOptionVarList(self, self.HideUserDefinedOptionVar.name) self.HideParentAttrsOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideParentAttrs', defaultValue=0) guiFactory.appendOptionVarList(self, self.HideParentAttrsOptionVar.name) self.HideCGMAttrsOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideCGMAttrs', defaultValue=1) guiFactory.appendOptionVarList(self, self.HideCGMAttrsOptionVar.name) self.HideNonstandardOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideNonStandard', defaultValue=1) guiFactory.appendOptionVarList(self, self.HideNonstandardOptionVar.name) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_attrToolsShowHelp', defaultValue=0) guiFactory.appendOptionVarList(self, self.ShowHelpOptionVar.name) self.SourceObjectOptionVar = OptionVarFactory( 'cgmVar_AttributeSourceObject', defaultValue='') guiFactory.appendOptionVarList(self, self.SourceObjectOptionVar.name) self.CopyAttrModeOptionVar = OptionVarFactory( 'cgmVar_CopyAttributeMode', defaultValue=0) guiFactory.appendOptionVarList(self, self.CopyAttrModeOptionVar.name) self.CopyAttrOptionsOptionVar = OptionVarFactory( 'cgmVar_CopyAttributeOptions', defaultValue=1) guiFactory.appendOptionVarList(self, self.CopyAttrOptionsOptionVar.name) self.TransferValueOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferValueState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferValueOptionVar.name) self.TransferIncomingOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferInConnectionState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferIncomingOptionVar.name) self.TransferOutgoingOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferOutConnectionState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferOutgoingOptionVar.name) self.TransferKeepSourceOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferKeepSourceState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferKeepSourceOptionVar.name) self.TransferConvertStateOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferConvertState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferConvertStateOptionVar.name) self.TransferDriveSourceStateOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferConnectToSourceState', defaultValue=0) guiFactory.appendOptionVarList( self, self.TransferDriveSourceStateOptionVar.name) self.CreateAttrTypeOptionVar = OptionVarFactory( 'cgmVar_AttrCreateType', defaultValue='') guiFactory.appendOptionVarList(self, self.CreateAttrTypeOptionVar.name)
class snapMarkingMenu(BaseMelWindow): _DEFAULT_MENU_PARENT = 'viewPanes' def __init__(self): """ Initializes the pop up menu class call """ self.optionVars = [] self.toolName = 'cgm.snapMM' IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') surfaceSnapAimModeVar = OptionVarFactory('cgmVar_SurfaceSnapAimMode', 'int') UpdateRotateOrderOnTagVar = OptionVarFactory('cgmVar_TaggingUpdateRO', 'int') self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=['']) self.LocinatorUpdateObjectsOptionVar = OptionVarFactory( 'cgmVar_SnapMMUpdateMode', defaultValue=0) guiFactory.appendOptionVarList( self, self.LocinatorUpdateObjectsOptionVar.name) self.SnapModeOptionVar = OptionVarFactory('cgmVar_SnapMatchMode', defaultValue=0) guiFactory.appendOptionVarList(self, self.SnapModeOptionVar.name) panel = mc.getPanel(up=True) sel = search.selectCheck() IsClickedOptionVar.set(0) mmActionOptionVar.set(0) if mc.popupMenu('cgmMM', ex=True): mc.deleteUI('cgmMM') if panel: if mc.control(panel, ex=True): mc.popupMenu('cgmMM', ctl=0, alt=0, sh=0, mm=1, b=1, aob=1, p='viewPanes', pmc=lambda *a: self.createUI('cgmMM')) def createUI(self, parent): """ Create the UI """ def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ killUI() command mmActionOptionVar.set(1) self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=['']) IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') self.SnapModeOptionVar.update( ) #Check if another tool has changed this setting sel = search.selectCheck() selPair = search.checkSelectionLength(2) IsClickedOptionVar.set(1) mc.menu(parent, e=True, deleteAllItems=True) MelMenuItem(parent, en=selPair, l='Point Snap', c=lambda *a: buttonAction(tdToolsLib.doPointSnap()), rp='NW') MelMenuItem(parent, en=selPair, l='Parent Snap', c=lambda *a: buttonAction(tdToolsLib.doParentSnap()), rp='N') MelMenuItem(parent, en=selPair, l='Orient Snap', c=lambda *a: buttonAction(tdToolsLib.doOrientSnap()), rp='NE') MelMenuItem(parent, en=selPair, l='Surface Snap', c=lambda *a: buttonAction( tdToolsLib.doSnapClosestPointToSurface(False)), rp='W') if self.LocinatorUpdateObjectsOptionVar.value: ShowMatch = False if self.LocinatorUpdateObjectsBufferOptionVar.value: ShowMatch = True MelMenuItem(parent, en=ShowMatch, l='Buffer Snap', c=lambda *a: buttonAction( locinatorLib.doUpdateLoc(self, True)), rp='S') else: ShowMatch = search.matchObjectCheck() MelMenuItem(parent, en=ShowMatch, l='Match Snap', c=lambda *a: buttonAction( locinatorLib.doUpdateSelectedObjects(self)), rp='S') MelMenuItem( parent, en=0, l='Mirror', c=lambda *a: buttonAction(locinatorLib.doUpdateObj(self, True)), rp='SW') MelMenuItemDiv(parent) MelMenuItem(parent, l='Loc Me', c=lambda *a: buttonAction(locinatorLib.doLocMe(self))) MelMenuItem(parent, l='Tag Loc to Object', en=selPair, c=lambda *a: buttonAction(locinatorLib.doTagObjects(self))) # Update Mode UpdateMenu = MelMenuItem(parent, l='Update Mode', subMenu=True) UpdateMenuCollection = MelRadioMenuCollection() if self.LocinatorUpdateObjectsOptionVar.value == 0: slMode = True bufferMode = False else: slMode = False bufferMode = True UpdateMenuCollection.createButton( UpdateMenu, l='Selected', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(0), rb=slMode) UpdateMenuCollection.createButton( UpdateMenu, l='Buffer', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(1), rb=bufferMode) #>>>Match Mode self.MatchModeOptions = ['parent', 'point', 'orient'] self.MatchModeCollection = MelRadioMenuCollection() self.MatchModeCollectionChoices = [] MatchModeMenu = MelMenuItem(parent, l='Match Mode', subMenu=True) self.matchMode = self.SnapModeOptionVar.value for c, item in enumerate(self.MatchModeOptions): if self.matchMode == c: rbValue = True else: rbValue = False self.MatchModeCollectionChoices.append( self.MatchModeCollection.createButton( MatchModeMenu, label=item, rb=rbValue, command=Callback(self.SnapModeOptionVar.set, c))) #>>> Define DefineMenu = MelMenuItem(parent, l='Buffer', subMenu=True) MelMenuItem(DefineMenu, l="Define", c=lambda *a: locinatorLib.defineObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(DefineMenu, l="Add Selected", c=lambda *a: locinatorLib.addSelectedToObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(DefineMenu, l="Remove Selected", c=lambda *a: locinatorLib.removeSelectedFromObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv(DefineMenu) MelMenuItem(DefineMenu, l="Select Members", c=lambda *a: locinatorLib.selectObjBufferMembers( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(DefineMenu, l="Clear", c=lambda *a: locinatorLib.clearObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv(parent) MelMenuItem(parent, l='Locinator', c=lambda *a: buttonAction(cgmToolbox.loadLocinator())) MelMenuItem(parent, l='cgm.animTools', c=lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItem(parent, l='cgm.tdTools', c=lambda *a: buttonAction(cgmToolbox.loadTDTools())) MelMenuItem(parent, l='cgm.attrTools', c=lambda *a: buttonAction(cgmToolbox.loadAttrTools())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars( self.optionVars))
class attrToolsClass(BaseMelWindow): from cgm.lib import guiFactory guiFactory.initializeTemplates() USE_Template = 'cgmUITemplate' WINDOW_NAME = 'attrTools' WINDOW_TITLE = 'cgm.attrTools' DEFAULT_SIZE = 375, 350 DEFAULT_MENU = None RETAIN = True MIN_BUTTON = True MAX_BUTTON = False FORCE_DEFAULT_SIZE = True #always resets the size of the window when its re-created def __init__(self): # Basic variables self.window = '' self.activeTab = '' self.toolName = 'attrTools' self.module = 'tdTools' self.winName = 'attrToolsWin' self.optionVars = [] self.showHelp = False self.helpBlurbs = [] self.oldGenBlurbs = [] self.showTimeSubMenu = False self.timeSubMenu = [] self.setupVariables() self.loadAttrs = [] # About Window self.description = 'Tools for working with attributes' self.author = 'Josh Burton' self.owner = 'CG Monks' self.website = 'www.cgmonks.com' self.version = __version__ # About Window #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Build #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #Menu self.UI_OptionsMenu = MelMenu(l='Options', pmc=self.buildOptionsMenu) self.UI_HelpMenu = MelMenu(l='Help', pmc=self.buildHelpMenu) WindowForm = MelColumnLayout(self) self.buildAttributeTool(WindowForm) if mc.ls(sl=True): attrToolsLib.uiLoadSourceObject(self) self.show() def setupVariables(self): self.SortModifyOptionVar = OptionVarFactory( 'cgmVar_attrToolsSortModfiy', defaultValue=0) guiFactory.appendOptionVarList(self, self.SortModifyOptionVar.name) self.HideTransformsOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideTransform', defaultValue=0) guiFactory.appendOptionVarList(self, self.HideTransformsOptionVar.name) self.HideUserDefinedOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideUserDefined', defaultValue=0) guiFactory.appendOptionVarList(self, self.HideUserDefinedOptionVar.name) self.HideParentAttrsOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideParentAttrs', defaultValue=0) guiFactory.appendOptionVarList(self, self.HideParentAttrsOptionVar.name) self.HideCGMAttrsOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideCGMAttrs', defaultValue=1) guiFactory.appendOptionVarList(self, self.HideCGMAttrsOptionVar.name) self.HideNonstandardOptionVar = OptionVarFactory( 'cgmVar_attrToolsHideNonStandard', defaultValue=1) guiFactory.appendOptionVarList(self, self.HideNonstandardOptionVar.name) self.ShowHelpOptionVar = OptionVarFactory('cgmVar_attrToolsShowHelp', defaultValue=0) guiFactory.appendOptionVarList(self, self.ShowHelpOptionVar.name) self.SourceObjectOptionVar = OptionVarFactory( 'cgmVar_AttributeSourceObject', defaultValue='') guiFactory.appendOptionVarList(self, self.SourceObjectOptionVar.name) self.CopyAttrModeOptionVar = OptionVarFactory( 'cgmVar_CopyAttributeMode', defaultValue=0) guiFactory.appendOptionVarList(self, self.CopyAttrModeOptionVar.name) self.CopyAttrOptionsOptionVar = OptionVarFactory( 'cgmVar_CopyAttributeOptions', defaultValue=1) guiFactory.appendOptionVarList(self, self.CopyAttrOptionsOptionVar.name) self.TransferValueOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferValueState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferValueOptionVar.name) self.TransferIncomingOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferInConnectionState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferIncomingOptionVar.name) self.TransferOutgoingOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferOutConnectionState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferOutgoingOptionVar.name) self.TransferKeepSourceOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferKeepSourceState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferKeepSourceOptionVar.name) self.TransferConvertStateOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferConvertState', defaultValue=1) guiFactory.appendOptionVarList(self, self.TransferConvertStateOptionVar.name) self.TransferDriveSourceStateOptionVar = OptionVarFactory( 'cgmVar_AttributeTransferConnectToSourceState', defaultValue=0) guiFactory.appendOptionVarList( self, self.TransferDriveSourceStateOptionVar.name) self.CreateAttrTypeOptionVar = OptionVarFactory( 'cgmVar_AttrCreateType', defaultValue='') guiFactory.appendOptionVarList(self, self.CreateAttrTypeOptionVar.name) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Menus #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildHelpMenu(self, *a): self.UI_HelpMenu.clear() MelMenuItem(self.UI_HelpMenu, l="Print Tools Help", c=lambda *a: self.printHelp()) MelMenuItemDiv(self.UI_HelpMenu) MelMenuItem(self.UI_HelpMenu, l="About", c=lambda *a: self.showAbout()) def buildOptionsMenu(self, *a): self.UI_OptionsMenu.clear() #>>> Grouping Options HidingMenu = MelMenuItem(self.UI_OptionsMenu, l='Autohide:', subMenu=True) MelMenuItem( self.UI_OptionsMenu, l="Sort Modify", cb=self.SortModifyOptionVar.value, annotation= "Sort the list of attributes in/nthe modify section alphabetically", c=lambda *a: attrToolsLib.uiToggleOptionCB( self, self.SortModifyOptionVar)) #guiFactory.appendOptionVarList(self,'cgmVar_MaintainLocalSetGroup') MelMenuItem(HidingMenu, l="Transforms", cb=self.HideTransformsOptionVar.value, c=lambda *a: attrToolsLib.uiToggleOptionCB( self, self.HideTransformsOptionVar)) MelMenuItem(HidingMenu, l="User Defined", cb=self.HideUserDefinedOptionVar.value, c=lambda *a: attrToolsLib.uiToggleOptionCB( self, self.HideUserDefinedOptionVar)) MelMenuItem(HidingMenu, l="Parent Attributes", cb=self.HideParentAttrsOptionVar.value, c=lambda *a: attrToolsLib.uiToggleOptionCB( self, self.HideParentAttrsOptionVar)) MelMenuItem(HidingMenu, l="CGM Attributes", cb=self.HideCGMAttrsOptionVar.value, c=lambda *a: attrToolsLib.uiToggleOptionCB( self, self.HideCGMAttrsOptionVar)) MelMenuItem(HidingMenu, l="Nonstandard", cb=self.HideNonstandardOptionVar.value, c=lambda *a: attrToolsLib.uiToggleOptionCB( self, self.HideNonstandardOptionVar)) #>>> Reset Options MelMenuItemDiv(self.UI_OptionsMenu) MelMenuItem(self.UI_OptionsMenu, l="Reload", c=lambda *a: self.reload()) MelMenuItem(self.UI_OptionsMenu, l="Reset", c=lambda *a: self.reset()) def showAbout(self): window = mc.window(title="About", iconName='About', ut='cgmUITemplate', resizeToFitChildren=True) mc.columnLayout(adjustableColumn=True) guiFactory.header(self.toolName, overrideUpper=True) mc.text(label='>>>A Part of the cgmTools Collection<<<', ut='cgmUIInstructionsTemplate') guiFactory.headerBreak() guiFactory.lineBreak() descriptionBlock = guiFactory.textBlock(self.description) guiFactory.lineBreak() mc.text(label=('%s%s' % ('Written by: ', self.author))) mc.text(label=('%s%s%s' % ('Copyright ', self.owner, ', 2011'))) guiFactory.lineBreak() mc.text(label='Version: %s' % self.version) mc.text(label='') guiFactory.doButton( 'Visit Website', 'import webbrowser;webbrowser.open("http://www.cgmonks.com/tools/maya-tools/attrtools/")' ) guiFactory.doButton( 'Close', 'import maya.cmds as mc;mc.deleteUI(\"' + window + '\", window=True)') mc.setParent('..') mc.showWindow(window) def printHelp(self): from cgm.tools.lib import attrToolsLib help(attrToolsLib) def reset(self): Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars, run)) def reload(self): run() #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Tools #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> def buildAttributeTool(self, parent, vis=True): OptionList = ['Tools', 'Manager', 'Utilities'] RadioCollectionName = 'AttributeMode' RadioOptionList = 'AttributeModeSelectionChoicesList' ShowHelpOption = mc.optionVar(q='cgmVar_TDToolsShowHelp') self.AttributeModeOptionVar = OptionVarFactory( 'cgmVar_AttributeMode', defaultValue=OptionList[0]) MelSeparator(parent, ut='cgmUIHeaderTemplate', h=5) #Mode Change row self.ModeSetRow = MelHLayout(parent, ut='cgmUISubTemplate', padding=0) MelLabel(self.ModeSetRow, label='Choose Mode: ', align='right') self.RadioCollectionName = MelRadioCollection() self.RadioOptionList = [] #build our sub section options self.ContainerList = [] self.ContainerList.append( self.buildAttributeEditingTool(parent, vis=False)) self.ContainerList.append( self.buildAttributeManagerTool(parent, vis=False)) self.ContainerList.append( self.buildAttributeUtilitiesTool(parent, vis=False)) for item in OptionList: self.RadioOptionList.append( self.RadioCollectionName.createButton( self.ModeSetRow, label=item, onCommand=Callback(guiFactory.toggleModeState, item, OptionList, self.AttributeModeOptionVar.name, self.ContainerList))) self.ModeSetRow.layout() mc.radioCollection(self.RadioCollectionName, edit=True, sl=self.RadioOptionList[OptionList.index( self.AttributeModeOptionVar.value)]) def buildAttributeEditingTool(self, parent, vis=True): #Container containerName = 'Attributes Constainer' self.containerName = MelColumn(parent, vis=vis) ###Create mc.setParent(self.containerName) guiFactory.header('Create') guiFactory.lineSubBreak() #>>>Create Row attrCreateRow = MelHSingleStretchLayout(self.containerName, ut='cgmUISubTemplate', padding=5) MelSpacer(attrCreateRow) MelLabel(attrCreateRow, l='Names:', align='right') self.AttrNamesTextField = MelTextField( attrCreateRow, backgroundColor=[1, 1, 1], h=20, ec=lambda *a: attrToolsLib.doAddAttributesToSelected(self), annotation= "Names for the attributes. Create multiple with a ';'. \n Message nodes try to connect to the last object in a selection \n For example: 'Test1;Test2;Test3'" ) guiFactory.doButton2( attrCreateRow, 'Add', lambda *a: attrToolsLib.doAddAttributesToSelected(self), "Add the attribute names from the text field") MelSpacer(attrCreateRow, w=2) attrCreateRow.setStretchWidget(self.AttrNamesTextField) attrCreateRow.layout() #>>> modify Section self.buildAttrTypeRow(self.containerName) MelSeparator(self.containerName, ut='cgmUIHeaderTemplate', h=2) MelSeparator(self.containerName, ut='cgmUITemplate', h=10) ###Modify mc.setParent(self.containerName) guiFactory.header('Modify') AttrReportRow = MelHLayout(self.containerName, ut='cgmUIInstructionsTemplate', h=20) self.AttrReportField = MelLabel( AttrReportRow, bgc=dictionary.returnStateColor('help'), align='center', label='...', h=20) AttrReportRow.layout() MelSeparator(self.containerName, ut='cgmUISubTemplate', h=5) #>>> Load To Field LoadAttributeObjectRow = MelHSingleStretchLayout(self.containerName, ut='cgmUISubTemplate', padding=5) MelSpacer(LoadAttributeObjectRow, w=5) guiFactory.doButton2(LoadAttributeObjectRow, '>>', lambda *a: attrToolsLib.uiLoadSourceObject(self), 'Load to field') self.SourceObjectField = MelTextField(LoadAttributeObjectRow, w=125, h=20, ut='cgmUIReservedTemplate', editable=False) LoadAttributeObjectRow.setStretchWidget(self.SourceObjectField) MelLabel(LoadAttributeObjectRow, l=' . ') self.ObjectAttributesOptionMenu = MelOptionMenu(LoadAttributeObjectRow, w=100) self.DeleteAttrButton = guiFactory.doButton2( LoadAttributeObjectRow, 'X', lambda *a: attrToolsLib.uiDeleteAttr( self, self.ObjectAttributesOptionMenu), 'Delete attribute', w=25, en=False) MelSpacer(LoadAttributeObjectRow, w=5) LoadAttributeObjectRow.layout() #>>> Standard Flags BasicAttrFlagsRow = MelHLayout(self.containerName, ut='cgmUISubTemplate', padding=2) MelSpacer(BasicAttrFlagsRow, w=5) self.KeyableAttrCB = MelCheckBox(BasicAttrFlagsRow, label='Keyable', en=False) MelSpacer(BasicAttrFlagsRow, w=5) self.HiddenAttrCB = MelCheckBox(BasicAttrFlagsRow, label='Hidden', en=False) MelSpacer(BasicAttrFlagsRow, w=5) self.LockedAttrCB = MelCheckBox(BasicAttrFlagsRow, label='Locked', en=False) MelSpacer(BasicAttrFlagsRow, w=5) BasicAttrFlagsRow.layout() #>>> Name Row self.EditNameSettingsRow = MelHSingleStretchLayout( self.containerName, ut='cgmUISubTemplate') self.EditNameSettingsRow.setStretchWidget( MelSpacer(self.EditNameSettingsRow, w=5)) NameLabel = MelLabel(self.EditNameSettingsRow, label='Name: ') self.NameField = MelTextField( self.EditNameSettingsRow, en=False, bgc=dictionary.returnStateColor('normal'), ec=lambda *a: attrToolsLib.uiRenameAttr(self), h=20, w=75) NiceNameLabel = MelLabel(self.EditNameSettingsRow, label='Nice: ') self.NiceNameField = MelTextField( self.EditNameSettingsRow, en=False, bgc=dictionary.returnStateColor('normal'), ec=lambda *a: attrToolsLib.uiUpdateNiceName(self), h=20, w=75) AliasLabel = MelLabel(self.EditNameSettingsRow, label='Alias: ') self.AliasField = MelTextField( self.EditNameSettingsRow, en=False, bgc=dictionary.returnStateColor('normal'), ec=lambda *a: attrToolsLib.uiUpdateAlias(self), h=20, w=75) MelSpacer(self.EditNameSettingsRow, w=5) self.EditNameSettingsRow.layout() """mc.formLayout(self.EditNameSettingsRow, edit = True, af = [(NameLabel, "left", 5), (self.AliasField,"right",5)], ac = [(self.NameField,"left",2,NameLabel), (NiceNameLabel,"left",2,self.NameField), (self.NiceNameField,"left",2,NiceNameLabel), (AliasLabel,"left",2,self.NiceNameField), (self.AliasField,"left",2,AliasLabel), ])""" #>>> Int Row #self.EditDigitSettingsRow = MelFormLayout(self.containerName,ut='cgmUISubTemplate',vis = False) self.EditDigitSettingsRow = MelHSingleStretchLayout( self.containerName, ut='cgmUISubTemplate', vis=False) self.EditDigitSettingsRow.setStretchWidget( MelSpacer(self.EditDigitSettingsRow, w=5)) MinLabel = MelLabel(self.EditDigitSettingsRow, label='Min:') self.MinField = MelTextField( self.EditDigitSettingsRow, bgc=dictionary.returnStateColor('normal'), ec=lambda *a: attrToolsLib.uiUpdateMinValue(self), h=20, w=35) MaxLabel = MelLabel(self.EditDigitSettingsRow, label='Max:') self.MaxField = MelTextField( self.EditDigitSettingsRow, bgc=dictionary.returnStateColor('normal'), ec=lambda *a: attrToolsLib.uiUpdateMaxValue(self), h=20, w=35) DefaultLabel = MelLabel(self.EditDigitSettingsRow, label='dv:') self.DefaultField = MelTextField( self.EditDigitSettingsRow, bgc=dictionary.returnStateColor('normal'), ec=lambda *a: attrToolsLib.uiUpdateDefaultValue(self), h=20, w=35) SoftMinLabel = MelLabel(self.EditDigitSettingsRow, label='sMin:') self.SoftMinField = MelTextField( self.EditDigitSettingsRow, bgc=dictionary.returnStateColor('normal'), ec=lambda *a: attrToolsLib.uiUpdateSoftMinValue(self), h=20, w=35) SoftMaxLabel = MelLabel(self.EditDigitSettingsRow, label='sMax:') self.SoftMaxField = MelTextField( self.EditDigitSettingsRow, bgc=dictionary.returnStateColor('normal'), ec=lambda *a: attrToolsLib.uiUpdateSoftMaxValue(self), h=20, w=35) MelSpacer(self.EditDigitSettingsRow, w=5) self.EditDigitSettingsRow.layout() """mc.formLayout(self.EditDigitSettingsRow, edit = True, af = [(MinLabel, "left", 20), (self.SoftMinField,"right",20)], ac = [(self.MinField,"left",2,MinLabel), (MaxLabel,"left",2,self.MinField), (self.MaxField,"left",2,MaxLabel), (DefaultLabel,"left",2,self.MaxField), (self.DefaultField,"left",2,DefaultLabel), (SoftMaxLabel,"left",2,self.DefaultField), (self.SoftMaxField,"left",2,SoftMaxLabel), (SoftMinLabel,"left",2,self.SoftMaxField), (self.SoftMinField,"left",2,SoftMinLabel) ])""" #>>> Enum self.EditEnumRow = MelHSingleStretchLayout(self.containerName, ut='cgmUISubTemplate', padding=5, vis=False) MelSpacer(self.EditEnumRow, w=10) MelLabel(self.EditEnumRow, label='Enum: ') self.EnumField = MelTextField( self.EditEnumRow, annotation= "Options divided by ':'. \n Set values with '=' \n For example: 'off:on=1:maybe=23'", bgc=dictionary.returnStateColor('normal'), h=20, w=75) MelSpacer(self.EditEnumRow, w=10) self.EditEnumRow.setStretchWidget(self.EnumField) self.EditEnumRow.layout() #>>> String self.EditStringRow = MelHSingleStretchLayout(self.containerName, ut='cgmUISubTemplate', padding=5, vis=False) MelSpacer(self.EditStringRow, w=10) MelLabel(self.EditStringRow, label='String: ') self.StringField = MelTextField( self.EditStringRow, h=20, bgc=dictionary.returnStateColor('normal'), w=75) MelSpacer(self.EditStringRow, w=10) self.EditStringRow.setStretchWidget(self.StringField) self.EditStringRow.layout() #>>> Message self.EditMessageRow = MelHSingleStretchLayout(self.containerName, ut='cgmUISubTemplate', padding=5, vis=False) MelSpacer(self.EditMessageRow, w=10) MelLabel(self.EditMessageRow, label='Message: ') self.MessageField = MelTextField( self.EditMessageRow, h=20, enable=False, bgc=dictionary.returnStateColor('locked'), ec=lambda *a: tdToolsLib.uiUpdateAutoNameTag(self, 'cgmPosition'), w=75) self.LoadMessageButton = guiFactory.doButton2( self.EditMessageRow, '<<', lambda *a: attrToolsLib.uiUpdateMessage(self), 'Load to message') MelSpacer(self.EditMessageRow, w=10) self.EditMessageRow.setStretchWidget(self.MessageField) self.EditMessageRow.layout() #>>> Conversion self.buildAttrConversionRow(self.containerName) self.AttrConvertRow(e=True, vis=False) #>>> Connect Report self.ConnectionReportRow = MelHLayout(self.containerName, ut='cgmUIInstructionsTemplate', h=20, vis=False) self.ConnectionReportField = MelLabel( self.ConnectionReportRow, vis=False, bgc=dictionary.returnStateColor('help'), align='center', label='...', h=20) self.ConnectionReportRow.layout() self.ConnectedPopUpMenu = MelPopupMenu(self.ConnectionReportRow, button=3) MelSeparator(self.containerName, ut='cgmUIHeaderTemplate', h=2) mc.setParent(self.containerName) guiFactory.lineBreak() return self.containerName def buildAttrTypeRow(self, parent): #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Attr type row #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> self.attrTypes = [ 'string', 'float', 'int', 'double3', 'bool', 'enum', 'message' ] attrShortTypes = [ 'str', 'float', 'int', '[000]', 'bool', 'enum', 'msg' ] self.CreateAttrTypeRadioCollection = MelRadioCollection() self.CreateAttrTypeRadioCollectionChoices = [] #build our sub section options AttrTypeRow = MelHLayout(self.containerName, ut='cgmUISubTemplate', padding=5) for cnt, item in enumerate(self.attrTypes): self.CreateAttrTypeRadioCollectionChoices.append( self.CreateAttrTypeRadioCollection.createButton( AttrTypeRow, label=attrShortTypes[cnt], onCommand=Callback(self.CreateAttrTypeOptionVar.set, item))) MelSpacer(AttrTypeRow, w=2) if self.CreateAttrTypeOptionVar.value: mc.radioCollection(self.CreateAttrTypeRadioCollection, edit=True, sl=(self.CreateAttrTypeRadioCollectionChoices[ self.attrTypes.index( self.CreateAttrTypeOptionVar.value)])) AttrTypeRow.layout() def buildAttrConversionRow(self, parent): #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Attr type row #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> self.attrConvertTypes = [ 'string', 'float', 'int', 'bool', 'enum', 'message' ] self.attrConvertShortTypes = [ 'str', 'float', 'int', 'bool', 'enum', 'msg' ] self.ConvertAttrTypeRadioCollection = MelRadioCollection() self.ConvertAttrTypeRadioCollectionChoices = [] self.ConvertAttrTypeOptionVar = OptionVarFactory( 'cgmVar_ActiveAttrConversionState', 'int') guiFactory.appendOptionVarList(self, self.ConvertAttrTypeOptionVar.name) self.ConvertAttrTypeOptionVar.set(0) #build our sub section options self.AttrConvertRow = MelHLayout(self.containerName, ut='cgmUISubTemplate', padding=5) for cnt, item in enumerate(self.attrConvertTypes): self.ConvertAttrTypeRadioCollectionChoices.append( self.ConvertAttrTypeRadioCollection.createButton( self.AttrConvertRow, label=self.attrConvertShortTypes[cnt], onCommand=Callback(attrToolsLib.uiConvertLoadedAttr, self, item))) MelSpacer(self.AttrConvertRow, w=2) self.AttrConvertRow.layout() def buildAttributeManagerTool(self, parent, vis=True): self.ManageForm = MelFormLayout(self.Get(), ut='cgmUITemplate') ManageHeader = guiFactory.header('Manage Attributes') #>>> Manager load frow ManagerLoadObjectRow = MelHSingleStretchLayout(self.ManageForm, padding=5) MelSpacer(ManagerLoadObjectRow, w=5) guiFactory.doButton2(ManagerLoadObjectRow, '>>', lambda *a: attrToolsLib.uiLoadSourceObject(self), 'Load to field') self.ManagerSourceObjectField = MelTextField( ManagerLoadObjectRow, w=125, h=20, ut='cgmUIReservedTemplate', editable=False) ManagerLoadObjectRow.setStretchWidget(self.ManagerSourceObjectField) MelSpacer(ManagerLoadObjectRow, w=5) ManagerLoadObjectRow.layout() #>>> Attribute List self.ManageAttrList = MelObjectScrollList(self.ManageForm, allowMultiSelection=True) #>>> Reorder Button ReorderButtonsRow = MelHLayout(self.ManageForm, padding=5) guiFactory.doButton2( ReorderButtonsRow, 'Move Up', lambda *a: attrToolsLib.uiReorderAttributes(self, 0), 'Create new buffer from selected buffer') guiFactory.doButton2( ReorderButtonsRow, 'Move Down', lambda *a: attrToolsLib.uiReorderAttributes(self, 1), 'Create new buffer from selected buffer') ReorderButtonsRow.layout() #>>>Transfer Options self.TransferModeCollection = MelRadioCollection() self.TransferModeCollectionChoices = [] TransferModeFlagsRow = MelHSingleStretchLayout(self.ManageForm, padding=2) MelLabel(TransferModeFlagsRow, l='Modes') Spacer = MelSeparator(TransferModeFlagsRow, w=10) self.TransferModeOptions = ['Connect', 'Copy', 'Transfer'] for i, item in enumerate(self.TransferModeOptions): self.TransferModeCollectionChoices.append( self.TransferModeCollection.createButton( TransferModeFlagsRow, label=item, onCommand=Callback(self.CopyAttrModeOptionVar.set, i))) MelSpacer(TransferModeFlagsRow, w=3) TransferModeFlagsRow.setStretchWidget(Spacer) MelSpacer(TransferModeFlagsRow, w=2) TransferModeFlagsRow.layout() mc.radioCollection(self.TransferModeCollection, edit=True, sl=(self.TransferModeCollectionChoices[( self.CopyAttrModeOptionVar.value)])) #>>>Transfer Options self.TransferOptionsCollection = MelRadioCollection() self.TransferOptionsCollectionChoices = [] TransferOptionsFlagsRow = MelHSingleStretchLayout(self.ManageForm, padding=0) Spacer = MelSpacer(TransferOptionsFlagsRow) TransferOptionsFlagsRow.setStretchWidget(Spacer) self.ConvertCB = MelCheckBox( TransferOptionsFlagsRow, label='Convert', annotation="Converts if necessary to finish the copy process", value=self.TransferConvertStateOptionVar.value, onCommand=Callback(self.TransferConvertStateOptionVar.set, 1), offCommand=Callback(self.TransferConvertStateOptionVar.set, 0)) self.ValueCB = MelCheckBox( TransferOptionsFlagsRow, label='Value', annotation="Copy values", value=self.TransferValueOptionVar.value, onCommand=Callback(self.TransferValueOptionVar.set, 1), offCommand=Callback(self.TransferValueOptionVar.set, 0)) self.IncomingCB = MelCheckBox( TransferOptionsFlagsRow, label='In', annotation="Copy or transfer incoming connections", value=self.TransferIncomingOptionVar.value, onCommand=Callback(self.TransferIncomingOptionVar.set, 1), offCommand=Callback(self.TransferIncomingOptionVar.set, 0)) self.OutgoingCB = MelCheckBox( TransferOptionsFlagsRow, label='Out', annotation="Copy or transfer incoming connections", value=self.TransferOutgoingOptionVar.value, onCommand=Callback(self.TransferOutgoingOptionVar.set, 1), offCommand=Callback(self.TransferOutgoingOptionVar.set, 0)) self.KeepSourceCB = MelCheckBox( TransferOptionsFlagsRow, label='Keep', annotation="Keep source connections when copying", value=self.TransferKeepSourceOptionVar.value, onCommand=Callback(self.TransferKeepSourceOptionVar.set, 1), offCommand=Callback(self.TransferKeepSourceOptionVar.set, 0)) self.DriveSourceCB = MelCheckBox( TransferOptionsFlagsRow, label='Drive', annotation= "Connect the source attr \nto selected or created attribute", value=self.TransferDriveSourceStateOptionVar.value, onCommand=Callback(self.TransferDriveSourceStateOptionVar.set, 1), offCommand=Callback(self.TransferDriveSourceStateOptionVar.set, 0)) self.AttrOptionsCB = MelCheckBox( TransferOptionsFlagsRow, label='Options', annotation= "Copies the attributes basic flags\n(locked,keyable,hidden)", value=self.CopyAttrOptionsOptionVar.value, onCommand=Callback(self.CopyAttrOptionsOptionVar.set, 1), offCommand=Callback(self.TransferDriveSourceStateOptionVar.set, 0)) TransferOptionsFlagsRow.layout() BottomButtonRow = guiFactory.doButton2( self.ManageForm, 'Connect/Copy/Transfer', lambda *a: attrToolsLib.uiTransferAttributes(self), 'Create new buffer from selected buffer') self.ManageForm( edit=True, af=[(ManageHeader, "top", 0), (ManageHeader, "left", 0), (ManageHeader, "right", 0), (self.ManageAttrList, "left", 0), (self.ManageAttrList, "right", 0), (ManagerLoadObjectRow, "left", 5), (ManagerLoadObjectRow, "right", 5), (ReorderButtonsRow, "left", 0), (ReorderButtonsRow, "right", 0), (TransferModeFlagsRow, "left", 5), (TransferModeFlagsRow, "right", 5), (BottomButtonRow, "left", 5), (BottomButtonRow, "right", 5), (TransferOptionsFlagsRow, "left", 2), (TransferOptionsFlagsRow, "right", 2), (TransferOptionsFlagsRow, "bottom", 4)], ac=[(ManagerLoadObjectRow, "top", 5, ManageHeader), (self.ManageAttrList, "top", 5, ManagerLoadObjectRow), (self.ManageAttrList, "bottom", 5, ReorderButtonsRow), (ReorderButtonsRow, "bottom", 5, BottomButtonRow), (BottomButtonRow, "bottom", 5, TransferModeFlagsRow), (TransferModeFlagsRow, "bottom", 5, TransferOptionsFlagsRow)], attachNone=[(TransferOptionsFlagsRow, "top")]) #Build pop up for attribute list field popUpMenu = MelPopupMenu(self.ManageAttrList, button=3) MelMenuItem(popUpMenu, label='Make Keyable', c=lambda *a: attrToolsLib.uiManageAttrsKeyable(self)) MelMenuItem(popUpMenu, label='Make Unkeyable', c=lambda *a: attrToolsLib.uiManageAttrsUnkeyable(self)) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu, label='Hide', c=lambda *a: attrToolsLib.uiManageAttrsHide(self)) MelMenuItem(popUpMenu, label='Unhide', c=lambda *a: attrToolsLib.uiManageAttrsUnhide(self)) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu, label='Lock', c=lambda *a: attrToolsLib.uiManageAttrsLocked(self)) MelMenuItem(popUpMenu, label='Unlock', c=lambda *a: attrToolsLib.uiManageAttrsUnlocked(self)) MelMenuItemDiv(popUpMenu) MelMenuItem(popUpMenu, label='Delete', c=lambda *a: attrToolsLib.uiManageAttrsDelete(self)) return self.ManageForm def buildAttributeUtilitiesTool(self, parent, vis=True): containerName = 'Utilities Container' self.containerName = MelColumn(parent, vis=vis) #>>> Tag Labels mc.setParent(self.containerName) guiFactory.header('Short cuts') guiFactory.lineSubBreak() AttributeUtilityRow1 = MelHLayout(self.containerName, ut='cgmUISubTemplate', padding=2) guiFactory.doButton2( AttributeUtilityRow1, 'cgmName to Float', lambda *a: tdToolsLib.doCGMNameToFloat(), 'Makes an animatalbe float attribute using the cgmName tag') mc.setParent(self.containerName) guiFactory.lineSubBreak() AttributeUtilityRow1.layout() #>>> SDK tools mc.setParent(self.containerName) guiFactory.lineBreak() guiFactory.header('SDK Tools') guiFactory.lineSubBreak() sdkRow = MelHLayout(self.containerName, ut='cgmUISubTemplate', padding=2) guiFactory.doButton2(sdkRow, 'Select Driven Joints', lambda *a: tdToolsLib.doSelectDrivenJoints(self), "Selects driven joints from an sdk attribute") sdkRow.layout() mc.setParent(self.containerName) guiFactory.lineSubBreak() return self.containerName
def createUI(self, parent): """ Create the UI """ def buttonAction(command): """ execute a command and let the menu know not do do the default button action but just kill the ui """ killUI() command mmActionOptionVar.set(1) self.LocinatorUpdateObjectsBufferOptionVar = OptionVarFactory( 'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=['']) IsClickedOptionVar = OptionVarFactory('cgmVar_IsClicked', 'int') mmActionOptionVar = OptionVarFactory('cgmVar_mmAction', 'int') self.SnapModeOptionVar.update( ) #Check if another tool has changed this setting sel = search.selectCheck() selPair = search.checkSelectionLength(2) IsClickedOptionVar.set(1) mc.menu(parent, e=True, deleteAllItems=True) MelMenuItem(parent, en=selPair, l='Point Snap', c=lambda *a: buttonAction(tdToolsLib.doPointSnap()), rp='NW') MelMenuItem(parent, en=selPair, l='Parent Snap', c=lambda *a: buttonAction(tdToolsLib.doParentSnap()), rp='N') MelMenuItem(parent, en=selPair, l='Orient Snap', c=lambda *a: buttonAction(tdToolsLib.doOrientSnap()), rp='NE') MelMenuItem(parent, en=selPair, l='Surface Snap', c=lambda *a: buttonAction( tdToolsLib.doSnapClosestPointToSurface(False)), rp='W') if self.LocinatorUpdateObjectsOptionVar.value: ShowMatch = False if self.LocinatorUpdateObjectsBufferOptionVar.value: ShowMatch = True MelMenuItem(parent, en=ShowMatch, l='Buffer Snap', c=lambda *a: buttonAction( locinatorLib.doUpdateLoc(self, True)), rp='S') else: ShowMatch = search.matchObjectCheck() MelMenuItem(parent, en=ShowMatch, l='Match Snap', c=lambda *a: buttonAction( locinatorLib.doUpdateSelectedObjects(self)), rp='S') MelMenuItem( parent, en=0, l='Mirror', c=lambda *a: buttonAction(locinatorLib.doUpdateObj(self, True)), rp='SW') MelMenuItemDiv(parent) MelMenuItem(parent, l='Loc Me', c=lambda *a: buttonAction(locinatorLib.doLocMe(self))) MelMenuItem(parent, l='Tag Loc to Object', en=selPair, c=lambda *a: buttonAction(locinatorLib.doTagObjects(self))) # Update Mode UpdateMenu = MelMenuItem(parent, l='Update Mode', subMenu=True) UpdateMenuCollection = MelRadioMenuCollection() if self.LocinatorUpdateObjectsOptionVar.value == 0: slMode = True bufferMode = False else: slMode = False bufferMode = True UpdateMenuCollection.createButton( UpdateMenu, l='Selected', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(0), rb=slMode) UpdateMenuCollection.createButton( UpdateMenu, l='Buffer', c=lambda *a: self.LocinatorUpdateObjectsOptionVar.set(1), rb=bufferMode) #>>>Match Mode self.MatchModeOptions = ['parent', 'point', 'orient'] self.MatchModeCollection = MelRadioMenuCollection() self.MatchModeCollectionChoices = [] MatchModeMenu = MelMenuItem(parent, l='Match Mode', subMenu=True) self.matchMode = self.SnapModeOptionVar.value for c, item in enumerate(self.MatchModeOptions): if self.matchMode == c: rbValue = True else: rbValue = False self.MatchModeCollectionChoices.append( self.MatchModeCollection.createButton( MatchModeMenu, label=item, rb=rbValue, command=Callback(self.SnapModeOptionVar.set, c))) #>>> Define DefineMenu = MelMenuItem(parent, l='Buffer', subMenu=True) MelMenuItem(DefineMenu, l="Define", c=lambda *a: locinatorLib.defineObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(DefineMenu, l="Add Selected", c=lambda *a: locinatorLib.addSelectedToObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(DefineMenu, l="Remove Selected", c=lambda *a: locinatorLib.removeSelectedFromObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv(DefineMenu) MelMenuItem(DefineMenu, l="Select Members", c=lambda *a: locinatorLib.selectObjBufferMembers( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItem(DefineMenu, l="Clear", c=lambda *a: locinatorLib.clearObjBuffer( self.LocinatorUpdateObjectsBufferOptionVar)) MelMenuItemDiv(parent) MelMenuItem(parent, l='Locinator', c=lambda *a: buttonAction(cgmToolbox.loadLocinator())) MelMenuItem(parent, l='cgm.animTools', c=lambda *a: buttonAction(cgmToolbox.loadAnimTools())) MelMenuItem(parent, l='cgm.tdTools', c=lambda *a: buttonAction(cgmToolbox.loadTDTools())) MelMenuItem(parent, l='cgm.attrTools', c=lambda *a: buttonAction(cgmToolbox.loadAttrTools())) MelMenuItemDiv(parent) MelMenuItem(parent, l="Reset", c=lambda *a: guiFactory.resetGuiInstanceOptionVars( self.optionVars))