Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Autodesk/synthesis into colb…
Browse files Browse the repository at this point in the history
…ura/1709/aps-logout
  • Loading branch information
azaleacolburn committed Jul 24, 2024
2 parents fdfbfcc + 243e49f commit abab679
Show file tree
Hide file tree
Showing 108 changed files with 7,342 additions and 3,557 deletions.
1 change: 0 additions & 1 deletion .github/workflows/FissionPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
- name: Install Dependencies
run: |
cd fission
rm package-lock.json
npm install
- name: Get package info
Expand Down
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
112 changes: 52 additions & 60 deletions exporter/SynthesisFusionAddin/Synthesis.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import logging
# DO NOT CHANGE ORDER, OR ADD IMPORTS BEFORE UNTIL END COMMENT

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.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm
from .src.Logging import getLogger, logFailure, setupLogger
from .src.Types.OString import OString
from .src.UI import (
HUI,
Expand All @@ -20,110 +19,103 @@
)
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


@logFailure
def run(_):
"""## Entry point to application from Fusion.
Arguments:
**context** *context* -- Fusion context to derive app and UI.
"""
setupLogger()

try:
# Remove all items prior to start just to make sure
unregister_all()

# creates the UI elements
register_ui()
# Remove all items prior to start just to make sure
unregister_all()

app = adsk.core.Application.get()
ui = app.userInterface
# creates the UI elements
register_ui()

MarkingMenu.setupMarkingMenu(ui)
app = adsk.core.Application.get()
ui = app.userInterface

except:
logging.getLogger(f"{INTERNAL_ID}").error("Failed:\n{}".format(traceback.format_exc()))
MarkingMenu.setupMarkingMenu(ui)


@logFailure
def stop(_):
"""## Fusion exit point - deconstructs buttons and handlers
Arguments:
**context** *context* -- Fusion Data.
"""
try:
unregister_all()
unregister_all()

app = adsk.core.Application.get()
ui = app.userInterface
app = adsk.core.Application.get()
ui = app.userInterface

MarkingMenu.stopMarkingMenu(ui)
MarkingMenu.stopMarkingMenu(ui)

# nm.deleteMe()
# nm.deleteMe()

# should make a logger class
handlers = root_logger.handlers[:]
for handler in handlers:
handler.close()
# I think this will clear the file completely
# root_logger.removeHandler(handler)
logger = getLogger(INTERNAL_ID)
logger.cleanupHandlers()

unload_config()
unload_config()

for file in gm.files:
try:
os.remove(file)
except OSError:
pass
for file in gm.files:
try:
os.remove(file)
except OSError:
pass

# removes path so that proto files don't get confused
# removes path so that proto files don't get confused

import sys
import sys

path = os.path.abspath(os.path.dirname(__file__))
path = os.path.abspath(os.path.dirname(__file__))

path_proto_files = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out"))
path_proto_files = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out"))

if path in sys.path:
sys.path.remove(path)
if path in sys.path:
sys.path.remove(path)

if path_proto_files in sys.path:
sys.path.remove(path_proto_files)

except:
logging.getLogger(f"{INTERNAL_ID}").error("Failed:\n{}".format(traceback.format_exc()))
if path_proto_files in sys.path:
sys.path.remove(path_proto_files)


@logFailure
def unregister_all() -> None:
"""Unregisters all UI elements in case any still exist.
- Good place to unregister custom app events that may repeat.
"""
try:
Camera.clearIconCache()

for element in gm.elements:
element.deleteMe()
Camera.clearIconCache()

for tab in gm.tabs:
tab.deleteMe()
for element in gm.elements:
element.deleteMe()

except:
logging.getLogger(f"{INTERNAL_ID}").error("Failed:\n{}".format(traceback.format_exc()))
for tab in gm.tabs:
tab.deleteMe()


@logFailure
def register_ui() -> None:
"""#### Generic Function to add all UI objects in a simple non destructive way."""

# if A_EP:
# A_EP.send_view("open")

# toolbar = Toolbar('SketchFab')
work_panel = Toolbar.getNewPanel(f"{APP_NAME}", f"{INTERNAL_ID}", "ToolsTab")

commandButton = HUI.HButton(
"Synthesis Exporter",
work_panel,
Helper.check_solid_open,
lambda *_: True, # TODO: Should be redone with various refactors.
ConfigCommand.ConfigureCommandCreatedHandler,
description=f"{DESCRIPTION}",
command=True,
Expand All @@ -134,9 +126,9 @@ def register_ui() -> None:
apsButton = HUI.HButton(
"APS",
work_panel,
Helper.check_solid_open,
lambda *_: True, # TODO: Should be redone with various refactors.
ShowAPSAuthCommand.ShowAPSAuthCommandCreatedHandler,
description=f"APS TEST",
description=f"APS",
command=True,
)

Expand Down
Loading

0 comments on commit abab679

Please sign in to comment.