Skip to content

Commit d9294c4

Browse files
committed
Import + Delete Zips works now
1 parent 3a22ae9 commit d9294c4

File tree

5 files changed

+50
-7
lines changed

5 files changed

+50
-7
lines changed

__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
BSEQ_OT_batch_sequences,
5555
BSEQ_PT_batch_sequences_settings,
5656
BSEQ_OT_meshio_object,
57-
BSEQ_OT_import_zip
57+
BSEQ_OT_import_zip,
58+
BSEQ_OT_delete_zips
5859
]
5960

6061
def register():
@@ -76,6 +77,7 @@ def register():
7677
def unregister():
7778
for cls in classes:
7879
bpy.utils.unregister_class(cls)
80+
bpy.utils.unregister_class(BSEQ_ImportedZip)
7981
bpy.types.TEXT_MT_templates.remove(draw_template)
8082
del bpy.types.Scene.BSEQ
8183
del bpy.types.Object.BSEQ

bseq/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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_batch_sequences, BSEQ_PT_batch_sequences_settings, BSEQ_OT_meshio_object, BSEQ_OT_import_zip
3-
from .properties import BSEQ_scene_property, BSEQ_obj_property, BSEQ_mesh_property
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, BSEQ_OT_delete_zips
3+
from .properties import BSEQ_scene_property, BSEQ_obj_property, BSEQ_mesh_property, BSEQ_ImportedZip
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
66
import bpy
@@ -55,5 +55,7 @@ def BSEQ_initialize(scene):
5555
"BSEQ_OT_batch_sequences",
5656
"BSEQ_PT_batch_sequences_settings",
5757
"BSEQ_OT_meshio_object",
58-
"BSEQ_OT_import_zip"
58+
"BSEQ_OT_import_zip",
59+
"BSEQ_OT_delete_zips",
60+
"BSEQ_ImportedZip"
5961
]

bseq/operators.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,34 @@ def execute(self, context):
451451
import zipfile
452452
zip_file = zipfile.ZipFile(self.filepath)
453453
zip_file.extractall(Path(self.filepath).parent)
454-
454+
zip_file.close()
455+
456+
folder = str(Path(self.filepath).parent) + '/' + str(Path(self.filepath).name)
457+
folder = folder[:-4]
458+
459+
seqs = fileseq.findSequencesOnDisk(str(folder))
460+
for s in seqs:
461+
create_obj(s, folder, transform_matrix=Matrix.Identity(4))
462+
463+
created_folder = context.scene.BSEQ.imported_zips.add()
464+
created_folder.path = folder
465+
455466
return {'FINISHED'}
456467

468+
class BSEQ_OT_delete_zips(bpy.types.Operator):
469+
"""Delete a zip file"""
470+
bl_idname = "bseq.delete_zips"
471+
bl_label = "Delete Zip"
472+
bl_options = {'PRESET', 'UNDO'}
473+
474+
def execute(self, context):
475+
folders = context.scene.BSEQ.imported_zips
476+
for folder in folders:
477+
import shutil
478+
shutil.rmtree(folder.path)
479+
return {'FINISHED'}
480+
481+
457482
class BSEQ_OT_meshio_object(bpy.types.Operator, ImportHelper):
458483
"""Batch Import Meshio Objects"""
459484
bl_idname = "wm.meshio_import_batch"

bseq/panels.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,13 @@ 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-
252+
split = layout.split(factor=0.5)
253+
col1 = split.column()
254+
col2 = split.column()
255+
256+
col1.operator("bseq.import_zip", text="Import from zip")
257+
col2.operator("bseq.delete_zips", text="Delete created folders")
258+
254259
class BSEQ_PT_Import_Child1(BSEQ_Panel, bpy.types.Panel):
255260
bl_parent_id = "BSEQ_PT_panel"
256261
bl_label = "Import from folder"

bseq/properties.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
from .callback import *
33
from mathutils import Matrix
44

5+
class BSEQ_ImportedZip(bpy.types.PropertyGroup):
6+
path: bpy.props.StringProperty(name="Directory",
7+
subtype="DIR_PATH",
8+
)
9+
10+
bpy.utils.register_class(BSEQ_ImportedZip)
11+
512
class BSEQ_scene_property(bpy.types.PropertyGroup):
613
path: bpy.props.StringProperty(name="Directory",
714
subtype="DIR_PATH",
@@ -112,6 +119,8 @@ class BSEQ_scene_property(bpy.types.PropertyGroup):
112119
description='Filter string for file sequences',
113120
default='',
114121
)
122+
123+
imported_zips: bpy.props.CollectionProperty(type=BSEQ_ImportedZip)
115124

116125
class BSEQ_obj_property(bpy.types.PropertyGroup):
117126
init: bpy.props.BoolProperty(default=False)

0 commit comments

Comments
 (0)