Macro 3D Printer Workflow

Description
Macro that creates, for selected parts, an "stl" file with perfect rounding i.e. without visible facets. It also allows to launch programs of your choice. For example to automate the FreeCAD -> Slicer -> printing workflow.

This allows you to create a real workflow from the creation of an stl file without visible facets to, for example, the opening of your slicer with your loaded stl file, the switching on of your printer, the heating of your bed and if necessary the opening of other commands or the triggering of commands in your home automation...



Principle of smoothing
With visible facets:

Without visible facets:

The macro modifies the deviation property of the solids before generation of the stl file and then replace the old values. At the end, it proposes to launch the stl file which will open for example under cura if the stl extension has been associated with cura in your operating system.

Launching other programs or commands
You can ask it to chain any program or command that you might type in a terminal.

Examples of applications:
 * Turn on the printer and the light (requires for example a controlled socket).
 * Connect octoprint to the printer.
 * Start the tray preheating.
 * Save your FreeCAD and stl file somewhere.

Setup
Check that in your operating system, the stl extension is associated with your slicer. In other words, when you click on an stl file, your slicer should open and load your stl file.

If you run the macro as it is, this will be ok for the generation of the stl without visible facets, but the others programs launches will not be ok. To be able to launch other programs (launch octoprint...), you have to adapt the lines of code that are after  in the section Parameters that can be changed. Have a look at the comments in the Code.

Usage
Select one or several part(s) (body...) to print before running the macro.

When you run the macro you have something like:



Accuracy (param deviation):
 * 0.5 is the default value in FreeCAD.
 * 0.05 allows a stronger smoothing.
 * 0.01 is perfect from a smoothing point of view.

The lower the value, the better the quality, but the larger the size of the stl file. The value must be between 0 and 1

Links
Forum: https://forum.freecadweb.org/viewtopic.php?f=12&t=52138

Macros recipes: Macros recipes

Credits
Thanks to openBrain for the help on the code. Very good teacher! Thanks to Mario 52 for the help on this wiki.

Script
ToolBar Icon

Versions
ver 00.02 21/01/2023 by 2cv001

Code
ver 00.02 21/01/2023 by 2cv001