From 6edc6cec7166b3e922585579c9310f69f0d69df4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 23 Dec 2024 12:33:28 +0500 Subject: [PATCH] Fix Migrate not migrating ifc file header #5903 --- .../ifcopenshell/util/schema.py | 1 + src/ifcpatch/test/test_Migrate.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/ifcpatch/test/test_Migrate.py diff --git a/src/ifcopenshell-python/ifcopenshell/util/schema.py b/src/ifcopenshell-python/ifcopenshell/util/schema.py index d6e2988446..f709af6b5a 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/schema.py +++ b/src/ifcopenshell-python/ifcopenshell/util/schema.py @@ -312,6 +312,7 @@ class Migrator: } def preprocess(self, old_file: ifcopenshell.file, new_file: ifcopenshell.file) -> None: + new_file.assign_header_from(old_file) to_delete = set() if old_file.schema == "IFC2X3" and new_file.schema == "IFC4": diff --git a/src/ifcpatch/test/test_Migrate.py b/src/ifcpatch/test/test_Migrate.py new file mode 100644 index 0000000000..afefd9d3fb --- /dev/null +++ b/src/ifcpatch/test/test_Migrate.py @@ -0,0 +1,29 @@ +# IfcOpenShell - IFC toolkit and geometry engine +# Copyright (C) 2022 Dion Moult +# +# This file is part of IfcOpenShell. +# +# IfcOpenShell is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# IfcOpenShell is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with IfcOpenShell. If not, see . + +import ifcpatch +import ifcopenshell +import test.bootstrap + + +class TestMigrate(test.bootstrap.IFC4): + def test_migrate_header(self): + old_file = self.file + old_file.header.file_name.name = "test" + new_file = ifcpatch.execute({"file": old_file, "recipe": "Migrate", "arguments": ["IFC4"]}) + assert new_file.header.file_name.name == "test"