Skip to content

Commit 7ba20b2

Browse files
blender extensions review
1 parent 13935a1 commit 7ba20b2

File tree

6 files changed

+110
-93
lines changed

6 files changed

+110
-93
lines changed

blender_manifest.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ website = "https://github.com/InteractiveComputerGraphics/blender-sequence-loade
1515

1616
# # Optional: tag list defined by Blender and server, see:
1717
# # https://docs.blender.org/manual/en/dev/advanced/extensions/tags.html
18-
tags = ["Animation", "Object"]
18+
tags = ["Import-Export"]
1919

2020
blender_version_min = "4.2.0"
2121
# # Optional: Blender version that the extension does not support, earlier versions are supported.
@@ -41,10 +41,9 @@ license = [
4141
# # Optional: bundle 3rd party Python modules.
4242
# # https://docs.blender.org/manual/en/dev/advanced/extensions/python_wheels.html
4343
wheels = [
44-
"./wheels/Fileseq-1.15.2-py3-none-any.whl",
45-
"./wheels/future-0.18.3-py3-none-any.whl",
46-
"./wheels/meshio-5.3.4-py3-none-any.whl",
47-
"./wheels/rich-13.7.0-py3-none-any.whl",
44+
"./wheels/fileseq-2.2.1-py3-none-any.whl",
45+
"./wheels/meshio-5.3.5-py3-none-any.whl",
46+
"./wheels/rich-14.2.0-py3-none-any.whl",
4847
]
4948

5049
# # Optional: add-ons can list which resources they will require:
@@ -77,5 +76,10 @@ paths_exclude_pattern = [
7776
"/docs/",
7877
"/images/",
7978
"build_addon.py",
80-
"download_wheels.sh"
79+
"download_wheels.sh",
80+
".readthedocs.yaml",
81+
".gitignore",
82+
".gitmodules",
83+
"template/dim3.py",
84+
"template/template.py"
8185
]

bseq/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .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, BSEQ_OT_delete_zips, BSEQ_addon_preferences, BSEQ_OT_load_all, BSEQ_OT_load_all_recursive
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_load_all, BSEQ_OT_load_all_recursive #, BSEQ_OT_import_zip, BSEQ_OT_delete_zips, BSEQ_addon_preferences
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
@@ -62,9 +62,9 @@ def BSEQ_initialize(scene):
6262
"BSEQ_OT_batch_sequences",
6363
"BSEQ_PT_batch_sequences_settings",
6464
"BSEQ_OT_meshio_object",
65-
"BSEQ_OT_import_zip",
66-
"BSEQ_OT_delete_zips",
67-
"BSEQ_addon_preferences",
65+
# "BSEQ_OT_import_zip",
66+
# "BSEQ_OT_delete_zips",
67+
# "BSEQ_addon_preferences",
6868
"BSEQ_OT_load_all",
6969
"BSEQ_OT_load_all_recursive"
7070
]

bseq/importer.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,14 @@ def update_obj(scene, depsgraph=None):
308308

309309
if obj.BSEQ.use_advance and obj.BSEQ.script_name:
310310
script = bpy.data.texts[obj.BSEQ.script_name]
311-
try:
312-
exec(script.as_string())
313-
except Exception as e:
314-
show_message_box(traceback.format_exc(), "running script: " + obj.BSEQ.script_name + " failed: " + str(e),
315-
"ERROR")
316-
continue
311+
show_message_box(f"Cannot run custom script {obj.BSEQ.script_name} using extension from Blender extensions. Use a custom build to enable. Removing script file..." + str(e), "INFO")
312+
obj.BSEQ.script_name = ""
313+
# try:
314+
# exec(script.as_string())
315+
# except Exception as e:
316+
# show_message_box(traceback.format_exc(), "running script: " + obj.BSEQ.script_name + " failed: " + str(e),
317+
# "ERROR")
318+
# continue
317319

318320
if 'process' in locals():
319321
user_process = locals()['process']
@@ -337,6 +339,7 @@ def update_obj(scene, depsgraph=None):
337339
continue
338340
finally:
339341
del locals()['preprocess']
342+
340343
else:
341344
if obj.BSEQ.match_frames:
342345
fs_frames = fs.frameSet()

bseq/operators.py

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -440,87 +440,87 @@ def draw(self, context):
440440
# if importer_prop.use_relative:
441441
# layout.prop(importer_prop, "root_path", text="Root Directory")
442442

443-
class BSEQ_addon_preferences(bpy.types.AddonPreferences):
444-
bl_idname = __package__
445-
446-
zips_folder: bpy.props.StringProperty(
447-
name="Zips Folder",
448-
subtype='DIR_PATH',
449-
)
450-
451-
def draw(self, context):
452-
# layout = self.layout
453-
# layout.label(text="Please set a folder to store the extracted zip files")
454-
# layout.prop(self, "zips_folder", text="Zips Folder")
455-
pass
456-
457-
zip_folder_name = '/tmp_zips'
458-
459-
class BSEQ_OT_import_zip(bpy.types.Operator, ImportHelper):
460-
"""Import a zip file"""
461-
bl_idname = "bseq.import_zip"
462-
bl_label = "Import Zip"
463-
bl_options = {'PRESET', 'UNDO'}
464-
465-
filename_ext = ".zip"
466-
filter_glob: bpy.props.StringProperty(
467-
default="*.zip",
468-
options={'HIDDEN', 'LIBRARY_EDITABLE'},
469-
)
470-
471-
files: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
443+
# class BSEQ_addon_preferences(bpy.types.AddonPreferences):
444+
# bl_idname = __package__
445+
446+
# zips_folder: bpy.props.StringProperty(
447+
# name="Zips Folder",
448+
# subtype='DIR_PATH',
449+
# )
450+
451+
# def draw(self, context):
452+
# # layout = self.layout
453+
# # layout.label(text="Please set a folder to store the extracted zip files")
454+
# # layout.prop(self, "zips_folder", text="Zips Folder")
455+
# pass
456+
457+
# zip_folder_name = '/tmp_zips'
458+
459+
# class BSEQ_OT_import_zip(bpy.types.Operator, ImportHelper):
460+
# """Import a zip file"""
461+
# bl_idname = "bseq.import_zip"
462+
# bl_label = "Import Zip"
463+
# bl_options = {'PRESET', 'UNDO'}
464+
465+
# filename_ext = ".zip"
466+
# filter_glob: bpy.props.StringProperty(
467+
# default="*.zip",
468+
# options={'HIDDEN', 'LIBRARY_EDITABLE'},
469+
# )
470+
471+
# files: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
472472

473-
def execute(self, context):
474-
importer_prop = context.scene.BSEQ
475-
476-
import zipfile
477-
zip_file = zipfile.ZipFile(self.filepath)
478-
479-
addon_prefs = context.preferences.addons[addon_name].preferences
480-
# Check if a string is empty:
481-
if not addon_prefs.zips_folder:
482-
show_message_box("Please set a folder to store the extracted zip files", icon="ERROR")
483-
return {"CANCELLED"}
484-
zips_folder = addon_prefs.zips_folder + zip_folder_name
485-
486-
valid_files = [info.filename for info in zip_file.infolist() if not info.filename.startswith('__MACOSX/')]
487-
zip_file.extractall(zips_folder, members=valid_files)
488-
zip_file.close()
489-
490-
folder = str(zips_folder) + '/' + str(Path(self.filepath).name)[:-4]
491-
print(folder)
492-
493-
seqs = fileseq.findSequencesOnDisk(str(folder))
494-
if not seqs:
495-
show_message_box("No sequences found in the zip file", icon="ERROR")
496-
return {"CANCELLED"}
497-
498-
for s in seqs:
499-
# Import it with absolute paths
500-
create_obj(s, False, folder, transform_matrix=get_transform_matrix(importer_prop))
473+
# def execute(self, context):
474+
# importer_prop = context.scene.BSEQ
475+
476+
# import zipfile
477+
# zip_file = zipfile.ZipFile(self.filepath)
478+
479+
# addon_prefs = context.preferences.addons[addon_name].preferences
480+
# # Check if a string is empty:
481+
# if not addon_prefs.zips_folder:
482+
# show_message_box("Please set a folder to store the extracted zip files", icon="ERROR")
483+
# return {"CANCELLED"}
484+
# zips_folder = addon_prefs.zips_folder + zip_folder_name
485+
486+
# valid_files = [info.filename for info in zip_file.infolist() if not info.filename.startswith('__MACOSX/')]
487+
# zip_file.extractall(zips_folder, members=valid_files)
488+
# zip_file.close()
489+
490+
# folder = str(zips_folder) + '/' + str(Path(self.filepath).name)[:-4]
491+
# print(folder)
492+
493+
# seqs = fileseq.findSequencesOnDisk(str(folder))
494+
# if not seqs:
495+
# show_message_box("No sequences found in the zip file", icon="ERROR")
496+
# return {"CANCELLED"}
497+
498+
# for s in seqs:
499+
# # Import it with absolute paths
500+
# create_obj(s, False, folder, transform_matrix=get_transform_matrix(importer_prop))
501501

502-
# created_folder = context.scene.BSEQ.imported_zips.add()
503-
# created_folder.path = folder
502+
# # created_folder = context.scene.BSEQ.imported_zips.add()
503+
# # created_folder.path = folder
504504

505-
return {'FINISHED'}
505+
# return {'FINISHED'}
506506

507-
class BSEQ_OT_delete_zips(bpy.types.Operator):
508-
"""Delete a zip file"""
509-
bl_idname = "bseq.delete_zips"
510-
bl_label = "Delete Zip"
511-
bl_options = {'PRESET', 'UNDO'}
507+
# class BSEQ_OT_delete_zips(bpy.types.Operator):
508+
# """Delete a zip file"""
509+
# bl_idname = "bseq.delete_zips"
510+
# bl_label = "Delete Zip"
511+
# bl_options = {'PRESET', 'UNDO'}
512512

513-
def execute(self, context):
514-
# folders = context.scene.BSEQ.imported_zips
515-
# for folder in folders:
513+
# def execute(self, context):
514+
# # folders = context.scene.BSEQ.imported_zips
515+
# # for folder in folders:
516516

517-
addon_prefs = context.preferences.addons[addon_name].preferences
518-
zips_folder = addon_prefs.zips_folder + zip_folder_name
517+
# addon_prefs = context.preferences.addons[addon_name].preferences
518+
# zips_folder = addon_prefs.zips_folder + zip_folder_name
519519

520-
import shutil
521-
shutil.rmtree(zips_folder)
520+
# import shutil
521+
# shutil.rmtree(zips_folder)
522522

523-
return {'FINISHED'}
523+
# return {'FINISHED'}
524524

525525
class BSEQ_OT_load_all(bpy.types.Operator):
526526
"""Load all sequences from selected folder and its subfolders"""

download_wheels.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pip wheel fileseq==1.15.2 -w ./wheels --no-deps
2-
pip wheel meshio==5.3.4 -w ./wheels --no-deps
3-
pip wheel future==0.18.3 -w ./wheels --no-deps
4-
pip wheel rich==13.7.0 -w ./wheels --no-deps
1+
pip wheel fileseq==2.2.1 -w ./wheels --no-deps
2+
pip wheel meshio==5.3.5 -w ./wheels --no-deps
3+
pip wheel rich==14.2.0 -w ./wheels --no-deps

template/Comparison Render.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""
2+
This template script allows you to render each sequence in a specified collection. It toggles the visibility of each sequence one at a time, disabling all others and rendering them individually.
3+
4+
This is mainly useful for creating comparison renders of different sequences in a scene, such as for different models of a physical simulation that were run outside of Blender.
5+
6+
The path is automatically set to `<original_path>/<sequence_name>/` for each render, where `<original_path>` is the original render output path set in the scene settings, and `<sequence_name>` is the name of the sequence being rendered.
7+
8+
Usage:
9+
1. Set the `comparison_collection` variable to the name of the collection containing the sequences you want to render.
10+
2. Run the script in Blender's scripting environment.
11+
"""
112
import bpy
213

314
# Utilities for comparison rendering

0 commit comments

Comments
 (0)