3DS MAX script: ExportFile command "ConvertUnit" to "cm" don't work!


#1

Hi,
I’m a beginner but I found a bug, or an error in max script …
I cannot pass the value “ConvertUnit” when I export a FBX, I try everything

I have this nice code below who work well.
I can change the “ASCII” option as well work like a charm,
but not the “ConvertUnit” to “cm” this value stay in “inch” when I export it

I can see the difference when I import in unreal engine, the size is not correct,
but when I export with the prompt (the dialogue box) it work well, because I can set “cm” in advanced/units.

I have a lot of objects to export so this is a good script only this little detail about the unit value don’t work
my scene is in “cm” unreal is in “cm” but the export without prompt make it in “in”, (inch)

There are no reason if I can change “ASCII”,
I should be able to change “ConvertUnit” as well…

what I did wrong ?
what the “ConvertUnit” to “cm” don’t work ?

button Button01 "Export Selected Object as .Fbx"
on Button01 pressed do
(
--array for selected object in max scene
SelectionObjects = selection as array
if SelectionObjects.count != 0 then
	(		
	--loop all the objects	
	for i=1 to SelectionObjects.count do
		(
		--select each objects
		select SelectionObjects[i]

		--convert to poly before export
		macros.run "Modifier Stack" "Convert_to_Poly"

		--set a name variable
		ObjectName = SelectionObjects[i].name

		--setting FBX pour export de l'objet
		thePlugin = pluginManager
		thePlugin.loadClass FBXEXPORTER --loaded in memory and accessible
	        --FBXExporterSetParam "ASCII" True or False.
	        FBXExporterSetParam "ASCII" true
	        --FBXExporterSetParam "ConvertUnit" "mm" or "cm" or "dm" or "m" or "km" or "in" or "ft" or "mi" or "yd".
	        FBXExporterSetParam "ConvertUnit" "cm"

		--export
		exportfile (C:\Test\" + ObjectName  + ".fbx") #noprompt selectedOnly:true using:thePlugin
		--messagebox ( ObjectName + " exported in " + "C:\Test\" ) title: "Exported !" beep: false
		)
	)
else 
	(
	messagebox "Nothing Selected" title: "Selection is Empty"
	)
)

Please help me !
Thank you for you help and time :slight_smile:


#2

I don’t know but how about this…since you know it stupidly converts it to Inches for you, then counter it by:

FBXExporterSetParam “ScaleFactor” 0.3937008

that is 1 cm = 0.3937008 inch