mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
get_elements_by_style to support curve styles used in IfcFillAreaStyleHatching
This commit is contained in:
@@ -764,10 +764,15 @@ def get_elements_by_style(
|
||||
style = file.by_type("IfcSurfaceStyle")[0]
|
||||
elements = ifcopenshell.util.element.get_elements_by_style(file, style)
|
||||
"""
|
||||
is_curve_style = style.is_a("IfcCurveStyle")
|
||||
results = set()
|
||||
inverses = list(ifc_file.get_inverse(style))
|
||||
while inverses:
|
||||
inverse = inverses.pop()
|
||||
inverse_class = inverse.is_a()
|
||||
if is_curve_style and inverse_class in ("IfcFillAreaStyleHatching", "IfcFillAreaStyle"):
|
||||
inverses.extend(ifc_file.get_inverse(inverse))
|
||||
continue
|
||||
if inverse.is_a("IfcPresentationStyleAssignment"):
|
||||
inverses.extend(ifc_file.get_inverse(inverse))
|
||||
continue
|
||||
|
||||
@@ -634,6 +634,24 @@ class TestGetElementsByStyle(test.bootstrap.IFC4):
|
||||
)
|
||||
assert subject.get_elements_by_style(self.file, style) == {element}
|
||||
|
||||
def test_getting_elements_of_a_styled_material_with_curve_style_hatching(self):
|
||||
element = self.file.create_entity("IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
|
||||
curve_style = self.file.create_entity("IfcCurveStyle")
|
||||
fill_style = self.file.create_entity("IfcFillAreaStyleHatching", HatchLineAppearance=curve_style)
|
||||
style = self.file.create_entity("IfcFillAreaStyle", FillStyles=[fill_style])
|
||||
self.file.create_entity(
|
||||
"IfcMaterialDefinitionRepresentation",
|
||||
RepresentedMaterial=material,
|
||||
Representations=[
|
||||
self.file.create_entity(
|
||||
"IfcStyledRepresentation", Items=[self.file.create_entity("IfcStyledItem", Styles=[style])]
|
||||
)
|
||||
],
|
||||
)
|
||||
assert subject.get_elements_by_style(self.file, curve_style) == {element}
|
||||
|
||||
|
||||
class TestGetElementsByRepresentation(test.bootstrap.IFC4):
|
||||
def test_getting_elements_of_a_styled_representation_item(self):
|
||||
|
||||
Reference in New Issue
Block a user