I'm having trouble understanding how to use fileDialog2's "optionsUICommit" flag. When the user hit's "save" in the file dialog box, I want to run the command
MEL only. The string is interpreted as a MEL callback, to be called
when the dialog is successfully dismissed. It will not be called if
the user cancels the dialog, or closes the window using window title
bar controls or other window system means. The callback is of the
form: global proc MyCustomOptionsUICommit(string $parent)
The parent argument is the parent layout into which controls have been
added using the optionsUICreate flag
import pymel.core as pm
print "Hello from file_dialog_save_file()!"
myDialog = pm.fileDialog2(ocm="on_save_dialog_file", fm=0, ff="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)", dialogStyle=2)
You can just do it like this, without the callback. Anything other than a user selection will return
c = cmds.fileDialog2(fm=0, ff="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)", dialogStyle=2) if c: print c else: print "user cancelled"