Maya’s Node Editor only allows to graph input/output connections for the selected node. If a node has many connections this can get overwhelming fast.
So this little code snippet allows to graph connections for a single attribute only: The attribute that the cursor is currently hovering over.
To keep things simple I only demonstrated outgoing connections and stuck with direct connections (no graph traversal). This can obviously be extended to incoming connections, respect graph traversal depth etc.
""" Adds outgoing connections for a specific attribute (under the cursor) to the Node Editor. 1. Gets the plug that the cursor is hovering over 2. Gets direct output connections (conversion nodes and their outputs if necessary) 3. Adds these nodes to the Node Editor This should obviously only be executed while hovering over the attribute in the Node Editor. To test you could: * assign it to a hotkey * make it a shelf button, execute once and then hit "g" to execute again so it is executed while you hover over attributes in the Node Editor """ from maya import mel from maya import cmds node_editor = mel.eval("getCurrentNodeEditor") item_under_cursor = cmds.nodeEditor(node_editor, feedbackType=True, q=True) if item_under_cursor == "plug": plug_under_cursor = cmds.nodeEditor(node_editor, feedbackPlug=True, q=True) # outgoing connections could obviously be changed to incoming connections, ... all_out_con = cmds.listConnections(plug_under_cursor, s=False, d=True, scn=True) or [] all_out_con.extend( cmds.listConnections(plug_under_cursor, s=False, d=True, scn=False) or []) all_out_con = list(set(all_out_con)) # deduplicate if all_out_con: cmds.nodeEditor(node_editor, addNode=all_out_con, layout=False, e=True) else: cmds.warning("Attribute '{}' has no outgoing connections.".format(plug_under_cursor)) else: cmds.warning("Hover over attribute in Node Editor while executing.")
If you have any questions or comments please do get in touch on Twitter
Comments are closed.