Cmds.fileDialog2 to cmds.textfield question



I’m making a Maya to Unreal object converter as part of a school assignment and i’m having trouble figuring out how i can have the File path I’ve Selected from the fileDialog2 option to appear in the textField string i have set up. Can anyone point me in the right direction?

Thank you!

Edit: Forgot to mention i’m using the Python language.


This should do what you’re looking for. This launches a window with a button and a textField. The button calls a function which brings up the file dialog. Whatever path you select is stored in a variable. Maya likes to return things as lists, so make sure to grab index 0. Finally, the function edits the textField with the path name.

from maya import cmds

def get_file(*args):
    cmds.textField(file_field, e=1, text=path_name)

if cmds.window('testFileUI', exists=1):
cmds.window('testFileUI', width=300, height=100)
cmds.button (c=get_file)
file_field = cmds.textField(text='')


Awesome i’ll give this a whirl when i get a chance to. Thank you so much!