Disconnecting nodes?

I am trying to disconnect a bunch of blend, MultDiv, conditional nodes on a control. What is a simple way to disconnect these nodes? I am trying to get a list of connections and then make a way to disconnectAttr, but I don’t think this is going to work… must be a workable way to do this.

connections = cmds.listConnections(myCtrl,destination=True)
for node in connections:
cmds.disconnectAttr(node, myCtrl)

What you probably want is to use the “plugs” flag on listConnections to get the attribute names, and also the “connections” flag to get both sides of the connection. Then you can iterate over the list in pairs.

connList = cmds.listConnections(myCtrl, destination=True, source=False, connections=True, plugs=True) or []
connIter = iter(connList)
for srcAttr in connIter:
    destAttr = connIter.next()
    cmds.disconnectAttr(srcAttr, destAttr)
connList = cmds.listConnections(myCtrl, destination=False, source=True, connections=True, plugs=True) or []
connIter = iter(connList)
for destAttr in connIter:
    srcAttr = connIter.next()
    cmds.disconnectAttr(srcAttr, destAttr)

(Sorry if the code is a little hacky. I just whipped it up. There may be a better way to do this.)

Can you use PyMel?


# Disconnect inputs and outputs
pm.disconnectAttr(node)

# Only disconnect inputs
pm.disconnectAttr(node, inputs=True)

# Only disconnect outputs
pm.disconnectAttr(node, outputs=True)