This commit is contained in:
Jedd Morgan
2025-07-15 11:23:39 +01:00
committed by GitHub
parent 2e351b4254
commit 8c6a29a996
2 changed files with 11 additions and 22 deletions
-14
View File
@@ -54,20 +54,6 @@ def cmd_line_import() -> None:
json.dump({"success": False, "error": str(e)}, f)
def manual_import() -> None:
PROJECT_ID = "f3a42bdf24"
MODEL_ID = "0e23cfdea3"
SERVER_URL = "app.speckle.systems"
# FILE_PATH = "C:\\Users\\Jedd\\Desktop\\openshell\\60mins.ifc"
# FILE_PATH = "C:\\Users\\Jedd\\Desktop\\openshell\\hillside_house_meters.ifc"
# FILE_PATH = "C:\\Users\\Jedd\\Desktop\\openshell\\GRAPHISOFT_Archicad_Sample_Project-S-Office_v1.0_AC25.ifc" # noqa: E501
FILE_PATH = "C:\\Users\\Jedd\\Desktop\\openshell\\GRAPHISOFT_Archicad_Sample_Project-S-Office_v1.0_AC25.ifc" # noqa: E501
account = get_accounts_for_server(SERVER_URL)[0]
open_and_convert_file(FILE_PATH, PROJECT_ID, None, MODEL_ID, account)
def open_and_convert_file(
file_path: str,
project_id: str,
+11 -8
View File
@@ -1,4 +1,5 @@
import time
from dataclasses import dataclass, field
from typing import cast
from ifcopenshell.entity_instance import entity_instance
@@ -16,13 +17,15 @@ from speckleifc.ifc_openshell_helpers import get_children
from speckleifc.render_material_proxy_manager import RenderMaterialProxyManager
@dataclass
class ImportJob:
def __init__(self, ifc_file: file):
self._ifc_file = ifc_file
self.cached_display_values: dict[int, list[Base]] = {}
self._render_material_manager = RenderMaterialProxyManager()
self.geometries_count = 0
self.geometries_used = 0
ifc_file: file
cached_display_values: dict[int, list[Base]] = field(default_factory=dict) # noqa: F821
_render_material_manager: RenderMaterialProxyManager = field(
default_factory=lambda: RenderMaterialProxyManager()
)
geometries_count: int = 0
geometries_used: int = 0
def convert_element(self, step_element: entity_instance) -> Base:
children = self._convert_children(step_element)
@@ -70,7 +73,7 @@ class ImportJob:
return root
def pre_process_geometry(self) -> None:
iterator = create_geometry_iterator(self._ifc_file)
iterator = create_geometry_iterator(self.ifc_file)
if not iterator.initialize():
raise SpeckleException(
"geometry iterator failed to initialize for the given file"
@@ -88,7 +91,7 @@ class ImportJob:
break
def _convert_project_tree(self) -> Base:
projects = self._ifc_file.by_type("IfcProject", False)
projects = self.ifc_file.by_type("IfcProject", False)
if len(projects) != 1:
raise SpeckleException("Expected exactly one IfcProject in file")
project = projects[0]