mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Fix #1886.
This commit is contained in:
@@ -113,7 +113,10 @@ def get_layers(ifc_file, element):
|
|||||||
if subelement.is_a("IfcShapeRepresentation"):
|
if subelement.is_a("IfcShapeRepresentation"):
|
||||||
layers.extend(subelement.LayerAssignments or [])
|
layers.extend(subelement.LayerAssignments or [])
|
||||||
elif subelement.is_a("IfcGeometricRepresentationItem"):
|
elif subelement.is_a("IfcGeometricRepresentationItem"):
|
||||||
layers.extend(subelement.LayerAssignment or [])
|
if ifc_file.schema == "IFC2X3":
|
||||||
|
layers.extend(subelement.LayerAssignments or [])
|
||||||
|
else:
|
||||||
|
layers.extend(subelement.LayerAssignment or [])
|
||||||
return layers
|
return layers
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -250,6 +250,26 @@ class TestGetlayers(test.bootstrap.IFC4):
|
|||||||
assert subject.get_layers(self.file, element) == [layer]
|
assert subject.get_layers(self.file, element) == [layer]
|
||||||
|
|
||||||
|
|
||||||
|
class TestGetlayers(test.bootstrap.IFC2X3):
|
||||||
|
def test_getting_the_layer_of_a_product_item(self):
|
||||||
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
|
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||||
|
item = self.file.createIfcExtrudedAreaSolid()
|
||||||
|
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||||
|
element.Representation = self.file.createIfcProductDefinitionShape(Representations=[representation])
|
||||||
|
ifcopenshell.api.run("layer.assign_layer", self.file, item=item, layer=layer)
|
||||||
|
assert subject.get_layers(self.file, element) == [layer]
|
||||||
|
|
||||||
|
def test_getting_the_layer_of_a_type_product_item(self):
|
||||||
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||||
|
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||||
|
item = self.file.createIfcExtrudedAreaSolid()
|
||||||
|
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||||
|
element.RepresentationMaps = [self.file.createIfcRepresentationMap(MappedRepresentation=representation)]
|
||||||
|
ifcopenshell.api.run("layer.assign_layer", self.file, item=item, layer=layer)
|
||||||
|
assert subject.get_layers(self.file, element) == [layer]
|
||||||
|
|
||||||
|
|
||||||
class TestGetContainerIFC4(test.bootstrap.IFC4):
|
class TestGetContainerIFC4(test.bootstrap.IFC4):
|
||||||
def test_getting_the_spatial_container_of_an_element(self):
|
def test_getting_the_spatial_container_of_an_element(self):
|
||||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
|
|||||||
Reference in New Issue
Block a user