Bonsai - fix loading ifcsqlite file after 497542d #7085

This commit is contained in:
Andrej730
2025-09-04 19:06:20 +05:00
parent 49b9f99557
commit 942cb586b2
3 changed files with 11 additions and 11 deletions
+6 -5
View File
@@ -246,18 +246,19 @@ class sqlite(file):
geometry = {}
for row in rows:
if row["geometry"] and row["geometry"] not in geometry:
# Same data types as in ifcopenshell.util.shape.
geometry[row["geometry"]] = {
"verts": np.frombuffer(row["verts"]).tolist() if row["verts"] else [],
"edges": np.frombuffer(row["edges"], dtype=np.int64).tolist() if row["edges"] else [],
"faces": np.frombuffer(row["faces"], dtype=np.int64).tolist() if row["faces"] else [],
"verts": np.frombuffer(row["verts"], dtype="d") if row["verts"] else np.empty(0, dtype="d"),
"edges": np.frombuffer(row["edges"], dtype="i") if row["edges"] else np.empty(0, dtype="i"),
"faces": np.frombuffer(row["faces"], dtype="i") if row["faces"] else np.empty(0, dtype="i"),
"material_ids": (
np.frombuffer(row["material_ids"], dtype=np.int64).tolist() if row["material_ids"] else []
np.frombuffer(row["material_ids"], dtype="i") if row["material_ids"] else np.empty(0, dtype="i")
),
"materials": json.loads(row["materials"]) if row["materials"] else [],
}
shapes[row["ifc_id"]] = {
"co": [row["x"], row["y"], row["z"]],
"matrix": np.copy(np.frombuffer(row["matrix"]).reshape((4, 4))),
"matrix": np.copy(np.frombuffer(row["matrix"], dtype="d").reshape((4, 4))),
"geometry": row["geometry"],
}
ids_without_geometry = set(ids) - set(shapes.keys())
@@ -692,7 +692,8 @@ def calculate_unit_scale(ifc_file: ifcopenshell.file, unit_type: str = "LENGTHUN
:returns: The scale factor
"""
if (
unit_type
type(ifc_file) is ifcopenshell.file
and unit_type
not in ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema_identifier)
.declaration_by_name("IfcUnitEnum")
.enumeration_items()