How to set the Export Selection attribute via script

Hi guys,

I’m creating a wrapper to pass some configurations to the game exporter when the user presses a button.

I’ve tried with both pymel and mel but I’m not able to get it working.
The issue is that I can’t select Export Selection as a default option.

        mel.eval('tabLayout -e -sti 1 "gameExporterTabLayout";')
        mel.eval('setAttr("gameExporterPreset1.exportSetIndex") 2;')   # <-.this should set the Export selection property but the command is totally ignored.


Do you have any idea about how to fix that?

I just found out that when the popup is open the correct settings are missing, but when I move between tabs they start showing up.

A dirty but working solution is to update first the tab (the preset) that it must not be used, and then coming back to the desired tab:

        mel.eval('tabLayout -e -sti 1 "gameExporterTabLayout";')
        mel.eval('setAttr("gameExporterPreset1.exportSetIndex") 2;')
        mel.eval('setAttr -type "string" gameExporterPreset1.exportFilename "'+raw_name+'" 2;')
        mel.eval('tabLayout -e -sti 2 "gameExporterTabLayout";')
        mel.eval('setAttr("gameExporterPreset2.exportSetIndex") 2;')
        mel.eval('setAttr -type "string" gameExporterPreset2.exportFilename "'+raw_name+'" 2;')

I hope you have any better solution.
thanks in advance.


If you wish to set the “Export Selection” value in the dropdown list:

import maya.mel as mel

mel.eval('tabLayout -e -sti 1 "gameExporterTabLayout";')
mel.eval('optionMenu -e -select 2 model_gameExporterExportSet;')
# ...
# Set the rest of the settings in the exporter interface using the code.
# ...

You do not need to manually set attribute values.
They will be automatically read from the interface and passed on.
Code implementation here:

mel.eval('whatIs gameExp_DoExport;')

But, probably, it is better to load your presets into the exporter.
Or rewrite the exporter without an interface (relying on the “gameFbxExporter.mel” code).

I think you’re right. I’m going to this direction.