Problems with allNodeTypes Command

Oftentimes, when loading your own custom tool set, you may want to confirm the existence of a plug-in on the client machine in order to prevent weird errors. Specifically, if you create a tool that works with a custom node, you may want to verify the node’s existence using the allNodeTypes command. Unfortunately, this command has a really quirky problem when used in Python.

The first thing worth mentioning is that this command is undocumented in all current versions of Maya with Python support (8.5, 2008, 2009, and 2010). Thus, you are using it at your own risk. Nonetheless, because it can be really useful, we should risk it! The command basically returns a list of all specific node types registered in the Maya session. I say “specific” here because it doesn’t return un-creatable parent classes for nodes (e.g. dagObject), but rather only those those which can be created using the createNode command. Consequently, you may want to search this list for your custom node and load its plug-in file if the node is not registered in the current session.

While the command seems to behave as expected in MEL, it does not currently work as expected in Python. Namely, if you first call this command from Python, then the first time it is called it will return None. Thus, to work around this problem, you should either first call the command from MEL, or make the first invocation form Python a dummy, as in this example:

__allNodes__ = cmds.allNodeTypes() # This returns None
__allNodes__ = cmds.allNodeTypes() # This returns the list and can therefore be used throughout your module

2 thoughts on “Problems with allNodeTypes Command”

  1. It looks like some versions of Maya (e.g. pre-2010 on Windows) actually spit out an error with Debug.dll when trying to invoke this command in many cases! No idea if there is a workaround, but I am updating my own tools package to remove this call.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.