From 8cea7c616aa74f2bb23d41ece5e4ef1f59f9e4b4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 3 Jul 2019 20:01:03 +0300 Subject: [PATCH] Add an option to skip existing resources when exporting a scene This can be helpful when exporting multiple scenes, to avoid certain auto-generated resources being exported multiple times. --- blender/io_mspgl/__init__.py | 3 +++ blender/io_mspgl/export_scene.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/blender/io_mspgl/__init__.py b/blender/io_mspgl/__init__.py index 43a3fac8..4c5fa8c2 100644 --- a/blender/io_mspgl/__init__.py +++ b/blender/io_mspgl/__init__.py @@ -134,6 +134,7 @@ class ExportMspGLScene(bpy.types.Operator, ExportMspGLBase): selected_only = bpy.props.BoolProperty(name="Selected objects only", description="Only export the selected objects") active_layers = bpy.props.BoolProperty(name="Active layers only", description="Only export objects on the active layers", default=True) resource_collection = bpy.props.BoolProperty(name="Resource collection", description="Put resources to a single collection file", default=True) + skip_existing = bpy.props.BoolProperty(name="Skip existing files", description="Skip resources that already exist as files", default=True) def create_exporter(self): from .export_scene import SceneExporter @@ -144,6 +145,8 @@ class ExportMspGLScene(bpy.types.Operator, ExportMspGLBase): col.prop(self, "selected_only") col.prop(self, "active_layers") col.prop(self, "resource_collection") + if self.resource_collection: + col.prop(self, "skip_existing") class ExportMspGLCamera(bpy.types.Operator, ExportMspGLBase): bl_idname = "export.mspgl_camera" diff --git a/blender/io_mspgl/export_scene.py b/blender/io_mspgl/export_scene.py index b28c8e04..44c892d8 100644 --- a/blender/io_mspgl/export_scene.py +++ b/blender/io_mspgl/export_scene.py @@ -6,6 +6,7 @@ class SceneExporter: self.selected_only = False self.active_layers = True self.resource_collection = True + self.skip_existing = True self.show_progress = True def export_to_file(self, context, out_fn): @@ -80,6 +81,9 @@ class SceneExporter: ".tex2d": "texture2d" } with open(os.path.join(path, base+"_resources.mdc"), "w") as res_out: for r in refs: + if self.skip_existing and os.path.exists(os.path.join(path, r.name)): + continue + st = Statement(keywords[os.path.splitext(r.name)[1]], r.name) st.sub = r.statements st.write_to_file(res_out) -- 2.45.2