Maya Python textField question

Maya Python textField question

Anonymous
Not applicable
1,755 Views
3 Replies
Message 1 of 4

Maya Python textField question

Anonymous
Not applicable

Oh great Maya forums, I beseech you once more for your assistance

 

Here is my plan. First create a joint and open your node editor. When you got your joint created, name it "A_Joint" hit "load joint" after running the script, then hit "test" upon hitting test, you should get a node created with the name "A_Joint_firstGuy"

the objective of this script is to create a node based on the name of whatever you loaded into the textField. It will take the name of the selected object and add it to the front of the name of the node

 

Atleast thats what should happen, but in truth I lack the knowledge to figure this out and every google search has thus far been fruitless. The script is down below for anyone willing to take a crack at it, thank you for your time and I hope to hear back from you:

 

import maya.cmds as cmds

 

if cmds.window(window, exists =True):

cmds.deleteUI(window)

 

window = cmds.window(title = "DS Selection Loader Demo", widthHeight=(300, 200) )

cmds.columnLayout(adjustableColumn=True)

 

def sld_loadHelperJoint():

sel = cmds.ls(selection=True)

selString = " ".join(sel)

add = cmds.textField('sld_surfaceTextHJ', edit=True, text=selString)

 

#def sld_loadParentJoint():

# sel = cmds.ls(selection=True)

# selString = " ".join(sel)

# add = cmds.textField('sld_surfaceTextPJ', edit=True, text=selString)

 

 

def createNode():

testNode = cmds.createNode( 'transform', name = textField +'_firstGuy' )

 

 

 

cmds.columnLayout(adjustableColumn=True)

sld_textFld = cmds.textField('sld_surfaceTextHJ', width =240)

cmds.button( label='Load Helper Joint', command = "sld_loadHelperJoint()")

cmds.setParent('..')

 

#cmds.columnLayout(adjustableColumn=True)

#name = cmds.textField('sld_surfaceTextPJ', width =240)

#cmds.button( label="Load Parent Joint", command = "sld_loadParentJoint()")

#cmds.setParent('..')

 

cmds.button ( 'Test', command = "createNode()")

 

 

# you must first create "def" group for the attributes you

# want to be created via button, "testNode" is our example

 

# Connect the translation of two nodes together

#cmds.connectAttr( 'firstGuy.t', 'secondGuy.translate' )

 

# Connect the rotation of one node to the override colour

# of a second node.

#cmds.connectAttr( 'firstGuy.rotate', 'secondGuy.overrideColor' )

 

cmds.showWindow (window)

 

 

0 Likes
Accepted solutions (1)
1,756 Views
3 Replies
Replies (3)
Message 2 of 4

rajasekaransurjen
Collaborator
Collaborator
Accepted solution

Hi,

Try This...

import maya.cmds as cmds
if cmds.window(window, exists =True):
    cmds.deleteUI(window)

window = cmds.window(title = "DS Selection Loader Demo", widthHeight=(300, 200) )
cmds.columnLayout(adjustableColumn=True)

def sld_loadHelperJoint(*_):
    rsSel = cmds.ls(selection=True)
    rsJtNm = cmds.textField( rsTxJtNm, query=True, text=True)
    rsHelperJt = cmds.joint( n = rsJtNm, p=(0, 0, 0) )
    rsConstNode = cmds.parentConstraint( rsSel, rsHelperJt, mo=0 )
    cmds.delete(rsConstNode)
def rsCreateNode(*_):
    rsJtNm = cmds.textField( rsTxJtNm, query=True, text=True)
    testNode = cmds.createNode( 'transform', name = (rsJtNm+'_firstGuy') )
    
rsTxJtNm = cmds.textField()
cmds.button( label='Load Helper Joint', command = sld_loadHelperJoint)
cmds.button ( 'Test', command = rsCreateNode)


cmds.showWindow (window)
0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you man, That did it!

0 Likes
Message 4 of 4

rajasekaransurjen
Collaborator
Collaborator

You are welcome.

0 Likes