mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
ifc2x3 tests
This commit is contained in:
@@ -121,27 +121,36 @@ def add_pset(file: ifcopenshell.file, product: ifcopenshell.entity_instance, nam
|
||||
has_property_sets.append(pset)
|
||||
settings["product"].HasPropertySets = has_property_sets
|
||||
return pset
|
||||
elif settings["product"].is_a("IfcMaterialDefinition"):
|
||||
for definition in settings["product"].HasProperties or []:
|
||||
if definition.Name == settings["name"]:
|
||||
# in IFC2X3 IfcMaterialDefinition not yet existed
|
||||
elif settings["product"].is_a("IfcMaterialDefinition") or settings["product"].is_a("IfcMaterial"):
|
||||
if file.schema == "IFC2X3":
|
||||
ifc_class = "IfcExtendedMaterialProperties"
|
||||
definitions = (d for d in file.by_type("IfcMaterialProperties") if d.Material == settings["product"])
|
||||
else:
|
||||
ifc_class = "IfcMaterialProperties"
|
||||
definitions = settings["product"].HasProperties
|
||||
for definition in definitions:
|
||||
# In IFC2X3 not all IfcMaterialProperties has Name
|
||||
if getattr(definition, "Name") == settings["name"]:
|
||||
return definition
|
||||
|
||||
return file.create_entity(
|
||||
"IfcMaterialProperties",
|
||||
ifc_class,
|
||||
**{
|
||||
"Name": settings["name"],
|
||||
"Material": settings["product"],
|
||||
}
|
||||
)
|
||||
elif settings["product"].is_a("IfcProfileDef"):
|
||||
for definition in settings["product"].HasProperties or []:
|
||||
if definition.Name == settings["name"]:
|
||||
return definition
|
||||
# in IFC2X3 IfcProfileProperties doesn't have Name and we cannot identify them
|
||||
if file.schema != "IFC2X3":
|
||||
for definition in settings["product"].HasProperties or []:
|
||||
if definition.Name == settings["name"]:
|
||||
return definition
|
||||
|
||||
return file.create_entity(
|
||||
"IfcProfileProperties",
|
||||
**{
|
||||
"Name": settings["name"],
|
||||
"ProfileDefinition": settings["product"],
|
||||
}
|
||||
)
|
||||
kwargs = {}
|
||||
kwargs["ProfileDefinition"] = settings["product"]
|
||||
if file.schema != "IFC2X3":
|
||||
kwargs["Name"] = settings["name"]
|
||||
|
||||
return file.create_entity("IfcProfileProperties", **kwargs)
|
||||
|
||||
@@ -97,7 +97,7 @@ def add_resource(
|
||||
related_objects=[resource],
|
||||
relating_object=settings["parent_resource"],
|
||||
)
|
||||
else:
|
||||
elif file.schema != "IFC2X3":
|
||||
context = file.by_type("IfcContext")[0]
|
||||
ifcopenshell.api.run(
|
||||
"project.assign_declaration",
|
||||
|
||||
@@ -175,6 +175,6 @@ def add_task(
|
||||
related_objects=[task],
|
||||
relating_object=settings["parent_task"],
|
||||
)
|
||||
if settings["parent_task"].Identification:
|
||||
if file.schema != "IFC2X3" and settings["parent_task"].Identification:
|
||||
task.Identification = settings["parent_task"].Identification + "." + str(len(rel.RelatedObjects))
|
||||
return task
|
||||
|
||||
@@ -90,11 +90,17 @@ def add_work_schedule(
|
||||
predefined_type=settings["predefined_type"],
|
||||
name=settings["name"],
|
||||
)
|
||||
work_schedule.CreationDate = ifcopenshell.util.date.datetime2ifc(datetime.now(), "IfcDateTime")
|
||||
if file.schema == "IFC2X3":
|
||||
work_schedule.CreationDate = createIfcDateAndTime(file, datetime.now())
|
||||
else:
|
||||
work_schedule.CreationDate = ifcopenshell.util.date.datetime2ifc(datetime.now(), "IfcDateTime")
|
||||
user = ifcopenshell.api.owner.settings.get_user(file)
|
||||
if user:
|
||||
work_schedule.Creators = [user.ThePerson]
|
||||
work_schedule.StartTime = ifcopenshell.util.date.datetime2ifc(settings["start_time"], "IfcDateTime")
|
||||
if file.schema == "IFC2X3":
|
||||
work_schedule.StartTime = createIfcDateAndTime(file, settings["start_time"])
|
||||
else:
|
||||
work_schedule.StartTime = ifcopenshell.util.date.datetime2ifc(settings["start_time"], "IfcDateTime")
|
||||
if settings["object_type"]:
|
||||
work_schedule.ObjectType = settings["object_type"]
|
||||
if settings["work_plan"]:
|
||||
@@ -106,7 +112,7 @@ def add_work_schedule(
|
||||
"relating_object": settings["work_plan"],
|
||||
}
|
||||
)
|
||||
else:
|
||||
elif file.schema != "IFC2X3":
|
||||
# TODO: this is an ambiguity by buildingSMART
|
||||
# See https://forums.buildingsmart.org/t/is-the-ifcworkschedule-project-declaration-mutually-exclusive-to-aggregation-within-a-relating-ifcworkplan/3510
|
||||
context = file.by_type("IfcContext")[0]
|
||||
@@ -117,3 +123,12 @@ def add_work_schedule(
|
||||
relating_context=context,
|
||||
)
|
||||
return work_schedule
|
||||
|
||||
|
||||
def createIfcDateAndTime(file: ifcopenshell.file, dt: datetime):
|
||||
ifc_dt = file.create_entity("IfcDateAndTime")
|
||||
ifc_dt.DateComponent = file.create_entity(
|
||||
"IfcCalendarDate", **ifcopenshell.util.date.datetime2ifc(dt, "IfcCalendarDate")
|
||||
)
|
||||
ifc_dt.TimeComponent = file.create_entity("IfcLocalTime", **ifcopenshell.util.date.datetime2ifc(dt, "IfcLocalTime"))
|
||||
return ifc_dt
|
||||
|
||||
@@ -177,11 +177,31 @@ class Usecase:
|
||||
representations.append(self.create_styled_representation())
|
||||
definition_representation.Representations = representations
|
||||
|
||||
def has_proposed_style(self, styled_item):
|
||||
return any(s == self.settings["style"] for s in styled_item.Styles)
|
||||
def has_proposed_style(self, styled_item: ifcopenshell.entity_instance) -> bool:
|
||||
style = self.settings["style"]
|
||||
styles = styled_item.Styles
|
||||
if style in styles:
|
||||
return True
|
||||
if self.file.schema != "IFC4X3":
|
||||
# IfcPresentationStyleAssignment is removed in IFC4X3
|
||||
for s in styles:
|
||||
if s.is_a("IfcPresentationStyleAssignment"):
|
||||
if style in s.Styles:
|
||||
return True
|
||||
return False
|
||||
|
||||
def has_same_style_type(self, styled_item):
|
||||
return any(s.is_a() == self.settings["style"].is_a() for s in styled_item.Styles)
|
||||
def has_same_style_type(self, styled_item: ifcopenshell.entity_instance) -> bool:
|
||||
style = self.settings["style"]
|
||||
style_class = style.is_a()
|
||||
for s in styled_item.Styles:
|
||||
s_class = s.is_a()
|
||||
if s_class == style_class:
|
||||
return True
|
||||
elif s_class == "IfcPresentationStyleAssignment":
|
||||
for ss in s.Styles:
|
||||
if ss.is_a() == style_class:
|
||||
return True
|
||||
return False
|
||||
|
||||
def create_new_definition_representation(self):
|
||||
representation = self.create_styled_representation()
|
||||
@@ -214,6 +234,14 @@ class Usecase:
|
||||
return self.file.create_entity(
|
||||
"IfcStyledItem", **{"Styles": [self.style], "Name": self.settings["style"].Name}
|
||||
)
|
||||
reuse_item.Styles = (self.style,)
|
||||
|
||||
# IfcPresentationStyleAssignment we created end up not being used
|
||||
# TODO: do not create IfcPresentationStyleAssignment in the first place
|
||||
# as it might get removed
|
||||
if reuse_item.is_a("IfcPresentationStyleAssignment") and self.style.is_a("IfcPresentationStyleAssignment"):
|
||||
self.file.remove(self.style)
|
||||
self.style = reuse_item
|
||||
|
||||
reuse_item.Styles = (self.settings["style"],)
|
||||
reuse_item.Name = self.settings["style"].Name
|
||||
return reuse_item
|
||||
|
||||
@@ -45,22 +45,25 @@ def remove_surface_style(file: ifcopenshell.file, style: ifcopenshell.entity_ins
|
||||
# Remove the shading item
|
||||
ifcopenshell.api.run("style.remove_surface_style", model, style=shading)
|
||||
"""
|
||||
settings = {"style": style}
|
||||
|
||||
to_delete = set()
|
||||
if settings["style"].is_a("IfcSurfaceStyleWithTextures"):
|
||||
for texture in settings["style"].Textures or []:
|
||||
if texture.IsMappedBy:
|
||||
for coordinate in texture.IsMappedBy:
|
||||
to_delete.add(coordinate)
|
||||
else:
|
||||
to_delete.add(texture)
|
||||
if style.is_a("IfcSurfaceStyleWithTextures"):
|
||||
textures = style.Textures
|
||||
if file.schema == "IFC2X3":
|
||||
to_delete.update(textures)
|
||||
else:
|
||||
for texture in textures:
|
||||
if coords := texture.IsMappedBy:
|
||||
for coordinate in coords:
|
||||
to_delete.add(coordinate)
|
||||
else:
|
||||
to_delete.add(texture)
|
||||
|
||||
for attribute in settings["style"]:
|
||||
for attribute in style:
|
||||
if isinstance(attribute, ifcopenshell.entity_instance) and attribute.id():
|
||||
to_delete.add(attribute)
|
||||
|
||||
file.remove(settings["style"])
|
||||
file.remove(style)
|
||||
|
||||
for element in to_delete:
|
||||
ifcopenshell.util.element.remove_deep2(file, element)
|
||||
|
||||
@@ -65,7 +65,14 @@ def unassign_material_style(
|
||||
for item in representation.Items:
|
||||
if not item.is_a("IfcStyledItem"):
|
||||
continue
|
||||
styles = [s for s in item.Styles if s != settings["style"]]
|
||||
styles = []
|
||||
for s in item.Styles:
|
||||
if s == settings["style"]:
|
||||
continue
|
||||
if s.is_a("IfcPresentationStyleAssignment"):
|
||||
if s.Styles == (settings["style"],):
|
||||
continue
|
||||
styles.append(s)
|
||||
if not styles:
|
||||
file.remove(item)
|
||||
elif len(styles) != len(item.Styles):
|
||||
|
||||
@@ -158,6 +158,7 @@ def get_psets(
|
||||
if qtos_only and not definition.is_a("IfcElementQuantity"):
|
||||
continue
|
||||
psets[definition.Name] = get_property_definition(definition, verbose=verbose)
|
||||
# NOTE: doesn't account for IFC2X3 missing HasProperties
|
||||
elif element.is_a("IfcMaterialDefinition") or element.is_a("IfcProfileDef"):
|
||||
for definition in getattr(element, "HasProperties", None) or []:
|
||||
if qtos_only:
|
||||
|
||||
@@ -38,13 +38,16 @@ class TestAddPset(test.bootstrap.IFC4):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Pset_MaterialCommon")
|
||||
assert pset.is_a("IfcMaterialProperties")
|
||||
assert "Pset_MaterialCommon" in ifcopenshell.util.element.get_psets(material)
|
||||
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")
|
||||
assert pset.is_a("IfcProfileProperties")
|
||||
assert "Pset_ProfileMechanical" in ifcopenshell.util.element.get_psets(profile)
|
||||
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")
|
||||
@@ -53,7 +56,7 @@ class TestAddPset(test.bootstrap.IFC4):
|
||||
assert "Custom_Pset" in ifcopenshell.util.element.get_psets(element)
|
||||
|
||||
|
||||
class TestAddPsetIFC2X3(test.bootstrap.IFC2X3):
|
||||
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")
|
||||
|
||||
@@ -21,6 +21,8 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.constraint
|
||||
|
||||
|
||||
# NOTE: resource module features relies on entities introduced in IFC4
|
||||
# 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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -36,3 +36,7 @@ class TestAssignProduct(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
|
||||
assert wall.ReferencedBy[0].RelatedObjects == (task,)
|
||||
|
||||
|
||||
class TestAssignProductIFC2X3(test.bootstrap.IFC2X3, TestAssignProduct):
|
||||
pass
|
||||
|
||||
@@ -20,6 +20,8 @@ import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
# NOTE: sequence module features relies on entities introduced in IFC4
|
||||
# therefore no IFC2X3 tests
|
||||
class TestCalculateTaskDuration(test.bootstrap.IFC4):
|
||||
def test_calculating_the_duration_based_on_a_labour_resource_with_work_hours(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
|
||||
@@ -22,6 +22,8 @@ import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
# NOTE: sequence module features relies on entities introduced in IFC4
|
||||
# therefore no IFC2X3 tests
|
||||
class TestCascadeSchedule(test.bootstrap.IFC4):
|
||||
def test_doing_nothing_if_the_task_has_no_successors(self):
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file)
|
||||
|
||||
@@ -21,6 +21,9 @@ import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
# NOTE: IfcTaskTime was introduced in IFC4
|
||||
|
||||
|
||||
class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
def test_editing_all_attributes(self):
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
|
||||
|
||||
@@ -21,6 +21,7 @@ import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
# NOTE: IfcWorkTime was introduced in IFC4
|
||||
class TestEditWorkTime(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
work_time = self.file.createIfcWorkTime()
|
||||
|
||||
@@ -22,6 +22,8 @@ import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
# NOTE: sequence module features relies on entities introduced in IFC4
|
||||
# therefore no IFC2X3 tests
|
||||
# A good way for checking these is to recreate them in ProjectLibre
|
||||
class TestRecalculateSchedule(test.bootstrap.IFC4):
|
||||
def test_doing_nothing_if_the_task_has_no_time(self):
|
||||
|
||||
@@ -27,3 +27,7 @@ class TestUnassignProduct(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=wall, related_object=task)
|
||||
ifcopenshell.api.run("sequence.unassign_product", self.file, relating_product=wall, related_object=task)
|
||||
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0
|
||||
|
||||
|
||||
class TestUnassignProductIFC2X3(test.bootstrap.IFC2X3, TestUnassignProduct):
|
||||
pass
|
||||
|
||||
@@ -121,3 +121,7 @@ class TestAssignContainer(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, products=[subelement], relating_object=aggregate)
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
assert not ifcopenshell.util.element.get_aggregate(subelement)
|
||||
|
||||
|
||||
class TestAssignContainerIFC2X3(test.bootstrap.IFC2X3, TestAssignContainer):
|
||||
pass
|
||||
|
||||
@@ -57,3 +57,7 @@ class TestUnassignContainer(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run("spatial.unassign_container", self.file, products=[subelement])
|
||||
assert len(self.file.by_type("IfcRelContainedInSpatialStructure")) == 0
|
||||
|
||||
|
||||
class TestUnassignContainerIFC2X3(test.bootstrap.IFC2X3, TestUnassignContainer):
|
||||
pass
|
||||
|
||||
@@ -28,3 +28,7 @@ class TestAddStructuralAnalysisModel(test.bootstrap.IFC4):
|
||||
models = self.file.by_type("IfcStructuralAnalysisModel")
|
||||
assert subject == models[0]
|
||||
assert subject.is_a("IfcStructuralAnalysisModel")
|
||||
|
||||
|
||||
class TestAddStructuralAnalysisModelIFC2X3(test.bootstrap.IFC2X3, TestAddStructuralAnalysisModel):
|
||||
pass
|
||||
|
||||
@@ -37,3 +37,7 @@ class TestAssignStructuralAnalysisModel(test.bootstrap.IFC4):
|
||||
assert rel.is_a("IfcRelAssignsToGroup")
|
||||
assert rel.RelatingGroup == subject
|
||||
assert product in rel.RelatedObjects
|
||||
|
||||
|
||||
class TestAssignStructuralAnalysisModelIFC2X3(test.bootstrap.IFC2X3, TestAssignStructuralAnalysisModel):
|
||||
pass
|
||||
|
||||
@@ -34,3 +34,7 @@ class TestEditStructuralAnalysisModel(test.bootstrap.IFC4):
|
||||
models = self.file.by_type("IfcStructuralAnalysisModel")
|
||||
assert subject == models[0]
|
||||
assert subject.is_a("IfcStructuralAnalysisModel")
|
||||
|
||||
|
||||
class TestEditStructuralAnalysisModelIFC2X3(test.bootstrap.IFC2X3, TestEditStructuralAnalysisModel):
|
||||
pass
|
||||
|
||||
@@ -32,3 +32,7 @@ class TestRemoveStructuralAnalysisModel(test.bootstrap.IFC4):
|
||||
)
|
||||
models = self.file.by_type("IfcStructuralAnalysisModel")
|
||||
assert len(models) == 0
|
||||
|
||||
|
||||
class TestRemoveStructuralAnalysisModelIFC2X3(test.bootstrap.IFC2X3, TestRemoveStructuralAnalysisModel):
|
||||
pass
|
||||
|
||||
@@ -44,3 +44,7 @@ class TestUnassignStructuralAnalysisModel(test.bootstrap.IFC4):
|
||||
rels = self.file.by_type("IfcRelAssignsToGroup")
|
||||
assert len(models[0].IsGroupedBy) == 0
|
||||
assert len(rels) == 0
|
||||
|
||||
|
||||
class TestUnassignStructuralAnalysisModelIFC2X3(test.bootstrap.IFC2X3, TestUnassignStructuralAnalysisModel):
|
||||
pass
|
||||
|
||||
@@ -24,63 +24,77 @@ import ifcopenshell.api
|
||||
class TestAddSurfaceStyle(test.bootstrap.IFC4):
|
||||
def test_adding_a_surface_style(self):
|
||||
style = self.file.createIfcSurfaceStyle()
|
||||
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
|
||||
if self.file.schema != "IFC2X3":
|
||||
attrs["Transparency"] = 0.5
|
||||
result = ifcopenshell.api.run(
|
||||
"style.add_surface_style",
|
||||
self.file,
|
||||
style=style,
|
||||
ifc_class="IfcSurfaceStyleShading",
|
||||
attributes={"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}, "Transparency": 0.5},
|
||||
attributes=attrs,
|
||||
)
|
||||
assert result.is_a("IfcSurfaceStyleShading")
|
||||
assert result.SurfaceColour.Red == 1
|
||||
assert result.SurfaceColour.Green == 1
|
||||
assert result.SurfaceColour.Blue == 1
|
||||
assert result.Transparency == 0.5
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert result.Transparency == 0.5
|
||||
assert style.Styles[0] == result
|
||||
|
||||
def test_adding_a_rendering_style(self):
|
||||
style = self.file.createIfcSurfaceStyle()
|
||||
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
|
||||
if self.file.schema != "IFC2X3":
|
||||
attrs["Transparency"] = 0.5
|
||||
result = ifcopenshell.api.run(
|
||||
"style.add_surface_style",
|
||||
self.file,
|
||||
style=style,
|
||||
ifc_class="IfcSurfaceStyleRendering",
|
||||
attributes={"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}, "Transparency": 0.5},
|
||||
attributes=attrs,
|
||||
)
|
||||
assert result.is_a("IfcSurfaceStyleRendering")
|
||||
assert result.SurfaceColour.Red == 1
|
||||
assert result.SurfaceColour.Green == 1
|
||||
assert result.SurfaceColour.Blue == 1
|
||||
assert result.Transparency == 0.5
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert result.Transparency == 0.5
|
||||
assert style.Styles[0] == result
|
||||
|
||||
def test_not_adding_a_style_twice(self):
|
||||
style = self.file.createIfcSurfaceStyle()
|
||||
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
|
||||
if self.file.schema != "IFC2X3":
|
||||
attrs["Transparency"] = 0.5
|
||||
ifcopenshell.api.run(
|
||||
"style.add_surface_style",
|
||||
self.file,
|
||||
style=style,
|
||||
ifc_class="IfcSurfaceStyleRendering",
|
||||
attributes={"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}, "Transparency": 0.5},
|
||||
attributes=attrs,
|
||||
)
|
||||
result = ifcopenshell.api.run(
|
||||
"style.add_surface_style",
|
||||
self.file,
|
||||
style=style,
|
||||
ifc_class="IfcSurfaceStyleRendering",
|
||||
attributes={"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}, "Transparency": 0.5},
|
||||
attributes=attrs,
|
||||
)
|
||||
assert style.Styles[0] == result
|
||||
assert len(style.Styles) == 1
|
||||
|
||||
def test_adding_multiple_styles_of_different_types(self):
|
||||
style = self.file.createIfcSurfaceStyle()
|
||||
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
|
||||
if self.file.schema != "IFC2X3":
|
||||
attrs["Transparency"] = 0.5
|
||||
result1 = ifcopenshell.api.run(
|
||||
"style.add_surface_style",
|
||||
self.file,
|
||||
style=style,
|
||||
ifc_class="IfcSurfaceStyleShading",
|
||||
attributes={"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}, "Transparency": 0.5},
|
||||
attributes=attrs,
|
||||
)
|
||||
result2 = ifcopenshell.api.run(
|
||||
"style.add_surface_style",
|
||||
@@ -95,19 +109,26 @@ class TestAddSurfaceStyle(test.bootstrap.IFC4):
|
||||
|
||||
def test_ensure_shading_and_rendering_are_mutually_exclusive_when_adding(self):
|
||||
style = self.file.createIfcSurfaceStyle()
|
||||
attrs = {"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}}
|
||||
if self.file.schema != "IFC2X3":
|
||||
attrs["Transparency"] = 0.5
|
||||
ifcopenshell.api.run(
|
||||
"style.add_surface_style",
|
||||
self.file,
|
||||
style=style,
|
||||
ifc_class="IfcSurfaceStyleShading",
|
||||
attributes={"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}, "Transparency": 0.5},
|
||||
attributes=attrs,
|
||||
)
|
||||
result = ifcopenshell.api.run(
|
||||
"style.add_surface_style",
|
||||
self.file,
|
||||
style=style,
|
||||
ifc_class="IfcSurfaceStyleRendering",
|
||||
attributes={"SurfaceColour": {"Name": "", "Red": 1, "Green": 1, "Blue": 1}, "Transparency": 0.5},
|
||||
attributes=attrs,
|
||||
)
|
||||
assert style.Styles[0] == result
|
||||
assert len(style.Styles) == 1
|
||||
|
||||
|
||||
class TestAddSurfaceStyleIFC2X3(test.bootstrap.IFC2X3, TestAddSurfaceStyle):
|
||||
pass
|
||||
|
||||
@@ -21,6 +21,7 @@ import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
# TODO: add ifc2x3 tests after add_surface_textures will support ifc2x3
|
||||
class TestAddSurfaceTexture(test.bootstrap.IFC4):
|
||||
def get_default_texture_data(self):
|
||||
return [
|
||||
@@ -67,6 +68,7 @@ class TestAddSurfaceTexture(test.bootstrap.IFC4):
|
||||
for texture, data in zip(textures, texture_data):
|
||||
self.compare_texture_to_data(texture, data)
|
||||
|
||||
# NOTE: IfcTextureCoordinate doesn't have Maps in IFC2X3
|
||||
def test_add_surface_textures_from_data_with_uv_maps(self):
|
||||
texture_data = self.get_default_texture_data()
|
||||
texture_data[0]["uv_mode"] = "Generated"
|
||||
|
||||
@@ -22,7 +22,7 @@ import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestAssignMaterialStyle(test.bootstrap.IFC4):
|
||||
class TestAssignMaterialStyleIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_run(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
@@ -38,7 +38,12 @@ class TestAssignMaterialStyle(test.bootstrap.IFC4):
|
||||
assert len(representation.Items) == 1
|
||||
item = representation.Items[0]
|
||||
assert item.is_a("IfcStyledItem")
|
||||
assert item.Styles == (style,)
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert item.Styles == (style,)
|
||||
else:
|
||||
# IfcPresentationStyleAssignment
|
||||
assert len(item.Styles[0]) == 1
|
||||
assert item.Styles[0].Styles == (style,)
|
||||
|
||||
style2 = self.file.createIfcSurfaceStyle()
|
||||
ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style2, context=context)
|
||||
@@ -48,8 +53,16 @@ class TestAssignMaterialStyle(test.bootstrap.IFC4):
|
||||
assert definition.Representations == (representation,)
|
||||
assert len(representation.Items) == 1
|
||||
assert representation.Items[0] == item
|
||||
assert representation.Items[0].Styles == (style2,)
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert representation.Items[0].Styles == (style2,)
|
||||
else:
|
||||
# IfcPresentationStyleAssignment
|
||||
assert len(representation.Items[0].Styles) == 1
|
||||
assert representation.Items[0].Styles == (style2,)
|
||||
|
||||
|
||||
class TestAssignMaterialStyleIFC4(test.bootstrap.IFC4, TestAssignMaterialStyleIFC2X3):
|
||||
# IfcMaterialConstituentSet was added in IFC4
|
||||
def test_update_shape_aspect_representations_items_styles_if_material_is_part_of_matching_material_constituents(
|
||||
self,
|
||||
):
|
||||
|
||||
@@ -25,15 +25,19 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
|
||||
def test_editing_a_shading_style(self):
|
||||
colour = self.file.createIfcColourRgb(None, 0, 0, 0)
|
||||
style = self.file.createIfcSurfaceStyleShading(colour)
|
||||
attrs = {"SurfaceColour": {"Red": 1, "Green": 1, "Blue": 1}}
|
||||
if self.file.schema != "IFC2X3":
|
||||
attrs["Transparency"] = 0.5
|
||||
ifcopenshell.api.run(
|
||||
"style.edit_surface_style",
|
||||
self.file,
|
||||
style=style,
|
||||
attributes={"SurfaceColour": {"Red": 1, "Green": 1, "Blue": 1}, "Transparency": 0.5},
|
||||
attributes=attrs,
|
||||
)
|
||||
assert style.SurfaceColour == colour
|
||||
assert list(colour) == [None, 1, 1, 1]
|
||||
assert style.Transparency == 0.5
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert style.Transparency == 0.5
|
||||
|
||||
def test_editing_an_empty_colour_or_factor(self):
|
||||
for attribute in [
|
||||
@@ -170,3 +174,7 @@ class TestEditSurfaceStyle(test.bootstrap.IFC4):
|
||||
)
|
||||
for attribute in attributes:
|
||||
assert tuple(getattr(style, attribute)) == (None, 1, 1, 1)
|
||||
|
||||
|
||||
class TestEditSurfaceStyleIFC2X3(test.bootstrap.IFC2X3, TestEditSurfaceStyle):
|
||||
pass
|
||||
|
||||
@@ -34,3 +34,7 @@ class TestRemoveStyle(test.bootstrap.IFC4):
|
||||
styled_item = self.file.createIfcStyledItem(Styles=[style])
|
||||
ifcopenshell.api.run("style.remove_style", self.file, style=style)
|
||||
assert len(list(self.file)) == 0
|
||||
|
||||
|
||||
class TestRemoveStyleIFC2X3(test.bootstrap.IFC2X3, TestRemoveStyle):
|
||||
pass
|
||||
|
||||
@@ -21,7 +21,7 @@ import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestRemoveSurfaceStyle(test.bootstrap.IFC4):
|
||||
class TestRemoveSurfaceStyleIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_removing_a_shading_style(self):
|
||||
style = self.file.createIfcSurfaceStyleShading(SurfaceColour=self.file.createIfcColourRgb(None, 1, 1, 1))
|
||||
ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
|
||||
@@ -33,13 +33,6 @@ class TestRemoveSurfaceStyle(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
|
||||
assert len(list(self.file)) == 0
|
||||
|
||||
def test_removing_a_texture_style_with_all_of_its_coordinates(self):
|
||||
texture = self.file.createIfcImageTexture()
|
||||
coordinates = self.file.createIfcTextureCoordinateGenerator(Maps=[texture])
|
||||
style = self.file.createIfcSurfaceStyleWithTextures(Textures=[texture])
|
||||
ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
|
||||
assert len(list(self.file)) == 0
|
||||
|
||||
def test_removing_a_rendering_style(self):
|
||||
style = self.file.createIfcSurfaceStyleRendering(
|
||||
SurfaceColour=self.file.createIfcColourRgb(None, 1, 1, 1),
|
||||
@@ -55,3 +48,13 @@ class TestRemoveSurfaceStyle(test.bootstrap.IFC4):
|
||||
g = ifcopenshell.file.from_string(self.file.wrapped_data.to_string())
|
||||
ifcopenshell.api.run("style.remove_surface_style", g, style=g.by_type("IfcSurfaceStyleRendering")[0])
|
||||
assert len(list(g)) == 0
|
||||
|
||||
|
||||
class TestRemoveSurfaceStyleIFC4(test.bootstrap.IFC4, TestRemoveSurfaceStyleIFC2X3):
|
||||
# IfcTextureCoordinateGenerator doesn't have Maps in IFC2X3
|
||||
def test_removing_a_texture_style_with_all_of_its_coordinates(self):
|
||||
texture = self.file.createIfcImageTexture()
|
||||
coordinates = self.file.createIfcTextureCoordinateGenerator(Maps=[texture])
|
||||
style = self.file.createIfcSurfaceStyleWithTextures(Textures=[texture])
|
||||
ifcopenshell.api.run("style.remove_surface_style", self.file, style=style)
|
||||
assert len(list(self.file)) == 0
|
||||
|
||||
@@ -22,7 +22,7 @@ import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class TestAssignMaterialStyle(test.bootstrap.IFC4):
|
||||
class TestUnassignMaterialStyleIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_run(self):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
@@ -36,7 +36,12 @@ class TestAssignMaterialStyle(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run(
|
||||
"style.unassign_material_style", self.file, material=material, style=style2, context=context
|
||||
)
|
||||
assert item.Styles == (style,)
|
||||
if self.file.schema != "IFC2X3":
|
||||
assert item.Styles == (style,)
|
||||
else:
|
||||
# IfcPresentationStyleAssignment
|
||||
assert len(item.Styles) == 1
|
||||
assert item.Styles[0].Styles == (style,)
|
||||
|
||||
# unassign last style
|
||||
ifcopenshell.api.run(
|
||||
@@ -46,6 +51,9 @@ class TestAssignMaterialStyle(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcStyledRepresentation")) == 0
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 0
|
||||
|
||||
|
||||
class TestUnassignMaterialStyleIFC4(test.bootstrap.IFC4, TestUnassignMaterialStyleIFC2X3):
|
||||
# IfcMaterialConstituentSet was added in IFC4
|
||||
def test_update_shape_aspect_representaitons_items_styles_if_material_is_part_of_matching_material_constituents(
|
||||
self,
|
||||
):
|
||||
|
||||
@@ -26,6 +26,10 @@ class TestAddPort(test.bootstrap.IFC4):
|
||||
assert ifcopenshell.api.run("system.add_port", self.file).is_a("IfcDistributionPort")
|
||||
|
||||
def test_assigning_a_port_as_well_if_an_element_is_specified(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcChiller")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowTerminal")
|
||||
port = ifcopenshell.api.run("system.add_port", self.file, element=element)
|
||||
assert ifcopenshell.util.system.get_ports(element) == [port]
|
||||
|
||||
|
||||
class TestAddPortIFC2X3(test.bootstrap.IFC2X3, TestAddPort):
|
||||
pass
|
||||
|
||||
@@ -25,4 +25,11 @@ class TestAddSystem(test.bootstrap.IFC4):
|
||||
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
|
||||
system2 = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcDistributionSystem")
|
||||
assert system.is_a("IfcSystem")
|
||||
assert system2.is_a("IfcDistributionSystem")
|
||||
if self.file.schema == "IFC2X3":
|
||||
assert system2.is_a("IfcSystem")
|
||||
else:
|
||||
assert system2.is_a("IfcDistributionSystem")
|
||||
|
||||
|
||||
class TestAddSystemIFC2X3(test.bootstrap.IFC2X3, TestAddSystem):
|
||||
pass
|
||||
|
||||
@@ -23,7 +23,7 @@ import ifcopenshell.api
|
||||
class TestAssignFlowControl(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
flow_element = self.file.createIfcFlowSegment()
|
||||
flow_control = self.file.createIfcController()
|
||||
flow_control = self.file.create_entity("IfcDistributionControlElement")
|
||||
|
||||
# simple assignment
|
||||
relation = ifcopenshell.api.run(
|
||||
@@ -56,7 +56,7 @@ class TestAssignFlowControl(test.bootstrap.IFC4):
|
||||
assert relation is None
|
||||
|
||||
# assigning another control to the same object
|
||||
flow_control1 = self.file.createIfcController()
|
||||
flow_control1 = self.file.create_entity("IfcDistributionControlElement")
|
||||
relation = ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
self.file,
|
||||
@@ -66,3 +66,7 @@ class TestAssignFlowControl(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcRelFlowControlElements")) == 1
|
||||
assert relation.RelatingFlowElement == flow_element
|
||||
assert set(relation.RelatedControlElements) == set((flow_control, flow_control1))
|
||||
|
||||
|
||||
class TestAssignFlowControlIFC2X3(test.bootstrap.IFC2X3, TestAssignFlowControl):
|
||||
pass
|
||||
|
||||
@@ -108,8 +108,12 @@ class TestConnectPort(test.bootstrap.IFC4):
|
||||
def test_connecting_ports_with_a_realising_element(self):
|
||||
port = ifcopenshell.api.run("system.add_port", self.file)
|
||||
port2 = ifcopenshell.api.run("system.add_port", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDuctFitting")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowFitting")
|
||||
ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, element=element)
|
||||
assert self.file.by_type("IfcRelConnectsPorts")[0].RealizingElement == element
|
||||
ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2)
|
||||
assert self.file.by_type("IfcRelConnectsPorts")[0].RealizingElement is None
|
||||
|
||||
|
||||
class TestConnectPortIFC2X3(test.bootstrap.IFC2X3, TestConnectPort):
|
||||
pass
|
||||
|
||||
@@ -21,7 +21,7 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.system
|
||||
|
||||
|
||||
class TestConnectPort(test.bootstrap.IFC4):
|
||||
class TestDisconnectPort(test.bootstrap.IFC4):
|
||||
def test_disconnecting_a_port(self):
|
||||
port = ifcopenshell.api.run("system.add_port", self.file)
|
||||
port2 = ifcopenshell.api.run("system.add_port", self.file)
|
||||
@@ -30,3 +30,7 @@ class TestConnectPort(test.bootstrap.IFC4):
|
||||
assert port.FlowDirection == None
|
||||
assert port2.FlowDirection == None
|
||||
assert len(self.file.by_type("IfcRelConnectsPorts")) == 0
|
||||
|
||||
|
||||
class TestDisconnectPortIFC2X3(test.bootstrap.IFC2X3, TestDisconnectPort):
|
||||
pass
|
||||
|
||||
@@ -27,7 +27,7 @@ class TestRemoveSystem(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcSystem")) == 0
|
||||
|
||||
def test_removing_orphaned_group_relationships(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowTerminal")
|
||||
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
|
||||
ifcopenshell.api.run("system.assign_system", self.file, product=element, system=system)
|
||||
ifcopenshell.api.run("system.remove_system", self.file, system=system)
|
||||
@@ -41,3 +41,7 @@ class TestRemoveSystem(test.bootstrap.IFC4):
|
||||
assert not self.file.by_type("IfcRelDefinesByProperties")
|
||||
assert not self.file.by_type("IfcPropertySet")
|
||||
assert not self.file.by_type("IfcPropertySingleValue")
|
||||
|
||||
|
||||
class TestRemoveSystemIFC2X3(test.bootstrap.IFC2X3, TestRemoveSystem):
|
||||
pass
|
||||
|
||||
@@ -23,7 +23,7 @@ import ifcopenshell.api
|
||||
class TestUnassignFlowControl(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
flow_element = self.file.createIfcFlowSegment()
|
||||
flow_control = self.file.createIfcController()
|
||||
flow_control = self.file.create_entity("IfcDistributionControlElement")
|
||||
|
||||
# assign and unassign
|
||||
relation = ifcopenshell.api.run(
|
||||
@@ -41,7 +41,7 @@ class TestUnassignFlowControl(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcRelFlowControlElements")) == 0
|
||||
|
||||
# 1 element 2 controls
|
||||
flow_control1 = self.file.createIfcController()
|
||||
flow_control1 = self.file.create_entity("IfcDistributionControlElement")
|
||||
relation = ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
self.file,
|
||||
@@ -62,3 +62,7 @@ class TestUnassignFlowControl(test.bootstrap.IFC4):
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelFlowControlElements")) == 1
|
||||
assert relation.RelatedControlElements == (flow_control,)
|
||||
|
||||
|
||||
class TestUnassignFlowControlIFC2X3(test.bootstrap.IFC2X3, TestUnassignFlowControl):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user