Repo of the Day
deadsy/sdfx
Published: Dec 12, 2023
Open repository ↗A simple CAD package using signed distance functions. It's written in go, and its pretty cool you could just declare some shapes in go and get the stl file generated by the code.
Summary
sdfx is a Go library that models 2D and 3D shapes using signed distance functions (SDFs) and exports them as STL or 3MF files. Shapes are defined in Go source code rather than through a GUI or a separate scripting language. The package supports constructive solid geometry (CSG) along with filleting and chamfering, operations that the README notes are awkward to express in OpenSCAD.
What it is useful for
sdfx targets engineers who want programmatic, parametric CAD without leaving their Go toolchain. Typical uses include:
- Building printable parts and mechanical assemblies such as gears, camshafts, Geneva mechanisms, and bolts, all shown in the project's gallery.
- Performing CSG operations on primitive and complex shapes; the README calls out that SDFs make CSG straightforward.
- Adding fillets and chamfers to edges, which the README highlights as a pain point with OpenSCAD.
- Exploring procedural geometry, with gallery examples covering gyroid surfaces, Voronoi-style point fields, bezier-based bowls, and TrueType font rendering.
- Producing STL or 3MF output for slicers, 3D printers, or mesh viewers.
The repository is published under the MIT license, which is worth noting for anyone considering embedding it in a larger project.
How engineers can use it
The README does not provide a single install command or go get line. Instead, it points new users at the included examples and outlines this workflow:
- Read the examples in the repository to learn the SDF-based API.
- Write a Go program that composes 2D or 3D SDF primitives into the desired shape.
- Build and run the program; it writes an STL or 3MF file.
- Open the file in a 3D mesh viewer (the README suggests MeshLab) to verify the result.
- Send the file to a 3D printer if satisfied.
For tighter iteration, the README references two external helpers, SDF Viewer Go and SDFX-UI, which can replace the build-and-render step during development. Because SDFs must be sampled on a grid and then meshed, fine-grained or large models can take time to process, although the README does not quantify this. The topics list also implies 2D export formats such as DXF and SVG, but the README itself only documents STL and 3MF as output, so engineers should verify support in the examples before relying on those formats. New users should consult the examples directory and the roadmap document before starting a new design.