From eaa80ad08a6ceb77f933a37a31eeffcf83200246 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 16 May 2024 17:27:03 +0500 Subject: [PATCH] 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 --- src/blenderbim/blenderbim/tool/geometry.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/blenderbim/blenderbim/tool/geometry.py b/src/blenderbim/blenderbim/tool/geometry.py index 77c8c7eefb..3133115c62 100644 --- a/src/blenderbim/blenderbim/tool/geometry.py +++ b/src/blenderbim/blenderbim/tool/geometry.py @@ -470,8 +470,15 @@ class Geometry(blenderbim.core.tool.Geometry): usage_count = [0] * len(obj.material_slots) if not usage_count: # if there are no materials, polygons will still use index 0 return [] + for poly in obj.data.polygons: 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] return styles