mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user