Menu

From STL to an editable FreeCAD macro: change one number, run it again
📰

From STL to an editable FreeCAD macro: change one number, run it again

DEV Community: opensource·Emir Mrkaljević·16 days ago
#VcipNPYl
#devtoopensource#devto#dev#part#freecad
Reading 0:00
15s threshold

mesh2cad turns an STL into CAD. Every part gets a STEP file with real planes, cylinders and cones. When the part is simple enough it also gets a script with named parameters, so "make the hole 2 mm bigger" is one edited number instead of an afternoon of mesh surgery.

Until now that script was CadQuery or OpenSCAD. A lot of people who print parts use FreeCAD, though, and asking them to install CadQuery just to change a hole felt wrong. So 0.16.0 adds a third output: a FreeCAD macro.

pip install -U mesh2cad mesh2cad convert plate.stl --freecad plate.FCMacro freecadcmd plate.FCMacro

Enter fullscreen mode

Exit fullscreen mode

What the macro looks like

For a 40 x 30 x 6 plate with a 10 mm hole, the part that matters is this:

# --- parameters --- base_x = 40.0 # base length (X) base_y = 30.0 # base width (Y) base_t = 6.0 # base thickness (Z) base_cx = 0.0 base_cy = 0.0 base_z0 = - 3.0 # bottom face height hole_1_d = 10.0 # diameter hole_1_x = 0.0 hole_1_y = 0.0

# --- model --- result = Part .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.