Create a shared node using the API

Create a shared node using the API

RFlannery1
Collaborator Collaborator
828 Views
2 Replies
Message 1 of 3

Create a shared node using the API

RFlannery1
Collaborator
Collaborator

The "createNode" command has a flag called "-shared".  The documentation says, "This node is shared across multiple files, so only create it if it does not already exist."  For example, the default cameras are marked as shared nodes.  So when you import another Maya scene into the current scene, it does not create duplicate "persp", "front", etc. cameras.

 

Is it possible to make a shared node using the API?  MFnDependencyNode has a function "isShared" to query whether a node is shared.  But there is no function like "setShared".  And the "create" function of MFnDependency node doesn't take a "shared" parameter.  So far, the only way I have found to do it is:

MGlobal.executePythonCommand("cmds.createNode('network', name='mySharedNode', shared=True, ss=True)");

Am I missing something?  Is there a better way?

Accepted solutions (1)
829 Views
2 Replies
Replies (2)
Message 2 of 3

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

I did some research last Friday and today by looking at how creating nodes is implemented. I didn't find anything better than running this command. Sorry for the bad news.

 

Yours,

Li

0 Likes
Message 3 of 3

RFlannery1
Collaborator
Collaborator

Okay.  Thanks for looking into it.

0 Likes