Turn Codes into Things: Kokopelli and Antimony

3D Printing & Imaging Woodworking Workshop
Turn Codes into Things: Kokopelli and Antimony
The Fab Boom Box, designed pre-kokopelli in the Fab Modules. It plays music off a standard SD card, runs on a single 9V battery and can be fabricated for under $100.

Kokopelli and antimony are parametric, comparative, implicit frameworks for computer-aided design that grew out of my master’s thesis at the MIT Center for Bits and Atoms – informed by previous work both there and in the broader research community – and were tested in the Fab Academy and the Machines that Make MIT class. At the moment, kokopelli is suitable for 2D and 3D modeling (and some even use it for PCB design!). It can export .pngs, .svgs, and .stls, and there’s basic built-in CAM for 2-, 3-, and 5-axis subtractive machining. Antimony, intended to be kokopelli’s spiritual successor, is experimental and under active development.

Basic shapes can be smoothly blended together for unusual effects.
In kokopelli, basic shapes can be smoothly blended together for unusual effects.

DownloadDOWNLOAD
The kokopelli and antimony applications and source are available via Matt Keeter’s GitHub. Kokopelli is also available as a Mac application. All code examples shown here, including the ones with sliders and other graphical elements are included.

If you get nervous when trigonometry starts showing its ugly face, don’t panic! Understanding the underpinnings gives you more power to define your own shapes and transformations, but it’s not mandatory. It’s completely possible to design with the standard library of shapes or use a graphical interface created by a more advanced user (scroll to the bottom) without ever touching the math expressions at the heart of the design format.

Like OpenSCAD, but with Built-In CAM

Currently, kokopelli CAM paths can be exported to Universal and Epilog laser cutters, the Roland Modela mini-mill, three- and five-axis Shopbot machines, and plain G-code. A modular workflow makes adding new machines easy.
kokopelli’s CAM interface doing path planning for a rough cut on a ShopBot.

Currently, kokopelli CAM paths can be exported to Universal and Epilog laser cutters, the Roland Modela mini-mill, three- and five-axis Shopbot machines, and plain G-code. A modular workflow makes adding new machines easy.  The screenshot (above) shows kokopelli’s CAM interface doing path planning for a rough cut on a ShopBot.

10table_12

These tools are built on an unusual solid modeling paradigm:  objects are represented as mathematical expressions, not as collections of polygons and edges (similar to OpenSCAD). Each object is a function of x, y, and z; if the function evaluates to less than zero at a particular point in space, that point is inside the solid.. For example, a sphere of radius 1 can be represented as “f(x, y, z) = pow(x, 2) + pow(y, 2) + pow(z, 2) – 1”. This paradigm makes constructive solid geometry (e.g. unions, intersections, cutouts, blending) very easy. The downside is that some traditional CAD operations (like chamfering a particular edge) become tricky to express, because object features are implicit rather than explicit.

Inspired by Brett Victor’s “Inventing on Principle.” The left pane shows Python source code; the right pane shows the rendered model, which is updated in real time as the code changes.
A complex sample model, this DIY milling machine is based on Jonathan Ward’s MTM A-Z design.

The Solver

On top of this abstraction sits a geometry engine, coded in C and optimized for solving these expressions very quickly by using a handful of tricks to effectively find the zero crossings of the expression (which corresponds to the model’s surface). The geometry engine renders either height-maps or triangulated meshes, with support for dynamic re-meshing as the user moves the camera around the scene.

Designer-Friendly Python

Kokopelli’s CAD system is built on this foundation. Instead of drafting and feature-based modeling, objects are designed as Python scripts. Many designers and creative coders are already familiar with Python, so the learning curve isn’t quite as steep as a domain-specific language. In addition, users have access to all of their favorite Python libraries.

koko2D-3d
“Tippy Top” mold bottom with the side cut away. Shown in both 2D (top) and 3D mesh view (bottom) in kokopelli split screen 2D/3D view.

The UI is inspired by Brett Victor’s “Inventing on Principle.” The left pane shows Python source code; the right pane shows the rendered model (either as a height-map, mesh, or both).  The models are updated in real time as the code changes.

UI Elements: Sliders and More!

Models can also be parameterized by sliders and other interactive UI elements in the view panel. This allows more experienced designers to make template models that can be customized by less experienced users.

LongHIng2d
Parametric living hinge example, included with kokopelli.

LampAtNightWhite2
PARAMETRIC LIVING HINGE QUICKSTART

Into living hinges? Want to create your own custom CNC-able designs for multiple machining formats? Anna Kaziunas France created a short guide to creating and fabricating your own parametric living hinge with the built-in kokopelli example.

kokopelli parametric box example

Antimony

Antimony uses the same foundation as kokopelli but combines Python scripting with graph-based composition (similar to the Grasshopper extension for Rhino). Objects, transformations, and user-defined scripts are represented as nodes with a set of inputs and outputs. These nodes are drawn as interactive elements overlaying the rendered models; users can click-and-drag to change their properties. Designers then connect inputs and outputs into graphs representing operations on a set of primitives.

antimony_script
Antimony’s scripting interface. Download from github.com/mkeeter/antimony

In practice, this is easier for novice users: they can get started by dragging-and-dropping primitives, then move into scripting when they need more sophisticated operations.

antimony_hello2
Extruding text in antimony

The Mac application and the Mac/Linux source for both antimony and kokopelli are at github.com/mkeeter/kokopelli) and include examples with graphical interfaces. To check out the included examples, after installing, use the kokopelli file menu to open a “.ko” file from the examples folder to get your CAD on.

Discuss this article with the rest of the community on our Discord server!
Tagged
Matt Keeter

Matt Keeter studied engineering at Harvey Mudd College, then got his M.S. at the MIT Center for Bits and Atoms. In his day job, he’s an electrical engineer at Formlabs. Outside of work, he creates unusual CAD systems, makes DIY electronics, volunteers at the MIT climbing wall, and goes out swing dancing.

View more articles by Matt Keeter

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK