From f0a971069241868cbcdab8120d8c71dc9e29f535 Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:21:51 -0700 Subject: [PATCH] Added open Synthesis on export option --- .../src/Parser/ExporterOptions.py | 1 + .../SynthesisFusionAddin/src/UI/ConfigCommand.py | 9 ++++++++- .../src/UI/GeneralConfigTab.py | 15 +++++++++++++++ exporter/SynthesisFusionAddin/src/__init__.py | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index 69e9bbef5..8f4375a19 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -57,6 +57,7 @@ class ExporterOptions: exportAsPart: bool = field(default=False) exportLocation: ExportLocation = field(default=ExportLocation.UPLOAD) + openSynthesisUponExport: bool = field(default=False) hierarchy: ModelHierarchy = field(default=ModelHierarchy.FusionAssembly) visualQuality: TriangleMeshQualityOptions = field(default=TriangleMeshQualityOptions.LowQualityTriangleMesh) diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index c50c7feed..56115cd1a 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -4,12 +4,13 @@ import os import pathlib +import webbrowser from enum import Enum import adsk.core import adsk.fusion -from src import gm +from src import APP_WEBSITE_URL, gm from src.APS.APS import getAuth, getUserInfo from src.Logging import getLogger, logFailure from src.Parser.ExporterOptions import ExporterOptions @@ -343,6 +344,7 @@ def notify(self, args): exportAsPart=generalConfigTab.exportAsPart, frictionOverride=generalConfigTab.overrideFriction, frictionOverrideCoeff=generalConfigTab.frictionOverrideCoeff, + openSynthesisUponExport=generalConfigTab.openSynthesisUponExport, ) Parser(exporterOptions).export() @@ -354,6 +356,11 @@ def notify(self, args): jointConfigTab.reset() gamepieceConfigTab.reset() + if generalConfigTab.openSynthesisUponExport: + res = webbrowser.open(APP_WEBSITE_URL) + if not res: + gm.ui.messageBox("Failed to open Synthesis in your default browser.") + class CommandExecutePreviewHandler(adsk.core.CommandEventHandler): """### Gets an event that is fired when the command has completed gathering the required input and now needs to perform a preview. diff --git a/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py b/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py index 40a602a40..a0da16895 100644 --- a/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py +++ b/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py @@ -154,6 +154,14 @@ def __init__(self, args: adsk.core.CommandCreatedEventArgs, exporterOptions: Exp frictionCoefficient.tooltip = "Friction coefficients range from 0 (ice) to 1 (rubber)." frictionCoefficient.isVisible = exporterOptions.frictionOverride + createBooleanInput( + "openSynthesisOnExportButton", + "Open Synthesis on Export", + generalTabInputs, + checked=exporterOptions.openSynthesisUponExport, + tooltip="Launch the Synthesis website upon export.", + ) + if exporterOptions.exportMode == ExportMode.FIELD: autoCalcWeightButton.isVisible = False exportAsPartButton.isVisible = False @@ -232,6 +240,13 @@ def frictionOverrideCoeff(self) -> float: ) return frictionSlider.valueOne + @property + def openSynthesisUponExport(self) -> bool: + openSynthesisButton: adsk.core.BoolValueCommandInput = self.generalOptionsTab.children.itemById( + "openSynthesisOnExportButton" + ) + return openSynthesisButton.value or False + @logFailure def handleInputChanged(self, args: adsk.core.InputChangedEventArgs) -> None: commandInput = args.input diff --git a/exporter/SynthesisFusionAddin/src/__init__.py b/exporter/SynthesisFusionAddin/src/__init__.py index 1e426279b..6ba62d214 100644 --- a/exporter/SynthesisFusionAddin/src/__init__.py +++ b/exporter/SynthesisFusionAddin/src/__init__.py @@ -5,6 +5,7 @@ APP_NAME = "Synthesis" APP_TITLE = "Synthesis Robot Exporter" +APP_WEBSITE_URL = "https://synthesis.autodesk.com/fission/" DESCRIPTION = "Exports files from Fusion into the Synthesis Format" INTERNAL_ID = "Synthesis" ADDIN_PATH = os.path.dirname(os.path.realpath(__file__))