Maxscript export only works after doing manual export first

Hi everyone,

I’m having a blast with Babylon, but I ran into a little snag.

I have a standard script for exporting an object with a physical material in 3DSMax into a glb model.

When the script runs, after each texture is says:
“Texture path is missing.”

Then next - without resetting 3DSMax - I use the Babylon Exporter dialog which does the export correctly.

After this manual export, I run the script again and the export works correctly.

So I’m concluding that somehow the manual export ‘fixes’ something which the export script needs to function correctly.

Does anyone have any ideas? This is what the script looks like:

glb_physical_material.base_color_map = bitmaptexture filename:(“C:/temp/diffuse.jpg”)
glb_physical_material.base_color = color 255 255 255

glb_physical_material.bump_map = bitmaptexture filename:(“C:/temp/bump.jpg”)
glb_physical_material.bump_map_amt = 1.0

glb_physical_material.metalness_map = bitmaptexture filename:(“C:/temp/metalness.jpg”)
glb_physical_material.metalness = 1.0

glb_physical_material.roughness_map = bitmaptexture filename:(“C:/temp/roughness.jpg”)
glb_physical_material.roughness = 1.0

$plane.material = glb_physical_material

Assembly = dotNetClass “System.Reflection.Assembly”
Assembly.loadfrom “C:\Program Files\Autodesk\3ds Max 2018\bin\assemblies\Max2Babylon.dll”
maxScriptManager = dotNetObject “Max2Babylon.MaxScriptManager”
max2BabylonSettings = maxScriptManager.InitParameters “C:/temp/export_automated.glb”
max2BabylonSettings.outputFormat = “glb”
max2BabylonSettings.txtQuality = 100
max2BabylonSettings.exportMaterials = true
max2BabylonSettings.exportOnlySelected = true
maxScriptManager.Export max2BabylonSettings true

Thanks!

Pinging @drigax

@FernandoConti Can you share a sample scene? I’m not sure if the exporter is tripping over trying to export textures that don’t exist, or if there’s something extra that the windowed exporter does that isn’t being reproduced via the maxscript manager.

Hi Dirgax, thank you for looking into this!

I’ve attached a zip with a ‘temp’ directory for the C-drive.

It’s just a simple plane and an ‘empty’ physical material.

(Just to be certain, 3DSMax needs a fresh start and the Babylon exporter dialog should not have been used.)

Thanks!

temp.zip (192.1 KB)

Sorry, this is the correct script:

glb_physical_material.base_color_map = bitmaptexture filename:(“C:/temp/diffuse.jpg”)
glb_physical_material.base_color = color 255 255 255

glb_physical_material.bump_map = bitmaptexture filename:(“C:/temp/bump.jpg”)
glb_physical_material.bump_map_amt = 1.0

glb_physical_material.metalness_map = bitmaptexture filename:(“C:/temp/metalness.jpg”)
glb_physical_material.metalness = 1.0

glb_physical_material.roughness_map = bitmaptexture filename:(“C:/temp/roughness.jpg”)
glb_physical_material.roughness = 1.0

$plane.material = glb_physical_material

Assembly = dotNetClass “System.Reflection.Assembly”
Assembly.loadfrom “C:\Program Files\Autodesk\3ds Max 2018\bin\assemblies\Max2Babylon.dll”
maxScriptManager = dotNetObject “Max2Babylon.MaxScriptManager”
max2BabylonSettings = maxScriptManager.InitParameters “C:/temp/export_automated.glb”
max2BabylonSettings.outputFormat = “glb”
max2BabylonSettings.txtQuality = 100
max2BabylonSettings.exportMaterials = true
max2BabylonSettings.exportOnlySelected = true
maxScriptManager.Export max2BabylonSettings true

Thanks, I’ll try to take a look today :slight_smile:

Awesome! :+1: