Files
IfcOpenShell/src/ifcopenshell-python/test/api/geometry/test_unassign_representation.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
2.9 KiB
Python
Raw Normal View History

import numpy
import pytest
import test.bootstrap
import ifcopenshell.api
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])
)
ifcopenshell.api.run("geometry.unassign_representation", self.file, product=wall, representation=representation)
assert representation not in wall.Representation.Representations
ifcopenshell.api.run(
"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
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])
ifcopenshell.api.run(
"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
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)
ifcopenshell.api.run(
"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 not wall.Representation
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0