From e0c28d9ca5bdf8c32cd57599d645d66aa233d009 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Fri, 28 Jun 2024 15:23:47 -0700 Subject: [PATCH 01/21] added friction override to exporter options --- .../src/Parser/ExporterOptions.py | 2 ++ .../FrictionOverride_icon/32x32-normal.png | Bin 0 -> 586 bytes .../SynthesisFusionAddin/src/UI/ConfigCommand.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 exporter/SynthesisFusionAddin/src/Resources/FrictionOverride_icon/32x32-normal.png diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index 31ed4cd0c4..4d01d9813f 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -92,6 +92,8 @@ class ExporterOptions: # Always stored in kg regardless of 'preferredUnits' robotWeight: float = field(default=0.0) + frictionOverride: float = field(default=0.0) + compressOutput: bool = field(default=True) exportAsPart: bool = field(default=False) diff --git a/exporter/SynthesisFusionAddin/src/Resources/FrictionOverride_icon/32x32-normal.png b/exporter/SynthesisFusionAddin/src/Resources/FrictionOverride_icon/32x32-normal.png new file mode 100644 index 0000000000000000000000000000000000000000..34f6b927a4769ba9eb525c709ed7a8aa7cb0ab95 GIT binary patch literal 586 zcmV-Q0=4~#P)i}@hQI;js>6EjxGeQUec<))S*R*ZR<>e*bd!C-2$n%`5tE*uGNs@4W zeva0f^?Hqn&@>HNYpk`TX-ZKP7-RapqA0M|(liab-HzF8#&|p)CZLo;DTVi*x3@P$ zgu1Rt(-eTZu6cQR!5D+JmMqKATBDRgYt48(##+l}vl%Av!DKSw=H`YF0?*IS{VC*m z&h_;*Ns@4KazarQeIID8`(7x^@@oRlIX0UOB0^PFD5Ve)x~{`}k5cbrCdNpN5qNLR z7$aJ1(li||AR=tHTkh}g`bgcmaL%z>t=Mk2`~QOZd@e&IKg*yi_}>D*4k@tr3IOKw`A^{YAw`ZHIr4q^ Y1IMisNbTmNO8@`>07*qoM6N<$f)uL|FaQ7m literal 0 HcmV?d00001 diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 6ea4e0b702..0207a8454e 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -702,7 +702,7 @@ def notify(self, args): frictionCoeff = physics_settings.addFloatSliderListCommandInput( "friction_coeff_override", "Friction Coefficient", "", valueList ) - frictionCoeff.isVisible = False + frictionCoeff.isVisible = True frictionCoeff.valueOne = 0.5 frictionCoeff.tooltip = "Friction coefficient of field element." frictionCoeff.tooltipDescription = "Friction coefficients range from 0 (ice) to 1 (rubber)." From 1a11e522ebdbd5a4b3854c7c2e8c8775c46064da Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Mon, 1 Jul 2024 11:42:14 -0700 Subject: [PATCH 02/21] added friction override to exporter options --- .../src/UI/ConfigCommand.py | 18 ++++++++++++++++-- exporter/SynthesisFusionAddin/src/configure.py | 5 +++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 0207a8454e..45ebf4bea0 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -4,7 +4,7 @@ import logging import os -import platform +#import platform import traceback from enum import Enum @@ -1174,6 +1174,18 @@ def notify(self, args): .children.itemById("compress") ).value + frictionOverride: bool = ( + eventArgs.command.commandInputs.itemById("advanced_settings") + .children.itemById("physics_settings") + .children.itemById("friction_override") + ).value + + frictionOverrideValue: float = ( + eventArgs.command.commandInputs.itemById("advanced_settings") + .children.itemById("physics_settings") + .children.itemById("friction_coeff_override") + ).value + exporterOptions = ExporterOptions( savepath, name, @@ -1187,9 +1199,11 @@ def notify(self, args): exportMode=_mode, compressOutput=compress, exportAsPart=export_as_part_boolean, + frictionOverride=frictionOverride, + frictionOverrideValue=frictionOverrideValue, ) - Parser(exporterOptions).export() + _: bool = Parser(exporterOptions).export() exporterOptions.writeToDesign() except: if gm.ui: diff --git a/exporter/SynthesisFusionAddin/src/configure.py b/exporter/SynthesisFusionAddin/src/configure.py index e121e7ae6e..0882f4080a 100644 --- a/exporter/SynthesisFusionAddin/src/configure.py +++ b/exporter/SynthesisFusionAddin/src/configure.py @@ -7,6 +7,7 @@ from .strings import INTERNAL_ID from .Types.OString import OString +from typing import Any try: config = ConfigParser() @@ -49,7 +50,7 @@ def setAnalytics(enabled: bool): return True -def get_value(key: str, section="main") -> any: +def get_value(key: str, section="main") -> Any: """Gets a value from the config file Args: @@ -62,7 +63,7 @@ def get_value(key: str, section="main") -> any: return config.get(section, key) -def write_configuration(section: str, key: str, value: any): +def write_configuration(section: str, key: str, value: Any): """Write a configuration flag to the ini file Args: From 3e8054cee9f1b389d6bb427bcdbf46fb1bd000bb Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Mon, 1 Jul 2024 11:46:02 -0700 Subject: [PATCH 03/21] added friction options exportation to config command --- exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py | 3 ++- exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index 4d01d9813f..995980444b 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -92,7 +92,8 @@ class ExporterOptions: # Always stored in kg regardless of 'preferredUnits' robotWeight: float = field(default=0.0) - frictionOverride: float = field(default=0.0) + frictionOverride: bool = field(default=False) + frictionOverrideCoeff: float | None = field(default=None) compressOutput: bool = field(default=True) exportAsPart: bool = field(default=False) diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 45ebf4bea0..33b84d6e01 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -1200,7 +1200,7 @@ def notify(self, args): compressOutput=compress, exportAsPart=export_as_part_boolean, frictionOverride=frictionOverride, - frictionOverrideValue=frictionOverrideValue, + frictionOverrideCoeff=frictionOverrideValue, ) _: bool = Parser(exporterOptions).export() From 393f618b89b8d712cfb978a2684367f394c0591b Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Wed, 3 Jul 2024 11:31:33 -0700 Subject: [PATCH 04/21] upload broken code for brandon to debug (tysm) --- .../src/Parser/SynthesisParser/Parser.py | 3 + .../src/UI/ConfigCommand.py | 72 +++++++++++-------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index a925f5b119..55f529775e 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -41,7 +41,10 @@ def export(self) -> bool: # Physical Props here when ready + self.logger.log(self.exporterOptions) + # ts = time() + progressDialog = app.userInterface.createProgressDialog() progressDialog.cancelButtonText = "Cancel" diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 33b84d6e01..7a37346d5a 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -621,11 +621,11 @@ def notify(self, args): """ Creates the advanced tab, which is the parent container for internal command inputs """ - advancedSettings = INPUTS_ROOT.addTabCommandInput("advanced_settings", "Advanced") + advancedSettings: adsk.core.TabCommandInput = INPUTS_ROOT.addTabCommandInput("advanced_settings", "Advanced") advancedSettings.tooltip = ( "Additional Advanced Settings to change how your model will be translated into Unity." ) - a_input = advancedSettings.children + a_input: adsk.core.CommandInputs = advancedSettings.children # ~~~~~~~~~~~~~~~~ EXPORTER SETTINGS ~~~~~~~~~~~~~~~~ """ @@ -660,12 +660,12 @@ def notify(self, args): """ Physics settings group command """ - physicsSettings = a_input.addGroupCommandInput("physics_settings", "Physics Settings") + physicsSettings: adsk.core.GroupCommandInput = a_input.addGroupCommandInput("physics_settings", "Physics Settings") - physicsSettings.isExpanded = False + physicsSettings.isExpanded = True physicsSettings.isEnabled = True - physicsSettings.tooltip = "tooltip" # TODO: update tooltip - physics_settings = physicsSettings.children + physicsSettings.tooltip = "Settings relating to the custom physics of the robot, like the wheel friction" + physics_settings: adsk.core.CommandInputs = physicsSettings.children # AARD-1687 # Should also be commented out / removed? @@ -673,7 +673,7 @@ def notify(self, args): # this is even being used. frictionOverrideTable = self.createTableInput( "friction_override_table", - "", + "Friction Override Table", physics_settings, 2, "1:2", @@ -683,32 +683,32 @@ def notify(self, args): frictionOverrideTable.tablePresentationStyle = 2 # frictionOverrideTable.isFullWidth = True - frictionOverride = self.createBooleanInput( + frictionOverrideInput = self.createBooleanInput( "friction_override", - "", + "Friction Override", physics_settings, - checked=False, + checked=physicsSettings.frictionOverrideBoolean, # object is missing attribute tooltip="Manually override the default friction values on the bodies in the assembly.", enabled=True, isCheckBox=False, ) - frictionOverride.resourceFolder = IconPaths.stringIcons["friction_override-enabled"] - frictionOverride.isFullWidth = True + frictionOverrideInput.resourceFolder = IconPaths.stringIcons["friction_override-enabled"] + frictionOverrideInput.isFullWidth = True valueList = [1] for i in range(20): valueList.append(i / 20) - frictionCoeff = physics_settings.addFloatSliderListCommandInput( + frictionCoeffSlider= physics_settings.addFloatSliderListCommandInput( "friction_coeff_override", "Friction Coefficient", "", valueList ) - frictionCoeff.isVisible = True - frictionCoeff.valueOne = 0.5 - frictionCoeff.tooltip = "Friction coefficient of field element." - frictionCoeff.tooltipDescription = "Friction coefficients range from 0 (ice) to 1 (rubber)." + frictionCoeffSlider.isVisible = True + frictionCoeffSlider.valueOne = 0.5 + frictionCoeffSlider.tooltip = "Friction coefficient of field element." + frictionCoeffSlider.tooltipDescription = "Friction coefficients range from 0 (ice) to 1 (rubber)." - frictionOverrideTable.addCommandInput(frictionOverride, 0, 0) - frictionOverrideTable.addCommandInput(frictionCoeff, 0, 1) + frictionOverrideTable.addCommandInput(frictionOverrideInput, 0, 0) + frictionOverrideTable.addCommandInput(frictionCoeffSlider, 0, 1) # ~~~~~~~~~~~~~~~~ JOINT SETTINGS ~~~~~~~~~~~~~~~~ """ @@ -1167,6 +1167,10 @@ def notify(self, args): elif dropdownExportMode.selectedItem.index == 1: _mode = ExportMode.FIELD + + """ + Advanced Settings + """ global compress compress = ( eventArgs.command.commandInputs.itemById("advanced_settings") @@ -1174,17 +1178,21 @@ def notify(self, args): .children.itemById("compress") ).value - frictionOverride: bool = ( - eventArgs.command.commandInputs.itemById("advanced_settings") - .children.itemById("physics_settings") - .children.itemById("friction_override") - ).value + settings = eventArgs.command.commandInputs.itemById("advanced_settings").children - frictionOverrideValue: float = ( - eventArgs.command.commandInputs.itemById("advanced_settings") - .children.itemById("physics_settings") - .children.itemById("friction_coeff_override") - ).value + gm.ui.messageBox(f"Command Inputs: {settings}") + + #frictionOverride: bool = ( + # eventArgs.command.commandInputs.itemById("advanced_settings") + # .children.itemById("physics_settings") + # .children.itemById("friction_override") + #).value + + #frictionOverrideValue: float = ( + # eventArgs.command.commandInputs.itemById("advanced_settings") + # .children.itemById("physics_settings") + # .children.itemById("friction_coeff_override") + #).value exporterOptions = ExporterOptions( savepath, @@ -1199,8 +1207,10 @@ def notify(self, args): exportMode=_mode, compressOutput=compress, exportAsPart=export_as_part_boolean, - frictionOverride=frictionOverride, - frictionOverrideCoeff=frictionOverrideValue, + #frictionOverride=frictionOverride, + #frictionOverrideCoeff=frictionOverrideValue, + frictionOverride=False, + frictionOverrideCoeff=None ) _: bool = Parser(exporterOptions).export() From 4a3337db96e7b382e7f89041b40ca7c48b07001d Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Wed, 3 Jul 2024 15:48:46 -0700 Subject: [PATCH 05/21] tested and fixed friction override exportation from config command --- .../src/Parser/SynthesisParser/Parser.py | 5 +- .../src/UI/ConfigCommand.py | 70 ++++++------------- 2 files changed, 23 insertions(+), 52 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 55f529775e..2c68771cc7 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -41,10 +41,7 @@ def export(self) -> bool: # Physical Props here when ready - self.logger.log(self.exporterOptions) - - # ts = time() - + # progressDialog = app.userInterface.createProgressDialog() progressDialog.cancelButtonText = "Cancel" diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 7a37346d5a..254db588cd 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -667,27 +667,11 @@ def notify(self, args): physicsSettings.tooltip = "Settings relating to the custom physics of the robot, like the wheel friction" physics_settings: adsk.core.CommandInputs = physicsSettings.children - # AARD-1687 - # Should also be commented out / removed? - # This would cause problems elsewhere but I can't tell i f - # this is even being used. - frictionOverrideTable = self.createTableInput( - "friction_override_table", - "Friction Override Table", - physics_settings, - 2, - "1:2", - 1, - columnSpacing=25, - ) - frictionOverrideTable.tablePresentationStyle = 2 - # frictionOverrideTable.isFullWidth = True - frictionOverrideInput = self.createBooleanInput( "friction_override", "Friction Override", physics_settings, - checked=physicsSettings.frictionOverrideBoolean, # object is missing attribute + checked=exporterOptions.frictionOverride, # object is missing attribute tooltip="Manually override the default friction values on the bodies in the assembly.", enabled=True, isCheckBox=False, @@ -699,17 +683,14 @@ def notify(self, args): for i in range(20): valueList.append(i / 20) - frictionCoeffSlider= physics_settings.addFloatSliderListCommandInput( - "friction_coeff_override", "Friction Coefficient", "", valueList + frictionCoeffSlider: adsk.core.FloatSliderCommandInput = physics_settings.addFloatSliderListCommandInput( + "friction_override_coeff", "Friction Coefficient", "", valueList ) frictionCoeffSlider.isVisible = True frictionCoeffSlider.valueOne = 0.5 frictionCoeffSlider.tooltip = "Friction coefficient of field element." frictionCoeffSlider.tooltipDescription = "Friction coefficients range from 0 (ice) to 1 (rubber)." - frictionOverrideTable.addCommandInput(frictionOverrideInput, 0, 0) - frictionOverrideTable.addCommandInput(frictionCoeffSlider, 0, 1) - # ~~~~~~~~~~~~~~~~ JOINT SETTINGS ~~~~~~~~~~~~~~~~ """ Joint settings group command @@ -999,12 +980,7 @@ def notify(self, args): self.log.error("Could not execute configuration due to failure") return - export_as_part_boolean = ( - eventArgs.command.commandInputs.itemById("advanced_settings") - .children.itemById("exporter_settings") - .children.itemById("export_as_part") - ).value - + processedFileName = gm.app.activeDocument.name.replace(" ", "_") dropdownExportMode = INPUTS_ROOT.itemById("mode") if dropdownExportMode.selectedItem.index == 0: @@ -1177,22 +1153,22 @@ def notify(self, args): .children.itemById("exporter_settings") .children.itemById("compress") ).value + + export_as_part_boolean = ( + eventArgs.command.commandInputs.itemById("advanced_settings") + .children.itemById("exporter_settings") + .children.itemById("export_as_part") + ).value - settings = eventArgs.command.commandInputs.itemById("advanced_settings").children - - gm.ui.messageBox(f"Command Inputs: {settings}") - - #frictionOverride: bool = ( - # eventArgs.command.commandInputs.itemById("advanced_settings") - # .children.itemById("physics_settings") - # .children.itemById("friction_override") - #).value - - #frictionOverrideValue: float = ( - # eventArgs.command.commandInputs.itemById("advanced_settings") - # .children.itemById("physics_settings") - # .children.itemById("friction_coeff_override") - #).value + frictionOverrideButton: adsk.core.BoolValueCommandInput = (eventArgs.command.commandInputs.itemById("advanced_settings") + .children.itemById("physics_settings") + .children.itemById("friction_override")) + frictionSlider: adsk.core.FloatSliderCommandInput = (eventArgs.command.commandInputs.itemById("advanced_settings") + .children.itemById("physics_settings") + .children.itemById("friction_override_coeff")) + + frictionOverrideCoeff = frictionSlider.valueOne + frictionOverride = frictionSlider.isVisible exporterOptions = ExporterOptions( savepath, @@ -1207,10 +1183,8 @@ def notify(self, args): exportMode=_mode, compressOutput=compress, exportAsPart=export_as_part_boolean, - #frictionOverride=frictionOverride, - #frictionOverrideCoeff=frictionOverrideValue, - frictionOverride=False, - frictionOverrideCoeff=None + frictionOverride=frictionOverride, + frictionOverrideCoeff=frictionOverrideCoeff ) _: bool = Parser(exporterOptions).export() @@ -1652,7 +1626,7 @@ def notify(self, args): inputs = cmdInput.commandInputs onSelect = gm.handlers[3] - frictionCoeff = INPUTS_ROOT.itemById("friction_coeff_override") + frictionCoeff = INPUTS_ROOT.itemById("friction_override_coeff") wheelSelect = inputs.itemById("wheel_select") jointSelect = inputs.itemById("joint_select") From d4d118a0e051b7c3f32a35381a67ed465130daa7 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Thu, 4 Jul 2024 16:25:29 -0700 Subject: [PATCH 06/21] added friction override to mirabuf assembly --- .../SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 2c68771cc7..de1eca831a 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -41,6 +41,8 @@ def export(self) -> bool: # Physical Props here when ready + if self.exporterOptions.frictionOverride: + assembly_out.data.parts.parts_definitions.value.friction_override = self.exporterOptions.frictionOverrideCoeff # progressDialog = app.userInterface.createProgressDialog() From 01aa9dd3d60c24be4f40aa50a26e665f46744a2e Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Thu, 4 Jul 2024 23:34:57 -0700 Subject: [PATCH 07/21] added export location --- .../src/Parser/ExporterOptions.py | 5 +++- .../src/Parser/SynthesisParser/Parser.py | 3 +- .../src/UI/ConfigCommand.py | 28 +++++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index 995980444b..7e90f4000b 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -22,6 +22,7 @@ SignalType = Enum("SignalType", ["PWM", "CAN", "PASSIVE"]) ExportMode = Enum("ExportMode", ["ROBOT", "FIELD"]) # Dynamic / Static export PreferredUnits = Enum("PreferredUnits", ["METRIC", "IMPERIAL"]) +ExportLocation = Enum("ExportLocation", ["UPLOAD", "DOWNLOAD"]) @dataclass @@ -93,7 +94,9 @@ class ExporterOptions: robotWeight: float = field(default=0.0) frictionOverride: bool = field(default=False) - frictionOverrideCoeff: float | None = field(default=None) + frictionOverrideCoeff: float = field(default=0.5) + + exportLocation: ExportLocation = field(default=ExportLocation.UPLOAD) compressOutput: bool = field(default=True) exportAsPart: bool = field(default=False) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index de1eca831a..0279b50694 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -41,9 +41,10 @@ def export(self) -> bool: # Physical Props here when ready + # TODO: Test exporting to mirabuf and add export location + if self.exporterOptions.frictionOverride: assembly_out.data.parts.parts_definitions.value.friction_override = self.exporterOptions.frictionOverrideCoeff - # progressDialog = app.userInterface.createProgressDialog() progressDialog.cancelButtonText = "Cancel" diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 254db588cd..cba810d979 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -15,6 +15,7 @@ from ..configure import NOTIFIED, write_configuration from ..general_imports import * from ..Parser.ExporterOptions import ( + ExportLocation, ExporterOptions, ExportMode, Gamepiece, @@ -222,6 +223,17 @@ def notify(self, args): dropdownExportMode.tooltip = "Export Mode" dropdownExportMode.tooltipDescription = "
Does this object move dynamically?" + # ~~~~~~~~~~~~~~~~ EXPORT LOCATION ~~~~~~~~~~~~~~~~~~ + + dropdownExportLocation = inputs.addDropDownCommandInput("location", "Export Location", dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle) + + upload: bool = exporterOptions.exportLocation == ExportLocation.UPLOAD + dropdownExportLocation.listItems.add("Upload", upload) + dropdownExportLocation.listItems.add("Download", not upload) + + dropdownExportLocation.tooltip = "Export Location" + dropdownExportLocation.tooltipDescription = "
Do you want to upload this mirabuf file to APS, or download it to your local machine?" + # ~~~~~~~~~~~~~~~~ WEIGHT CONFIGURATION ~~~~~~~~~~~~~~~~ """ Table for weight config. @@ -1013,8 +1025,9 @@ def notify(self, args): _exportWheels = [] # all selected wheels, formatted for parseOptions _exportJoints = [] # all selected joints, formatted for parseOptions _exportGamepieces = [] # TODO work on the code to populate Gamepiece - _robotWeight = float - _mode = ExportMode.ROBOT + _robotWeight: float + _mode: ExportLocation + _location: ExportLocation """ Loops through all rows in the wheel table to extract all the input values @@ -1143,6 +1156,16 @@ def notify(self, args): elif dropdownExportMode.selectedItem.index == 1: _mode = ExportMode.FIELD + """ + Export Location + """ + + dropdownExportLocation = INPUTS_ROOT.itemById("location") + if dropdownExportLocation.select.index == 0: + _location = ExportLocation.UPLOAD + elif dropdownExportLocation.select.index == 1: + _location = ExportLocation.DOWNLOAD + """ Advanced Settings @@ -1181,6 +1204,7 @@ def notify(self, args): preferredUnits=selectedUnits, robotWeight=_robotWeight, exportMode=_mode, + exportLocation=_location, compressOutput=compress, exportAsPart=export_as_part_boolean, frictionOverride=frictionOverride, From 4b92b618296e9b379189dc3572c85745328b22f8 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Fri, 5 Jul 2024 10:25:05 -0700 Subject: [PATCH 08/21] Revert "added export location" This reverts commit 01aa9dd3d60c24be4f40aa50a26e665f46744a2e. --- .../src/Parser/ExporterOptions.py | 5 +--- .../src/Parser/SynthesisParser/Parser.py | 3 +- .../src/UI/ConfigCommand.py | 28 ++----------------- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index 7e90f4000b..995980444b 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -22,7 +22,6 @@ SignalType = Enum("SignalType", ["PWM", "CAN", "PASSIVE"]) ExportMode = Enum("ExportMode", ["ROBOT", "FIELD"]) # Dynamic / Static export PreferredUnits = Enum("PreferredUnits", ["METRIC", "IMPERIAL"]) -ExportLocation = Enum("ExportLocation", ["UPLOAD", "DOWNLOAD"]) @dataclass @@ -94,9 +93,7 @@ class ExporterOptions: robotWeight: float = field(default=0.0) frictionOverride: bool = field(default=False) - frictionOverrideCoeff: float = field(default=0.5) - - exportLocation: ExportLocation = field(default=ExportLocation.UPLOAD) + frictionOverrideCoeff: float | None = field(default=None) compressOutput: bool = field(default=True) exportAsPart: bool = field(default=False) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 0279b50694..de1eca831a 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -41,10 +41,9 @@ def export(self) -> bool: # Physical Props here when ready - # TODO: Test exporting to mirabuf and add export location - if self.exporterOptions.frictionOverride: assembly_out.data.parts.parts_definitions.value.friction_override = self.exporterOptions.frictionOverrideCoeff + # progressDialog = app.userInterface.createProgressDialog() progressDialog.cancelButtonText = "Cancel" diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index cba810d979..254db588cd 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -15,7 +15,6 @@ from ..configure import NOTIFIED, write_configuration from ..general_imports import * from ..Parser.ExporterOptions import ( - ExportLocation, ExporterOptions, ExportMode, Gamepiece, @@ -223,17 +222,6 @@ def notify(self, args): dropdownExportMode.tooltip = "Export Mode" dropdownExportMode.tooltipDescription = "
Does this object move dynamically?" - # ~~~~~~~~~~~~~~~~ EXPORT LOCATION ~~~~~~~~~~~~~~~~~~ - - dropdownExportLocation = inputs.addDropDownCommandInput("location", "Export Location", dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle) - - upload: bool = exporterOptions.exportLocation == ExportLocation.UPLOAD - dropdownExportLocation.listItems.add("Upload", upload) - dropdownExportLocation.listItems.add("Download", not upload) - - dropdownExportLocation.tooltip = "Export Location" - dropdownExportLocation.tooltipDescription = "
Do you want to upload this mirabuf file to APS, or download it to your local machine?" - # ~~~~~~~~~~~~~~~~ WEIGHT CONFIGURATION ~~~~~~~~~~~~~~~~ """ Table for weight config. @@ -1025,9 +1013,8 @@ def notify(self, args): _exportWheels = [] # all selected wheels, formatted for parseOptions _exportJoints = [] # all selected joints, formatted for parseOptions _exportGamepieces = [] # TODO work on the code to populate Gamepiece - _robotWeight: float - _mode: ExportLocation - _location: ExportLocation + _robotWeight = float + _mode = ExportMode.ROBOT """ Loops through all rows in the wheel table to extract all the input values @@ -1156,16 +1143,6 @@ def notify(self, args): elif dropdownExportMode.selectedItem.index == 1: _mode = ExportMode.FIELD - """ - Export Location - """ - - dropdownExportLocation = INPUTS_ROOT.itemById("location") - if dropdownExportLocation.select.index == 0: - _location = ExportLocation.UPLOAD - elif dropdownExportLocation.select.index == 1: - _location = ExportLocation.DOWNLOAD - """ Advanced Settings @@ -1204,7 +1181,6 @@ def notify(self, args): preferredUnits=selectedUnits, robotWeight=_robotWeight, exportMode=_mode, - exportLocation=_location, compressOutput=compress, exportAsPart=export_as_part_boolean, frictionOverride=frictionOverride, From 4cff48634bcdc07ef4d59dcb65f0bdb962c0a4df Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Mon, 8 Jul 2024 09:08:17 -0700 Subject: [PATCH 09/21] ran formatter --- .../src/Parser/SynthesisParser/Parser.py | 4 ++- .../src/UI/ConfigCommand.py | 35 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index de1eca831a..61181c23c5 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -42,7 +42,9 @@ def export(self) -> bool: # Physical Props here when ready if self.exporterOptions.frictionOverride: - assembly_out.data.parts.parts_definitions.value.friction_override = self.exporterOptions.frictionOverrideCoeff + assembly_out.data.parts.parts_definitions.value.friction_override = ( + self.exporterOptions.frictionOverrideCoeff + ) # progressDialog = app.userInterface.createProgressDialog() diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 254db588cd..18550b3b0e 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -4,7 +4,8 @@ import logging import os -#import platform + +# import platform import traceback from enum import Enum @@ -621,7 +622,9 @@ def notify(self, args): """ Creates the advanced tab, which is the parent container for internal command inputs """ - advancedSettings: adsk.core.TabCommandInput = INPUTS_ROOT.addTabCommandInput("advanced_settings", "Advanced") + advancedSettings: adsk.core.TabCommandInput = INPUTS_ROOT.addTabCommandInput( + "advanced_settings", "Advanced" + ) advancedSettings.tooltip = ( "Additional Advanced Settings to change how your model will be translated into Unity." ) @@ -660,7 +663,9 @@ def notify(self, args): """ Physics settings group command """ - physicsSettings: adsk.core.GroupCommandInput = a_input.addGroupCommandInput("physics_settings", "Physics Settings") + physicsSettings: adsk.core.GroupCommandInput = a_input.addGroupCommandInput( + "physics_settings", "Physics Settings" + ) physicsSettings.isExpanded = True physicsSettings.isEnabled = True @@ -671,7 +676,7 @@ def notify(self, args): "friction_override", "Friction Override", physics_settings, - checked=exporterOptions.frictionOverride, # object is missing attribute + checked=exporterOptions.frictionOverride, # object is missing attribute tooltip="Manually override the default friction values on the bodies in the assembly.", enabled=True, isCheckBox=False, @@ -686,7 +691,7 @@ def notify(self, args): frictionCoeffSlider: adsk.core.FloatSliderCommandInput = physics_settings.addFloatSliderListCommandInput( "friction_override_coeff", "Friction Coefficient", "", valueList ) - frictionCoeffSlider.isVisible = True + frictionCoeffSlider.isVisible = True frictionCoeffSlider.valueOne = 0.5 frictionCoeffSlider.tooltip = "Friction coefficient of field element." frictionCoeffSlider.tooltipDescription = "Friction coefficients range from 0 (ice) to 1 (rubber)." @@ -980,7 +985,6 @@ def notify(self, args): self.log.error("Could not execute configuration due to failure") return - processedFileName = gm.app.activeDocument.name.replace(" ", "_") dropdownExportMode = INPUTS_ROOT.itemById("mode") if dropdownExportMode.selectedItem.index == 0: @@ -1143,7 +1147,6 @@ def notify(self, args): elif dropdownExportMode.selectedItem.index == 1: _mode = ExportMode.FIELD - """ Advanced Settings """ @@ -1153,20 +1156,24 @@ def notify(self, args): .children.itemById("exporter_settings") .children.itemById("compress") ).value - + export_as_part_boolean = ( eventArgs.command.commandInputs.itemById("advanced_settings") .children.itemById("exporter_settings") .children.itemById("export_as_part") ).value - frictionOverrideButton: adsk.core.BoolValueCommandInput = (eventArgs.command.commandInputs.itemById("advanced_settings") + frictionOverrideButton: adsk.core.BoolValueCommandInput = ( + eventArgs.command.commandInputs.itemById("advanced_settings") .children.itemById("physics_settings") - .children.itemById("friction_override")) - frictionSlider: adsk.core.FloatSliderCommandInput = (eventArgs.command.commandInputs.itemById("advanced_settings") + .children.itemById("friction_override") + ) + frictionSlider: adsk.core.FloatSliderCommandInput = ( + eventArgs.command.commandInputs.itemById("advanced_settings") .children.itemById("physics_settings") - .children.itemById("friction_override_coeff")) - + .children.itemById("friction_override_coeff") + ) + frictionOverrideCoeff = frictionSlider.valueOne frictionOverride = frictionSlider.isVisible @@ -1184,7 +1191,7 @@ def notify(self, args): compressOutput=compress, exportAsPart=export_as_part_boolean, frictionOverride=frictionOverride, - frictionOverrideCoeff=frictionOverrideCoeff + frictionOverrideCoeff=frictionOverrideCoeff, ) _: bool = Parser(exporterOptions).export() From be4426cf897358bbe75af3d200018fa69a5005d2 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Fri, 12 Jul 2024 08:54:58 -0700 Subject: [PATCH 10/21] move friction override serialization --- exporter/SynthesisFusionAddin/src/APS/APS.py | 5 ++--- .../src/Parser/SynthesisParser/Parser.py | 9 ++++----- fission/src/mirabuf/MirabufParser.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/APS/APS.py b/exporter/SynthesisFusionAddin/src/APS/APS.py index e31964e561..245bfa2b88 100644 --- a/exporter/SynthesisFusionAddin/src/APS/APS.py +++ b/exporter/SynthesisFusionAddin/src/APS/APS.py @@ -23,7 +23,6 @@ APS_AUTH = None APS_USER_INFO = None - @dataclass class APSAuth: access_token: str @@ -66,6 +65,7 @@ def getCodeChallenge() -> str | None: def getAuth() -> APSAuth: + curr_time = int(time.time() * 1000) global APS_AUTH if APS_AUTH is not None: return APS_AUTH @@ -76,12 +76,11 @@ def getAuth() -> APSAuth: access_token=p["access_token"], refresh_token=p["refresh_token"], expires_in=p["expires_in"], - expires_at=int(p["expires_in"] * 1000), + expires_at=int(curr_time + (p["expires_in"] * 1000)), token_type=p["token_type"], ) except: raise Exception("Need to sign in!") - curr_time = int(time.time() * 1000) if curr_time >= APS_AUTH.expires_at: refreshAuthToken() if APS_USER_INFO is None: diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 61181c23c5..c5893faa3f 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -41,11 +41,7 @@ def export(self) -> bool: # Physical Props here when ready - if self.exporterOptions.frictionOverride: - assembly_out.data.parts.parts_definitions.value.friction_override = ( - self.exporterOptions.frictionOverrideCoeff - ) - # + # progressDialog = app.userInterface.createProgressDialog() progressDialog.cancelButtonText = "Cancel" @@ -130,6 +126,9 @@ def export(self) -> bool: JointHierarchy.BuildJointPartHierarchy( design, assembly_out.data.joints, self.exporterOptions, self.pdMessage ) + gm.ui.messageBox(json.dumps(assembly_out.data.parts), "PRINT") + if self.exporterOptions.frictionOverride: + assembly_out.data.parts.part_definitions[].value.friction_override = self.exporterOptions.frictionOverrideCoeff # These don't have an effect, I forgot how this is suppose to work # progressDialog.message = "Taking Photo for thumbnail..." diff --git a/fission/src/mirabuf/MirabufParser.ts b/fission/src/mirabuf/MirabufParser.ts index a9a814e85a..e206adedc0 100644 --- a/fission/src/mirabuf/MirabufParser.ts +++ b/fission/src/mirabuf/MirabufParser.ts @@ -226,6 +226,14 @@ class MirabufParser { directedRecursive(this._rigidNodes[0].id) } this._directedGraph = directedGraph + + const partDefinitions: { [k: string]: mirabuf.IPartDefinition } | null | undefined = + this.assembly.data?.parts?.partDefinitions + if (!partDefinitions) { + console.log("Failed to get part definitions") + return + } + console.log(partDefinitions) } private NewRigidNode(suffix?: string): RigidNode { From 0f29963a43a1ec0d41598431d1ce52e51d551517 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Fri, 12 Jul 2024 09:53:58 -0700 Subject: [PATCH 11/21] move friction override to materials --- .../src/Parser/SynthesisParser/Materials.py | 12 ++++++++---- .../src/Parser/SynthesisParser/Parser.py | 5 ----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index b3199a1f9d..9049c8c5c1 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -8,7 +8,7 @@ from proto.proto_out import material_pb2 from ...general_imports import INTERNAL_ID -from .. import ExporterOptions +from ..ExporterOptions import ExporterOptions from .PDMessage import PDMessage from .Utilities import * @@ -33,12 +33,16 @@ def _MapAllPhysicalMaterials( getPhysicalMaterialData(material, newmaterial, options) -def setDefaultMaterial(physical_material: material_pb2.PhysicalMaterial): +def setDefaultMaterial(physical_material: material_pb2.PhysicalMaterial, options: ExporterOptions): construct_info("default", physical_material) physical_material.description = "A default physical material" - physical_material.dynamic_friction = 0.5 - physical_material.static_friction = 0.5 + if options.frictionOverride: + physical_material.dynamic_friction = options.frictionOverrideCoeff + physical_material.static_friction = options.frictionOverrideCoeff + else: + physical_material.dynamic_friction = 0.5 + physical_material.static_friction = 0.5 physical_material.restitution = 0.5 physical_material.deformable = False diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index c5893faa3f..0b511e0066 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -41,8 +41,6 @@ def export(self) -> bool: # Physical Props here when ready - # - progressDialog = app.userInterface.createProgressDialog() progressDialog.cancelButtonText = "Cancel" progressDialog.isBackgroundTranslucent = False @@ -126,9 +124,6 @@ def export(self) -> bool: JointHierarchy.BuildJointPartHierarchy( design, assembly_out.data.joints, self.exporterOptions, self.pdMessage ) - gm.ui.messageBox(json.dumps(assembly_out.data.parts), "PRINT") - if self.exporterOptions.frictionOverride: - assembly_out.data.parts.part_definitions[].value.friction_override = self.exporterOptions.frictionOverrideCoeff # These don't have an effect, I forgot how this is suppose to work # progressDialog.message = "Taking Photo for thumbnail..." From ddac7fe772c83fafe00778a09be9af63a96824ab Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Fri, 12 Jul 2024 10:01:18 -0700 Subject: [PATCH 12/21] pass in options correctly --- .../src/Parser/SynthesisParser/Materials.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 9049c8c5c1..02aff8daa5 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -21,7 +21,7 @@ def _MapAllPhysicalMaterials( options: ExporterOptions, progressDialog: PDMessage, ) -> None: - setDefaultMaterial(materials.physicalMaterials["default"]) + setDefaultMaterial(materials.physicalMaterials["default"], options) for material in physicalMaterials: progressDialog.addMaterial(material.name) From 85ddf0bc31315875672c3d8a54b8168dd858a5be Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Fri, 12 Jul 2024 13:00:06 -0700 Subject: [PATCH 13/21] export aps auth from strings --- exporter/SynthesisFusionAddin/src/APS/APS.py | 12 +++++++----- exporter/SynthesisFusionAddin/src/strings.py | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/APS/APS.py b/exporter/SynthesisFusionAddin/src/APS/APS.py index 245bfa2b88..31f74056c6 100644 --- a/exporter/SynthesisFusionAddin/src/APS/APS.py +++ b/exporter/SynthesisFusionAddin/src/APS/APS.py @@ -10,6 +10,7 @@ from ..general_imports import ( APP_NAME, + APS_AUTH, DESCRIPTION, INTERNAL_ID, gm, @@ -20,7 +21,6 @@ CLIENT_ID = "GCxaewcLjsYlK8ud7Ka9AKf9dPwMR3e4GlybyfhAK2zvl3tU" auth_path = os.path.abspath(os.path.join(my_addin_path, "..", ".aps_auth")) -APS_AUTH = None APS_USER_INFO = None @dataclass @@ -64,7 +64,7 @@ def getCodeChallenge() -> str | None: return data["challenge"] -def getAuth() -> APSAuth: +def getAuth() -> APSAuth | None: curr_time = int(time.time() * 1000) global APS_AUTH if APS_AUTH is not None: @@ -80,7 +80,9 @@ def getAuth() -> APSAuth: token_type=p["token_type"], ) except: - raise Exception("Need to sign in!") + gm.ui.messageBox("Need to sign in!") + return None + if curr_time >= APS_AUTH.expires_at: refreshAuthToken() if APS_USER_INFO is None: @@ -97,7 +99,7 @@ def convertAuthToken(code: str): access_token=data["access_token"], refresh_token=data["refresh_token"], expires_in=data["expires_in"], - expires_at=int(data["expires_in"] * 1000), + expires_at=int(curr_time + data["expires_in"] * 1000), token_type=data["token_type"], ) with open(auth_path, "wb") as f: @@ -136,7 +138,7 @@ def refreshAuthToken(): access_token=data["access_token"], refresh_token=data["refresh_token"], expires_in=data["expires_in"], - expires_at=int(data["expires_in"] * 1000), + expires_at=int(curr_time + data["expires_in"] * 1000), token_type=data["token_type"], ) except urllib.request.HTTPError as e: diff --git a/exporter/SynthesisFusionAddin/src/strings.py b/exporter/SynthesisFusionAddin/src/strings.py index 6e3aa109e2..ae5b372900 100644 --- a/exporter/SynthesisFusionAddin/src/strings.py +++ b/exporter/SynthesisFusionAddin/src/strings.py @@ -2,3 +2,4 @@ APP_TITLE = "Synthesis Robot Exporter" DESCRIPTION = "Exports files from Fusion into the Synthesis Format" INTERNAL_ID = "synthesis" +APS_AUTH: None | str = None From 363438c1a226dc9a7924feecba22f901529bb025 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Fri, 12 Jul 2024 14:09:51 -0700 Subject: [PATCH 14/21] add curr_time to another place it was missing --- exporter/SynthesisFusionAddin/src/APS/APS.py | 5 ++++- .../SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/APS/APS.py b/exporter/SynthesisFusionAddin/src/APS/APS.py index 31f74056c6..9317cb7a20 100644 --- a/exporter/SynthesisFusionAddin/src/APS/APS.py +++ b/exporter/SynthesisFusionAddin/src/APS/APS.py @@ -95,11 +95,13 @@ def convertAuthToken(code: str): authUrl = f'http://localhost:80/api/aps/code/?code={code}&redirect_uri={urllib.parse.quote_plus("http://localhost:80/api/aps/exporter/")}' res = urllib.request.urlopen(authUrl) data = _res_json(res)["response"] + curr_time = time.time() * 1000 + logging.getLogger("curr_time{}".format(curr_time)) APS_AUTH = APSAuth( access_token=data["access_token"], refresh_token=data["refresh_token"], expires_in=data["expires_in"], - expires_at=int(curr_time + data["expires_in"] * 1000), + expires_at=curr_time + data["expires_in"] * 1000, token_type=data["token_type"], ) with open(auth_path, "wb") as f: @@ -131,6 +133,7 @@ def refreshAuthToken(): req = urllib.request.Request("https://developer.api.autodesk.com/authentication/v2/token", data=body) req.method = "POST" req.add_header(key="Content-Type", val="application/x-www-form-urlencoded") + curr_time = time.time() * 1000 try: res = urllib.request.urlopen(req) data = _res_json(res) diff --git a/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py b/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py index bacc6e094b..6042e54e56 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py @@ -80,8 +80,8 @@ def notify(self, args): command.execute.add(onExecute) gm.handlers.append(onExecute) except: - gm.ui.messageBox("Failed:\n{}".format(traceback.format_exc())) - logging.getLogger(f"{INTERNAL_ID}").error("Failed:\n{}".format(traceback.format_exc())) + gm.ui.messageBox("Failed:\n{}Here".format(traceback.format_exc())) + logging.getLogger(f"{INTERNAL_ID}").error("Failed:\n{}Here".format(traceback.format_exc())) if palette: palette.deleteMe() @@ -139,7 +139,7 @@ def notify(self, args): convertAuthToken(data["code"]) except: - gm.ui.messageBox("Failed:\n".format(traceback.format_exc())) - logging.getLogger(f"{INTERNAL_ID}").error("Failed:\n".format(traceback.format_exc())) + gm.ui.messageBox("Failed:\n{}".format(traceback.format_exc())) + logging.getLogger(f"{INTERNAL_ID}").error("Failed:\n{}".format(traceback.format_exc())) if palette: palette.deleteMe() From 0b49cd2b18835c8317c335bcba08508418aa0f78 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Thu, 18 Jul 2024 13:53:21 -0700 Subject: [PATCH 15/21] added friction override to parsing --- .../src/Parser/SynthesisParser/Materials.py | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 02aff8daa5..b7db69a2e0 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -2,18 +2,32 @@ import logging import math import traceback - +import json import adsk from proto.proto_out import material_pb2 -from ...general_imports import INTERNAL_ID +from ...general_imports import * from ..ExporterOptions import ExporterOptions from .PDMessage import PDMessage from .Utilities import * OPACITY_RAMPING_CONSTANT = 14.0 +# Update tables as needed for UX and needed materials +static_friction_coeffs = { + 'Aluminum': 1.1, + 'Steel': 0.75, + 'Rubber': 1.0, + 'Plastic': 0.7, +} + +dynamic_friction_coeffs = { + 'Aluminum': 1.1, + 'Steel': 0.75, + 'Rubber': 1.0, + 'Plastic': 0.7, +} def _MapAllPhysicalMaterials( physicalMaterials: list, @@ -24,6 +38,7 @@ def _MapAllPhysicalMaterials( setDefaultMaterial(materials.physicalMaterials["default"], options) for material in physicalMaterials: + progressDialog.addMaterial(material.name) if progressDialog.wasCancelled(): @@ -57,6 +72,14 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): proto_material (protomaterial): proto material mirabuf options (parseoptions): parse options """ + + string: str = "" + + for prop in fusion_material.materialProperties: + string += " " + prop.name +" type: " +str(type(prop)) + "\n\n" + + logging.getLogger(INTERNAL_ID).info(string) + try: construct_info("", proto_material, fus_object=fusion_material) @@ -69,8 +92,13 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): mechanicalProperties = proto_material.mechanical strengthProperties = proto_material.strength - proto_material.dynamic_friction = 0.5 - proto_material.static_friction = 0.5 + if options.frictionOverride: + physical_material.dynamic_friction = options.frictionOverrideCoeff + physical_material.static_friction = options.frictionOverrideCoeff + else: + physical_material.dynamic_friction = dynamic_friction_coeffs.get(fusion_material.name, 0.5) + physical_material.static_friction = static_friction_coeffs.get(fusion_material.name, 0.5) + proto_material.restitution = 0.5 proto_material.description = f"{fusion_material.name} exported from FUSION" From 42154ce875e327ba19a35e4966ce14b491e9788a Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Wed, 24 Jul 2024 15:50:45 -0700 Subject: [PATCH 16/21] fixed double button and physical material misnaming --- .../src/Parser/SynthesisParser/Materials.py | 8 ++++---- .../SynthesisFusionAddin/src/UI/ConfigCommand.py | 13 +------------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 704f64b0ad..00c5090c89 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -93,11 +93,11 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): strengthProperties = proto_material.strength if options.frictionOverride: - physical_material.dynamic_friction = options.frictionOverrideCoeff - physical_material.static_friction = options.frictionOverrideCoeff + proto_material.dynamic_friction = options.frictionOverrideCoeff + proto_material.static_friction = options.frictionOverrideCoeff else: - physical_material.dynamic_friction = dynamic_friction_coeffs.get(fusion_material.name, 0.5) - physical_material.static_friction = static_friction_coeffs.get(fusion_material.name, 0.5) + proto_material.dynamic_friction = dynamic_friction_coeffs.get(fusion_material.name, 0.5) + proto_material.static_friction = static_friction_coeffs.get(fusion_material.name, 0.5) proto_material.restitution = 0.5 proto_material.dynamic_friction = 0.5 diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 9b9665552a..05721f1e7f 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -511,18 +511,7 @@ def notify(self, args): # enabled=True, # ) - frictionOverrideInput = self.createBooleanInput( - "friction_override", - "Friction Override", - physics_settings, - checked=exporterOptions.frictionOverride, # object is missing attribute - tooltip="Manually override the default friction values on the bodies in the assembly.", - enabled=True, - isCheckBox=False, - ) - frictionOverrideInput.resourceFolder = IconPaths.stringIcons["friction_override-enabled"] - frictionOverrideInput.isFullWidth = True - # self.createBooleanInput( + # self.createBooleanInput( # "calculate_limits", # "Calculate Limits", # joints_settings, From c777ef98e204205fb0c0f103b9a6c547937f9fca Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Wed, 24 Jul 2024 16:08:00 -0700 Subject: [PATCH 17/21] ran formatter --- .../src/Parser/SynthesisParser/Materials.py | 21 ++++++++++--------- .../src/UI/ConfigCommand.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 00c5090c89..4b3fc6d9b7 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -17,19 +17,20 @@ # Update tables as needed for UX and needed materials static_friction_coeffs = { - 'Aluminum': 1.1, - 'Steel': 0.75, - 'Rubber': 1.0, - 'Plastic': 0.7, + "Aluminum": 1.1, + "Steel": 0.75, + "Rubber": 1.0, + "Plastic": 0.7, } dynamic_friction_coeffs = { - 'Aluminum': 1.1, - 'Steel': 0.75, - 'Rubber': 1.0, - 'Plastic': 0.7, + "Aluminum": 1.1, + "Steel": 0.75, + "Rubber": 1.0, + "Plastic": 0.7, } + def _MapAllPhysicalMaterials( physicalMaterials: list, materials: material_pb2.Materials, @@ -77,9 +78,9 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): string: str = "" for prop in fusion_material.materialProperties: - string += " " + prop.name +" type: " + str(type(prop)) + "\n\n" + string += " " + prop.name + " type: " + str(type(prop)) + "\n\n" - logging.getLogger(INTERNAL_ID).info(string) + logging.getLogger(INTERNAL_ID).info(string) construct_info("", proto_material, fus_object=fusion_material) diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 05721f1e7f..f26829638c 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -511,7 +511,7 @@ def notify(self, args): # enabled=True, # ) - # self.createBooleanInput( + # self.createBooleanInput( # "calculate_limits", # "Calculate Limits", # joints_settings, From 3b17c5a87d0c7c988eb5a9cde7c2b1c755b8e067 Mon Sep 17 00:00:00 2001 From: Azalea Colburn Date: Thu, 25 Jul 2024 09:09:56 -0700 Subject: [PATCH 18/21] fix friction override --- .../src/Parser/SynthesisParser/Materials.py | 20 +++++++++---------- .../src/UI/ConfigCommand.py | 13 +++++++++++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 4b3fc6d9b7..00ef48f315 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -18,16 +18,18 @@ # Update tables as needed for UX and needed materials static_friction_coeffs = { "Aluminum": 1.1, - "Steel": 0.75, - "Rubber": 1.0, - "Plastic": 0.7, + "Steel, Cast": 0.75, + "Steel, Mild": 0.75, + "Rubber, Nitrile": 1.0, + "ABS Plastic": 0.7, } dynamic_friction_coeffs = { "Aluminum": 1.1, - "Steel": 0.75, - "Rubber": 1.0, - "Plastic": 0.7, + "Steel, Cast": 0.75, + "Steel, Mild": 0.75, + "Rubber, Nitrile": 1.0, + "ABS Plastic": 0.7, } @@ -37,6 +39,7 @@ def _MapAllPhysicalMaterials( options: ExporterOptions, progressDialog: PDMessage, ) -> None: + logging.getLogger(INTERNAL_ID).info("In Materials") setDefaultMaterial(materials.physicalMaterials["default"], options) for material in physicalMaterials: @@ -77,11 +80,6 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): """ string: str = "" - for prop in fusion_material.materialProperties: - string += " " + prop.name + " type: " + str(type(prop)) + "\n\n" - - logging.getLogger(INTERNAL_ID).info(string) - construct_info("", proto_material, fus_object=fusion_material) proto_material.deformable = False diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index f26829638c..865954d48a 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -466,7 +466,7 @@ def notify(self, args): "friction_override", "Friction Override", physics_settings, - checked=True, # object is missing attribute + checked=True, tooltip="Manually override the default friction values on the bodies in the assembly.", enabled=True, isCheckBox=False, @@ -879,6 +879,15 @@ def notify(self, args): .children.itemById("export_as_part") ).value + frictionOverrideSlider = ( + eventArgs.command.commandInputs.itemById("advanced_settings") + .children.itemById("physics_settings") + .children.itemById("friction_override_coeff") + ) + + frictionOverride = frictionOverrideSlider.isVisible + frictionOverrideCoeff = frictionOverrideSlider.valueOne + exporterOptions = ExporterOptions( savepath, name, @@ -893,6 +902,8 @@ def notify(self, args): exportLocation=_location, compressOutput=compress, exportAsPart=export_as_part_boolean, + frictionOverride=frictionOverride, + frictionOverrideCoeff=frictionOverrideCoeff ) Parser(exporterOptions).export() From 78fab850072111ed80302edda082b37bca7bbe99 Mon Sep 17 00:00:00 2001 From: BrandonPacewic Date: Thu, 25 Jul 2024 13:33:36 -0700 Subject: [PATCH 19/21] Fixed bug with fusion material overrides Co-authored-by: azaleacolburn --- .../src/Parser/SynthesisParser/Materials.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 00ef48f315..07b9da188f 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -63,9 +63,9 @@ def setDefaultMaterial(physical_material: material_pb2.PhysicalMaterial, options else: physical_material.dynamic_friction = 0.5 physical_material.static_friction = 0.5 + physical_material.restitution = 0.5 physical_material.deformable = False - physical_material.matType = 0 @@ -99,10 +99,6 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): proto_material.static_friction = static_friction_coeffs.get(fusion_material.name, 0.5) proto_material.restitution = 0.5 - proto_material.dynamic_friction = 0.5 - proto_material.static_friction = 0.5 - proto_material.restitution = 0.5 - proto_material.description = f"{fusion_material.name} exported from FUSION" """ From 8c9bb18ebf8b44dd7d5ce2605acb40d4a3cb85dc Mon Sep 17 00:00:00 2001 From: BrandonPacewic Date: Thu, 25 Jul 2024 13:45:00 -0700 Subject: [PATCH 20/21] General cleanups --- .../src/Parser/SynthesisParser/Materials.py | 12 ++++-------- fission/src/mirabuf/MirabufParser.ts | 2 ++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 87c37bfb91..97d8d47f57 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -17,7 +17,7 @@ OPACITY_RAMPING_CONSTANT = 14.0 # Update tables as needed for UX and needed materials -static_friction_coeffs = { +STATIC_FRICTION_COEFFS = { "Aluminum": 1.1, "Steel, Cast": 0.75, "Steel, Mild": 0.75, @@ -25,7 +25,7 @@ "ABS Plastic": 0.7, } -dynamic_friction_coeffs = { +DYNAMIC_FRICTION_COEFFS = { "Aluminum": 1.1, "Steel, Cast": 0.75, "Steel, Mild": 0.75, @@ -40,11 +40,9 @@ def _MapAllPhysicalMaterials( options: ExporterOptions, progressDialog: PDMessage, ) -> None: - logging.getLogger(INTERNAL_ID).info("In Materials") setDefaultMaterial(materials.physicalMaterials["default"], options) for material in physicalMaterials: - progressDialog.addMaterial(material.name) if progressDialog.wasCancelled(): @@ -79,8 +77,6 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): proto_material (protomaterial): proto material mirabuf options (parseoptions): parse options """ - string: str = "" - construct_info("", proto_material, fus_object=fusion_material) proto_material.deformable = False @@ -96,8 +92,8 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): proto_material.dynamic_friction = options.frictionOverrideCoeff proto_material.static_friction = options.frictionOverrideCoeff else: - proto_material.dynamic_friction = dynamic_friction_coeffs.get(fusion_material.name, 0.5) - proto_material.static_friction = static_friction_coeffs.get(fusion_material.name, 0.5) + proto_material.dynamic_friction = DYNAMIC_FRICTION_COEFFS.get(fusion_material.name, 0.5) + proto_material.static_friction = STATIC_FRICTION_COEFFS.get(fusion_material.name, 0.5) proto_material.restitution = 0.5 proto_material.description = f"{fusion_material.name} exported from FUSION" diff --git a/fission/src/mirabuf/MirabufParser.ts b/fission/src/mirabuf/MirabufParser.ts index 1be47bbe0a..b36a736e97 100644 --- a/fission/src/mirabuf/MirabufParser.ts +++ b/fission/src/mirabuf/MirabufParser.ts @@ -2,6 +2,7 @@ import * as THREE from "three" import { mirabuf } from "@/proto/mirabuf" import { MirabufTransform_ThreeMatrix4 } from "@/util/TypeConversions" import { ProgressHandle } from "@/ui/components/ProgressNotificationData" +import { transcode } from "buffer" export type RigidNodeId = string @@ -233,6 +234,7 @@ class MirabufParser { } this._directedGraph = directedGraph + // Transition: GH-1014 const partDefinitions: { [k: string]: mirabuf.IPartDefinition } | null | undefined = this.assembly.data?.parts?.partDefinitions if (!partDefinitions) { From b32c9f5896806a2543f6ba01c000fc05ac72e4e6 Mon Sep 17 00:00:00 2001 From: BrandonPacewic Date: Thu, 25 Jul 2024 13:45:59 -0700 Subject: [PATCH 21/21] Did not mean to add this --- fission/src/mirabuf/MirabufParser.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/fission/src/mirabuf/MirabufParser.ts b/fission/src/mirabuf/MirabufParser.ts index b36a736e97..dd7df1e7cf 100644 --- a/fission/src/mirabuf/MirabufParser.ts +++ b/fission/src/mirabuf/MirabufParser.ts @@ -2,7 +2,6 @@ import * as THREE from "three" import { mirabuf } from "@/proto/mirabuf" import { MirabufTransform_ThreeMatrix4 } from "@/util/TypeConversions" import { ProgressHandle } from "@/ui/components/ProgressNotificationData" -import { transcode } from "buffer" export type RigidNodeId = string