diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/add_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/add_pset.py index 835bd83d75..d28fe9b16d 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/add_pset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/add_pset.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource.py b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource.py index 8131bed326..dd60840349 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource.py +++ b/src/ifcopenshell-python/ifcopenshell/api/resource/add_resource.py @@ -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", diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py index 6fd08d4b1d..152c74439b 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py @@ -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 diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py index 3fe8e1a003..a3bc13886c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_schedule.py @@ -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 diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py index 45bbb3a059..b1ddd3e298 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py +++ b/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py @@ -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 diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/remove_surface_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/remove_surface_style.py index 4ec3b9a3f3..98674c5f84 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/style/remove_surface_style.py +++ b/src/ifcopenshell-python/ifcopenshell/api/style/remove_surface_style.py @@ -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) diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/unassign_material_style.py b/src/ifcopenshell-python/ifcopenshell/api/style/unassign_material_style.py index 71189f8a88..17d0adfb3a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/style/unassign_material_style.py +++ b/src/ifcopenshell-python/ifcopenshell/api/style/unassign_material_style.py @@ -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): diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index f57d1891bc..2430a2553a 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -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: diff --git a/src/ifcopenshell-python/test/api/pset/test_add_pset.py b/src/ifcopenshell-python/test/api/pset/test_add_pset.py index 9d18e16ee2..26c26f26af 100644 --- a/src/ifcopenshell-python/test/api/pset/test_add_pset.py +++ b/src/ifcopenshell-python/test/api/pset/test_add_pset.py @@ -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") diff --git a/src/ifcopenshell-python/test/api/resource/test_calculate_resource_work.py b/src/ifcopenshell-python/test/api/resource/test_calculate_resource_work.py index 83a9d9303d..e81e47f2fc 100644 --- a/src/ifcopenshell-python/test/api/resource/test_calculate_resource_work.py +++ b/src/ifcopenshell-python/test/api/resource/test_calculate_resource_work.py @@ -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") diff --git a/src/ifcopenshell-python/test/api/root/test_create_entity.py b/src/ifcopenshell-python/test/api/root/test_create_entity.py index 49fc0891c2..9ec93d8933 100644 --- a/src/ifcopenshell-python/test/api/root/test_create_entity.py +++ b/src/ifcopenshell-python/test/api/root/test_create_entity.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/root/test_reassign_class.py b/src/ifcopenshell-python/test/api/root/test_reassign_class.py index 17b3fd1801..80276686e9 100644 --- a/src/ifcopenshell-python/test/api/root/test_reassign_class.py +++ b/src/ifcopenshell-python/test/api/root/test_reassign_class.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/root/test_remove_product.py b/src/ifcopenshell-python/test/api/root/test_remove_product.py index 418bdbc503..91a2cf6e31 100644 --- a/src/ifcopenshell-python/test/api/root/test_remove_product.py +++ b/src/ifcopenshell-python/test/api/root/test_remove_product.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/sequence/test_assign_product.py b/src/ifcopenshell-python/test/api/sequence/test_assign_product.py index 698752ebc7..f0973e2fd0 100644 --- a/src/ifcopenshell-python/test/api/sequence/test_assign_product.py +++ b/src/ifcopenshell-python/test/api/sequence/test_assign_product.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/sequence/test_calculate_task_duration.py b/src/ifcopenshell-python/test/api/sequence/test_calculate_task_duration.py index 587f7be225..06f0ed367b 100644 --- a/src/ifcopenshell-python/test/api/sequence/test_calculate_task_duration.py +++ b/src/ifcopenshell-python/test/api/sequence/test_calculate_task_duration.py @@ -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") diff --git a/src/ifcopenshell-python/test/api/sequence/test_cascade_schedule.py b/src/ifcopenshell-python/test/api/sequence/test_cascade_schedule.py index 9e5f8aa308..dd921ec2ae 100644 --- a/src/ifcopenshell-python/test/api/sequence/test_cascade_schedule.py +++ b/src/ifcopenshell-python/test/api/sequence/test_cascade_schedule.py @@ -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) diff --git a/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py b/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py index 3e59d526bb..efd41b0176 100644 --- a/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py +++ b/src/ifcopenshell-python/test/api/sequence/test_edit_task_time.py @@ -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()) diff --git a/src/ifcopenshell-python/test/api/sequence/test_edit_work_time.py b/src/ifcopenshell-python/test/api/sequence/test_edit_work_time.py index d200116878..ce024a1bca 100644 --- a/src/ifcopenshell-python/test/api/sequence/test_edit_work_time.py +++ b/src/ifcopenshell-python/test/api/sequence/test_edit_work_time.py @@ -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() diff --git a/src/ifcopenshell-python/test/api/sequence/test_recalculate_schedule.py b/src/ifcopenshell-python/test/api/sequence/test_recalculate_schedule.py index 74ef955d66..b08c38273c 100644 --- a/src/ifcopenshell-python/test/api/sequence/test_recalculate_schedule.py +++ b/src/ifcopenshell-python/test/api/sequence/test_recalculate_schedule.py @@ -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): diff --git a/src/ifcopenshell-python/test/api/sequence/test_unassign_product.py b/src/ifcopenshell-python/test/api/sequence/test_unassign_product.py index a70e45d06f..4dba192ef3 100644 --- a/src/ifcopenshell-python/test/api/sequence/test_unassign_product.py +++ b/src/ifcopenshell-python/test/api/sequence/test_unassign_product.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/spatial/test_assign_container.py b/src/ifcopenshell-python/test/api/spatial/test_assign_container.py index 533db20267..e4ca971319 100644 --- a/src/ifcopenshell-python/test/api/spatial/test_assign_container.py +++ b/src/ifcopenshell-python/test/api/spatial/test_assign_container.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/spatial/test_unassign_container.py b/src/ifcopenshell-python/test/api/spatial/test_unassign_container.py index 033b5cd333..d7f172817c 100644 --- a/src/ifcopenshell-python/test/api/spatial/test_unassign_container.py +++ b/src/ifcopenshell-python/test/api/spatial/test_unassign_container.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/structural/test_add_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_add_structural_analysis_model.py index 1849bf33e8..9fb407530d 100644 --- a/src/ifcopenshell-python/test/api/structural/test_add_structural_analysis_model.py +++ b/src/ifcopenshell-python/test/api/structural/test_add_structural_analysis_model.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/structural/test_assign_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_assign_structural_analysis_model.py index b89b061b4c..7146a53f59 100644 --- a/src/ifcopenshell-python/test/api/structural/test_assign_structural_analysis_model.py +++ b/src/ifcopenshell-python/test/api/structural/test_assign_structural_analysis_model.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/structural/test_edit_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_edit_structural_analysis_model.py index 40f0fbfd4a..4527a0d3d8 100644 --- a/src/ifcopenshell-python/test/api/structural/test_edit_structural_analysis_model.py +++ b/src/ifcopenshell-python/test/api/structural/test_edit_structural_analysis_model.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/structural/test_remove_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_remove_structural_analysis_model.py index 2fed85b618..a631d741aa 100644 --- a/src/ifcopenshell-python/test/api/structural/test_remove_structural_analysis_model.py +++ b/src/ifcopenshell-python/test/api/structural/test_remove_structural_analysis_model.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/structural/test_unassign_structural_analysis_model.py b/src/ifcopenshell-python/test/api/structural/test_unassign_structural_analysis_model.py index 4168d2404b..b2269b8a3a 100644 --- a/src/ifcopenshell-python/test/api/structural/test_unassign_structural_analysis_model.py +++ b/src/ifcopenshell-python/test/api/structural/test_unassign_structural_analysis_model.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/style/test_add_surface_style.py b/src/ifcopenshell-python/test/api/style/test_add_surface_style.py index b13fd8e7b7..80e297bed0 100644 --- a/src/ifcopenshell-python/test/api/style/test_add_surface_style.py +++ b/src/ifcopenshell-python/test/api/style/test_add_surface_style.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/style/test_add_surface_textures.py b/src/ifcopenshell-python/test/api/style/test_add_surface_textures.py index bdca230d99..590aa02399 100644 --- a/src/ifcopenshell-python/test/api/style/test_add_surface_textures.py +++ b/src/ifcopenshell-python/test/api/style/test_add_surface_textures.py @@ -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" diff --git a/src/ifcopenshell-python/test/api/style/test_assign_material_style.py b/src/ifcopenshell-python/test/api/style/test_assign_material_style.py index 01325d8b99..14bdf5fda9 100644 --- a/src/ifcopenshell-python/test/api/style/test_assign_material_style.py +++ b/src/ifcopenshell-python/test/api/style/test_assign_material_style.py @@ -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, ): diff --git a/src/ifcopenshell-python/test/api/style/test_edit_surface_style.py b/src/ifcopenshell-python/test/api/style/test_edit_surface_style.py index 48282ece48..54665c70d3 100644 --- a/src/ifcopenshell-python/test/api/style/test_edit_surface_style.py +++ b/src/ifcopenshell-python/test/api/style/test_edit_surface_style.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/style/test_remove_style.py b/src/ifcopenshell-python/test/api/style/test_remove_style.py index 2b8620b442..857dec169f 100644 --- a/src/ifcopenshell-python/test/api/style/test_remove_style.py +++ b/src/ifcopenshell-python/test/api/style/test_remove_style.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py b/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py index 2722a1de9a..01394cda6c 100644 --- a/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py +++ b/src/ifcopenshell-python/test/api/style/test_remove_surface_style.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/style/test_unassign_material_style.py b/src/ifcopenshell-python/test/api/style/test_unassign_material_style.py index 47c6e6a928..f1e2b1c8a3 100644 --- a/src/ifcopenshell-python/test/api/style/test_unassign_material_style.py +++ b/src/ifcopenshell-python/test/api/style/test_unassign_material_style.py @@ -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, ): diff --git a/src/ifcopenshell-python/test/api/system/test_add_port.py b/src/ifcopenshell-python/test/api/system/test_add_port.py index e1d74be2e9..5a1a06f59f 100644 --- a/src/ifcopenshell-python/test/api/system/test_add_port.py +++ b/src/ifcopenshell-python/test/api/system/test_add_port.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/system/test_add_system.py b/src/ifcopenshell-python/test/api/system/test_add_system.py index 07c304cbba..2c0ed31b8a 100644 --- a/src/ifcopenshell-python/test/api/system/test_add_system.py +++ b/src/ifcopenshell-python/test/api/system/test_add_system.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/system/test_assign_flow_control.py b/src/ifcopenshell-python/test/api/system/test_assign_flow_control.py index ac78e66633..038b22b83a 100644 --- a/src/ifcopenshell-python/test/api/system/test_assign_flow_control.py +++ b/src/ifcopenshell-python/test/api/system/test_assign_flow_control.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/system/test_connect_port.py b/src/ifcopenshell-python/test/api/system/test_connect_port.py index ab1325389a..8904ae05b6 100644 --- a/src/ifcopenshell-python/test/api/system/test_connect_port.py +++ b/src/ifcopenshell-python/test/api/system/test_connect_port.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/system/test_disconnect_port.py b/src/ifcopenshell-python/test/api/system/test_disconnect_port.py index 8b2ade0310..a19b665700 100644 --- a/src/ifcopenshell-python/test/api/system/test_disconnect_port.py +++ b/src/ifcopenshell-python/test/api/system/test_disconnect_port.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/system/test_remove_system.py b/src/ifcopenshell-python/test/api/system/test_remove_system.py index 86118cf943..0e1797eae1 100644 --- a/src/ifcopenshell-python/test/api/system/test_remove_system.py +++ b/src/ifcopenshell-python/test/api/system/test_remove_system.py @@ -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 diff --git a/src/ifcopenshell-python/test/api/system/test_unassign_flow_control.py b/src/ifcopenshell-python/test/api/system/test_unassign_flow_control.py index bb881367e6..873c497505 100644 --- a/src/ifcopenshell-python/test/api/system/test_unassign_flow_control.py +++ b/src/ifcopenshell-python/test/api/system/test_unassign_flow_control.py @@ -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