topics: [“mechanical design”, “cad”, “freecad”, “python”, “mathematics”]
FreeCAD is widely known as a parametric CAD system.
However, what is far less known is that:
Using only Python code,
FreeCAD can generate surprisingly rich geometric shapes
—without using:
In this article, we introduce pure code-driven solid geometry created with:

This solid is generated by:
All of this is done entirely in Python code.
No sketches. No constraints.
Next is a shape that is even more hostile to GUI-based modeling.

This model is constructed by:
Because the geometric properties change mid-way,
this type of model is notoriously fragile in history-based GUI CAD.
The important point is not that the shapes look exotic.
In these examples:
are all defined as variables and functions in Python.
In other words:
Geometry is not the result of manual operations
but the result of executing rules
Trying to create the same shapes in GUI CAD typically results in:
In contrast, with code-based design:
def r(z):
return base + amp * math.sin(freq * z)
The design intent itself is preserved as code.
Change a parameter → re-run → new geometry.
This approach is not just for artistic modeling.
It is highly effective for:
Because everything is code-based:
FreeCAD can be used not only as:
but also as:
There is no need to reject GUI workflows.
However, simply adding the option to:
Describe shape-generation rules in code
dramatically expands how CAD can be used.
The code used to generate the shapes in this article is available here:
Function-defined Loft + Twisted Solid
loft_twist_solid.py
Branched Spiral Solid
branched_spiral_sweep.py
The code used in this article is released under the MIT License.