Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd628132dd | |||
| 6a79b02af7 | |||
| ebe7312cd6 |
+1
-1
@@ -11,7 +11,7 @@ dependencies = [
|
||||
"appdirs>=1.4.4",
|
||||
"attrs>=24.3.0",
|
||||
"deprecated>=1.2.15",
|
||||
"gql[requests,websockets]>=3.5.0,<4.0.0",
|
||||
"gql[requests,websockets]>=3.5.0",
|
||||
"httpx>=0.28.1",
|
||||
"pydantic>=2.10.5",
|
||||
"pydantic-settings>=2.7.1",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -128,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
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import math
|
||||
from typing import Any, Tuple
|
||||
|
||||
from ifcopenshell.entity_instance import entity_instance
|
||||
@@ -135,10 +134,6 @@ def _get_quantities(
|
||||
value = getattr(quantity, quantity.attribute_name(3))
|
||||
unit_info = _get_unit_info(element, quantity)
|
||||
|
||||
# Server does not consider `NaN` valid json
|
||||
if math.isnan(value):
|
||||
value = None
|
||||
|
||||
if unit_info:
|
||||
# Create structured quantity object with units
|
||||
results[quantity_name] = {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user