From dda2853c1329c52a478ceb20e97bcaa50a20b0a9 Mon Sep 17 00:00:00 2001 From: BrandonPacewic Date: Thu, 20 Jun 2024 13:43:35 -0700 Subject: [PATCH] Final formatting --- .../src/Parser/ExporterOptions.py | 4 +- .../src/Parser/SynthesisParser/Components.py | 12 +--- .../Parser/SynthesisParser/JointHierarchy.py | 17 ++--- .../src/Parser/SynthesisParser/Joints.py | 14 ++--- .../src/Parser/SynthesisParser/PDMessage.py | 8 +-- .../src/Parser/SynthesisParser/Parser.py | 12 ++-- .../src/UI/ConfigCommand.py | 62 ++++++------------- .../src/UI/CustomGraphics.py | 6 +- exporter/SynthesisFusionAddin/src/UI/HUI.py | 12 +--- .../SynthesisFusionAddin/src/UI/IconPaths.py | 6 +- .../SynthesisFusionAddin/src/UI/Toolbar.py | 4 +- 11 files changed, 44 insertions(+), 113 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index d725051398..7669b7bdd5 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -125,9 +125,7 @@ def writeToDesign(self) -> None: { key: ( lambda value: ( - value - if not isinstance(value, Enum) - else value.value + value if not isinstance(value, Enum) else value.value ) )(value) for key, value in obj.__dict__.items() diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py index ea5d033974..c938617785 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py @@ -36,9 +36,7 @@ def _MapAllComponents( fill_info(partDefinition, component, comp_ref) - PhysicalProperties.GetPhysicalProperties( - component, partDefinition.physical_data - ) + PhysicalProperties.GetPhysicalProperties(component, partDefinition.physical_data) if options.exportMode == ExporterOptions.ExportMode.FIELD: partDefinition.dynamic = False @@ -58,9 +56,7 @@ def processBody(body: adsk.fusion.BRepBody | adsk.fusion.MeshBody): else: _ParseMesh(body, options, part_body.triangle_mesh) - appearance_key = "{}_{}".format( - body.appearance.name, body.appearance.id - ) + appearance_key = "{}_{}".format(body.appearance.name, body.appearance.id) # this should be appearance if appearance_key in materials.appearances: part_body.appearance_override = appearance_key @@ -156,9 +152,7 @@ def __parseChildOccurrence( if options.exportMode == ExporterOptions.ExportMode.FIELD: for x in options.gamepieces: if x.occurrenceToken == mapConstant: - partsData.part_definitions[part.part_definition_reference].dynamic = ( - True - ) + partsData.part_definitions[part.part_definition_reference].dynamic = True break part.transform.spatial_matrix.extend(occurrence.transform.asArray()) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py index 4ed2717f35..8a381966d9 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py @@ -82,9 +82,7 @@ class JointRelationship(enum.Enum): class DynamicOccurrenceNode(GraphNode): - def __init__( - self, occurrence: adsk.fusion.Occurrence, isGround=False, previous=None - ): + def __init__(self, occurrence: adsk.fusion.Occurrence, isGround=False, previous=None): super().__init__(occurrence) self.isGround = isGround self.name = occurrence.name @@ -124,9 +122,7 @@ def getConnectedAxisTokens(self) -> list: class DynamicEdge(GraphEdge): - def __init__( - self, relationship: OccurrenceRelationship, node: DynamicOccurrenceNode - ): + def __init__(self, relationship: OccurrenceRelationship, node: DynamicOccurrenceNode): super().__init__(relationship, node) # should print all in this class @@ -518,9 +514,7 @@ def populateJoint(simNode: SimulationNode, joints: joint_pb2.Joints, progressDia # print(f"Configuring {proto_joint.info.name}") # construct body tree if possible - createTreeParts( - simNode.data, OccurrenceRelationship.CONNECTION, root, progressDialog - ) + createTreeParts(simNode.data, OccurrenceRelationship.CONNECTION, root, progressDialog) proto_joint.parts.nodes.append(root) @@ -539,10 +533,7 @@ def createTreeParts( raise RuntimeError("User canceled export") # if it's the next part just exit early for our own sanity - if ( - relationship == OccurrenceRelationship.NEXT - or dynNode.data.isLightBulbOn == False - ): + if relationship == OccurrenceRelationship.NEXT or dynNode.data.isLightBulbOn == False: return # set the occurrence / component id to reference the part diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py index b443c7d3a6..1983829b8d 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py @@ -116,18 +116,13 @@ def populateJoints( # really could just map the enum to a friggin string if ( - parse_joints.signalType - != ExporterOptions.SignalType.PASSIVE + parse_joints.signalType != ExporterOptions.SignalType.PASSIVE and assembly.dynamic ): - if ( - parse_joints.signalType - == ExporterOptions.SignalType.CAN - ): + if parse_joints.signalType == ExporterOptions.SignalType.CAN: signal.device_type = signal_pb2.DeviceType.CANBUS elif ( - parse_joints.signalType - == ExporterOptions.SignalType.PWM + parse_joints.signalType == ExporterOptions.SignalType.PWM ): signal.device_type = signal_pb2.DeviceType.PWM @@ -405,8 +400,7 @@ def _jointOrigin( geometryOrOrigin = ( ( fusionJoint.geometryOrOriginOne - if fusionJoint.geometryOrOriginOne.objectType - == "adsk::fusion::JointGeometry" + if fusionJoint.geometryOrOriginOne.objectType == "adsk::fusion::JointGeometry" else fusionJoint.geometryOrOriginTwo ) if fusionJoint.objectType == "adsk::fusion::Joint" diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PDMessage.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PDMessage.py index d5057709da..d284a44f93 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PDMessage.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PDMessage.py @@ -43,13 +43,9 @@ def _format(self): # TABS DO NOTHING HALP out = f"{self.assemblyName} parsing:\n" out += f"\t Components: \t[ {self.currentCompCount} / {self.componentCount} ]\n" - out += ( - f"\t Occurrences: \t[ {self.currentOccCount} / {self.occurrenceCount} ]\n" - ) + out += f"\t Occurrences: \t[ {self.currentOccCount} / {self.occurrenceCount} ]\n" out += f"\t Materials: \t[ {self.currentMatCount} / {self.materialCount} ]\n" - out += ( - f"\t Appearances: \t[ {self.currentAppCount} / {self.appearanceCount} ]\n" - ) + out += f"\t Appearances: \t[ {self.currentAppCount} / {self.appearanceCount} ]\n" out += f"{self.currentMessage}" return out diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 7fddd89b54..507830f046 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -214,18 +214,14 @@ def export(self) -> bool: for child in node.children: if child.value == "ground": - joint_hierarchy_out = ( - f"{joint_hierarchy_out} |---> ground\n" - ) + joint_hierarchy_out = f"{joint_hierarchy_out} |---> ground\n" else: newnode = assembly_out.data.joints.joint_instances[ child.value ] - jointdefinition = ( - assembly_out.data.joints.joint_definitions[ - newnode.joint_reference - ] - ) + jointdefinition = assembly_out.data.joints.joint_definitions[ + newnode.joint_reference + ] wheel_ = ( " wheel : true" if (jointdefinition.user_data.data["wheel"] != "") diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index de37ddbb69..4c7e0b7953 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -186,12 +186,8 @@ def notify(self, args): cmd.isAutoExecute = False cmd.isExecutedWhenPreEmpted = False cmd.okButtonText = "Export" # replace default OK text with "export" - cmd.setDialogInitialSize( - 400, 350 - ) # these aren't working for some reason... - cmd.setDialogMinimumSize( - 400, 350 - ) # these aren't working for some reason... + cmd.setDialogInitialSize(400, 350) # these aren't working for some reason... + cmd.setDialogMinimumSize(400, 350) # these aren't working for some reason... global INPUTS_ROOT # Global CommandInputs arg INPUTS_ROOT = cmd.commandInputs @@ -419,9 +415,7 @@ def notify(self, args): ) jointConfig.isExpanded = False jointConfig.isVisible = True - jointConfig.tooltip = ( - "Select and define joint occurrences in your assembly." - ) + jointConfig.tooltip = "Select and define joint occurrences in your assembly." joint_inputs = jointConfig.children @@ -571,9 +565,7 @@ def notify(self, args): ) weightTableInput_f.tablePresentationStyle = 2 # set to clear background - weight_name_f = gamepiece_inputs.addStringValueInput( - "weight_name", "Weight" - ) + weight_name_f = gamepiece_inputs.addStringValueInput("weight_name", "Weight") weight_name_f.value = "Unit of Mass" weight_name_f.isReadOnly = True @@ -586,9 +578,7 @@ def notify(self, args): enabled=True, isCheckBox=False, ) - auto_calc_weight_f.resourceFolder = IconPaths.stringIcons[ - "calculate-enabled" - ] + auto_calc_weight_f.resourceFolder = IconPaths.stringIcons["calculate-enabled"] auto_calc_weight_f.isFullWidth = True weight_unit_f = gamepiece_inputs.addDropDownCommandInput( @@ -630,9 +620,7 @@ def notify(self, args): 50, ) - addFieldInput = gamepiece_inputs.addBoolValueInput( - "field_add", "Add", False - ) + addFieldInput = gamepiece_inputs.addBoolValueInput("field_add", "Add", False) removeFieldInput = gamepiece_inputs.addBoolValueInput( "field_delete", "Remove", False @@ -1465,9 +1453,7 @@ def traverseAssembly( if occ in value: return [joint, occ] # occurrence that is jointed - if ( - occ.childOccurrences - ): # if occurrence has children, traverse sub-tree + if occ.childOccurrences: # if occurrence has children, traverse sub-tree self.traverseAssembly(occ.childOccurrences, jointedOcc) return None # no jointed occurrence found except: @@ -1540,9 +1526,7 @@ def wheelParent(self, occ: adsk.fusion.Occurrence): treeParent = parent # each parent that will traverse up in algorithm. while treeParent != None: # loops until reaches top-level component - returned = self.traverseAssembly( - treeParent.childOccurrences, jointedOcc - ) + returned = self.traverseAssembly(treeParent.childOccurrences, jointedOcc) if returned != None: for i in range(parentLevel): @@ -2014,10 +1998,7 @@ def notify(self, args): # gm.ui.activeSelections.clear() addWheelInput.isEnabled = True - if ( - wheelTableInput.selectedRow == -1 - or wheelTableInput.selectedRow == 0 - ): + if wheelTableInput.selectedRow == -1 or wheelTableInput.selectedRow == 0: wheelTableInput.selectedRow = wheelTableInput.rowCount - 1 gm.ui.messageBox("Select a row to delete.") else: @@ -2030,10 +2011,7 @@ def notify(self, args): addJointInput.isEnabled = True addWheelInput.isEnabled = True - if ( - jointTableInput.selectedRow == -1 - or jointTableInput.selectedRow == 0 - ): + if jointTableInput.selectedRow == -1 or jointTableInput.selectedRow == 0: jointTableInput.selectedRow = jointTableInput.rowCount - 1 gm.ui.messageBox("Select a row to delete.") else: @@ -2189,9 +2167,7 @@ def notify(self, args): onSelect.allWheelPreselections.clear() onSelect.wheelJointList.clear() - for ( - group - ) in gm.app.activeDocument.design.rootComponent.customGraphicsGroups: + for group in gm.app.activeDocument.design.rootComponent.customGraphicsGroups: group.deleteMe() # Currently causes Internal Autodesk Error @@ -2260,9 +2236,7 @@ def addJointToTable(joint: adsk.fusion.Joint) -> None: icon.tooltip = "Ball joint" # joint name - name = cmdInputs.addTextBoxCommandInput( - "name_j", "Occurrence name", "", 1, True - ) + name = cmdInputs.addTextBoxCommandInput("name_j", "Occurrence name", "", 1, True) name.tooltip = joint.name name.formattedText = "

{}

".format(joint.name) @@ -2535,9 +2509,9 @@ def removeWheelFromTable(index: int) -> None: except IndexError: pass except: - logging.getLogger( - "{INTERNAL_ID}.UI.ConfigCommand.removeWheelFromTable()" - ).error("Failed:\n{}".format(traceback.format_exc())) + logging.getLogger("{INTERNAL_ID}.UI.ConfigCommand.removeWheelFromTable()").error( + "Failed:\n{}".format(traceback.format_exc()) + ) def removeJointFromTable(joint: adsk.fusion.Joint) -> None: @@ -2573,9 +2547,9 @@ def removeJointFromTable(joint: adsk.fusion.Joint) -> None: else: listItems.item(index).deleteMe() except: - logging.getLogger( - "{INTERNAL_ID}.UI.ConfigCommand.removeJointFromTable()" - ).error("Failed:\n{}".format(traceback.format_exc())) + logging.getLogger("{INTERNAL_ID}.UI.ConfigCommand.removeJointFromTable()").error( + "Failed:\n{}".format(traceback.format_exc()) + ) def removeGamePieceFromTable(index: int) -> None: diff --git a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py index d6986f9844..9b99310657 100644 --- a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py +++ b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py @@ -32,10 +32,8 @@ def createTextGraphics(wheel: adsk.fusion.Occurrence, _wheels) -> None: graphicsText.cullMode = ( adsk.fusion.CustomGraphicsCullModes.CustomGraphicsCullBack ) - graphicsText.color = ( - adsk.fusion.CustomGraphicsShowThroughColorEffect.create( - adsk.core.Color.create(230, 146, 18, 255), 1 - ) + graphicsText.color = adsk.fusion.CustomGraphicsShowThroughColorEffect.create( + adsk.core.Color.create(230, 146, 18, 255), 1 ) # orange/synthesis theme graphicsText.depthPriority = 0 diff --git a/exporter/SynthesisFusionAddin/src/UI/HUI.py b/exporter/SynthesisFusionAddin/src/UI/HUI.py index f2b5d32368..f3530cc8ac 100644 --- a/exporter/SynthesisFusionAddin/src/UI/HUI.py +++ b/exporter/SynthesisFusionAddin/src/UI/HUI.py @@ -138,9 +138,7 @@ def __init__( cmdDef = gm.ui.commandDefinitions.itemById(self.uid) if cmdDef: # gm.ui.messageBox("Looks like you have experienced a crash we will do cleanup.") - self.logger.debug( - "Looks like there was a crash, doing cleanup in button id" - ) + self.logger.debug("Looks like there was a crash, doing cleanup in button id") self.scrub() # needs to updated with new OString data @@ -148,9 +146,7 @@ def __init__( self.uid, f"{name}", f"{description}", - OsHelper.getOSPath( - ".", "src", "Resources", f'{self.name.replace(" ", "")}' - ), + OsHelper.getOSPath(".", "src", "Resources", f'{self.name.replace(" ", "")}'), ) """ Button Command Definition stored as a member """ @@ -208,9 +204,7 @@ def deleteMe(self): self.logger.debug(f"Removing Button {self.uid}") cmdDef.deleteMe() - ctrl = gm.ui.allToolbarPanels.itemById(self.location).controls.itemById( - self.uid - ) + ctrl = gm.ui.allToolbarPanels.itemById(self.location).controls.itemById(self.uid) if ctrl: self.logger.debug(f"Removing Button Control {self.location}:{self.uid}") ctrl.deleteMe() diff --git a/exporter/SynthesisFusionAddin/src/UI/IconPaths.py b/exporter/SynthesisFusionAddin/src/UI/IconPaths.py index b07edab1fb..9508f5e4ff 100644 --- a/exporter/SynthesisFusionAddin/src/UI/IconPaths.py +++ b/exporter/SynthesisFusionAddin/src/UI/IconPaths.py @@ -12,14 +12,12 @@ "omni": resources + os.path.join("WheelIcons", "omni-wheel-preview190x24.png"), "standard": resources + os.path.join("WheelIcons", "standard-wheel-preview190x24.png"), - "mecanum": resources - + os.path.join("WheelIcons", "mecanum-wheel-preview190x24.png"), + "mecanum": resources + os.path.join("WheelIcons", "mecanum-wheel-preview190x24.png"), } jointIcons = { "rigid": resources + os.path.join("JointIcons", "JointRigid", "rigid190x24.png"), - "revolute": resources - + os.path.join("JointIcons", "JointRev", "revolute190x24.png"), + "revolute": resources + os.path.join("JointIcons", "JointRev", "revolute190x24.png"), "slider": resources + os.path.join("JointIcons", "JointSlider", "slider190x24.png"), "cylindrical": resources + os.path.join("JointIcons", "JointCyl", "cylindrical190x24.png"), diff --git a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py index 4a260ae18a..8044c46e7d 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py +++ b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py @@ -57,9 +57,7 @@ def getPanel(self, name: str, visibility: bool = True) -> str or None: self.logger.debug(f"Created Panel {panel_uid} in Toolbar {self.uid}") return panel_uid else: - self.logger.error( - f"Failed to Create Panel {panel_uid} in Toolbar {self.uid}" - ) + self.logger.error(f"Failed to Create Panel {panel_uid} in Toolbar {self.uid}") return None @staticmethod