Skip to content

Commit

Permalink
Fusion addin (#7)
Browse files Browse the repository at this point in the history
* added fusion post processors

* initial fusion api
Does not currently have enough depth to allow full integration into Fusion and merge toolpaths before post processing

* update gitignore

* create toolbar

* remove excess ui setup code

* fix issue is button already exists

* Split code into functions

* Removed gcode and CAD to tidy repo

* methodize stop

* Bug with fusion api I think. Changed how clean up works

* add example handler with various input options

* added resources

* add more resources

* updated cam post processor to include tool change

* rename fff post processor

* Setup ui layout

* generate toolpaths

* Post process both Fusion setups

* attempt to make parser detect cam tool last used
made program flow more sensible to read

* Updated parser to handler different CAM tools
Updated parser to handler Fusion additive gcode

* Fusion addin generates merged gcode

* updated parser to detect print layer height
Should also allow variable print heights

* add tool tips

* rename dropdown to overlap
rename intersect to dropdown
Sorry for any confusion when looking back, this naming makes more sense to me
Save output file in users workspace
provide user with progress indicator

* automatically opens created gcode file

* added icon to generate button command

* add a tooltip image for generate button

* added final completion message

* added fusion additive profiles

* fleshing out readme

* update readme config

* added demo gifs

* update way additive layer height is determined

* rename Simplify3DGcodeLayer to AdditiveGcodeLayer

* add post time out

* Removed temp controller from fusion post processor
Streamlined start gcode

* updated fusion settings

* update readme

* Updated documentation

* update table of contents

* Updated authors

* Allow non planar radial cuts

* temp removed non planar for release

* Readd spinner demo gcode

* updated config to be suitable for demo gcode

* readded spinner demo stls
  • Loading branch information
AndyEveritt authored Mar 30, 2020
1 parent e065852 commit 48eb4e2
Show file tree
Hide file tree
Showing 94 changed files with 2,383 additions and 1,238,815 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.vscode
*tmp.gcode
*tmp.nc

# 3D files
*.gcode
*.nc
*.stl
*.dmp
*.f3d

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
13 changes: 13 additions & 0 deletions ASMBL.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"autodeskProduct": "Fusion360",
"type": "addin",
"id": "c48d4cde-3023-49c1-95f7-3515aba13ecd",
"author": "AndyEveritt",
"description": {
"": "Additive and Subtractive Manufacturing By Layer"
},
"version": "1.0.2",
"runOnStartup": false,
"supportedOS": "windows|mac",
"editEnabled": true
}
149 changes: 149 additions & 0 deletions ASMBL.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import adsk.core
import adsk.fusion
import traceback

from .fusion_api import Handlers
from .fusion_api.Handlers import handlers


def create_tab(workspace, tab_name):
# Get all the tabs for the workspace:
allTabs = workspace.toolbarTabs
tabId = tab_name + 'TabId'

# check if tab exists
newTab = allTabs.itemById(tabId)

if not newTab:
# Add a new tab to the workspace:
newTab = allTabs.add(tabId, tab_name)
return newTab


def create_panel(workspace, tab, panel_name):
# Get all of the toolbar panels for the NewCam tab:
allTabPanels = tab.toolbarPanels

# Activate the Cam Workspace before activating the newly added Tab
workspace.activate()

panel = None
panel = allTabPanels.itemById(panel_name + 'PanelId')
if panel is None:
# Add setup panel
panel = allTabPanels.add(panel_name + 'PanelId', panel_name)
return panel


def create_button(workspace, tab, panel, button_name, CreatedEventHandler, tooltip=None, resources=''):
# We want this panel to be visible:
workspace.activate()
panel.isVisible = True

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

# Check if Setup Button exists
buttonId = button_name.replace(' ', '') + 'Id'
button = cmdDefinitions.itemById(buttonId)
if not tooltip:
tooltip = button_name

if not button:
# Create a button command definition.
button = cmdDefinitions.addButtonDefinition(
buttonId, button_name, tooltip, resources)

# Connect to the command created event.
newcommandCreated = CreatedEventHandler()
button.commandCreated.add(newcommandCreated)
handlers.append(newcommandCreated)

# Add setup button to ASMBL setup panel
panelControls = panel.controls
buttonControl = panelControls.itemById(buttonId)
if not buttonControl:
buttonControl = panelControls.addCommand(button)
return buttonControl


def remove_pannel(tab, panel_name):
# Get all the tabs for the workspace:
panelId = panel_name + 'PanelId'

# check if tab exists
panel = tab.toolbarPanels.itemById(panelId)

# Remove the controls we added to our panel
for control in panel.controls:
if control.isValid:
control.deleteMe()

# Remove our panel
panel.deleteMe()


def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface

cmdDefinitions = ui.commandDefinitions

# Get all workspaces:
allWorkspaces = ui.workspaces

# Get the CAM workspace:
camWorkspace = allWorkspaces.itemById('CAMEnvironment')

AsmblTab = create_tab(camWorkspace, 'Asmbl')
# asmblSetupPanel = create_panel(camWorkspace, AsmblTab, 'Setup')

asmblActionsPanel = create_panel(camWorkspace, AsmblTab, 'Actions')
asmblPostProcessControl = create_button(camWorkspace, AsmblTab, asmblActionsPanel,
'Post Process', Handlers.PostProcessCreatedEventHandler,
tooltip='Generate combined gcode file for ASMBL',
resources='./resources/PostProcess')
asmblPostProcessControl.isPromotedByDefault = True
asmblPostProcessControl.isPromoted = True
asmblPostProcessControl.commandDefinition.tooltipDescription = '\
<br>Requires an FFF setup and a milling setup</br>\
<br>Will not work if there are any more/fewer setups</br>'
asmblPostProcessControl.commandDefinition.toolClipFilename = 'resources/GenerateAsmbl/tooltip.png'


pass

except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


# When the addin stops we need to clean up the ui
def stop(context):
app = adsk.core.Application.get()
ui = app.userInterface

try:
# Get all workspaces:
allWorkspaces = ui.workspaces

# Get the CAM workspace:
camWorkspace = allWorkspaces.itemById('CAMEnvironment')

allTabs = camWorkspace.toolbarTabs

# check if tab exists
tab = allTabs.itemById('AsmblTabId')

# remove_pannel(tab, 'Setup')
remove_pannel(tab, 'Actions')

# Remove our render tab from the UI
if tab.isValid:
tab.deleteMe()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Loading

0 comments on commit 48eb4e2

Please sign in to comment.