How set Draco parameters with Maxscript?

Hi everyone,

I’m trying to set the Draco compression settings in a Maxscript export:

	max2BabylonSettings.exportOnlySelected = true
	max2BabylonSettings.dracoCompression = true
	max2BabylonSettings.dracoParams = ... ?

Looking at “Exporters/3ds Max/Max2Babylon/Forms/ExporterForm.cs” on Github I see all the elements in C#:

                exportParameters.dracoParams = new DracoParameters()
                    compressionLevel = (int)dracoUserControl.CompressionLevelNumericUpDown.Value,
                    quantizePositionBits = dracoUserControl.QPositionTrackBar.Value,
                    quantizeNormalBits = dracoUserControl.QNormalTrackBar.Value,
                    quantizeTexcoordBits = dracoUserControl.QTexcoordTrackBar.Value,
                    quantizeColorBits = dracoUserControl.QColorTrackBar.Value,
                    quantizeGenericBits = dracoUserControl.QGenericTrackBar.Value,
                    unifiedQuantization = dracoUserControl.UnifiedCheckBox.Checked

…but I don’t know how to format them in Maxscript as part of “.dracoParams : <BabylonExport.Entities.DracoParameters>”

Could anyone show example maxscript code for this? Thank you so much in advance!

I’m also noticing that when I do a manual glb export through the 3dsmax plugin interface compared to a Maxscript export, that the Maxscript glb export looks pretty bad. It’s like the default Draco parameters aren’t picked up and everything is dialed down to the worst quality.

Could someone please help? :blush: :pray: It’s holding up our pipeline unfortunately, thanks! :pray:

Unfortunately I don’t think there are many people who work with Maxscript here but @PatrickRyan may be able to point you somewhere?

1 Like

Thank you! I hope he can help :blush:

@FernandoConti, I don’t do a lot with Maxscript, but if you have a sample file with your current Maxscript in it or simply the Maxscript I can build from, I can take a look and see what I can uncover. Starting with your script will save a lot of time.

In the meantime, this might point you in a direction. When exporting with our exporter, there is a console that details what is happening. The line in the console under Draco Compression lists this:


Which maps nicely to the advanced tab:

This may give you an inkling of the formatting and naming for the dracoParams.

Thank you Patrick, but I still don’t know how to format it, I’ve tried numerous array and string formatting combinations.

Every time Maxscript says that it’s “unable to convert to BabylonExport.Entities.DracoParameters” using the "max2BabylonSettings.dracoParams = " setting as part of the InitParameters of the Max2Babylon.MaxsScriptManager.

Where can I find info on what Max2Babylon.dll expects as format?

This is the code so far:

Assembly = dotNetClass System.Reflection.Assembly
Assembly.loadfrom C:\Program Files\Autodesk\3ds Max 2019\bin\assemblies\Max2Babylon.dll
maxScriptManager = dotNetObject Max2Babylon.MaxScriptManager
max2BabylonSettings = maxScriptManager.InitParameters (“…”)
max2BabylonSettings.textureFolder = (“…”)
max2BabylonSettings.outputFormat = “gltf”
max2BabylonSettings.mergeAOwithMR = true
max2BabylonSettings.txtQuality = 95
max2BabylonSettings.exportMaterials = true
max2BabylonSettings.exportTextures = true
max2BabylonSettings.writeTextures = true
max2BabylonSettings.dracoCompression = true
max2BabylonSettings.dracoParams = …?

I will take a look at it and see what I can uncover. Thanks for the script!

1 Like

Wonderful, thank you Patrick!

Hi @PatrickRyan, it’s been a while but I was still wondering if you might know how to set those Draco parameters :innocent:

I worked on this for quite a while, but the issue I keep running into is that scripting a plugin isn’t the most straight forward. It’s still on my backlog, but I had to shift focus to some other projects. I think we are missing hooks in the exporter to enable scripting, which is an entirely different problem. There are also some other things that are percolating in other areas that may change the question but nothing I can talk about at this point.

1 Like

Okay thank you Patrick!

1 Like

Hey. Just saw this. Here’s how you can do this. Following is a sample snippet that exports the first node in the hierarchy ( of the max scene ). See the part where I set draco params.

fName = rootNode.children[1].name;
oPath = @"C:\Users\Mukarram\Downloads\" + fName + ".glb";

Assembly = dotNetClass "System.Reflection.Assembly";
Assembly.loadfrom "C:\Program Files\Autodesk\3ds Max 2022\bin\assemblies\Max2Babylon.dll";
maxScriptManager = dotNetObject "Max2Babylon.MaxScriptManager";
params = maxScriptManager.InitParameters oPath;
params.exportMaterials = true;
params.exportTextures = true;
params.mergeAO = true;
params.exportOnlySelected = false;
params.enableKHRTextureTransform = khrTexTransformChkBox.checked;

params.dracoCompression = true;
dracoParams = dotNetObject "BabylonExport.Entities.DracoParameters";
dracoParams.compressionLevel = 7;
params.dracoParams = dracoParams;

params.autoSaveSceneFile = false;
params.createDefaultSkybox = false;
params.outputFormat = "glb";
params.writeTextures = true;
params.outputPath = oPath;
maxScriptManager.Export params true;

I hope it helps


Hi Mukarram, thank you so much! Sorry for the late reply, I seem to have my email alerts disabled.

I’m going to check it out, awesome! :blush: :+1: :pray: