Maxscripting the FBX exporter

Maxscripting the FBX exporter

kenc
Advocate Advocate
1,978 Views
6 Replies
Message 1 of 7

Maxscripting the FBX exporter

kenc
Advocate
Advocate

Hi All

 

I am having two issues with maxscripting the FBX exporter

 

Issue 1

When using FBXExporterSetParam "LoadExportPresetFile" "O:\\FBX EXPORT PRESETS\\FBX-2019.fbxexportpreset" and then using FBXExporterSetParam "LoadExportPresetFile" "O:\\FBX EXPORT PRESETS\\FBX-2019-scaled.fbxexportpreset" the FBX parameters do not change using FBXExporterGetParam command.

 

Issue 2

When using FBXExporterSetParam "ScaleFactor" 100.0 the scale of the mesh imported into Unreal is not correct.

 

I would appreciate some help with this.

 

TIA Ken

0 Likes
1,979 Views
6 Replies
Replies (6)
Message 2 of 7

omidt_gh
Enthusiast
Enthusiast

That's a bit funny.

I export the scene with 3dsmax and with the "Import Asset" I get a wrong scaling. The transformation node doesn't seem to be imported, so a Box scaled 100x100x100 gets in with 1x1x1...
But importing with File->Import Into Level gives me a BP_Actor with everything correctly scaled...

Also, remember your modeling environment should be configured to work in centimeters space...
Some default to meters, 3dsmax default is set to Inch.
On FBX exporter settings you should be able to set units to centimeters as well. (That means 1cm to 1meter)

I think your default unit system is not the correct one and that's your issues with scale.

0 Likes
Message 3 of 7

domo.spaji
Advisor
Advisor

How is that wrong scaling - if you change scaling factor from 1 to 100?

Reversing that gives you 1/100?

 

And what this means?


Also, remember your modeling environment should be configured to work in centimeters space...
On FBX exporter settings you should be able to set units to centimeters as well. (That means 1cm to 1meter)


 

0 Likes
Message 4 of 7

kenc
Advocate
Advocate

omidt.gh

 

I'm using 2019 and my system units are meters while I'm exporting an object in centimeters. Scripting the exporter does not expose the automatic checkbox variable, so the scaling is out by a factor of 100. Apparently the the scaling factor setting does not work. The exported units will be automatic because the automatic checkbox cannot be changed.

0 Likes
Message 5 of 7

omidt_gh
Enthusiast
Enthusiast

If you pay attention 3dsmax default unit system is inch that means 2.54 CM and not 1 cm, so scale from 1 to 100 means scaling 2.5 cm to 250 cm and that's different from 1 to 100 cm.

Just give it a try and see what will happen.

0 Likes
Message 6 of 7

kenc
Advocate
Advocate

The default is NOT inches. I have a scene open set at 1 meter and the scene has an object merged into it at 1 centimeter. Somehow I need the automatic conversion turned off so I can set scale to 100.

0 Likes
Message 7 of 7

ads_royje
Alumni
Alumni

Hello @kenc ,

 

sorry you are having such problems with the FBX exporter maxscript setting.
I'll try to explain the FBX setting hoping it can help you find the issue you are facing.

The Automatic Unit conversion is set (automatically) to 'false' when setting conversion units to different type than the Max scene.
this can be verified when looking in the FBX files exported as ASCII

FBXExporterSetParam "ASCII" true


In the FBX file, look for the "GlobalSettings:" near the top of the file.
There are 2 properties related to the Units 
"OriginalUnitScaleFactor" is the Max scene Units
"UnitScaleFactor" is the Exported Units from the Automatic Conversion.

Keep in mind that FBX (MotionBuilder scene file type) is in Centimeters, meaning that 1.0 in FBX is a centimeter.
So if Max is set, for instance in Inches and the Automatic Units is set Automatic (to Inches) then the global settings would read

P: "UnitScaleFactor", "double", "Number", "",2.54
P: "OriginalUnitScaleFactor", "double", "Number", "",2.54

"OriginalUnitScaleFactor", "double", "Number", "",2.54 mean Max is set in Inches, as 2.54 cm per inch
"UnitScaleFactor", "double", "Number", "", 2.54 mean that the Conversion Unit is set to Inches.

If Max scene is set to Meters and exported as Centimeters, it would read:

P: "UnitScaleFactor", "double", "Number", "", 1
P: "OriginalUnitScaleFactor", "double", "Number", "", 100

 
When a conversion is applied (Automatic Conversion is False), a scale is applied to the node also, not the mesh data but the node. This can be found in FBX file in the node's properties, as local scale:

P: "Lcl Scaling", "Lcl Scaling", "", "A",100.00000066,100.00000066,100.00000066

 
Some confusion with the Unit Conversion "Scale Factor" in the UI and the FBX command "ScaleFactor":

FBXExporterGetParam "ScaleFactor"
FBXExporterSetParam "ScaleFactor" 100.0

In the FBX Exporter UI > Units > "Scale Factor" is a display information about the unit conversion from Max to FBX using one of the valid units: "mm" "cm" "dm" "m" "km" "in" "ft" "yr" "mi" set by the FBX commands 

FBXExporterGetParam "ConvertUnit
FBXExporterSetParam "ConvertUnit" "cm"

This setting will affect the FBX  GlobalSettings: "UnitScaleFactor" mentioned above.

The maxscript commands "ScaleFactor" is an additive scaling applied to the Node's local scale
So, setting a "ScaleFactor" in maxscript will apply a Scale on the node: its "Lcl Scaling".

When importing in Unreal, there are options about the Scale import in the FBX import settings. It may be set to import scale as 1.0 and may explain why the "ScaleFactor" you apply may not import as expected.

Other useful commands.
the FBX UI for the export settings can be opened this way for viewing/setting in the UI, this opens Settings and wil not Export.

OpenFbxSetting()

A maxscript access to the FBX settings UI options

-- get FBX UI properties
FBXExporterGetParam "FBXProperties"

-- can get and set UI properties for Dynamic Scale Conversion, the Automatic Conversion
FBXExporterGetParam "Export|AdvOptGrp|UnitsGrp|DynamicScaleConversion"
FBXExporterSetParam "Export|AdvOptGrp|UnitsGrp|DynamicScaleConversion" false


I hope this can help clarify.

0 Likes