list all default maya nodes?

list all default maya nodes?

jwlove
Advocate Advocate
2,849 Views
6 Replies
Message 1 of 7

list all default maya nodes?

jwlove
Advocate
Advocate

Is there an easy way to list all the default maya nodes?  By 'default' I mean the nodes that exist in a freshly opened blank scene that are common to all maya scene files.

 

I'm creating a script to go over nodes who's names end with a number to do some renaming/cleanup on them (such as unitConversion nodes, tweak nodes, and any other random math nodes used in the rig).  Rather than specify a node type and iterate over them all, I'm just listing all the nodes in the scene that end with a number and processing over them... but I'd like to skip the default maya nodes - or just remove them from the list altogether...

 

I could create a blank scene and list the nodes to generate a hardcoded list of 'ignore' nodes, but I'd kind of prefer it to be dynamic enough to work in any future versions of maya as well (without having to remember to generate this list with each new maya version if possible).

 

Thanks!

0 Likes
2,850 Views
6 Replies
Replies (6)
Message 2 of 7

jmreinhart
Advisor
Advisor

You could try filtering out the "locked" nodes. That should cover all of the nodes that Maya has in an empty scene (plus any nodes that are required for UI functionality that might get created later).

0 Likes
Message 3 of 7

jwlove
Advocate
Advocate

That sounded like a good idea, but maybe I'm missing something...

 

It doesn't appear that the default nodes in maya are locked...  for example 'time1' is a default maya node, but when I query its locked state with the 'lockNode' command, it shows it to not be locked.

 

Also, 'mc.ls(lockedNodes=True)' comes back with an empty list.

 

Am I doing something wrong?

0 Likes
Message 4 of 7

negow
Advocate
Advocate

As a workaround, you could open a new scene, call `cmds.ls()` and store the result in your script. That way, you get to define what "default" means (e.g. does it include nodes from plug-ins like Arnold?) and can rely on the defaults always being the same.

Message 5 of 7

jwlove
Advocate
Advocate

yeah, I think I'm gonna have to do something like that - I'll have to set it up to run when maya launches and store an os.environ variable, I guess.

 

Thanks!

0 Likes
Message 6 of 7

stuzzz
Collaborator
Collaborator

hi,

 

You may use the MFnDependencyNode::isDefaultNode();

Here's a quick try in python:

 

obj = MObject()
fn = MFnDependencyNode()
for x in cmds.ls("*"):
	sel = MSelectionList()
	sel.add(x)
	sel.getDependNode(0, obj)
	fn.setObject(obj)
	if fn.isDefaultNode():
		print "%s is a default node" % fn.absoluteName()

 

 

Message 7 of 7

jwlove
Advocate
Advocate

Oh man, this is great - it gets most of the nodes, but unfortunately leaves these out:

 

'lightLinker1', 'persp', 'perspShape', 'top', 'topShape', 'front', 'frontShape', 'side', 'sideShape', 'shapeEditorManager', 'poseInterpolatorManager', 'layerManager', 'defaultLayer', 'renderLayerManager', 'defaultRenderLayer'

 

Since my rename script is mostly concerned with node names ending with a number, most of that shouldn't be an issue though.

0 Likes