Python maya.OpenMayaMPx.MFnPlugin() Examples

The following are 30 code examples of maya.OpenMayaMPx.MFnPlugin(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.OpenMayaMPx , or try the search function .
Example #1
Source File: glTFTranslator.py    From maya-glTF with MIT License 8 votes vote down vote up
def initializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject, PLUGIN_COMPANY, '1.0', "Any")
    try:
        mplugin.registerFileTranslator( PLUGIN_NAME, None, translator_creator,
                                        "glTFTranslatorOpts", "resFormat=embedded;anim=keyed;vFlip=1;")
        '''
        status =  plugin.registerFileTranslator( "Lep",
                                        "lepTranslator.rgb",
                                        LepTranslator::creator,
                                        "lepTranslatorOpts",
                                        "showPositions=1",
                                        true );
        '''
    except:
        sys.stderr.write( "Failed to register translator: %s" % PLUGIN_NAME )
        raise

# uninitialize the script plug-in 
Example #2
Source File: cmdx.py    From cmdx with BSD 2-Clause "Simplified" License 7 votes vote down vote up
def uninitializePlugin(plugin):
    om.MFnPlugin(plugin).deregisterCommand(command)


# --------------------------------------------------------
#
# Commonly Node Types
#
# Creating a new node using a pre-defined Type ID is 10% faster
# than doing it using a string, but keeping all (~800) around
# has a negative impact on maintainability and readability of
# the project, so a balance is struck where only the most
# performance sensitive types are included here.
#
# Developers: See cmdt.py for a list of all available types and their IDs
#
# -------------------------------------------------------- 
Example #3
Source File: paintRemoveInfluenceCtxCommands.py    From maya-skinning-tools with GNU General Public License v3.0 6 votes vote down vote up
def initializePlugin( obj ):
    plugin = OpenMayaMPx.MFnPlugin(obj, __author__, __version__, "Any")
        
    # get all commands
    commands = [
        (CONTEXT_INITIALIZE, creatorInitialize, syntaxInitialize),
        (CONTEXT_BEFORE, creatorBefore, syntaxBefore),
        (CONTEXT_AFTER, creatorAfter, syntaxAfter),
    ]
    
    # register all commands
    for command, creator, syntax in commands:
        try:            
            plugin.registerCommand(command, creator, syntax)
        except:         
            raise RuntimeError("Failed to register : {0}".format(command)) 
Example #4
Source File: paintRemoveInfluenceCtxCommands.py    From maya-skinning-tools with GNU General Public License v3.0 6 votes vote down vote up
def uninitializePlugin(obj):
    plugin = OpenMayaMPx.MFnPlugin(obj)
    
    # get all commands
    commands = [
        CONTEXT_INITIALIZE,
        CONTEXT_BEFORE,
        CONTEXT_AFTER
    ]
    
    # unregister all commands
    for command in commands:
        try:            
            plugin.deregisterCommand(command)
        except:         
            raise RuntimeError("Failed to unregister : {0}".format(command)) 
Example #5
Source File: characterRoot.py    From AdvancedPythonForMaya with GNU General Public License v3.0 6 votes vote down vote up
def initializePlugin(plugin):
    # Add the current directory to the script path so it can find the template we wrote
    dirName = 'E:\Projects\AdvancedPythonForMaya\Scene'
    # Maya will look for the environment vairable, MAYA_SCRIPT_PATH to look for scripts
    MAYA_SCRIPT_PATH = os.getenv('MAYA_SCRIPT_PATH')
    if dirName not in MAYA_SCRIPT_PATH:
        # os.pathsep gives us the character that separates paths on your specific operating system
        MAYA_SCRIPT_PATH += (os.pathsep + dirName)
        os.environ['MAYA_SCRIPT_PATH'] = MAYA_SCRIPT_PATH

    pluginFn = ompx.MFnPlugin(plugin)
    try:
        pluginFn.registerTransform(
            CharacterRoot.kNodeName,  # Name of the node
            CharacterRoot.kNodeID,  # ID for the node
            CharacterRoot.creator,  # Creator function
            CharacterRoot.initialize,  # Initialize function
            CharacterRoot.kMatrix,  # Matrix object
            CharacterRoot.kMatrixID  # Matrix ID
        )
    except:
        om.MGlobal.displayError("Failed to register node: %s" % CharacterRoot.kNodeName)
        raise 
Example #6
Source File: instanceAlongCurve.py    From instanceAlongCurve with MIT License 6 votes vote down vote up
def initializePlugin( mobject ):
    mplugin = OpenMayaMPx.MFnPlugin( mobject, "mmerchante", kPluginVersion )
    try:
        if (OpenMaya.MGlobal.mayaState() != OpenMaya.MGlobal.kBatch) and (OpenMaya.MGlobal.mayaState() != OpenMaya.MGlobal.kLibraryApp):
            
            # Register command
            mplugin.registerCommand( kPluginCmdName, instanceAlongCurveCommand.cmdCreator )

            mplugin.addMenuItem("Instance Along Curve", "MayaWindow|mainEditMenu", kPluginCmdName, "")

            # Register AE template
            pm.callbacks(addCallback=loadAETemplateCallback, hook='AETemplateCustomContent', owner=kPluginNodeName)

            # Register IAC manip node
            mplugin.registerNode( kPluginManipNodeName, kPluginNodeManipId, instanceAlongCurveLocatorManip.nodeCreator, instanceAlongCurveLocatorManip.nodeInitializer, OpenMayaMPx.MPxNode.kManipContainer )

        # Register IAC node
        mplugin.registerNode( kPluginNodeName, kPluginNodeId, instanceAlongCurveLocator.nodeCreator,
                              instanceAlongCurveLocator.nodeInitializer, OpenMayaMPx.MPxNode.kLocatorNode, kPluginNodeClassify )

    except:
        sys.stderr.write('Failed to register plugin instanceAlongCurve. stack trace: \n')
        sys.stderr.write(traceback.format_exc())
        raise 
Example #7
Source File: closestPointOnCurve.py    From anima with MIT License 5 votes vote down vote up
def initializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject, "Erkan Ozgur Yilmaz","1.0.2")
    try:
        mplugin.registerNode(
            kPluginNodeTypeName,
            cpocPluginId,
            nodeCreator,
            nodeInitializer
        )
    except:
        sys.stderr.write("Failed to register node: %s" % kPluginNodeTypeName)
        raise

# uninitialize the script plug-in 
Example #8
Source File: loadOsm2maya.py    From osm2maya with GNU General Public License v3.0 5 votes vote down vote up
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterFileTranslator(osm2mayaTranslator.description)
    except:
        sys.stderr.write("Failed to deregister translator: %s" % osm2mayaTranslator.description)
        raise 
Example #9
Source File: closestPointOnCurve.py    From anima with MIT License 5 votes vote down vote up
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterNode(cpocPluginId)
    except:
        sys.stderr.write("Failed to deregister node: %s" % kPluginNodeTypeName)
        raise 
Example #10
Source File: randomizeUVDeformer.py    From anima with MIT License 5 votes vote down vote up
def initializePlugin(obj):
    """
    """
    plugin = OpenMayaMPx.MFnPlugin(obj, "Erkan Ozgur Yilmaz", "0.1.0", "Any")
    try:
        plugin.registerNode(
            node_type_name,
            plugin_id,
            nodeCreator,
            nodeInitializer,
            OpenMayaMPx.MPxNode.kDeformerNode
        )
    except:
        sys.stderr.write('Failed to register node: %s' % node_type_name) 
Example #11
Source File: oyTrajectoryDrawer.py    From anima with MIT License 5 votes vote down vote up
def initializePlugin(mobject):
    ''' initialize the script plug-in
    '''
    mplugin = OpenMayaMPx.MFnPlugin(mobject, "E. Ozgur Yilmaz", __version__ , "Any" )
    try:
        mplugin.registerNode( kPluginNodeTypeName, oyTrajectoryDrawerNodeId, nodeCreator, nodeInitializer, OpenMayaMPx.MPxNode.kLocatorNode )
    except:
        sys.stderr.write( "Failed to register node: %s" % kPluginNodeTypeName )
        raise 
Example #12
Source File: oyTrajectoryDrawer.py    From anima with MIT License 5 votes vote down vote up
def uninitializePlugin(mobject):
    ''' uninitialize the script plug-in
    '''
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterNode( oyTrajectoryDrawerNodeId )
    except:
        sys.stderr.write( "Failed to deregister node: %s" % kPluginNodeTypeName )
        raise 
Example #13
Source File: oyClosestPointOnMesh.py    From anima with MIT License 5 votes vote down vote up
def initializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject, "Ozgur Yilmaz", "1.0.0")
    try:
        mplugin.registerNode(kPluginNodeTypeName, cpomPluginId, nodeCreator,
                             nodeInitializer)
    except:
        sys.stderr.write("Failed to register node: %s" % kPluginNodeTypeName)
        raise


# uninitialize the script plug-in 
Example #14
Source File: oyClosestPointOnMesh.py    From anima with MIT License 5 votes vote down vote up
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterNode(cpomPluginId)
    except:
        sys.stderr.write("Failed to deregister node: %s" % kPluginNodeTypeName)
        raise 
Example #15
Source File: oyBallisticRuler.py    From anima with MIT License 5 votes vote down vote up
def initializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject, "E. Ozgur Yilmaz", __version__ , "Any")
    try:
        mplugin.registerNode( kPluginNodeTypeName, kPluginNodeId, nodeCreator, nodeInitializer )
    except:
        sys.stderr.write( "Failed to register node: %s" % kPluginNodeTypeName )
        raise



# uninitialize the script plug-in 
Example #16
Source File: instanceAlongCurve.py    From instanceAlongCurve with MIT License 5 votes vote down vote up
def uninitializePlugin( mobject ):
    mplugin = OpenMayaMPx.MFnPlugin( mobject )
    try:
        mplugin.deregisterNode( kPluginNodeId )

        if (OpenMaya.MGlobal.mayaState() != OpenMaya.MGlobal.kBatch) and (OpenMaya.MGlobal.mayaState() != OpenMaya.MGlobal.kLibraryApp):
            mplugin.deregisterCommand( kPluginCmdName )
            mplugin.deregisterNode( kPluginNodeManipId )
    except:
        sys.stderr.write( 'Failed to deregister plugin instanceAlongCurve')
        raise

### UTILS 
Example #17
Source File: cmt_py.py    From cmt with MIT License 5 votes vote down vote up
def initializePlugin(obj):
    plugin = OpenMayaMPx.MFnPlugin(obj, 'Chad Vernon', '1.0', 'Any')

    # plugin.registerNode(swingtwist.SwingTwistNode.name, swingtwist.SwingTwistNode.id,
    #                     swingtwist.SwingTwistNode.creator, swingtwist.SwingTwistNode.initialize)
    #
    # plugin.registerCommand(swingtwist.SwingTwistCommand.name, swingtwist.SwingTwistCommand.creator,
    #                        swingtwist.SwingTwistCommand.command_syntax)
    # 
Example #18
Source File: cmt_py.py    From cmt with MIT License 5 votes vote down vote up
def uninitializePlugin(obj):
    plugin = OpenMayaMPx.MFnPlugin(obj)

    # plugin.deregisterCommand(swingtwist.SwingTwistCommand.name)
    # plugin.deregisterNode(swingtwist.SwingTwistNode.id) 
Example #19
Source File: characterRoot.py    From AdvancedPythonForMaya with GNU General Public License v3.0 5 votes vote down vote up
def uninitializePlugin(plugin):
    pluginFn = ompx.MFnPlugin(plugin)

    try:
        pluginFn.deregisterNode(CharacterRoot.kNodeID)
    except:
        om.MGlobal.displayError('Failed to unregister node: %s' % CharacterRoot.kNodeName)
        raise 
Example #20
Source File: pushDeformer.py    From AdvancedPythonForMaya with GNU General Public License v3.0 5 votes vote down vote up
def initializePlugin(plugin):
    pluginFn = ompx.MFnPlugin(plugin)
    try:
        pluginFn.registerNode(
            PushDeformer.name,
            PushDeformer.id,
            PushDeformer.creator,
            PushDeformer.initialize,
            ompx.MPxNode.kDeformerNode # One extra argument to tell it the type of node
                              )
    except:
        om.MGlobal.displayError('Failed to register node: %s' % PushDeformer.name)
        raise 
Example #21
Source File: pushDeformer.py    From AdvancedPythonForMaya with GNU General Public License v3.0 5 votes vote down vote up
def uninitializePlugin(plugin):
    pluginFn = ompx.MFnPlugin(plugin)

    try:
        pluginFn.deregisterNode(PushDeformer.id)
    except:
        om.MGlobal.displayError('Failed to unregister node: %s' % PushDeformer.name)
        raise 
Example #22
Source File: greenCageDeformer.py    From maya_greenCageDeformer with MIT License 5 votes vote down vote up
def initializePlugin(mobj):
    plugin = api1px.MFnPlugin(mobj, __author__, __version__, 'Any')
    _registerNode(plugin, GreenCageDeformer, api1px.MPxNode.kDeformerNode) 
Example #23
Source File: greenCageDeformer.py    From maya_greenCageDeformer with MIT License 5 votes vote down vote up
def uninitializePlugin(mobj):
    plugin = api1px.MFnPlugin(mobj)
    _deregisterNode(plugin, GreenCageDeformer) 
Example #24
Source File: cmdx.py    From cmdx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def uninitialize2(Plugin):
    def uninitializePlugin(obj):
        om.MFnPlugin(obj).deregisterNode(Plugin.typeid)

    return uninitializePlugin


# Plugins written with Maya Python API 1.0 
Example #25
Source File: spore.py    From spore with MIT License 5 votes vote down vote up
def uninitializePlugin(mobject):
    """ uninitialize plugins in reverse order & delete menu """

    sys._global_spore_dispatcher.logger.debug('Unloading Spore plugin')
    mplugin = ompx.MFnPlugin(mobject)

    try:
        mplugin.deregisterCommand(spore_sampler.SporeSampler.name)
    except:
        sys.stderr.write("Failed to deregister command: %s" % spore_sampler.SporeSampler.name)
        raise

    try:
        mplugin.deregisterCommand(spore_command.SporeCommand.name)
    except:
        sys.stderr.write("Failed to deregister command: %s" % spore_command.SporeCommand.name)
        raise

    try: # deregister context and tool command
        mplugin.deregisterContextCommand(spore_context.K_CONTEXT_NAME,
                                         spore_context.K_TOOL_CMD_NAME)
    except:
        sys.stderr.write("Failed to deregister node: %s" % spore_context.K_CONTEXT_NAME)
        raise

    try: # deregister spore node
        mplugin.deregisterNode(spore_node.SporeNode.id)
    except:
        sys.stderr.write("Failed to deregister node: %s" % spore_node.SporeNode.name)
        raise

    sys._global_spore_dispatcher.clean_up()
    del sys._global_spore_dispatcher 
Example #26
Source File: paintSmoothWeightsCtxCommands.py    From maya-skinning-tools with GNU General Public License v3.0 5 votes vote down vote up
def initializePlugin( obj ):
    plugin = OpenMayaMPx.MFnPlugin(obj, __author__, __version__, "Any")
        
    # get all commands
    commands = [
        (CONTEXT_INITIALIZE, creatorInitialize, syntaxInitialize),
        (CONTEXT_UPDATE, creatorUpdate, syntaxUpdate),
    ]
    
    # register all commands
    for command, creator, syntax in commands:
        try:            
            plugin.registerCommand(command, creator, syntax)
        except:         
            raise RuntimeError("Failed to register : {0}".format(command)) 
Example #27
Source File: glTFTranslator.py    From maya-glTF with MIT License 5 votes vote down vote up
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterFileTranslator( PLUGIN_NAME )
    except:
        sys.stderr.write( "Failed to deregister translator: %s" % PLUGIN_NAME )
        raise 
Example #28
Source File: P4Maya.py    From P4VFX with MIT License 5 votes vote down vote up
def initializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        print "Adding Perforce Menu"
        perforce.init()
    except:
        sys.stderr.write( "Failed to register command: %s\n" % kPluginCmdName )
        raise

# Uninitialize the script plug-in 
Example #29
Source File: P4Maya.py    From P4VFX with MIT License 5 votes vote down vote up
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        print "Removing Perforce Menu"
        perforce.close()
    except Exception as e:
        print e
        sys.stderr.write( "Failed to unregister command: %s\n" % kPluginCmdName ) 
Example #30
Source File: cmdx.py    From cmdx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def initializePlugin(plugin):
    om.MFnPlugin(plugin).registerCommand(
        command,
        _apiUndo
    )