Skip to content

Commit 48eb4e2

Browse files
authored
Fusion addin (#7)
* 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
1 parent e065852 commit 48eb4e2

File tree

94 files changed

+2383
-1238815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2383
-1238815
lines changed

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
.vscode
2-
*tmp.gcode
3-
*tmp.nc
2+
3+
# 3D files
4+
*.gcode
5+
*.nc
46
*.stl
7+
*.dmp
8+
*.f3d
59

610
# Byte-compiled / optimized / DLL files
711
__pycache__/

ASMBL.manifest

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"autodeskProduct": "Fusion360",
3+
"type": "addin",
4+
"id": "c48d4cde-3023-49c1-95f7-3515aba13ecd",
5+
"author": "AndyEveritt",
6+
"description": {
7+
"": "Additive and Subtractive Manufacturing By Layer"
8+
},
9+
"version": "1.0.2",
10+
"runOnStartup": false,
11+
"supportedOS": "windows|mac",
12+
"editEnabled": true
13+
}

ASMBL.py

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import adsk.core
2+
import adsk.fusion
3+
import traceback
4+
5+
from .fusion_api import Handlers
6+
from .fusion_api.Handlers import handlers
7+
8+
9+
def create_tab(workspace, tab_name):
10+
# Get all the tabs for the workspace:
11+
allTabs = workspace.toolbarTabs
12+
tabId = tab_name + 'TabId'
13+
14+
# check if tab exists
15+
newTab = allTabs.itemById(tabId)
16+
17+
if not newTab:
18+
# Add a new tab to the workspace:
19+
newTab = allTabs.add(tabId, tab_name)
20+
return newTab
21+
22+
23+
def create_panel(workspace, tab, panel_name):
24+
# Get all of the toolbar panels for the NewCam tab:
25+
allTabPanels = tab.toolbarPanels
26+
27+
# Activate the Cam Workspace before activating the newly added Tab
28+
workspace.activate()
29+
30+
panel = None
31+
panel = allTabPanels.itemById(panel_name + 'PanelId')
32+
if panel is None:
33+
# Add setup panel
34+
panel = allTabPanels.add(panel_name + 'PanelId', panel_name)
35+
return panel
36+
37+
38+
def create_button(workspace, tab, panel, button_name, CreatedEventHandler, tooltip=None, resources=''):
39+
# We want this panel to be visible:
40+
workspace.activate()
41+
panel.isVisible = True
42+
43+
app = adsk.core.Application.get()
44+
ui = app.userInterface
45+
cmdDefinitions = ui.commandDefinitions
46+
47+
# Check if Setup Button exists
48+
buttonId = button_name.replace(' ', '') + 'Id'
49+
button = cmdDefinitions.itemById(buttonId)
50+
if not tooltip:
51+
tooltip = button_name
52+
53+
if not button:
54+
# Create a button command definition.
55+
button = cmdDefinitions.addButtonDefinition(
56+
buttonId, button_name, tooltip, resources)
57+
58+
# Connect to the command created event.
59+
newcommandCreated = CreatedEventHandler()
60+
button.commandCreated.add(newcommandCreated)
61+
handlers.append(newcommandCreated)
62+
63+
# Add setup button to ASMBL setup panel
64+
panelControls = panel.controls
65+
buttonControl = panelControls.itemById(buttonId)
66+
if not buttonControl:
67+
buttonControl = panelControls.addCommand(button)
68+
return buttonControl
69+
70+
71+
def remove_pannel(tab, panel_name):
72+
# Get all the tabs for the workspace:
73+
panelId = panel_name + 'PanelId'
74+
75+
# check if tab exists
76+
panel = tab.toolbarPanels.itemById(panelId)
77+
78+
# Remove the controls we added to our panel
79+
for control in panel.controls:
80+
if control.isValid:
81+
control.deleteMe()
82+
83+
# Remove our panel
84+
panel.deleteMe()
85+
86+
87+
def run(context):
88+
ui = None
89+
try:
90+
app = adsk.core.Application.get()
91+
ui = app.userInterface
92+
93+
cmdDefinitions = ui.commandDefinitions
94+
95+
# Get all workspaces:
96+
allWorkspaces = ui.workspaces
97+
98+
# Get the CAM workspace:
99+
camWorkspace = allWorkspaces.itemById('CAMEnvironment')
100+
101+
AsmblTab = create_tab(camWorkspace, 'Asmbl')
102+
# asmblSetupPanel = create_panel(camWorkspace, AsmblTab, 'Setup')
103+
104+
asmblActionsPanel = create_panel(camWorkspace, AsmblTab, 'Actions')
105+
asmblPostProcessControl = create_button(camWorkspace, AsmblTab, asmblActionsPanel,
106+
'Post Process', Handlers.PostProcessCreatedEventHandler,
107+
tooltip='Generate combined gcode file for ASMBL',
108+
resources='./resources/PostProcess')
109+
asmblPostProcessControl.isPromotedByDefault = True
110+
asmblPostProcessControl.isPromoted = True
111+
asmblPostProcessControl.commandDefinition.tooltipDescription = '\
112+
<br>Requires an FFF setup and a milling setup</br>\
113+
<br>Will not work if there are any more/fewer setups</br>'
114+
asmblPostProcessControl.commandDefinition.toolClipFilename = 'resources/GenerateAsmbl/tooltip.png'
115+
116+
117+
pass
118+
119+
except:
120+
if ui:
121+
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
122+
123+
124+
# When the addin stops we need to clean up the ui
125+
def stop(context):
126+
app = adsk.core.Application.get()
127+
ui = app.userInterface
128+
129+
try:
130+
# Get all workspaces:
131+
allWorkspaces = ui.workspaces
132+
133+
# Get the CAM workspace:
134+
camWorkspace = allWorkspaces.itemById('CAMEnvironment')
135+
136+
allTabs = camWorkspace.toolbarTabs
137+
138+
# check if tab exists
139+
tab = allTabs.itemById('AsmblTabId')
140+
141+
# remove_pannel(tab, 'Setup')
142+
remove_pannel(tab, 'Actions')
143+
144+
# Remove our render tab from the UI
145+
if tab.isValid:
146+
tab.deleteMe()
147+
except:
148+
if ui:
149+
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

0 commit comments

Comments
 (0)