Skip to content

Commit

Permalink
Merge branch 'dev' into dhruv/name-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay committed Jul 19, 2024
2 parents 2708e48 + 94839ef commit 31ea4f7
Show file tree
Hide file tree
Showing 67 changed files with 4,227 additions and 159 deletions.
59 changes: 51 additions & 8 deletions exporter/SynthesisFusionAddin/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Synthesis Exporter

This is a Addin for Autodesk® Fusion™ that will export a [Mirabuf](https://github.com/HiceS/mirabuf) usable by the Synthesis simulator.

## Features

- [x] Materials
- [x] Apperances
- [x] Instances
Expand Down Expand Up @@ -30,16 +32,17 @@ 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**
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
- If there is no button there may be a problem - see below for [checking log file](#debug-non-start)
- If there is no button there may be a problem - see below for [checking log file](#debug-non-start)

---

Expand All @@ -50,21 +53,21 @@ We use `VSCode` Primarily, download it to interact with our code or use your own
Most of the runtime for the addin is saved under the `logs` directory in this folder

- Open `logs/synthesis.log`
- If nothing appears something went very wrong (make a issue on this github)
- If something appears and you cannot solve it feel free to make an issue anyway and include the file
- If nothing appears something went very wrong (make a issue on this github)
- If something appears and you cannot solve it feel free to make an issue anyway and include the file

#### General Debugging

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**
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 `Debug` at the bottom of the dialog
- This is in a dropdown with the Run Button
- This is in a dropdown with the Run Button
8. This should open VSCode - Now run with `FN+5`
- Now you may add break points or debug at will
- Now you may add break points or debug at will

---

Expand All @@ -84,4 +87,44 @@ We format using a Python formatter called `black` [![Code style: black](https://
- use `isort .` followed by `black .` to format all relevant exporter python files.
- or, alternatively, run `python ./tools/format.py` to do this for you!

__Note: black will always ignore files in the proto/proto_out folder since google formats those__
**Note: black will always ignore files in the proto/proto_out folder since google formats those**

### Docstring standard

This standard is inconsistently applied, and that's ok

```python
def foo(bar: fizz="flower") -> Result[walrus, None]:
"""
Turns a fizz into a walrus
Parameters:
bar - The fizz to be transformed (default = "flower") ; fizz standards are subject to change, old fizzes may no longer be valid
Returns:
Success - She new walrus
Failure - None if the summoning fails ; the cause of failure will be printed, not returned
Notes:
- Only works as expected if the bar arg isn't a palindrome or an anagram of coffee. Otherwise unexpected (but still valid) walruses may be returned
- Please do not name your fizz "rizz" either, it hurts the walrus's feelings
TODO: Consult witch about inconsistent alchemical methods
"""
# More alchemical fizz -> walrus code
some_walrus = bar + "_coffee"
return some_walrus

```

Note that not this much detail is necessary when writing function documentation, notes, defaults, and a differentiation between sucess and failure aren't always necessary.

#### Where to list potential causes of failure?

It depends on how many you can list

- 1: In the failure return case
- 2-3: In the notes section
- 4+: In a dedicated "potential causes of failure section" between the "returns" and "notes" sections

Additionally, printing the error instead of returning it is bad practice
13 changes: 10 additions & 3 deletions exporter/SynthesisFusionAddin/Synthesis.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# DO NOT CHANGE ORDER, OR ADD IMPORTS BEFORE UNTIL END COMMENT

import logging
import os
import traceback
from shutil import rmtree

import adsk.core

from .src.APS import APS
from .src.configure import setAnalytics, unload_config
from .src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm, root_logger
from .src.Types.OString import OString
from .src.UI import (
Expand All @@ -20,6 +20,13 @@
)
from .src.UI.Toolbar import Toolbar

# END OF RESTRICTION

# Transition: AARD-1721
# Should attempt to fix this ordering scheme within AARD-1741
from .src.APS import APS # isort:skip
from .src.configure import setAnalytics, unload_config # isort:skip


def run(_):
"""## Entry point to application from Fusion.
Expand Down Expand Up @@ -136,7 +143,7 @@ def register_ui() -> None:
work_panel,
Helper.check_solid_open,
ShowAPSAuthCommand.ShowAPSAuthCommandCreatedHandler,
description=f"APS TEST",
description=f"APS",
command=True,
)

Expand Down
29 changes: 20 additions & 9 deletions exporter/SynthesisFusionAddin/proto/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import adsk.core
import adsk.fusion

from src.general_imports import INTERNAL_ID
from src.strings import INTERNAL_ID

system = platform.system()

Expand Down Expand Up @@ -167,13 +167,24 @@ def _checkDeps() -> bool:
return False


try:
import logging.handlers
"""
Checks for, and installs if need be, the dependencies needed by the Synthesis Exporter. Will error if it cannot install the dependencies
correctly. This should crash the exporter, since most of the exporter needs these dependencies to function in
the first place.
"""

import google.protobuf
import pkg_resources

from .proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2
except ImportError or ModuleNotFoundError:
installCross(["protobuf==4.23.3"])
from .proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2
def installDependencies():
try:
import logging.handlers

import google.protobuf
import pkg_resources
from requests import get, post

from .proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2
except ImportError or ModuleNotFoundError:
installCross(["protobuf==4.23.3", "result==0.17.0"])
from requests import get, post

from .proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2
Loading

0 comments on commit 31ea4f7

Please sign in to comment.