Skip to content

Commit 3a22ae9

Browse files
committed
Added import zip operator
1 parent ada1a62 commit 3a22ae9

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@
5151
BSEQ_OT_enable_all,
5252
BSEQ_OT_refresh_sequences,
5353
BSEQ_OT_set_start_end_frames,
54-
BSEQ_OT_batchSequences,
55-
BSEQ_PT_batchSequences_Settings,
56-
BSEQ_OT_MeshioObject
54+
BSEQ_OT_batch_sequences,
55+
BSEQ_PT_batch_sequences_settings,
56+
BSEQ_OT_meshio_object,
57+
BSEQ_OT_import_zip
5758
]
5859

5960
def register():

bseq/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from bseq.utils import refresh_obj
2-
from .operators import BSEQ_OT_load, BSEQ_OT_edit, BSEQ_OT_resetpt, BSEQ_OT_resetmesh, BSEQ_OT_resetins, BSEQ_OT_set_as_split_norm, BSEQ_OT_remove_split_norm, BSEQ_OT_disable_selected, BSEQ_OT_enable_selected, BSEQ_OT_refresh_seq, BSEQ_OT_disable_all, BSEQ_OT_enable_all, BSEQ_OT_refresh_sequences, BSEQ_OT_set_start_end_frames, BSEQ_OT_batchSequences, BSEQ_PT_batchSequences_Settings, BSEQ_OT_MeshioObject
2+
from .operators import BSEQ_OT_load, BSEQ_OT_edit, BSEQ_OT_resetpt, BSEQ_OT_resetmesh, BSEQ_OT_resetins, BSEQ_OT_set_as_split_norm, BSEQ_OT_remove_split_norm, BSEQ_OT_disable_selected, BSEQ_OT_enable_selected, BSEQ_OT_refresh_seq, BSEQ_OT_disable_all, BSEQ_OT_enable_all, BSEQ_OT_refresh_sequences, BSEQ_OT_set_start_end_frames, BSEQ_OT_batch_sequences, BSEQ_PT_batch_sequences_settings, BSEQ_OT_meshio_object, BSEQ_OT_import_zip
33
from .properties import BSEQ_scene_property, BSEQ_obj_property, BSEQ_mesh_property
44
from .panels import BSEQ_UL_Obj_List, BSEQ_List_Panel, BSEQ_Settings, BSEQ_PT_Import, BSEQ_PT_Import_Child1, BSEQ_PT_Import_Child2, BSEQ_Globals_Panel, BSEQ_Advanced_Panel, BSEQ_Templates, BSEQ_UL_Att_List, draw_template
55
from .messenger import subscribe_to_selected, unsubscribe_to_selected
@@ -52,7 +52,8 @@ def BSEQ_initialize(scene):
5252
"BSEQ_OT_enable_all",
5353
"BSEQ_OT_refresh_sequences",
5454
"BSEQ_OT_set_start_end_frames",
55-
"BSEQ_OT_batchSequences",
56-
"BSEQ_PT_batchSequences_Settings",
57-
"BSEQ_OT_MeshioObject"
55+
"BSEQ_OT_batch_sequences",
56+
"BSEQ_PT_batch_sequences_settings",
57+
"BSEQ_OT_meshio_object",
58+
"BSEQ_OT_import_zip"
5859
]

bseq/operators.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,11 @@ def execute(self, context):
335335

336336
return {"FINISHED"}
337337

338-
339338
from pathlib import Path
340339
import meshio
341340
from bpy_extras.io_utils import ImportHelper
342341

343-
class BSEQ_OT_batchSequences(bpy.types.Operator, ImportHelper):
342+
class BSEQ_OT_batch_sequences(bpy.types.Operator, ImportHelper):
344343
"""Batch Import Sequences"""
345344
bl_idname = "wm.seq_import_batch"
346345
bl_label = "Import Sequences"
@@ -404,7 +403,7 @@ def execute(self, context):
404403
def draw(self, context):
405404
pass
406405

407-
class BSEQ_PT_batchSequences_Settings(bpy.types.Panel):
406+
class BSEQ_PT_batch_sequences_settings(bpy.types.Panel):
408407
bl_space_type = 'FILE_BROWSER'
409408
bl_region_type = 'TOOL_PROPS'
410409
bl_label = "Settings Panel"
@@ -434,7 +433,28 @@ def draw(self, context):
434433
if importer_prop.relative:
435434
layout.prop(importer_prop, "root_path", text="Root Directory")
436435

437-
class BSEQ_OT_MeshioObject(bpy.types.Operator, ImportHelper):
436+
class BSEQ_OT_import_zip(bpy.types.Operator, ImportHelper):
437+
"""Import a zip file"""
438+
bl_idname = "bseq.import_zip"
439+
bl_label = "Import Zip"
440+
bl_options = {'PRESET', 'UNDO'}
441+
442+
filename_ext = ".zip"
443+
filter_glob: bpy.props.StringProperty(
444+
default="*.zip",
445+
options={'HIDDEN', 'LIBRARY_EDITABLE'},
446+
)
447+
448+
files: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
449+
450+
def execute(self, context):
451+
import zipfile
452+
zip_file = zipfile.ZipFile(self.filepath)
453+
zip_file.extractall(Path(self.filepath).parent)
454+
455+
return {'FINISHED'}
456+
457+
class BSEQ_OT_meshio_object(bpy.types.Operator, ImportHelper):
438458
"""Batch Import Meshio Objects"""
439459
bl_idname = "wm.meshio_import_batch"
440460
bl_label = "Import Multiple Meshio Objects"
@@ -452,7 +472,7 @@ def execute(self, context):
452472

453473
def menu_func_import(self, context):
454474
self.layout.operator(
455-
BSEQ_OT_MeshioObject.bl_idname,
475+
BSEQ_OT_meshio_object.bl_idname,
456476
text="MeshIO Object")
457477

458478
# Default Keymap Configuration

bseq/panels.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ def draw(self, context):
249249
box_col3.label(text="Scale:")
250250
box_col3.prop(importer_prop, "custom_scale", text="")
251251

252+
layout.operator("bseq.import_zip", text="Import from zip")
253+
252254
class BSEQ_PT_Import_Child1(BSEQ_Panel, bpy.types.Panel):
253255
bl_parent_id = "BSEQ_PT_panel"
254256
bl_label = "Import from folder"

0 commit comments

Comments
 (0)