Python Maya fbx export settings

Hi, I’m have problems using the following code to set my export settings. It appears to export but does not take into account any of the settings I have declared by code below.

import maya.cmds as cmds
import maya.mel as mel

FBX settings

mel.eval(‘FBXResetExport’) # This ensures the user’s settings are ignored.
mel.eval(‘FBXExportConvertUnitString -v cm’)
mel.eval(‘FBXExportFileVersion -v “FBX201800”’)
mel.eval(‘FBXExportSmoothMesh -v true’)
mel.eval(‘FBXExportUseSceneName -v true’)
mel.eval(‘FBXExportUpAxis y’)
mel.eval(‘FBXExportCameras -v false’)
mel.eval(‘FBXExportLights -v false’)

mel.eval(‘FBXExport -f “D:/streams/test2.fbx” -s’)

Any help would be ace! Thanks

Do the same commands work from MEL instead of Python?

Also, does mel.eval('FBXProperties') dump the values correctly?
Also you can just call a lot of these functions from python directly, like the above can just be cmds.FBXProperties()

I have some code in front of me that’s essentially identical to yours which does definitely work (in Maya 2020) - the only difference between them (and I shouldn’t think this is the problem, but it might be worth mentioning) is that rather than ‘true’ or ‘false’ I’m using 1 and 0:

mel.eval('FBXResetExport')
mel.eval('FBXExportBakeComplexAnimation -v 1')
mel.eval('FBXExportInAscii -v 1')
mel.eval('FBXExport -f "{}"'.format(fbxOut))

Thanks for all the replies folks!

@bob.w cmds.FBXProperties() is really handy. Thanks!

I ran a cmds.FBXProperties() and notice one command was not updating regarding the FBXProperties dump values.

This being the command I used:

import maya.cmds as cmds
import maya.mel as mel

mel.eval(‘FBXExportConvertUnitString -v Centimeters’)

FBXProperties dump values below:

PATH: Export|AdvOptGrp|UnitsGrp|UnitsSelector ( TYPE: Enum ) ( VALUE: “Meters” ) (POSSIBLE VALUES: “Millimeters” “Centimeters” “Decimeters” “Meters” “Kilometers” “Inches” “Feet” “Yards” “Miles” )

Unless I’m looking at the wrong output, the Export|AdvOptGrp|UnitsGrp|UnitsSelector value should be Centimeters but is Meters.

The following commands worked:
mel.eval(‘FBXExportFileVersion -v FBX20200’)
mel.eval(‘FBXExportSmoothMesh -v true’)
mel.eval(‘FBXExportUseSceneName -v true’)
mel.eval(‘FBXExportUpAxis y’)
mel.eval(‘FBXExportCameras -v false’)
mel.eval(‘FBXExportLights -v false’)

Still scratching my head to why this unit setting is being stubborn. Any ideas to why would be really great :slight_smile:

Thanks