Closed anbufx closed 4 years ago
The export paramers are all defined here:
But export materials should be enabed by default... Can you try manually setting exportMaterials = true
in your export parameters?
Looks like the culprit. We change whatever default values of that struct to whatever settings are set in the scene. I'm not sure if this is intended behavior or not... @PatrickRyanMS , do you remember this at all?
https://github.com/BabylonJS/Exporters/commit/15da8e8a5013f30f14e85f79098ce34463a1a84a
Appears to have originally added this functionality. Again I'm not sure if its expected that we initialize the scene to use the scene-saved export parameter values. Most likely this makes it easy to batch hundreds or thousands of scenes to export using their own unique settings. I think we can at the very least add an entrypoint to be able to quickly save a configured ExportParameter to the scene root attributes.
@elpie89, does this sound correct?
Hi, the idea was to avoid to initialize all the parameters from maxscript And I preferred to always use the scene parameters..this way just calling a simple line
...maxscriptmanager.Export()
will run with last saved configuration if someone wants to modify this behavior will just pass parameters eventually in the maxscript itself
here an example of how I normally do this in pymxs
param = BabylonPYMXS.BabylonParameters(lodFilePath, "gltf")
param.exportOnlySelected = True
param.exportMaterials = True
BabylonPYMXS.runBabylonExporter(param)
In the specified case just modifying this line
exportParameters.exportMaterials = Loader.Core.RootNode.GetBoolProperty("babylonjs_export_materials");
into this one
exportParameters.exportMaterials = Loader.Core.RootNode.GetBoolProperty("babylonjs_export_materials",1);
will fix @anbufx problem
I don't really know if we should keep the material exporter by default
@Drigax if you tell me which parameters should be enabled by default I could keep this consistent between maxscript and C#.
Below is the max script, I use for exporting single file, It exports without material, But manually I open babylon from menu and after pressing save button, if i run the script it works by exporting material.
Assembly = dotNetClass "System.Reflection.Assembly"
Assembly.loadfrom "C:\Program Files\Autodesk\3ds Max 2017\bin\assemblies\Max2Babylon.dll" maxScriptManager = dotNetObject "Max2Babylon.MaxScriptManager"
maxScriptManager.Export "D:\test.glb" --true --
Below is the script I use for exporting multiple files, By manually selecting the path for 3ds max files. As I understood Babylon settings are reverted to initial state instead of using the last saved configuration, If it use the last saved configuration, I can save the settings in the start and run the script for multiple files.
thePath = getSavePath() if thePath != undefined do ( theFiles = getFiles (thePath+"\*.max") for f in theFiles do ( loadMaxFile f
actionMan.executeAction 92 "1"
Assembly = dotNetClass "System.Reflection.Assembly"
Assembly.loadfrom "C:\Program Files\Autodesk\3ds Max 2017\bin\assemblies\Max2Babylon.dll" maxScriptManager = dotNetObject "Max2babylon.MaxScriptManager"
maxScriptManager.Export ((getFileNamePath f) + (getFileNameFile f) + ".glb")
saveMaxFile f
) resetMaxFile #noPrompt )
Please let me know, what lines to be included in the above scripts. Thanks
I would do just this
thePath = getSavePath()
if thePath != undefined do
(
theFiles = getFiles (thePath+"\*.max")
for f in theFiles do
(
loadMaxFile f
actionMan.executeAction 92 "1"
Assembly = dotNetClass "System.Reflection.Assembly"
Assembly.loadfrom "C:\Program Files\Autodesk\3ds Max 2017\bin\assemblies\Max2Babylon.dll"
maxScriptManager = dotNetObject "Max2babylon.MaxScriptManager"
param = maxScriptManager.InitParameters (getFileNamePath f) + (getFileNameFile f) + ".glb"
param.exportMaterials = true
--show(param) to get all babylon parameters and configure it as you want
maxScriptManager.Export param true
saveMaxFile f
)
resetMaxFile #noPrompt
)
Yes, it works now. Thanks.
I use a script to export 3ds max files to GLB in 3ds max, it works with out materials, it seems default settings doesn't include materials, but after pressing save button in babylon window it works. What is the script for babylon converter save settings, I can include the save syntax in the script. and execute the script in batch process for multiple file conversion. Any suggestions?