chore(auto_export): cleanups

This commit is contained in:
kaosat.dev 2024-04-05 23:19:29 +02:00
parent ed09ab7d48
commit e139a1496d
3 changed files with 5 additions and 23 deletions

View File

@ -69,7 +69,7 @@ def generate_gltf_export_preferences(addon_prefs):
if str(key) not in constant_keys: if str(key) not in constant_keys:
gltf_export_preferences[key] = standard_gltf_exporter_settings.get(key) gltf_export_preferences[key] = standard_gltf_exporter_settings.get(key)
print("") print("")
print("final export preferences", gltf_export_preferences) print("export preferences for gltf exporter", gltf_export_preferences)
return gltf_export_preferences return gltf_export_preferences

View File

@ -115,10 +115,10 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
self.will_save_settings = False self.will_save_settings = False
if settings: if settings:
print("loading settings in invoke AutoExportGLTF", settings) #print("loading settings in invoke AutoExportGLTF", settings)
try: try:
for (k, v) in settings.items(): for (k, v) in settings.items():
print("loading setting", k, v) #print("loading setting", k, v)
setattr(self, k, v) setattr(self, k, v)
self.will_save_settings = True self.will_save_settings = True
@ -150,7 +150,6 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
This should ONLY be run when actually doing exports/aka calling auto_export function, because we only care about the difference in settings between EXPORTS This should ONLY be run when actually doing exports/aka calling auto_export function, because we only care about the difference in settings between EXPORTS
""" """
def did_export_settings_change(self): def did_export_settings_change(self):
print("comparing settings")
# compare both the auto export settings & the gltf settings # compare both the auto export settings & the gltf settings
previous_auto_settings = bpy.data.texts[".gltf_auto_export_settings_previous"] if ".gltf_auto_export_settings_previous" in bpy.data.texts else None previous_auto_settings = bpy.data.texts[".gltf_auto_export_settings_previous"] if ".gltf_auto_export_settings_previous" in bpy.data.texts else None
previous_gltf_settings = bpy.data.texts[".gltf_auto_export_gltf_settings_previous"] if ".gltf_auto_export_gltf_settings_previous" in bpy.data.texts else None previous_gltf_settings = bpy.data.texts[".gltf_auto_export_gltf_settings_previous"] if ".gltf_auto_export_gltf_settings_previous" in bpy.data.texts else None
@ -163,7 +162,7 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
# if there were no setting before, it is new, we need export # if there were no setting before, it is new, we need export
changed = False changed = False
if previous_auto_settings == None or previous_gltf_settings == None: if previous_auto_settings == None or previous_gltf_settings == None:
print("previous settings missing, exporting") #print("previous settings missing, exporting")
changed = True changed = True
else: else:
auto_settings_changed = sorted(json.loads(previous_auto_settings.as_string()).items()) != sorted(json.loads(current_auto_settings.as_string()).items()) if current_auto_settings != None else False auto_settings_changed = sorted(json.loads(previous_auto_settings.as_string()).items()) != sorted(json.loads(current_auto_settings.as_string()).items()) if current_auto_settings != None else False
@ -189,25 +188,8 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
previous_gltf_settings.clear() previous_gltf_settings.clear()
previous_gltf_settings.write(current_gltf_settings.as_string()) previous_gltf_settings.write(current_gltf_settings.as_string())
print("changed", changed)
return changed return changed
"""# if there was no setting before, it is new, we need export
print("changed settings IN OPERATOR", changed_gltf_settings, previous_export_settings)
if previous_export_settings == None:
return True # we can disregard the gltf settings, we need to save either way
else:
export_settings = self.format_settings()
if len(export_settings.keys()) == 0: # first time after we already used the addon, since we already have export settings, but they have not yet been applied
return changed_gltf_settings
print("previous", sorted(json.loads(previous_export_settings.as_string()).items()))
print("current", sorted(export_settings.items()))
changed = sorted(json.loads(previous_export_settings.as_string()).items()) != sorted(export_settings.items())
print("changed FINAL: auto_settings", changed, "gltf_settings", changed_gltf_settings, "combo", changed or changed_gltf_settings)
return changed and changed_gltf_settings"""
def execute(self, context): def execute(self, context):
# disable change detection while the operator runs # disable change detection while the operator runs

View File

@ -205,7 +205,7 @@ def clear_hollow_scene(temp_scene, original_root_collection):
temp_root_collection = temp_scene.collection temp_root_collection = temp_scene.collection
temp_scene_objects = [o for o in temp_root_collection.all_objects] temp_scene_objects = [o for o in temp_root_collection.all_objects]
for object in temp_scene_objects: for object in temp_scene_objects:
print("removing", object.name) #print("removing", object.name)
bpy.data.objects.remove(object, do_unlink=True) bpy.data.objects.remove(object, do_unlink=True)
# remove the temporary scene # remove the temporary scene
bpy.data.scenes.remove(temp_scene, do_unlink=True) bpy.data.scenes.remove(temp_scene, do_unlink=True)