From 37dd6a990c21c3d2e946c321d52fb2c367331720 Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Fri, 22 Mar 2024 23:35:10 +0100 Subject: [PATCH] feat(auto_export): experimenting with ways of getting standard gltf export settings & using them --- .../auto_export/export_gltf.py | 25 ++++++++++++++++++- .../get_standard_exporter_settings.py | 7 ++++-- .../helpers/helpers_scenes.py | 3 --- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/tools/gltf_auto_export/auto_export/export_gltf.py b/tools/gltf_auto_export/auto_export/export_gltf.py index 11fb4da..2c08dfc 100644 --- a/tools/gltf_auto_export/auto_export/export_gltf.py +++ b/tools/gltf_auto_export/auto_export/export_gltf.py @@ -1,5 +1,7 @@ import os import bpy + +from .get_standard_exporter_settings import get_standard_exporter_settings from .preferences import (AutoExportGltfPreferenceNames) def generate_gltf_export_preferences(addon_prefs): @@ -37,10 +39,31 @@ def generate_gltf_export_preferences(addon_prefs): export_optimize_animation_size=False ) + + + for key in addon_prefs.__annotations__.keys(): if str(key) not in AutoExportGltfPreferenceNames: #print("overriding setting", key, "value", getattr(addon_prefs,key)) - gltf_export_preferences[key] = getattr(addon_prefs,key) + gltf_export_preferences[key] = getattr(addon_prefs, key) + + + """standard_gltf_exporter_settings = get_standard_exporter_settings() + print("standard settings", standard_gltf_exporter_settings) + + constant_keys = [ + 'export_cameras', + 'export_extras', # For custom exported properties. + 'export_lights', + ] + + # a certain number of essential params should NEVER be overwritten , no matter the settings of the standard exporter + for key in standard_gltf_exporter_settings.keys(): + if str(key) not in constant_keys: + gltf_export_preferences[key] = standard_gltf_exporter_settings.get(key) + + print("final export preferences", gltf_export_preferences)""" + return gltf_export_preferences diff --git a/tools/gltf_auto_export/auto_export/get_standard_exporter_settings.py b/tools/gltf_auto_export/auto_export/get_standard_exporter_settings.py index 8756e7d..4af09ef 100644 --- a/tools/gltf_auto_export/auto_export/get_standard_exporter_settings.py +++ b/tools/gltf_auto_export/auto_export/get_standard_exporter_settings.py @@ -1,6 +1,9 @@ import bpy def get_standard_exporter_settings(): + settings_key = 'glTF2ExportSettings' for scene in bpy.data.scenes: - if 'glTF2ExportSettings' in scene: - print("standard exporter settings", scene['glTF2ExportSettings']) \ No newline at end of file + if settings_key in scene: + settings = scene[settings_key] + #print("standard exporter settings", settings, dict(settings)) + return dict(settings) \ No newline at end of file diff --git a/tools/gltf_auto_export/helpers/helpers_scenes.py b/tools/gltf_auto_export/helpers/helpers_scenes.py index 039a41f..57e2654 100644 --- a/tools/gltf_auto_export/helpers/helpers_scenes.py +++ b/tools/gltf_auto_export/helpers/helpers_scenes.py @@ -208,9 +208,6 @@ def get_scenes(addon_prefs): return [level_scene_names, level_scenes, library_scene_names, library_scenes] - - - def inject_blueprints_list_into_main_scene(scene): print("injecting assets/blueprints data into scene") root_collection = scene.collection