Beispiel #1
0
def updateBufferName(self,bufferTextField,bufferName):
	newName = mc.textField(bufferTextField,q=True,text = True)
	
	assert mc.objExists(bufferName) is True,"'%s' doesn't exist.Try updating the tool."%bufferObject

	if bufferName and newName:
		b = ObjectFactory(bufferName)
		b.store('cgmName', newName)
		b.doName()
		mc.textField(bufferTextField,e = True,text = b.nameBase)
		#Reset
		guiFactory.resetGuiInstanceOptionVars(self.optionVars,bufferTools.run)

	else:
		guiFactory.warning("There's a problem with the name input.")
def updateBufferName(self,bufferTextField,bufferName):
	newName = mc.textField(bufferTextField,q=True,text = True)
	
	assert mc.objExists(bufferName) is True,"'%s' doesn't exist.Try updating the tool."%bufferObject

	if bufferName and newName:
		b = ObjectFactory(bufferName)
		b.store('cgmName', newName)
		b.doName()
		mc.textField(bufferTextField,e = True,text = b.nameBase)
		#Reset
		guiFactory.resetGuiInstanceOptionVars(self.optionVars,bufferTools.run)

	else:
		guiFactory.warning("There's a problem with the name input.")
	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))
Beispiel #4
0
	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))
Beispiel #5
0
    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))
Beispiel #6
0
 def reset(self):
     Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars, run))
Beispiel #7
0
    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))
Beispiel #8
0
	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))
Beispiel #9
0
	def reset(self):	
		Callback(guiFactory.resetGuiInstanceOptionVars(self.optionVars,run))
Beispiel #10
0
		mUI.MelMenuItem(parent, l = 'cgm.animTools',
	                c = lambda *a: buttonAction(cgmToolbox.loadAnimTools()))	
		mUI.MelMenuItemDiv(parent)
		mUI.MelMenuItem(parent,l = 'ml Set Key',
			        c = lambda *a: buttonAction(animToolsLib.ml_setKeyCall()))
		mUI.MelMenuItem(parent,l = 'ml Hold',
			        c = lambda *a: buttonAction(animToolsLib.ml_holdCall()))
		mUI.MelMenuItem(parent,l = 'ml Delete Key',
			        c = lambda *a: buttonAction(animToolsLib.ml_deleteKeyCall()))
		mUI.MelMenuItem(parent,l = 'ml Arc Tracer',
			        c = lambda *a: buttonAction(animToolsLib.ml_arcTracerCall()))
		"""
        #mUI.MelMenuItem(parent,l = "-"*20,en = False)
        mUI.MelMenuItemDiv(parent)							
        mUI.MelMenuItem(parent, l="Reset",
                    c=lambda *a: guiFactory.resetGuiInstanceOptionVars(self.optionVars))

        f_time = time.clock()-time_buildMenuStart
        log.info('build menu took: %0.3f seconds  ' % (f_time) + '<'*10)  

    def toggleVarAndReset(self, optionVar):
        try:
            self.mmActionOptionVar.value=1						
            optionVar.toggle()
            log.info("PuppetKey.toggleVarAndReset>>> %s : %s"%(optionVar.name,optionVar.value))
        except Exception,error:
            log.error(error)
            print "MM change var and reset failed!"


def killUI():
Beispiel #11
0
	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))
Beispiel #12
0
class snapMarkingMenu(mUI.BaseMelWindow):
    def __init__(self):
        """
		Initializes the pop up menu class call
		"""
        self._str_MM = 'snapMarkingMenu'
        self.optionVars = []
        self.toolName = 'cgm.snapMM'
        IsClickedOptionVar = cgmMeta.cgmOptionVar('cgmVar_IsClicked', 'int')
        mmActionOptionVar = cgmMeta.cgmOptionVar('cgmVar_mmAction', 'int')
        surfaceSnapAimModeVar = cgmMeta.cgmOptionVar(
            'cgmVar_SurfaceSnapAimMode', 'int')
        UpdateRotateOrderOnTagVar = cgmMeta.cgmOptionVar(
            'cgmVar_TaggingUpdateRO', 'int')
        self.LocinatorUpdateObjectsBufferOptionVar = cgmMeta.cgmOptionVar(
            'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=[''])

        self.LocinatorUpdateObjectsOptionVar = cgmMeta.cgmOptionVar(
            'cgmVar_SnapMMUpdateMode', defaultValue=0)
        guiFactory.appendOptionVarList(
            self, self.LocinatorUpdateObjectsOptionVar.name)

        self.SnapModeOptionVar = cgmMeta.cgmOptionVar('cgmVar_SnapMatchMode',
                                                      defaultValue=0)
        guiFactory.appendOptionVarList(self, self.SnapModeOptionVar.name)

        IsClickedOptionVar.setValue(0)
        mmActionOptionVar.setValue(0)

        #if mc.popupMenu('cgmMM',ex = True):
        #mc.deleteUI('cgmMM')#...deleting ui elements seems to be hard crashing maya 2017

        _p = mc.getPanel(up=True)
        if _p is None:
            log.error("No panel detected...")
            return
        if _p:
            log.info("{0} panel under pointer {1}...".format(self._str_MM, _p))
            _parentPanel = mc.panel(_p, q=True, ctl=True)
            log.info("{0} panel under pointer {1} | parent: {2}...".format(
                self._str_MM, _p, _parentPanel))
            if 'MayaWindow' in _parentPanel:
                _p = 'viewPanes'
        if not mc.control(_p, ex=True):
            raise ValueError, "{0} doesn't exist!".format(_p)
            #_p = panel
        if not mc.popupMenu('cgmMM', ex=True):
            mc.popupMenu('cgmMM',
                         ctl=0,
                         alt=0,
                         sh=0,
                         mm=1,
                         b=1,
                         aob=1,
                         p=_p,
                         pmc=lambda *a: self.createUI('cgmMM'),
                         postMenuCommandOnce=True)
        else:
            mc.popupMenu('cgmMM',
                         edit=True,
                         ctl=0,
                         alt=0,
                         sh=0,
                         mm=1,
                         b=1,
                         aob=1,
                         p=_p,
                         pmc=lambda *a: self.createUI('cgmMM'),
                         postMenuCommandOnce=True)

    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()
            mmActionOptionVar.value = 1
            command

        self.LocinatorUpdateObjectsBufferOptionVar = cgmMeta.cgmOptionVar(
            'cgmVar_LocinatorUpdateObjectsBuffer', defaultValue=[''])
        IsClickedOptionVar = cgmMeta.cgmOptionVar('cgmVar_IsClicked', 'int')
        mmActionOptionVar = cgmMeta.cgmOptionVar('cgmVar_mmAction', 'int')

        self.SnapModeOptionVar.update(
        )  #Check if another tool has changed this setting

        _sel = mc.ls(sl=True)
        selPair = search.checkSelectionLength(2)
        _selecCheck = len(_sel)
        IsClickedOptionVar.value = 1

        mc.menu(parent, e=True, deleteAllItems=True)
        mUI.MelMenuItem(parent,
                        en=selPair,
                        l='Point Snap',
                        c=lambda *a: buttonAction(tdToolsLib.doPointSnap()),
                        rp='NW')
        mUI.MelMenuItem(parent,
                        en=selPair,
                        l='Parent Snap',
                        c=lambda *a: buttonAction(tdToolsLib.doParentSnap()),
                        rp='N')
        mUI.MelMenuItem(parent,
                        en=selPair,
                        l='Orient Snap',
                        c=lambda *a: buttonAction(tdToolsLib.doOrientSnap()),
                        rp='NE')

        mUI.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
            mUI.MelMenuItem(parent,
                            en=ShowMatch,
                            l='Buffer Snap',
                            c=lambda *a: buttonAction(
                                locinatorLib.doUpdateLoc(self, True)),
                            rp='S')
        else:
            ShowMatch = search.matchObjectCheck()
            mUI.MelMenuItem(parent,
                            en=ShowMatch,
                            l='Match Snap',
                            c=lambda *a: buttonAction(
                                locinatorLib.doUpdateSelectedObjects(self)),
                            rp='S')

        mUI.MelMenuItem(
            parent,
            en=_selecCheck,
            l='RayCast',
            #c = mUI.Callback(buttonAction,raySnap_start(_sel)),
            c=lambda *a: buttonAction(raySnap_start(_sel)),
            rp='SW')
        mUI.MelMenuItem(
            parent,
            en=0,
            l='Mirror',
            c=lambda *a: buttonAction(locinatorLib.doUpdateObj(self, True)),
            rp='SE')

        mUI.MelMenuItemDiv(parent)
        mUI.MelMenuItem(parent,
                        l='Loc Me',
                        c=lambda *a: buttonAction(locinatorLib.doLocMe(self)))
        mUI.MelMenuItem(
            parent,
            l='Tag Loc to Object',
            en=selPair,
            c=lambda *a: buttonAction(locinatorLib.doTagObjects(self)))
        # Update Mode
        UpdateMenu = mUI.MelMenuItem(parent, l='Update Mode', subMenu=True)
        UpdateMenuCollection = mUI.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.setValue(0),
            rb=slMode)
        UpdateMenuCollection.createButton(
            UpdateMenu,
            l='Buffer',
            c=lambda *a: self.LocinatorUpdateObjectsOptionVar.setValue(1),
            rb=bufferMode)
        #>>>Match Mode
        self.MatchModeOptions = ['parent', 'point', 'orient']

        self.MatchModeCollection = mUI.MelRadioMenuCollection()
        self.MatchModeCollectionChoices = []

        MatchModeMenu = mUI.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=mUI.Callback(self.SnapModeOptionVar.setValue, c)))
        #>>> Define
        DefineMenu = mUI.MelMenuItem(parent, l='Buffer', subMenu=True)
        mUI.MelMenuItem(DefineMenu,
                        l="Define",
                        c=lambda *a: locinatorLib.defineObjBuffer(
                            self.LocinatorUpdateObjectsBufferOptionVar))

        mUI.MelMenuItem(DefineMenu,
                        l="Add Selected",
                        c=lambda *a: locinatorLib.addSelectedToObjBuffer(
                            self.LocinatorUpdateObjectsBufferOptionVar))

        mUI.MelMenuItem(DefineMenu,
                        l="Remove Selected",
                        c=lambda *a: locinatorLib.removeSelectedFromObjBuffer(
                            self.LocinatorUpdateObjectsBufferOptionVar))

        mUI.MelMenuItemDiv(DefineMenu)
        mUI.MelMenuItem(DefineMenu,
                        l="Select Members",
                        c=lambda *a: locinatorLib.selectObjBufferMembers(
                            self.LocinatorUpdateObjectsBufferOptionVar))
        mUI.MelMenuItem(DefineMenu,
                        l="Clear",
                        c=lambda *a: locinatorLib.clearObjBuffer(
                            self.LocinatorUpdateObjectsBufferOptionVar))

        try:  #>>> Sym Axis....
            _str_section = 'Ray Cast menu'

            uiMenu_rayCast = mUI.MelMenuItem(parent,
                                             l='Ray Cast Mode',
                                             subMenu=True)
            var_RayCastMode = cgmMeta.cgmOptionVar(
                'cgmVar_SnapMenuRayCastMode', defaultValue=0)

            self.uiRC_RayCast = mUI.MelRadioMenuCollection()
            self.uiOptions_RayCast = []
            _v = var_RayCastMode.value
            _modes = cgmDrag._clickMesh_modes
            for i, item in enumerate(_modes):
                if i == _v:
                    _rb = True
                else:
                    _rb = False
                self.uiOptions_RayCast.append(
                    self.uiRC_RayCast.createButton(
                        uiMenu_rayCast,
                        label=item,
                        c=mUI.Callback(var_RayCastMode.setValue, i),
                        rb=_rb))
        except Exception, err:
            log.error("{0} failed to load. err: {1}".format(_str_section, err))

        mUI.MelMenuItemDiv(parent)
        mUI.MelMenuItem(parent,
                        l='Locinator',
                        c=lambda *a: buttonAction(cgmToolbox.loadLocinator()))
        mUI.MelMenuItem(parent,
                        l='cgm.animTools',
                        c=lambda *a: buttonAction(cgmToolbox.loadAnimTools()))
        mUI.MelMenuItem(parent,
                        l='cgm.tdTools',
                        c=lambda *a: buttonAction(cgmToolbox.loadTDTools()))
        mUI.MelMenuItem(parent,
                        l='cgm.attrTools',
                        c=lambda *a: buttonAction(cgmToolbox.loadAttrTools()))
        mUI.MelMenuItem(parent,
                        l='reload cgm.core',
                        c=lambda *a: buttonAction(cgmToolbox.reload_cgmCore()))

        mUI.MelMenuItemDiv(parent)

        mUI.MelMenuItem(
            parent,
            l="Docs",
            c='import webbrowser;webbrowser.open("http://www.cgmonks.com/tools/maya-tools/cgmmmsnap");'
        )

        mUI.MelMenuItem(parent,
                        l="Reset",
                        c=lambda *a: guiFactory.resetGuiInstanceOptionVars(
                            self.optionVars))
Beispiel #13
0
    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))
Beispiel #14
0
		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()))
		"""
	#MelMenuItem(parent,l = "-"*20,en = False)
	MelMenuItemDiv(parent)							
	MelMenuItem(parent, l="Reset",
	            c=lambda *a: guiFactory.resetGuiInstanceOptionVars(self.optionVars))
	
	f_time = time.clock()-time_buildMenuStart
	log.info('build menu took: %0.3f seconds  ' % (f_time) + '<'*10)  
	
    def toggleVarAndReset(self, optionVar):
	try:
	    self.mmActionOptionVar.value=1						
	    optionVar.toggle()
	    log.info("PuppetKey.toggleVarAndReset>>> %s : %s"%(optionVar.name,optionVar.value))
	except Exception,error:
	    log.error(error)
	    print "MM change var and reset failed!"


def killUI():