Skip to content

Commit

Permalink
Open Synthesis Upon Export [AARD-1772] (#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Aug 24, 2024
2 parents a1b9e7a + 9869129 commit 43f9225
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,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)
Expand Down
9 changes: 8 additions & 1 deletion exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

import os
import pathlib
import webbrowser
from enum import Enum
from typing import Any

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
Expand Down Expand Up @@ -348,6 +349,7 @@ def notify(self, args: adsk.core.CommandEventArgs) -> None:
exportAsPart=generalConfigTab.exportAsPart,
frictionOverride=generalConfigTab.overrideFriction,
frictionOverrideCoeff=generalConfigTab.frictionOverrideCoeff,
openSynthesisUponExport=generalConfigTab.openSynthesisUponExport,
)

Parser(exporterOptions).export()
Expand All @@ -359,6 +361,11 @@ def notify(self, args: adsk.core.CommandEventArgs) -> None:
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.
Expand Down
15 changes: 15 additions & 0 deletions exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ def __init__(self, args: adsk.core.CommandCreatedEventArgs, exporterOptions: Exp
frictionCoefficient.tooltip = "<i>Friction coefficients range from 0 (ice) to 1 (rubber).</i>"
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
Expand Down Expand Up @@ -182,6 +190,13 @@ def frictionOverrideCoeff(self) -> float:
)
return frictionSlider.valueOne or -1.0

@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:
autoCalcWeightButton: adsk.core.BoolValueCommandInput = args.inputs.itemById("autoCalcWeightButton")
Expand Down
1 change: 1 addition & 0 deletions exporter/SynthesisFusionAddin/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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__))
Expand Down

0 comments on commit 43f9225

Please sign in to comment.