Python API 2.0, custom node gets a warning: # Warning: Unrecognized node type 'NumberToStringNode'; preserving node information during this session. #

Python API 2.0, custom node gets a warning: # Warning: Unrecognized node type 'NumberToStringNode'; preserving node information during this session. #

g2m.agent
Collaborator Collaborator
866 Views
1 Reply
Message 1 of 2

Python API 2.0, custom node gets a warning: # Warning: Unrecognized node type 'NumberToStringNode'; preserving node information during this session. #

g2m.agent
Collaborator
Collaborator

Windows 10, Maya 2020.2

custom node gets a warning when loading:

# Warning: Unrecognized node type 'NumberToStringNode'; preserving node information during this session. #

and my custom node is considered an "unknown" node.

maya_kDum21PQxu.png

I really don't understand why. this is my code:

import maya.api.OpenMaya as om # Maya Python API 2.0

# tell Maya use Python API 2.0
# Both methods have the same result.
# maya_useNewAPI = True #  (Maya 2019+)
def maya_useNewAPI():
    pass

# nodes  # ------------------------------------

# NumberToString
class NumberToStringNode(om.MPxNode):
    TYPE_NAME = "NumberToString"
    TYPE_ID = om.MTypeId(0x0007F7F8)

    def __init__(self):
        super(NumberToStringNode, self).__init__()

    @classmethod
    def creator(cls):
        return NumberToStringNode()

    @classmethod
    def initialize(cls):
        pass

# plugin ------------------------------------------------

# Initialize the plug-in #
def initializePlugin(plugin):
    vendor = "myName"
    version = "0.0.1"

    plugin_fn = om.MFnPlugin(plugin, vendor, version)

    # register nodes 
    try:
        plugin_fn.registerNode(
            NumberToStringNode.TYPE_NAME,
            NumberToStringNode.TYPE_ID, 
            NumberToStringNode.creator, 
            NumberToStringNode.initialize, 
            om.MPxNode.kDependNode)
    except:
        om.MGlobal.displayError("Failed to register node: {0}".format(NumberToStringNode.TYPE_NAME))

    print("hello maya")

# Uninitialize the plug-in #
def uninitializePlugin(plugin):
    plugin_fn = om.MFnPlugin(plugin)

    # deregister nodes
    try:
        plugin_fn.deregisterNode(NumberToStringNode.TYPE_ID)
    except:
        om.MGlobal.displayError("Failed to deregister node: {0}".format(NumberToStringNode.TYPE_NAME))
Accepted solutions (1)
867 Views
1 Reply
Reply (1)
Message 2 of 2

tdHendrix
Collaborator
Collaborator
Accepted solution

Tried it in Maya 2020.3 and it works for me. I used this command to create the node:

 

createNode NumberToString;


Greg Hendrix - Senior Technical Animator
LinkedIn : Twitter