Macro 3D Printer 3mf Workflow

Macro_3D_Printer_3mf_Workflow

Description
FreeCAD macro exporting smooth 3MF files and preserving all slicer print settings, with automatic workflow to your preferred slicer.

Macro version: 00.03
Last modified: 2026/09/18
FreeCAD version: All
Download: Toolbar icon

Macro 3D_Printer_3mf_Workflow 3D_Printer_3mf_Workflow_ConfigIni.FCMacro
Author: 2cv001

Author
2cv001
Download
Toolbar icon

Macro 3D_Printer_3mf_Workflow 3D_Printer_3mf_Workflow_ConfigIni.FCMacro

Links
Macro Version
00.03
Date last modified
2026/09/18
FreeCAD Version(s)
All
Default shortcut
None
See also
None

Description

FreeCAD macro exporting smooth 3MF files and preserving all slicer print settings, with automatic workflow to your preferred slicer.

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro


# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.

from PySide import QtGui, QtCore

diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
    "Information",
    "This macro must be downloaded from this link\n"
    "\n"
    "https://raw.githubusercontent.com/2cv001/3D_printer_3mf_workflow/main/3D_Printer_3mf_Workflow.FCMacro" + "\n"
    "\n"
    "Quit this window to access the download page")

diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()

import webbrowser 
webbrowser.open("https://raw.githubusercontent.com/2cv001/3D_printer_3mf_workflow/main/3D_Printer_3mf_Workflow.FCMacro")

More detailed description:

https://github.com/2cv001/3D_printer_3mf_workflow/blob/main/README.md

Purpose

This macro automates and enhances the 3D printing workflow from FreeCAD to your slicer by:

This macro is the successor to macro 3d_printer_workflow.

The 3D_Printer_Workflow macro was already capable of producing smooth, facet‑free exports. Its main limitation was that it relied on STL files, which cannot store slicer or printing parameters.

This macro uses .3mf files, allowing all print settings to be saved and reused.

To retain the core functionality of the previous macro, this version also provides an STL export option with adjustable tessellation parameters, allowing smooth mesh generation just like before.

Limitation

The current version can export only a single object, but you can work around this by using links — for example, a Simple Group — to combine multiple objects into one.

Export filenames

Exports use the selected object's visible name (its Label in the FreeCAD tree), in the same directory as the saved FreeCAD document. For example, selecting Housing creates Housing.3mf and, if enabled, Housing.stl; selecting Lid creates Lid.3mf and Lid.stl. Each object has its own 3MF print settings and backups. Select one object and run the macro, then repeat for the next object.

For a PartDesign Body, selecting a face or edge in the 3D view, or a feature such as a Pad or Pocket in the tree, exports the whole Body using the Body's Label. Selecting several features of the same Body still counts as one object. Objects outside a Body retain their own labels and geometry.

Filename-incompatible characters are replaced with underscores. Names that collide within the document (including after sanitizing or ignoring letter case) receive the object's internal name as a suffix. Workflow backup/temporary suffixes and Windows device names are also adjusted to avoid conflicts. Use distinct, stable labels: renaming an object changes its export filename. Objects from different documents in the same folder should also have distinct labels.

Existing exports named after the project are not renamed automatically. To reuse their print settings, select the old .3mf in the 3MF file for print parameters field on the first export of a part. Save subsequent slicer changes in that part's new .3mf file.

This supports separate exports of 3D objects in one document; it does not split individual contours of a sketch or solids inside a single selected object.

Principle of smoothing

With visible facets

Without visible facets

The macro exports the selected objects to a 3MF file using the specified tessellation parameters (LinearDeflection and AngularDeflection). It generates temporary mesh objects for the export process and automatically removes them afterward.

Launching other programs or commands

The macro allows you to define custom commands that will be executed automatically after the 3MF file is generated. This feature is optional and can be used to automate additional steps in your workflow, such as:

Workflow Overview

First Launch

Subsequent Launches

Technical Notes

Use

Run the macro from FreeCAD. The slicer path is set directly in the macro’s main dialog, using the dedicated input field.

On first launch, enter your print settings in the slicer and save the .3mf file (generally, except in Cura, this is just Ctrl+S or “Save” in the menu).

On next launches, enjoy automatic reuse of your settings.

Macro_3D_Printer_3mf_workflow capture écrant

Setup (optional: to add additional commands)

A dedicated helper macro is provided to make configuration easy. Your commands are stored in an .ini file used by the workflow.

The ⚙️ button in the options window allows you to both install and open the configuration macro (3D_Printer_3mf_Workflow_ConfigIni.FCMacro).

Macro_3D_Printer_3mf_workflow capture écrant

Using %PROJECT%, %PROJECTDIR%, %PROJECTNAME% %EXPORT%, and %EXPORTNAME% in user commands

When you define custom post‑processing commands in the workflow, you can use three special placeholders. These placeholders are automatically replaced by values derived from your FreeCAD project file.

Available placeholders

Placeholders and their meaning:

Examples

Copy the generated 3MF file next to the project :

copy "%PROJECT%.3mf" "%PROJECTDIR%/backup/%PROJECTNAME%.3mf"

Run a script stored in the project folder :

python "%PROJECTDIR%/scripts/postprocess.py" "%PROJECT%.3mf"

Send an HTTP request using the project name :

curl "http://myserver/api/start?job=%PROJECTNAME%"

Turn on a Shelly smart plug Gen 1

curl "http://192.168.xxx.xxx/relay/0?turn=on"

Gen2

http://192.168.xxx.xxx/rpc/Switch.Set?id=0&on=true

Or if your device have a password :

curl -u admin:yourpassword "http://192.168.xxx.xx/rpc/Switch.Set?id=0&on=true"

Usage

More details at https://github.com/2cv001/3D_printer_3mf_workflow

Discussion

English: https://forum.freecad.org/viewtopic.php?t=102503

French: https://forum.freecad.org/viewtopic.php?t=103419

Script

ToolBar Icon

Code

ver 00.03 2026/09/18 by 2cv001 3D_Printer_3mf_Workflow.FCMacro

Download