Node Editor Custom Node Menus


Disclaimer:
All code here is provided as is without support.
Use at your own risk! These posts assume you have some knowledge of import/running python script in maya. If Gifs/Images are not displaying in Chrome try a different browser.

More recent Part 2

nodeMenu

So stumbled on something interesting tonight. Figured I’d post about it. Create custom marking menus in the Node Editor

Cool! So I tried this out immediately;

from maya.app.general import nodeEditorMenus
from maya import cmds
def addPMAMenuItems(ned, node):
type = cmds.nodeType(node)
if type == 'hermiteArrayCrv':
def addOutputs(*args):
confirm = cmds.confirmDialog(title="Create Jnt Outputs?", message="Ok?")
if confirm:
## Create outputs for the selected hermite nodes
for e in cmds.ls(sl=True):
outCount = cmds.getAttr("{}.outputCount".format(e))
for x in xrange(outCount):
loc = cmds.joint(n='{}_out{}'.format(e, x))
#loc = cmds.spaceLocator(n='{}_out{}'.format(e, x), p=(0,0,0))[0]
cmds.select(clear=True)
cmds.connectAttr("{}.outputs[{}].translate".format(e, x), "{}.translate".format(loc), f=True)
cmds.connectAttr("{}.outputs[{}].rotate".format(e, x), "{}.rotate".format(loc), f=True)
cmds.connectAttr("{}.outputs[{}].scale".format(e, x), "{}.scale".format(loc), f=True)
cmds.menuItem(label="Create Outputs as jnts", radialPosition="N", c = addOutputs)
return True
else:
return False
nodeEditorMenus.customInclusiveNodeItemMenuCallbacks.append(addPMAMenuItems)
## when testing use the following to remove the menus so you don't end up with 100's of them;
# nodeEditorMenus.customInclusiveNodeItemMenuCallbacks.remove(addPMAMenuItems)

Now I wouldn’t approach this like this. I’m going to look at a way to get this cleaned up and see about adding some of these to my node editor, cause it definitely frustrates me having to go for buttons all the time when prototyping rigs.
At some point I’m going to have rounded up a script to cleanup the entire nodeEditor to how I like it, filters, menus etc.

nodeMenuResults