Skip to content

Commit

Permalink
Remove export buttons
Browse files Browse the repository at this point in the history
No longer necessary as Blender 4.2 has collection exporters
  • Loading branch information
passivestar committed Jul 9, 2024
1 parent 57b73c0 commit 0fa68a7
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 73 deletions.
64 changes: 0 additions & 64 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,70 +1172,6 @@ def execute(self, context):
bpy.ops.file.unpack_all(method='WRITE_LOCAL')
return {'FINISHED'}

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=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')
selected_object: BoolProperty(name='Selected Object', default=False)

def execute(self, context):
if bpy.data.filepath == '':
self.report({'ERROR'}, 'File is not saved')
return {'FINISHED'}

file = bpy.path.basename(bpy.data.filepath).split('.')[0]
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()

# Unpack all data to files if needed
if self.unpack_data:
bpy.ops.qm.unpack_all_data_to_files()

# Name of the object if exporting selected object
filename = context.object.name if self.selected_object else file

if self.mode == 'glb' or self.mode == 'gltf':
bpy.ops.export_scene.gltf(
export_format='GLB' if self.mode == 'glb' else 'GLTF_SEPARATE',
export_apply=self.apply_modifiers,
export_lights=True,
export_cameras=True,
export_keep_originals=True,
export_extras=True,
export_import_convert_lighting_mode='COMPAT',
export_gn_mesh=True,
use_selection=self.selected_object,
use_active_collection=self.batch_mode == 'COLLECTION',
filepath = os.path.join(file_directory, active_collection_name_clean if self.batch_mode == 'COLLECTION' else filename + '.' + self.mode)
)
elif self.mode == 'fbx':
bpy.ops.export_scene.fbx(
mesh_smooth_type='EDGE',
use_mesh_modifiers=self.apply_modifiers,
add_leaf_bones=False,
apply_scale_options='FBX_SCALE_ALL',
use_batch_own_dir=False,
bake_anim_use_nla_strips=False,
bake_space_transform=self.apply_transform,
batch_mode=self.batch_mode,
use_selection=self.selected_object,
filepath=os.path.join(file_directory, filename + '.fbx') if self.batch_mode == 'OFF' else file_directory
)
else:
self.report({'ERROR'}, 'Unknown export extension')
return {'FINISHED'}

class ViewOperator(bpy.types.Operator):
"""View Selected if in edit mode or anything is selected in object mode. View Camera otherwise"""
bl_idname, bl_label = 'qm.view', 'View'
Expand Down
2 changes: 1 addition & 1 deletion blender_manifest.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
schema_version = "1.0.0"

id = "quickmenu"
version = "3.1.3"
version = "3.1.4"
name = "Quick Menu"
tagline = "Simplifies access to useful operators and adds new functionality"
maintainer = "passivestar"
Expand Down
8 changes: 0 additions & 8 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,6 @@
{ "path": "(D) Tool/(R) Knife", "operator": "qm.tool", "params": { "tool_name": "builtin.knife" } },
{ "path": "(F) Mode", "operator": "view3d.object_mode_pie_or_toggle" },

{ "path": "(Z) Files/(Q) Export GLTF", "operator": "qm.export", "params": { "mode": "gltf", "batch_mode": "OFF" } },
{ "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/[Separator]" },

{ "path": "(Z) Files/(Z) Reimport All Textures", "operator": "qm.reimport_textures" },
Expand Down

0 comments on commit 0fa68a7

Please sign in to comment.