MAYA: ConnectAttr disconnecting previous connections

def spaceSwitchConstraintOnOFFBuild( orginSource, sourceInputON, sourceInputOFF, controllerAttributeName, constraintController, ParentNodeREV = ''):
    listInputsOnOFF = [sourceInputOFF ,sourceInputON]
    if mc.objExists(orginSource + '_parentConstraint1'):
        mc.delete(orginSource + '_parentConstraint1')    
    mc.parentConstraint( listInputsOnOFF, orginSource, w=1 )  
    if not mc.objExists(ParentNodeREV):
           mc.createNode( 'reverse', n= ParentNodeREV)          
    spaceSwitcherRange( constraintController, controllerAttributeName, ["onOffRange"])
    mc.connectAttr ((constraintController + '.' + controllerAttributeName), (ParentNodeREV + '.inputX'))
    mc.connectAttr ((ParentNodeREV + ".outputX"),  (orginSource + "_parentConstraint1." + sourceInputOFF + "W0"))
    mc.connectAttr ((constraintController + '.' + controllerAttributeName),  (orginSource + "_parentConstraint1." + sourceInputON + "W1"))

so I’m currently working on a faster option to connect constraints to object attributes, but I’ve seemed to have run into an issue.

the problem is that I plan to set multiple objects to one control, however whenever I connect a attribute to its connection it disconnects all other connections to the node, i’m hoping there is a workaround. (thanks in advance!)

spaceSwitchConstraintOnOFFBuild( “joint1_FK_IK”, “joint1_FK”, “joint1_IK”, “IKFKTest”, “CircleControl”, ParentNodeREV = ‘joint1_FK_IKREV’ )

attachest fine in the reverse node

connects from object directly to controller (joint1_FK_IK) <-- CircleControl

spaceSwitchConstraintOnOFFBuild( “joint2_FK_IK”, “joint2_FK”, “joint2_IK”, “IKFKTest”, “CircleControl”, ParentNodeREV = ‘joint1_FK_IKREV’)

attachest fine in the reverse node

connects from object directly to controller (joint2_FK_IK) <-- CircleControl (breakes connection from joint1_FK_IK )

spaceSwitchConstraintOnOFFBuild( “joint3_FK_IK”, “joint3_FK”, “joint3_IK”, “IKFKTest”, “CircleControl”, ParentNodeREV = ‘joint1_FK_IKREV’)

attachest fine in the reverse node

connects from object directly to controller (joint3_FK_IK) <-- CircleControl (breakes connection from joint2_FK_IK)


…del

Did you try to add the flag na=True to connectAttr ?

mc.connectAttr ((constraintController + '.' + controllerAttributeName), (ParentNodeREV + '.inputX'))

On that line, you keep trying to make the same connection since each line of your test has set ParentNodeREV=‘joint1_FK_IKREV’. That line should be throwing an error that it already has a connection. Is there a reason you are trying to use the same reverse node every time?

I’m sure everything would work if you created a new reverse node for each “joint#_FK_IK” instance. So, the second test would use ParentNodeREV=‘joint2_FK_IKREV’ and the third test would use ParentNodeREV=‘joint3_FK_IKREV’.

woops kept rebuilding the controls and it screwed it up the connections . Problem was solved!
tkvtoons, you were also right the connections had issues when the command had duplicate connections commands

Warning: ‘CircleControl.IKFKTest’ is already connected to ‘joint1_FK_IKREV.inputX’.

def spaceSwitchConstraintOnOFFBuild( orginSource, sourceInputON, sourceInputOFF, controllerAttributeName, constraintController, ParentNodeREV = ‘’):
listInputsOnOFF = [sourceInputOFF ,sourceInputON]
if mc.objExists(orginSource + ‘_parentConstraint1’):
mc.delete(orginSource + ‘_parentConstraint1’)
mc.parentConstraint( listInputsOnOFF, orginSource, w=1 )
if not mc.objExists(ParentNodeREV):
mc.createNode( ‘reverse’, n= ParentNodeREV)
if mc.attributeQuery(controllerAttributeName, node= constraintController, exists=True) == False:
spaceSwitcherRange( constraintController, controllerAttributeName, [“onOffRange”])
mc.connectAttr ((constraintController + ‘.’ + controllerAttributeName), (ParentNodeREV + ‘.inputX’))
mc.connectAttr ((ParentNodeREV + “.outputX”), (orginSource + “_parentConstraint1.” + sourceInputOFF + “W0”))
mc.connectAttr ((constraintController + ‘.’ + controllerAttributeName), (orginSource + “_parentConstraint1.” + sourceInputON + “W1”))