Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd628132dd | |||
| 6a79b02af7 | |||
| 0cd0c3a1f6 | |||
| ebe7312cd6 | |||
| 2594ce0382 |
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -142,6 +142,7 @@ class SpeckleClient:
|
||||
self.account.userInfo.avatar = userData.avatar
|
||||
|
||||
self.account.serverInfo = self.server.get()
|
||||
self.account.serverInfo.url = self.url
|
||||
|
||||
def authenticate_with_account(self, account: Account) -> None:
|
||||
"""Authenticate the client using an Account object
|
||||
|
||||
@@ -88,6 +88,8 @@ def user_application_data_path() -> Path:
|
||||
message="Cannot get appdata path from environment."
|
||||
)
|
||||
return Path(app_data_path)
|
||||
if sys.platform.startswith("darwin"): # macOS
|
||||
return _ensure_folder_exists(Path.home() / "Library", "Application Support")
|
||||
else:
|
||||
# try getting the standard XDG_DATA_HOME value
|
||||
# as that is used as an override
|
||||
@@ -98,7 +100,7 @@ def user_application_data_path() -> Path:
|
||||
return _ensure_folder_exists(Path.home(), ".config")
|
||||
except Exception as ex:
|
||||
raise SpeckleException(
|
||||
message="Failed to initialize user application data path.", exception=ex
|
||||
message="Failed to initialize user application data path."
|
||||
) from ex
|
||||
|
||||
|
||||
|
||||
@@ -97,10 +97,11 @@ def initialise_tracker(account: Account | None = None):
|
||||
if not METRICS_TRACKER:
|
||||
METRICS_TRACKER = MetricsTracker()
|
||||
|
||||
if account and account.userInfo.email:
|
||||
METRICS_TRACKER.set_last_user(account.userInfo.email)
|
||||
if account and account.serverInfo.url:
|
||||
METRICS_TRACKER.set_last_server(account.serverInfo.url)
|
||||
if not account:
|
||||
return
|
||||
|
||||
METRICS_TRACKER.set_last_user(account.userInfo.email)
|
||||
METRICS_TRACKER.set_last_server(account.serverInfo.url)
|
||||
|
||||
|
||||
class Singleton(type):
|
||||
@@ -132,12 +133,12 @@ class MetricsTracker(metaclass=Singleton):
|
||||
if node and user:
|
||||
self.last_user = f"@{self.hash(f'{node}-{user}')}"
|
||||
|
||||
def set_last_user(self, email: str):
|
||||
def set_last_user(self, email: str | None):
|
||||
if not email:
|
||||
return
|
||||
self.last_user = f"@{self.hash(email)}"
|
||||
|
||||
def set_last_server(self, server: str):
|
||||
def set_last_server(self, server: str | None):
|
||||
if not server:
|
||||
return
|
||||
self.last_server = self.hash(server)
|
||||
|
||||
@@ -8,11 +8,12 @@ import requests
|
||||
|
||||
from specklepy.api.client import SpeckleClient
|
||||
from specklepy.core.api import operations
|
||||
from specklepy.core.api.credentials import Account, UserInfo
|
||||
from specklepy.core.api.enums import ProjectVisibility
|
||||
from specklepy.core.api.inputs.project_inputs import ProjectCreateInput
|
||||
from specklepy.core.api.inputs.version_inputs import CreateVersionInput
|
||||
from specklepy.core.api.models import Version
|
||||
from specklepy.core.api.models.current import Project
|
||||
from specklepy.core.api.models.current import Project, ServerInfo
|
||||
from specklepy.logging import metrics
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.objects.geometry import Point
|
||||
@@ -89,13 +90,15 @@ def second_user_dict(host: str) -> Dict[str, str]:
|
||||
def create_client(host: str, token: str) -> SpeckleClient:
|
||||
client = SpeckleClient(host=host, use_ssl=False)
|
||||
client.authenticate_with_token(token)
|
||||
user = client.active_user.get()
|
||||
assert user
|
||||
client.account.userInfo.id = user.id
|
||||
client.account.userInfo.email = user.email
|
||||
client.account.userInfo.name = user.name
|
||||
client.account.userInfo.company = user.company
|
||||
client.account.userInfo.avatar = user.avatar
|
||||
|
||||
assert isinstance(client.account, Account)
|
||||
assert isinstance(client.account.userInfo, UserInfo)
|
||||
assert client.account.userInfo.id
|
||||
assert client.account.userInfo.name
|
||||
assert isinstance(client.account.serverInfo, ServerInfo)
|
||||
assert client.account.serverInfo.url
|
||||
assert client.account.serverInfo.name
|
||||
|
||||
return client
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user