Skip to content

Commit d624169

Browse files
Merge dev
* dev: (31 commits) fix: remove comments and fix indentation fix: make format command apply import sorting fix: format fix: remove bad comments refactor: make SelectButton its own component fix: useful readme chore: switch webui to bun chore: run black chore: update git configuration feat: transition to biome instead of eslint and prettier feat: indicate clearly when selection is active fix: load default joints correctly feat: potentially support multiple gamepieces at once fix: use builtin list type chore: format and fix builds Delete exporter/SynthesisFusionAddin/web/src/assets/react.svg feat: transfer material tagging ui chore(ci): cache node dependencies in webui CI workflow fix: remove bad import fix: remove bun lock ...
2 parents cf81416 + dd25423 commit d624169

33 files changed

+3120
-81
lines changed

.github/workflows/FusionWebUI.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Fusion - WebUI Build and Format
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
push:
7+
branches: [ prod, dev ]
8+
paths:
9+
- 'exporter/SynthesisFusionAddin/web/**'
10+
pull_request:
11+
branches: [ prod, dev ]
12+
paths:
13+
- 'exporter/SynthesisFusionAddin/web/**'
14+
15+
16+
jobs:
17+
runFormatValidationScript:
18+
defaults:
19+
run:
20+
working-directory: exporter/SynthesisFusionAddin/web
21+
name: Biome Format Validation
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout Code
25+
uses: actions/checkout@v4
26+
- name: Bun Runtime Setup
27+
uses: oven-sh/setup-bun@v2
28+
with:
29+
bun-version: latest
30+
- name: Cache Node Dependencies
31+
uses: actions/cache@v3
32+
with:
33+
key: "${{runner.os}}-npm-fusion-${{hashFiles('exporter/SynthesisFusionAddin/web/bun.lock')}}"
34+
path: 'exporter/SynthesisFusionAddin/web/node_modules'
35+
restore-keys: |
36+
${{runner.os}}-npm-fusion-
37+
${{runner.os}}-npm
38+
39+
- name: Install Dependencies
40+
run: bun install --frozen-lockfile
41+
42+
- name: Linter & Formatter
43+
run: |
44+
bunx biome --version
45+
bunx biome ci --error-on-warnings
46+
47+
runBuildScript:
48+
name: Build
49+
runs-on: ubuntu-latest
50+
defaults:
51+
run:
52+
working-directory: exporter/SynthesisFusionAddin/web
53+
steps:
54+
- name: Checkout Code
55+
uses: actions/checkout@v4
56+
- name: Bun Runtime Setup
57+
uses: oven-sh/setup-bun@v2
58+
with:
59+
bun-version: latest
60+
- name: Cache Node Dependencies
61+
uses: actions/cache@v3
62+
with:
63+
key: "${{runner.os}}-npm-fusion-${{hashFiles('exporter/SynthesisFusionAddin/web/bun.lock')}}"
64+
path: 'exporter/SynthesisFusionAddin/web/node_modules'
65+
restore-keys: |
66+
${{runner.os}}-npm-fusion-
67+
${{runner.os}}-npm
68+
69+
- name: Install Dependencies
70+
run: bun install --frozen-lockfile
71+
72+
- name: Build
73+
run: bun run build

exporter/SynthesisFusionAddin/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,6 @@ site-packages
110110
proto/proto_out
111111

112112
.aps_auth
113+
114+
115+
src/Resources/**/*.png

exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import os
88
import platform
99
from dataclasses import dataclass, field, fields
10+
from typing import Any
1011

1112
import adsk.core
1213
from adsk.fusion import CalculationAccuracy, TriangleMeshQualityOptions
1314

1415
from src import INTERNAL_ID
15-
from src.Logging import logFailure, timed
16+
from src.Logging import getLogger, logFailure, timed
1617
from src.Types import (
1718
KG,
1819
ExportLocation,
@@ -68,7 +69,19 @@ def readFromDesign(self) -> "ExporterOptions":
6869
for field in fields(self):
6970
attribute = designAttributes.itemByName(INTERNAL_ID, field.name)
7071
if attribute:
71-
attrJsonData = makeObjectFromJson(type(field.type), json.loads(attribute.value))
72+
attrJsonData = makeObjectFromJson(field.type, json.loads(attribute.value))
73+
setattr(self, field.name, attrJsonData)
74+
75+
self.visualQuality = TriangleMeshQualityOptions.LowQualityTriangleMesh
76+
return self
77+
78+
@logFailure
79+
@timed
80+
def readFromJSON(self, data: dict[str, Any]) -> "ExporterOptions":
81+
for field in fields(self):
82+
attribute = data.get(field.name)
83+
if attribute is not None:
84+
attrJsonData = makeObjectFromJson(field.type, attribute)
7285
setattr(self, field.name, attrJsonData)
7386

7487
self.visualQuality = TriangleMeshQualityOptions.LowQualityTriangleMesh
@@ -81,3 +94,12 @@ def writeToDesign(self) -> None:
8194
for field in fields(self):
8295
data = json.dumps(getattr(self, field.name), default=encodeNestedObjects, indent=4)
8396
designAttributes.add(INTERNAL_ID, field.name, data)
97+
98+
@logFailure
99+
@timed
100+
def writeToJson(self) -> dict[str, Any]:
101+
out = {}
102+
for field in fields(self):
103+
data = json.dumps(getattr(self, field.name), default=encodeNestedObjects, indent=4)
104+
out[field.name] = json.loads(data)
105+
return out

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(self, options: ExporterOptions):
4545

4646
@timed
4747
def export(self) -> None:
48+
getLogger().info(f"Exporting with options {self.exporterOptions}")
4849
app = adsk.core.Application.get()
4950
design: adsk.fusion.Design = app.activeDocument.design
5051

exporter/SynthesisFusionAddin/src/Types.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,19 @@ def encodeNestedObjects(obj: Any) -> Any:
104104
return obj
105105

106106

107-
def makeObjectFromJson(objType: type, data: Any) -> Any:
107+
# This function was previously taking type(field.type) instead of just field.type, but it didn't seem to be able to deal with lists like that, and this version does seem to be working in all the places where it's used
108+
def makeObjectFromJson(objType: type[Any] | str | Any, data: Any) -> Any:
108109
if isinstance(objType, EnumType):
109110
return objType(data)
110-
elif isinstance(objType, PRIMITIVES) or isinstance(data, PRIMITIVES):
111+
elif isinstance(objType, PRIMITIVES) or isinstance(data, PRIMITIVES) or get_origin(objType) is dict:
111112
return data
112113
elif get_origin(objType) is list:
113114
return [makeObjectFromJson(get_args(objType)[0], item) for item in data]
114-
115115
obj = objType()
116-
assert is_dataclass(obj) and isinstance(data, dict), "Found unsupported type to decode."
116+
assert is_dataclass(obj) and isinstance(data, dict), f"Found unsupported type to decode. {objType} {data}"
117117
for field in fields(obj):
118118
if field.name in data:
119-
setattr(obj, field.name, makeObjectFromJson(type(field.type), data[field.name]))
119+
setattr(obj, field.name, makeObjectFromJson(field.type, data[field.name]))
120120
else:
121121
setattr(obj, field.name, field.default_factory if field.default_factory is not MISSING else field.default)
122122

0 commit comments

Comments
 (0)