Handle null Styles when loading surface styles

An IfcSurfaceStyle with a NULL Styles set raised a TypeError when
loading a project. Guard the iterations, matching the existing
defensive pattern in import_presentation_styles.

Generated with the assistance of an AI coding tool.
This commit is contained in:
CyrilWaechter
2026-09-14 17:08:43 +02:00
committed by Cyril Waechter
parent ff2b57d152
commit 243f0f32dc
2 changed files with 16 additions and 3 deletions
+13
View File
@@ -393,6 +393,19 @@ class TestGetUVMaps(NewFile):
assert subject.get_uv_maps(representation) == [uv_map]
class TestGetStyleElements(NewFile):
def test_style_with_null_styles(self):
style = ifcopenshell.file().create_entity("IfcSurfaceStyle", "Name", "BOTH", None)
assert subject.get_style_elements(style) == {}
def test_material_with_null_styles(self):
tool.Ifc.set(ifc := ifcopenshell.file())
style = ifc.create_entity("IfcSurfaceStyle", "Name", "BOTH", None)
material = bpy.data.materials.new("Material")
tool.Ifc.link(style, material)
assert subject.get_style_elements(material) == {}
class TestImportSurfaceAttributes(NewFile):
def test_run(self):
tool.Ifc.set(ifc := ifcopenshell.file())