Quantcast
Channel: MEL – Game Development
Viewing all articles
Browse latest Browse all 5

Problems with allNodeTypes Command

$
0
0

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

Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images