diff --git a/src/bonsai/bonsai/core/tool.py b/src/bonsai/bonsai/core/tool.py index 91003174ad..889ca774ee 100644 --- a/src/bonsai/bonsai/core/tool.py +++ b/src/bonsai/bonsai/core/tool.py @@ -894,6 +894,7 @@ class Root: def get_default_container(cls): pass def get_element_representation(cls, element, context): pass def get_element_type(cls, element): pass + def has_material_styles(cls, element): pass def get_object_name(cls, obj): pass def get_object_representation(cls, obj): pass def get_representation_context(cls, representation): pass diff --git a/src/bonsai/bonsai/tool/root.py b/src/bonsai/bonsai/tool/root.py index ccc76b9526..9daef1798c 100644 --- a/src/bonsai/bonsai/tool/root.py +++ b/src/bonsai/bonsai/tool/root.py @@ -54,6 +54,12 @@ class Root(bonsai.core.tool.Root): new.obj = obj new.name = opening_type + @classmethod + def has_material_styles(cls, element: ifcopenshell.entity_instance) -> bool: + """Return True if any constituent material of element has a style representation.""" + materials = ifcopenshell.util.element.get_materials(element) + return any(getattr(m, "HasRepresentation", None) for m in materials) + @classmethod def assign_body_styles(cls, element: ifcopenshell.entity_instance, obj: bpy.types.Object) -> None: # Should this even be here? Should it be in the geometry tool? diff --git a/src/bonsai/test/core/test_root.py b/src/bonsai/test/core/test_root.py index 96bd389d1d..4fcafe6947 100644 --- a/src/bonsai/test/core/test_root.py +++ b/src/bonsai/test/core/test_root.py @@ -40,8 +40,7 @@ class TestCopyClass: collector.assign("obj").should_be_called() subject.copy_class(ifc, collector, geometry, root, obj="obj") - # def test_copy_with_new_geometry_copied_from_the_old(self, ifc, collector, geometry, root): - def test_AAAAAAAAAAAA(self, ifc, collector, geometry, root): + def test_copy_with_new_geometry_copied_from_the_old(self, ifc, collector, geometry, root): ifc.get_entity("obj").should_be_called().will_return("original_element") root.is_element_a("original_element", "IfcRelSpaceBoundary").should_be_called().will_return(False) root.get_object_representation("obj").should_be_called().will_return("representation")