Skip to content

Commit

Permalink
Track Compiled Proto Files (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Aug 13, 2024
2 parents 770220d + faae787 commit 309c287
Show file tree
Hide file tree
Showing 19 changed files with 373 additions and 35 deletions.
17 changes: 8 additions & 9 deletions exporter/SynthesisFusionAddin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ We use `VSCode` Primarily, download it to interact with our code or use your own

### How to Build + Run

1. See root [`README`](/README.md) on how to run `init` script
2. Open `Autodesk Fusion`
3. Select `UTILITIES` from the top bar
4. Click `ADD-INS` Button
5. Click `Add-Ins` tab at the top of Scripts and Add-Ins dialog
6. Press + Button under **My Add-Ins**
7. Navigate to the containing folder for this Addin and click open at bottom - _clone-directory_/synthesis/exporters/SynthesisFusionAddin
8. Synthesis should be an option - select it and click run at the bottom of the dialog
9. There should now be a button that says Synthesis in your utilities menu
1. Open `Autodesk Fusion`
2. Select `UTILITIES` from the top bar
3. Click `ADD-INS` Button
4. Click `Add-Ins` tab at the top of Scripts and Add-Ins dialog
5. Press + Button under **My Add-Ins**
6. Navigate to the containing folder for this Addin and click open at bottom - _clone-directory_/synthesis/exporters/SynthesisFusionAddin
7. Synthesis should be an option - select it and click run at the bottom of the dialog
8. There should now be a button that says Synthesis in your utilities menu
- If there is no button there may be a problem - see below for [checking log file](#debug-non-start)

---
Expand Down
4 changes: 2 additions & 2 deletions exporter/SynthesisFusionAddin/Synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

# Required for absolute imports.
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "proto", "proto_out")))

from src.Dependencies import resolveDependencies
from src.Logging import logFailure, setupLogger
Expand All @@ -15,7 +14,8 @@
try:
# Attempt to import required pip dependencies to verify their installation.
import requests
from proto.proto_out import (

from src.Proto import (
assembly_pb2,
joint_pb2,
material_pb2,
Expand Down
2 changes: 2 additions & 0 deletions exporter/SynthesisFusionAddin/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ skip = [
".vscode/",
"/dist/",
"proto/proto_out",
"src/Proto",
]

[tool.black]
Expand All @@ -30,6 +31,7 @@ exclude = '''
| .vscode
| dist
| proto_out
| src/Proto
)/
)
'''
17 changes: 0 additions & 17 deletions exporter/SynthesisFusionAddin/src/Dependencies.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import importlib.machinery
import importlib.util
import os
import subprocess
import sys
Expand Down Expand Up @@ -52,18 +51,6 @@ def executeCommand(*args: str) -> subprocess.CompletedProcess:
raise error


@logFailure
def verifyCompiledProtoImports() -> bool:
protoModules = ["assembly_pb2", "joint_pb2", "material_pb2", "types_pb2"]
for module in protoModules:
# Absolute imports must be set up by this point for importlib to be able to find each module.
spec = importlib.util.find_spec(f"proto.proto_out.{module}")
if spec is None:
return False

return True


def getInstalledPipPackages(pythonExecutablePath: str) -> dict[str, str]:
result: str = executeCommand(pythonExecutablePath, "-m", "pip", "freeze").stdout
# We don't need to check against packages with a specific hash as those are not required by Synthesis.
Expand All @@ -83,10 +70,6 @@ def packagesOutOfDate(installedPackages: dict[str, str]) -> bool:
def resolveDependencies() -> bool | None:
app = adsk.core.Application.get()
ui = app.userInterface
if not verifyCompiledProtoImports():
ui.messageBox("Missing required compiled protobuf files.")
return False

if app.isOffLine:
# If we have gotten this far that means that an import error was thrown for possible missing
# dependencies... And we can't try to download them because we have no internet... ¯\_(ツ)_/¯
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Contains all of the logic for mapping the Components / Occurrences
import adsk.core
import adsk.fusion
from proto.proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2

from src.Logging import logFailure
from src.Parser.ExporterOptions import ExporterOptions
Expand All @@ -12,6 +11,7 @@
guid_component,
guid_occurrence,
)
from src.Proto import assembly_pb2, joint_pb2, material_pb2, types_pb2
from src.Types import ExportMode

# TODO: Impelement Material overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import adsk.core
import adsk.fusion
from proto.proto_out import joint_pb2, types_pb2

from src import gm
from src.Logging import getLogger, logFailure
from src.Parser.ExporterOptions import ExporterOptions
from src.Parser.SynthesisParser.PDMessage import PDMessage
from src.Parser.SynthesisParser.Utilities import guid_component, guid_occurrence
from src.Proto import joint_pb2, types_pb2

logger = getLogger()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import adsk.core
import adsk.fusion
from proto.proto_out import assembly_pb2, joint_pb2, signal_pb2, types_pb2

from src.Logging import getLogger
from src.Parser.ExporterOptions import ExporterOptions
Expand All @@ -38,6 +37,7 @@
fill_info,
guid_occurrence,
)
from src.Proto import assembly_pb2, joint_pb2, signal_pb2, types_pb2
from src.Types import JointParentType, SignalType

logger = getLogger()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import adsk
from proto.proto_out import material_pb2

from src.Logging import logFailure
from src.Parser.ExporterOptions import ExporterOptions
from src.Parser.SynthesisParser.PDMessage import PDMessage
from src.Parser.SynthesisParser.Utilities import construct_info, fill_info
from src.Proto import material_pb2

OPACITY_RAMPING_CONSTANT = 14.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import adsk.core
import adsk.fusion
from google.protobuf.json_format import MessageToJson
from proto.proto_out import assembly_pb2, types_pb2

from src import gm
from src.APS.APS import getAuth, upload_mirabuf
Expand All @@ -18,6 +17,7 @@
PDMessage,
)
from src.Parser.SynthesisParser.Utilities import fill_info
from src.Proto import assembly_pb2, types_pb2
from src.Types import ExportLocation, ExportMode
from src.UI.Camera import captureThumbnail, clearIconCache

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from typing import Union

import adsk
from proto.proto_out import types_pb2

from src.Logging import logFailure
from src.Proto import types_pb2


@logFailure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import adsk.core
import adsk.fusion
from proto.proto_out import assembly_pb2

from src.Logging import logFailure
from src.Proto import assembly_pb2


@logFailure
Expand Down
4 changes: 4 additions & 0 deletions exporter/SynthesisFusionAddin/src/Proto/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os
import sys

sys.path.append(os.path.dirname(os.path.abspath(__file__)))
65 changes: 65 additions & 0 deletions exporter/SynthesisFusionAddin/src/Proto/assembly_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions exporter/SynthesisFusionAddin/src/Proto/joint_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 309c287

Please sign in to comment.