From 537bfed7a8b537bb8a91bdfd4c6582b9baa03112 Mon Sep 17 00:00:00 2001 From: Stefan Jeske Date: Thu, 21 Mar 2024 16:54:12 +0100 Subject: [PATCH 1/2] fix importer for weird attributes --- bseq/importer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bseq/importer.py b/bseq/importer.py index 2ad93ed..390c7d0 100644 --- a/bseq/importer.py +++ b/bseq/importer.py @@ -104,7 +104,7 @@ def create_or_retrieve_attribute(mesh, k, v): if len(v.shape) == 2: dim = v.shape[1] if dim > 3: - show_message_box('higher than 3 dimensional attribue, ignored') + # show_message_box('higher than 3 dimensional attribue, ignored') return None if dim == 1: return mesh.attributes.new(k, "FLOAT", "POINT") @@ -113,7 +113,7 @@ def create_or_retrieve_attribute(mesh, k, v): if dim == 3: return mesh.attributes.new(k, "FLOAT_VECTOR", "POINT") if len(v.shape) > 2: - show_message_box('more than 2 dimensional tensor, ignored') + # show_message_box('more than 2 dimensional tensor, ignored') return None else: return mesh.attributes[k] @@ -192,6 +192,8 @@ def update_mesh(meshio_mesh, mesh): for k, v in meshio_mesh.point_data.items(): k = "bseq_" + k attribute = create_or_retrieve_attribute(mesh, k, v) + if attribute is None: + continue name_string = None if attribute.data_type == "FLOAT": name_string = "value" From 81e918b601d69702925e8bc52526a0835cb6146f Mon Sep 17 00:00:00 2001 From: Stefan Jeske Date: Tue, 2 Apr 2024 18:22:36 +0200 Subject: [PATCH 2/2] fix for 4.1 compatibility with normals --- __init__.py | 8 ++++++++ bseq/importer.py | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index d256d28..c56266d 100644 --- a/__init__.py +++ b/__init__.py @@ -16,6 +16,14 @@ current_folder = os.path.dirname(os.path.abspath(__file__)) if current_folder not in sys.path: sys.path.append(current_folder) +# add paths of external libraries to sys.path +if os.path.exists(os.path.join(current_folder, "extern")): + external_libs = ["fileseq/src", "meshio/src", "python-future/src", "rich"] + for lib in external_libs: + lib_path = os.path.join(current_folder, "extern", lib) + if lib_path not in sys.path: + sys.path.append(lib_path) + if bpy.context.preferences.filepaths.use_relative_paths == True: bpy.context.preferences.filepaths.use_relative_paths = False diff --git a/bseq/importer.py b/bseq/importer.py index 390c7d0..9c67c52 100644 --- a/bseq/importer.py +++ b/bseq/importer.py @@ -204,7 +204,11 @@ def update_mesh(meshio_mesh, mesh): # set as split normal per vertex if mesh.BSEQ.split_norm_att_name and mesh.BSEQ.split_norm_att_name == k: - mesh.use_auto_smooth = True + # If blender version is less than 4.1.0, then dont set auto smooth. + # It has been removed and normals will be used automatically if they are set. + # https://developer.blender.org/docs/release_notes/4.1/python_api/#mesh + if bpy.app.version < (4, 1, 0): + mesh.use_auto_smooth = True mesh.normals_split_custom_set_from_vertices(v) for k, v in meshio_mesh.field_data.items():