Macro 3D Printer 3mf Workflow/de

Generisches Makro-Symbol Erstellen Sie Ihr persönliches Symbol mit demselben Namen des Makros Makro_3D_Printer_3mf_Workflow

Beschreibung
FreeCAD-Makro, das glatte 3MF-Dateien exportieren und alle Slicer- und Druckerdaten sichern kann, mit einem automatischen Arbeitsablauf für den bevorzugten Slicer.

Versionsmakro : 00.03
Datum der letzten Änderung : 2026/09/18
FreeCAD version : Alle
Herunterladen : Toolbar icon

Macro 3D_Printer_3mf_Workflow 3D_Printer_3mf_Workflow_ConfigIni.FCMacro
Autor: 2cv001

Autor
2cv001
Herunterladen
Toolbar icon

Macro 3D_Printer_3mf_Workflow 3D_Printer_3mf_Workflow_ConfigIni.FCMacro

Links
Macro-Version
00.03
Datum der letzten Änderung
2026/09/18
FreeCAD-Version(s)
Alle
Standardverknüpfung
None
Siehe auch
None

Beschreibung

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/refs/heads/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/refs/heads/main/3D_Printer_3mf_Workflow.FCMacro")

FreeCAD-Makro zum Exportieren von glatten 3MF-Dateien unter Beibehaltung aller Druckereinstellungen des Slicers, mit automatischem Arbeitsablaufs zum bevorzugten Slicer.

Ausführlichere Beschreibung:

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

Zweck

Dieses Makro automatisiert und verbessert den Arbeitsablauf von FreeCAD zum Slicer für das 3D-Drucken durch:

Auf einen Blick

  • Smooth prints: curved surfaces come out without visible facets.
  • Your slicer settings are kept: set them once in the slicer (temperature, supports, infill…); every new export from FreeCAD keeps them.
  • From FreeCAD to the slicer in one click: the macro exports the 3MF and opens it in your slicer.
  • Several objects at once, each one with its own settings.
  • Your own commands before or after the export: turn on the printer through a smart plug while FreeCAD exports, preheat, copy the 3MF… Ready-made templates, a live check and a Test button help to write them.
  • You see what you export: a preview of the selected objects and the estimated export time.
  • Works with most slicers: QIDISlicer, QIDIStudio, PrusaSlicer, OrcaSlicer, Bambu Studio, Cura, Creality Print, Anycubic.

Prinzip der Glättung

Mit sichtbaren Facetten

Ohne sichtbare Facetten

Das Makro exportiert die ausgewählten Objekte unter Verwendung der angegebenen Tessellationsparameter (LinearDeflection und AngularDeflection) in eine 3MF-Datei. Es generiert temporäre Netzobjekte für den Exportvorgang und entfernt diese anschließend automatisch.

Arbeitsablauf-Übersicht

Erster Start

  • FreeCAD exportiert eine .3mf-Datei, die ausschließlich die Objektgeometrie enthält.
  • Der Slicer öffnet die Datei.
  • Der Benutzer gibt die Druckeinstellungen ein (z. B. 200 °C, PLA, 50 mm/s).
  • Der Slicer speichert die .3mf-Datei mit den eingebetteten Druckeinstellungen.

Nachfolgende Starts

  • Es wird eine neue .3mf-Datei mit Geometrie und Konfiguration erstellt.
  • Der Slicer öffnet die Datei mit allen voreingestellten Parametern.
  • ✅ Es muss nichts erneut eingegeben werden – Änderungen bleiben erhalten.

Anwendung

Install the macro with the Addon Manager of FreeCAD, then select the objects to print in the tree.

Das Makro in FreeCAD ausführen. Der Slicer-Pfad wird direkt im Hauptdialog des Makros über das dafür vorgesehene Eingabefeld festgelegt.

Beim ersten Start die Druckeinstellungen im Slicer eingeben und die .3mf-Datei (in der Regel – außer in Cura – einfach mit Strg+S oder über den Menüpunkt „Speichern“) speichern.

Bei den nächsten Starts werden die Einstellungen automatisch übernommen.

Macro_3D_Printer_3mf_workflow capture écrant

Andere Programme oder Befehle starten

Das Makro ermöglicht, individuelle Befehle zu definieren, die automatisch ausgeführt werden, nachdem die 3MF-Datei erstellt wurde. Diese Funktion ist optional und kann dazu verwendet werden, zusätzliche Schritte im Arbeitsablauf zu automatisieren, wie:

  • Die erstellte 3MF-Datei an einen anderen Ort kopieren.
  • Den 3D-Drucker mit einem Smart-Plug einschalten.
  • Eine Leuchte einschalten.
  • Die Druckunterlage vorheizen.
  • Eine HTTP-Abfrage an das eigene Heimautomatisierungssystem senden.
  • Ein Skript oder ein externes Werkzeug starten.

The options window lists your commands, each with a checkbox: check the ones to run this time. Commands run before the export are marked "(before the export)".

Einrichtung (optional: um weitere Befehle hinzuzufügen)

Zur Vereinfachung der Konfiguration steht ein spezielles Hilfsmakro zur Verfügung. Ihre Befehle werden in einer vom Workflow verwendeten INI-Datei gespeichert.

Die Schaltfläche ⚙️ im Optionen-Fenster ermöglicht das Installieren und auch das Öffnen des Konfigurationsmakros (3D_Printer_3mf_Workflow_ConfigIni.FCMacro).

Configuration window: the selected command has a mistake (C:/… instead of C:\…), the check points it out before you run it.

Jede Zeile der Tabelle ist ein Befehl:

Column Meaning
Command The program and its parameters
Label The name shown in the options window
Delay (s) Time to wait before running the command
Enabled by default Checked in the options window when the macro starts
Before the export Run the command before the export instead of after it

Hover your mouse over a column title to display help tooltips.

Einen Befehl schreiben

  • Add from a template (first button) creates a ready-made command: copy the 3MF, open the project folder, web request, Shelly plug (Gen 1 or Gen 2, with or without a password, or through the Shelly cloud with an API key), Home Assistant, Jeedom, Klipper preheating, Python script. The part to replace, such as <PLUG_IP>, is selected: just type. Requests made with curl use --fail, so that an error answered by the device is reported as an error.
  • Add from scratch adds an empty row.
  • Move up / Move down change the order of the commands. "Before the export" commands are always run before the others.
  • Under the table, the command of the selected row can be edited with:
    • Browse…: inserts the path of a program or file;
    • Insert a variable: inserts %EXPORT%.3mf, %PROJECTDIR%… (see below), with the quotes and the space when needed. The menu shows the real value of each variable for the current export.
  • A check, updated as you type, shows:
    • whether the program is found, and where;
    • how the command is split into parameters, with the real paths of the current export;
    • the usual mistakes: command built into Windows such as copy without cmd /c, part of a template left to replace, unclosed quote, single quotes, > or |, unknown variable, %EXPORT% used before the export;
    • wrong paths: a full path such as %PROJECT% placed after a folder (use %PROJECTNAME%), a C:/… path given to cmd (write C:\…), a folder that does not exist.
  • Test runs the command right away (after confirmation) and tells whether it succeeded. For curl, the usual errors are explained (device not found, not reachable, error answered, no answer in time).

Rules to know:

  • Put an argument containing spaces between double quotes ("%EXPORT%.3mf").
  • Commands are run directly, without a shell: commands built into the Windows command prompt (copy, del, echo…) need cmd /c in front of them, and >, | or && do not work.

Vor oder nach dem Export

  • After the export (default): the commands run in order once the 3MF is written and the slicer launched, before the end message. FreeCAD is not blocked while a delay runs.
  • Before the export checked: the command runs as soon as the options are validated, before the meshing. Typical use: turn on the printer and start preheating while FreeCAD exports. The macro waits for each delay (countdown in the status bar) and the export only starts after the last "before" command. The 3MF is not written yet at that time: do not use %EXPORT% in these commands.

Example: a "before" command turns on the Shelly plug, a second "before" command with a 10 s delay sends the preheating to Klipper once the printer has started, then the export begins.

The "before" commands are stored separately in the .ini file (EXTRA_COMMANDS_BEFORE): an older version of the macro ignores them.

%PROJECT%, %PROJECTDIR%, %PROJECTNAME% %EXPORT%, und %EXPORTNAME% in Benutzerbefehlen verwenden

Wenn benutzerdefinierte Nachbearbeitungsbefehle im Arbeitsablauf definiert werden, können drei spezielle Platzhalter verwendet werden. Diese Platzhalter werden automatisch durch Werte ersetzt, die aus der FreeCAD-Projektdatei abgeleitet werden.

Verfügbare Platzhalter

Platzhalter und ihre Bedeutung:

  • %PROJECT%: Vollständiger Pfad des FreeCAD-Projekts ohne Erweiterung
  • %PROJECTDIR%: Ordner mit dem FreeCAD-Projekt
  • %PROJECTNAME%: Projektdateiname ohne Erweiterung
  • %EXPORT%: Vollständiger Pfad des ausgewählten Objekts ohne Dateiendung
  • %EXPORTNAME%: Dateinamen ohne Dateiendung exportieren

To build a path in another folder, use the names: "C:\Backup\%EXPORTNAME%.3mf", not "C:\Backup\%EXPORT%.3mf".

Beispiele

These examples are also available with Add from a template. Replace the parts between < > with your own values.

Die erzeugte 3MF-Datei in das Projekt kopieren:

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

Unter Linux/macOS:

cp "%EXPORT%.3mf" "%PROJECTDIR%/backup/%EXPORTNAME%.3mf"

Ein im Projektordner gespeichertes Skript ausführen:

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

Den Projektordner öffnen (Windows):

explorer "%PROJECTDIR%"

Eine HTTP-Anfrage unter Verwendung des Projektnamens senden:

Turning on the printer (to check "Before the export")

Ein Shelly Smart Plug Gen 1 einschalten

Gen 1 with a password (restricted login):

curl --fail -u <USER>:<PASSWORD> "http://<PLUG_IP>/relay/0?turn=on"

Gen2

Oder wenn das Gerät ein Passwort hat:

Through the Shelly cloud (server address and authorization key in the Shelly app: User settings → Authorization cloud key; device ID in the device settings):

curl --fail -X POST "https://<CLOUD_SERVER>/device/relay/control" -d "channel=0&turn=on&id=<DEVICE_ID>&auth_key=<API_KEY>"

Home Assistant (long-lived access token created in your Home Assistant profile):

curl --fail -X POST -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" -d "{\"entity_id\":\"switch.<PLUG_NAME>\"}" "http://<HOME_ASSISTANT_ADDRESS>:8123/api/services/switch/turn_on"

Jeedom (API key in Settings → System → Configuration → API; command ID shown in the advanced configuration of the command):

curl --fail "http://<JEEDOM_ADDRESS>/core/api/jeeApi.php?apikey=<API_KEY>&type=cmd&id=<COMMAND_ID>"

Preheat the bed of a Klipper printer to 60 °C (Moonraker):

curl --fail -X POST "http://<PRINTER_IP>:7125/printer/gcode/script?script=M140%20S60"

Keep your keys and passwords for yourself: they are stored in clear text in the .ini file.

Weitermachen

Mehrere Objekte exportieren

Select one or more objects (Ctrl+click in the tree) and run the macro. All the selected objects go into a single 3MF, each one as a separate object in the slicer, with its own print settings.

The top right corner of the options window shows a small isometric image of the selected objects, with their colors (for a PartDesign Body, the color of its visible feature), so you can check what will be exported. It is drawn by the macro from a very coarse mesh, without OpenGL, in a few hundredths of a second; the document and the 3D view are not touched.

  • First export: the objects keep exactly their FreeCAD layout (X, Y and Z). The group is centered on the plate and the lowest object rests on it. If objects overlap, QIDISlicer / PrusaSlicer ask whether to load them as a single object having multiple parts: answer Yes to keep them assembled, No to get separate objects (then arrange them on the plate).
  • Next exports: each FreeCAD object is matched with the slicer object of the same name. Its geometry is replaced; its settings and its position and rotation on the plate are kept, and it is put back on the plate.
  • Objects that are no longer selected are removed from the 3MF; newly selected objects are added at their FreeCAD position.
  • Copies made on the plate in the slicer (duplicated objects or added instances) are kept as long as the object has not changed in FreeCAD. When it has changed, the macro asks: Keep the copies (each one gets the new geometry and keeps its place; if the part got bigger they may overlap, use "Arrange" in the slicer) or Remove the copies. With Do not recover slicer position/rotation checked, the copies are removed.
  • With a single selected object and a 3MF whose object has another name, the first object on the plate is replaced and renamed after the FreeCAD object, so 3MF files made by previous versions keep working.
  • With the STL option, all the selected objects go into one STL file.
  • Objects inside an App::Part are exported at their global position.

Auswahl der 3MF-Basis

The 3MF file for print parameters list chooses the 3MF whose print settings and objects are reused:

  • No base (new 3MF): a new 3MF containing only the geometry. If the 3MF of the selection already exists, it is kept as a .old backup.
  • This selection's 3MF: the usual choice, selected by default when it exists. When it does not exist yet, the most recent 3MF of the project folder that contains an object with the same name is selected instead (for example the 3MF of several objects, when you export one of them alone), so its settings are not lost.
  • The other 3MF files of the project folder, most recent first.
  • The last 8 bases used in other folders (remembered from one session to the next), shown with their folder and date, so that several "Body.3mf" from different projects can be told apart. Hover over a line to see its full path.
  • Browse… picks a 3MF anywhere, for example in another project.

Each 3MF of the list shows its thumbnail: the preview image saved in the file by the slicer (plate image for QIDIStudio / Bambu / Orca, thumbnail for Cura / SuperSlicer / FreeCAD). It is only read from the file, so it costs nothing; a 3MF without a preview image simply has no thumbnail.

Below the list, the macro shows the name the 3MF will be saved as and explains what the chosen base will do: for which objects the existing settings are kept, which objects are new (they get the general settings), and whether the base has no slicer settings at all. The text turns orange when object settings may not be reused (no object of the base has a selected name, or "No base" while the 3MF of the selection exists). The base file itself is never modified; if the 3MF of the selection already exists and another base is chosen, it is backed up first (.old file).

From the base, the macro always keeps the general settings: printer, filament (type, temperatures, cooling… and all the filaments of a multi-color printer) and print profile (layer height, speeds, walls, default infill and supports…). The settings of an object (its own infill, walls, layer height, supports, filament, modifiers…) are kept only for the objects matched by name. Objects of the base that match no selected object are removed; new objects get the general settings and the first filament.

Auf Flächen und Modifikatoren angewendete Einstellungen

Some print settings are attached to specific faces of an object: enforced or blocked supports, seams, colors (and other per-face data). They, as well as modifiers and extra parts, are tied to the old geometry and cannot be kept when it changes. If some would be lost, the macro tells you which objects are concerned and asks you to Continue or Cancel (the 3MF is then left unchanged).

Objects whose geometry has not changed in FreeCAD since the last export are left exactly as they are in the slicer: their settings applied to faces, modifiers, copies and position are all kept, and the warning only lists the objects that really changed. For example, with Housing_Lid.3mf, modifying only the Housing keeps the enforced supports of the Lid. (Changing the precision or the angular tolerance changes the mesh, so all objects are then replaced. With Do not recover slicer position/rotation checked, all objects are replaced and placed as in FreeCAD.)

Netzfeinheit und Exportdauer

Very small values make the mesh huge, and FreeCAD is frozen while it is computed. Before meshing, the macro quickly estimates the number of triangles and the time needed (from a few coarse test meshes, in less than a second). If the mesh would take more than about 30 seconds or have more than a million triangles, it asks first: Continue or Back to options to choose coarser values.

The Mesh fineness panel of the options window holds the Precision (LinearDeflection, in mm) and the Angular tolerance (AngularDeflection, in degrees); their tooltips explain them. On the right, Export time shows the estimated time for the selected objects, with the number of triangles and the 3MF size below. It is computed when the window opens and updated live while you change the values; it turns orange above the warning limits.

Optimize fineness chooses the finest precision and angular tolerance whose estimated export fits in the Target export time (remembered between sessions), keeping the ratio between the two values. It never goes below 0.01 mm and 2°: below that, the printed part does not change (0.4 mm nozzle, 0.1 to 0.2 mm layers), only the file and the time grow. You can still type finer values yourself.

The time estimate adjusts itself to your computer: after each export, the real meshing time is compared with the estimate and a correction factor is kept in the .ini file.

Dateinamen exportieren

Beim Export wird der sichtbare Name des ausgewählten Objekts (seine Bezeichnung im FreeCAD-Baum) verwendet, und zwar im selben Verzeichnis wie das gespeicherte FreeCAD-Dokument. Wenn Sie beispielsweise Housing auswählen, werden die Dateien Housing.3mf und – sofern aktiviert – Housing.stl erstellt; bei Auswahl von Lid entstehen die Dateien Lid.3mf“ und „Lid.stl. Jedes Objekt verfügt über eigene 3MF-Druckeinstellungen und Sicherungskopien. Ein Objekt auswählen und das Makro ausführen, den Vorgang anschließend für das nächste Objekt wiederholen.

Bei einem PartDesign-Körper wird durch die Auswahl einer Fläche oder Kante in der 3D-Ansicht oder eines Formelements wie beispielsweise eines Blocks oder einer Vertiefung im Baum der gesamte Körper unter Verwendung der Bezeichnung des Körpers exportiert. Die Auswahl mehrerer Elemente desselben Körpers gilt weiterhin als ein Objekt. Objekte außerhalb eines Körpers behalten ihre eigenen Bezeichnungen und ihre eigene Geometrie bei.

Zeichen, die für Dateinamen ungeeignet sind, werden durch Unterstriche ersetzt. Namen, die innerhalb des Dokuments kollidieren (auch nach Bereinigung oder Ignorierung der Groß-/Kleinschreibung), erhalten den internen Namen des Objekts als Suffix. Arbeitsablauf-Sicherungs-/Temporär-Suffixe und Windows-Gerätenamen werden ebenfalls angepasst, um Konflikte zu vermeiden. Eindeutige, beständige Bezeichnungen verwenden: Das Umbenennen eines Objekts ändert dessen Exportdateinamen. Objekte aus verschiedenen Dokumenten im selben Ordner sollten ebenfalls eindeutige Bezeichnungen haben.

Bestehende, nach dem Projekt benannte Exporte werden nicht automatisch umbenannt. Um deren Druckeinstellungen wiederzuverwenden, beim ersten Export eines Teils die alte .3mf-Datei im Feld 3MF-Datei für Druckparameter auswählen. Nachfolgende Änderungen im Slicer in der neuen .3mf-Datei dieses Teils speichern.

Diese Funktion ermöglicht den separaten Export von 3D-Objekten innerhalb eines Dokuments; einzelne Konturen einer Skizze oder Volumenkörper innerhalb eines einzelnen ausgewählten Objekts werden dabei nicht aufgeteilt.

Slicer-Pfad

The slicer path must be the slicer program itself (on Windows, its .exe file): a part file such as a .3mf or .stl is refused. On Windows, the Browse… button of the slicer line only lists programs, so that it is not confused with the Browse… button of the base 3MF.

Technische Hinweise

  • Die Geometrie wird aus dem aktiven FreeCAD-Dokument extrahiert.
  • Anstelle von .stl-Dateien werden .3mf-Dateien verwendet, um die Druckmetadaten beizubehalten.
  • Die Druckeinstellungen werden in der .3mf-Datei im selben Verzeichnis wie das FreeCAD-Dokument gespeichert.
  • Kompatibel mit den meisten Slicern, die das .3mf-Format unterstützen: getestet mit QidiSlicer, QidiStudio, Cura, PrusaSlicer, OrcaSlicer, Bambu Studio, Anycubic und Creality.
  • Nicht kompatibel mit Slicern, die keine 3MF-Dateien mit Druckeinstellungen erzeugen (z. B. ideaMaker, FlashPrint). Bei anderen Slicern kann es gerne ausprobiert werden – es sollte funktionieren. Andernfalls bitte ein Issue auf GitHub erstellen.
  • Das Makro kann so konfiguriert werden, dass es andere Befehle ausführt, beispielsweise das Einschalten des Druckers über einen angeschlossenen Smart Plug.

Versionsverlauf

Dieses Makro ist der Nachfolger des Makro 3d_printer_workflow.

Das Makro 3D_Printer_Workflow war schon in der Lage, glatte, facettenfreie Exporte zu erstellen. Seine Haupteinschränkung war, dass er auf STL-Dateien angewiesen war, die keine Slicer- oder Druckeinstellungen speichern können.

Dieses Makro verwendet .3mf-Dateien, die ermöglichen, alle Druckeinstellungen zu speichern und wiederzuverwenden.

Um die Kernfunktionalität des vorherigen Makros beizubehalten, bietet diese Version ebenfalls eine STL-Exportoption mit einstellbaren Tessellationsparametern, die wie zuvor eine reibungslose Netzgenerierung ermöglicht.

Anwendung

Mehr Details unter https://github.com/2cv001/3D_printer_3mf_workflow

Diskussion

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

Französisch: https://forum.freecad.org/viewtopic.php?t=103419

Skript

Werkzeugleisten-Symbol

Code

ver 00.07 2026/11/26 by 2cv001 3D_Printer_3mf_Workflow.FCMacro

Herunterladen