@@ -214,6 +214,42 @@ def test_getting_an_inherited_material_from_the_elements_type(self):
214214 assert subject .get_material (element ) == material
215215
216216
217+ class TestGetlayers (test .bootstrap .IFC4 ):
218+ def test_getting_the_layer_of_a_product_representation (self ):
219+ element = ifcopenshell .api .run ("root.create_entity" , self .file , ifc_class = "IfcWall" )
220+ layer = ifcopenshell .api .run ("layer.add_layer" , self .file )
221+ representation = self .file .createIfcShapeRepresentation ()
222+ element .Representation = self .file .createIfcProductDefinitionShape (Representations = [representation ])
223+ ifcopenshell .api .run ("layer.assign_layer" , self .file , item = representation , layer = layer )
224+ assert subject .get_layers (self .file , element ) == [layer ]
225+
226+ def test_getting_the_layer_of_a_product_item (self ):
227+ element = ifcopenshell .api .run ("root.create_entity" , self .file , ifc_class = "IfcWall" )
228+ layer = ifcopenshell .api .run ("layer.add_layer" , self .file )
229+ item = self .file .createIfcExtrudedAreaSolid ()
230+ representation = self .file .createIfcShapeRepresentation (Items = [item ])
231+ element .Representation = self .file .createIfcProductDefinitionShape (Representations = [representation ])
232+ ifcopenshell .api .run ("layer.assign_layer" , self .file , item = item , layer = layer )
233+ assert subject .get_layers (self .file , element ) == [layer ]
234+
235+ def test_getting_the_layer_of_a_type_product_representation (self ):
236+ element = ifcopenshell .api .run ("root.create_entity" , self .file , ifc_class = "IfcWallType" )
237+ layer = ifcopenshell .api .run ("layer.add_layer" , self .file )
238+ representation = self .file .createIfcShapeRepresentation ()
239+ element .RepresentationMaps = [self .file .createIfcRepresentationMap (MappedRepresentation = representation )]
240+ ifcopenshell .api .run ("layer.assign_layer" , self .file , item = representation , layer = layer )
241+ assert subject .get_layers (self .file , element ) == [layer ]
242+
243+ def test_getting_the_layer_of_a_type_product_item (self ):
244+ element = ifcopenshell .api .run ("root.create_entity" , self .file , ifc_class = "IfcWallType" )
245+ layer = ifcopenshell .api .run ("layer.add_layer" , self .file )
246+ item = self .file .createIfcExtrudedAreaSolid ()
247+ representation = self .file .createIfcShapeRepresentation (Items = [item ])
248+ element .RepresentationMaps = [self .file .createIfcRepresentationMap (MappedRepresentation = representation )]
249+ ifcopenshell .api .run ("layer.assign_layer" , self .file , item = item , layer = layer )
250+ assert subject .get_layers (self .file , element ) == [layer ]
251+
252+
217253class TestGetContainerIFC4 (test .bootstrap .IFC4 ):
218254 def test_getting_the_spatial_container_of_an_element (self ):
219255 element = ifcopenshell .api .run ("root.create_entity" , self .file , ifc_class = "IfcWall" )
0 commit comments