Hey guys, so I’m working on a simple demo code: nothing special, I’m kindof new to python coding. It’s pretty simple: create 2 nodes and name them anything, run the python script, select your first node and hit “Load A Node” then once you do that: select the second node and hit “Load B Node”
Now where your assistance would be most appreciated, I’m trying figure out how to make “Connect Node” connect the translate attributes of the 2 nodes loaded into the text field, or just any attributes, here is the code if anyone would like to take a crack at it:
import maya.cmds as cmds
if cmds.window(window, exists =True):
cmds.deleteUI(window)
window = cmds.window(title=‘DS selection connector demo’)
column = cmds.columnLayout(adj=True)
sld_textFldA = cmds.textField(‘sld_surfaceText1’, width =240)
load_button = cmds.button( label=‘Load A Node’, c = set_textfield1)
sld_textFldB = cmds.textField(‘sld_surfaceText2’, width =240)
load_button = cmds.button( label=‘Load B Node’, c = set_textfield2)
node_button = cmds.button( label=‘Connect Node’, c = make_node)
def set_textfield1(_):
sel = cmds.ls(selection=True)
cmds.textField(sld_textFldA, edit=True, text=sel[0])
def set_textfield2(_):
sel = cmds.ls(selection=True)
cmds.textField(sld_textFldB, edit=True, text=sel[0])
def connect_node(_):
text_value = cmds.textField(sld_textFldA, q = True, text=True)
text_value = cmds.textField(sld_textFldB, q = True, text=True)
if text_value:
print “connected:”, cmds.connectAttr(c = set_textfield1 + ‘.translate’)
print “connected:”, cmds.connectAttr(c = set_textfield2 + ‘.translate’)
else:
cmds.warning(“select an object and add it to the window first!”)
cmds.showWindow( window )