Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to properly set defaults on a scripted FBX export dialog?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
876 Views, 2 Replies

How to properly set defaults on a scripted FBX export dialog?

Hey, I'm trying to set up a python script to automatically detect the type of game asset being created in Maya, and then export that asset to the correct directory, with the correct name.

 

I want to bring up the standard FBX export dialog with a preloaded preset based on the asset type, and the correct output directory selected, and a default file name suggested. 

The artist will then be able to review the export options, naming, and if all is good, just need to click 'Export'.

 

I'm using the following call to bring up the same dialog that the main UI uses:

maya.cmds.ExportSelection()

but I can't find a clean way to pre-set the data that I want in that dialog.

I've found an EXTREMELY hacky way to do it for the Export Preset, but can't seem to figure out how to set up the directory, or the default file name.  Does anyone know anything I can do?

 

I could setup the file defaults in fileDialog2, except that won't have the nice export settings pane.

 

Thanks in advance!

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

I would recommend using a cmds.fileDialog2, as ACOLTEL suggested here:

https://forums.autodesk.com/t5/maya-programming/python-how-to-set-up-a-default-file-name-in-filedial...

multipleFilters = "Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)"
cmds.fileDialog2(fileFilter=multipleFilters, dialogStyle=2, startingDirectory="e:/toto.ma")

You can learn what functions there are here:
https://help.autodesk.com/cloudhelp/2018/CHS/Maya-Tech-Docs/CommandsPython/fileDialog2.html

 

also, please don't abbreviate the variable names. Always use the longer name. You will thank me when you go back to your script a month from now, after forgetting what everything is 😉

Message 3 of 3
Anonymous
in reply to: Anonymous

From additional research, this has been my fallback fallback solution, but maybe it's the best and also the most work.
The whole point of the dialog is to show the default export options for whatever asset type an artist is working on, and let them tweak it if necessary, and then export.

 

I seem to have 3 options, none of them great, and I haven't proved out any as working all the way yet:

 

1. Use cmds.ExportSelection() as mentioned above, but there's no way to easily load the default Export Options, FilePath or FileName.
2. Use cmds.GameExporterWnd(), but there's no easy way to block and wait on the user hitting the "Export" button, and find out whether they cancelled, or accepted the export.
3. Use cmds.filedialog2(), which has the appropriate hooks for setting the data, and trapping the button events, but I'd have to rebuild the FBX Export options UI, and then translate those options and execute the export, all of them manually.

 

I'm currently, still trying to figure out the last details of number 2, before trying number 3.  I wish there were an easier way.  Also, there is no good documentation of how to access the mel functions and data correctly for the gameExporter, so it's been a lot of experimentation.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report