Skip to content

Commit 0783423

Browse files
4.1 Compatibility (#34)
* fix importer for weird attributes * fix for 4.1 compatibility with normals
1 parent 404fc01 commit 0783423

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
current_folder = os.path.dirname(os.path.abspath(__file__))
1717
if current_folder not in sys.path:
1818
sys.path.append(current_folder)
19+
# add paths of external libraries to sys.path
20+
if os.path.exists(os.path.join(current_folder, "extern")):
21+
external_libs = ["fileseq/src", "meshio/src", "python-future/src", "rich"]
22+
for lib in external_libs:
23+
lib_path = os.path.join(current_folder, "extern", lib)
24+
if lib_path not in sys.path:
25+
sys.path.append(lib_path)
26+
1927

2028
if bpy.context.preferences.filepaths.use_relative_paths == True:
2129
bpy.context.preferences.filepaths.use_relative_paths = False

bseq/importer.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def create_or_retrieve_attribute(mesh, k, v):
104104
if len(v.shape) == 2:
105105
dim = v.shape[1]
106106
if dim > 3:
107-
show_message_box('higher than 3 dimensional attribue, ignored')
107+
# show_message_box('higher than 3 dimensional attribue, ignored')
108108
return None
109109
if dim == 1:
110110
return mesh.attributes.new(k, "FLOAT", "POINT")
@@ -113,7 +113,7 @@ def create_or_retrieve_attribute(mesh, k, v):
113113
if dim == 3:
114114
return mesh.attributes.new(k, "FLOAT_VECTOR", "POINT")
115115
if len(v.shape) > 2:
116-
show_message_box('more than 2 dimensional tensor, ignored')
116+
# show_message_box('more than 2 dimensional tensor, ignored')
117117
return None
118118
else:
119119
return mesh.attributes[k]
@@ -192,6 +192,8 @@ def update_mesh(meshio_mesh, mesh):
192192
for k, v in meshio_mesh.point_data.items():
193193
k = "bseq_" + k
194194
attribute = create_or_retrieve_attribute(mesh, k, v)
195+
if attribute is None:
196+
continue
195197
name_string = None
196198
if attribute.data_type == "FLOAT":
197199
name_string = "value"
@@ -202,7 +204,11 @@ def update_mesh(meshio_mesh, mesh):
202204

203205
# set as split normal per vertex
204206
if mesh.BSEQ.split_norm_att_name and mesh.BSEQ.split_norm_att_name == k:
205-
mesh.use_auto_smooth = True
207+
# If blender version is less than 4.1.0, then dont set auto smooth.
208+
# It has been removed and normals will be used automatically if they are set.
209+
# https://developer.blender.org/docs/release_notes/4.1/python_api/#mesh
210+
if bpy.app.version < (4, 1, 0):
211+
mesh.use_auto_smooth = True
206212
mesh.normals_split_custom_set_from_vertices(v)
207213

208214
for k, v in meshio_mesh.field_data.items():

0 commit comments

Comments
 (0)