When I'm creating a complex parametric part/model, I often omit the "final" boolean union on complex part's components, as it often greatly increases computation time. Instead, I'll simply put all the components of the part in a Std_Part container, and when it's time for export, I'll select the Std_Part container to export the STL.
Unfortunately this means the STL model is not "correct", in that it contains internal faces/data where internal shared faces have not been removed by the boolean operation I have omitted.
To get around, this, I've create a simply python script using the 'pymeshlab' library, which very quickly performs a mesh-based boolean union on the exported STL.
The end result is a correct STL part, cleaned of all internal faces. This saves me a lot of time in FreeCAD, not having to wait for recomputation of a complex set of boolean operations.
I currently manually drag-and-drop my STL files onto my python script, but I was hoping for a way to hook into FreeCAD's STL export operation, to run an external script or command on the exported file after it has finished exporting. Obviously I could code this into a private fork, but I was hoping there would be an existing plugin interface to make this possible.
Ability to hook into Mesh/STL export process?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Ability to hook into Mesh/STL export process?
You can implement your own FreeCAD extension module. Therefore determine the path you get with
Open a file explorer and navigate to the above returned path. If there is not yet a directory Mod create it. Then create a sub-directory e.g. MeshExt. Inside this sub-directory add two files:
Code: Select all
App.getUserAppDataDir()
- Init.py with this content
Code: Select all
FreeCAD.changeExportModule("STL Mesh (*.stl *.ast)", "Mesh", "MeshExt")
- MeshExt.py with this content
Code: Select all
import Mesh def export(meshes, filename): Mesh.export(meshes, filename) print ("Use pymeshlab")