Skip to content

Commit ebf6b9f

Browse files
committed
1 parent c2e4b5f commit ebf6b9f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/ifcopenshell-python/ifcopenshell/util/element.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ def get_layers(ifc_file, element):
113113
if subelement.is_a("IfcShapeRepresentation"):
114114
layers.extend(subelement.LayerAssignments or [])
115115
elif subelement.is_a("IfcGeometricRepresentationItem"):
116-
layers.extend(subelement.LayerAssignment or [])
116+
if ifc_file.schema == "IFC2X3":
117+
layers.extend(subelement.LayerAssignments or [])
118+
else:
119+
layers.extend(subelement.LayerAssignment or [])
117120
return layers
118121

119122

src/ifcopenshell-python/test/util/test_element.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,26 @@ def test_getting_the_layer_of_a_type_product_item(self):
250250
assert subject.get_layers(self.file, element) == [layer]
251251

252252

253+
class TestGetlayers(test.bootstrap.IFC2X3):
254+
def test_getting_the_layer_of_a_product_item(self):
255+
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
256+
layer = ifcopenshell.api.run("layer.add_layer", self.file)
257+
item = self.file.createIfcExtrudedAreaSolid()
258+
representation = self.file.createIfcShapeRepresentation(Items=[item])
259+
element.Representation = self.file.createIfcProductDefinitionShape(Representations=[representation])
260+
ifcopenshell.api.run("layer.assign_layer", self.file, item=item, layer=layer)
261+
assert subject.get_layers(self.file, element) == [layer]
262+
263+
def test_getting_the_layer_of_a_type_product_item(self):
264+
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
265+
layer = ifcopenshell.api.run("layer.add_layer", self.file)
266+
item = self.file.createIfcExtrudedAreaSolid()
267+
representation = self.file.createIfcShapeRepresentation(Items=[item])
268+
element.RepresentationMaps = [self.file.createIfcRepresentationMap(MappedRepresentation=representation)]
269+
ifcopenshell.api.run("layer.assign_layer", self.file, item=item, layer=layer)
270+
assert subject.get_layers(self.file, element) == [layer]
271+
272+
253273
class TestGetContainerIFC4(test.bootstrap.IFC4):
254274
def test_getting_the_spatial_container_of_an_element(self):
255275
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")

0 commit comments

Comments
 (0)