Skip to content

Commit 13ce5e6

Browse files
authored
Merge branch 'dev' into aries/1896/scoreboard-ui
2 parents d41dd4e + a7a4a35 commit 13ce5e6

File tree

7 files changed

+100
-18
lines changed

7 files changed

+100
-18
lines changed

exporter/SynthesisFusionAddin/src/ErrorHandling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def handle_err_top(func: Callable[..., Result[None]]) -> Callable[..., None]:
129129

130130
def wrapper(*args, **kwargs): # type: ignore
131131
result = func(*args, **kwargs)
132+
132133
if result.is_err():
133134
message, severity = result.unwrap_err()
134135
if severity == ErrorSeverity.Fatal:

exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import enum
22
import sys
33
from logging import ERROR
4+
from os import error
45
from typing import Any, Iterator, cast
56

67
import adsk.core
@@ -221,10 +222,10 @@ def __init__(self, design: adsk.fusion.Design) -> None:
221222
self.grounded = searchForGrounded(design.rootComponent)
222223

223224
if self.grounded is None:
224-
message = "These is no grounded component in this assembly, aborting kinematic export."
225-
gm.ui.messageBox(message)
225+
message = "There is not a pinned component in this assembly, aborting kinematic export."
226+
# gm.ui.messageBox(message)
226227
_____: Err[None] = Err(message, ErrorSeverity.Fatal)
227-
raise RuntimeError()
228+
raise RuntimeError(message)
228229

229230
self.currentTraversal: dict[str, DynamicOccurrenceNode | bool] = dict()
230231
self.groundedConnections: list[adsk.fusion.Occurrence] = []
@@ -247,7 +248,7 @@ def __init__(self, design: adsk.fusion.Design) -> None:
247248
message = populate_node_result.unwrap_err()[0]
248249
gm.ui.messageBox(message)
249250
____: Err[None] = Err(message, ErrorSeverity.Fatal)
250-
raise RuntimeError()
251+
raise RuntimeError(message)
251252

252253
rootNode = populate_node_result.unwrap()
253254
self.groundSimNode = SimulationNode(rootNode, None, grounded=True)
@@ -522,12 +523,9 @@ def buildJointPartHierarchy(
522523

523524
return Ok(None)
524525

525-
# I'm fairly certain bubbling this back up is the way to go
526-
except Warning:
527-
return Err(
528-
"Instantiation of the JointParser failed, likely due to a lack of a grounded component in the assembly",
529-
ErrorSeverity.Fatal,
530-
)
526+
except RuntimeError as e:
527+
progressDialog.progressDialog.hide()
528+
raise e
531529

532530

533531
def populateJoint(simNode: SimulationNode, joints: joint_pb2.Joints, progressDialog: PDMessage) -> Result[None]:

exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ def export(self) -> None:
148148
self.pdMessage,
149149
)
150150

151-
JointHierarchy.buildJointPartHierarchy(design, assembly_out.data.joints, self.exporterOptions, self.pdMessage)
151+
try:
152+
JointHierarchy.buildJointPartHierarchy(
153+
design, assembly_out.data.joints, self.exporterOptions, self.pdMessage
154+
)
155+
except RuntimeError as e:
156+
raise e
152157

153158
# These don't have an effect, I forgot how this is suppose to work
154159
# progressDialog.message = "Taking Photo for thumbnail..."

exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ def notify(self, html_args: adsk.core.HTMLEventArgs) -> None:
247247
)
248248
elif html_args.action == "export":
249249
opts = moduleExporterOptions.ExporterOptions().readFromJSON(data)
250-
export(opts)
251-
html_args.returnData = "{}"
250+
export(opts, html_args)
252251
elif html_args.action == "save":
253252
opts = moduleExporterOptions.ExporterOptions().readFromJSON(data)
254253
opts.writeToDesign()
@@ -336,7 +335,7 @@ def addChildOccurrences(childOccurrences: adsk.fusion.OccurrenceList) -> None:
336335

337336

338337
@logFailure(messageBox=True)
339-
def export(exporterOptions: moduleExporterOptions.ExporterOptions) -> None:
338+
def export(exporterOptions: moduleExporterOptions.ExporterOptions, html_args: adsk.core.HTMLEventArgs) -> None:
340339
logger.info("NEWUI")
341340
logger.info(exporterOptions)
342341
design = adsk.fusion.Design.cast(adsk.core.Application.get().activeProduct)
@@ -361,8 +360,13 @@ def export(exporterOptions: moduleExporterOptions.ExporterOptions) -> None:
361360
exporterOptions.version = docVersion
362361
exporterOptions.materials = 0
363362

364-
Parser.Parser(exporterOptions).export()
363+
try:
364+
Parser.Parser(exporterOptions).export()
365+
except RuntimeError as e:
366+
html_args.returnData = json.dumps({"_err": str(e)})
367+
return
365368
exporterOptions.writeToDesign()
369+
html_args.returnData = "{}"
366370

367371
if exporterOptions.openSynthesisUponExport:
368372
res = webbrowser.open(APP_WEBSITE_URL)
@@ -431,7 +435,10 @@ def notify(self, _: adsk.core.CommandEventArgs) -> None:
431435
try:
432436
Parser.Parser(exporterOptions).export()
433437
except:
434-
pass
438+
jointConfigTab.reset()
439+
gamepieceConfigTab.reset()
440+
441+
return
435442
exporterOptions.writeToDesign()
436443
jointConfigTab.reset()
437444
gamepieceConfigTab.reset()

exporter/SynthesisFusionAddin/web/src/lib/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ const errorMatchers: { text: string; cb: () => void }[] = [
4040
Global_SetAlert("info", "Selection cancelled")
4141
},
4242
},
43+
{
44+
text: "not a pinned",
45+
cb: () => {
46+
Global_SetAlert("error", "Please pin a component to export the assembly")
47+
},
48+
},
4349
]
4450

4551
export async function sendData<A extends keyof Messages>(
@@ -64,9 +70,10 @@ export async function sendData<A extends keyof Messages>(
6470
})
6571
if (!wasHandled) {
6672
console.error({ action, errorResponse: parsed._err })
73+
return undefined
6774
}
6875

69-
return undefined
76+
return parsed as Messages[A][1] & { _err: string }
7077
}
7178
return parsed as Messages[A][1]
7279
} catch (error) {
@@ -85,9 +92,12 @@ export async function sendDataAndToast<A extends keyof Messages>(
8592

8693
if (resp === undefined) {
8794
Global_SetAlert("error", failureMsg)
88-
} else {
95+
} else if (resp._err === undefined) {
8996
Global_SetAlert("info", sucessMsg)
97+
} else {
98+
return undefined
9099
}
100+
91101
return resp
92102
}
93103

fission/flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fission/flake.nix

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
description = "Synthesis' Web-Based Robotics Simulator";
3+
4+
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
5+
6+
outputs =
7+
inputs:
8+
let
9+
supportedSystems = [
10+
"x86_64-linux"
11+
"aarch64-linux"
12+
"x86_64-darwin"
13+
"aarch64-darwin"
14+
];
15+
forEachSupportedSystem =
16+
f: inputs.nixpkgs.lib.genAttrs supportedSystems (system: f inputs.nixpkgs.legacyPackages.${system});
17+
in
18+
{
19+
devShells = forEachSupportedSystem (pkgs: {
20+
default = pkgs.mkShell {
21+
nativeBuildInputs = with pkgs; [
22+
playwright-driver.browsers
23+
];
24+
25+
env = {
26+
PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers;
27+
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true;
28+
};
29+
};
30+
});
31+
32+
formatter = forEachSupportedSystem (pkgs: pkgs.nixfmt-tree);
33+
};
34+
}

0 commit comments

Comments
 (0)