diff --git a/src/ifcopenshell-python/test/test_sql.py b/src/ifcopenshell-python/test/test_sql.py
index d4d263db3c..8b4323a3c8 100644
--- a/src/ifcopenshell-python/test/test_sql.py
+++ b/src/ifcopenshell-python/test/test_sql.py
@@ -16,11 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
-import pytest
import tempfile
-import test.bootstrap
-import ifcopenshell
import ifcpatch
+import ifcopenshell
from pathlib import Path
TEST_FILE = Path(__file__).parent / "files" / "basic.ifc"
diff --git a/src/ifcpatch/ifcpatch/recipes/MergeProjects.py b/src/ifcpatch/ifcpatch/recipes/MergeProjects.py
index 4e06b01274..22f0ac9e7a 100644
--- a/src/ifcpatch/ifcpatch/recipes/MergeProjects.py
+++ b/src/ifcpatch/ifcpatch/recipes/MergeProjects.py
@@ -91,15 +91,28 @@ class Patcher:
model_rotation = (model_rotation * -1) - 360
if not np.allclose(existing_origin, other_origin) or not np.isclose(existing_angle, other_angle):
+ if self.file.schema != "IFC2X3" and (crs := self.file.by_type("IfcProjectedCRS")):
+ name = crs[0].Name
+ elif (
+ self.file.schema == "IFC2X3"
+ and (project := self.file.by_type("IfcProject")[0])
+ and (pset := ifcopenshell.util.element.get_pset(project, "ePSet_ProjectedCRS"))
+ ):
+ name = pset.get("Name", "Unknown") or "Unknown"
+ else:
+ # I'm not entirely sure about this. If existing_origin !=
+ # other_origin there are two possibilities: either there is a
+ # projected CRS, or there is a WCS. If I had to choose between
+ # using a WCS and an "unnamed" CRS, I'd choose the latter.
+ name = "Unknown"
x, y, z = ifcopenshell.util.geolocation.auto_enh2xyz(
other, *existing_origin, is_specified_in_map_units=False
)
e, n, h = existing_origin
SetFalseOrigin(
- "",
other,
self.logger,
- name="",
+ name=name,
x=x,
y=y,
z=z,
diff --git a/src/ifcpatch/test/test_Ifc2Sql.py b/src/ifcpatch/test/test_Ifc2Sql.py
index 529cdb3214..c552e07945 100644
--- a/src/ifcpatch/test/test_Ifc2Sql.py
+++ b/src/ifcpatch/test/test_Ifc2Sql.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import tempfile
import ifcpatch
import ifcopenshell
import ifcopenshell.api.context
@@ -27,15 +28,15 @@ import ifcopenshell.util.placement
import ifcopenshell.util.representation
import ifcopenshell.util.shape
import ifcopenshell.util.shape_builder
-import test.bootstrap
from pathlib import Path
class TestIfc2Sql:
def test_run(self):
TEST_FILE = Path(__file__).parent / "files" / "basic.ifc"
+ tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".ifcsqlite")
sqlite_path = ifcpatch.execute(
- {"file": ifcopenshell.open(TEST_FILE), "recipe": "Ifc2Sql", "arguments": ["sqlite"]}
+ {"file": ifcopenshell.open(TEST_FILE), "recipe": "Ifc2Sql", "arguments": ["sqlite", None, None, None, tmp.name]}
)
assert isinstance(sqlite_path, str)
assert sqlite_path.endswith(".ifcsqlite")