Compare commits

..

3 Commits

Author SHA1 Message Date
Jedd Morgan dd628132dd stash 2025-09-21 21:51:27 +01:00
Jedd Morgan 6a79b02af7 Merge branch 'main' into jrm/fix-counter 2025-09-19 15:07:52 +01:00
Jedd Morgan ebe7312cd6 Fix geometry counter 2025-09-19 14:58:38 +01:00
4 changed files with 48 additions and 11 deletions
+21 -1
View File
@@ -6,6 +6,7 @@ from os import getenv
from speckleifc.main import open_and_convert_file
from specklepy.core.api.client import SpeckleClient
from specklepy.core.api.credentials import get_accounts_for_server
from specklepy.logging import metrics
@@ -55,7 +56,26 @@ 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"
metrics.set_host_app(
"ifc",
)
account = get_accounts_for_server(SERVER_URL)[0]
client = SpeckleClient(SERVER_URL, use_ssl=not SERVER_URL.startswith("http://"))
client.authenticate_with_account(account)
project = client.project.get(PROJECT_ID)
open_and_convert_file(FILE_PATH, project, None, MODEL_ID, client)
if __name__ == "__main__":
start = time.time()
cmd_line_import()
# cmd_line_import()
manual_import()
print(f"Total time (including cleanup): {(time.time() - start) * 1000}ms")
+2 -1
View File
@@ -13,7 +13,8 @@ def _create_iterator_settings() -> settings:
# no need to weld verts
ifc_settings.set("weld-vertices", False)
# Speckle meshes are all in world coords
ifc_settings.set("use-world-coords", True)
ifc_settings.set("use-world-coords", False)
ifc_settings.set("permissive-shape-reuse", False)
# Tiny performance improvement,
ifc_settings.set("no-wire-intersection-check", True)
# Rendermaterials inherit the material names instead of type + unique id
+4 -2
View File
@@ -54,9 +54,10 @@ class ImportJob:
)
children = self._convert_children(step_element)
display_value = self.cached_display_values.get(step_element.id(), [])
id = step_element.id()
display_value = self.cached_display_values.get(id, [])
if display_value is not None:
if display_value:
self.geometries_used += 1
# Extract current storey name from DataObject if available
@@ -127,6 +128,7 @@ class ImportJob:
self.geometries_count += 1
id = cast(int, shape.id)
print(f"converted {id}")
try:
display_value = geometry_to_speckle(
shape, self._render_material_manager
+21 -7
View File
@@ -1,6 +1,8 @@
from urllib.parse import quote, unquote, urlparse
from warnings import warn
from gql import gql
from specklepy.core.api.client import SpeckleClient
from specklepy.core.api.credentials import (
Account,
@@ -137,11 +139,27 @@ class StreamWrapper:
if use_fe2 is True and self.branch_name is not None:
self.model_id = self.branch_name
# get branch name
query = gql(
"""
query Project($project_id: String!, $model_id: String!) {
project(id: $project_id) {
id
model(id: $model_id) {
name
}
}
}
"""
)
self._client = self.get_client()
model = self._client.model.get(self.model_id, self.stream_id)
params = {"project_id": self.stream_id, "model_id": self.model_id}
project = self._client.httpclient.execute(query, params)
self.branch_name = model.name
try:
self.branch_name = project["project"]["model"]["name"]
except KeyError as ke:
raise SpeckleException("Project model name is not found", ke) from ke
if not self.stream_id:
raise SpeckleException(
@@ -157,10 +175,6 @@ class StreamWrapper:
"""
Gets an account object for this server from the local accounts db
(added via Speckle Manager or a json file)
WARNING: this function will return ANY account for the server,
just because you pass a token in doesn't guarantee it will be used.
This whole class could do with a re-design...
"""
if self._account and self._account.token:
return self._account