mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
ifc2x3 tests
This commit is contained in:
@@ -23,22 +23,22 @@ import ifcopenshell.api
|
||||
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="IfcWall", predefined_type="SOLIDWALL", name="Foo"
|
||||
"root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
|
||||
)
|
||||
assert wall.is_a() == "IfcWall"
|
||||
assert wall.is_a() == "IfcRailing"
|
||||
assert len(wall.GlobalId) == 22
|
||||
assert wall.Name == "Foo"
|
||||
assert wall.PredefinedType == "SOLIDWALL"
|
||||
assert wall.PredefinedType == "HANDRAIL"
|
||||
|
||||
def test_handling_predefined_types(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall", name="Foo")
|
||||
element = ifcopenshell.api.run("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="IfcWall", predefined_type="SHEAR", name="Foo"
|
||||
"root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="HANDRAIL", name="Foo"
|
||||
)
|
||||
assert element.PredefinedType == "SHEAR"
|
||||
assert element.PredefinedType == "HANDRAIL"
|
||||
element = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcWall", predefined_type="Foobar", name="Foo"
|
||||
"root.create_entity", self.file, ifc_class="IfcRailing", predefined_type="Foobar", name="Foo"
|
||||
)
|
||||
assert element.PredefinedType == "USERDEFINED"
|
||||
assert element.ObjectType == "Foobar"
|
||||
@@ -47,11 +47,12 @@ class TestCreateEntity(test.bootstrap.IFC4):
|
||||
)
|
||||
assert element.PredefinedType == "USERDEFINED"
|
||||
assert element.ElementType == "Foobar"
|
||||
element = ifcopenshell.api.run(
|
||||
"root.create_entity", self.file, ifc_class="IfcTaskType", predefined_type="Foobar", name="Foo"
|
||||
)
|
||||
assert element.PredefinedType == "USERDEFINED"
|
||||
assert element.ProcessType == "Foobar"
|
||||
if self.file.schema != "IFC2X3":
|
||||
element = ifcopenshell.api.run(
|
||||
"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")
|
||||
@@ -66,9 +67,14 @@ class TestCreateEntity(test.bootstrap.IFC4):
|
||||
assert element.ConstructionType == "NOTDEFINED"
|
||||
assert element.ParameterTakesPrecedence == False
|
||||
assert element.Sizeable == False
|
||||
element = ifcopenshell.api.run("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")
|
||||
assert element.PartitioningType == "NOTDEFINED"
|
||||
if self.file.schema != "IFC2X3":
|
||||
element = ifcopenshell.api.run("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")
|
||||
assert element.PartitioningType == "NOTDEFINED"
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFurnitureType", name="Foo")
|
||||
assert element.AssemblyPlace == "NOTDEFINED"
|
||||
|
||||
|
||||
class TestCreateEntityIFC2X3(test.bootstrap.IFC2X3, TestCreateEntity):
|
||||
pass
|
||||
|
||||
@@ -18,14 +18,17 @@
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
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")
|
||||
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")
|
||||
assert len([e for e in self.file]) == 1
|
||||
assert new.id() == 1
|
||||
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):
|
||||
@@ -92,3 +95,7 @@ class TestReassignClass(test.bootstrap.IFC4):
|
||||
# original clases are gone
|
||||
assert len(self.file.by_type("IfcWall")) == 0
|
||||
assert len(self.file.by_type("IfcWallType")) == 0
|
||||
|
||||
|
||||
class TestReassignClassIFC2X3(test.bootstrap.IFC2X3, TestReassignClass):
|
||||
pass
|
||||
|
||||
@@ -395,7 +395,7 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
|
||||
def test_removing_all_space_boundaries_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
boundary = self.file.createIfcRelSpaceBoundary2ndLevel(
|
||||
boundary = self.file.createIfcRelSpaceBoundary(
|
||||
GlobalId=ifcopenshell.guid.new(), RelatedBuildingElement=element
|
||||
)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
@@ -417,8 +417,8 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
|
||||
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="IfcController")
|
||||
flow_control1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcController")
|
||||
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")
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
@@ -439,8 +439,8 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
|
||||
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="IfcController")
|
||||
flow_control1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcController")
|
||||
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")
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
@@ -456,3 +456,7 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=flow_element)
|
||||
assert not self.file.by_type("IfcRelFlowControlElements")
|
||||
|
||||
|
||||
class TestRemoveProductIFC2X3(test.bootstrap.IFC2X3, TestRemoveProduct):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user