mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
Fix failing ifcpatch tests
This commit is contained in:
@@ -16,11 +16,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pytest
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import test.bootstrap
|
|
||||||
import ifcopenshell
|
|
||||||
import ifcpatch
|
import ifcpatch
|
||||||
|
import ifcopenshell
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
TEST_FILE = Path(__file__).parent / "files" / "basic.ifc"
|
TEST_FILE = Path(__file__).parent / "files" / "basic.ifc"
|
||||||
|
|||||||
@@ -91,15 +91,28 @@ class Patcher:
|
|||||||
model_rotation = (model_rotation * -1) - 360
|
model_rotation = (model_rotation * -1) - 360
|
||||||
|
|
||||||
if not np.allclose(existing_origin, other_origin) or not np.isclose(existing_angle, other_angle):
|
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(
|
x, y, z = ifcopenshell.util.geolocation.auto_enh2xyz(
|
||||||
other, *existing_origin, is_specified_in_map_units=False
|
other, *existing_origin, is_specified_in_map_units=False
|
||||||
)
|
)
|
||||||
e, n, h = existing_origin
|
e, n, h = existing_origin
|
||||||
SetFalseOrigin(
|
SetFalseOrigin(
|
||||||
"",
|
|
||||||
other,
|
other,
|
||||||
self.logger,
|
self.logger,
|
||||||
name="",
|
name=name,
|
||||||
x=x,
|
x=x,
|
||||||
y=y,
|
y=y,
|
||||||
z=z,
|
z=z,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import tempfile
|
||||||
import ifcpatch
|
import ifcpatch
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.api.context
|
import ifcopenshell.api.context
|
||||||
@@ -27,15 +28,15 @@ import ifcopenshell.util.placement
|
|||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
import ifcopenshell.util.shape
|
import ifcopenshell.util.shape
|
||||||
import ifcopenshell.util.shape_builder
|
import ifcopenshell.util.shape_builder
|
||||||
import test.bootstrap
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
class TestIfc2Sql:
|
class TestIfc2Sql:
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
TEST_FILE = Path(__file__).parent / "files" / "basic.ifc"
|
TEST_FILE = Path(__file__).parent / "files" / "basic.ifc"
|
||||||
|
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".ifcsqlite")
|
||||||
sqlite_path = ifcpatch.execute(
|
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 isinstance(sqlite_path, str)
|
||||||
assert sqlite_path.endswith(".ifcsqlite")
|
assert sqlite_path.endswith(".ifcsqlite")
|
||||||
|
|||||||
Reference in New Issue
Block a user