diff --git a/bpy_speckle/convert/to_native.py b/bpy_speckle/convert/to_native.py index a2b49a1..63d3e86 100644 --- a/bpy_speckle/convert/to_native.py +++ b/bpy_speckle/convert/to_native.py @@ -518,7 +518,7 @@ def icurve_to_native(speckle_curve: Base, name: str, scale: float) -> bpy.types. else bpy.data.curves.new(name, type="CURVE") ) blender_curve.dimensions = "3D" - blender_curve.resolution_u = 12 #TODO: We could maybe decern the resolution from the ployline displayValue + blender_curve.resolution_u = 12 #TODO: We could maybe decern the resolution from the polyline displayValue icurve_to_native_spline(speckle_curve, blender_curve, scale) diff --git a/bpy_speckle/convert/util.py b/bpy_speckle/convert/util.py index 5b0e4a4..8a299cb 100644 --- a/bpy_speckle/convert/util.py +++ b/bpy_speckle/convert/util.py @@ -255,7 +255,7 @@ def add_uv_coords(speckle_mesh: Mesh, blender_mesh: BMesh): } def get_blender_custom_properties(obj, max_depth: int = 63): - """Recursivly grabs custom properties on blender objects. Max depth is determined by the max allowed by Newtonsoft.NET, don't exceed unless you know what you're doing""" + """Recursively grabs custom properties on blender objects. Max depth is determined by the max allowed by Newtonsoft.NET, don't exceed unless you know what you're doing""" if max_depth <= 0: return obj diff --git a/bpy_speckle/operators/streams.py b/bpy_speckle/operators/streams.py index 2e94474..46fd3cd 100644 --- a/bpy_speckle/operators/streams.py +++ b/bpy_speckle/operators/streams.py @@ -74,7 +74,7 @@ def get_receive_funcs(speckle: SpeckleSceneSettings) -> tuple[ObjectCallback, Re #] INSTANCES_SETTINGS = [ - ("collection_instance", "Collection Instace", "Receive Instances as Collection Instances"), + ("collection_instance", "Collection Instance", "Receive Instances as Collection Instances"), ("linked_duplicates", "Linked Duplicates", "Receive Instances as Linked Duplicates"), ] @@ -91,7 +91,7 @@ class ReceiveStreamObjects(bpy.types.Operator): clean_meshes: BoolProperty(name="Clean Meshes", default=False) - #receive_mode: EnumProperty(items=RECEIVE_MODES, name="Receive Type", default="replace", description="The behaviour of the recieve operation") + #receive_mode: EnumProperty(items=RECEIVE_MODES, name="Receive Type", default="replace", description="The behaviour of the receive operation") receive_instances_as: EnumProperty(items=INSTANCES_SETTINGS, name="Receive Instances As", default="collection_instance", description="How to receive speckle Instances") @@ -183,7 +183,7 @@ def receive(self, context: Context) -> None: (object_converted_callback, on_complete_callback) = get_receive_funcs(speckle) # older commits will have a non-collection root object - # for the sake of consistant behaviour, we will wrap any non-collection commit objects in a collection + # for the sake of consistent behaviour, we will wrap any non-collection commit objects in a collection if not isinstance(commit_object, SCollection): dummy_commit_object = SCollection() dummy_commit_object.elements = [commit_object] @@ -620,7 +620,7 @@ def execute(self, context): def delete_stream(self, context: Context) -> None: if not self.are_you_sure: - raise Exception("Cancled by user") + raise Exception("Cancelled by user") self.are_you_sure = False diff --git a/bpy_speckle/operators/users.py b/bpy_speckle/operators/users.py index 712b6f0..00b9e93 100644 --- a/bpy_speckle/operators/users.py +++ b/bpy_speckle/operators/users.py @@ -6,10 +6,10 @@ from bpy.types import Context from bpy_speckle.functions import _report from bpy_speckle.clients import speckle_clients -from bpy_speckle.properties.scene import SpeckleCommitObject, SpeckleSceneSettings, SpeckleUserObject, get_speckle +from bpy_speckle.properties.scene import SpeckleCommitObject, SpeckleSceneSettings, SpeckleStreamObject, SpeckleUserObject, get_speckle from specklepy.core.api.client import SpeckleClient from specklepy.core.api.models import Stream -from specklepy.core.api.credentials import get_local_accounts +from specklepy.core.api.credentials import get_local_accounts, Account from specklepy.logging import metrics class ResetUsers(bpy.types.Operator): @@ -58,7 +58,7 @@ def execute(self, context): _report("Loading users...") speckle = cast(SpeckleSceneSettings, context.scene.speckle) #type: ignore - users = speckle.users + users_list = speckle.users ResetUsers.reset_ui(context) @@ -77,31 +77,19 @@ def execute(self, context): raise Exception("Zero accounts were found, please add one through Speckle Manager or a local account") for profile in profiles: - user = users.add() - user.server_name = profile.serverInfo.name or "Speckle Server" - user.server_url = profile.serverInfo.url - user.id = profile.userInfo.id - user.name = profile.userInfo.name - user.email = profile.userInfo.email - user.company = profile.userInfo.company or "" try: - url = profile.serverInfo.url - assert(url) - client = SpeckleClient( - host=url, - use_ssl="https" in url, - ) - client.authenticate_with_account(profile) - speckle_clients.append(client) + add_user_account(profile, speckle) except Exception as ex: - _report(f"Failed to authenticate user {user.email} with server {user.server_url}: {ex}") - users.remove(len(users) - 1) + _report(f"Failed to authenticate user account {profile.userInfo.email} with server {profile.serverInfo.url}: {ex}") + users_list.remove(len(users_list) - 1) + continue + if profile.isDefault: - active_user_index = len(users) - 1 + active_user_index = len(users_list) - 1 - _report(f"Authenticated {len(users)}/{len(profiles)} accounts") + _report(f"Authenticated {len(users_list)}/{len(profiles)} accounts") - if active_user_index < len(users): + if active_user_index < len(users_list): speckle.active_user = str(active_user_index) bpy.context.view_layer.update() @@ -109,14 +97,38 @@ def execute(self, context): if context.area: context.area.tag_redraw() - if not users: + if not users_list: raise Exception("Zero valid user accounts were found, please ensure account is valid and the server is running") return {"FINISHED"} +def add_user_account(account: Account, speckle: SpeckleSceneSettings) -> SpeckleUserObject: + """Creates a new new SpeckleUserObject for the provided user Account and adds it to the SpeckleSceneSettings""" + users_list = speckle.users + + URL = account.serverInfo.url + + user = cast(SpeckleUserObject, users_list.add()) + user.server_name = account.serverInfo.name or "Speckle Server" + user.server_url = URL + user.id = account.userInfo.id + user.name = account.userInfo.name + user.email = account.userInfo.email + user.company = account.userInfo.company or "" + + assert(URL) + client = SpeckleClient( + host=URL, + use_ssl="https" in URL, + ) + client.authenticate_with_account(account) + speckle_clients.append(client) + return user + def add_user_stream(user: SpeckleUserObject, stream: Stream): - s = user.streams.add() + """Adds the provided Stream (with branch & commits) to the SpeckleUserObject""" + s = cast(SpeckleStreamObject, user.streams.add()) s.name = stream.name s.id = stream.id s.description = stream.description