diff --git a/exporter/SynthesisFusionAddin/src/APS/APS.py b/exporter/SynthesisFusionAddin/src/APS/APS.py index 346ae439f7..a65728ec23 100644 --- a/exporter/SynthesisFusionAddin/src/APS/APS.py +++ b/exporter/SynthesisFusionAddin/src/APS/APS.py @@ -199,10 +199,7 @@ def create_folder(auth: str, project_id: str, parent_folder_id: str, folder_disp success - the href of the new folder ; might be changed to the id in the future failure - none if the API request fails ; the failure text will be printed """ - headers = { - "Authorization": f"Bearer {auth}", - "Content-Type": "application/vnd.api+json", - } + headers = {"Authorization": f"Bearer {auth}", "Content-Type": "application/vnd.api+json"} data: dict[str, Any] = { "jsonapi": {"version": "1.0"}, "data": { @@ -216,9 +213,7 @@ def create_folder(auth: str, project_id: str, parent_folder_id: str, folder_disp } res = requests.post( - f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/folders", - headers=headers, - json=data, + f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/folders", headers=headers, json=data ) if not res.ok: gm.ui.messageBox(f"Failed to create new folder: {res.text}", "ERROR") @@ -302,15 +297,7 @@ def upload_mirabuf(project_id: str, folder_id: str, file_name: str, file_content return None if file_id != "": update_file_version( - auth, - project_id, - folder_id, - lineage_id, - file_id, - file_name, - file_contents, - file_version, - object_id, + auth, project_id, folder_id, lineage_id, file_id, file_name, file_contents, file_version, object_id ) else: _lineage_info = create_first_file_version(auth, str(object_id), project_id, str(folder_id), file_name) @@ -362,8 +349,7 @@ def get_project_id(auth: str, hub_id: str, project_name: str) -> str | None: headers = {"Authorization": f"Bearer {auth}"} project_list_res = requests.get( - f"https://developer.api.autodesk.com/project/v1/hubs/{hub_id}/projects", - headers=headers, + f"https://developer.api.autodesk.com/project/v1/hubs/{hub_id}/projects", headers=headers ) if not project_list_res.ok: gm.ui.messageBox("UPLOAD ERROR", f"Failed to retrieve hubs: {project_list_res.text}") @@ -445,10 +431,7 @@ def update_file_version( "Content-Type": "application/vnd.api+json", } - attributes = { - "name": file_name, - "extension": {"type": "versions:autodesk.core:File", "version": f"1.0"}, - } + attributes = {"name": file_name, "extension": {"type": "versions:autodesk.core:File", "version": f"1.0"}} relationships: dict[str, Any] = { "item": { @@ -467,23 +450,16 @@ def update_file_version( data = { "jsonapi": {"version": "1.0"}, - "data": { - "type": "versions", - "attributes": attributes, - "relationships": relationships, - }, + "data": {"type": "versions", "attributes": attributes, "relationships": relationships}, } update_res = requests.post( - f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/versions", - headers=headers, - json=data, + f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/versions", headers=headers, json=data ) if not update_res.ok: gm.ui.messageBox(f"UPLOAD ERROR:\n{update_res.text}", "Updating file to new version failed") return None gm.ui.messageBox( - f"Successfully updated file {file_name} to version {int(curr_file_version) + 1} on APS", - "UPLOAD SUCCESS", + f"Successfully updated file {file_name} to version {int(curr_file_version) + 1} on APS", "UPLOAD SUCCESS" ) new_id: str = update_res.json()["data"]["id"] return new_id @@ -568,15 +544,10 @@ def create_storage_location(auth: str, project_id: str, folder_id: str, file_nam "Content-Type": "application/vnd.api+json", } storage_location_res = requests.post( - f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/storage", - json=data, - headers=headers, + f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/storage", json=data, headers=headers ) if not storage_location_res.ok: - gm.ui.messageBox( - f"UPLOAD ERROR: {storage_location_res.text}", - f"Failed to create storage location", - ) + gm.ui.messageBox(f"UPLOAD ERROR: {storage_location_res.text}", f"Failed to create storage location") return None storage_location_json: dict[str, Any] = storage_location_res.json() object_id: str = storage_location_json["data"]["id"] @@ -664,8 +635,7 @@ def complete_upload(auth: str, upload_key: str, object_key: str, bucket_key: str ) if not completed_res.ok: gm.ui.messageBox( - f"UPLOAD ERROR: {completed_res.text}\n{completed_res.status_code}", - "Failed to complete upload", + f"UPLOAD ERROR: {completed_res.text}\n{completed_res.status_code}", "Failed to complete upload" ) return None return "" @@ -703,10 +673,7 @@ def create_first_file_version( "Accept": "application/vnd.api+json", } - included_attributes = { - "name": file_name, - "extension": {"type": "versions:autodesk.core:File", "version": "1.0"}, - } + included_attributes = {"name": file_name, "extension": {"type": "versions:autodesk.core:File", "version": "1.0"}} attributes = { "displayName": file_name, @@ -732,24 +699,15 @@ def create_first_file_version( data = { "jsonapi": {"version": "1.0"}, - "data": { - "type": "items", - "attributes": attributes, - "relationships": relationships, - }, + "data": {"type": "items", "attributes": attributes, "relationships": relationships}, "included": included, } first_version_res = requests.post( - f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/items", - json=data, - headers=headers, + f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/items", json=data, headers=headers ) if not first_version_res.ok: - gm.ui.messageBox( - f"Failed to create first file version: {first_version_res.text}", - "UPLOAD ERROR", - ) + gm.ui.messageBox(f"Failed to create first file version: {first_version_res.text}", "UPLOAD ERROR") return None first_version_json: dict[str, Any] = first_version_res.json() diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 774d8eb53f..4a501b1319 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -179,9 +179,7 @@ def notify(self, args): # ~~~~~~~~~~~~~~~~ EXPORT LOCATION ~~~~~~~~~~~~~~~~~~ dropdownExportLocation = inputs.addDropDownCommandInput( - "location", - "Export Location", - dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle, + "location", "Export Location", dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle ) upload: bool = exporterOptions.exportLocation == ExportLocation.UPLOAD @@ -555,8 +553,7 @@ def notify(self, args): getAuth() user_info = getUserInfo() apsSettings = INPUTS_ROOT.addTabCommandInput( - "aps_settings", - f"APS Settings ({user_info.given_name if user_info else 'Not Signed In'})", + "aps_settings", f"APS Settings ({user_info.given_name if user_info else 'Not Signed In'})" ) apsSettings.tooltip = "Configuration settings for Autodesk Platform Services." diff --git a/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py b/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py index 9332f11d01..4f25ebfe01 100644 --- a/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py +++ b/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py @@ -31,73 +31,33 @@ def __init__(self, args: adsk.core.CommandCreatedEventArgs) -> None: jointConfigTabInputs = self.jointConfigTab.children self.jointConfigTable = createTableInput("jointTable", "Joint Table", jointConfigTabInputs, 7, "1:2:2:2:2:2:2") self.jointConfigTable.addCommandInput( - createTextBoxInput( - "jointMotionHeader", - "Motion", - jointConfigTabInputs, - "Motion", - bold=False, - ), - 0, - 0, + createTextBoxInput("jointMotionHeader", "Motion", jointConfigTabInputs, "Motion", bold=False), 0, 0 ) self.jointConfigTable.addCommandInput( - createTextBoxInput("nameHeader", "Name", jointConfigTabInputs, "Joint name", bold=False), - 0, - 1, + createTextBoxInput("nameHeader", "Name", jointConfigTabInputs, "Joint name", bold=False), 0, 1 ) self.jointConfigTable.addCommandInput( - createTextBoxInput( - "parentHeader", - "Parent", - jointConfigTabInputs, - "Parent joint", - background="#d9d9d9", - ), + createTextBoxInput("parentHeader", "Parent", jointConfigTabInputs, "Parent joint", background="#d9d9d9"), 0, 2, ) self.jointConfigTable.addCommandInput( - createTextBoxInput( - "signalHeader", - "Signal", - jointConfigTabInputs, - "Signal type", - background="#d9d9d9", - ), + createTextBoxInput("signalHeader", "Signal", jointConfigTabInputs, "Signal type", background="#d9d9d9"), 0, 3, ) self.jointConfigTable.addCommandInput( - createTextBoxInput( - "speedHeader", - "Speed", - jointConfigTabInputs, - "Joint Speed", - background="#d9d9d9", - ), + createTextBoxInput("speedHeader", "Speed", jointConfigTabInputs, "Joint Speed", background="#d9d9d9"), 0, 4, ) self.jointConfigTable.addCommandInput( - createTextBoxInput( - "forceHeader", - "Force", - jointConfigTabInputs, - "Joint Force", - background="#d9d9d9", - ), + createTextBoxInput("forceHeader", "Force", jointConfigTabInputs, "Joint Force", background="#d9d9d9"), 0, 5, ) self.jointConfigTable.addCommandInput( - createTextBoxInput( - "wheelHeader", - "Is Wheel", - jointConfigTabInputs, - "Is Wheel", - background="#d9d9d9", - ), + createTextBoxInput("wheelHeader", "Is Wheel", jointConfigTabInputs, "Is Wheel", background="#d9d9d9"), 0, 6, ) @@ -113,39 +73,21 @@ def __init__(self, args: adsk.core.CommandCreatedEventArgs) -> None: self.wheelConfigTable = createTableInput("wheelTable", "Wheel Table", jointConfigTabInputs, 4, "1:2:2:2") self.wheelConfigTable.addCommandInput( - createTextBoxInput( - "wheelMotionHeader", - "Motion", - jointConfigTabInputs, - "Motion", - bold=False, - ), - 0, - 0, + createTextBoxInput("wheelMotionHeader", "Motion", jointConfigTabInputs, "Motion", bold=False), 0, 0 ) self.wheelConfigTable.addCommandInput( - createTextBoxInput("name_header", "Name", jointConfigTabInputs, "Joint name", bold=False), - 0, - 1, + createTextBoxInput("name_header", "Name", jointConfigTabInputs, "Joint name", bold=False), 0, 1 ) self.wheelConfigTable.addCommandInput( createTextBoxInput( - "wheelTypeHeader", - "WheelType", - jointConfigTabInputs, - "Wheel type", - background="#d9d9d9", + "wheelTypeHeader", "WheelType", jointConfigTabInputs, "Wheel type", background="#d9d9d9" ), 0, 2, ) self.wheelConfigTable.addCommandInput( createTextBoxInput( - "signalTypeHeader", - "SignalType", - jointConfigTabInputs, - "Signal type", - background="#d9d9d9", + "signalTypeHeader", "SignalType", jointConfigTabInputs, "Signal type", background="#d9d9d9" ), 0, 3, @@ -237,11 +179,7 @@ def addJoint(self, fusionJoint: adsk.fusion.Joint, synJoint: Joint | None = None if synJoint: signalType.listItems.add("‎", synJoint.signalType is SignalType.PWM, IconPaths.signalIcons["PWM"]) signalType.listItems.add("‎", synJoint.signalType is SignalType.CAN, IconPaths.signalIcons["CAN"]) - signalType.listItems.add( - "‎", - synJoint.signalType is SignalType.PASSIVE, - IconPaths.signalIcons["PASSIVE"], - ) + signalType.listItems.add("‎", synJoint.signalType is SignalType.PASSIVE, IconPaths.signalIcons["PASSIVE"]) else: signalType.listItems.add("‎", True, IconPaths.signalIcons["PWM"]) signalType.listItems.add("‎", False, IconPaths.signalIcons["CAN"]) @@ -292,10 +230,7 @@ def addJoint(self, fusionJoint: adsk.fusion.Joint, synJoint: Joint | None = None jointForceValue = 5 jointForce = commandInputs.addValueInput( - "jointForce", - "Force", - "N", - adsk.core.ValueInput.createByReal(jointForceValue), + "jointForce", "Force", "N", adsk.core.ValueInput.createByReal(jointForceValue) ) jointForce.tooltip = "Newtons" self.jointConfigTable.addCommandInput(jointForce, row, 5) @@ -338,9 +273,7 @@ def addWheel(self, joint: adsk.fusion.Joint, wheel: Wheel | None = None) -> None wheelName = commandInputs.addTextBoxCommandInput("wheelName", "Joint Name", joint.name, 1, True) wheelName.tooltip = joint.name # TODO: Should this be the same? wheelType = commandInputs.addDropDownCommandInput( - "wheelType", - "Wheel Type", - dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle, + "wheelType", "Wheel Type", dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle ) selectedWheelType = wheel.wheelType if wheel else WheelType.STANDARD @@ -357,9 +290,7 @@ def addWheel(self, joint: adsk.fusion.Joint, wheel: Wheel | None = None) -> None ) signalType = commandInputs.addDropDownCommandInput( - "wheelSignalType", - "Signal Type", - dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle, + "wheelSignalType", "Signal Type", dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle ) signalType.isFullWidth = True signalType.isEnabled = False @@ -462,9 +393,7 @@ def reset(self) -> None: # commandInput in a input changed handle for some reason. @logFailure def handleInputChanged( - self, - args: adsk.core.InputChangedEventArgs, - globalCommandInputs: adsk.core.CommandInputs, + self, args: adsk.core.InputChangedEventArgs, globalCommandInputs: adsk.core.CommandInputs ) -> None: commandInput = args.input if commandInput.id == "wheelType": diff --git a/exporter/SynthesisFusionAddin/tools/format.py b/exporter/SynthesisFusionAddin/tools/format.py index 60d9ba7063..7531b93de7 100644 --- a/exporter/SynthesisFusionAddin/tools/format.py +++ b/exporter/SynthesisFusionAddin/tools/format.py @@ -11,12 +11,7 @@ def main(args: list[str] = sys.argv[1:]) -> None: for command in ["isort", "black"]: try: print(f"Formatting with {command}...") - subprocess.call( - [command, dir], - shell=False, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) + subprocess.call([command, dir], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except FileNotFoundError: print(f'"{command}" could not be found. Please resolve dependencies.') return