Skip to content

Commit

Permalink
Exporter Updates (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Mar 14, 2024
2 parents a5c324e + 7474ccc commit ce40abc
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 26 deletions.
7 changes: 4 additions & 3 deletions exporter/SynthesisFusionAddin/proto/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def executeCommand(command: tuple) -> int:
)
else:
# Uses os.system because I was unable to get subprocess.call to work on MacOS
executionResult = os.system(str.join(' ', command))
installComm = str.join(' ', command)
executionResult = os.system(installComm)

return executionResult

Expand Down Expand Up @@ -104,7 +105,7 @@ def installCross(pipDeps: list) -> bool:
progressBar.message = f"Installing {depName}..."
adsk.doEvents()
# os.path.join needed for varying system path separators
installResult = executeCommand([os.path.join(pythonFolder, 'python'), '-m', 'pip', 'install', depName])
installResult = executeCommand([f"\"{os.path.join(pythonFolder, 'python')}\"", '-m', 'pip', 'install', depName])
if installResult != 0:
logging.getLogger(f'{INTERNAL_ID}').warn(f'Dep installation "{depName}" exited with code "{installResult}"')

Expand All @@ -116,7 +117,7 @@ def installCross(pipDeps: list) -> bool:
progressBar.message = f"Uninstalling {depName}..."
progressBar.progressValue += 1
adsk.doEvents()
uninstallResult = executeCommand([os.path.join(pythonFolder, 'python'), '-m', 'pip', 'uninstall', f'{depName}', '-y'])
uninstallResult = executeCommand([f"\"{os.path.join(pythonFolder, 'python')}\"", '-m', 'pip', 'uninstall', f'{depName}', '-y'])
if uninstallResult != 0:
logging.getLogger(f'{INTERNAL_ID}').warn(f'AntiDep uninstallation "{depName}" exited with code "{uninstallResult}"')

Expand Down
6 changes: 3 additions & 3 deletions exporter/SynthesisFusionAddin/src/Analytics/poster.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def __send(self, body) -> bool:
try:
# define user agent so this works
headers = {}
headers[
"User-Agent"
] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
headers["User-Agent"] = (
"Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
)

# print(f"{self.url}/collect?{body}")

Expand Down
1 change: 1 addition & 0 deletions exporter/SynthesisFusionAddin/src/Analyzer/sniff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" Takes in a given function call and times and tests the memory allocations to get data
"""

from ..general_imports import *
from time import time
import tracemalloc, time, linecache, os, inspect
Expand Down
1 change: 1 addition & 0 deletions exporter/SynthesisFusionAddin/src/Analyzer/timer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" Takes in a given function call and times and tests the memory allocations to get data
"""

from ..general_imports import *
from time import time
import os, inspect
Expand Down
1 change: 1 addition & 0 deletions exporter/SynthesisFusionAddin/src/GlobalManager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Initializes the global variables that are set in the run method to reduce hanging commands. """

import adsk.core, adsk.fusion, traceback
import inspect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Z
"""

import adsk, logging, traceback

from proto.proto_out import types_pb2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Returns:
- Success
"""

import adsk.core, adsk.fusion, logging
from typing import *

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 25 additions & 20 deletions exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,7 @@ def notify(self, args: adsk.core.SelectionEventArgs):
# indicator = INPUTS_ROOT.itemById("algorithmic_indicator")

if self.selectedOcc:
self.cmd.setCursor("", 0, 0)
if dropdownExportMode.selectedItem.index == 1:
occurrenceList = gm.app.activeDocument.design.rootComponent.allOccurrencesByComponent(
self.selectedOcc.component
Expand All @@ -1704,6 +1705,7 @@ def notify(self, args: adsk.core.SelectionEventArgs):
selectionInput.isVisible = False

elif self.selectedJoint:
self.cmd.setCursor("", 0, 0)
jointType = self.selectedJoint.jointMotion.jointType
if (
jointType == JointMotions.REVOLUTE.value
Expand Down Expand Up @@ -1753,17 +1755,20 @@ def notify(self, args):
try:
design = adsk.fusion.Design.cast(gm.app.activeProduct)
preSelectedOcc = adsk.fusion.Occurrence.cast(args.selection.entity)
preSelectedJoint = adsk.fusion.Joint.cast(args.selection.entity)

onSelect = gm.handlers[3] # select handler

if not preSelectedOcc or not design:
if (not preSelectedOcc and not preSelectedJoint) or not design:
self.cmd.setCursor("", 0, 0)
return

preSelected = preSelectedOcc if preSelectedOcc else preSelectedJoint

dropdownExportMode = INPUTS_ROOT.itemById("mode")
if preSelectedOcc and design:
if preSelected and design:
if dropdownExportMode.selectedItem.index == 0:
if preSelectedOcc.entityToken in onSelect.allWheelPreselections:
if preSelected.entityToken in onSelect.allWheelPreselections:
self.cmd.setCursor(
IconPaths.mouseIcons["remove"],
0,
Expand All @@ -1777,7 +1782,7 @@ def notify(self, args):
)

elif dropdownExportMode.selectedItem.index == 1:
if preSelectedOcc.entityToken in onSelect.allGamepiecePreselections:
if preSelected.entityToken in onSelect.allGamepiecePreselections:
self.cmd.setCursor(
IconPaths.mouseIcons["remove"],
0,
Expand All @@ -1789,6 +1794,8 @@ def notify(self, args):
0,
0,
)
else:
self.cmd.setCursor("", 0, 0)
except:
if gm.ui:
gm.ui.messageBox("Failed:\n{}".format(traceback.format_exc()))
Expand All @@ -1811,8 +1818,9 @@ def notify(self, args):
try:
design = adsk.fusion.Design.cast(gm.app.activeProduct)
preSelectedOcc = adsk.fusion.Occurrence.cast(args.selection.entity)
preSelectedJoint = adsk.fusion.Joint.cast(args.selection.entity)

if preSelectedOcc and design:
if (preSelectedOcc or preSelectedJoint) and design:
self.cmd.setCursor(
"", 0, 0
) # if preselection ends (mouse off of design), reset the mouse icon to default
Expand Down Expand Up @@ -1932,22 +1940,22 @@ def notify(self, args):
gamepieceConfig.isVisible = False
weightTableInput.isVisible = True

addFieldInput.isEnabled = (
wheelConfig.isVisible
) = jointConfig.isVisible = True
addFieldInput.isEnabled = wheelConfig.isVisible = (
jointConfig.isVisible
) = True

elif modeDropdown.selectedItem.index == 1:
if gamepieceConfig:
gm.ui.activeSelections.clear()
gm.app.activeDocument.design.rootComponent.opacity = 1

addWheelInput.isEnabled = (
addJointInput.isEnabled
) = gamepieceConfig.isVisible = True
addWheelInput.isEnabled = addJointInput.isEnabled = (
gamepieceConfig.isVisible
) = True

jointConfig.isVisible = (
wheelConfig.isVisible
) = weightTableInput.isVisible = False
jointConfig.isVisible = wheelConfig.isVisible = (
weightTableInput.isVisible
) = False

elif cmdInput.id == "joint_config":
gm.app.activeDocument.design.rootComponent.opacity = 1
Expand Down Expand Up @@ -2087,6 +2095,7 @@ def notify(self, args):

wheelSelect.isVisible = True
wheelSelect.isEnabled = True
wheelSelect.clearSelection()
addJointInput.isEnabled = True
addWheelInput.isEnabled = False

Expand All @@ -2096,13 +2105,15 @@ def notify(self, args):
addWheelInput.isEnabled = True
jointSelect.isVisible = True
jointSelect.isEnabled = True
jointSelect.clearSelection()
addJointInput.isEnabled = False

elif cmdInput.id == "field_add":
self.reset()

gamepieceSelect.isVisible = True
gamepieceSelect.isEnabled = True
gamepieceSelect.clearSelection()
addFieldInput.isEnabled = False

elif cmdInput.id == "wheel_delete":
Expand Down Expand Up @@ -2146,18 +2157,12 @@ def notify(self, args):
removeGamePieceFromTable(index)

elif cmdInput.id == "wheel_select":
self.reset()

addWheelInput.isEnabled = True

elif cmdInput.id == "joint_select":
self.reset()

addJointInput.isEnabled = True

elif cmdInput.id == "gamepiece_select":
self.reset()

addFieldInput.isEnabled = True

elif cmdInput.id == "friction_override":
Expand Down
1 change: 1 addition & 0 deletions exporter/SynthesisFusionAddin/src/configure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Stores data and fields from config.ini """

from configparser import ConfigParser
from .Types.OString import OString
from .strings import INTERNAL_ID
Expand Down
2 changes: 2 additions & 0 deletions installer/exporter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/Synthesis
/*.zip
14 changes: 14 additions & 0 deletions installer/exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Synthesis Exporter Installer

## Creating the installer
### Windows
1. Run `setup.bat`. This will copy the Synthesis exporter into the current directory.
2. Zip together the `install.bat` script and the `Synthesis` directory.

### MacOS
1. Run `create.sh`. This will copy the Synthesis exporter into the current directory and create a zip file with the necessary files.

## Using the installer
1. Download the zip file.
2. Unzip it anywhere (likely your Downloads folder).
3. Run the `install.bat` (`install.sh` for MacOS) script.
11 changes: 11 additions & 0 deletions installer/exporter/create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if test -d ./Synthesis; then
rm -rf ./Synthesis
fi

cp -r ../../exporter/SynthesisFusionAddin/ ./Synthesis
echo "Copied over Synthesis exporter!"

zip -r SynthesisExporter Synthesis/ install.sh
echo "Created zip installer!"
10 changes: 10 additions & 0 deletions installer/exporter/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

if exist "%AppData%\Autodesk\Autodesk Fusion 360\API\AddIns\Synthesis\" (
echo "Removing existing Synthesis exporter..."
rmdir "%AppData%\Autodesk\Autodesk Fusion 360\API\AddIns\Synthesis\" /Q/S
)

echo "Copying to %AppData%\Autodesk\Autodesk Fusion 360\API\AddIns\Synthesis..."
xcopy Synthesis "%AppData%\Autodesk\Autodesk Fusion 360\API\AddIns\Synthesis\" /E
echo "Synthesis Exporter Successfully Installed!"
10 changes: 10 additions & 0 deletions installer/exporter/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

if test -d ~/Library/Application\ Support/Autodesk/Autodesk\ Fusion\ 360/API/AddIns/SynthesisFusionAddin; then
echo "Removing existing Synthesis exporter..."
rm -rf ~/Library/Application\ Support/Autodesk/Autodesk\ Fusion\ 360/API/AddIns/SynthesisFusionAddin
fi

cp -r Synthesis/ ~/Library/Application\ Support/Autodesk/Autodesk\ Fusion\ 360/API/AddIns/SynthesisFusionAddin

echo "Synthesis successfully copied!"
9 changes: 9 additions & 0 deletions installer/exporter/setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off

if exist Synthesis\ (
rmdir Synthesis /Q/S
echo Removed .\Synthesis
)

xcopy ..\..\exporter\SynthesisFusionAddin Synthesis\ /E
echo Copied exporter into .\Synthesis

0 comments on commit ce40abc

Please sign in to comment.