feat(tools):
* auto_export now defaults to being disabled (otherwise you will get export attempts etc even if you only had the add-on installed ! * modified logic accordingly * various related tweaks * adjusted tests
This commit is contained in:
parent
1cf47d36b1
commit
ed09ab7d48
|
@ -22,7 +22,6 @@ def auto_export(changes_per_scene, changed_export_parameters, addon_prefs):
|
|||
# Get the folder
|
||||
folder_path = os.path.dirname(file_path)
|
||||
# get the preferences for our addon
|
||||
|
||||
#should we use change detection or not
|
||||
export_change_detection = getattr(addon_prefs, "export_change_detection")
|
||||
|
||||
|
|
|
@ -179,10 +179,12 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
|
|||
|
||||
changed = auto_settings_changed or gltf_settings_changed
|
||||
# now write the current settings to the "previous settings"
|
||||
if current_auto_settings != None:
|
||||
previous_auto_settings = bpy.data.texts[".gltf_auto_export_settings_previous"] if ".gltf_auto_export_settings_previous" in bpy.data.texts else bpy.data.texts.new(".gltf_auto_export_settings_previous")
|
||||
previous_auto_settings.clear()
|
||||
previous_auto_settings.write(current_auto_settings.as_string()) # TODO : check if this is always valid
|
||||
|
||||
if previous_gltf_settings != 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 bpy.data.texts.new(".gltf_auto_export_gltf_settings_previous")
|
||||
previous_gltf_settings.clear()
|
||||
previous_gltf_settings.write(current_gltf_settings.as_string())
|
||||
|
@ -207,16 +209,16 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
|
|||
return changed and changed_gltf_settings"""
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
# disable change detection while the operator runs
|
||||
bpy.context.window_manager.auto_export_tracker.disable_change_detection()
|
||||
if self.direct_mode:
|
||||
self.load_settings(context)
|
||||
if self.will_save_settings:
|
||||
print("SAVING SETTINGS")
|
||||
self.save_settings(context)
|
||||
|
||||
changes_per_scene = context.window_manager.auto_export_tracker.changed_objects_per_scene
|
||||
|
||||
if self.auto_export: # only do the actual exporting if auto export is actually enabled
|
||||
#& do the export
|
||||
if self.direct_mode: #Do not auto export when applying settings in the menu, do it on save only
|
||||
#determine changed parameters
|
||||
|
@ -224,6 +226,8 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
|
|||
auto_export(changes_per_scene, params_changed, self)
|
||||
# cleanup
|
||||
bpy.app.timers.register(bpy.context.window_manager.auto_export_tracker.enable_change_detection, first_interval=1)
|
||||
else:
|
||||
print("auto export disabled, skipping")
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
|
|
|
@ -64,7 +64,7 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
|||
auto_export: BoolProperty(
|
||||
name='Auto export',
|
||||
description='Automatically export to gltf on save',
|
||||
default=True
|
||||
default=False
|
||||
)
|
||||
export_main_scene_name: StringProperty(
|
||||
name='Main scene',
|
||||
|
|
|
@ -73,6 +73,7 @@ class AutoExportTracker(PropertyGroup):
|
|||
if active_operator.bl_idname == "EXPORT_SCENES_OT_auto_gltf":
|
||||
# we force saving params
|
||||
active_operator.will_save_settings = True
|
||||
active_operator.auto_export = True
|
||||
|
||||
if scene.name != "temp_scene":
|
||||
# print("depsgraph_update_post", scene.name)
|
||||
|
|
|
@ -365,3 +365,38 @@ def invoke_override(self, context, event):
|
|||
|
||||
|
||||
from io_scene_gltf2 import (ExportGLTF2, GLTF_PT_export_main, GLTF_PT_export_include)
|
||||
|
||||
|
||||
from io_scene_gltf2 import (ExportGLTF2, GLTF_PT_export_main,ExportGLTF2_Base, GLTF_PT_export_include)
|
||||
import io_scene_gltf2 as gltf_exporter_original
|
||||
#import io_scene_gltf2.GLTF_PT_export_data_scene as GLTF_PT_export_data_scene_original
|
||||
"""
|
||||
class GLTF_PT_export_data(gltf_exporter_original.GLTF_PT_export_data):
|
||||
bl_space_type = 'FILE_BROWSER'
|
||||
bl_region_type = 'TOOL_PROPS'
|
||||
bl_label = "Data"
|
||||
bl_parent_id = "GLTF_PT_auto_export_gltf"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sfile = context.space_data
|
||||
operator = sfile.active_operator
|
||||
|
||||
return operator.bl_idname == "EXPORT_SCENES_OT_auto_gltf"
|
||||
|
||||
class GLTF_PT_export_data_scene(gltf_exporter_original.GLTF_PT_export_data_scene):
|
||||
bl_space_type = 'FILE_BROWSER'
|
||||
bl_region_type = 'TOOL_PROPS'
|
||||
bl_label = "Scene Graph"
|
||||
bl_parent_id = "GLTF_PT_export_data"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sfile = context.space_data
|
||||
operator = sfile.active_operator
|
||||
return operator.bl_idname == "EXPORT_SCENES_OT_auto_gltf"
|
||||
|
||||
def draw(self, context):
|
||||
return super().draw(context)"""
|
|
@ -85,6 +85,7 @@ def test_export_complex(setup_data):
|
|||
bpy.data.objects["Blueprint1_mesh"].location = [1, 2, 1]
|
||||
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
|
|
|
@ -47,6 +47,7 @@ class GLTF_PT_auto_export_SidePanel(bpy.types.Panel):
|
|||
op.gltf_export_id = "gltf_auto_export" # we specify that we are in a special case
|
||||
|
||||
op = layout.operator("EXPORT_SCENES_OT_auto_gltf", text="Auto Export Settings")
|
||||
op.auto_export = True
|
||||
#print("GLTF_PT_export_main", GLTF_PT_export_main.bl_parent_id)
|
||||
|
||||
# main ui in the file => export
|
||||
|
@ -69,8 +70,6 @@ class GLTF_PT_auto_export_main(bpy.types.Panel):
|
|||
layout.use_property_split = True
|
||||
layout.use_property_decorate = False # No animation.
|
||||
|
||||
sfile = context.space_data
|
||||
|
||||
class GLTF_PT_auto_export_root(bpy.types.Panel):
|
||||
bl_space_type = 'FILE_BROWSER'
|
||||
bl_region_type = 'TOOL_PROPS'
|
||||
|
@ -159,8 +158,8 @@ class GLTF_PT_auto_export_scenes(bpy.types.Panel):
|
|||
col = row.column(align=True)
|
||||
col.separator()
|
||||
|
||||
layout.active = operator.auto_export
|
||||
source = operator
|
||||
|
||||
rows = 2
|
||||
|
||||
# main/level scenes
|
||||
|
@ -241,7 +240,7 @@ class GLTF_PT_auto_export_blueprints(bpy.types.Panel):
|
|||
sfile = context.space_data
|
||||
operator = sfile.active_operator
|
||||
|
||||
layout.active = operator.export_blueprints
|
||||
layout.active = operator.auto_export and operator.export_blueprints
|
||||
|
||||
# collections/blueprints
|
||||
layout.prop(operator, "export_blueprints_path")
|
||||
|
@ -275,51 +274,12 @@ class GLTF_PT_auto_export_collections_list(bpy.types.Panel):
|
|||
|
||||
sfile = context.space_data
|
||||
operator = sfile.active_operator
|
||||
layout.active = operator.auto_export and operator.export_blueprints
|
||||
|
||||
for collection in bpy.context.window_manager.exportedCollections:
|
||||
row = layout.row()
|
||||
row.label(text=collection.name)
|
||||
|
||||
class GLTF_PT_auto_export_gltf(bpy.types.Panel):
|
||||
bl_space_type = 'FILE_BROWSER'
|
||||
bl_region_type = 'TOOL_PROPS'
|
||||
bl_label = "Gltf"
|
||||
bl_parent_id = "GLTF_PT_auto_export_main"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sfile = context.space_data
|
||||
operator = sfile.active_operator
|
||||
|
||||
return operator.bl_idname == "EXPORT_SCENES_OT_auto_gltf" #"EXPORT_SCENE_OT_gltf"
|
||||
|
||||
def draw(self, context):
|
||||
preferences = context.preferences
|
||||
layout = self.layout
|
||||
|
||||
sfile = context.space_data
|
||||
operator = sfile.active_operator
|
||||
addon_prefs = operator
|
||||
|
||||
op = layout.operator("EXPORT_SCENES_OT_wrapper", text='Gltf settings')#'glTF 2.0 (.glb/.gltf)')
|
||||
|
||||
op = layout.operator("EXPORT_SCENE_OT_gltf", text='Gltf settings')#'glTF 2.0 (.glb/.gltf)')
|
||||
#op.export_format = 'GLTF_SEPARATE'
|
||||
op.use_selection=True
|
||||
op.will_save_settings=True
|
||||
op.use_visible=True # Export visible and hidden objects. See Object/Batch Export to skip.
|
||||
op.use_renderable=True
|
||||
op.use_active_collection = True
|
||||
op.use_active_collection_with_nested=True
|
||||
op.use_active_scene = True
|
||||
op.filepath="dummy"
|
||||
#bpy.ops.export_scene.gltf
|
||||
|
||||
"""for key in addon_prefs.__annotations__.keys():
|
||||
if key not in AutoExportGltfPreferenceNames:
|
||||
layout.prop(operator, key)"""
|
||||
|
||||
class SCENE_UL_GLTF_auto_export(bpy.types.UIList):
|
||||
# The draw_item function is called for each item of the collection that is visible in the list.
|
||||
# data is the RNA object containing the collection,
|
||||
|
@ -351,41 +311,3 @@ class SCENE_UL_GLTF_auto_export(bpy.types.UIList):
|
|||
elif self.layout_type == 'GRID':
|
||||
layout.alignment = 'CENTER'
|
||||
layout.label(text="", icon_value=icon)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
from io_scene_gltf2 import (ExportGLTF2, GLTF_PT_export_main,ExportGLTF2_Base, GLTF_PT_export_include)
|
||||
import io_scene_gltf2 as gltf_exporter_original
|
||||
#import io_scene_gltf2.GLTF_PT_export_data_scene as GLTF_PT_export_data_scene_original
|
||||
"""
|
||||
class GLTF_PT_export_data(gltf_exporter_original.GLTF_PT_export_data):
|
||||
bl_space_type = 'FILE_BROWSER'
|
||||
bl_region_type = 'TOOL_PROPS'
|
||||
bl_label = "Data"
|
||||
bl_parent_id = "GLTF_PT_auto_export_gltf"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sfile = context.space_data
|
||||
operator = sfile.active_operator
|
||||
|
||||
return operator.bl_idname == "EXPORT_SCENES_OT_auto_gltf"
|
||||
|
||||
class GLTF_PT_export_data_scene(gltf_exporter_original.GLTF_PT_export_data_scene):
|
||||
bl_space_type = 'FILE_BROWSER'
|
||||
bl_region_type = 'TOOL_PROPS'
|
||||
bl_label = "Scene Graph"
|
||||
bl_parent_id = "GLTF_PT_export_data"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sfile = context.space_data
|
||||
operator = sfile.active_operator
|
||||
return operator.bl_idname == "EXPORT_SCENES_OT_auto_gltf"
|
||||
|
||||
def draw(self, context):
|
||||
return super().draw(context)"""
|
Loading…
Reference in New Issue