def selectPaintWeightsInfluence(self, infl):
        '''
        tries to select influence (provided as string) in current maya's paint weights context and UI
        if skin paint context is not available, nothing happens
        '''
        if not Utils.isCurrentlyPaintingWeights():
            return

        # influence name can come in any form ('joint3', 'joint2|joint3', 'joint1|joint2|joint3')
        # get the absolute shortest possible (but still unique) and longest
        try:
            longName = cmds.ls(infl, l=True)[0]
            shortName = cmds.ls(longName, l=False)[0]

            log.info("selecting in paint weights: influence %s" % str(infl))

            # try to work around with the mess in the earlier versions of
            # maya's paint weights UI:
            if Utils.getMayaVersion() < Utils.MAYA2011:
                itemName = Utils.mel('artAttrSkinShortName("%s")' % shortName)
                Utils.mel(
                    'artSkinSelectInfluence("artAttrSkinPaintCtx","%s","%s");'
                    % (shortName, itemName))
            else:
                Utils.mel(
                    'artSkinSelectInfluence("artAttrSkinPaintCtx","%s");' %
                    shortName)

            # show paint weights interface
            cmds.toolPropertyWindow()
        except:
            # problems listing given influence.. just die here
            Utils.displayError('problem selecting influence %s' % infl)
Exemplo n.º 2
0
    def selectPaintWeightsInfluence(self,infl):
        '''
        tries to select influence (provided as string) in current maya's paint weights context and UI
        if skin paint context is not available, nothing happens
        '''
        if not Utils.isCurrentlyPaintingWeights():
            return
        
        # influence name can come in any form ('joint3', 'joint2|joint3', 'joint1|joint2|joint3')
        # get the absolute shortest possible (but still unique) and longest
        try:
            longName = cmds.ls(infl,l=True)[0]
            shortName = cmds.ls(longName,l=False)[0]

            log.info("selecting in paint weights: influence %s" % str(infl))
        
            # try to work around with the mess in the earlier versions of 
            # maya's paint weights UI:
            if Utils.getMayaVersion()<Utils.MAYA2011:
                itemName = Utils.mel('artAttrSkinShortName("%s")'%shortName)
                Utils.mel('artSkinSelectInfluence("artAttrSkinPaintCtx","%s","%s");' % (shortName,itemName));
            else:
                Utils.mel('artSkinSelectInfluence("artAttrSkinPaintCtx","%s");' % shortName);
                
            # show paint weights interface
            cmds.toolPropertyWindow()
        except:
            # problems listing given influence.. just die here
            Utils.displayError('problem selecting influence %s' % infl)
Exemplo n.º 3
0
def closeNextDialogWithResult(result):
    '''
    close next modal dialog with given result
    '''
    if Utils.getMayaVersion()>=Utils.MAYA2011:
        mUtils.executeDeferred(lambda:BaseDialog.currentDialog.closeDialogWithResult(result))
    else:
        Utils.displayError("hurray for maya 2009, close dialog manually with result "+result)
Exemplo n.º 4
0
def closeNextDialogWithResult(result):
    '''
    close next modal dialog with given result
    '''
    if Utils.getMayaVersion() >= Utils.MAYA2011:
        mUtils.executeDeferred(
            lambda: BaseDialog.currentDialog.closeDialogWithResult(result))
    else:
        Utils.displayError(
            "hurray for maya 2009, close dialog manually with result " +
            result)
Exemplo n.º 5
0
    def execute(self):
        ldm = LayerDataModel.getInstance()
        for layerId in ldm.layerListsUI.getSelectedLayers():
            if ldm.mll.getLayerIndex(layerId) == 0:
                Utils.displayError("Cannot merge lowest layer")
                return

            ldm.mll.layerMergeDown(layerId)

        LayerEvents.layerListModified.emit()
        self.onExecuted.emit()
Exemplo n.º 6
0
    def execute(self):
        '''
        button handler for "Mirror Skin Weights"
        '''
        from ngSkinTools.ui.mainwindow import MainWindow
        from ngSkinTools.ui.tabMirror import TabMirror

        # any problems? maybe cache is not initialized/outdated?
        layerData = LayerDataModel.getInstance()
        layerData.updateMirrorCacheStatus()
        if not layerData.mirrorCache.isValid:
            Utils.displayError(layerData.mirrorCache.message)
            return False

        try:
            mirrorTab = MainWindow.getInstance().tabMirror

            mirrorDirection = MirrorDirection.DIRECTION_POSITIVETONEGATIVE
            if mirrorTab.controls.mirrorDirection.getValue() == 0:  # guess
                mirrorDirection = MirrorDirection.DIRECTION_GUESS
            if mirrorTab.controls.mirrorDirection.getValue(
            ) == 2:  # negative to positive
                mirrorDirection = MirrorDirection.DIRECTION_NEGATIVETOPOSITIVE
            if mirrorTab.controls.mirrorDirection.getSelectedText(
            ) == TabMirror.MIRROR_FLIP:
                mirrorDirection = MirrorDirection.DIRECTION_FLIP

            with LayerDataModel.getInstance().mll.batchUpdateContext():
                for layerId in LayerDataModel.getInstance(
                ).layerListsUI.getSelectedLayers():
                    LayerDataModel.getInstance().mll.mirrorLayerWeights(
                        layerId,
                        mirrorWidth=mirrorTab.controls.mirrorWidth.getValue(),
                        mirrorLayerWeights=mirrorTab.controls.mirrorWeights.
                        getValue(),
                        mirrorLayerMask=mirrorTab.controls.mirrorMask.getValue(
                        ),
                        mirrorDualQuaternion=mirrorTab.controls.mirrorDq.
                        getValue(),
                        mirrorDirection=mirrorDirection)

            # if layer list is filtered, might be handy to refresh influence list now - not that it costs much
            LayerEvents.influenceListChanged.emit()

            return True
        except:
            import traceback
            traceback.print_exc()
            Utils.displayError("unknown error")
            # we're not sure what's wrong in this case, just re-raise
            raise
Exemplo n.º 7
0
 def execute(self):
     ldm = LayerDataModel.getInstance()
     for layerId in ldm.layerListsUI.getSelectedLayers():
         if ldm.mll.getLayerIndex(layerId)==0:
             Utils.displayError("Cannot merge lowest layer")
             return
         
         ldm.mll.layerMergeDown(layerId)
         
         
     
         
     LayerEvents.layerListModified.emit()
     self.onExecuted.emit()
    def open():
        '''
        just a shortcut method to construct and display main window
        '''

        window = MainWindow.getInstance()
        window.showWindow()

        # don't know where to fit this in, it's just an utility warning for those trying to run
        # this on a different maya version
        if Utils.getMayaVersion() == Utils.MAYAUNSUPPORTEDVERSION:
            Utils.displayError('unsupported Maya version detected.')

        Utils.silentCheckForUpdates()

        return window
Exemplo n.º 9
0
    def open():
        '''
        just a shortcut method to construct and display main window
        '''

        window = MainWindow.getInstance()
        window.showWindow()
        
        # don't know where to fit this in, it's just an utility warning for those trying to run
        # this on a different maya version
        if Utils.getMayaVersion()==Utils.MAYAUNSUPPORTEDVERSION:
            Utils.displayError('unsupported Maya version detected.')
            
        Utils.silentCheckForUpdates()
        
        return window
Exemplo n.º 10
0
    def execute(self):
        '''
        button handler for "Mirror Skin Weights"
        '''
        from ngSkinTools.ui.mainwindow import MainWindow
        from ngSkinTools.ui.tabMirror import TabMirror
        

        # any problems? maybe cache is not initialized/outdated?
        layerData = LayerDataModel.getInstance() 
        layerData.updateMirrorCacheStatus()
        if not layerData.mirrorCache.isValid:
            Utils.displayError(layerData.mirrorCache.message)
            return False

        try:
            mirrorTab = MainWindow.getInstance().tabMirror
            
            mirrorDirection = MirrorDirection.DIRECTION_POSITIVETONEGATIVE
            if mirrorTab.controls.mirrorDirection.getValue()==0: # guess
                mirrorDirection = MirrorDirection.DIRECTION_GUESS;
            if mirrorTab.controls.mirrorDirection.getValue()==2: # negative to positive
                mirrorDirection = MirrorDirection.DIRECTION_NEGATIVETOPOSITIVE;
            if mirrorTab.controls.mirrorDirection.getSelectedText()==TabMirror.MIRROR_FLIP: 
                mirrorDirection = MirrorDirection.DIRECTION_FLIP;
            
            with LayerDataModel.getInstance().mll.batchUpdateContext():
                for layerId in LayerDataModel.getInstance().layerListsUI.getSelectedLayers():
                    LayerDataModel.getInstance().mll.mirrorLayerWeights(layerId,
                            mirrorWidth=mirrorTab.controls.mirrorWidth.getValue(),
                            mirrorLayerWeights=mirrorTab.controls.mirrorWeights.getValue(),
                            mirrorLayerMask=mirrorTab.controls.mirrorMask.getValue(),
                            mirrorDualQuaternion=mirrorTab.controls.mirrorDq.getValue(),
                            mirrorDirection=mirrorDirection
                        )
            
            # if layer list is filtered, might be handy to refresh influence list now - not that it costs much
            LayerEvents.influenceListChanged.emit()
            
            return True
        except:
            import traceback;traceback.print_exc();
            Utils.displayError("unknown error")
            # we're not sure what's wrong in this case, just re-raise
            raise        
Exemplo n.º 11
0
    def openLink(self, link):
        '''
        open given documentation link (should be an instance of DocLink)
        if documentation root is local, checks for link validity
        on success, opens a web browser 
        '''
        if self.documentationRoot is None:
            return

        uri = self.getURL(link)

        # if possible, check for link availability
        if not self.linkExists(uri):
            Utils.displayError('documentation path does not exist: ' + uri)
            return

        if self.isLocal(uri):
            uri = uri.replace("\\", "/")
            if not uri.lower().startswith("file:///"):
                uri = "file:///" + uri

        webbrowser.open_new(uri)
Exemplo n.º 12
0
 def openLink(self,link):
     '''
     open given documentation link (should be an instance of DocLink)
     if documentation root is local, checks for link validity
     on success, opens a web browser 
     '''
     if self.documentationRoot is None:
         return
     
     uri = self.getURL(link)
     
     # if possible, check for link availability
     if not self.linkExists(uri):
         Utils.displayError('documentation path does not exist: '+uri)
         return
     
     if self.isLocal(uri):
         uri = uri.replace("\\", "/");
         if not uri.lower().startswith("file:///"):
             uri = "file:///"+uri
         
     webbrowser.open_new(uri)