mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
geometry.unassign_representation to remove shape aspects
previously it was leaving unused shape aspects unconnected to any other elements, now it will purge them
This commit is contained in:
@@ -25,26 +25,41 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
def test_unassigning_a_product_representation(self):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
representation2 = self.file.createIfcShapeRepresentation()
|
||||
item = self.file.create_entity("IfcExtrudedAreaSolid")
|
||||
representation2.Items = (item,)
|
||||
wall = self.file.createIfcWall(
|
||||
Representation=self.file.createIfcProductDefinitionShape(Representations=[representation, representation2])
|
||||
)
|
||||
|
||||
shape_aspect = self.file.create_entity("IfcShapeAspect")
|
||||
shape_aspect.ShapeRepresentations = (self.file.createIfcShapeRepresentation(Items=(item,)),)
|
||||
shape_aspect.PartOfProductDefinitionShape = wall.Representation
|
||||
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=wall, representation=representation)
|
||||
assert representation not in wall.Representation.Representations
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=wall, representation=representation2)
|
||||
assert not wall.Representation
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
|
||||
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
|
||||
assert len(self.file.by_type("IfcShapeAspect")) == 0
|
||||
|
||||
def test_unassigning_a_type_product_representation(self):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
item = self.file.create_entity("IfcExtrudedAreaSolid")
|
||||
representation = self.file.createIfcShapeRepresentation(Items=(item,))
|
||||
origin = self.file.createIfcAxis2Placement3D()
|
||||
repmap = self.file.createIfcRepresentationMap(MappedRepresentation=representation, MappingOrigin=origin)
|
||||
walltype = self.file.createIfcWallType(RepresentationMaps=[repmap])
|
||||
|
||||
shape_aspect = self.file.create_entity("IfcShapeAspect")
|
||||
shape_aspect.ShapeRepresentations = (self.file.createIfcShapeRepresentation(Items=(item,)),)
|
||||
shape_aspect.PartOfProductDefinitionShape = repmap
|
||||
|
||||
ifcopenshell.api.geometry.unassign_representation(self.file, product=walltype, representation=representation)
|
||||
assert not walltype.RepresentationMaps
|
||||
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
|
||||
assert len(self.file.by_type("IfcRepresentationMap")) == 0
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
|
||||
assert len(self.file.by_type("IfcShapeAspect")) == 0
|
||||
|
||||
def test_unassigning_a_type_product_representation_used_by_instances(self):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
|
||||
Reference in New Issue
Block a user