Skip to content

Commit 03f8b2f

Browse files
committed
set appropriate scale factor on export
on export set the scale factor in order to go from the current system unit to centimeters
1 parent 5b50bff commit 03f8b2f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Assets/Integrations/Autodesk/max/scripts/UnityFbxForMaxPlugin.ms

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,9 @@ macroScript UnityImport category:"Unity"
3636
-- Get all objects in scene before importAction
3737
origObjects = objects as array
3838
callbacks.addScript #postImport ("afterImport()") id:#unityPlugin
39-
40-
-- set the system units to centimeters
41-
local origUnits = units.SystemType
42-
units.SystemType = #Centimeters
4339

4440
importFile fbxFileName using:FBXIMP
4541

46-
units.SystemType = origUnits
47-
4842
unityFbxFilePathAttr = getFilenamePath fbxFileName
4943
unityFbxFileNameAttr = filenameFromPath fbxFileName
5044

@@ -71,12 +65,25 @@ macroScript UnityImport category:"Unity"
7165
)
7266
macroScript UnityExport category:"Unity"
7367
(
68+
fn unitToScaleFactor unit = (
69+
case unit of (
70+
#Inches: 2.54
71+
#Feet: 30.48
72+
#Miles: 160934
73+
#Millimeters: 0.1
74+
#Kilometers: 100000
75+
#Meters: 100
76+
default: 1
77+
)
78+
);
79+
7480
fn loadUnityFbxExportSettings = (
7581
fbxExportSettings = getINISetting (GetMAXIniFile()) "Unity" "UnityFbxExportSettings"
7682
if fbxExportSettings != undefined and doesFileExist fbxExportSettings then(
7783
filein fbxExportSettings
7884
)
79-
)
85+
FbxExporterSetParam "ScaleFactor" (unitToScaleFactor units.SystemType)
86+
);
8087

8188
-- Make sure the FbxExporter plugin is loaded
8289
pluginManager.loadClass FbxExporter

0 commit comments

Comments
 (0)