Hello guys,
I have started studying maya python for a week and I am trying to create easy save mesh file ui. but I have a problem with getting text from textField. Here is my code.
#UI Function
def main():
#before adding window
if (cmds.window('EasySave', exists = True)): #delete window if exist
cmds.deleteUI('EasySave', window = True)
cmds.windowPref('EasySave', remove = True) #delete previous setting
#Add window
windowwidth = 400 #width variable
window = cmds.window('EasySave', title ='EasySave', iconName='ES', widthHeight=(windowwidth, 100), sizeable = False) #window variable
cmds.columnLayout( adjustableColumn = True )
#First column ( text)
cmds.text('Put the file path for the selected mesh', align = 'center', font = 'boldLabelFont')
#Second column
tmpRowWidth = [ windowwidth * 0.1 , windowwidth * 0.7 , windowwidth * 0.2 ]
cmds.rowLayout(numberOfColumns = 3, columnWidth3 = tmpRowWidth, adjustableColumn = True)
cmds.text('path') #add text
filepath = cmds.textField('filepath', width = tmpRowWidth[1]) #textfield
cmds.button('browse', label = 'browse', width = tmpRowWidth[2], command = "browseFunction()") #button
cmds.setParent('..')
#Third column
tmpRowWidth = [ windowwidth*0.5 , windowwidth*0.5 ]
cmds.rowLayout(numberOfColumns = 2, columnWidth2 = tmpRowWidth, adjustableColumn = True)
cmds.button('exportFBX', label = 'Export FBX', width = tmpRowWidth[0], align = 'center' , command = 'exportFunction()')
cmds.button('exportOBJ', label = 'Export OBJ', width = tmpRowWidth[1], align = 'center' , command = 'exportFunction()')
cmds.setParent('..')
#Show window
cmds.showWindow(window)
#browse Function
def browseFunction():
chooseFile = cmds.fileDialog2(caption = 'filepath', fileMode = 0) # add filepath info
filepath = cmds.textField('filepath', edit = True , text = chooseFile[0]) #return chooseFile string
#export Function
def exportFunction():
#get FBX export save
print(cmds.textField(filepath, edit = True)) #error
So far I made the code works with getting file browse, but I had a hard time getting info from textField. Is there a way to get textField info from a different function?
