Skip to content

Commit 9de49d7

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dhruv/1694/shadow-cascades
2 parents 1fdb767 + 3a20e92 commit 9de49d7

File tree

83 files changed

+2667
-1530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2667
-1530
lines changed

.github/workflows/FissionUnitTest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
with:
4545
path: |
4646
~/.cache/ms-playwright/
47-
key: ${{ runner.os }}-assets-playwright-${{ env.PLAYWRIGHT_VERSION }}
47+
key: ${{ runner.os }}-assets-playwright-${{ env.PLAYWRIGHT_VERSION }}-v2
4848

4949
- name: Install Dependencies
5050
run: |

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "mirabuf"]
22
path = mirabuf
33
url = https://github.com/HiceS/mirabuf.git
4+
[submodule "jolt"]
5+
path = jolt
6+
url = https://github.com/HunterBarclay/JoltPhysics.js.git

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ All code is under a configured formatting utility. See each component for more d
6060

6161
Mirabuf is a file format we use to store physical data from Fusion to load into the Synthesis simulator (Fission). This is a separate project that is a submodule of Synthesis. [See Mirabuf](https://github.com/HiceS/mirabuf/)
6262

63+
### Jolt Physics
64+
65+
Jolt is the core physics engine for our web biased simulator. [See JoltPhysics.js](https://github.com/HunterBarclay/JoltPhysics.js) for more information.
66+
6367
### Tutorials
6468

6569
Our source code for the tutorials featured on our [Tutorials Page](https://synthesis.autodesk.com/tutorials.html).

exporter/SynthesisFusionAddin/Synthesis.py

+29-39
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,45 @@
33

44
import adsk.core
55

6-
# Currently required for `resolveDependencies()`, will be required for absolute imports.
6+
# Required for absolute imports.
77
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
8+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "proto", "proto_out")))
89

9-
from .src.Dependencies import resolveDependencies # isort:skip
10+
from src.Dependencies import resolveDependencies
11+
from src.Logging import logFailure, setupLogger
1012

11-
# Transition: AARD-1741
12-
# Import order should be removed in AARD-1737 and `setupLogger()` moved to `__init__.py`
13-
from .src.Logging import getLogger, logFailure, setupLogger # isort:skip
14-
15-
setupLogger()
13+
logger = setupLogger()
1614

1715
try:
18-
from .src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm
19-
from .src.UI import (
20-
HUI,
21-
Camera,
22-
ConfigCommand,
23-
MarkingMenu,
24-
ShowAPSAuthCommand,
25-
ShowWebsiteCommand,
16+
# Attempt to import required pip dependencies to verify their installation.
17+
import requests
18+
from proto.proto_out import (
19+
assembly_pb2,
20+
joint_pb2,
21+
material_pb2,
22+
motor_pb2,
23+
signal_pb2,
24+
types_pb2,
2625
)
27-
from .src.UI.Toolbar import Toolbar
28-
except (ImportError, ModuleNotFoundError) as error:
29-
getLogger().warn(f"Running resolve dependencies with error of:\n{error}")
26+
except (ImportError, ModuleNotFoundError, BaseException) as error: # BaseException required to catch proto.VersionError
27+
logger.warn(f"Running resolve dependencies with error of:\n{error}")
3028
result = resolveDependencies()
3129
if result:
3230
adsk.core.Application.get().userInterface.messageBox("Installed required dependencies.\nPlease restart Fusion.")
3331

3432

33+
from src import APP_NAME, DESCRIPTION, INTERNAL_ID, gm
34+
from src.UI import (
35+
HUI,
36+
Camera,
37+
ConfigCommand,
38+
MarkingMenu,
39+
ShowAPSAuthCommand,
40+
ShowWebsiteCommand,
41+
)
42+
from src.UI.Toolbar import Toolbar
43+
44+
3545
@logFailure
3646
def run(_):
3747
"""## Entry point to application from Fusion.
@@ -68,28 +78,8 @@ def stop(_):
6878

6979
# nm.deleteMe()
7080

71-
logger = getLogger(INTERNAL_ID)
7281
logger.cleanupHandlers()
73-
74-
for file in gm.files:
75-
try:
76-
os.remove(file)
77-
except OSError:
78-
pass
79-
80-
# removes path so that proto files don't get confused
81-
82-
import sys
83-
84-
path = os.path.abspath(os.path.dirname(__file__))
85-
86-
path_proto_files = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out"))
87-
88-
if path in sys.path:
89-
sys.path.remove(path)
90-
91-
if path_proto_files in sys.path:
92-
sys.path.remove(path_proto_files)
82+
gm.clear()
9383

9484

9585
@logFailure

exporter/SynthesisFusionAddin/src/APS/APS.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
import requests
1212

13-
from ..general_imports import INTERNAL_ID, gm, my_addin_path
14-
from ..Logging import getLogger
13+
from src import ADDIN_PATH, gm
14+
from src.Logging import getLogger
1515

1616
logger = getLogger()
1717

1818
CLIENT_ID = "GCxaewcLjsYlK8ud7Ka9AKf9dPwMR3e4GlybyfhAK2zvl3tU"
19-
auth_path = os.path.abspath(os.path.join(my_addin_path, "..", ".aps_auth"))
19+
auth_path = os.path.abspath(os.path.join(ADDIN_PATH, "..", ".aps_auth"))
2020

2121
APS_AUTH = None
2222
APS_USER_INFO = None

exporter/SynthesisFusionAddin/src/Dependencies.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import importlib.machinery
22
import importlib.util
33
import os
4-
import platform
54
import subprocess
65
import sys
76
from pathlib import Path
87

98
import adsk.core
109
import adsk.fusion
1110

12-
from .Logging import getLogger, logFailure
11+
from src import SYSTEM
12+
from src.Logging import getLogger, logFailure
1313

1414
logger = getLogger()
15-
system = platform.system()
1615

1716
# Since the Fusion python runtime is separate from the system python runtime we need to do some funky things
1817
# in order to download and install python packages separate from the standard library.
@@ -29,13 +28,11 @@ def getInternalFusionPythonInstillationFolder() -> str:
2928
pythonStandardLibraryModulePath = importlib.machinery.PathFinder.find_spec("os", sys.path).origin
3029

3130
# Depending on platform, adjust to folder to where the python executable binaries are stored.
32-
if system == "Windows":
31+
if SYSTEM == "Windows":
3332
folder = f"{Path(pythonStandardLibraryModulePath).parents[1]}"
34-
elif system == "Darwin":
35-
folder = f"{Path(pythonStandardLibraryModulePath).parents[2]}/bin"
3633
else:
37-
# TODO: System string should be moved to __init__ after GH-1013
38-
raise RuntimeError("Unsupported platform.")
34+
assert SYSTEM == "Darwin"
35+
folder = f"{Path(pythonStandardLibraryModulePath).parents[2]}/bin"
3936

4037
return folder
4138

@@ -100,7 +97,7 @@ def resolveDependencies() -> bool | None:
10097
adsk.doEvents()
10198

10299
pythonFolder = getInternalFusionPythonInstillationFolder()
103-
pythonExecutableFile = "python.exe" if system == "Windows" else "python" # Confirming 110% everything is fine.
100+
pythonExecutableFile = "python.exe" if SYSTEM == "Windows" else "python" # Confirming 110% everything is fine.
104101
pythonExecutablePath = os.path.join(pythonFolder, pythonExecutableFile)
105102

106103
progressBar = ui.createProgressDialog()
@@ -109,7 +106,7 @@ def resolveDependencies() -> bool | None:
109106
progressBar.show("Synthesis", f"Installing dependencies...", 0, len(PIP_DEPENDENCY_VERSION_MAP) * 2 + 2, 0)
110107

111108
# Install pip manually on macos as it is not included by default? Really?
112-
if system == "Darwin" and not os.path.exists(os.path.join(pythonFolder, "pip")):
109+
if SYSTEM == "Darwin" and not os.path.exists(os.path.join(pythonFolder, "pip")):
113110
pipInstallScriptPath = os.path.join(pythonFolder, "get-pip.py")
114111
if not os.path.exists(pipInstallScriptPath):
115112
executeCommand("curl", "https://bootstrap.pypa.io/get-pip.py", "-o", pipInstallScriptPath)

exporter/SynthesisFusionAddin/src/GlobalManager.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
""" Initializes the global variables that are set in the run method to reduce hanging commands. """
22

3-
import logging
4-
53
import adsk.core
64
import adsk.fusion
75

8-
from .general_imports import *
9-
from .strings import *
10-
116

127
class GlobalManager(object):
138
"""Global Manager instance"""
@@ -47,6 +42,11 @@ def __init__(self):
4742
def __str__(self):
4843
return "GlobalManager"
4944

45+
def clear(self):
46+
for attr, value in self.__dict__.items():
47+
if isinstance(value, list):
48+
setattr(self, attr, [])
49+
5050
instance = None
5151

5252
def __new__(cls):

exporter/SynthesisFusionAddin/src/Logging.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
import adsk.core
1313

14-
from .strings import INTERNAL_ID
15-
from .UI.OsHelper import getOSPath
14+
from src import INTERNAL_ID
15+
from src.UI.OsHelper import getOSPath
1616

1717
MAX_LOG_FILES_TO_KEEP = 10
1818
TIMING_LEVEL = 25
@@ -27,7 +27,7 @@ def cleanupHandlers(self) -> None:
2727
handler.close()
2828

2929

30-
def setupLogger() -> None:
30+
def setupLogger() -> SynthesisLogger:
3131
now = datetime.now().strftime("%H-%M-%S")
3232
today = date.today()
3333
logFileFolder = getOSPath(f"{pathlib.Path(__file__).parent.parent}", "logs")
@@ -46,6 +46,7 @@ def setupLogger() -> None:
4646
logger = getLogger(INTERNAL_ID)
4747
logger.setLevel(10) # Debug
4848
logger.addHandler(logHandler)
49+
return cast(SynthesisLogger, logger)
4950

5051

5152
def getLogger(name: str | None = None) -> SynthesisLogger:

exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import adsk.core
1212
from adsk.fusion import CalculationAccuracy, TriangleMeshQualityOptions
1313

14-
from ..Logging import logFailure, timed
15-
from ..strings import INTERNAL_ID
16-
from ..Types import (
14+
from src import INTERNAL_ID
15+
from src.Logging import logFailure, timed
16+
from src.Types import (
1717
KG,
1818
ExportLocation,
1919
ExportMode,

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

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# Contains all of the logic for mapping the Components / Occurrences
2-
import logging
3-
import traceback
4-
import uuid
5-
from typing import *
6-
72
import adsk.core
83
import adsk.fusion
9-
104
from proto.proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2
115

12-
from ...Logging import logFailure, timed
13-
from ...Types import ExportMode
14-
from ..ExporterOptions import ExporterOptions
15-
from . import PhysicalProperties
16-
from .PDMessage import PDMessage
17-
from .Utilities import *
6+
from src.Logging import logFailure
7+
from src.Parser.ExporterOptions import ExporterOptions
8+
from src.Parser.SynthesisParser import PhysicalProperties
9+
from src.Parser.SynthesisParser.PDMessage import PDMessage
10+
from src.Parser.SynthesisParser.Utilities import (
11+
fill_info,
12+
guid_component,
13+
guid_occurrence,
14+
)
15+
from src.Types import ExportMode
1816

1917
# TODO: Impelement Material overrides
2018

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

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import enum
2-
import logging
3-
import traceback
4-
from typing import *
2+
from typing import Union
53

64
import adsk.core
75
import adsk.fusion
8-
96
from proto.proto_out import joint_pb2, types_pb2
107

11-
from ...general_imports import *
12-
from ...Logging import getLogger, logFailure
13-
from ..ExporterOptions import ExporterOptions
14-
from .PDMessage import PDMessage
15-
from .Utilities import guid_component, guid_occurrence
8+
from src import gm
9+
from src.Logging import getLogger, logFailure
10+
from src.Parser.ExporterOptions import ExporterOptions
11+
from src.Parser.SynthesisParser.PDMessage import PDMessage
12+
from src.Parser.SynthesisParser.Utilities import guid_component, guid_occurrence
1613

1714
logger = getLogger()
1815

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

+11-9
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@
2828

2929
import adsk.core
3030
import adsk.fusion
31-
32-
from proto.proto_out import assembly_pb2, joint_pb2, motor_pb2, signal_pb2, types_pb2
33-
34-
from ...general_imports import *
35-
from ...Logging import getLogger
36-
from ...Types import JointParentType, SignalType
37-
from ..ExporterOptions import ExporterOptions
38-
from .PDMessage import PDMessage
39-
from .Utilities import construct_info, fill_info, guid_occurrence
31+
from proto.proto_out import assembly_pb2, joint_pb2, signal_pb2, types_pb2
32+
33+
from src.Logging import getLogger
34+
from src.Parser.ExporterOptions import ExporterOptions
35+
from src.Parser.SynthesisParser.PDMessage import PDMessage
36+
from src.Parser.SynthesisParser.Utilities import (
37+
construct_info,
38+
fill_info,
39+
guid_occurrence,
40+
)
41+
from src.Types import JointParentType, SignalType
4042

4143
logger = getLogger()
4244

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

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
# Should contain Physical and Apperance materials ?
2-
import json
3-
import logging
4-
import math
5-
import traceback
6-
71
import adsk
8-
92
from proto.proto_out import material_pb2
103

11-
from ...general_imports import *
12-
from ...Logging import logFailure, timed
13-
from ..ExporterOptions import ExporterOptions
14-
from .PDMessage import PDMessage
15-
from .Utilities import *
4+
from src.Logging import logFailure
5+
from src.Parser.ExporterOptions import ExporterOptions
6+
from src.Parser.SynthesisParser.PDMessage import PDMessage
7+
from src.Parser.SynthesisParser.Utilities import construct_info, fill_info
168

179
OPACITY_RAMPING_CONSTANT = 14.0
1810

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

+14-9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@
44
import adsk.core
55
import adsk.fusion
66
from google.protobuf.json_format import MessageToJson
7-
87
from proto.proto_out import assembly_pb2, types_pb2
98

10-
from ...APS.APS import getAuth, upload_mirabuf
11-
from ...general_imports import *
12-
from ...Logging import getLogger, logFailure, timed
13-
from ...Types import ExportLocation, ExportMode
14-
from ...UI.Camera import captureThumbnail, clearIconCache
15-
from ..ExporterOptions import ExporterOptions
16-
from . import Components, JointHierarchy, Joints, Materials, PDMessage
17-
from .Utilities import *
9+
from src import gm
10+
from src.APS.APS import getAuth, upload_mirabuf
11+
from src.Logging import getLogger, logFailure, timed
12+
from src.Parser.ExporterOptions import ExporterOptions
13+
from src.Parser.SynthesisParser import (
14+
Components,
15+
JointHierarchy,
16+
Joints,
17+
Materials,
18+
PDMessage,
19+
)
20+
from src.Parser.SynthesisParser.Utilities import fill_info
21+
from src.Types import ExportLocation, ExportMode
22+
from src.UI.Camera import captureThumbnail, clearIconCache
1823

1924
logger = getLogger()
2025

0 commit comments

Comments
 (0)