PDA

View Full Version : How do I disconnect two nodes?


phifehinds
06-07-2010, 11:32 PM
How can I disconnect two nodes from each other without having to specify the attribute I want to disconnect?

For example if I have two spheres and they have multiple connections to each other I want to simply disconnect all incoming and outgoing connections between the two spheres.

disconnectAttr doesn't work because it forces me to specify what attribute I want to disconnect...

namelesshero
06-08-2010, 12:28 AM
looking for an answer on this too.

i know the long way of doing this and this is probably the way but if there's a better way of doing things I'm all ears.

open up hyper shade and find the nodes you created(this is where naming nodes once created will come in handy for heavy scenes)graph their respective networks and then delete, then if needed open up connection editor and unlink any italicized.

outoftune
06-08-2010, 07:59 AM
disconnectAttr doesn't work because it forces me to specify what attribute I want to disconnect...

Query whats connected using
listConnections

and then kill all connections with a loop.

theflash
06-08-2010, 08:59 AM
import maya.cmds as mc
def breakNodes(node1, node2):
"""
Two nodes which need to be disconnected
"""
# all connections from node1 to other nodes
cnnList = mc.listConnections(node1,c=1,s=0,p=1)
breakCnnsTo(cnnList,node2)
# all connections from node2 to other nodes
cnnList = mc.listConnections(node2,c=1,s=0,p=1)
breakCnnsTo(cnnList,node1)

def breakCnnsTo(cnnList,destNode):
"""
breaks connections given in cnnList if destination attribute belongs to destNode
"""
#separate connection list into src(odd) dest(even) elements
srcCnns = cnnList[::2]
destCnns = cnnList[1::2]
totalCnn = len(cnnList)/2
# loop in pair of src, dest
for i in range(0,totalCnn):
# check if dest is given node
if destCnns[i].find(destNode) > -1:
mc.disconnectAttr(srcCnns[i], destCnns[i])

def breakSelected():
sel = mc.ls(sl=1)
# first loop to select one
for nod in sel:
# second for doing all combinations possible for pairing
for otherNode in sel:
if nod != otherNode:
breakNodes(nod, otherNode)


Select multiple nodes and this will break all connection within selection.

CGTalk Moderation
06-08-2010, 08:59 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.