示例#1
0
        def addPluginPyNodes(*args):
            try:
                id = _pluginData[pluginName]['callbackId']
                if id is not None:
                    _api.MEventMessage.removeCallback( id )
                    if hasattr(id, 'disown'):
                        id.disown()
            except KeyError:
                _logger.warning("could not find callback id!")

            _pluginData[pluginName]['dependNodes'] = mayaTypes
            _logger.debug("adding new nodes: %s", ', '.join( mayaTypes ))

            for mayaType in mayaTypes:
                _logger.debug("Adding node: %s..." % mayaType)
                inheritance = _factories.getInheritance( mayaType )

                if not util.isIterable(inheritance):
                    _logger.warn( "could not get inheritance for mayaType %s" % mayaType)
                else:
                    #__logger.debug(mayaType, inheritance)
                    #__logger.debug("adding new node:", mayaType, apiEnum, inheritence)
                    # some nodes in the hierarchy for this node might not exist, so we cycle through all
                    parent = 'dependNode'

                    for node in inheritance:
                        nodeName = _factories.addPyNode( nodetypes, node, parent )
                        parent = node
                        if 'pymel.all' in sys.modules:
                            # getattr forces loading of Lazy object
                            setattr( sys.modules['pymel.all'], nodeName, getattr(nodetypes,nodeName) )
                _logger.debug("Done adding node %s" % mayaType)
示例#2
0
        def addPluginPyNodes(*args):
            try:
                id = _pluginData[pluginName]['callbackId']
                if id is not None:
                    _api.MEventMessage.removeCallback( id )
                    if hasattr(id, 'disown'):
                        id.disown()
            except KeyError:
                _logger.warning("could not find callback id!")

            _pluginData[pluginName]['dependNodes'] = mayaTypes
            allTypes = set(cmds.ls(nodeTypes=1))
            for mayaType in mayaTypes:
                # make sure it's a 'valid' type - some plugins list node types
                # that don't show up in ls(nodeTypes=1), and aren't creatable
                # ...perhaps they're abstract types?
                # Unfortunately, can't check this, as only plugin I know of
                # that has such a node - mayalive, mlConstraint - is only
                # available up to 2009, which has a bug with allNodeTypes...
                # Oddly enough, mlConstraint WILL show up in allTypes here,
                # but not after the plugin is loaded / callback finishes...?
                if mayaType not in allTypes:
                    continue
                
                _logger.debug("Adding node: %s" % mayaType)
                try:
                    inheritance = _factories.getInheritance( mayaType )
                except Exception:
                    import traceback
                    _logger.debug(traceback.format_exc())
                    inheritance = None

                if inheritance == 'manip':
                    continue
                elif not inheritance or not util.isIterable(inheritance):
                    _logger.warn( "could not get inheritance for mayaType %s" % mayaType)
                else:
                    #__logger.debug(mayaType, inheritance)
                    #__logger.debug("adding new node:", mayaType, apiEnum, inheritence)
                    # some nodes in the hierarchy for this node might not exist, so we cycle through all
                    parent = 'dependNode'

                    for node in inheritance:
                        nodeName = _factories.addPyNode( nodetypes, node, parent )
                        parent = node