From 28f6bed4c71b54702ed56c35477f715366a53fc3 Mon Sep 17 00:00:00 2001 From: passivestar <60579014+passivestar@users.noreply.github.com> Date: Sun, 5 May 2024 22:26:32 +0400 Subject: [PATCH] Make exporters unpack data by default Also make sure you can't export the root collection to prevent accidentally exporting the entire project --- __init__.py | 8 ++++++-- config.json | 12 +----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/__init__.py b/__init__.py index a77be8d..d464b89 100644 --- a/__init__.py +++ b/__init__.py @@ -6,7 +6,7 @@ bl_info = { 'name': 'QuickMenu', - 'version': (3, 0, 7), + 'version': (3, 0, 8), 'author': 'passivestar', 'blender': (4, 1, 0), 'location': 'Press the hotkey in 3D View', @@ -1186,7 +1186,7 @@ class ExportOperator(bpy.types.Operator): """Export""" bl_idname, bl_label = 'qm.export', 'Export' mode: StringProperty(name='Mode', default='fbx') - unpack_data: BoolProperty(name='Unpack Data', default=False) + unpack_data: BoolProperty(name='Unpack Data', default=True) apply_modifiers: BoolProperty(name='Apply Modifiers', default=True) apply_transform: BoolProperty(name='Apply Transform', default=True) batch_mode: StringProperty(name='Batch Mode', default='OFF') @@ -1201,6 +1201,10 @@ def execute(self, context): file_directory = os.path.dirname(bpy.data.filepath) active_collection_name_clean = re.sub(r'[^a-zA-Z0-9_]', '_', bpy.context.view_layer.active_layer_collection.name) + if self.batch_mode == "COLLECTION" and (self.mode == "gltf" or self.mode == "glb") and active_collection_name_clean == "Scene_Collection": + self.report({'ERROR'}, 'Select a collection') + return {'FINISHED'} + # Save the blend file bpy.ops.wm.save_mainfile() diff --git a/config.json b/config.json index baf1ca2..7c4d0bf 100644 --- a/config.json +++ b/config.json @@ -358,22 +358,12 @@ { "path": "(F) Mode", "operator": "view3d.object_mode_pie_or_toggle" }, { "path": "(Z) Files/(Q) Export GLB", "operator": "qm.export", "params": { "mode": "glb" } }, - { "path": "(Z) Files/(W) Export GLTF Selected Object", "operator": "qm.export", "params": {"mode" : "gltf", "selected_object": true}}, - { "path": "(Z) Files/(E) Export GLTF Active Collection", "operator": "qm.export", "params": { "mode": "gltf", "batch_mode": "COLLECTION" } }, + { "path": "(Z) Files/(W) Export GLTF Active Collection", "operator": "qm.export", "params": { "mode": "gltf", "batch_mode": "COLLECTION" } }, { "path": "(Z) Files/[Separator]" }, { "path": "(Z) Files/(A) Export FBX", "operator": "qm.export", "params": { "mode": "fbx", "batch_mode": "OFF" } }, { "path": "(Z) Files/(S) Export FBX Collections", "operator": "qm.export", "params": { "mode": "fbx", "batch_mode": "COLLECTION" } }, - { - "path": "(Z) Files/(D) Export FBX Collections (Unpack Data and Apply Transform)", "operator": "qm.export", - "params": { - "mode": "fbx", - "batch_mode": "COLLECTION", - "apply_transform": true, - "unpack_data": true - } - }, { "path": "(Z) Files/[Separator]" },