View Full Version : [PYTHON] :problem connecting attributes

02-22-2011, 01:50 PM
so hi everyone , switching from mel to python it s such a pain ! but i think is worth it
alright that s my problem i wanna connect two attributes , the code works doesnt give any error
but it just doesnt make the connection :/

mc.connectAttr = ( "%s.translate.translateX" %( firstTextName), "%s.color1.color1R" % (blendColorTranslate) )

so i tried differen syntax and nothing happen code runs , no errors but nothing happen . that piss me off :shrug:

does anyone know what is going on? also if i add the f=True the scirpt wont work and i wasnt able to understand why

02-22-2011, 02:14 PM
You are assigning a set to the mc.connectAttr command, not very efficient for making connections:

Maybe this could work:
mc.connectAttr( "%s.translateX" %( firstTextName), "%s.color1R" % (blendColorTranslate) )

02-22-2011, 05:30 PM
actually i dont know why i put the "=" it s not a variable XD

anyway i cant make it working i tried your line of code and it s not working , i tried with real names too

mc.connectAttr ( 'test1_chain1.translateX' ,'test1_base_Tbln.color1.color1R' )

and i take back ur same line error this

# Error: 'tuple' object is not callable # Traceback (most recent call last): # File "<maya console>", line 1, in <module> # TypeError: 'tuple' object is not callable #

:eek: :eek:
any idea?

02-22-2011, 06:21 PM
I suppose its because your variables have the wrong format. Works fine if I do this:

import maya.cmds as cmds
obj = "nurbsSphere1"
shader = "lambert2"
cmds.connectAttr("%s.translateX" % (obj), "%s.colorR" % (shader))

02-22-2011, 07:35 PM
well i tried with the real name they have too , not the variables . and it s exactly the code i posted above . this one

mc.connectAttr ( 'test1_chain1.translateX' ,'test1_base_Tbln.color1.color1R' )

test1_chain1 and test1_base_Tbln.color1 are the true names of the objects not stored in variables and i get same error :/

02-22-2011, 09:18 PM
error " 'tuple' object is not callable" comes from a "mc.connectAttr = ( ", where that assignment replaced connectAttr procedure with a tuple object. just restart maya and your last code examples will be fine.

02-22-2011, 09:32 PM
The attribute is called color1R, not color1.color1R:

mc.connectAttr ( 'test1_chain1.translateX' ,'test1_base_Tbln.color1R' )

02-23-2011, 04:06 AM
The attribute is called color1R, not color1.color1R:

mc.connectAttr ( 'test1_chain1.translateX' ,'test1_base_Tbln.color1R' )

well that is what i wrote in first place after i made the connection manually and the mel command were saying color1.color1R now i m gonna restart maya and trying with both the syntax. thank you guys i will let you know

02-23-2011, 04:29 AM
alright it s working . both 3 syntax


mc.connectAttr ( 'test1_chain1.translate.translateX' ,'test1_base_Tbln.color1.color1R' )

mc.connectAttr ( 'test1_chain1.translateX' ,'test1_base_Tbln.color1R' )

mc.connectAttr ( "%s.translateX" %( firstTextName), "%s.color1R" % (blendColorTranslate) )

thank u to both of you guys

CGTalk Moderation
02-23-2011, 04:29 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.