2022-01-19 12:18:33 +11:00
|
|
|
# IfcOpenShell - IFC toolkit and geometry engine
|
|
|
|
|
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
|
|
|
|
#
|
|
|
|
|
# This file is part of IfcOpenShell.
|
|
|
|
|
#
|
|
|
|
|
# IfcOpenShell is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# IfcOpenShell is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2021-11-08 21:02:04 +11:00
|
|
|
import test.bootstrap
|
2024-06-28 12:36:31 +10:00
|
|
|
import ifcopenshell.api.geometry
|
2021-11-08 21:02:04 +11:00
|
|
|
import ifcopenshell.util.placement
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestUnassignRepresentation(test.bootstrap.IFC4):
|
|
|
|
|
def test_unassigning_a_product_representation(self):
|
|
|
|
|
representation = self.file.createIfcShapeRepresentation()
|
|
|
|
|
representation2 = self.file.createIfcShapeRepresentation()
|
|
|
|
|
wall = self.file.createIfcWall(
|
|
|
|
|
Representation=self.file.createIfcProductDefinitionShape(Representations=[representation, representation2])
|
|
|
|
|
)
|
2024-06-28 12:36:31 +10:00
|
|
|
ifcopenshell.api.geometry.unassign_representation(self.file, product=wall, representation=representation)
|
2021-11-08 21:02:04 +11:00
|
|
|
assert representation not in wall.Representation.Representations
|
2024-06-28 12:36:31 +10:00
|
|
|
ifcopenshell.api.geometry.unassign_representation(
|
|
|
|
|
self.file, product=wall, representation=representation2
|
2021-11-08 21:02:04 +11:00
|
|
|
)
|
|
|
|
|
assert not wall.Representation
|
|
|
|
|
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
|
|
|
|
|
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
|
|
|
|
|
|
|
|
|
|
def test_unassigning_a_type_product_representation(self):
|
|
|
|
|
representation = self.file.createIfcShapeRepresentation()
|
|
|
|
|
origin = self.file.createIfcAxis2Placement3D()
|
|
|
|
|
repmap = self.file.createIfcRepresentationMap(MappedRepresentation=representation, MappingOrigin=origin)
|
|
|
|
|
walltype = self.file.createIfcWallType(RepresentationMaps=[repmap])
|
2024-06-28 12:36:31 +10:00
|
|
|
ifcopenshell.api.geometry.unassign_representation(
|
|
|
|
|
self.file, product=walltype, representation=representation
|
2021-11-08 21:02:04 +11:00
|
|
|
)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
def test_unassigning_a_type_product_representation_used_by_instances(self):
|
|
|
|
|
representation = self.file.createIfcShapeRepresentation()
|
|
|
|
|
origin = self.file.createIfcAxis2Placement3D()
|
|
|
|
|
repmap = self.file.createIfcRepresentationMap(MappedRepresentation=representation, MappingOrigin=origin)
|
|
|
|
|
walltype = self.file.createIfcWallType(RepresentationMaps=[repmap])
|
|
|
|
|
mapped_item = self.file.createIfcMappedItem(MappingSource=repmap)
|
|
|
|
|
rep = self.file.createIfcShapeRepresentation(Items=[mapped_item])
|
|
|
|
|
prodrep = self.file.createIfcProductDefinitionShape(Representations=[rep])
|
|
|
|
|
wall = self.file.createIfcWall(Representation=prodrep)
|
2024-06-28 12:36:31 +10:00
|
|
|
ifcopenshell.api.geometry.unassign_representation(
|
|
|
|
|
self.file, product=walltype, representation=representation
|
2021-11-08 21:02:04 +11:00
|
|
|
)
|
|
|
|
|
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 not wall.Representation
|
|
|
|
|
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
|