mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -19,60 +19,64 @@
|
||||
import numpy
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.unit
|
||||
import ifcopenshell.api.spatial
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.placement
|
||||
|
||||
|
||||
class TestAssignObject(test.bootstrap.IFC4):
|
||||
def test_assigning_an_aggregate(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
rel = ifcopenshell.api.run(
|
||||
"aggregate.assign_object", self.file, products=[subelement1, subelement2], relating_object=element
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
rel = ifcopenshell.api.aggregate.assign_object(
|
||||
self.file, products=[subelement1, subelement2], relating_object=element
|
||||
)
|
||||
assert ifcopenshell.util.element.get_aggregate(subelement1) == element
|
||||
assert ifcopenshell.util.element.get_aggregate(subelement2) == element
|
||||
assert rel.is_a("IfcRelAggregates")
|
||||
|
||||
def test_doing_nothing_if_the_aggregate_is_already_assigned(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_that_old_aggregate_relationships_are_updated_if_they_still_have_elements(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element1)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement2], relating_object=element1)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element1)
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement2], relating_object=element1)
|
||||
rel = subelement1.Decomposes[0]
|
||||
assert len(rel.RelatedObjects) == 2
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element2)
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element2)
|
||||
assert len(rel.RelatedObjects) == 1
|
||||
|
||||
def test_that_old_aggregate_relationships_are_purged_if_no_more_elements_are_contained(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element1)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element1)
|
||||
rel_id = subelement1.Decomposes[0].id()
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element2)
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element2)
|
||||
with pytest.raises(RuntimeError):
|
||||
self.file.by_id(rel_id)
|
||||
|
||||
def test_assigning_a_container_does_not_shift_object_placements(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element1)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element1)
|
||||
matrix1 = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -89,37 +93,33 @@ class TestAssignObject(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element1, matrix=matrix1.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element1, matrix=matrix1.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element2, matrix=matrix2.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element2, matrix=matrix2.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element2)
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element2)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo.PlacesObject[0] == element2
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), matrix1)
|
||||
|
||||
def test_not_updating_placement_if_placement_is_not_relative(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
placement = self.file.createIfcGridPlacement()
|
||||
subelement.ObjectPlacement = placement
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
assert subelement.ObjectPlacement == placement
|
||||
|
||||
def test_removing_containment_if_it_exists(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||
container = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=container)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
|
||||
container = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=container)
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
assert not ifcopenshell.util.element.get_container(subelement, should_get_direct=True)
|
||||
|
||||
|
||||
|
||||
@@ -16,38 +16,38 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestUnassignObject(test.bootstrap.IFC4):
|
||||
def test_unassigning_an_object(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.run(
|
||||
"aggregate.assign_object", self.file, products=[subelement1, subelement2], relating_object=element
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.aggregate.assign_object(
|
||||
self.file, products=[subelement1, subelement2], relating_object=element
|
||||
)
|
||||
ifcopenshell.api.run("aggregate.unassign_object", self.file, products=[subelement1, subelement2])
|
||||
ifcopenshell.api.aggregate.unassign_object(self.file, products=[subelement1, subelement2])
|
||||
assert ifcopenshell.util.element.get_aggregate(subelement1) is None
|
||||
assert ifcopenshell.util.element.get_aggregate(subelement2) is None
|
||||
|
||||
def test_the_rel_is_kept_if_there_are_more_decomposed_elements(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement1], relating_object=element)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement2], relating_object=element)
|
||||
ifcopenshell.api.run("aggregate.unassign_object", self.file, products=[subelement1])
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement1], relating_object=element)
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement2], relating_object=element)
|
||||
ifcopenshell.api.aggregate.unassign_object(self.file, products=[subelement1])
|
||||
assert len(self.file.by_type("IfcRelAggregates")) == 1
|
||||
|
||||
def test_the_rel_is_purged_if_there_are_no_more_decomposed_elements(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.run("aggregate.unassign_object", self.file, products=[subelement])
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.aggregate.unassign_object(self.file, products=[subelement])
|
||||
assert len(self.file.by_type("IfcRelAggregates")) == 0
|
||||
|
||||
|
||||
|
||||
@@ -17,21 +17,22 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.boundary
|
||||
|
||||
|
||||
class TestCopyBoundary(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
boundary = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelSpaceBoundary")
|
||||
boundary2 = ifcopenshell.api.run("boundary.copy_boundary", self.file, boundary=boundary)
|
||||
boundary = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRelSpaceBoundary")
|
||||
boundary2 = ifcopenshell.api.boundary.copy_boundary(self.file, boundary=boundary)
|
||||
assert boundary2.is_a("IfcRelSpaceBoundary")
|
||||
assert boundary2.GlobalId != boundary.GlobalId
|
||||
|
||||
def test_copying_connection_geometry(self):
|
||||
geometry = self.file.createIfcConnectionSurfaceGeometry()
|
||||
boundary = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelSpaceBoundary")
|
||||
boundary = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRelSpaceBoundary")
|
||||
boundary.ConnectionGeometry = geometry
|
||||
boundary2 = ifcopenshell.api.run("boundary.copy_boundary", self.file, boundary=boundary)
|
||||
boundary2 = ifcopenshell.api.boundary.copy_boundary(self.file, boundary=boundary)
|
||||
assert boundary2.ConnectionGeometry.is_a("IfcConnectionSurfaceGeometry")
|
||||
assert boundary2.ConnectionGeometry != boundary.ConnectionGeometry
|
||||
|
||||
|
||||
@@ -17,20 +17,21 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.boundary
|
||||
|
||||
|
||||
class TestRemoveBoundary(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
boundary = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelSpaceBoundary")
|
||||
ifcopenshell.api.run("boundary.remove_boundary", self.file, boundary=boundary)
|
||||
boundary = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRelSpaceBoundary")
|
||||
ifcopenshell.api.boundary.remove_boundary(self.file, boundary=boundary)
|
||||
assert not self.file.by_type("IfcRelSpaceBoundary")
|
||||
|
||||
def test_removing_connection_geometry(self):
|
||||
geometry = self.file.createIfcConnectionSurfaceGeometry()
|
||||
boundary = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRelSpaceBoundary")
|
||||
boundary = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRelSpaceBoundary")
|
||||
boundary.ConnectionGeometry = geometry
|
||||
ifcopenshell.api.run("boundary.remove_boundary", self.file, boundary=boundary)
|
||||
ifcopenshell.api.boundary.remove_boundary(self.file, boundary=boundary)
|
||||
assert not self.file.by_type("IfcRelSpaceBoundary")
|
||||
assert not self.file.by_type("IfcConnectionSurfaceGeometry")
|
||||
|
||||
|
||||
@@ -17,20 +17,21 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.classification
|
||||
|
||||
|
||||
class TestAddClassification(test.bootstrap.IFC4):
|
||||
def test_adding_a_classification(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
assert self.file.by_type("IfcClassification")[0].Name == "Name"
|
||||
|
||||
def test_adding_a_classification_from_a_library(self):
|
||||
library = ifcopenshell.file()
|
||||
classification = library.createIfcClassification(Name="Name")
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("classification.add_classification", self.file, classification=classification)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.classification.add_classification(self.file, classification=classification)
|
||||
assert self.file.by_type("IfcClassification")[0].Name == "Name"
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.classification
|
||||
import ifcopenshell.util.classification
|
||||
|
||||
|
||||
@@ -26,12 +27,11 @@ class TestAddReference(test.bootstrap.IFC4):
|
||||
def test_adding_a_reference(self):
|
||||
is_ifc2x3 = self.file.schema == "IFC2X3"
|
||||
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2],
|
||||
identification="X",
|
||||
@@ -64,12 +64,11 @@ class TestAddReference(test.bootstrap.IFC4):
|
||||
classification = library.createIfcClassification(Name="Name")
|
||||
reference = library.createIfcClassificationReference(Identification="1", ReferencedSource=classification)
|
||||
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification=classification)
|
||||
ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification=classification)
|
||||
ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2],
|
||||
reference=reference,
|
||||
@@ -94,16 +93,15 @@ class TestAddReference(test.bootstrap.IFC4):
|
||||
assert len(rel.RelatedObjects) == 2
|
||||
|
||||
def test_adding_a_reference_to_a_resource_and_to_a_root(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = self.file.createIfcMaterial()
|
||||
element2 = self.file.createIfcCostValue()
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
|
||||
if self.file.schema == "IFC2X3":
|
||||
with pytest.raises(TypeError):
|
||||
ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2, element3],
|
||||
identification="X",
|
||||
@@ -112,8 +110,7 @@ class TestAddReference(test.bootstrap.IFC4):
|
||||
)
|
||||
return
|
||||
else:
|
||||
ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2, element3],
|
||||
identification="X",
|
||||
|
||||
@@ -17,46 +17,45 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.classification
|
||||
|
||||
|
||||
class TestRemoveClassification(test.bootstrap.IFC4):
|
||||
def test_removing_a_classification(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
ifcopenshell.api.run("classification.remove_classification", self.file, classification=element)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
ifcopenshell.api.classification.remove_classification(self.file, classification=element)
|
||||
assert not self.file.by_type("IfcClassification")
|
||||
|
||||
def test_removing_a_classification_and_all_of_its_references(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element],
|
||||
identification="X",
|
||||
name="Foobar",
|
||||
classification=result,
|
||||
)
|
||||
ifcopenshell.api.run("classification.remove_classification", self.file, classification=result)
|
||||
ifcopenshell.api.classification.remove_classification(self.file, classification=result)
|
||||
assert not self.file.by_type("IfcClassification")
|
||||
assert not self.file.by_type("IfcClassificationReference")
|
||||
assert not self.file.by_type("IfcRelAssociatesClassification")
|
||||
|
||||
def test_removing_a_classification_and_all_of_its_references_when_associated_with_a_resource(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
element = self.file.create_entity("IfcWall", Name="Wall")
|
||||
ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element],
|
||||
identification="X",
|
||||
name="Foobar",
|
||||
classification=result,
|
||||
)
|
||||
ifcopenshell.api.run("classification.remove_classification", self.file, classification=result)
|
||||
ifcopenshell.api.classification.remove_classification(self.file, classification=result)
|
||||
assert not self.file.by_type("IfcClassification")
|
||||
assert not self.file.by_type("IfcClassificationReference")
|
||||
if self.file.schema != "IFC2X3":
|
||||
|
||||
@@ -18,41 +18,40 @@
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.classification
|
||||
import ifcopenshell.util.classification
|
||||
|
||||
|
||||
class TestRemoveReference(test.bootstrap.IFC4):
|
||||
def test_removing_a_reference(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
reference = ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2],
|
||||
identification="X",
|
||||
name="Foobar",
|
||||
classification=result,
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_reference", self.file, products=[element, element2], reference=reference
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2], reference=reference
|
||||
)
|
||||
assert len(ifcopenshell.util.classification.get_references(element)) == 0
|
||||
assert len(ifcopenshell.util.classification.get_references(element2)) == 0
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
|
||||
def test_removing_a_reference_from_a_resource_and_from_a_root(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = self.file.createIfcMaterial()
|
||||
element2 = self.file.createIfcCostValue()
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
if self.file.schema == "IFC2X3":
|
||||
with pytest.raises(TypeError):
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
reference = ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2, element3],
|
||||
identification="X",
|
||||
@@ -61,8 +60,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
)
|
||||
return
|
||||
else:
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
reference = ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2, element3],
|
||||
identification="X",
|
||||
@@ -70,8 +68,8 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
classification=result,
|
||||
)
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_reference", self.file, products=[element, element2, element3], reference=reference
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2, element3], reference=reference
|
||||
)
|
||||
assert len(ifcopenshell.util.classification.get_references(element)) == 0
|
||||
assert len(ifcopenshell.util.classification.get_references(element2)) == 0
|
||||
@@ -79,13 +77,12 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
|
||||
def test_retaining_the_reference_if_still_in_use(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.run("classification.add_classification", self.file, classification="Name")
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
result = ifcopenshell.api.classification.add_classification(self.file, classification="Name")
|
||||
reference = ifcopenshell.api.classification.add_reference(
|
||||
self.file,
|
||||
products=[element, element2, element3],
|
||||
identification="X",
|
||||
@@ -93,11 +90,11 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
classification=result,
|
||||
)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 1
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_reference", self.file, products=[element, element2], reference=reference
|
||||
ifcopenshell.api.classification.remove_reference(
|
||||
self.file, products=[element, element2], reference=reference
|
||||
)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 1
|
||||
ifcopenshell.api.run("classification.remove_reference", self.file, products=[element3], reference=reference)
|
||||
ifcopenshell.api.classification.remove_reference(self.file, products=[element3], reference=reference)
|
||||
assert len(self.file.by_type("IfcClassificationReference")) == 0
|
||||
|
||||
|
||||
|
||||
@@ -16,46 +16,46 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.constraint
|
||||
import ifcopenshell.util.constraint
|
||||
|
||||
|
||||
class TestAssignConstraint(test.bootstrap.IFC4):
|
||||
def test_assign_a_constraint(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
|
||||
ifcopenshell.api.run(
|
||||
"constraint.assign_constraint", self.file, products=[element, element2], constraint=constraint
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(constraint) == {element, element2}
|
||||
assert len(self.file.by_type("IfcRelAssociatesConstraint")) == 1
|
||||
|
||||
def test_doing_nothing_if_the_constraint_is_already_assigned(self):
|
||||
constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"constraint.assign_constraint", self.file, products=[element, element2], constraint=constraint
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run(
|
||||
"constraint.assign_constraint", self.file, products=[element, element2], constraint=constraint
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
|
||||
constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("constraint.assign_constraint", self.file, products=[element1], constraint=constraint)
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element1], constraint=constraint)
|
||||
rel = self.file.by_type("IfcRelAssociatesConstraint")[0]
|
||||
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"constraint.assign_constraint", self.file, products=[element2, element3], constraint=constraint
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element2, element3], constraint=constraint
|
||||
)
|
||||
assert len(rel.RelatedObjects) == 3
|
||||
|
||||
|
||||
@@ -16,49 +16,49 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.constraint
|
||||
import ifcopenshell.util.constraint
|
||||
|
||||
|
||||
class TestUnassignConstraint(test.bootstrap.IFC4):
|
||||
def test_unassigning_a_constraint(self):
|
||||
constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"constraint.assign_constraint", self.file, products=[element, element2], constraint=constraint
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"constraint.unassign_constraint", self.file, products=[element, element2], constraint=constraint
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element) == set()
|
||||
assert len(self.file.by_type("IfcRelAssociatesConstraint")) == 0
|
||||
|
||||
def test_doing_nothing_if_no_constraint(self):
|
||||
constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"constraint.unassign_constraint", self.file, products=[element, element2], constraint=constraint
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element, element2], constraint=constraint
|
||||
)
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element) == set()
|
||||
assert ifcopenshell.util.constraint.get_constrained_elements(element2) == set()
|
||||
|
||||
def test_updating_the_rel_when_a_reference_is_removed_with_multipled_elements(self):
|
||||
constraint = ifcopenshell.api.run("constraint.add_objective", self.file)
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("constraint.assign_constraint", self.file, products=[element1], constraint=constraint)
|
||||
constraint = ifcopenshell.api.constraint.add_objective(self.file)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.constraint.assign_constraint(self.file, products=[element1], constraint=constraint)
|
||||
rel = self.file.by_type("IfcRelAssociatesConstraint")[0]
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"constraint.assign_constraint", self.file, products=[element2, element3], constraint=constraint
|
||||
ifcopenshell.api.constraint.assign_constraint(
|
||||
self.file, products=[element2, element3], constraint=constraint
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"constraint.unassign_constraint", self.file, products=[element1, element2], constraint=constraint
|
||||
ifcopenshell.api.constraint.unassign_constraint(
|
||||
self.file, products=[element1, element2], constraint=constraint
|
||||
)
|
||||
assert rel.RelatedObjects == (element3,)
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
class TestAddContext(test.bootstrap.IFC4):
|
||||
def test_adding_a_3d_context(self):
|
||||
self.file.createIfcProject()
|
||||
context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
assert context.ContextType == "Model"
|
||||
assert context.is_a() == "IfcGeometricRepresentationContext"
|
||||
assert context.WorldCoordinateSystem.is_a() == "IfcAxis2Placement3D"
|
||||
@@ -34,7 +34,7 @@ class TestAddContext(test.bootstrap.IFC4):
|
||||
|
||||
def test_adding_a_2d_context(self):
|
||||
self.file.createIfcProject()
|
||||
context = ifcopenshell.api.run("context.add_context", self.file, context_type="Plan")
|
||||
context = ifcopenshell.api.context.add_context(self.file, context_type="Plan")
|
||||
assert context.ContextType == "Plan"
|
||||
assert context.is_a() == "IfcGeometricRepresentationContext"
|
||||
assert context.WorldCoordinateSystem.is_a() == "IfcAxis2Placement2D"
|
||||
@@ -44,7 +44,7 @@ class TestAddContext(test.bootstrap.IFC4):
|
||||
|
||||
def test_defaulting_to_3d_with_an_unknown_context_type(self):
|
||||
self.file.createIfcProject()
|
||||
context = ifcopenshell.api.run("context.add_context", self.file)
|
||||
context = ifcopenshell.api.context.add_context(self.file)
|
||||
assert context.ContextType is None
|
||||
assert context.is_a() == "IfcGeometricRepresentationContext"
|
||||
assert context.WorldCoordinateSystem.is_a() == "IfcAxis2Placement3D"
|
||||
@@ -56,15 +56,15 @@ class TestAddContext(test.bootstrap.IFC4):
|
||||
def test_adding_a_subcontext(self):
|
||||
self.test_adding_a_3d_context()
|
||||
context = self.file.by_type("IfcGeometricRepresentationContext")[0]
|
||||
subcontext = ifcopenshell.api.run("context.add_context", self.file, parent=context, target_view="NOTDEFINED")
|
||||
subcontext = ifcopenshell.api.context.add_context(self.file, parent=context, target_view="NOTDEFINED")
|
||||
assert subcontext.is_a("IfcGeometricRepresentationSubContext")
|
||||
assert subcontext.TargetView == "NOTDEFINED"
|
||||
|
||||
def test_adding_a_subcontext_with_an_optional_identifier_specified(self):
|
||||
self.test_adding_a_3d_context()
|
||||
context = self.file.by_type("IfcGeometricRepresentationContext")[0]
|
||||
subcontext = ifcopenshell.api.run(
|
||||
"context.add_context", self.file, parent=context, target_view="NOTDEFINED", context_identifier="Body"
|
||||
subcontext = ifcopenshell.api.context.add_context(
|
||||
self.file, parent=context, target_view="NOTDEFINED", context_identifier="Body"
|
||||
)
|
||||
assert subcontext.is_a("IfcGeometricRepresentationSubContext")
|
||||
assert subcontext.TargetView == "NOTDEFINED"
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
class TestEditContext(test.bootstrap.IFC4):
|
||||
def test_editing_a_context(self):
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
ifcopenshell.api.run(
|
||||
"context.edit_context",
|
||||
ifcopenshell.api.context.edit_context(
|
||||
self.file,
|
||||
context=context,
|
||||
attributes={
|
||||
@@ -41,8 +40,7 @@ class TestEditContext(test.bootstrap.IFC4):
|
||||
|
||||
def test_editing_a_subcontext(self):
|
||||
subcontext = self.file.createIfcGeometricRepresentationSubcontext()
|
||||
ifcopenshell.api.run(
|
||||
"context.edit_context",
|
||||
ifcopenshell.api.context.edit_context(
|
||||
self.file,
|
||||
context=subcontext,
|
||||
attributes={
|
||||
|
||||
@@ -17,20 +17,20 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.context
|
||||
|
||||
|
||||
class TestRemoveContext(test.bootstrap.IFC4):
|
||||
def test_removing_a_context(self):
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
ifcopenshell.api.run("context.remove_context", self.file, context=context)
|
||||
ifcopenshell.api.context.remove_context(self.file, context=context)
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 0
|
||||
|
||||
def test_removing_a_context_with_subcontexts(self):
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
subcontext = self.file.createIfcGeometricRepresentationSubcontext()
|
||||
subcontext.ParentContext = context
|
||||
ifcopenshell.api.run("context.remove_context", self.file, context=context)
|
||||
ifcopenshell.api.context.remove_context(self.file, context=context)
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 0
|
||||
|
||||
def test_removing_a_subcontext_and_reassigning_references_to_its_parent(self):
|
||||
@@ -41,7 +41,7 @@ class TestRemoveContext(test.bootstrap.IFC4):
|
||||
if self.file.schema != "IFC2X3":
|
||||
projected_crs = self.file.createIfcProjectedCRS()
|
||||
map_conversion = self.file.createIfcMapConversion(SourceCRS=subcontext, TargetCRS=projected_crs)
|
||||
ifcopenshell.api.run("context.remove_context", self.file, context=subcontext)
|
||||
ifcopenshell.api.context.remove_context(self.file, context=subcontext)
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationSubcontext")) == 0
|
||||
assert representation in self.file.get_inverse(context)
|
||||
if self.file.schema != "IFC2X3":
|
||||
@@ -51,7 +51,7 @@ class TestRemoveContext(test.bootstrap.IFC4):
|
||||
def test_removing_a_context_with_references(self):
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
representation = self.file.createIfcRepresentation(ContextOfItems=context)
|
||||
ifcopenshell.api.run("context.remove_context", self.file, context=context)
|
||||
ifcopenshell.api.context.remove_context(self.file, context=context)
|
||||
assert len([e for e in self.file]) == 0
|
||||
|
||||
|
||||
|
||||
@@ -17,32 +17,33 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.api.control
|
||||
|
||||
|
||||
class TestAssignControl(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
wall = self.file.createIfcWall()
|
||||
control = ifcopenshell.api.run("cost.add_cost_schedule", self.file)
|
||||
control = ifcopenshell.api.cost.add_cost_schedule(self.file)
|
||||
|
||||
# simple assignment
|
||||
relation = ifcopenshell.api.run(
|
||||
"control.assign_control", self.file, relating_control=control, related_object=wall
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
assert relation.RelatingControl == control
|
||||
assert relation.RelatedObjects == (wall,)
|
||||
|
||||
# trying to establish existing relationship
|
||||
relation = ifcopenshell.api.run(
|
||||
"control.assign_control", self.file, relating_control=control, related_object=wall
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
assert relation is None
|
||||
|
||||
# assigning same control to another object
|
||||
wall1 = self.file.createIfcWall()
|
||||
relation = ifcopenshell.api.run(
|
||||
"control.assign_control", self.file, relating_control=control, related_object=wall1
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall1
|
||||
)
|
||||
assert relation is not None
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
|
||||
@@ -17,28 +17,29 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.api.control
|
||||
|
||||
|
||||
class TestUnassignControl(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
wall = self.file.createIfcWall()
|
||||
control = ifcopenshell.api.run("cost.add_cost_schedule", self.file)
|
||||
control = ifcopenshell.api.cost.add_cost_schedule(self.file)
|
||||
|
||||
# assign and unassign
|
||||
relation = ifcopenshell.api.run(
|
||||
"control.assign_control", self.file, relating_control=control, related_object=wall
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
ifcopenshell.api.run("control.unassign_control", self.file, relating_control=control, related_object=wall)
|
||||
ifcopenshell.api.control.unassign_control(self.file, relating_control=control, related_object=wall)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 0
|
||||
|
||||
# 1 control 2 related objects
|
||||
wall1 = self.file.createIfcWall()
|
||||
relation = ifcopenshell.api.run(
|
||||
"control.assign_control", self.file, relating_control=control, related_object=wall
|
||||
relation = ifcopenshell.api.control.assign_control(
|
||||
self.file, relating_control=control, related_object=wall
|
||||
)
|
||||
ifcopenshell.api.run("control.assign_control", self.file, relating_control=control, related_object=wall1)
|
||||
ifcopenshell.api.run("control.unassign_control", self.file, relating_control=control, related_object=wall1)
|
||||
ifcopenshell.api.control.assign_control(self.file, relating_control=control, related_object=wall1)
|
||||
ifcopenshell.api.control.unassign_control(self.file, relating_control=control, related_object=wall1)
|
||||
assert len(self.file.by_type("IfcRelAssignsToControl")) == 1
|
||||
assert relation.RelatedObjects == (wall,)
|
||||
|
||||
|
||||
@@ -17,22 +17,22 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAddCostItem(test.bootstrap.IFC4):
|
||||
def test_add_a_cost_item(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo")
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo")
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
|
||||
assert item1.is_a("IfcCostItem")
|
||||
assert item1.HasAssignments[0].is_a("IfcRelAssignsToControl")
|
||||
assert item1.HasAssignments[0].RelatingControl == schedule
|
||||
|
||||
def test_add_a_sub_cost_item(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo")
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo")
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.cost.add_cost_item(self.file, cost_item=item1)
|
||||
assert item2.is_a("IfcCostItem")
|
||||
assert ifcopenshell.util.element.get_nest(item2) == item1
|
||||
|
||||
|
||||
@@ -17,22 +17,24 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.control
|
||||
|
||||
|
||||
class TestAddCostItemQuantity(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
schema = ifcopenshell.schema_by_name(self.file.schema)
|
||||
quantity_types = [t.name() for t in schema.declaration_by_name("IfcPhysicalSimpleQuantity").subtypes()]
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("control.assign_control", self.file, relating_control=item, related_object=wall)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file)
|
||||
item = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.control.assign_control(self.file, relating_control=item, related_object=wall)
|
||||
|
||||
quantities = []
|
||||
for quantity_type in quantity_types:
|
||||
quantity = ifcopenshell.api.run(
|
||||
"cost.add_cost_item_quantity", self.file, cost_item=item, ifc_class=quantity_type
|
||||
quantity = ifcopenshell.api.cost.add_cost_item_quantity(
|
||||
self.file, cost_item=item, ifc_class=quantity_type
|
||||
)
|
||||
assert quantity.is_a(quantity_type)
|
||||
assert quantity.Name == "Unnamed"
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
|
||||
|
||||
class TestAddCostSchedule(test.bootstrap.IFC4):
|
||||
def test_add_a_cost_schedule(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
|
||||
assert schedule.is_a("IfcCostSchedule")
|
||||
assert schedule.Name == "Foo"
|
||||
assert schedule.PredefinedType == "BUDGET"
|
||||
|
||||
def test_adding_a_userdefined_type(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="FOO")
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="FOO")
|
||||
assert schedule.is_a("IfcCostSchedule")
|
||||
assert schedule.Name == "Foo"
|
||||
assert schedule.PredefinedType == "USERDEFINED"
|
||||
|
||||
@@ -17,31 +17,31 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
|
||||
|
||||
class TestRemoveCostItem(test.bootstrap.IFC4):
|
||||
def test_remove_a_cost_item(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
|
||||
ifcopenshell.api.run("cost.remove_cost_item", self.file, cost_item=item1)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
|
||||
ifcopenshell.api.cost.remove_cost_item(self.file, cost_item=item1)
|
||||
assert not self.file.by_type("IfcCostItem")
|
||||
assert not self.file.by_type("IfcRelAssignsToControl")
|
||||
|
||||
def test_remove_a_sub_cost_item(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1)
|
||||
ifcopenshell.api.run("cost.remove_cost_item", self.file, cost_item=item2)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.cost.add_cost_item(self.file, cost_item=item1)
|
||||
ifcopenshell.api.cost.remove_cost_item(self.file, cost_item=item2)
|
||||
assert self.file.by_type("IfcCostItem") == [item1]
|
||||
assert self.file.by_type("IfcRelAssignsToControl")
|
||||
assert not self.file.by_type("IfcRelNests")
|
||||
|
||||
def test_remove_a_parent_cost_item(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1)
|
||||
ifcopenshell.api.run("cost.remove_cost_item", self.file, cost_item=item1)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.cost.add_cost_item(self.file, cost_item=item1)
|
||||
ifcopenshell.api.cost.remove_cost_item(self.file, cost_item=item1)
|
||||
assert not self.file.by_type("IfcCostItem")
|
||||
assert not self.file.by_type("IfcRelAssignsToControl")
|
||||
assert not self.file.by_type("IfcRelNests")
|
||||
|
||||
@@ -18,19 +18,20 @@
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.cost
|
||||
|
||||
|
||||
class TestRemoveCostSchedule(test.bootstrap.IFC4):
|
||||
def test_remove_a_cost_schedule(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
|
||||
ifcopenshell.api.run("cost.remove_cost_schedule", self.file, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
|
||||
ifcopenshell.api.cost.remove_cost_schedule(self.file, cost_schedule=schedule)
|
||||
assert not self.file.by_type("IfcCostSchedule")
|
||||
|
||||
def test_remove_a_schedule_with_items(self):
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", self.file, name="Foo", predefined_type="BUDGET")
|
||||
item1 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.run("cost.add_cost_item", self.file, cost_item=item1)
|
||||
ifcopenshell.api.run("cost.remove_cost_schedule", self.file, cost_schedule=schedule)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(self.file, name="Foo", predefined_type="BUDGET")
|
||||
item1 = ifcopenshell.api.cost.add_cost_item(self.file, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.cost.add_cost_item(self.file, cost_item=item1)
|
||||
ifcopenshell.api.cost.remove_cost_schedule(self.file, cost_schedule=schedule)
|
||||
assert not self.file.by_type("IfcCostSchedule")
|
||||
assert not self.file.by_type("IfcCostItem")
|
||||
assert not self.file.by_type("IfcRelNests")
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.document
|
||||
|
||||
|
||||
class TestAddInformation(test.bootstrap.IFC4):
|
||||
def test_adding_information(self):
|
||||
project = self.file.createIfcProject()
|
||||
element = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
element = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
assert element.is_a("IfcDocumentInformation")
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 1
|
||||
|
||||
def test_adding_information_to_the_project(self):
|
||||
project = self.file.createIfcProject()
|
||||
element = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
element = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
rel = self.file.by_type("IfcRelAssociatesDocument")[0]
|
||||
assert rel.is_a("IfcRelAssociatesDocument")
|
||||
assert rel.RelatingDocument == element
|
||||
@@ -37,13 +37,13 @@ class TestAddInformation(test.bootstrap.IFC4):
|
||||
|
||||
def test_adding_a_subdocument(self):
|
||||
project = self.file.createIfcProject()
|
||||
parent = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
element = ifcopenshell.api.run("document.add_information", self.file, parent=parent)
|
||||
parent = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
element = ifcopenshell.api.document.add_information(self.file, parent=parent)
|
||||
assert element.is_a("IfcDocumentInformation")
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 2
|
||||
assert element.IsPointedTo[0].RelatingDocument == parent
|
||||
assert parent.IsPointer[0].RelatedDocuments[0] == element
|
||||
element2 = ifcopenshell.api.run("document.add_information", self.file, parent=parent)
|
||||
element2 = ifcopenshell.api.document.add_information(self.file, parent=parent)
|
||||
assert element in parent.IsPointer[0].RelatedDocuments
|
||||
assert element2 in parent.IsPointer[0].RelatedDocuments
|
||||
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.document
|
||||
|
||||
|
||||
class TestAddReference(test.bootstrap.IFC4):
|
||||
def test_adding_a_reference(self):
|
||||
element = ifcopenshell.api.run("document.add_reference", self.file, information=None)
|
||||
element = ifcopenshell.api.document.add_reference(self.file, information=None)
|
||||
assert element.is_a("IfcDocumentReference")
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 1
|
||||
|
||||
def test_adding_a_reference_to_an_information(self):
|
||||
self.file.createIfcProject()
|
||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
element = ifcopenshell.api.run("document.add_reference", self.file, information=information)
|
||||
information = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
element = ifcopenshell.api.document.add_reference(self.file, information=information)
|
||||
assert element.is_a("IfcDocumentReference")
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 1
|
||||
ifc2x3 = self.file.schema == "IFC2X3"
|
||||
|
||||
@@ -17,23 +17,24 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.document
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAssignDocument(test.bootstrap.IFC4):
|
||||
def test_assigning_a_document(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
|
||||
ifcopenshell.api.run("document.assign_document", self.file, products=[element], document=reference)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.document.add_reference(self.file, information=None)
|
||||
ifcopenshell.api.document.assign_document(self.file, products=[element], document=reference)
|
||||
assert element.HasAssociations[0].RelatingDocument == reference
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == {element}
|
||||
|
||||
def test_assigning_multiple_documents(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
|
||||
ifcopenshell.api.run("document.assign_document", self.file, products=[element, element2], document=reference)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.document.add_reference(self.file, information=None)
|
||||
ifcopenshell.api.document.assign_document(self.file, products=[element, element2], document=reference)
|
||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 1
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == {element, element2}
|
||||
|
||||
|
||||
@@ -17,45 +17,45 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.document
|
||||
|
||||
|
||||
class TestRemoveInformation(test.bootstrap.IFC4):
|
||||
def test_remove_information(self):
|
||||
self.file.createIfcProject()
|
||||
element = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
ifcopenshell.api.run("document.remove_information", self.file, information=element)
|
||||
element = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
ifcopenshell.api.document.remove_information(self.file, information=element)
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 0
|
||||
|
||||
def test_removing_all_references_of_an_information(self):
|
||||
self.file.createIfcProject()
|
||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
ifcopenshell.api.run("document.add_reference", self.file, information=information)
|
||||
ifcopenshell.api.run("document.remove_information", self.file, information=information)
|
||||
information = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
ifcopenshell.api.document.add_reference(self.file, information=information)
|
||||
ifcopenshell.api.document.remove_information(self.file, information=information)
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 0
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 0
|
||||
|
||||
# test removing relationship to another information if it was the only relating element
|
||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
information1 = ifcopenshell.api.run("document.add_information", self.file, parent=information)
|
||||
information2 = ifcopenshell.api.run("document.add_information", self.file, parent=information)
|
||||
information = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
information1 = ifcopenshell.api.document.add_information(self.file, parent=information)
|
||||
information2 = ifcopenshell.api.document.add_information(self.file, parent=information)
|
||||
|
||||
ifcopenshell.api.run("document.remove_information", self.file, information=information1)
|
||||
ifcopenshell.api.document.remove_information(self.file, information=information1)
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 2
|
||||
assert len(self.file.by_type("IfcDocumentInformationRelationship")) == 1
|
||||
|
||||
ifcopenshell.api.run("document.remove_information", self.file, information=information2)
|
||||
ifcopenshell.api.document.remove_information(self.file, information=information2)
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 1
|
||||
assert len(self.file.by_type("IfcDocumentInformationRelationship")) == 0
|
||||
|
||||
def test_removing_all_subdocuments_and_their_references_too(self):
|
||||
self.file.createIfcProject()
|
||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
information2 = ifcopenshell.api.run("document.add_information", self.file, parent=information)
|
||||
ifcopenshell.api.run("document.add_reference", self.file, information=information2)
|
||||
ifcopenshell.api.run("document.remove_information", self.file, information=information)
|
||||
information = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
information2 = ifcopenshell.api.document.add_information(self.file, parent=information)
|
||||
ifcopenshell.api.document.add_reference(self.file, information=information2)
|
||||
ifcopenshell.api.document.remove_information(self.file, information=information)
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 0
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 0
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.document
|
||||
|
||||
|
||||
class TestRemoveReference(test.bootstrap.IFC4):
|
||||
def test_removing_reference(self):
|
||||
project = self.file.createIfcProject()
|
||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
reference = ifcopenshell.api.run("document.add_reference", self.file, information=information)
|
||||
ifcopenshell.api.run("document.remove_reference", self.file, reference=reference)
|
||||
information = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
reference = ifcopenshell.api.document.add_reference(self.file, information=information)
|
||||
ifcopenshell.api.document.remove_reference(self.file, reference=reference)
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 0
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 1
|
||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 1
|
||||
@@ -33,11 +33,11 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
def test_removing_a_reference_assigned_to_an_object(self):
|
||||
project = self.file.createIfcProject()
|
||||
wall = self.file.createIfcWall()
|
||||
information = ifcopenshell.api.run("document.add_information", self.file, parent=None)
|
||||
reference = ifcopenshell.api.run("document.add_reference", self.file, information=information)
|
||||
ifcopenshell.api.run("document.assign_document", self.file, products=[wall], document=reference)
|
||||
information = ifcopenshell.api.document.add_information(self.file, parent=None)
|
||||
reference = ifcopenshell.api.document.add_reference(self.file, information=information)
|
||||
ifcopenshell.api.document.assign_document(self.file, products=[wall], document=reference)
|
||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 2
|
||||
ifcopenshell.api.run("document.remove_reference", self.file, reference=reference)
|
||||
ifcopenshell.api.document.remove_reference(self.file, reference=reference)
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 0
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 1
|
||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 1
|
||||
|
||||
@@ -17,28 +17,29 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.document
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestUnassignDocument(test.bootstrap.IFC4):
|
||||
def test_unassigning_a_document(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
|
||||
ifcopenshell.api.run("document.assign_document", self.file, products=[element], document=reference)
|
||||
ifcopenshell.api.run("document.unassign_document", self.file, products=[element], document=reference)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.document.add_reference(self.file, information=None)
|
||||
ifcopenshell.api.document.assign_document(self.file, products=[element], document=reference)
|
||||
ifcopenshell.api.document.unassign_document(self.file, products=[element], document=reference)
|
||||
assert not element.HasAssociations
|
||||
assert not len(self.file.by_type("IfcRelAssociatesDocument"))
|
||||
|
||||
def test_unassigning_a_document_used_by_multiple_entities(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.run("document.add_reference", self.file, information=None)
|
||||
ifcopenshell.api.run(
|
||||
"document.assign_document", self.file, products=[element, element2, element3], document=reference
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
reference = ifcopenshell.api.document.add_reference(self.file, information=None)
|
||||
ifcopenshell.api.document.assign_document(
|
||||
self.file, products=[element, element2, element3], document=reference
|
||||
)
|
||||
ifcopenshell.api.run("document.unassign_document", self.file, products=[element, element2], document=reference)
|
||||
ifcopenshell.api.document.unassign_document(self.file, products=[element, element2], document=reference)
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == {element3}
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.drawing
|
||||
|
||||
|
||||
class TestAssignProduct(test.bootstrap.IFC4):
|
||||
@@ -25,16 +25,16 @@ class TestAssignProduct(test.bootstrap.IFC4):
|
||||
wall = self.file.createIfcWall()
|
||||
label = self.file.createIfcAnnotation()
|
||||
label2 = self.file.createIfcAnnotation()
|
||||
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
|
||||
ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label)
|
||||
assert wall.ReferencedBy[0].RelatedObjects == (label,)
|
||||
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label2)
|
||||
ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label2)
|
||||
assert wall.ReferencedBy[0].RelatedObjects == (label, label2)
|
||||
|
||||
def test_not_assigning_twice(self):
|
||||
wall = self.file.createIfcWall()
|
||||
label = self.file.createIfcAnnotation()
|
||||
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
|
||||
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
|
||||
ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label)
|
||||
ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label)
|
||||
assert len(wall.ReferencedBy) == 1
|
||||
assert wall.ReferencedBy[0].RelatedObjects == (label,)
|
||||
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.drawing
|
||||
|
||||
|
||||
class TestEditTextLiteral(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
text = self.file.createIfcTextLiteralWithExtent()
|
||||
ifcopenshell.api.run(
|
||||
"drawing.edit_text_literal",
|
||||
ifcopenshell.api.drawing.edit_text_literal(
|
||||
self.file,
|
||||
text_literal=text,
|
||||
attributes={
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.drawing
|
||||
|
||||
|
||||
class TestUnassignProduct(test.bootstrap.IFC4):
|
||||
def test_unassigning_a_product(self):
|
||||
wall = self.file.createIfcWall()
|
||||
label = self.file.createIfcAnnotation()
|
||||
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
|
||||
ifcopenshell.api.run("drawing.unassign_product", self.file, relating_product=wall, related_object=label)
|
||||
ifcopenshell.api.drawing.assign_product(self.file, relating_product=wall, related_object=label)
|
||||
ifcopenshell.api.drawing.unassign_product(self.file, relating_product=wall, related_object=label)
|
||||
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0
|
||||
|
||||
|
||||
|
||||
@@ -17,23 +17,24 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.context
|
||||
import ifcopenshell.api.geometry
|
||||
import numpy as np
|
||||
|
||||
|
||||
class TestAddBoolean(test.bootstrap.IFC4):
|
||||
def test_returning_ifc_boolean_clipping_result(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
body = ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
model = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
body = ifcopenshell.api.context.add_context(
|
||||
self.file,
|
||||
context_type="Model",
|
||||
context_identifier="Body",
|
||||
target_view="MODEL_VIEW",
|
||||
parent=model,
|
||||
)
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
|
||||
profile = self.file.create_entity(
|
||||
"IfcIShapeProfileDef",
|
||||
@@ -45,12 +46,10 @@ class TestAddBoolean(test.bootstrap.IFC4):
|
||||
FlangeThickness=8,
|
||||
FilletRadius=12,
|
||||
)
|
||||
rep = ifcopenshell.api.run(
|
||||
"geometry.add_profile_representation", self.file, context=body, profile=profile, depth=5
|
||||
)
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
|
||||
rep = ifcopenshell.api.geometry.add_profile_representation(self.file, context=body, profile=profile, depth=5)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
|
||||
|
||||
ifcopenshell.api.run("geometry.add_boolean", self.file, representation=rep, matrix=np.eye(4))
|
||||
ifcopenshell.api.geometry.add_boolean(self.file, representation=rep, matrix=np.eye(4))
|
||||
assert rep.Items[0].is_a() == "IfcBooleanClippingResult"
|
||||
assert rep.RepresentationType == "Clipping"
|
||||
|
||||
|
||||
@@ -18,41 +18,44 @@
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.type
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.geometry
|
||||
|
||||
|
||||
class TestAssignRepresentation(test.bootstrap.IFC4):
|
||||
def test_assigning_to_a_product(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rep = self.file.createIfcShapeRepresentation()
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
|
||||
assert wall.Representation.Representations == (rep,)
|
||||
|
||||
def test_assigning_to_a_product_with_existing_representations(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rep = self.file.createIfcShapeRepresentation()
|
||||
rep2 = self.file.createIfcShapeRepresentation()
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep2)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep2)
|
||||
assert wall.Representation.Representations == (rep, rep2)
|
||||
|
||||
def test_assigning_to_a_type_product(self):
|
||||
walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
rep = self.file.createIfcShapeRepresentation()
|
||||
rep2 = self.file.createIfcShapeRepresentation()
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep2)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep2)
|
||||
assert walltype.RepresentationMaps[0].MappedRepresentation == rep
|
||||
assert walltype.RepresentationMaps[1].MappedRepresentation == rep2
|
||||
|
||||
def test_assigning_to_a_type_will_map_representations_to_instances(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
rep2 = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep2)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep2)
|
||||
assert wall.Representation.Representations[0].RepresentationType == "MappedRepresentation"
|
||||
assert wall.Representation.Representations[0].Items[0].MappingSource.MappedRepresentation == rep
|
||||
assert wall.Representation.Representations[0].Items[0].MappingSource == walltype.RepresentationMaps[0]
|
||||
@@ -65,13 +68,13 @@ class TestAssignRepresentation(test.bootstrap.IFC4):
|
||||
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
rep2 = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
|
||||
walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
|
||||
walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
|
||||
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
|
||||
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep2)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep2)
|
||||
assert wall.Representation.Representations[0].RepresentationType == "MappedRepresentation"
|
||||
assert wall.Representation.Representations[0].Items[0].MappingSource.MappedRepresentation == rep
|
||||
assert walltype.RepresentationMaps[0].MappedRepresentation == rep
|
||||
@@ -82,10 +85,10 @@ class TestAssignRepresentation(test.bootstrap.IFC4):
|
||||
def test_assigning_to_an_instance_with_a_nongeometric_type_only_adds_it_to_the_instance(self):
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
|
||||
walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
|
||||
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
|
||||
assert wall.Representation.Representations[0].RepresentationType != "MappedRepresentation"
|
||||
assert wall.Representation.Representations[0] == rep
|
||||
assert not walltype.RepresentationMaps
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.geometry
|
||||
|
||||
|
||||
class TestConnectElement(test.bootstrap.IFC4):
|
||||
def test_connecting_an_element(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run(
|
||||
"geometry.connect_element",
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.geometry.connect_element(
|
||||
self.file,
|
||||
relating_element=wall1,
|
||||
related_element=wall2,
|
||||
@@ -37,10 +37,9 @@ class TestConnectElement(test.bootstrap.IFC4):
|
||||
assert rel.Description == "FOOBAR"
|
||||
|
||||
def test_reconnecting_an_element_changes_the_description(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run(
|
||||
"geometry.connect_element",
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.geometry.connect_element(
|
||||
self.file,
|
||||
relating_element=wall1,
|
||||
related_element=wall2,
|
||||
@@ -52,8 +51,7 @@ class TestConnectElement(test.bootstrap.IFC4):
|
||||
assert rel.Description == "FOOBAR"
|
||||
|
||||
total_elements = len([e for e in self.file])
|
||||
rel = ifcopenshell.api.run(
|
||||
"geometry.connect_element",
|
||||
rel = ifcopenshell.api.geometry.connect_element(
|
||||
self.file,
|
||||
relating_element=wall1,
|
||||
related_element=wall2,
|
||||
@@ -63,10 +61,9 @@ class TestConnectElement(test.bootstrap.IFC4):
|
||||
assert rel.Description == "FOOBAZ"
|
||||
|
||||
def test_reconnecting_and_changing_the_order(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run(
|
||||
"geometry.connect_element",
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.geometry.connect_element(
|
||||
self.file,
|
||||
relating_element=wall1,
|
||||
related_element=wall2,
|
||||
@@ -75,9 +72,7 @@ class TestConnectElement(test.bootstrap.IFC4):
|
||||
assert rel.RelatingElement == wall1
|
||||
assert rel.RelatedElement == wall2
|
||||
|
||||
total_elements = len([e for e in self.file])
|
||||
rel = ifcopenshell.api.run(
|
||||
"geometry.connect_element",
|
||||
rel = ifcopenshell.api.geometry.connect_element(
|
||||
self.file,
|
||||
relating_element=wall2,
|
||||
related_element=wall1,
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.geometry
|
||||
|
||||
|
||||
class TestConnectPath(test.bootstrap.IFC4):
|
||||
def test_connecting_a_path(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = self.connect_path(wall1, wall2, "ATSTART", "ATEND", description="MITRE")
|
||||
assert rel.is_a("IfcRelConnectsPathElements")
|
||||
assert rel.RelatingElement == wall1
|
||||
@@ -33,34 +34,34 @@ class TestConnectPath(test.bootstrap.IFC4):
|
||||
assert rel.Description == "MITRE"
|
||||
|
||||
def test_doing_nothing_if_the_element_is_already_connected(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
self.connect_path(wall1, wall2)
|
||||
total_elements = len([e for e in self.file])
|
||||
self.connect_path(wall1, wall2)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_updating_the_connection_type_if_already_connected(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
|
||||
total_elements = len([e for e in self.file])
|
||||
rel = self.connect_path(wall1, wall2, "ATSTART")
|
||||
assert rel.RelatingConnectionType == "ATSTART"
|
||||
assert rel.RelatedConnectionType == "NOTDEFINED"
|
||||
|
||||
def test_preventing_cyclical_connections(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall2, related_element=wall1)
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall2, related_element=wall1)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_a_relating_element_can_have_multiple_path_connections(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATPATH", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATPATH", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
|
||||
@@ -74,57 +75,57 @@ class TestConnectPath(test.bootstrap.IFC4):
|
||||
assert rel2.RelatedConnectionType == "ATSTART"
|
||||
|
||||
def test_a_element_can_only_have_up_to_one_start_or_end_connections(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATSTART", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATEND", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATSTART", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATSTART", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATEND", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATEND", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATPATH", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATPATH", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATEND")
|
||||
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATSTART")
|
||||
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATEND")
|
||||
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATEND")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
@@ -137,8 +138,7 @@ class TestConnectPath(test.bootstrap.IFC4):
|
||||
related_connection="NOTDEFINED",
|
||||
description=None,
|
||||
):
|
||||
return ifcopenshell.api.run(
|
||||
"geometry.connect_path",
|
||||
return ifcopenshell.api.geometry.connect_path(
|
||||
self.file,
|
||||
relating_element=relating_element,
|
||||
related_element=related_element,
|
||||
|
||||
@@ -17,22 +17,23 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.geometry
|
||||
|
||||
|
||||
class TestDisconnectElement(test.bootstrap.IFC4):
|
||||
def test_disconnecting_an_element(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("geometry.connect_element", self.file, relating_element=wall1, related_element=wall2)
|
||||
ifcopenshell.api.run("geometry.disconnect_element", self.file, relating_element=wall1, related_element=wall2)
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_element(self.file, relating_element=wall1, related_element=wall2)
|
||||
ifcopenshell.api.geometry.disconnect_element(self.file, relating_element=wall1, related_element=wall2)
|
||||
assert not self.file.by_type("IfcRelConnectsElements")
|
||||
|
||||
def test_order_does_not_matter(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("geometry.connect_element", self.file, relating_element=wall1, related_element=wall2)
|
||||
ifcopenshell.api.run("geometry.disconnect_element", self.file, relating_element=wall2, related_element=wall1)
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_element(self.file, relating_element=wall1, related_element=wall2)
|
||||
ifcopenshell.api.geometry.disconnect_element(self.file, relating_element=wall2, related_element=wall1)
|
||||
assert not self.file.by_type("IfcRelConnectsElements")
|
||||
|
||||
|
||||
|
||||
@@ -17,56 +17,55 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.geometry
|
||||
|
||||
|
||||
class TestDisconnectPath(test.bootstrap.IFC4):
|
||||
def test_disconnecting_a_path(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
|
||||
ifcopenshell.api.run("geometry.disconnect_path", self.file, relating_element=wall1, related_element=wall2)
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
|
||||
ifcopenshell.api.geometry.disconnect_path(self.file, relating_element=wall1, related_element=wall2)
|
||||
assert not self.file.by_type("IfcRelConnectsPathElements")
|
||||
|
||||
def test_disconnecting_by_connection_type(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"geometry.connect_path",
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_path(
|
||||
self.file,
|
||||
relating_element=wall1,
|
||||
related_element=wall2,
|
||||
relating_connection="ATSTART",
|
||||
related_connection="ATEND",
|
||||
)
|
||||
ifcopenshell.api.run("geometry.disconnect_path", self.file, element=wall1, connection_type="ATEND")
|
||||
ifcopenshell.api.geometry.disconnect_path(self.file, element=wall1, connection_type="ATEND")
|
||||
assert self.file.by_type("IfcRelConnectsPathElements")
|
||||
ifcopenshell.api.run("geometry.disconnect_path", self.file, element=wall1, connection_type="ATSTART")
|
||||
ifcopenshell.api.geometry.disconnect_path(self.file, element=wall1, connection_type="ATSTART")
|
||||
assert not self.file.by_type("IfcRelConnectsPathElements")
|
||||
ifcopenshell.api.run(
|
||||
"geometry.connect_path",
|
||||
ifcopenshell.api.geometry.connect_path(
|
||||
self.file,
|
||||
relating_element=wall1,
|
||||
related_element=wall2,
|
||||
relating_connection="ATSTART",
|
||||
related_connection="ATEND",
|
||||
)
|
||||
ifcopenshell.api.run("geometry.disconnect_path", self.file, element=wall2, connection_type="ATEND")
|
||||
ifcopenshell.api.geometry.disconnect_path(self.file, element=wall2, connection_type="ATEND")
|
||||
assert not self.file.by_type("IfcRelConnectsPathElements")
|
||||
|
||||
def test_doing_nothing_if_there_is_no_connection(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run("geometry.disconnect_path", self.file, relating_element=wall1, related_element=wall2)
|
||||
ifcopenshell.api.geometry.disconnect_path(self.file, relating_element=wall1, related_element=wall2)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_that_order_matters(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run("geometry.disconnect_path", self.file, relating_element=wall2, related_element=wall1)
|
||||
ifcopenshell.api.geometry.disconnect_path(self.file, relating_element=wall2, related_element=wall1)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
|
||||
|
||||
@@ -19,21 +19,27 @@
|
||||
import numpy
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.void
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.unit
|
||||
import ifcopenshell.api.system
|
||||
import ifcopenshell.api.spatial
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.placement
|
||||
|
||||
|
||||
class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
def test_attemping_to_edit_the_placement_of_an_invalid_element(self):
|
||||
project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
result = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=project)
|
||||
project = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
result = ifcopenshell.api.geometry.edit_object_placement(self.file, product=project)
|
||||
assert result is None
|
||||
|
||||
def test_setting_an_object_placement(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -42,15 +48,13 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
|
||||
def test_setting_an_object_placement_using_si_units(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -67,15 +71,15 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element, matrix=matrix, is_si=True)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix, is_si=True)
|
||||
assert numpy.array_equal(
|
||||
ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix_millimeters
|
||||
)
|
||||
|
||||
def test_changing_an_object_placement(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix1 = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -92,23 +96,19 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix1.copy(), is_si=False)
|
||||
created_element_ids = [e.id() for e in self.file.traverse(element.ObjectPlacement)]
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix2.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix2.copy(), is_si=False)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix2)
|
||||
for element_id in created_element_ids:
|
||||
with pytest.raises(RuntimeError):
|
||||
self.file.by_id(element_id)
|
||||
|
||||
def test_changing_an_object_placement_used_by_other_products(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix1 = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -125,21 +125,17 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix1.copy(), is_si=False)
|
||||
element2.ObjectPlacement = element.ObjectPlacement
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix2.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix2.copy(), is_si=False)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix2)
|
||||
assert element.ObjectPlacement != element2.ObjectPlacement
|
||||
|
||||
def test_changing_an_object_placement_partially_used_by_other_products(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix1 = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -156,24 +152,20 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix1.copy(), is_si=False)
|
||||
element2.ObjectPlacement = self.file.createIfcLocalPlacement(
|
||||
RelativePlacement=element.ObjectPlacement.RelativePlacement
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix2.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix2.copy(), is_si=False)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix2)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element2.ObjectPlacement), matrix1)
|
||||
|
||||
def test_changing_an_object_placement_shared_by_its_parent(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
matrix1 = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -190,22 +182,20 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix1.copy(), is_si=False)
|
||||
subelement.ObjectPlacement = element.ObjectPlacement
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=matrix2.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=matrix2.copy(), is_si=False
|
||||
)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo != subelement.ObjectPlacement
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), matrix2)
|
||||
assert element.ObjectPlacement != subelement.ObjectPlacement
|
||||
|
||||
def test_changing_placements_relative_to_a_spatial_container(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -222,22 +212,20 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_relative_to_an_aggregate(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -254,22 +242,20 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_relative_to_a_nest_parent(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
subelement = ifcopenshell.api.run("system.add_port", self.file, element=element)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
subelement = ifcopenshell.api.system.add_port(self.file, element=element)
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -286,23 +272,21 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_relative_to_a_voided_element(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
site = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[element], relating_structure=site)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
site = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[element], relating_structure=site)
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -319,26 +303,24 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=subelement, element=element)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=subelement, element=element)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_relative_to_an_opening(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
site = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSite")
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[wall], relating_structure=site)
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=site)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
site = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSite")
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[wall], relating_structure=site)
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=site)
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -355,19 +337,13 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=element, element=wall)
|
||||
ifcopenshell.api.run("void.add_filling", self.file, element=subelement, opening=element)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=site, matrix=numpy.eye(4), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=wall, matrix=numpy.eye(4), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=element, element=wall)
|
||||
ifcopenshell.api.void.add_filling(self.file, element=subelement, opening=element)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=site, matrix=numpy.eye(4), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=wall, matrix=numpy.eye(4), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
@@ -377,10 +353,10 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_relative_to_a_projected_element(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectionElement")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectionElement")
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -405,21 +381,19 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
"RelatedFeatureElement": subelement,
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_without_affecting_children(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -436,25 +410,23 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), submatrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_with_affecting_children(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -479,15 +451,12 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement",
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file,
|
||||
product=element,
|
||||
matrix=submatrix.copy(),
|
||||
@@ -501,10 +470,10 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_with_children_using_non_si_units(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1000.0),
|
||||
@@ -529,25 +498,21 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix_si.copy(), is_si=True
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix_si.copy(), is_si=True)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
|
||||
def test_changing_placements_always_affecting_child_ports_as_a_special_case(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
subelement = ifcopenshell.api.run("system.add_port", self.file, element=element)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
subelement = ifcopenshell.api.system.add_port(self.file, element=element)
|
||||
|
||||
matrix = numpy.eye(4)
|
||||
matrix[:3, 3] = (1, 1, 1)
|
||||
@@ -558,14 +523,13 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
shifted_submatrix = numpy.eye(4)
|
||||
shifted_submatrix[:3, 3] = (1, 3, 5)
|
||||
|
||||
previous_placement_id = ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
previous_placement_id = ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
).id()
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement",
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file,
|
||||
product=element,
|
||||
matrix=submatrix.copy(),
|
||||
@@ -582,10 +546,10 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
self.file.by_id(previous_placement_id)
|
||||
|
||||
def test_changing_placements_always_affecting_child_features_as_a_special_case(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
|
||||
matrix = numpy.eye(4)
|
||||
matrix[:3, 3] = (1, 1, 1)
|
||||
@@ -596,15 +560,14 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
shifted_submatrix = numpy.eye(4)
|
||||
shifted_submatrix[:3, 3] = (1, 3, 5)
|
||||
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=subelement, element=element)
|
||||
previous_placement_id = ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=subelement, element=element)
|
||||
previous_placement_id = ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
).id()
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement",
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file,
|
||||
product=element,
|
||||
matrix=submatrix.copy(),
|
||||
@@ -625,28 +588,27 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
(m := numpy.eye(4))[:3, 3] = translation
|
||||
return m
|
||||
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
|
||||
building = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
storey = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[storey], relating_object=building)
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[wall], relating_structure=storey)
|
||||
building = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
storey = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[storey], relating_object=building)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[wall], relating_structure=storey)
|
||||
|
||||
matrix = np_matrix_translation((1, 1, 1))
|
||||
submatrix = np_matrix_translation((1, 2, 3))
|
||||
building_placement_id = ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=building, matrix=matrix.copy(), is_si=False
|
||||
building_placement_id = ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=building, matrix=matrix.copy(), is_si=False
|
||||
).id()
|
||||
storey_placement_id = ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=storey, matrix=matrix.copy(), is_si=False
|
||||
storey_placement_id = ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=storey, matrix=matrix.copy(), is_si=False
|
||||
).id()
|
||||
wall_placement_id = ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=wall, matrix=matrix.copy(), is_si=False
|
||||
wall_placement_id = ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=wall, matrix=matrix.copy(), is_si=False
|
||||
).id()
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement",
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file,
|
||||
product=building,
|
||||
matrix=submatrix.copy(),
|
||||
@@ -664,10 +626,10 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
|
||||
class TestEditObjectPlacementIFC2X3(test.bootstrap.IFC2X3, TestEditObjectPlacement):
|
||||
def test_changing_placements_relative_to_a_distribution_element(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
subelement = ifcopenshell.api.run("system.add_port", self.file, element=element)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
subelement = ifcopenshell.api.system.add_port(self.file, element=element)
|
||||
matrix = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
@@ -684,11 +646,9 @@ class TestEditObjectPlacementIFC2X3(test.bootstrap.IFC2X3, TestEditObjectPlaceme
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy(), is_si=False
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy(), is_si=False)
|
||||
ifcopenshell.api.geometry.edit_object_placement(
|
||||
self.file, product=subelement, matrix=submatrix.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(subelement.ObjectPlacement), submatrix)
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.geometry
|
||||
|
||||
|
||||
class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
def test_removing_a_single_unused_shape_representation(self):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
|
||||
|
||||
def test_not_removing_a_shape_representation_in_use(self):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
self.file.createIfcProductRepresentation(Representations=[representation])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
|
||||
|
||||
def test_removing_a_mapped_representation_fully(self):
|
||||
@@ -44,7 +44,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
],
|
||||
)
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
|
||||
|
||||
def test_removing_only_the_representation_mapping_if_the_map_has_other_users(self):
|
||||
@@ -57,7 +57,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
Items=[self.file.createIfcMappedItem(MappingTarget=representation_map)],
|
||||
)
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
|
||||
assert self.file.by_type("IfcShapeRepresentation")[0].RepresentationType != "MappedRepresentation"
|
||||
assert len(self.file.by_type("IfcRepresentationMap")) == 1
|
||||
@@ -67,7 +67,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
surface_style = self.file.createIfcSurfaceStyle()
|
||||
styled_item = self.file.createIfcStyledItem(Item=item, Styles=[surface_style])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 0
|
||||
assert len(self.file.by_type("IfcSurfaceStyle")) == 1
|
||||
|
||||
@@ -76,13 +76,13 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
styled_item = self.file.createIfcStyledItem(Item=item)
|
||||
representation2 = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 1
|
||||
|
||||
def test_purging_representation_presentation_layers(self):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[representation])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 0
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
|
||||
|
||||
@@ -90,7 +90,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
representation2 = self.file.createIfcShapeRepresentation()
|
||||
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[representation, representation2])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 1
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
|
||||
|
||||
@@ -98,7 +98,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
item = self.file.createIfcExtrudedAreaSolid()
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[item])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 0
|
||||
assert len(self.file.by_type("IfcExtrudedAreaSolid")) == 0
|
||||
|
||||
@@ -107,21 +107,21 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
representation2 = self.file.createIfcShapeRepresentation(Items=[item2])
|
||||
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[item, item2])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 1
|
||||
assert len(self.file.by_type("IfcExtrudedAreaSolid")) == 1
|
||||
|
||||
def test_not_purging_geometric_representation_contexts(self):
|
||||
context = self.file.createIfcGeometricRepresentationSubContext()
|
||||
representation = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
|
||||
|
||||
def test_purging_colour_map(self):
|
||||
item = self.file.createIfcTriangulatedFaceSet()
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
colour = self.file.createIfcIndexedColourMap(Colours=self.file.createIfcColourRgbList(), MappedTo=item)
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcIndexedColourMap")) == 0
|
||||
assert len(self.file.by_type("IfcColourRgbList")) == 0
|
||||
|
||||
@@ -132,7 +132,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
texture = self.file.createIfcIndexedTriangleTextureMap(
|
||||
TexCoords=self.file.createIfcTextureVertexList(), MappedTo=item, Maps=[image]
|
||||
)
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcIndexedTriangleTextureMap")) == 0
|
||||
assert len(self.file.by_type("IfcTextureVertexList")) == 0
|
||||
assert len(self.file.by_type("IfcImageTexture")) == 0
|
||||
@@ -145,7 +145,7 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
TexCoords=self.file.createIfcTextureVertexList(), MappedTo=item, Maps=[image]
|
||||
)
|
||||
texture2 = self.file.createIfcIndexedTriangleTextureMap(Maps=[image])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
ifcopenshell.api.geometry.remove_representation(self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcIndexedTriangleTextureMap")) == 1
|
||||
assert len(self.file.by_type("IfcTextureVertexList")) == 0
|
||||
assert len(self.file.by_type("IfcImageTexture")) == 1
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import numpy
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.util.placement
|
||||
|
||||
|
||||
@@ -30,10 +28,10 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
wall = self.file.createIfcWall(
|
||||
Representation=self.file.createIfcProductDefinitionShape(Representations=[representation, representation2])
|
||||
)
|
||||
ifcopenshell.api.run("geometry.unassign_representation", self.file, product=wall, representation=representation)
|
||||
ifcopenshell.api.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
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=wall, representation=representation2
|
||||
)
|
||||
assert not wall.Representation
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
|
||||
@@ -44,8 +42,8 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
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
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=walltype, representation=representation
|
||||
)
|
||||
assert not walltype.RepresentationMaps
|
||||
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
|
||||
@@ -61,8 +59,8 @@ class TestUnassignRepresentation(test.bootstrap.IFC4):
|
||||
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
|
||||
ifcopenshell.api.geometry.unassign_representation(
|
||||
self.file, product=walltype, representation=representation
|
||||
)
|
||||
assert not walltype.RepresentationMaps
|
||||
assert len(self.file.by_type("IfcAxis2Placement3D")) == 0
|
||||
|
||||
@@ -17,20 +17,20 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.grid
|
||||
|
||||
|
||||
class TestCreateGridAxis(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
grid = self.file.createIfcGrid()
|
||||
axis = ifcopenshell.api.run(
|
||||
"grid.create_grid_axis", self.file, axis_tag="axis_tag", same_sense=True, uvw_axes="UAxes", grid=grid
|
||||
axis = ifcopenshell.api.grid.create_grid_axis(
|
||||
self.file, axis_tag="axis_tag", same_sense=True, uvw_axes="UAxes", grid=grid
|
||||
)
|
||||
assert axis.AxisTag == "axis_tag"
|
||||
assert axis.SameSense is True
|
||||
assert grid.UAxes == (axis,)
|
||||
axis2 = ifcopenshell.api.run(
|
||||
"grid.create_grid_axis", self.file, axis_tag="axis_tag", same_sense=True, uvw_axes="UAxes", grid=grid
|
||||
axis2 = ifcopenshell.api.grid.create_grid_axis(
|
||||
self.file, axis_tag="axis_tag", same_sense=True, uvw_axes="UAxes", grid=grid
|
||||
)
|
||||
assert grid.UAxes == (axis, axis2)
|
||||
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.group
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAddGroup(test.bootstrap.IFC4):
|
||||
def test_add_group_no_arguments(self):
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
assert group.Name == "Unnamed"
|
||||
assert group.Description == None
|
||||
|
||||
def test_add_group(self):
|
||||
group = ifcopenshell.api.run("group.add_group", self.file, name="Name", description="Description")
|
||||
group = ifcopenshell.api.group.add_group(self.file, name="Name", description="Description")
|
||||
assert group.Name == "Name"
|
||||
assert group.Description == "Description"
|
||||
|
||||
|
||||
@@ -17,27 +17,28 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.group
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAssignGroup(test.bootstrap.IFC4):
|
||||
def test_assign_group_for_multiple_elements(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
|
||||
# assign group for multiple elements
|
||||
ifcopenshell.api.run("group.assign_group", self.file, products=[element, element2], group=group)
|
||||
ifcopenshell.api.group.assign_group(self.file, products=[element, element2], group=group)
|
||||
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
|
||||
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(self.file.by_type("IfcWall"))
|
||||
|
||||
def test_reuse_existing_relationship(self):
|
||||
self.test_assign_group_for_multiple_elements()
|
||||
rel = self.file.by_type("IfcRelAssignsToGroup")[0]
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
group = self.file.by_type("IfcGroup")[0]
|
||||
ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
|
||||
ifcopenshell.api.group.assign_group(self.file, products=[element], group=group)
|
||||
|
||||
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
|
||||
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(self.file.by_type("IfcWall"))
|
||||
|
||||
@@ -17,27 +17,29 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.group
|
||||
|
||||
|
||||
class TestRemoveGroup(test.bootstrap.IFC4):
|
||||
def test_removing_a_group(self):
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
ifcopenshell.api.run("group.remove_group", self.file, group=group)
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
ifcopenshell.api.group.remove_group(self.file, group=group)
|
||||
assert len(self.file.by_type("IfcGroup")) == 0
|
||||
|
||||
def test_removing_orphaned_group_relationships(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
|
||||
ifcopenshell.api.run("group.remove_group", self.file, group=group)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
ifcopenshell.api.group.assign_group(self.file, products=[element], group=group)
|
||||
ifcopenshell.api.group.remove_group(self.file, group=group)
|
||||
assert not self.file.by_type("IfcRelAssignsToGroup")
|
||||
|
||||
def test_removing_orphaned_property_relationships(self):
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=group, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
ifcopenshell.api.run("group.remove_group", self.file, group=group)
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=group, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
ifcopenshell.api.group.remove_group(self.file, group=group)
|
||||
assert not self.file.by_type("IfcRelDefinesByProperties")
|
||||
assert not self.file.by_type("IfcPropertySet")
|
||||
assert not self.file.by_type("IfcPropertySingleValue")
|
||||
|
||||
@@ -17,17 +17,18 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.group
|
||||
|
||||
|
||||
class TestAssignGroup(test.bootstrap.IFC4):
|
||||
def test_group_unassignment(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
ifcopenshell.api.run("group.assign_group", self.file, products=[element, element2, element3], group=group)
|
||||
ifcopenshell.api.run("group.unassign_group", self.file, products=[element2, element3], group=group)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
ifcopenshell.api.group.assign_group(self.file, products=[element, element2, element3], group=group)
|
||||
ifcopenshell.api.group.unassign_group(self.file, products=[element2, element3], group=group)
|
||||
|
||||
assert len(rels := self.file.by_type("IfcRelAssignsToGroup")) == 1
|
||||
rel = rels[0]
|
||||
@@ -35,11 +36,11 @@ class TestAssignGroup(test.bootstrap.IFC4):
|
||||
assert rel.RelatedObjects == (element,)
|
||||
|
||||
def test_remove_relationship_unassigning_last_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
ifcopenshell.api.run("group.assign_group", self.file, products=[element, element2], group=group)
|
||||
ifcopenshell.api.run("group.unassign_group", self.file, products=[element, element2], group=group)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
ifcopenshell.api.group.assign_group(self.file, products=[element, element2], group=group)
|
||||
ifcopenshell.api.group.unassign_group(self.file, products=[element, element2], group=group)
|
||||
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 0
|
||||
|
||||
|
||||
|
||||
@@ -17,22 +17,23 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.group
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestUpdateGroupProductsIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_update_group_without_products(self):
|
||||
elements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") for i in range(4)]
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
ifcopenshell.api.run("group.update_group_products", self.file, products=elements, group=group)
|
||||
elements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") for i in range(4)]
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
ifcopenshell.api.group.update_group_products(self.file, products=elements, group=group)
|
||||
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(elements)
|
||||
|
||||
def test_update_group_products(self):
|
||||
elements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") for i in range(4)]
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
ifcopenshell.api.run("group.assign_group", self.file, products=elements[:2], group=group)
|
||||
ifcopenshell.api.run("group.update_group_products", self.file, products=elements[2:], group=group)
|
||||
elements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") for i in range(4)]
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
ifcopenshell.api.group.assign_group(self.file, products=elements[:2], group=group)
|
||||
ifcopenshell.api.group.update_group_products(self.file, products=elements[2:], group=group)
|
||||
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(elements[2:])
|
||||
assert ifcopenshell.util.element.get_groups(elements[0]) == []
|
||||
assert ifcopenshell.util.element.get_groups(elements[1]) == []
|
||||
@@ -41,13 +42,13 @@ class TestUpdateGroupProductsIFC2X3(test.bootstrap.IFC2X3):
|
||||
class TestUpdateGroupProductsIFC4(test.bootstrap.IFC4, TestUpdateGroupProductsIFC2X3):
|
||||
def test_update_group_products(self):
|
||||
# in ifc4 IfcGroup can have multiple rels
|
||||
elements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") for i in range(4)]
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
elements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") for i in range(4)]
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
|
||||
self.file.create_entity("IfcRelAssignsToGroup", RelatingGroup=group, RelatedObjects=elements[:1])
|
||||
self.file.create_entity("IfcRelAssignsToGroup", RelatingGroup=group, RelatedObjects=elements[1:2])
|
||||
|
||||
ifcopenshell.api.run("group.update_group_products", self.file, products=elements[2:], group=group)
|
||||
ifcopenshell.api.group.update_group_products(self.file, products=elements[2:], group=group)
|
||||
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
|
||||
assert set(ifcopenshell.util.element.get_grouped_by(group)) == set(elements[2:])
|
||||
assert ifcopenshell.util.element.get_groups(elements[0]) == []
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.layer
|
||||
|
||||
|
||||
class TestAddLayer(test.bootstrap.IFC4):
|
||||
def test_add_layer_no_arguments(self):
|
||||
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||
layer = ifcopenshell.api.layer.add_layer(self.file)
|
||||
assert layer.Name == "Unnamed"
|
||||
|
||||
def test_assign_additional_items(self):
|
||||
layer = ifcopenshell.api.run("layer.add_layer", self.file, name="Name")
|
||||
layer = ifcopenshell.api.layer.add_layer(self.file, name="Name")
|
||||
assert layer.Name == "Name"
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.layer
|
||||
|
||||
|
||||
class TestAssignLayer(test.bootstrap.IFC4):
|
||||
@@ -25,7 +25,7 @@ class TestAssignLayer(test.bootstrap.IFC4):
|
||||
items = [self.file.createIfcExtrudedAreaSolid() for i in range(2)]
|
||||
layer = self.file.createIfcPresentationLayerAssignment()
|
||||
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=items, layer=layer)
|
||||
ifcopenshell.api.layer.assign_layer(self.file, items=items, layer=layer)
|
||||
assert len(layer.AssignedItems) == 2
|
||||
assert set(layer.AssignedItems) == set(items)
|
||||
|
||||
@@ -33,8 +33,8 @@ class TestAssignLayer(test.bootstrap.IFC4):
|
||||
items = [self.file.createIfcExtrudedAreaSolid() for i in range(4)]
|
||||
layer = self.file.createIfcPresentationLayerAssignment()
|
||||
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=items[:2], layer=layer)
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=items[2:], layer=layer)
|
||||
ifcopenshell.api.layer.assign_layer(self.file, items=items[:2], layer=layer)
|
||||
ifcopenshell.api.layer.assign_layer(self.file, items=items[2:], layer=layer)
|
||||
assert len(layer.AssignedItems) == 4
|
||||
assert set(layer.AssignedItems) == set(items)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.layer
|
||||
|
||||
|
||||
class TestUnassignLayer(test.bootstrap.IFC4):
|
||||
@@ -25,8 +25,8 @@ class TestUnassignLayer(test.bootstrap.IFC4):
|
||||
items = [self.file.createIfcExtrudedAreaSolid() for i in range(3)]
|
||||
layer = self.file.createIfcPresentationLayerAssignment()
|
||||
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=items, layer=layer)
|
||||
ifcopenshell.api.run("layer.unassign_layer", self.file, items=items[2:], layer=layer)
|
||||
ifcopenshell.api.layer.assign_layer(self.file, items=items, layer=layer)
|
||||
ifcopenshell.api.layer.unassign_layer(self.file, items=items[2:], layer=layer)
|
||||
assert len(layer.AssignedItems) == 2
|
||||
assert set(layer.AssignedItems) == set(items[:2])
|
||||
|
||||
@@ -34,8 +34,8 @@ class TestUnassignLayer(test.bootstrap.IFC4):
|
||||
items = [self.file.createIfcExtrudedAreaSolid() for i in range(3)]
|
||||
layer = self.file.createIfcPresentationLayerAssignment()
|
||||
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=items, layer=layer)
|
||||
ifcopenshell.api.run("layer.unassign_layer", self.file, items=items, layer=layer)
|
||||
ifcopenshell.api.layer.assign_layer(self.file, items=items, layer=layer)
|
||||
ifcopenshell.api.layer.unassign_layer(self.file, items=items, layer=layer)
|
||||
assert not self.file.by_type("IfcPresentationLayerAssignment")
|
||||
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestAddLibrary(test.bootstrap.IFC4):
|
||||
def test_adding_a_library(self):
|
||||
library = ifcopenshell.api.run("library.add_library", self.file, name="Name")
|
||||
library = ifcopenshell.api.library.add_library(self.file, name="Name")
|
||||
assert library.is_a("IfcLibraryInformation")
|
||||
assert library.Name == "Name"
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestAddReference(test.bootstrap.IFC4):
|
||||
def test_adding_a_reference(self):
|
||||
library = ifcopenshell.api.run("library.add_library", self.file, name="Name")
|
||||
reference = ifcopenshell.api.run("library.add_reference", self.file, library=library)
|
||||
library = ifcopenshell.api.library.add_library(self.file, name="Name")
|
||||
reference = ifcopenshell.api.library.add_reference(self.file, library=library)
|
||||
assert reference.is_a("IfcLibraryReference")
|
||||
ifc2x3 = self.file.schema == "IFC2X3"
|
||||
if ifc2x3:
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestAssignReference(test.bootstrap.IFC4):
|
||||
@@ -26,17 +26,17 @@ class TestAssignReference(test.bootstrap.IFC4):
|
||||
product = self.file.createIfcWall()
|
||||
product2 = self.file.createIfcWall()
|
||||
product3 = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
|
||||
rel = self.file.by_type("IfcRelAssociatesLibrary")[0]
|
||||
assert rel.RelatedObjects == (product,)
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product2, product3], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product2, product3], reference=reference)
|
||||
assert set(rel.RelatedObjects) == set((product, product2, product3))
|
||||
|
||||
def test_not_assigning_twice(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
product = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
|
||||
rel = self.file.by_type("IfcRelAssociatesLibrary")[0]
|
||||
assert rel.RelatedObjects == (product,)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import test.bootstrap
|
||||
import datetime
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
import ifcopenshell.util.date
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ class TestEditLibrary(test.bootstrap.IFC4):
|
||||
attributes["Location"] = "Location"
|
||||
attributes["Description"] = "Description"
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"library.edit_library",
|
||||
ifcopenshell.api.library.edit_library(
|
||||
self.file,
|
||||
library=library,
|
||||
attributes=attributes,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestEditReference(test.bootstrap.IFC4):
|
||||
@@ -31,8 +31,7 @@ class TestEditReference(test.bootstrap.IFC4):
|
||||
if self.file.schema != "IFC2X3":
|
||||
attributes["Description"] = "Description"
|
||||
attributes["Language"] = "Language"
|
||||
ifcopenshell.api.run(
|
||||
"library.edit_reference",
|
||||
ifcopenshell.api.library.edit_reference(
|
||||
self.file,
|
||||
reference=reference,
|
||||
attributes=attributes,
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestRemoveLibrary(test.bootstrap.IFC4):
|
||||
def test_removing_a_library(self):
|
||||
library = self.file.createIfcLibraryInformation()
|
||||
ifcopenshell.api.run("library.remove_library", self.file, library=library)
|
||||
ifcopenshell.api.library.remove_library(self.file, library=library)
|
||||
assert len(self.file.by_type("IfcLibraryInformation")) == 0
|
||||
|
||||
def test_removing_a_library_and_all_references(self):
|
||||
@@ -38,7 +38,7 @@ class TestRemoveLibrary(test.bootstrap.IFC4):
|
||||
|
||||
self.file.createIfcRelAssociatesLibrary(GlobalId="foo", RelatingLibrary=library)
|
||||
self.file.createIfcRelAssociatesLibrary(GlobalId="bar", RelatingLibrary=reference1)
|
||||
ifcopenshell.api.run("library.remove_library", self.file, library=library)
|
||||
ifcopenshell.api.library.remove_library(self.file, library=library)
|
||||
assert len(self.file.by_type("IfcLibraryReference")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
|
||||
|
||||
class TestRemoveReference(test.bootstrap.IFC4):
|
||||
def test_removing_a_reference(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
product = self.file.createIfcWall()
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.run("library.remove_reference", self.file, reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=[product], reference=reference)
|
||||
ifcopenshell.api.library.remove_reference(self.file, reference=reference)
|
||||
assert len(self.file.by_type("IfcLibraryReference")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.library
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ class TestUnassignReference(test.bootstrap.IFC4):
|
||||
def test_unassigning_a_reference(self):
|
||||
reference = self.file.createIfcLibraryReference()
|
||||
products = [self.file.createIfcWall() for i in range(3)]
|
||||
ifcopenshell.api.run("library.assign_reference", self.file, products=products, reference=reference)
|
||||
ifcopenshell.api.run("library.unassign_reference", self.file, products=products[:1], reference=reference)
|
||||
ifcopenshell.api.library.assign_reference(self.file, products=products, reference=reference)
|
||||
ifcopenshell.api.library.unassign_reference(self.file, products=products[:1], reference=reference)
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == set(products[1:])
|
||||
|
||||
ifcopenshell.api.run("library.unassign_reference", self.file, products=products[1:], reference=reference)
|
||||
ifcopenshell.api.library.unassign_reference(self.file, products=products[1:], reference=reference)
|
||||
assert ifcopenshell.util.element.get_referenced_elements(reference) == set()
|
||||
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
|
||||
|
||||
|
||||
@@ -17,28 +17,28 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.material
|
||||
|
||||
|
||||
class TestAddMaterialSetIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_add_layer_set(self):
|
||||
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
|
||||
material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
|
||||
assert material.LayerSetName == "Unnamed"
|
||||
assert material.is_a("IfcMaterialLayerSet")
|
||||
|
||||
def test_add_list(self):
|
||||
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
|
||||
material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialList")
|
||||
assert material.is_a("IfcMaterialList")
|
||||
|
||||
|
||||
class TestAddMaterialSetIFC4(test.bootstrap.IFC4, TestAddMaterialSetIFC2X3):
|
||||
# entities added in IFC4
|
||||
def test_add_profile_set(self):
|
||||
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialProfileSet")
|
||||
material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialProfileSet")
|
||||
assert material.Name == "Unnamed"
|
||||
assert material.is_a("IfcMaterialProfileSet")
|
||||
|
||||
def test_add_constituent_set(self):
|
||||
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialConstituentSet")
|
||||
material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialConstituentSet")
|
||||
assert material.Name == "Unnamed"
|
||||
assert material.is_a("IfcMaterialConstituentSet")
|
||||
|
||||
@@ -16,48 +16,45 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.type
|
||||
import ifcopenshell.api.material
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_assign_element_single_material(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert ifcopenshell.util.element.get_material(element1) == material
|
||||
assert ifcopenshell.util.element.get_material(element2) == material
|
||||
|
||||
def test_raise_exception_creating_ifc_material_without(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterial", material=None
|
||||
)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterial", material=None)
|
||||
assert ifcopenshell.util.element.get_material(element)
|
||||
|
||||
def test_assign_type_single_material(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert ifcopenshell.util.element.get_material(element1) == material
|
||||
assert ifcopenshell.util.element.get_material(element2) == material
|
||||
|
||||
def test_assign_type_material_layer_set(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSet"
|
||||
)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element1, element2], type="IfcMaterialLayerSet")
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
material_set = ifcopenshell.util.element.get_material(element1)
|
||||
assert material_set.is_a("IfcMaterialLayerSet")
|
||||
@@ -65,15 +62,13 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert ifcopenshell.util.element.get_material(element2) == material_set
|
||||
|
||||
def test_assign_type_material_layer_set_and_element_layer_set_usage(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
material_set = ifcopenshell.util.element.get_material(element_type)
|
||||
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
|
||||
@@ -82,22 +77,18 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert ifcopenshell.util.element.get_material(element2, should_inherit=False) == material_usage1
|
||||
|
||||
def test_assign_type_material_layer_set_and_element_layer_set_usage_is_different_for_different_types(self):
|
||||
element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type1)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type1], type="IfcMaterialLayerSet"
|
||||
)
|
||||
element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type1)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type1], type="IfcMaterialLayerSet")
|
||||
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type2)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type2], type="IfcMaterialLayerSet"
|
||||
)
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type2)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type2], type="IfcMaterialLayerSet")
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
material_set1 = ifcopenshell.util.element.get_material(element_type1)
|
||||
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
|
||||
@@ -111,10 +102,10 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert material_usage2 != material_usage1
|
||||
|
||||
def test_assign_element_layer_set_usage_is_different_for_different_layer_set_directions(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
|
||||
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
|
||||
@@ -133,11 +124,10 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert material_usage1 != material_usage2
|
||||
|
||||
def test_assign_element_material_list(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material",
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file,
|
||||
products=[element1, element2],
|
||||
type="IfcMaterialList",
|
||||
@@ -152,10 +142,10 @@ class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
|
||||
class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
|
||||
def test_assign_type_material_profile_set(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSet"
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialProfileSet"
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
material_set = ifcopenshell.util.element.get_material(element1)
|
||||
@@ -164,17 +154,13 @@ class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
|
||||
assert ifcopenshell.util.element.get_material(element2) == material_set
|
||||
|
||||
def test_assign_type_material_profile_set_and_element_profile_set_usage(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type], type="IfcMaterialProfileSet"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
material_set = element_type.HasAssociations[0].RelatingMaterial
|
||||
material_usage1 = element1.HasAssociations[0].RelatingMaterial
|
||||
@@ -183,22 +169,18 @@ class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
|
||||
assert ifcopenshell.util.element.get_material(element2, should_inherit=False) == material_usage1
|
||||
|
||||
def test_assign_type_material_profile_set_and_element_profile_set_usage_is_different_for_different_types(self):
|
||||
element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type1)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type1], type="IfcMaterialProfileSet"
|
||||
)
|
||||
element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type1)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type1], type="IfcMaterialProfileSet")
|
||||
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type2)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type2], type="IfcMaterialProfileSet"
|
||||
)
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type2)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type2], type="IfcMaterialProfileSet")
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
material_set1 = ifcopenshell.util.element.get_material(element_type1)
|
||||
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
|
||||
@@ -212,10 +194,10 @@ class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
|
||||
assert material_usage2 != material_usage1
|
||||
|
||||
def test_assign_type_material_constituent_set(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
material_set = ifcopenshell.util.element.get_material(element1)
|
||||
|
||||
@@ -17,22 +17,26 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.style
|
||||
import ifcopenshell.api.context
|
||||
import ifcopenshell.api.material
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
def test_copy_a_single_material(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
new = ifcopenshell.api.material.copy_material(self.file, material=material)
|
||||
assert new.Name == "CON01"
|
||||
assert len(self.file.by_type("IfcMaterial")) == 2
|
||||
|
||||
def test_assignments_are_not_copied(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
|
||||
new = ifcopenshell.api.material.copy_material(self.file, material=material)
|
||||
assert ifcopenshell.util.element.get_elements_by_material(self.file, material)
|
||||
assert not ifcopenshell.util.element.get_elements_by_material(self.file, new)
|
||||
|
||||
@@ -42,10 +46,10 @@ class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
return material.HasProperties
|
||||
return [i for i in self.file.get_inverse(material) if i.is_a("IfcMaterialProperties")]
|
||||
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
|
||||
new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"foo": "bar"})
|
||||
new = ifcopenshell.api.material.copy_material(self.file, material=material)
|
||||
assert new.Name == "CON01"
|
||||
assert len(self.file.by_type("IfcMaterial")) == 2
|
||||
assert len(self.file.by_type("IfcMaterialProperties")) == 2
|
||||
@@ -60,12 +64,12 @@ class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
assert props_new.ExtendedProperties[0].NominalValue.wrappedValue == "bar"
|
||||
|
||||
def test_copy_a_material_with_a_style_representation(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
style = ifcopenshell.api.run("style.add_style", self.file)
|
||||
ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
|
||||
new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
style = ifcopenshell.api.style.add_style(self.file)
|
||||
ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
|
||||
new = ifcopenshell.api.material.copy_material(self.file, material=material)
|
||||
assert new.Name == "CON01"
|
||||
assert len(self.file.by_type("IfcPresentationStyle")) == 1
|
||||
assert len(self.file.by_type("IfcMaterialDefinitionRepresentation")) == 2
|
||||
@@ -74,15 +78,13 @@ class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
assert new.HasRepresentation[0].Representations[0].ContextOfItems == context
|
||||
|
||||
def test_copy_a_material_constituent_set(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
material_set = ifcopenshell.api.run(
|
||||
"material.add_material_set", self.file, name="Foo", set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
item = ifcopenshell.api.run(
|
||||
"material.add_constituent", self.file, constituent_set=material_set, material=material
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, name="Foo", set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
item = ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
|
||||
|
||||
new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
|
||||
new = ifcopenshell.api.material.copy_material(self.file, material=material_set)
|
||||
assert new != material_set
|
||||
assert new.Name == "Foo"
|
||||
assert new.MaterialConstituents[0] != item
|
||||
@@ -92,13 +94,11 @@ class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
|
||||
def test_copy_a_material_layer_set(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
material_set = ifcopenshell.api.run(
|
||||
"material.add_material_set", self.file, name="Foo", set_type="IfcMaterialLayerSet"
|
||||
)
|
||||
item = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, name="Foo", set_type="IfcMaterialLayerSet")
|
||||
item = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
|
||||
new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
|
||||
new = ifcopenshell.api.material.copy_material(self.file, material=material_set)
|
||||
assert new != material_set
|
||||
assert new.LayerSetName == "Foo"
|
||||
assert new.MaterialLayers[0] != item
|
||||
@@ -108,7 +108,7 @@ class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
|
||||
def test_copy_a_material_profile_set(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
profile = self.file.create_entity(
|
||||
"IfcIShapeProfileDef",
|
||||
ProfileName="HEA100",
|
||||
@@ -119,14 +119,14 @@ class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
FlangeThickness=8,
|
||||
FilletRadius=12,
|
||||
)
|
||||
material_set = ifcopenshell.api.run(
|
||||
"material.add_material_set", self.file, name="Foo", set_type="IfcMaterialProfileSet"
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, name="Foo", set_type="IfcMaterialProfileSet"
|
||||
)
|
||||
item = ifcopenshell.api.run(
|
||||
"material.add_profile", self.file, profile_set=material_set, material=material, profile=profile
|
||||
item = ifcopenshell.api.material.add_profile(
|
||||
self.file, profile_set=material_set, material=material, profile=profile
|
||||
)
|
||||
|
||||
new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
|
||||
new = ifcopenshell.api.material.copy_material(self.file, material=material_set)
|
||||
assert new != material_set
|
||||
assert new.Name == "Foo"
|
||||
assert new.MaterialProfiles[0] != item
|
||||
@@ -138,11 +138,11 @@ class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcProfileDef")) == 1
|
||||
|
||||
def test_copy_a_material_list(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
|
||||
ifcopenshell.api.run("material.add_list_item", self.file, material_list=material_set, material=material)
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialList")
|
||||
ifcopenshell.api.material.add_list_item(self.file, material_list=material_set, material=material)
|
||||
|
||||
new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
|
||||
new = ifcopenshell.api.material.copy_material(self.file, material=material_set)
|
||||
assert new != material_set
|
||||
assert new.Materials[0] == material
|
||||
assert len(self.file.by_type("IfcMaterialList")) == 2
|
||||
|
||||
@@ -17,58 +17,62 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.style
|
||||
import ifcopenshell.api.context
|
||||
import ifcopenshell.api.material
|
||||
|
||||
|
||||
class TestRemoveMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_removing_material(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
ifcopenshell.api.material.remove_material(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
|
||||
def test_removing_material_with_associations(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material)
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material)
|
||||
ifcopenshell.api.material.remove_material(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
|
||||
def test_removing_material_in_layer(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialLayerSet")[0].MaterialLayers) == 1
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
ifcopenshell.api.material.remove_material(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert len(self.file.by_type("IfcMaterialLayerSet")[0].MaterialLayers) == 0
|
||||
|
||||
def test_removing_material_in_list(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
|
||||
ifcopenshell.api.run("material.add_list_item", self.file, material_list=material_set, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialList")
|
||||
ifcopenshell.api.material.add_list_item(self.file, material_list=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialList")[0].Materials) == 1
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
ifcopenshell.api.material.remove_material(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert len(self.file.by_type("IfcMaterialList")[0].Materials) == 0
|
||||
|
||||
def test_removing_a_material_with_a_style_definition(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
style = ifcopenshell.api.run("style.add_style", self.file)
|
||||
ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
style = ifcopenshell.api.style.add_style(self.file)
|
||||
ifcopenshell.api.style.assign_material_style(self.file, material=material, style=style, context=context)
|
||||
assert len(self.file.by_type("IfcMaterialDefinitionRepresentation")) == 1
|
||||
assert len(self.file.by_type("IfcStyledRepresentation")) == 1
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 1
|
||||
assert len(self.file.by_type("IfcSurfaceStyle")) == 1
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
ifcopenshell.api.material.remove_material(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcMaterialDefinitionRepresentation")) == 0
|
||||
assert len(self.file.by_type("IfcStyledRepresentation")) == 0
|
||||
@@ -81,11 +85,11 @@ class TestRemoveMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
return material.HasProperties
|
||||
return [i for i in self.file.get_inverse(material) if i.is_a("IfcMaterialProperties")]
|
||||
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
assert get_material_props(material)
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
ifcopenshell.api.material.remove_material(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterialProperties")) == 0
|
||||
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
|
||||
|
||||
@@ -93,27 +97,27 @@ class TestRemoveMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
class TestRemoveMaterialIFC4(test.bootstrap.IFC4, TestRemoveMaterialIFC2X3):
|
||||
# IfcMaterialProfileSet added in IFC4
|
||||
def test_removing_material_in_profile(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.run("material.add_profile", self.file, profile_set=material_set, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.material.add_profile(self.file, profile_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialProfileSet")[0].MaterialProfiles) == 1
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
ifcopenshell.api.material.remove_material(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert len(self.file.by_type("IfcMaterialProfileSet")[0].MaterialProfiles) == 0
|
||||
|
||||
def test_removing_material_in_constituent(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
material_set = ifcopenshell.api.run(
|
||||
"material.add_material_set", self.file, set_type="IfcMaterialConstituentSet"
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(
|
||||
self.file, set_type="IfcMaterialConstituentSet"
|
||||
)
|
||||
ifcopenshell.api.run("material.add_constituent", self.file, constituent_set=material_set, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
|
||||
ifcopenshell.api.material.add_constituent(self.file, constituent_set=material_set, material=material)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents) == 1
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
ifcopenshell.api.material.remove_material(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents is None
|
||||
|
||||
@@ -17,28 +17,30 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.material
|
||||
|
||||
|
||||
class TestRemoveMaterialSetIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_removing_material_set(self):
|
||||
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.remove_material_set", self.file, material=material)
|
||||
material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.remove_material_set(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterialLayerSet")) == 0
|
||||
|
||||
def test_removing_material_set_with_associations(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material)
|
||||
ifcopenshell.api.run("material.remove_material_set", self.file, material=material)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[wall], material=material)
|
||||
ifcopenshell.api.material.remove_material_set(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterialLayerSet")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
|
||||
def test_removing_a_material_set_with_set_items_but_preserving_materials(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
|
||||
ifcopenshell.api.run("material.remove_material_set", self.file, material=material_set)
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
material_set = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material)
|
||||
ifcopenshell.api.material.remove_material_set(self.file, material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialLayerSet")) == 0
|
||||
assert len(self.file.by_type("IfcMaterialLayer")) == 0
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
@@ -47,10 +49,10 @@ class TestRemoveMaterialSetIFC2X3(test.bootstrap.IFC2X3):
|
||||
class TestRemoveMaterialSetIFC4(test.bootstrap.IFC4, TestRemoveMaterialSetIFC2X3):
|
||||
# IFC2X3 doesn't support adding a pset to IfcMaterialLayerSet
|
||||
def test_removing_a_material_set_with_properties(self):
|
||||
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
material = ifcopenshell.api.material.add_material_set(self.file, set_type="IfcMaterialLayerSet")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
assert material.HasProperties
|
||||
ifcopenshell.api.run("material.remove_material_set", self.file, material=material)
|
||||
ifcopenshell.api.material.remove_material_set(self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterialProperties")) == 0
|
||||
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
|
||||
|
||||
@@ -17,31 +17,33 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.type
|
||||
import ifcopenshell.api.material
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_unassign_single_material(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcWall")) == 2
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
|
||||
def test_unassign_single_material_with_multiple_elements(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element2])
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element2])
|
||||
assert element1.HasAssociations
|
||||
assert not element2.HasAssociations
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
@@ -49,28 +51,24 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
|
||||
def test_unassign_material_layer_set_from_type(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSet"
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element1, element2], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcWallType")) == 2
|
||||
assert len(self.file.by_type("IfcMaterialLayerSet")) == 1
|
||||
|
||||
def test_unassign_material_layer_set_usage_from_element(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert element_type.HasAssociations
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
@@ -79,20 +77,14 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert len(self.file.by_type("IfcMaterialLayerSetUsage")) == 0
|
||||
|
||||
def test_unassign_material_layer_set_usage_shouldnt_remove_other_usages_of_the_type(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element1])
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element1], type="IfcMaterialLayerSetUsage")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element2], type="IfcMaterialLayerSetUsage")
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element1])
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 2
|
||||
assert element_type.HasAssociations
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
@@ -101,20 +93,18 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert len(self.file.by_type("IfcMaterialLayerSetUsage")) == 1
|
||||
|
||||
def test_unassign_material_layer_set_usage_from_element_with_multiple_invalid_usages(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.material.assign_material(self.file, products=[element], type="IfcMaterialLayerSetUsage")
|
||||
|
||||
# In some invalid IFCs from Revit, they reuse usages. Let's recreate this invalid scenario
|
||||
rel.RelatedObjects = list(rel.RelatedObjects) + [element2]
|
||||
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element])
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element])
|
||||
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 2
|
||||
for rel in self.file.by_type("IfcRelAssociatesMaterial"):
|
||||
@@ -128,22 +118,21 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert ifcopenshell.util.element.get_material(element2, should_inherit=False).is_a("IfcMaterialLayerSetUsage")
|
||||
|
||||
def test_unassign_element_material_list(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material1 = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material",
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material1 = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file,
|
||||
products=[element1, element2],
|
||||
type="IfcMaterialList",
|
||||
material=material1,
|
||||
)
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material3 = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element3], type="IfcMaterialList", material=material3
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material3 = ifcopenshell.api.material.add_material(self.file, name="CON01")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element3], type="IfcMaterialList", material=material3
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2, element3])
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2, element3])
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcMaterialList")) == 2
|
||||
assert len(self.file.by_type("IfcMaterial")) == 2
|
||||
@@ -152,29 +141,25 @@ class TestUnassignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
class TestUnassignMaterialIFC4(test.bootstrap.IFC4, TestUnassignMaterialIFC2X3):
|
||||
|
||||
def test_unassign_material_profile_set_from_type(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element1], type="IfcMaterialProfileSet")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element2], type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element1], type="IfcMaterialProfileSet")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element2], type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcWallType")) == 2
|
||||
assert len(self.file.by_type("IfcMaterialProfileSet")) == 2
|
||||
|
||||
def test_unassign_material_profile_set_usage_from_element(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1, element2], relating_type=element_type)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element_type], type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type], type="IfcMaterialProfileSet"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2])
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2])
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert element_type.HasAssociations
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
@@ -183,16 +168,14 @@ class TestUnassignMaterialIFC4(test.bootstrap.IFC4, TestUnassignMaterialIFC2X3):
|
||||
assert len(self.file.by_type("IfcMaterialProfileSetUsage")) == 0
|
||||
|
||||
def test_unassign_material_constituent_set_from_type(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.material.assign_material(
|
||||
self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
|
||||
)
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element3], type="IfcMaterialConstituentSet"
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, products=[element1, element2, element3])
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element3], type="IfcMaterialConstituentSet")
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[element1, element2, element3])
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcWallType")) == 3
|
||||
assert len(self.file.by_type("IfcMaterialConstituentSet")) == 2
|
||||
|
||||
@@ -18,68 +18,69 @@
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.nest
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.placement
|
||||
|
||||
|
||||
class TestAssignObject(test.bootstrap.IFC4):
|
||||
def test_assigning_a_nesting(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
rel = ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_objects=[subelement1, subelement2], relating_object=element
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
rel = ifcopenshell.api.nest.assign_object(
|
||||
self.file, related_objects=[subelement1, subelement2], relating_object=element
|
||||
)
|
||||
assert ifcopenshell.util.element.get_nest(subelement1) == element
|
||||
assert ifcopenshell.util.element.get_nest(subelement2) == element
|
||||
assert rel.is_a("IfcRelNests")
|
||||
|
||||
def test_doing_nothing_if_the_nesting_is_already_assigned(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_that_old_nesting_relationships_are_updated_if_they_still_have_elements(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_objects=[subelement1, subelement2], relating_object=element1
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
self.file, related_objects=[subelement1, subelement2], relating_object=element1
|
||||
)
|
||||
rel = subelement1.Decomposes[0] if self.file.schema == "IFC2X3" else subelement1.Nests[0]
|
||||
assert len(rel.RelatedObjects) == 2
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement1], relating_object=element2)
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement1], relating_object=element2)
|
||||
assert len(rel.RelatedObjects) == 1
|
||||
|
||||
def test_that_old_nesting_relationships_are_purged_if_no_more_elements_are_nested(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement1], relating_object=element1)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement1], relating_object=element1)
|
||||
rel_id = (subelement1.Decomposes[0] if self.file.schema == "IFC2X3" else subelement1.Nests[0]).id()
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement1], relating_object=element2)
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement1], relating_object=element2)
|
||||
with pytest.raises(RuntimeError):
|
||||
self.file.by_id(rel_id)
|
||||
|
||||
def test_maintain_assignment_order_in_related_objects(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask") for _ in range(5)]
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask") for _ in range(5)]
|
||||
for i in range(5):
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_objects=subelements[: i + 1], relating_object=element
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
self.file, related_objects=subelements[: i + 1], relating_object=element
|
||||
)
|
||||
rel = self.file.by_type("IfcRelNests")[0]
|
||||
assert rel.RelatedObjects == tuple(subelements[: i + 1])
|
||||
|
||||
# maintain the order in the affected relationships too
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_objects=subelements[2:3], relating_object=element2
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
self.file, related_objects=subelements[2:3], relating_object=element2
|
||||
)
|
||||
assert rel.RelatedObjects == tuple(subelements[:2] + subelements[3:])
|
||||
|
||||
|
||||
@@ -16,43 +16,43 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.nest
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestUnassignObject(test.bootstrap.IFC4):
|
||||
def test_unassigning_an_object(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.run(
|
||||
"nest.assign_object", self.file, related_objects=[subelement1, subelement2], relating_object=element
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(
|
||||
self.file, related_objects=[subelement1, subelement2], relating_object=element
|
||||
)
|
||||
ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=[subelement1, subelement2])
|
||||
ifcopenshell.api.nest.unassign_object(self.file, related_objects=[subelement1, subelement2])
|
||||
assert ifcopenshell.util.element.get_nest(subelement1) is None
|
||||
assert ifcopenshell.util.element.get_nest(subelement2) is None
|
||||
|
||||
def test_the_rel_is_kept_if_there_are_more_nested_elements(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement1], relating_object=element)
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement2], relating_object=element)
|
||||
ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=[subelement1])
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement1], relating_object=element)
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement2], relating_object=element)
|
||||
ifcopenshell.api.nest.unassign_object(self.file, related_objects=[subelement1])
|
||||
assert len(self.file.by_type("IfcRelNests")) == 1
|
||||
|
||||
def test_the_rel_is_purged_if_there_are_no_more_nested_elements(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
|
||||
ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=[subelement])
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
|
||||
ifcopenshell.api.nest.unassign_object(self.file, related_objects=[subelement])
|
||||
assert len(self.file.by_type("IfcRelNests")) == 0
|
||||
|
||||
def test_maintain_assignment_order_in_related_objects(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask")
|
||||
subelements = [ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcTask") for _ in range(5)]
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask")
|
||||
subelements = [ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcTask") for _ in range(5)]
|
||||
rel = self.file.create_entity("IfcRelNests", RelatingObject=element, RelatedObjects=subelements)
|
||||
|
||||
original_order = subelements.copy()
|
||||
@@ -61,7 +61,7 @@ class TestUnassignObject(test.bootstrap.IFC4):
|
||||
removed_elements = set()
|
||||
for i in (0, 3, 2, 4):
|
||||
subelement = subelements[i]
|
||||
ifcopenshell.api.run("nest.unassign_object", self.file, related_objects=[subelement])
|
||||
ifcopenshell.api.nest.unassign_object(self.file, related_objects=[subelement])
|
||||
removed_elements.add(subelement)
|
||||
assert rel.RelatedObjects == tuple([o for o in original_order if o not in removed_elements])
|
||||
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestAddActor(test.bootstrap.IFC4):
|
||||
def test_adding_an_actor(self):
|
||||
person = self.file.createIfcPerson()
|
||||
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
|
||||
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
|
||||
assert actor.is_a() == "IfcActor"
|
||||
assert actor.TheActor == person
|
||||
|
||||
def test_adding_an_occupant(self):
|
||||
person = self.file.createIfcPerson()
|
||||
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcOccupant", actor=person)
|
||||
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcOccupant", actor=person)
|
||||
assert actor.is_a() == "IfcOccupant"
|
||||
assert actor.TheActor == person
|
||||
|
||||
|
||||
@@ -17,18 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestAddAddress(test.bootstrap.IFC4):
|
||||
def test_adding_to_a_person(self):
|
||||
person = self.file.createIfcPerson()
|
||||
postal = ifcopenshell.api.run(
|
||||
"owner.add_address", self.file, assigned_object=person, ifc_class="IfcPostalAddress"
|
||||
)
|
||||
telecom = ifcopenshell.api.run(
|
||||
"owner.add_address", self.file, assigned_object=person, ifc_class="IfcTelecomAddress"
|
||||
)
|
||||
postal = ifcopenshell.api.owner.add_address(self.file, assigned_object=person, ifc_class="IfcPostalAddress")
|
||||
telecom = ifcopenshell.api.owner.add_address(self.file, assigned_object=person, ifc_class="IfcTelecomAddress")
|
||||
assert postal.is_a("IfcPostalAddress")
|
||||
assert telecom.is_a("IfcTelecomAddress")
|
||||
assert postal.Purpose == telecom.Purpose == "OFFICE"
|
||||
@@ -37,11 +33,11 @@ class TestAddAddress(test.bootstrap.IFC4):
|
||||
|
||||
def test_adding_to_a_organisation(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
postal = ifcopenshell.api.run(
|
||||
"owner.add_address", self.file, assigned_object=organisation, ifc_class="IfcPostalAddress"
|
||||
postal = ifcopenshell.api.owner.add_address(
|
||||
self.file, assigned_object=organisation, ifc_class="IfcPostalAddress"
|
||||
)
|
||||
telecom = ifcopenshell.api.run(
|
||||
"owner.add_address", self.file, assigned_object=organisation, ifc_class="IfcTelecomAddress"
|
||||
telecom = ifcopenshell.api.owner.add_address(
|
||||
self.file, assigned_object=organisation, ifc_class="IfcTelecomAddress"
|
||||
)
|
||||
assert postal.is_a("IfcPostalAddress")
|
||||
assert telecom.is_a("IfcTelecomAddress")
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestAddApplication(test.bootstrap.IFC4):
|
||||
def test_adding_the_ifcopenshell_application(self):
|
||||
application = ifcopenshell.api.run("owner.add_application", self.file)
|
||||
application = ifcopenshell.api.owner.add_application(self.file)
|
||||
developer = application.ApplicationDeveloper
|
||||
assert application.Version == ifcopenshell.version
|
||||
assert application.ApplicationFullName == "IfcOpenShell"
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestAddOrganisation(test.bootstrap.IFC4):
|
||||
def test_adding_an_organisation(self):
|
||||
org = ifcopenshell.api.run("owner.add_organisation", self.file, identification="Id", name="Name")
|
||||
org = ifcopenshell.api.owner.add_organisation(self.file, identification="Id", name="Name")
|
||||
# 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
|
||||
assert org[0] == "Id"
|
||||
assert org.Name == "Name"
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestAddPerson(test.bootstrap.IFC4):
|
||||
def test_adding_a_person(self):
|
||||
person = ifcopenshell.api.run(
|
||||
"owner.add_person",
|
||||
person = ifcopenshell.api.owner.add_person(
|
||||
self.file,
|
||||
identification="Identification",
|
||||
family_name="FamilyName",
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestAddPersonAndOrganisation(test.bootstrap.IFC4):
|
||||
def test_adding(self):
|
||||
person = self.file.createIfcPerson()
|
||||
organisation = self.file.createIfcOrganization()
|
||||
person_and_organisation = ifcopenshell.api.run(
|
||||
"owner.add_person_and_organisation", self.file, person=person, organisation=organisation
|
||||
ifcopenshell.api.owner.add_person_and_organisation(
|
||||
self.file, person=person, organisation=organisation
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -17,20 +17,20 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestAddRole(test.bootstrap.IFC4):
|
||||
def test_adding_a_role_to_a_person(self):
|
||||
person = self.file.createIfcPerson()
|
||||
role = ifcopenshell.api.run("owner.add_role", self.file, assigned_object=person)
|
||||
role = ifcopenshell.api.owner.add_role(self.file, assigned_object=person)
|
||||
assert role.is_a("IfcActorRole")
|
||||
assert role.Role == "ARCHITECT"
|
||||
assert person.Roles == (role,)
|
||||
|
||||
def test_adding_a_role_to_an_organisation(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
role = ifcopenshell.api.run("owner.add_role", self.file, assigned_object=organisation)
|
||||
role = ifcopenshell.api.owner.add_role(self.file, assigned_object=organisation)
|
||||
assert role.is_a("IfcActorRole")
|
||||
assert role.Role == "ARCHITECT"
|
||||
assert organisation.Roles == (role,)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestAssignActor(test.bootstrap.IFC4):
|
||||
@@ -25,16 +25,16 @@ class TestAssignActor(test.bootstrap.IFC4):
|
||||
wall = self.file.createIfcWall()
|
||||
wall2 = self.file.createIfcWall()
|
||||
actor = self.file.createIfcActor()
|
||||
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
|
||||
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
|
||||
assert actor.IsActingUpon[0].RelatedObjects == (wall,)
|
||||
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall2)
|
||||
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall2)
|
||||
assert actor.IsActingUpon[0].RelatedObjects == (wall, wall2)
|
||||
|
||||
def test_not_assigning_twice(self):
|
||||
wall = self.file.createIfcWall()
|
||||
actor = self.file.createIfcActor()
|
||||
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
|
||||
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
|
||||
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
|
||||
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
|
||||
assert actor.IsActingUpon[0].RelatedObjects == (wall,)
|
||||
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ import ifcopenshell.api.owner.settings
|
||||
class TestCreateOwnerHistory(test.bootstrap.IFC4):
|
||||
def test_creating_nothing_if_no_user_or_application_is_available(self):
|
||||
if self.file.schema != "IFC2X3":
|
||||
history = ifcopenshell.api.run("owner.create_owner_history", self.file)
|
||||
history = ifcopenshell.api.owner.create_owner_history(self.file)
|
||||
assert history is None
|
||||
else:
|
||||
ifcopenshell.api.owner.settings.factory_reset()
|
||||
# create new file as bootstrap is creating users in ifc2x3 by default
|
||||
file = ifcopenshell.file(schema="IFC2X3")
|
||||
with pytest.raises(Exception) as e:
|
||||
ifcopenshell.api.run("owner.create_owner_history", file)
|
||||
ifcopenshell.api.owner.create_owner_history(file)
|
||||
assert "Please create a user to continue" in str(e.value)
|
||||
ifcopenshell.api.owner.settings.restore()
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestCreateOwnerHistory(test.bootstrap.IFC4):
|
||||
application = self.file.createIfcApplication()
|
||||
ifcopenshell.api.owner.settings.get_user = lambda x: user
|
||||
ifcopenshell.api.owner.settings.get_application = lambda x: application
|
||||
history = ifcopenshell.api.run("owner.create_owner_history", self.file)
|
||||
history = ifcopenshell.api.owner.create_owner_history(self.file)
|
||||
ifcopenshell.api.owner.settings.restore()
|
||||
|
||||
assert history.is_a("IfcOwnerHistory")
|
||||
|
||||
@@ -17,15 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestEditActor(test.bootstrap.IFC4):
|
||||
def test_editing_an_actor(self):
|
||||
person = self.file.createIfcPerson()
|
||||
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
|
||||
ifcopenshell.api.run(
|
||||
"owner.edit_actor",
|
||||
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
|
||||
ifcopenshell.api.owner.edit_actor(
|
||||
self.file,
|
||||
actor=actor,
|
||||
attributes={"Name": "Name", "Description": "Description", "ObjectType": "ObjectType"},
|
||||
@@ -36,9 +35,8 @@ class TestEditActor(test.bootstrap.IFC4):
|
||||
|
||||
def test_editing_an_occupant(self):
|
||||
person = self.file.createIfcPerson()
|
||||
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcOccupant", actor=person)
|
||||
ifcopenshell.api.run(
|
||||
"owner.edit_actor",
|
||||
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcOccupant", actor=person)
|
||||
ifcopenshell.api.owner.edit_actor(
|
||||
self.file,
|
||||
actor=actor,
|
||||
attributes={
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestEditAddress(test.bootstrap.IFC4):
|
||||
def test_editing_a_postal_address(self):
|
||||
address = self.file.createIfcPostalAddress()
|
||||
ifcopenshell.api.run(
|
||||
"owner.edit_address",
|
||||
ifcopenshell.api.owner.edit_address(
|
||||
self.file,
|
||||
address=address,
|
||||
attributes={
|
||||
@@ -66,8 +65,7 @@ class TestEditAddress(test.bootstrap.IFC4):
|
||||
if self.file.schema != "IFC2X3":
|
||||
attributes["MessagingIDs"] = ["Messaging", "IDs"]
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"owner.edit_address",
|
||||
ifcopenshell.api.owner.edit_address(
|
||||
self.file,
|
||||
address=address,
|
||||
attributes=attributes,
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestEditOrganisation(test.bootstrap.IFC4):
|
||||
def test_editing_a_organisation(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
ifcopenshell.api.run(
|
||||
"owner.edit_organisation",
|
||||
ifcopenshell.api.owner.edit_organisation(
|
||||
self.file,
|
||||
organisation=organisation,
|
||||
attributes={
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestEditPerson(test.bootstrap.IFC4):
|
||||
def test_editing_a_person(self):
|
||||
person = self.file.createIfcPerson()
|
||||
ifcopenshell.api.run(
|
||||
"owner.edit_person",
|
||||
ifcopenshell.api.owner.edit_person(
|
||||
self.file,
|
||||
person=person,
|
||||
attributes={
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestEditRole(test.bootstrap.IFC4):
|
||||
def test_editing_a_role(self):
|
||||
role = self.file.createIfcActorRole()
|
||||
ifcopenshell.api.run(
|
||||
"owner.edit_role",
|
||||
ifcopenshell.api.owner.edit_role(
|
||||
self.file,
|
||||
role=role,
|
||||
attributes={"Role": "ARCHITECT", "UserDefinedRole": "UserDefinedRole", "Description": "Description"},
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestRemoveActor(test.bootstrap.IFC4):
|
||||
def test_removing_an_actor(self):
|
||||
person = self.file.createIfcPerson()
|
||||
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
|
||||
ifcopenshell.api.run("owner.remove_actor", self.file, actor=actor)
|
||||
actor = ifcopenshell.api.owner.add_actor(self.file, ifc_class="IfcActor", actor=person)
|
||||
ifcopenshell.api.owner.remove_actor(self.file, actor=actor)
|
||||
assert len(self.file.by_type("IfcActor")) == 0
|
||||
|
||||
|
||||
|
||||
@@ -17,29 +17,29 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestRemoveAddress(test.bootstrap.IFC4):
|
||||
def test_removing_an_address(self):
|
||||
postal = self.file.createIfcPostalAddress()
|
||||
telecom = self.file.createIfcTelecomAddress()
|
||||
ifcopenshell.api.run("owner.remove_address", self.file, address=postal)
|
||||
ifcopenshell.api.run("owner.remove_address", self.file, address=telecom)
|
||||
ifcopenshell.api.owner.remove_address(self.file, address=postal)
|
||||
ifcopenshell.api.owner.remove_address(self.file, address=telecom)
|
||||
assert len(self.file.by_type("IfcAddress")) == 0
|
||||
|
||||
def test_ensuring_organisation_cardinality_is_valid(self):
|
||||
address = self.file.createIfcPostalAddress()
|
||||
organisation = self.file.createIfcOrganization()
|
||||
organisation.Addresses = [address]
|
||||
ifcopenshell.api.run("owner.remove_address", self.file, address=address)
|
||||
ifcopenshell.api.owner.remove_address(self.file, address=address)
|
||||
assert organisation.Addresses is None
|
||||
|
||||
def test_ensuring_person_cardinality_is_valid(self):
|
||||
address = self.file.createIfcPostalAddress()
|
||||
person = self.file.createIfcPerson()
|
||||
person.Addresses = [address]
|
||||
ifcopenshell.api.run("owner.remove_address", self.file, address=address)
|
||||
ifcopenshell.api.owner.remove_address(self.file, address=address)
|
||||
assert person.Addresses is None
|
||||
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_removing_a_organisation(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcOrganization")) == 0
|
||||
|
||||
def test_removing_roles_and_addresses_only_used_by_the_organisation(self):
|
||||
@@ -33,7 +33,7 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
organisation.Roles = [role]
|
||||
organisation.Addresses = [address]
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcOrganization")) == 0
|
||||
assert len(self.file.by_type("IfcActorRole")) == 0
|
||||
assert len(self.file.by_type("IfcPostalAddress")) == 0
|
||||
@@ -47,7 +47,7 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
|
||||
organisation.Addresses = [address]
|
||||
organisation2.Roles = [role]
|
||||
organisation2.Addresses = [address]
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcOrganization")) == 1
|
||||
assert len(self.file.by_type("IfcActorRole")) == 1
|
||||
assert len(self.file.by_type("IfcPostalAddress")) == 1
|
||||
@@ -55,37 +55,37 @@ class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_deleting_organisation_relationships_as_the_relating_organisation(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
self.file.createIfcOrganizationRelationship(RelatingOrganization=organisation)
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcOrganizationRelationship")) == 0
|
||||
|
||||
def test_deleting_organisation_relationships_as_the_related_organisation(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
self.file.createIfcOrganizationRelationship(RelatedOrganizations=[organisation])
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcOrganizationRelationship")) == 0
|
||||
|
||||
def test_deleting_person_and_organisations(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
self.file.createIfcPersonAndOrganization(TheOrganization=organisation)
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
|
||||
|
||||
def test_deleting_actors(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=organisation)
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcActor")) == 0
|
||||
|
||||
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
document_information = self.file.createIfcDocumentInformation(Editors=[organisation])
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert document_information.Editors is None
|
||||
|
||||
def test_deleting_an_application(self):
|
||||
organisation = self.file.createIfcOrganization()
|
||||
self.file.createIfcApplication(ApplicationDeveloper=organisation)
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcApplication")) == 0
|
||||
|
||||
|
||||
@@ -94,17 +94,17 @@ class TestRemoveOrganisationIFC4(test.bootstrap.IFC4, TestRemoveOrganisationIFC2
|
||||
def test_deleting_resource_approval_relationships(self):
|
||||
organisation = self.file.create_entity("IfcOrganization")
|
||||
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
|
||||
|
||||
def test_deleting_resource_constraint_relationships(self):
|
||||
organisation = self.file.create_entity("IfcOrganization")
|
||||
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
|
||||
|
||||
def test_deleting_external_reference_relationships(self):
|
||||
organisation = self.file.create_entity("IfcOrganization")
|
||||
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_removing_a_person(self):
|
||||
person = self.file.createIfcPerson()
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert len(self.file.by_type("IfcPerson")) == 0
|
||||
|
||||
def test_removing_roles_and_addresses_only_used_by_the_person(self):
|
||||
@@ -34,7 +34,7 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
|
||||
person = self.file.createIfcPerson()
|
||||
person.Roles = [role]
|
||||
person.Addresses = [address]
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert len(self.file.by_type("IfcPerson")) == 0
|
||||
assert len(self.file.by_type("IfcActorRole")) == 0
|
||||
assert len(self.file.by_type("IfcPostalAddress")) == 0
|
||||
@@ -48,7 +48,7 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
|
||||
person.Addresses = [address]
|
||||
person2.Roles = [role]
|
||||
person2.Addresses = [address]
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert len(self.file.by_type("IfcPerson")) == 1
|
||||
assert len(self.file.by_type("IfcActorRole")) == 1
|
||||
assert len(self.file.by_type("IfcPostalAddress")) == 1
|
||||
@@ -56,14 +56,14 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_ensuring_work_controls_should_not_be_left_in_an_invalid_set_cardinality(self):
|
||||
person = self.file.createIfcPerson()
|
||||
work_control = self.file.createIfcWorkControl(Creators=[person])
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert work_control.Creators is None
|
||||
|
||||
def test_ensuring_inventory_should_not_be_left_in_an_invalid_set_cardinality(self):
|
||||
person = self.file.createIfcPerson()
|
||||
inventory = self.file.createIfcInventory(ResponsiblePersons=[person])
|
||||
inventory_id = inventory.id()
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert inventory.ResponsiblePersons is None
|
||||
else:
|
||||
@@ -73,19 +73,19 @@ class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_deleting_person_and_organisations(self):
|
||||
person = self.file.createIfcPerson()
|
||||
self.file.createIfcPersonAndOrganization(ThePerson=person)
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
|
||||
|
||||
def test_deleting_actors(self):
|
||||
person = self.file.createIfcPerson()
|
||||
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=person)
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert len(self.file.by_type("IfcActor")) == 0
|
||||
|
||||
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
|
||||
person = self.file.createIfcPerson()
|
||||
document_information = self.file.createIfcDocumentInformation(Editors=[person])
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert document_information.Editors is None
|
||||
|
||||
|
||||
@@ -94,17 +94,17 @@ class TestRemovePersonIFC4(test.bootstrap.IFC4, TestRemovePersonIFC2X3):
|
||||
def test_deleting_resource_approval_relationships(self):
|
||||
person = self.file.create_entity("IfcPerson")
|
||||
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[person])
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
|
||||
|
||||
def test_deleting_resource_constraint_relationships(self):
|
||||
person = self.file.create_entity("IfcPerson")
|
||||
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[person])
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
|
||||
|
||||
def test_deleting_external_reference_relationships(self):
|
||||
person = self.file.create_entity("IfcPerson")
|
||||
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[person])
|
||||
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
|
||||
ifcopenshell.api.owner.remove_person(self.file, person=person)
|
||||
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
|
||||
|
||||
@@ -17,32 +17,32 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
class TestRemovePersonAndOrganisationIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_removing(self):
|
||||
user = self.file.createIfcPersonAndOrganization()
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
|
||||
assert len(self.file.by_type("IfcPersonAndOrganization")) == 0
|
||||
|
||||
def test_deleting_actors(self):
|
||||
user = self.file.createIfcPersonAndOrganization()
|
||||
self.file.createIfcActor(GlobalId=ifcopenshell.guid.new(), TheActor=user)
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
|
||||
assert len(self.file.by_type("IfcActor")) == 0
|
||||
|
||||
def test_ensuring_document_information_should_not_be_left_in_an_invalid_set_cardinality(self):
|
||||
user = self.file.createIfcPersonAndOrganization()
|
||||
document_information = self.file.createIfcDocumentInformation(Editors=[user])
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
|
||||
assert document_information.Editors is None
|
||||
|
||||
def test_deleting_owner_history(self):
|
||||
user = self.file.createIfcPersonAndOrganization()
|
||||
self.file.createIfcOwnerHistory(OwningUser=user)
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
|
||||
assert len(self.file.by_type("IfcOwnerHistory")) == 0
|
||||
|
||||
|
||||
@@ -51,17 +51,17 @@ class TestRemovePersonAndOrganisationIFC4(test.bootstrap.IFC4, TestRemovePersonA
|
||||
def test_deleting_resource_approval_relationships(self):
|
||||
user = self.file.create_entity("IfcPersonAndOrganization")
|
||||
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[user])
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
|
||||
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
|
||||
|
||||
def test_deleting_resource_constraint_relationships(self):
|
||||
user = self.file.create_entity("IfcPersonAndOrganization")
|
||||
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[user])
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
|
||||
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
|
||||
|
||||
def test_deleting_external_reference_relationships(self):
|
||||
user = self.file.create_entity("IfcPersonAndOrganization")
|
||||
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[user])
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(self.file, person_and_organisation=user)
|
||||
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
|
||||
|
||||
@@ -17,34 +17,34 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestRemoveRoleIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_removing_a_role(self):
|
||||
role = self.file.createIfcActorRole()
|
||||
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
|
||||
ifcopenshell.api.owner.remove_role(self.file, role=role)
|
||||
assert len(self.file.by_type("IfcActorRole")) == 0
|
||||
|
||||
def test_ensuring_organisation_cardinality_is_valid(self):
|
||||
role = self.file.createIfcActorRole()
|
||||
organisation = self.file.createIfcOrganization()
|
||||
organisation.Roles = [role]
|
||||
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
|
||||
ifcopenshell.api.owner.remove_role(self.file, role=role)
|
||||
assert organisation.Roles is None
|
||||
|
||||
def test_ensuring_person_cardinality_is_valid(self):
|
||||
role = self.file.createIfcActorRole()
|
||||
person = self.file.createIfcPerson()
|
||||
person.Roles = [role]
|
||||
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
|
||||
ifcopenshell.api.owner.remove_role(self.file, role=role)
|
||||
assert person.Roles is None
|
||||
|
||||
def test_ensuring_person_and_organisation_cardinality_is_valid(self):
|
||||
role = self.file.createIfcActorRole()
|
||||
person_and_organisation = self.file.createIfcPersonAndOrganization()
|
||||
person_and_organisation.Roles = [role]
|
||||
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
|
||||
ifcopenshell.api.owner.remove_role(self.file, role=role)
|
||||
assert person_and_organisation.Roles is None
|
||||
|
||||
|
||||
@@ -52,17 +52,17 @@ class TestRemoveRoleIFC4(test.bootstrap.IFC4, TestRemoveRoleIFC2X3):
|
||||
def test_deleting_resource_approval_relationships(self):
|
||||
organisation = self.file.create_entity("IfcOrganization")
|
||||
self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
|
||||
|
||||
def test_deleting_resource_constraint_relationships(self):
|
||||
organisation = self.file.create_entity("IfcOrganization")
|
||||
self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
|
||||
|
||||
def test_deleting_external_reference_relationships(self):
|
||||
organisation = self.file.create_entity("IfcOrganization")
|
||||
self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
|
||||
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(self.file, organisation=organisation)
|
||||
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestUnassignActor(test.bootstrap.IFC4):
|
||||
def test_unassigning_an_actor(self):
|
||||
wall = self.file.createIfcWall()
|
||||
actor = self.file.createIfcActor()
|
||||
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
|
||||
ifcopenshell.api.run("owner.unassign_actor", self.file, relating_actor=actor, related_object=wall)
|
||||
ifcopenshell.api.owner.assign_actor(self.file, relating_actor=actor, related_object=wall)
|
||||
ifcopenshell.api.owner.unassign_actor(self.file, relating_actor=actor, related_object=wall)
|
||||
assert len(self.file.by_type("IfcRelAssignsToActor")) == 0
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
import time
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
class TestUpdateOwnerHistory(test.bootstrap.IFC4):
|
||||
@@ -32,7 +32,7 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.owner.settings.get_application = lambda x: application
|
||||
|
||||
element = self.file.createIfcWall()
|
||||
history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
|
||||
history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
|
||||
assert history.is_a("IfcOwnerHistory")
|
||||
assert element.OwnerHistory == history
|
||||
assert history.ChangeAction == "ADDED"
|
||||
@@ -53,10 +53,10 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.owner.settings.get_application = lambda x: application
|
||||
|
||||
element = self.file.createIfcWall()
|
||||
old_history = ifcopenshell.api.run("owner.create_owner_history", self.file)
|
||||
old_history = ifcopenshell.api.owner.create_owner_history(self.file)
|
||||
element.OwnerHistory = old_history
|
||||
|
||||
new_history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
|
||||
new_history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
|
||||
assert new_history == old_history
|
||||
assert element.OwnerHistory == new_history
|
||||
assert new_history.ChangeAction == "MODIFIED"
|
||||
@@ -78,11 +78,11 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
|
||||
|
||||
element = self.file.createIfcWall()
|
||||
element2 = self.file.createIfcWall()
|
||||
old_history = ifcopenshell.api.run("owner.create_owner_history", self.file)
|
||||
old_history = ifcopenshell.api.owner.create_owner_history(self.file)
|
||||
element.OwnerHistory = old_history
|
||||
element2.OwnerHistory = old_history
|
||||
|
||||
new_history = ifcopenshell.api.run("owner.update_owner_history", self.file, element=element)
|
||||
new_history = ifcopenshell.api.owner.update_owner_history(self.file, element=element)
|
||||
assert new_history != old_history
|
||||
assert element.OwnerHistory == new_history
|
||||
assert new_history.ChangeAction == "MODIFIED"
|
||||
@@ -95,7 +95,7 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
|
||||
|
||||
def test_doing_nothing_if_no_history_can_be_updated(self):
|
||||
person = self.file.createIfcPerson()
|
||||
assert ifcopenshell.api.run("owner.update_owner_history", self.file, element=person) == None
|
||||
assert ifcopenshell.api.owner.update_owner_history(self.file, element=person) == None
|
||||
|
||||
|
||||
class TestUpdateOwnerHistoryIFC2X3(test.bootstrap.IFC2X3, TestUpdateOwnerHistory):
|
||||
|
||||
@@ -17,48 +17,54 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.type
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.api.void
|
||||
import ifcopenshell.api.style
|
||||
import ifcopenshell.api.context
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.material
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_do_not_append_twice(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", library, name="Schedule")
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(library, name="Schedule")
|
||||
profile = library.createIfcIShapeProfileDef()
|
||||
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=schedule)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=schedule)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=schedule)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=schedule)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=profile)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=profile)
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
|
||||
def test_append_a_type_product(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
|
||||
def test_reuse_an_existing_context_if_it_was_added_from_library_previously(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
project = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
|
||||
lib_context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
project = ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
|
||||
lib_context = ifcopenshell.api.context.add_context(library, context_type="Model")
|
||||
|
||||
self.file.add(project) # will add project and it's contexts
|
||||
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
style = ifcopenshell.api.run("style.add_style", library)
|
||||
ifcopenshell.api.run(
|
||||
"style.assign_material_style", library, material=material, style=style, context=lib_context
|
||||
)
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
style = ifcopenshell.api.style.add_style(library)
|
||||
ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=lib_context)
|
||||
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
|
||||
context = self.file.by_type("IfcMaterial")[0].HasRepresentation[0].Representations[0].ContextOfItems
|
||||
@@ -66,61 +72,61 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert context.WorldCoordinateSystem
|
||||
|
||||
def test_append_a_single_type_product_even_though_an_inverse_material_relationship_is_shared(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element2], material=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
ifcopenshell.api.material.assign_material(library, products=[element], material=material)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element2], material=material)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
|
||||
def test_append_a_type_product_with_its_materials(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
ifcopenshell.api.material.assign_material(library, products=[element], material=material)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert self.file.by_type("IfcWallType")[0].HasAssociations[0].RelatingMaterial.Name == "Material"
|
||||
|
||||
def test_append_a_type_product_where_its_inverse_material_relationship_refers_to_products_not_in_scope(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element_type], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element_type2], material=material)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
ifcopenshell.api.material.assign_material(library, products=[element], material=material)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element_type], material=material)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element_type2], material=material)
|
||||
|
||||
# appending another type not connected to IfcWall directly
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element_type2)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element_type2)
|
||||
assert set(self.file.by_type("IfcWall")) == set()
|
||||
|
||||
# appending type of IfcWall
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element_type2)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element_type2)
|
||||
assert set(self.file.by_type("IfcWall")) == set()
|
||||
|
||||
def test_append_two_type_products_sharing_the_same_material_indirectly_via_a_material_set(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element1 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element1 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
|
||||
layer_set1 = ifcopenshell.api.run("material.add_material_set", library, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set1, material=material)
|
||||
ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set1, material=material)
|
||||
layer_set1 = ifcopenshell.api.material.add_material_set(library, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.add_layer(library, layer_set=layer_set1, material=material)
|
||||
ifcopenshell.api.material.add_layer(library, layer_set=layer_set1, material=material)
|
||||
|
||||
layer_set2 = ifcopenshell.api.run("material.add_material_set", library, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set2, material=material)
|
||||
ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set2, material=material)
|
||||
layer_set2 = ifcopenshell.api.material.add_material_set(library, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.material.add_layer(library, layer_set=layer_set2, material=material)
|
||||
ifcopenshell.api.material.add_layer(library, layer_set=layer_set2, material=material)
|
||||
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element1], material=layer_set1)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element2], material=layer_set2)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element1], material=layer_set1)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element2], material=layer_set2)
|
||||
|
||||
new1 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element1)
|
||||
new2 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
|
||||
new1 = ifcopenshell.api.project.append_asset(self.file, library=library, element=element1)
|
||||
new2 = ifcopenshell.api.project.append_asset(self.file, library=library, element=element2)
|
||||
|
||||
material = self.file.by_type("IfcMaterial")[0]
|
||||
assert ifcopenshell.util.element.get_material(new1).MaterialLayers[0].Material == material
|
||||
@@ -129,13 +135,13 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert ifcopenshell.util.element.get_material(new2).MaterialLayers[1].Material == material
|
||||
|
||||
def test_append_a_type_product_with_its_styles(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
history = library.createIfcOwnerHistory()
|
||||
element.OwnerHistory = history
|
||||
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
rel = ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
rel = ifcopenshell.api.material.assign_material(library, products=[element], material=material)
|
||||
# We share a history. This ensures that we continue to check all
|
||||
# whitelisted inverses even though one of the subelements (i.e. this
|
||||
# shared history) is already processed. See bug #2837.
|
||||
@@ -145,13 +151,13 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
library.createIfcStyledItem(Item=item)
|
||||
mapped_rep = library.createIfcShapeRepresentation(Items=[item])
|
||||
element.RepresentationMaps = [library.createIfcRepresentationMap(MappedRepresentation=mapped_rep)]
|
||||
new = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
new = ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert len(new.RepresentationMaps[0].MappedRepresentation.Items[0].StyledByItem) == 1
|
||||
assert self.file.by_type("IfcStyledItem")[0].Item == self.file.by_type("IfcBoundingBox")[0]
|
||||
|
||||
def test_append_product_with_styles_to_reuse_styleditems(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
history = library.createIfcOwnerHistory()
|
||||
element_type.OwnerHistory = history
|
||||
item = library.createIfcBoundingBox()
|
||||
@@ -160,63 +166,63 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
mapped_rep = library.createIfcShapeRepresentation(Items=[item], ContextOfItems=context)
|
||||
element_type.RepresentationMaps = [library.createIfcRepresentationMap(MappedRepresentation=mapped_rep)]
|
||||
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
|
||||
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 1
|
||||
|
||||
def test_append_a_type_product_with_a_styled_materials(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
local_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
local_context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
|
||||
context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
|
||||
context = ifcopenshell.api.context.add_context(library, context_type="Model")
|
||||
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
style = ifcopenshell.api.run("style.add_style", library)
|
||||
ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=context)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
ifcopenshell.api.material.assign_material(library, products=[element], material=material)
|
||||
style = ifcopenshell.api.style.add_style(library)
|
||||
ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=context)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert self.file.by_type("IfcWallType")[0].HasAssociations[0].RelatingMaterial.Name == "Material"
|
||||
assert self.file.by_type("IfcWallType")[0].HasAssociations[0].RelatingMaterial.HasRepresentation
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
|
||||
|
||||
def test_append_a_material(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
|
||||
def test_append_a_material_with_a_representation(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
style = ifcopenshell.api.run("style.add_style", library)
|
||||
context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
|
||||
ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=context)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
style = ifcopenshell.api.style.add_style(library)
|
||||
context = ifcopenshell.api.context.add_context(library, context_type="Model")
|
||||
ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=context)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
|
||||
context = self.file.by_type("IfcMaterial")[0].HasRepresentation[0].Representations[0].ContextOfItems
|
||||
assert context.ContextType == "Model"
|
||||
|
||||
def test_append_a_material_with_a_representation_and_reuse_an_existing_context(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
file_context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
style = ifcopenshell.api.run("style.add_style", library)
|
||||
context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
|
||||
ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=context)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
style = ifcopenshell.api.style.add_style(library)
|
||||
context = ifcopenshell.api.context.add_context(library, context_type="Model")
|
||||
ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=context)
|
||||
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
|
||||
context = self.file.by_type("IfcMaterial")[0].HasRepresentation[0].Representations[0].ContextOfItems
|
||||
@@ -225,10 +231,9 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert context.WorldCoordinateSystem
|
||||
|
||||
def test_append_a_material_with_a_representation_and_reuse_an_existing_subcontext(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
file_subcontext = ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
file_context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
file_subcontext = ifcopenshell.api.context.add_context(
|
||||
self.file,
|
||||
parent=file_context,
|
||||
context_type="Model",
|
||||
@@ -236,21 +241,20 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
target_view="MODEL_VIEW",
|
||||
)
|
||||
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
style = ifcopenshell.api.run("style.add_style", library)
|
||||
context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
|
||||
subcontext = ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
style = ifcopenshell.api.style.add_style(library)
|
||||
context = ifcopenshell.api.context.add_context(library, context_type="Model")
|
||||
subcontext = ifcopenshell.api.context.add_context(
|
||||
library,
|
||||
parent=context,
|
||||
context_type="Model",
|
||||
context_identifier="Body",
|
||||
target_view="MODEL_VIEW",
|
||||
)
|
||||
ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=subcontext)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
|
||||
ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=subcontext)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext", include_subtypes=False)) == 1
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationSubContext", include_subtypes=False)) == 1
|
||||
@@ -260,24 +264,23 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert subcontext.ParentContext.WorldCoordinateSystem
|
||||
|
||||
def test_append_a_material_with_a_representation_and_reuse_an_existing_context_by_a_new_subcontext(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
file_context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
style = ifcopenshell.api.run("style.add_style", library)
|
||||
context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
|
||||
subcontext = ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
ifcopenshell.api.root.create_entity(library, ifc_class="IfcProject")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
style = ifcopenshell.api.style.add_style(library)
|
||||
context = ifcopenshell.api.context.add_context(library, context_type="Model")
|
||||
subcontext = ifcopenshell.api.context.add_context(
|
||||
library,
|
||||
context_type="Model",
|
||||
context_identifier="Body",
|
||||
target_view="MODEL_VIEW",
|
||||
parent=context,
|
||||
)
|
||||
ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=subcontext)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
|
||||
ifcopenshell.api.style.assign_material_style(library, material=material, style=style, context=subcontext)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 1
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationContext", include_subtypes=False)) == 1
|
||||
assert len(self.file.by_type("IfcGeometricRepresentationSubContext", include_subtypes=False)) == 1
|
||||
@@ -288,83 +291,83 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert subcontext.ParentContext == file_context
|
||||
|
||||
def test_append_a_profile_def(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
profile = library.createIfcIShapeProfileDef()
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=profile)
|
||||
assert len(self.file.by_type("IfcIShapeProfileDef")) == 1
|
||||
|
||||
def test_append_a_product(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert len(self.file.by_type("IfcWall")) == 1
|
||||
|
||||
def test_append_a_product_with_all_properties(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("pset.add_pset", library, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
ifcopenshell.api.pset.add_pset(library, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert ifcopenshell.util.element.get_psets(self.file.by_type("IfcWall")[0])["Foo_Bar"]
|
||||
|
||||
def test_append_a_product_with_its_type(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert ifcopenshell.util.element.get_type(self.file.by_type("IfcWall")[0]).is_a("IfcWallType")
|
||||
|
||||
def test_append_only_specified_occurrences_of_a_typed_product(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element2], relating_type=element_type)
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element3], relating_type=element_type)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
element3 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.type.assign_type(library, related_objects=[element2], relating_type=element_type)
|
||||
ifcopenshell.api.type.assign_type(library, related_objects=[element3], relating_type=element_type)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element2)
|
||||
assert len(ifcopenshell.util.element.get_types(self.file.by_type("IfcWallType")[0])) == 2
|
||||
assert len(self.file.by_type("IfcWall")) == 2
|
||||
|
||||
def test_append_a_product_with_materials(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
ifcopenshell.api.material.assign_material(library, products=[element], material=material)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert ifcopenshell.util.element.get_material(self.file.by_type("IfcWall")[0]).Name == "Material"
|
||||
|
||||
def test_append_a_product_where_its_inverse_material_relationship_refers_to_product_types_not_in_scope(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element_type], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element_type2], material=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.type.assign_type(library, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
ifcopenshell.api.material.assign_material(library, products=[element], material=material)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element_type], material=material)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element_type2], material=material)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert [e.GlobalId for e in self.file.by_type("IfcWallType")] == [element_type.GlobalId]
|
||||
|
||||
def test_append_a_product_with_its_styles(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
item = library.createIfcBoundingBox()
|
||||
library.createIfcStyledItem(Item=item)
|
||||
representation = library.createIfcShapeRepresentation(Items=[item])
|
||||
element.Representation = library.createIfcProductDefinitionShape(Representations=[representation])
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert self.file.by_type("IfcStyledItem")[0].Item == self.file.by_type("IfcBoundingBox")[0]
|
||||
|
||||
def test_append_a_product_with_openings(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.run("void.add_opening", library, opening=opening, element=element)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.root.create_entity(library, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.void.add_opening(library, opening=opening, element=element)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=element)
|
||||
assert self.file.by_type("IfcWall")[0].HasOpenings[0].RelatedOpeningElement.is_a("IfcOpeningElement")
|
||||
|
||||
|
||||
@@ -372,28 +375,28 @@ class TestAppendAssetIFC4(test.bootstrap.IFC4, TestAppendAssetIFC2X3):
|
||||
# NOTE: breaks in IFC2X3 since IfcProfileDef doesn't have "HasProperties" inverse in ifc2x3
|
||||
# and we use it in whitelisted_inverse_attributes for appending IfcProfileDef
|
||||
def test_append_a_profile_def_with_all_properties(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
profile = library.createIfcIShapeProfileDef()
|
||||
ifcopenshell.api.run("pset.add_pset", library, product=profile, name="Foo_Bar")
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
|
||||
ifcopenshell.api.pset.add_pset(library, product=profile, name="Foo_Bar")
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=profile)
|
||||
assert len(self.file.by_type("IfcIShapeProfileDef")) == 1
|
||||
assert self.file.by_type("IfcIShapeProfileDef")[0].HasProperties[0].Name == "Foo_Bar"
|
||||
|
||||
# NOTE: breaks in IFC2X3 since IfcMaterial doesn't have "HasProperties" inverse in ifc2x3
|
||||
# and we use it in whitelisted_inverse_attributes for appending IfcTypeProduct
|
||||
def test_append_two_type_products_sharing_the_same_material_with_properties(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
element1 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
element1 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.material.add_material(library, name="Material")
|
||||
|
||||
pset = ifcopenshell.api.run("pset.add_pset", library, product=material, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", library, pset=pset, properties={"Foo": "Bar"})
|
||||
pset = ifcopenshell.api.pset.add_pset(library, product=material, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(library, pset=pset, properties={"Foo": "Bar"})
|
||||
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element1], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element2], material=material)
|
||||
new1 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element1)
|
||||
new2 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element1], material=material)
|
||||
ifcopenshell.api.material.assign_material(library, products=[element2], material=material)
|
||||
new1 = ifcopenshell.api.project.append_asset(self.file, library=library, element=element1)
|
||||
new2 = ifcopenshell.api.project.append_asset(self.file, library=library, element=element2)
|
||||
|
||||
assert len(self.file.by_type("IfcMaterialProperties")) == 1
|
||||
material = self.file.by_type("IfcMaterial")[0]
|
||||
@@ -404,11 +407,11 @@ class TestAppendAssetIFC4(test.bootstrap.IFC4, TestAppendAssetIFC2X3):
|
||||
# NOTE: breaks in IFC2X3 since IfcCostItem doesn't have "IsNestedBy" inverse in ifc2x3
|
||||
# and we use it in whitelisted_inverse_attributes for appending IfcCostSchedule
|
||||
def test_append_a_cost_schedule(self):
|
||||
library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", library, name="Schedule")
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", library, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.run("cost.add_cost_item", library, cost_item=item)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=schedule)
|
||||
library = ifcopenshell.api.project.create_file(version=self.file.schema)
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(library, name="Schedule")
|
||||
item = ifcopenshell.api.cost.add_cost_item(library, cost_schedule=schedule)
|
||||
item2 = ifcopenshell.api.cost.add_cost_item(library, cost_item=item)
|
||||
ifcopenshell.api.project.append_asset(self.file, library=library, element=schedule)
|
||||
assert len(self.file.by_type("IfcCostSchedule")) == 1
|
||||
assert len(self.file.by_type("IfcCostItem")) == 2
|
||||
assert self.file.by_type("IfcCostSchedule")[0].Name == "Schedule"
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.project
|
||||
|
||||
|
||||
# NOTE: supported only in IFC4+
|
||||
@@ -29,11 +30,10 @@ class TestAssignDeclaration(test.bootstrap.IFC4):
|
||||
return definitions
|
||||
|
||||
def test_assign_a_declaration(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration",
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file,
|
||||
definitions=[element_type, element_type2],
|
||||
relating_context=library,
|
||||
@@ -42,29 +42,29 @@ class TestAssignDeclaration(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcRelDeclares")) == 1
|
||||
|
||||
def test_doing_nothing_if_the_library_is_already_assigned(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_that_old_relationships_are_updated_if_they_still_contain_elements(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type], relating_context=library
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type], relating_context=library
|
||||
)
|
||||
rel = self.file.by_type("IfcRelDeclares")[0]
|
||||
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type2, element_type3], relating_context=library
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type2, element_type3], relating_context=library
|
||||
)
|
||||
assert len(rel.RelatedDefinitions) == 3
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.project
|
||||
|
||||
|
||||
class TestCreateFile(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.api.run("project.create_file")
|
||||
ifc = ifcopenshell.api.project.create_file()
|
||||
assert ifc.schema == "IFC4"
|
||||
ifc = ifcopenshell.api.run("project.create_file", version="IFC2X3")
|
||||
ifc = ifcopenshell.api.project.create_file(version="IFC2X3")
|
||||
assert ifc.schema == "IFC2X3"
|
||||
assert ifc.wrapped_data.header.file_name.name == "/dev/null"
|
||||
assert ifc.wrapped_data.header.file_name.time_stamp
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.project
|
||||
from typing import Union
|
||||
|
||||
|
||||
@@ -29,14 +30,13 @@ class TestUnassignDeclaration(test.bootstrap.IFC4):
|
||||
return rel.RelatingContext
|
||||
|
||||
def test_unassigning_a_definition(self):
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type, element_type2], relating_context=library
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.unassign_declaration",
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
self.file,
|
||||
definitions=[element_type, element_type2],
|
||||
relating_context=library,
|
||||
@@ -45,11 +45,10 @@ class TestUnassignDeclaration(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcRelDeclares")) == 0
|
||||
|
||||
def test_doing_nothing_if_there_was_no_declaration(self):
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"project.unassign_declaration",
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
self.file,
|
||||
definitions=[element_type, element_type2],
|
||||
relating_context=library,
|
||||
@@ -58,23 +57,21 @@ class TestUnassignDeclaration(test.bootstrap.IFC4):
|
||||
assert self.get_context(element_type2) == None
|
||||
|
||||
def test_updating_the_rel_when_a_reference_is_removed_with_multipled_elements(self):
|
||||
library = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProjectLibrary")
|
||||
element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration", self.file, definitions=[element_type1], relating_context=library
|
||||
library = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProjectLibrary")
|
||||
element_type1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element_type3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file, definitions=[element_type1], relating_context=library
|
||||
)
|
||||
rel = self.file.by_type("IfcRelDeclares")[0]
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration",
|
||||
ifcopenshell.api.project.assign_declaration(
|
||||
self.file,
|
||||
definitions=[element_type2, element_type3],
|
||||
relating_context=library,
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"project.unassign_declaration",
|
||||
ifcopenshell.api.project.unassign_declaration(
|
||||
self.file,
|
||||
definitions=[element_type1, element_type2],
|
||||
relating_context=library,
|
||||
|
||||
@@ -17,48 +17,51 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.profile
|
||||
import ifcopenshell.api.material
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAddPset(test.bootstrap.IFC4):
|
||||
def test_adding_a_pset_to_an_object(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
assert pset.is_a("IfcPropertySet")
|
||||
assert "Pset_WallCommon" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
def test_adding_a_pset_to_a_type_object(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
assert pset.is_a("IfcPropertySet")
|
||||
assert "Pset_WallCommon" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
def test_adding_a_pset_to_a_material(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Pset_MaterialCommon")
|
||||
material = ifcopenshell.api.material.add_material(self.file)
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=material, name="Pset_MaterialCommon")
|
||||
assert pset.is_a("IfcMaterialProperties")
|
||||
assert pset.Name == "Pset_MaterialCommon"
|
||||
assert pset.Material == material
|
||||
|
||||
def test_adding_a_pset_to_a_profile(self):
|
||||
profile = ifcopenshell.api.run("profile.add_parameterized_profile", self.file, ifc_class="IfcCircleProfileDef")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=profile, name="Pset_ProfileMechanical")
|
||||
profile = ifcopenshell.api.profile.add_parameterized_profile(self.file, ifc_class="IfcCircleProfileDef")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=profile, name="Pset_ProfileMechanical")
|
||||
assert pset.is_a("IfcProfileProperties")
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert pset.Name == "Pset_ProfileMechanical"
|
||||
assert pset.ProfileDefinition == profile
|
||||
|
||||
def test_adding_a_pset_to_a_context(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Custom_Pset")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Custom_Pset")
|
||||
assert pset.is_a("IfcPropertySet")
|
||||
assert "Custom_Pset" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
|
||||
class TestAddPsetIFC2X3(test.bootstrap.IFC2X3, TestAddPset):
|
||||
def test_adding_a_pset_to_a_project(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Custom_Pset")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Custom_Pset")
|
||||
assert pset.is_a("IfcPropertySet")
|
||||
assert "Custom_Pset" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
@@ -17,33 +17,34 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAddQto(test.bootstrap.IFC4):
|
||||
def test_adding_a_qto_to_an_object(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Qto_WallBaseQuantities")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Qto_WallBaseQuantities")
|
||||
assert qto.is_a("IfcElementQuantity")
|
||||
assert "Qto_WallBaseQuantities" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
def test_adding_a_qto_to_a_type_object(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Custom_Qto")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Custom_Qto")
|
||||
assert qto.is_a("IfcElementQuantity")
|
||||
assert "Custom_Qto" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
def test_adding_a_qto_to_a_context(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Custom_Qto")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Custom_Qto")
|
||||
assert qto.is_a("IfcElementQuantity")
|
||||
assert "Custom_Qto" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
|
||||
class TestAddQtoIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_adding_a_qto_to_a_project(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Custom_Qto")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Custom_Qto")
|
||||
assert qto.is_a("IfcElementQuantity")
|
||||
assert "Custom_Qto" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
|
||||
import operator
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
class TestEditPset(test.bootstrap.IFC4):
|
||||
def test_editing_a_blank_buildingsmart_templated_pset(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={"Reference": "reference", "Status": ["NEW"], "Combustible": True, "ThermalTransmittance": 42},
|
||||
@@ -51,16 +51,15 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[3].NominalValue.wrappedValue == 42
|
||||
|
||||
def test_editing_an_existing_buildingsmart_templated_pset(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={"Reference": "foo", "Status": ["NEW"], "Combustible": True, "ThermalTransmittance": 42},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset", self.file, pset=pset, properties={"Reference": "bar", "Status": []}, should_purge=False
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file, pset=pset, properties={"Reference": "bar", "Status": []}, should_purge=False
|
||||
)
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
|
||||
@@ -72,15 +71,14 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[1].EnumerationValues is None
|
||||
|
||||
def test_editing_a_templated_pset_with_automatic_casting_of_primitive_data_types(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={"ThermalTransmittance": "42"},
|
||||
)
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": "bar", "Status": None})
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": "bar", "Status": None})
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
|
||||
assert pset.HasProperties[0].Name == "ThermalTransmittance"
|
||||
@@ -88,49 +86,48 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == 42
|
||||
|
||||
def test_adding_a_property_if_it_is_none(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": None}, should_purge=False)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": None}, should_purge=False)
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert len(pset.HasProperties) == 1
|
||||
|
||||
def test_not_adding_a_property_if_it_is_none_and_should_purge_is_true(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": None}, should_purge=True)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": None}, should_purge=True)
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert len(pset.HasProperties) == 0
|
||||
|
||||
def test_removing_a_none_property_if_specified(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": "Foo"})
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Reference": None}, should_purge=True)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": "Foo"})
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Reference": None}, should_purge=True)
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert len(pset.HasProperties) == 0
|
||||
|
||||
def test_removing_a_none_enumeration_property_if_specified(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["NEW"]})
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ["NEW"]})
|
||||
assert pset.HasProperties[0].Name == "Status"
|
||||
assert pset.HasProperties[0].EnumerationValues[0].wrappedValue == "NEW"
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": []}, should_purge=True)
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": []}, should_purge=True)
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert len(pset.HasProperties) == 0
|
||||
|
||||
def test_editing_a_pset_name(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="foo")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, name="bar")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="foo")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, name="bar")
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert pset.Name == "bar"
|
||||
|
||||
def test_adding_properties_without_a_template_with_autodetected_and_manual_data_types(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
@@ -164,18 +161,16 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[4].NominalValue.wrappedValue == 123.0
|
||||
|
||||
def test_editing_properties_with_autodetected_existing_types(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
"MyCustom": self.file.createIfcContextDependentMeasure(12),
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
@@ -188,12 +183,11 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == 34
|
||||
|
||||
def test_editing_list_valued_properties(self):
|
||||
cable = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcDistributionPort", predefined_type="CABLE"
|
||||
cable = ifcopenshell.api.root.create_entity(
|
||||
self.file, ifc_class="IfcDistributionPort", predefined_type="CABLE"
|
||||
)
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=cable, name="Pset_DistributionPortTypeCable")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=cable, name="Pset_DistributionPortTypeCable")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
@@ -206,18 +200,16 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert list(map(operator.itemgetter(0), pset.HasProperties[0].ListValues)) == ["One", "Two", "Three"]
|
||||
|
||||
def test_editing_properties_with_an_explicit_type(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
"MyCustom": self.file.createIfcLabel("True"),
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
@@ -230,19 +222,17 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue is True
|
||||
|
||||
def test_editing_properties_with_custom_units(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
custom_unit = self.file.createIfcSIUnit(UnitType="PRESSUREUNIT", Prefix="GIGA", Name="PASCAL")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
"MyCustom": self.file.createIfcModulusOfElasticityMeasure(20),
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
@@ -260,8 +250,8 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
|
||||
def test_editing_properties_of_non_rooted_elements(self):
|
||||
element = self.file.createIfcMaterial()
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"foo": "bar"})
|
||||
|
||||
assert element.HasProperties[0] == pset
|
||||
assert pset.Properties[0].Name == "foo"
|
||||
@@ -289,10 +279,9 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
],
|
||||
},
|
||||
)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
pset_template=template,
|
||||
@@ -308,15 +297,15 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
def test_editing_a_shared_property(self):
|
||||
element1 = self.file.createIfcMaterial()
|
||||
element2 = self.file.createIfcMaterial()
|
||||
pset1 = ifcopenshell.api.run("pset.add_pset", self.file, product=element1, name="Foo_Bar")
|
||||
pset2 = ifcopenshell.api.run("pset.add_pset", self.file, product=element2, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset1, properties={"foo": "bar"})
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset2, properties={"foo2": "bar2"})
|
||||
pset1 = ifcopenshell.api.pset.add_pset(self.file, product=element1, name="Foo_Bar")
|
||||
pset2 = ifcopenshell.api.pset.add_pset(self.file, product=element2, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset1, properties={"foo": "bar"})
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset2, properties={"foo2": "bar2"})
|
||||
element1.HasProperties[0].Properties = list(element1.HasProperties[0].Properties) + list(
|
||||
element2.HasProperties[0].Properties
|
||||
)
|
||||
assert ifcopenshell.util.element.get_pset(element1, "Foo_Bar", "foo2") == "bar2"
|
||||
assert ifcopenshell.util.element.get_pset(element2, "Foo_Bar", "foo2") == "bar2"
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset1, properties={"foo2": "bar3"})
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset1, properties={"foo2": "bar3"})
|
||||
assert ifcopenshell.util.element.get_pset(element1, "Foo_Bar", "foo2") == "bar3"
|
||||
assert ifcopenshell.util.element.get_pset(element2, "Foo_Bar", "foo2") == "bar2"
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
|
||||
|
||||
class TestEditQto(test.bootstrap.IFC4):
|
||||
def test_editing_a_blank_buildingsmart_templated_qto(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Qto_WallBaseQuantities")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_qto",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Qto_WallBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(
|
||||
self.file,
|
||||
qto=qto,
|
||||
properties={"Length": 1, "NetSideArea": 2, "NetVolume": 3},
|
||||
@@ -42,15 +42,14 @@ class TestEditQto(test.bootstrap.IFC4):
|
||||
assert pset.Quantities[2].VolumeValue == 3
|
||||
|
||||
def test_editing_an_existing_buildingsmart_templated_pset(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Qto_WallBaseQuantities")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_qto",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Qto_WallBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(
|
||||
self.file,
|
||||
qto=qto,
|
||||
properties={"Length": 1, "NetSideArea": 2, "NetVolume": 3},
|
||||
)
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"Length": 42, "NetSideArea": None})
|
||||
ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"Length": 42, "NetSideArea": None})
|
||||
qto = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
|
||||
assert qto.Quantities[0].Name == "Length"
|
||||
@@ -62,24 +61,23 @@ class TestEditQto(test.bootstrap.IFC4):
|
||||
assert len(qto.Quantities) == 2
|
||||
|
||||
def test_not_adding_a_property_if_it_is_none(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Qto_WallBaseQuantities")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"Length": None})
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Qto_WallBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"Length": None})
|
||||
qto = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert len(qto.Quantities) == 0
|
||||
|
||||
def test_editing_a_qto_name(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="foo")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, name="bar")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="foo")
|
||||
ifcopenshell.api.pset.edit_qto(self.file, qto=qto, name="bar")
|
||||
qto = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert qto.Name == "bar"
|
||||
|
||||
def test_adding_quantities_without_a_template_with_autodetected_and_manual_data_types(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_qto",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_qto(
|
||||
self.file,
|
||||
qto=qto,
|
||||
properties={
|
||||
@@ -112,18 +110,16 @@ class TestEditQto(test.bootstrap.IFC4):
|
||||
assert qto.Quantities[5].WeightValue == 7
|
||||
|
||||
def test_editing_quantities_with_autodetected_existing_types(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_qto",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_qto(
|
||||
self.file,
|
||||
qto=qto,
|
||||
properties={
|
||||
"MyLength": self.file.createIfcLengthMeasure(12),
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_qto",
|
||||
ifcopenshell.api.pset.edit_qto(
|
||||
self.file,
|
||||
qto=qto,
|
||||
properties={
|
||||
@@ -135,18 +131,16 @@ class TestEditQto(test.bootstrap.IFC4):
|
||||
assert qto.Quantities[0].LengthValue == 34
|
||||
|
||||
def test_editing_properties_with_an_explicit_type(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_qto",
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_qto(
|
||||
self.file,
|
||||
qto=qto,
|
||||
properties={
|
||||
"MyLength": self.file.createIfcLengthMeasure(12),
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_qto",
|
||||
ifcopenshell.api.pset.edit_qto(
|
||||
self.file,
|
||||
qto=qto,
|
||||
properties={
|
||||
|
||||
@@ -17,94 +17,95 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestRemovePset(test.bootstrap.IFC4):
|
||||
def test_removing_pset(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 1
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
|
||||
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 0
|
||||
assert len(self.file.by_type("IfcPropertySet")) == 0
|
||||
|
||||
def test_removing_material_psets(self):
|
||||
element = self.file.createIfcMaterial()
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
assert len(element.HasProperties) == 1
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
|
||||
assert len(element.HasProperties) == 0
|
||||
assert len(self.file.by_type("IfcMaterialProperties")) == 0
|
||||
|
||||
def test_removing_profile_psets(self):
|
||||
element = self.file.createIfcProfileDef()
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
assert len(element.HasProperties) == 1
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
|
||||
assert len(element.HasProperties) == 0
|
||||
assert len(self.file.by_type("IfcMaterialProperties")) == 0
|
||||
|
||||
def test_only_unassigning_if_pset_is_used_by_other_elements(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
rel = self.file.by_type("IfcRelDefinesByProperties")[0]
|
||||
rel.RelatedObjects = [element, element2]
|
||||
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 1
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
|
||||
assert ifcopenshell.util.element.get_psets(element) == {}
|
||||
assert "Foo_Bar" in ifcopenshell.util.element.get_psets(element2)
|
||||
|
||||
def test_removing_a_pset_with_properties(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
|
||||
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 0
|
||||
assert len(self.file.by_type("IfcPropertySet")) == 0
|
||||
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
|
||||
|
||||
def test_removing_a_qto_with_quantities(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"Foo": 42})
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=qto)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"Foo": 42})
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=qto)
|
||||
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 0
|
||||
assert len(self.file.by_type("IfcQuantitySet")) == 0
|
||||
assert len(self.file.by_type("IfcPhysicalSimpleQuantity")) == 0
|
||||
|
||||
def test_removing_a_pset_with_shared_properties(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
pset2 = ifcopenshell.api.run("pset.add_pset", self.file, product=element2, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
pset2 = ifcopenshell.api.pset.add_pset(self.file, product=element2, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
pset2.HasProperties = pset.HasProperties
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
|
||||
assert pset2.HasProperties
|
||||
|
||||
def test_removing_a_pset_with_enumeration(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["NEW"]})
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ["NEW"]})
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
|
||||
assert len(self.file.by_type("IfcPropertyEnumeration")) == 0
|
||||
|
||||
def test_removing_a_pset_with_shared_enumeration(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["NEW"]})
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ["NEW"]})
|
||||
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset2 = ifcopenshell.api.run("pset.add_pset", self.file, product=element2, name="Pset_WallCommon")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset2, properties={"Status": ["NEW"]})
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset2 = ifcopenshell.api.pset.add_pset(self.file, product=element2, name="Pset_WallCommon")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset2, properties={"Status": ["NEW"]})
|
||||
|
||||
enumeration1 = pset.HasProperties[0].EnumerationReference
|
||||
enumeration2 = pset2.HasProperties[0].EnumerationReference
|
||||
pset2.HasProperties[0].EnumerationReference = enumeration1
|
||||
self.file.remove(enumeration2)
|
||||
|
||||
ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset)
|
||||
ifcopenshell.api.pset.remove_pset(self.file, product=element, pset=pset)
|
||||
assert len(self.file.by_type("IfcPropertyEnumeration")) == 1
|
||||
|
||||
@@ -17,42 +17,38 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset_template
|
||||
|
||||
|
||||
class TestEditPropTemplate(test.bootstrap.IFC4):
|
||||
def test_editing_a_simple_template(self):
|
||||
template = ifcopenshell.api.run("pset_template.add_pset_template", self.file, name="ABC_RiskFactors")
|
||||
prop = ifcopenshell.api.run("pset_template.add_prop_template", self.file, pset_template=template)
|
||||
ifcopenshell.api.run(
|
||||
"pset_template.edit_prop_template",
|
||||
template = ifcopenshell.api.pset_template.add_pset_template(self.file, name="ABC_RiskFactors")
|
||||
prop = ifcopenshell.api.pset_template.add_prop_template(self.file, pset_template=template)
|
||||
ifcopenshell.api.pset_template.edit_prop_template(
|
||||
self.file,
|
||||
prop_template=prop,
|
||||
attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLabel"},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset_template.edit_prop_template", self.file, prop_template=prop, attributes={"Name": "DemoB"}
|
||||
ifcopenshell.api.pset_template.edit_prop_template(
|
||||
self.file, prop_template=prop, attributes={"Name": "DemoB"}
|
||||
)
|
||||
assert prop.Name == "DemoB"
|
||||
|
||||
def test_editing_an_enumeration(self):
|
||||
template = ifcopenshell.api.run("pset_template.add_pset_template", self.file, name="ABC_RiskFactors")
|
||||
prop = ifcopenshell.api.run("pset_template.add_prop_template", self.file, pset_template=template)
|
||||
ifcopenshell.api.run(
|
||||
"pset_template.edit_prop_template",
|
||||
template = ifcopenshell.api.pset_template.add_pset_template(self.file, name="ABC_RiskFactors")
|
||||
prop = ifcopenshell.api.pset_template.add_prop_template(self.file, pset_template=template)
|
||||
ifcopenshell.api.pset_template.edit_prop_template(
|
||||
self.file,
|
||||
prop_template=prop,
|
||||
attributes={"Name": "DemoA", "PrimaryMeasureType": "IfcLabel"},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset_template.edit_prop_template",
|
||||
ifcopenshell.api.pset_template.edit_prop_template(
|
||||
self.file,
|
||||
prop_template=prop,
|
||||
attributes={"Enumerators": ["FOO", "BAR"]},
|
||||
)
|
||||
assert prop.Enumerators.EnumerationValues == tuple(self.file.createIfcLabel(v) for v in ("FOO", "BAR"))
|
||||
ifcopenshell.api.run(
|
||||
"pset_template.edit_prop_template",
|
||||
ifcopenshell.api.pset_template.edit_prop_template(
|
||||
self.file,
|
||||
prop_template=prop,
|
||||
attributes={"Name": "DemoC", "Enumerators": ["BAZ", "BAR"]},
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.resource
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.constraint
|
||||
|
||||
|
||||
@@ -25,12 +28,11 @@ import ifcopenshell.util.constraint
|
||||
# therefore no IFC2X3 tests
|
||||
class TestCalculateResourceWork(test.bootstrap.IFC4):
|
||||
def test_calculating_resource_work_based_on_a_daily_productivity_rate(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
|
||||
resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
@@ -40,23 +42,22 @@ class TestCalculateResourceWork(test.bootstrap.IFC4):
|
||||
},
|
||||
)
|
||||
|
||||
slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file)
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
|
||||
task = ifcopenshell.api.sequence.add_task(self.file)
|
||||
ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
|
||||
assert resource.Usage.ScheduleWork == "P2.0D"
|
||||
|
||||
def test_calculating_resource_work_based_on_an_hourly_productivity_rate(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
|
||||
resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
@@ -66,46 +67,45 @@ class TestCalculateResourceWork(test.bootstrap.IFC4):
|
||||
},
|
||||
)
|
||||
|
||||
slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file)
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
|
||||
task = ifcopenshell.api.sequence.add_task(self.file)
|
||||
ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
|
||||
assert resource.Usage.ScheduleWork == "PT4.0H"
|
||||
|
||||
def test_no_calculation_if_no_productivity_data_available(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
|
||||
resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
|
||||
resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
|
||||
|
||||
slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file)
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
|
||||
task = ifcopenshell.api.sequence.add_task(self.file)
|
||||
ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
|
||||
|
||||
assert resource.Usage is None
|
||||
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"BaseQuantityProducedName": "foo"})
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"BaseQuantityProducedName": "foo"})
|
||||
|
||||
ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
|
||||
ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
|
||||
|
||||
assert resource.Usage is None
|
||||
|
||||
def test_calculating_resource_work_based_on_a_counted_quantity(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
|
||||
resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
resource = ifcopenshell.api.resource.add_resource(self.file, ifc_class="IfcLaborResource")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
@@ -115,15 +115,15 @@ class TestCalculateResourceWork(test.bootstrap.IFC4):
|
||||
},
|
||||
)
|
||||
|
||||
slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.pset.add_qto(self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=resource)
|
||||
ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=resource)
|
||||
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=schedule)
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
|
||||
schedule = ifcopenshell.api.sequence.add_work_schedule(self.file)
|
||||
task = ifcopenshell.api.sequence.add_task(self.file, work_schedule=schedule)
|
||||
ifcopenshell.api.sequence.assign_product(self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.sequence.assign_process(self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.resource.calculate_resource_work(self.file, resource=resource)
|
||||
assert resource.Usage.ScheduleWork == "PT0.5H"
|
||||
|
||||
@@ -18,38 +18,47 @@
|
||||
|
||||
import numpy
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.unit
|
||||
import ifcopenshell.api.type
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.void
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.group
|
||||
import ifcopenshell.api.system
|
||||
import ifcopenshell.api.spatial
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.util
|
||||
import ifcopenshell.util.system
|
||||
|
||||
|
||||
class TestCopyClass(test.bootstrap.IFC4):
|
||||
def test_copying_a_simple_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert new != element
|
||||
assert new.GlobalId != element.GlobalId
|
||||
assert new.is_a("IfcWall")
|
||||
|
||||
def test_copying_object_placements_so_children_of_the_original_element_dont_reference_the_new_element(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
matrix = numpy.identity(4)
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element, matrix=matrix.copy())
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=subelement, matrix=matrix.copy())
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=element, matrix=matrix.copy())
|
||||
ifcopenshell.api.geometry.edit_object_placement(self.file, product=subelement, matrix=matrix.copy())
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement
|
||||
assert subelement.ObjectPlacement.PlacementRelTo != new.ObjectPlacement
|
||||
assert element.ObjectPlacement.RelativePlacement != new.ObjectPlacement.RelativePlacement
|
||||
|
||||
def test_copying_psets_so_changing_properties_of_the_new_element_does_not_affect_the_old(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foobar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"foo": "bar"})
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
new_pset = new.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert element.IsDefinedBy[0] != new.IsDefinedBy[0]
|
||||
@@ -60,10 +69,10 @@ class TestCopyClass(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == new_pset.HasProperties[0].NominalValue.wrappedValue
|
||||
|
||||
def test_copying_type_psets_so_changing_properties_of_the_new_type_does_not_affect_the_old(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foobar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"foo": "bar"})
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
pset = element.HasPropertySets[0]
|
||||
new_pset = new.HasPropertySets[0]
|
||||
assert element.HasPropertySets[0] != new.HasPropertySets[0]
|
||||
@@ -74,128 +83,128 @@ class TestCopyClass(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == new_pset.HasProperties[0].NominalValue.wrappedValue
|
||||
|
||||
def test_copying_a_container_only_and_not_its_contents(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert element.ContainsElements
|
||||
assert not new.ContainsElements
|
||||
|
||||
def test_copying_contents_of_a_container_and_maintaining_the_containment_relationship(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=subelement)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=subelement)
|
||||
assert new.ContainedInStructure[0].RelatingStructure == element
|
||||
|
||||
def test_copying_a_container_only_and_not_its_decomposition(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBuildingStorey")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert element.IsDecomposedBy
|
||||
assert not new.IsDecomposedBy
|
||||
|
||||
def test_copying_an_aggregate_only_and_not_its_decomposition(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert element.IsDecomposedBy
|
||||
assert not new.IsDecomposedBy
|
||||
|
||||
def test_copying_an_aggregate_decomposition_and_maintaining_the_aggregate_relationship(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=subelement)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=subelement)
|
||||
assert new.Decomposes[0].RelatingObject == element
|
||||
|
||||
def test_not_copying_any_representations_because_life_is_hard(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element.Representation = self.file.createIfcProductDefinitionShape()
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert new.Representation is None
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element.RepresentationMaps = [self.file.createIfcRepresentationMap()]
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert new.RepresentationMaps is None
|
||||
|
||||
def test_copying_an_element_with_an_opening(self):
|
||||
# IfcOpeningElement opening
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=wall)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=wall)
|
||||
assert wall.HasOpenings[0] != new.HasOpenings[0]
|
||||
assert wall.HasOpenings[0].RelatedOpeningElement == opening
|
||||
assert new.HasOpenings[0].RelatedOpeningElement != opening
|
||||
assert new.HasOpenings[0].RelatedOpeningElement.is_a("IfcOpeningElement")
|
||||
|
||||
# IfcVoidingFeature opening
|
||||
plate = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPlate")
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcVoidingFeature")
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=plate)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=plate)
|
||||
plate = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcPlate")
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcVoidingFeature")
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=plate)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=plate)
|
||||
assert plate.HasOpenings[0] != new.HasOpenings[0]
|
||||
assert plate.HasOpenings[0].RelatedOpeningElement == opening
|
||||
assert new.HasOpenings[0].RelatedOpeningElement != opening
|
||||
assert new.HasOpenings[0].RelatedOpeningElement.is_a("IfcVoidingFeature")
|
||||
|
||||
def test_copying_an_element_with_a_filled_opening_should_not_copy_the_opening_nor_fill(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
window = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindow")
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
|
||||
ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=window)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=wall)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
window = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWindow")
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
|
||||
ifcopenshell.api.void.add_filling(self.file, opening=opening, element=window)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=wall)
|
||||
assert not new.HasOpenings
|
||||
|
||||
def test_copying_an_opening_voiding_an_element(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=opening)
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=wall)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=opening)
|
||||
assert opening.VoidsElements[0] != new.VoidsElements[0]
|
||||
assert new.VoidsElements[0].RelatingBuildingElement == wall
|
||||
|
||||
def test_copying_an_opening_with_a_filling(self):
|
||||
door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=opening)
|
||||
door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.void.add_filling(self.file, opening=opening, element=door)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=opening)
|
||||
assert not new.HasFillings
|
||||
|
||||
def test_copying_a_filling(self):
|
||||
door = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=door)
|
||||
door = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.void.add_filling(self.file, opening=opening, element=door)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=door)
|
||||
assert not new.FillsVoids
|
||||
|
||||
def test_retaining_a_single_material(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = self.file.createIfcMaterial()
|
||||
self.file.createIfcRelAssociatesMaterial(RelatedObjects=[element], RelatingMaterial=material)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert new.HasAssociations[0].RelatingMaterial == element.HasAssociations[0].RelatingMaterial
|
||||
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterial")
|
||||
|
||||
def test_copying_material_set_usages(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = self.file.createIfcMaterialLayerSetUsage()
|
||||
self.file.createIfcRelAssociatesMaterial(RelatedObjects=[element], RelatingMaterial=material)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert new.HasAssociations[0].RelatingMaterial != element.HasAssociations[0].RelatingMaterial
|
||||
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterialLayerSetUsage")
|
||||
|
||||
def test_copying_material_sets_for_type_elements_only(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
single_material = self.file.createIfcMaterial()
|
||||
layer = self.file.createIfcMaterialLayer(Material=single_material)
|
||||
material = self.file.createIfcMaterialLayerSet(MaterialLayers=[layer])
|
||||
self.file.createIfcRelAssociatesMaterial(RelatedObjects=[element], RelatingMaterial=material)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterialLayerSet")
|
||||
assert new.HasAssociations[0].RelatingMaterial != element.HasAssociations[0].RelatingMaterial
|
||||
assert (
|
||||
@@ -208,25 +217,25 @@ class TestCopyClass(test.bootstrap.IFC4):
|
||||
)
|
||||
|
||||
def test_copying_a_type_and_purging_type_relationships(self):
|
||||
type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=type)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=type)
|
||||
type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=type)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=type)
|
||||
assert not new.Types
|
||||
|
||||
def test_copying_distribution_ports(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcChiller")
|
||||
port = ifcopenshell.api.run("system.add_port", self.file)
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcChiller")
|
||||
port = ifcopenshell.api.system.add_port(self.file)
|
||||
ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
|
||||
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcChiller")
|
||||
port2 = ifcopenshell.api.run("system.add_port", self.file)
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element2, port=port2)
|
||||
ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, direction="NOTDEFINED")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcChiller")
|
||||
port2 = ifcopenshell.api.system.add_port(self.file)
|
||||
ifcopenshell.api.system.assign_port(self.file, element=element2, port=port2)
|
||||
ifcopenshell.api.system.connect_port(self.file, port1=port, port2=port2, direction="NOTDEFINED")
|
||||
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
new_ports = ifcopenshell.util.system.get_ports(new)
|
||||
assert port not in new_ports
|
||||
assert new_ports[0].is_a("IfcDistributionPort")
|
||||
@@ -235,17 +244,16 @@ class TestCopyClass(test.bootstrap.IFC4):
|
||||
assert not ifcopenshell.util.system.get_connected_port(new_ports[0])
|
||||
|
||||
def test_not_copying_path_connections(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"geometry.connect_path",
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_path(
|
||||
self.file,
|
||||
relating_element=element1,
|
||||
related_element=element2,
|
||||
relating_connection="ATSTART",
|
||||
related_connection="ATEND",
|
||||
)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element1)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element1)
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
assert element1.ConnectedTo
|
||||
assert element2.ConnectedFrom
|
||||
@@ -253,20 +261,20 @@ class TestCopyClass(test.bootstrap.IFC4):
|
||||
assert not new.ConnectedFrom
|
||||
|
||||
def test_maintaining_group_relationships(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.run("group.add_group", self.file)
|
||||
ifcopenshell.api.run("group.assign_group", self.file, group=group, products=[element])
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.group.add_group(self.file)
|
||||
ifcopenshell.api.group.assign_group(self.file, group=group, products=[element])
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 1
|
||||
assert new.HasAssignments[0].RelatingGroup == group
|
||||
|
||||
|
||||
class TestCopyClassIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_copying_distribution_ports(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowTerminal")
|
||||
port = ifcopenshell.api.run("system.add_port", self.file)
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowTerminal")
|
||||
port = ifcopenshell.api.system.add_port(self.file)
|
||||
ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
|
||||
new = ifcopenshell.api.root.copy_class(self.file, product=element)
|
||||
new_ports = ifcopenshell.util.system.get_ports(new)
|
||||
assert port not in new_ports
|
||||
assert new_ports[0].is_a("IfcDistributionPort")
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
|
||||
|
||||
class TestCreateEntity(test.bootstrap.IFC4):
|
||||
def test_creating_a_simple_entity_with_automatic_global_id(self):
|
||||
wall = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
|
||||
wall = ifcopenshell.api.root.create_entity(
|
||||
self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
|
||||
)
|
||||
assert wall.is_a() == "IfcRailing"
|
||||
assert len(wall.GlobalId) == 22
|
||||
@@ -31,48 +31,48 @@ class TestCreateEntity(test.bootstrap.IFC4):
|
||||
assert wall.PredefinedType == "HANDRAIL"
|
||||
|
||||
def test_handling_predefined_types(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcRailing", name="Foo")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcRailing", name="Foo")
|
||||
assert element.PredefinedType is None
|
||||
element = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
|
||||
element = ifcopenshell.api.root.create_entity(
|
||||
self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
|
||||
)
|
||||
assert element.PredefinedType == "HANDRAIL"
|
||||
element = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="Foobar", name="Foo"
|
||||
element = ifcopenshell.api.root.create_entity(
|
||||
self.file, ifc_class="IfcRailing", predefined_type="Foobar", name="Foo"
|
||||
)
|
||||
assert element.PredefinedType == "USERDEFINED"
|
||||
assert element.ObjectType == "Foobar"
|
||||
element = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcWallType", predefined_type="Foobar", name="Foo"
|
||||
element = ifcopenshell.api.root.create_entity(
|
||||
self.file, ifc_class="IfcWallType", predefined_type="Foobar", name="Foo"
|
||||
)
|
||||
assert element.PredefinedType == "USERDEFINED"
|
||||
assert element.ElementType == "Foobar"
|
||||
if self.file.schema != "IFC2X3":
|
||||
element = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcTaskType", predefined_type="Foobar", name="Foo"
|
||||
element = ifcopenshell.api.root.create_entity(
|
||||
self.file, ifc_class="IfcTaskType", predefined_type="Foobar", name="Foo"
|
||||
)
|
||||
assert element.PredefinedType == "USERDEFINED"
|
||||
assert element.ProcessType == "Foobar"
|
||||
|
||||
def test_setting_default_values_for_validity(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType", name="Foo")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType", name="Foo")
|
||||
assert element.PredefinedType == "NOTDEFINED"
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoorStyle", name="Foo")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoorStyle", name="Foo")
|
||||
assert element.OperationType == "NOTDEFINED"
|
||||
assert element.ConstructionType == "NOTDEFINED"
|
||||
assert element.ParameterTakesPrecedence == False
|
||||
assert element.Sizeable == False
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindowStyle", name="Foo")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWindowStyle", name="Foo")
|
||||
assert element.OperationType == "NOTDEFINED"
|
||||
assert element.ConstructionType == "NOTDEFINED"
|
||||
assert element.ParameterTakesPrecedence == False
|
||||
assert element.Sizeable == False
|
||||
if self.file.schema != "IFC2X3":
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoorType", name="Foo")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoorType", name="Foo")
|
||||
assert element.OperationType == "NOTDEFINED"
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindowType", name="Foo")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWindowType", name="Foo")
|
||||
assert element.PartitioningType == "NOTDEFINED"
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFurnitureType", name="Foo")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFurnitureType", name="Foo")
|
||||
assert element.AssemblyPlace == "NOTDEFINED"
|
||||
|
||||
|
||||
|
||||
@@ -17,52 +17,53 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.type
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestReassignClass(test.bootstrap.IFC4):
|
||||
def test_reassigning_a_simple_class(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
n_elements = len([e for e in self.file])
|
||||
original_id = element.id()
|
||||
new = ifcopenshell.api.run("root.reassign_class", self.file, product=element, ifc_class="IfcSlab")
|
||||
new = ifcopenshell.api.root.reassign_class(self.file, product=element, ifc_class="IfcSlab")
|
||||
assert len([e for e in self.file]) == n_elements
|
||||
assert new.id() == original_id
|
||||
assert new.is_a("IfcSlab")
|
||||
|
||||
def test_reassigning_a_predefined_type(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
new = ifcopenshell.api.run(
|
||||
"root.reassign_class", self.file, product=element, ifc_class="IfcSlab", predefined_type="FLOOR"
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
new = ifcopenshell.api.root.reassign_class(
|
||||
self.file, product=element, ifc_class="IfcSlab", predefined_type="FLOOR"
|
||||
)
|
||||
assert new.PredefinedType == "FLOOR"
|
||||
|
||||
def test_falling_back_to_userdefined_if_the_predefined_type_cannot_be_reassigned_for_occurrence_class(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
new = ifcopenshell.api.run(
|
||||
"root.reassign_class", self.file, product=element, ifc_class="IfcSlab", predefined_type="FOO"
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
new = ifcopenshell.api.root.reassign_class(
|
||||
self.file, product=element, ifc_class="IfcSlab", predefined_type="FOO"
|
||||
)
|
||||
assert new.PredefinedType == "USERDEFINED"
|
||||
assert new.ObjectType == "FOO"
|
||||
|
||||
def test_falling_back_to_userdefined_if_the_predefined_type_cannot_be_reassigned_for_type_class(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
new = ifcopenshell.api.run(
|
||||
"root.reassign_class", self.file, product=element, ifc_class="IfcSlabType", predefined_type="FOO"
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
new = ifcopenshell.api.root.reassign_class(
|
||||
self.file, product=element, ifc_class="IfcSlabType", predefined_type="FOO"
|
||||
)
|
||||
assert new.PredefinedType == "USERDEFINED"
|
||||
assert new.ElementType == "FOO"
|
||||
|
||||
def test_reassign_class_for_type_occurrences(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
|
||||
|
||||
element_type = ifcopenshell.api.run(
|
||||
"root.reassign_class", self.file, product=element_type, ifc_class="IfcSlabType"
|
||||
element_type = ifcopenshell.api.root.reassign_class(
|
||||
self.file, product=element_type, ifc_class="IfcSlabType"
|
||||
)
|
||||
|
||||
# type occurrences have reassigned classes
|
||||
@@ -75,13 +76,13 @@ class TestReassignClass(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcWallType")) == 0
|
||||
|
||||
def test_reassigning_type_class_and_its_occurrences_classes_if_entity_was_typed(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
|
||||
|
||||
element1 = ifcopenshell.api.run("root.reassign_class", self.file, product=element1, ifc_class="IfcSlab")
|
||||
element1 = ifcopenshell.api.root.reassign_class(self.file, product=element1, ifc_class="IfcSlab")
|
||||
|
||||
# occurrence type has reassigned class
|
||||
element_type = ifcopenshell.util.element.get_type(element1)
|
||||
|
||||
@@ -17,68 +17,83 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.unit
|
||||
import ifcopenshell.api.nest
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.void
|
||||
import ifcopenshell.api.grid
|
||||
import ifcopenshell.api.type
|
||||
import ifcopenshell.api.pset
|
||||
import ifcopenshell.api.group
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.api.system
|
||||
import ifcopenshell.api.spatial
|
||||
import ifcopenshell.api.drawing
|
||||
import ifcopenshell.api.context
|
||||
import ifcopenshell.api.geometry
|
||||
import ifcopenshell.api.material
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
def test_removing_an_element_by_itself(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
|
||||
def test_removing_an_element_local_placement(self):
|
||||
# just removing the product with the placement
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
placement = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
placement = ifcopenshell.api.geometry.edit_object_placement(self.file, product=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(self.file.by_type("IfcObjectPlacement")) == 0
|
||||
|
||||
# removing the product that shares the placement with other product
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
placement = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element)
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
placement = ifcopenshell.api.geometry.edit_object_placement(self.file, product=element)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element1.ObjectPlacement = placement
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(self.file.by_type("IfcObjectPlacement")) == 1
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element1)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element1)
|
||||
assert len(self.file.by_type("IfcObjectPlacement")) == 0
|
||||
|
||||
# removing the product that's placement used as a reference point for another placement
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
placement = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element)
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
placement1 = ifcopenshell.api.run("geometry.edit_object_placement", self.file, product=element1)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
placement = ifcopenshell.api.geometry.edit_object_placement(self.file, product=element)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
placement1 = ifcopenshell.api.geometry.edit_object_placement(self.file, product=element1)
|
||||
placement.PlacementRelTo = placement1
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(self.file.by_type("IfcObjectPlacement")) == 1
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element1)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element1)
|
||||
assert len(self.file.by_type("IfcObjectPlacement")) == 0
|
||||
|
||||
def test_removing_element_type_psets(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
element2.HasPropertySets = (pset,)
|
||||
|
||||
# make sure it won't remove the pset if it's connected elsewhere
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element2)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element2)
|
||||
assert len(self.file.by_type("IfcPropertySet")) == 1
|
||||
assert len(self.file.by_type("IfcPropertySingleValue")) == 1
|
||||
|
||||
# if it's the product is the only inverse for pset, it should remove the pset
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(self.file.by_type("IfcPropertySet")) == 0
|
||||
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
|
||||
|
||||
def test_removing_all_representations_of_an_element(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
total_entities = len(list(self.file))
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element.Representation = self.file.createIfcProductDefinitionShape(
|
||||
Representations=[
|
||||
self.file.createIfcShapeRepresentation(
|
||||
@@ -86,7 +101,7 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
)
|
||||
]
|
||||
)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
|
||||
@@ -94,10 +109,10 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
|
||||
def test_unassigning_but_not_removing_mapped_representations_of_an_element(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.unit.assign_unit(self.file)
|
||||
context = ifcopenshell.api.context.add_context(self.file, context_type="Model")
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
rep_map = self.file.createIfcRepresentationMap(
|
||||
MappingOrigin=self.file.createIfcAxis2Placement3D(),
|
||||
MappedRepresentation=self.file.createIfcShapeRepresentation(
|
||||
@@ -106,10 +121,9 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
)
|
||||
element_type.RepresentationMaps = [rep_map]
|
||||
total_entities = len(list(self.file))
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
# should_map_representations=False to create mapping manually
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type",
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file,
|
||||
related_objects=[element],
|
||||
relating_type=element_type,
|
||||
@@ -129,7 +143,7 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
]
|
||||
)
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 2
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcProductDefinitionShape")) == 0
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
|
||||
@@ -138,329 +152,316 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
|
||||
def test_removing_an_element_type_by_itself(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(self.file.by_type("IfcWallType")) == 0
|
||||
|
||||
def test_removing_all_openings_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(list(self.file)) == 0
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
assert len(self.file.by_type("IfcOpeningElement")) == 0
|
||||
assert len(self.file.by_type("IfcRelVoidsElement")) == 0
|
||||
|
||||
def test_removing_axes_of_a_grid(self):
|
||||
grid = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcGrid")
|
||||
axis = ifcopenshell.api.run("grid.create_grid_axis", self.file, uvw_axes="UAxes", grid=grid)
|
||||
grid = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcGrid")
|
||||
axis = ifcopenshell.api.grid.create_grid_axis(self.file, uvw_axes="UAxes", grid=grid)
|
||||
axis.AxisCurve = self.file.createIfcPolyline()
|
||||
axis = ifcopenshell.api.run("grid.create_grid_axis", self.file, uvw_axes="VAxes", grid=grid)
|
||||
axis = ifcopenshell.api.grid.create_grid_axis(self.file, uvw_axes="VAxes", grid=grid)
|
||||
axis.AxisCurve = self.file.createIfcPolyline()
|
||||
total_entities = len(list(self.file))
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=grid)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=grid)
|
||||
assert len(list(self.file)) == 0
|
||||
|
||||
def test_removing_all_void_relationships_of_an_opening(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
total_entities = len(list(self.file))
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=opening)
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=opening)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcOpeningElement")) == 0
|
||||
assert len(self.file.by_type("IfcRelVoidsElement")) == 0
|
||||
|
||||
def test_removing_all_fill_relationships_of_a_filling(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||
filling = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoor")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
opening = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcOpeningElement")
|
||||
filling = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDoor")
|
||||
total_entities = len(list(self.file))
|
||||
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=element)
|
||||
ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=filling)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=filling)
|
||||
ifcopenshell.api.void.add_opening(self.file, opening=opening, element=element)
|
||||
ifcopenshell.api.void.add_filling(self.file, opening=opening, element=filling)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=filling)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcDoor")) == 0
|
||||
assert len(self.file.by_type("IfcRelFillsElement")) == 0
|
||||
|
||||
def test_removing_all_distribution_ports(self):
|
||||
total_entities = len(list(self.file))
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
port = ifcopenshell.api.run("system.add_port", self.file, element=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
port = ifcopenshell.api.system.add_port(self.file, element=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcFlowSegment")) == 0
|
||||
assert len(self.file.by_type("IfcRelNests")) == 0
|
||||
assert len(self.file.by_type("IfcDistributionPort")) == 0
|
||||
|
||||
def test_removing_all_nesting_relationships_of_a_whole(self):
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
|
||||
total_entities = len(list(self.file))
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelNests")) == 0
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
assert len(self.file.by_type("IfcBeam")) == 1
|
||||
|
||||
def test_removing_all_nesting_relationships_of_a_part(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
total_entities = len(list(self.file))
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.run("nest.assign_object", self.file, related_objects=[subelement], relating_object=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=subelement)
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.nest.assign_object(self.file, related_objects=[subelement], relating_object=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=subelement)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelNests")) == 0
|
||||
assert len(self.file.by_type("IfcWall")) == 1
|
||||
assert len(self.file.by_type("IfcBeam")) == 0
|
||||
|
||||
def test_removing_all_aggregate_relationships_of_a_whole(self):
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
|
||||
total_entities = len(list(self.file))
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelAggregates")) == 0
|
||||
assert len(self.file.by_type("IfcElementAssembly")) == 0
|
||||
assert len(self.file.by_type("IfcBeam")) == 1
|
||||
|
||||
def test_removing_all_aggregate_relationships_of_a_part(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcElementAssembly")
|
||||
total_entities = len(list(self.file))
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=subelement)
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.aggregate.assign_object(self.file, products=[subelement], relating_object=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=subelement)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelAggregates")) == 0
|
||||
assert len(self.file.by_type("IfcElementAssembly")) == 1
|
||||
assert len(self.file.by_type("IfcBeam")) == 0
|
||||
|
||||
def test_removing_all_containment_relationships_of_a_container(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSpace")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSpace")
|
||||
total_entities = len(list(self.file))
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelContainedInSpatialStructure")) == 0
|
||||
assert len(self.file.by_type("IfcSpace")) == 0
|
||||
assert len(self.file.by_type("IfcWall")) == 1
|
||||
|
||||
def test_removing_all_containment_relationships_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSpace")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSpace")
|
||||
total_entities = len(list(self.file))
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=subelement)
|
||||
subelement = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.spatial.assign_container(self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=subelement)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelContainedInSpatialStructure")) == 0
|
||||
assert len(self.file.by_type("IfcSpace")) == 1
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
|
||||
def test_removing_path_connection_relationships_of_an_element(self):
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcColumn")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcColumn")
|
||||
total_entities = len(list(self.file))
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=element1, related_element=element2)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element1)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=element1, related_element=element2)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element1)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 0
|
||||
assert len(self.file.by_type("IfcColumn")) == 1
|
||||
assert len(self.file.by_type("IfcBeam")) == 0
|
||||
|
||||
def test_removing_connection_relationships_of_an_element(self):
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
total_entities = len(list(self.file))
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"geometry.connect_element",
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_element(
|
||||
self.file,
|
||||
related_element=element1,
|
||||
relating_element=element2,
|
||||
)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element1)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element1)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelConnectsElements")) == 0
|
||||
assert len(self.file.by_type("IfcSlab")) == 1
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
|
||||
def test_removing_connection_relationships_of_an_element_with_additional_realizing_element(self):
|
||||
slab1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
slab2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
slab1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
slab2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
total_entities = len(list(self.file))
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
self.file.createIfcRelConnectsWithRealizingElements(
|
||||
ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
|
||||
RelatingElement=wall,
|
||||
RelatedElement=slab1,
|
||||
RealizingElements=(wall, slab1, slab2),
|
||||
)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=wall)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=wall)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelConnectsElements")) == 0
|
||||
assert len(self.file.by_type("IfcSlab")) == 2
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
|
||||
def test_removing_connection_relationships_of_an_element_element_is_realizing_element(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
slab1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
slab1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
total_entities = len(list(self.file))
|
||||
slab2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
slab2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
slab2_entities = len(list(self.file)) - total_entities
|
||||
self.file.createIfcRelConnectsWithRealizingElements(
|
||||
ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
|
||||
RelatingElement=wall,
|
||||
RelatedElement=slab1,
|
||||
RealizingElements=(wall, slab1, slab2),
|
||||
)
|
||||
total_entities = len(list(self.file))
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=slab2)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=slab2)
|
||||
assert len(list(self.file)) == (total_entities - slab2_entities)
|
||||
assert len(self.file.by_type("IfcRelConnectsElements")) == 1
|
||||
assert len(self.file.by_type("IfcSlab")) == 1
|
||||
assert len(self.file.by_type("IfcWall")) == 1
|
||||
|
||||
def test_removing_connection_relationships_of_an_element_element_is_only_realizing_element(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
slab1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
slab1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
total_entities = len(list(self.file))
|
||||
slab2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
slab2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
self.file.createIfcRelConnectsWithRealizingElements(
|
||||
ifcopenshell.guid.new(),
|
||||
OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(self.file),
|
||||
RelatingElement=wall,
|
||||
RelatedElement=slab1,
|
||||
RealizingElements=(slab2,),
|
||||
)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=slab2)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=slab2)
|
||||
assert len(list(self.file)) == total_entities
|
||||
assert len(self.file.by_type("IfcRelConnectsElements")) == 0
|
||||
assert len(self.file.by_type("IfcSlab")) == 1
|
||||
assert len(self.file.by_type("IfcWall")) == 1
|
||||
|
||||
def test_removing_ports_connection_relationship(self):
|
||||
port1 = ifcopenshell.api.run("system.add_port", self.file)
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element1, port=port1)
|
||||
port1 = ifcopenshell.api.system.add_port(self.file)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
ifcopenshell.api.system.assign_port(self.file, element=element1, port=port1)
|
||||
|
||||
port2 = ifcopenshell.api.run("system.add_port", self.file)
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element2, port=port2)
|
||||
port2 = ifcopenshell.api.system.add_port(self.file)
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
ifcopenshell.api.system.assign_port(self.file, element=element2, port=port2)
|
||||
|
||||
ifcopenshell.api.run("system.connect_port", self.file, port1=port1, port2=port2, direction="SOURCE")
|
||||
ifcopenshell.api.system.connect_port(self.file, port1=port1, port2=port2, direction="SOURCE")
|
||||
connection = self.file.by_type("IfcRelConnectsPorts")[0]
|
||||
|
||||
# making sure removing realizing element won't remove the entire connection since it's optional
|
||||
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
connection.RealizingElement = element3
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element3)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element3)
|
||||
assert len(self.file.by_type("IfcRelConnectsPorts")) == 1
|
||||
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element1)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element1)
|
||||
assert len(self.file.by_type("IfcRelConnectsPorts")) == 0
|
||||
assert len(self.file.by_type("IfcFlowSegment")) == 1
|
||||
assert len(self.file.by_type("IfcDistributionPort")) == 1
|
||||
|
||||
def test_removing_all_property_relationships_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert not self.file.by_type("IfcRelDefinesByProperties")
|
||||
assert not self.file.by_type("IfcPropertySet")
|
||||
assert not self.file.by_type("IfcPropertySingleValue")
|
||||
|
||||
def test_removing_all_material_relationships_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="Foo")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.material.add_material(self.file, name="Foo")
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert not self.file.by_type("IfcRelAssociatesMaterial")
|
||||
assert self.file.by_type("IfcMaterial")
|
||||
|
||||
def test_removing_all_type_relationships_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert not self.file.by_type("IfcRelDefinesByType")
|
||||
assert self.file.by_type("IfcWallType")
|
||||
|
||||
def test_removing_all_type_relationships_of_an_element_type(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element_type)
|
||||
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element1], relating_type=element_type)
|
||||
ifcopenshell.api.type.assign_type(self.file, related_objects=[element2], relating_type=element_type)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element_type)
|
||||
assert not self.file.by_type("IfcRelDefinesByType")
|
||||
assert self.file.by_type("IfcWall")
|
||||
|
||||
def test_removing_all_space_boundaries_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
boundary = self.file.createIfcRelSpaceBoundary(GlobalId=ifcopenshell.guid.new(), RelatedBuildingElement=element)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert not self.file.by_type("IfcRelSpaceBoundary")
|
||||
|
||||
def test_removing_orphaned_group_relationships(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.run("group.add_group", self.file, name="Unit 1A")
|
||||
ifcopenshell.api.run("group.assign_group", self.file, products=[element], group=group)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
group = ifcopenshell.api.group.add_group(self.file, name="Unit 1A")
|
||||
ifcopenshell.api.group.assign_group(self.file, products=[element], group=group)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert not self.file.by_type("IfcRelAssignsToGroup")
|
||||
|
||||
def test_removing_product_assignments(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
annotation = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=element, related_object=annotation)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
annotation = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcAnnotation")
|
||||
ifcopenshell.api.drawing.assign_product(self.file, relating_product=element, related_object=annotation)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=element)
|
||||
assert not self.file.by_type("IfcRelAssignsToProduct")
|
||||
|
||||
def test_removing_flow_control_elements(self):
|
||||
flow_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
flow_control = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDistributionControlElement")
|
||||
flow_control1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDistributionControlElement")
|
||||
flow_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
flow_control = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionControlElement")
|
||||
flow_control1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionControlElement")
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
self.file,
|
||||
related_flow_control=flow_control,
|
||||
relating_flow_element=flow_element,
|
||||
ifcopenshell.api.system.assign_flow_control(
|
||||
self.file, related_flow_control=flow_control, relating_flow_element=flow_element
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
self.file,
|
||||
related_flow_control=flow_control1,
|
||||
relating_flow_element=flow_element,
|
||||
ifcopenshell.api.system.assign_flow_control(
|
||||
self.file, related_flow_control=flow_control1, relating_flow_element=flow_element
|
||||
)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=flow_control)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=flow_control)
|
||||
assert len(self.file.by_type("IfcRelFlowControlElements")) == 1
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=flow_control1)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=flow_control1)
|
||||
assert not self.file.by_type("IfcRelFlowControlElements")
|
||||
|
||||
def test_removing_flow_element_with_flow_controls(self):
|
||||
flow_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
flow_control = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDistributionControlElement")
|
||||
flow_control1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDistributionControlElement")
|
||||
flow_element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
|
||||
flow_control = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionControlElement")
|
||||
flow_control1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcDistributionControlElement")
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
self.file,
|
||||
related_flow_control=flow_control,
|
||||
relating_flow_element=flow_element,
|
||||
ifcopenshell.api.system.assign_flow_control(
|
||||
self.file, related_flow_control=flow_control, relating_flow_element=flow_element
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
self.file,
|
||||
related_flow_control=flow_control1,
|
||||
relating_flow_element=flow_element,
|
||||
ifcopenshell.api.system.assign_flow_control(
|
||||
self.file, related_flow_control=flow_control1, relating_flow_element=flow_element
|
||||
)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=flow_element)
|
||||
ifcopenshell.api.root.remove_product(self.file, product=flow_element)
|
||||
assert not self.file.by_type("IfcRelFlowControlElements")
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user