diff --git a/src/bonsai/bonsai/bim/import_ifc.py b/src/bonsai/bonsai/bim/import_ifc.py index d9dc6cea60..870433e2be 100644 --- a/src/bonsai/bonsai/bim/import_ifc.py +++ b/src/bonsai/bonsai/bim/import_ifc.py @@ -631,15 +631,13 @@ class IfcImporter: verts = geometry["verts"] mesh["has_cartesian_point_offset"] = False - if geometry["faces"]: + if geometry["faces"].size: mesh = tool.Loader.create_mesh_from_shape( mesh=mesh, faces=geometry["faces"].reshape(-1, 3), verts=verts.reshape(-1, 3) ) else: - e = geometry["edges"] - v = verts - vertices = [[v[i], v[i + 1], v[i + 2]] for i in range(0, len(v), 3)] - edges = [[e[i], e[i + 1]] for i in range(0, len(e), 2)] + vertices = verts.reshape(-1, 3).tolist() + edges = geometry["edges"].reshape(-1, 2).tolist() mesh.from_pydata(vertices, edges, []) mesh["ios_materials"] = geometry["materials"] diff --git a/src/ifcopenshell-python/ifcopenshell/sql.py b/src/ifcopenshell-python/ifcopenshell/sql.py index 4d46377858..c2f8185a8e 100644 --- a/src/ifcopenshell-python/ifcopenshell/sql.py +++ b/src/ifcopenshell-python/ifcopenshell/sql.py @@ -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()) diff --git a/src/ifcopenshell-python/ifcopenshell/util/unit.py b/src/ifcopenshell-python/ifcopenshell/util/unit.py index d2273ec129..a364ed2467 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/unit.py +++ b/src/ifcopenshell-python/ifcopenshell/util/unit.py @@ -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()