mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-08 05:16:25 +00:00
fix issue getting styles if object had empty mat slots
Occurred only with only_assigned_to_faces = True A bit related to #4675 Error was styles = [style for style, usage in zip(styles, usage_count, strict=True) if usage > 0] ValueError: zip() argument 2 is longer than argument 1
This commit is contained in:
@@ -470,8 +470,15 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
usage_count = [0] * len(obj.material_slots)
|
usage_count = [0] * len(obj.material_slots)
|
||||||
if not usage_count: # if there are no materials, polygons will still use index 0
|
if not usage_count: # if there are no materials, polygons will still use index 0
|
||||||
return []
|
return []
|
||||||
|
|
||||||
for poly in obj.data.polygons:
|
for poly in obj.data.polygons:
|
||||||
usage_count[poly.material_index] += 1
|
usage_count[poly.material_index] += 1
|
||||||
|
|
||||||
|
# remove usages for empty material slots
|
||||||
|
for i, slot in reversed(list(enumerate(obj.material_slots))):
|
||||||
|
if not slot.material:
|
||||||
|
del usage_count[i]
|
||||||
|
|
||||||
styles = [style for style, usage in zip(styles, usage_count, strict=True) if usage > 0]
|
styles = [style for style, usage in zip(styles, usage_count, strict=True) if usage > 0]
|
||||||
return styles
|
return styles
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user