Skip to main content

Fusion 360 Export Face to DXF

Simple script for Fusion 360 which will save a selected face as a DXF file. Useful for exporting 3d models to be used in programs like LightBurn for laser cutting.

Why

Fusion lets you export a sketch as a DXF, but there's a few issues here:

  • DXF includes other sketch data, including lines which weren't extruded
  • If multiple sketches were made on the same body, this export style won't work

Instead, what many people do is the following:

  • Hide other components
  • Select the face, and create a new sketch
  • Use the "Project" tool (p key), and project the underlying geometry
  • Finish the sketch
  • Export this new sketch as a DXF

This workflow isn't terrible, but it is slow and a lot of button clicks. The below script just does all of these things automatically.

For example, take the following model, where I want to export the blue face:

SampleModel

The image on the left shows the default Save as DXF, the right shows the DXF output by this tool.

Output

How to use

  • Download the following script, save it as FusionLaser.py. Can save it anywhere, default location for scripts is: C:\Users\%USERNAME%\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\Scripts.
  • Go the the UTILITIES tab, ADD-INS, Scripts and Add-Ins
  • Click the green + icon, and select the script

Then, to use it:

  • Select the face you want to export
  • Open this add-ins menu (or press Shift S)
  • Select this script, and click Run
  • A dialog box will prompt you to save the DXF. By default, it uses the parent component name

Script

import adsk.core, adsk.fusion, traceback
import os

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

# get the selected face
if ui.activeSelections.count != 1:
ui.messageBox("Select a face")
return

selection = ui.activeSelections.item(0)

selectedFace = selection.entity # should be a BRepFace object

if not isinstance(selectedFace, adsk.fusion.BRepFace):
ui.messageBox("Selected item is not a face")
return

component = selectedFace.body.parentComponent # get the component the face belongs to

# hide all other components
for comp in des.allComponents:
if comp != component:
comp.isSuppressed = True

# create a new sketch
sketches = component.sketches
sketch = sketches.add(selectedFace)

# project face geometry
for loop in selectedFace.loops:
for edge in loop.edges:
sketch.project(edge)

# get default filename
default_filename = component.name + ".dxf"

# save file dialog
file_dialog = ui.createFileDialog()
file_dialog.title = "Save DXF File"
file_dialog.filter = "DXF Files (*.dxf)"
file_dialog.initialFilename = default_filename

if file_dialog.showSave() == adsk.core.DialogResults.DialogOK:
output_path = file_dialog.filename
else:
for comp in des.allComponents:
comp.isSuppressed = False
return

# export the sketch as a DXF
export_manager = des.exportManager
dxf_options = export_manager.createDXFSketchExportOptions(output_path, sketch)
dxf_options.filename = output_path
export_manager.execute(dxf_options)

# unhide all components
for comp in des.allComponents:
comp.isSuppressed = False

# delete sketch
sketch.deleteMe()

ui.messageBox('DXF exported successfully to:\n{}'.format(output_path))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))