ImplicitCAD: Programmatic CAD Built with 3D Printing in Mind

Cornerstone of many useful things: This Prusa i3 part was modeled in OpenSCAD.

Programmatic CAD, in particular the OpenSCAD language and IDE, has accompanied the maker movement for a while now. After its introduction in 2009, it quickly found its way into the 3D printing toolbox of many makers and eventually became what could be called an Industry Standard among open hardware labs, makerspaces and tinkerers. The Prusa i3, one of the most popular DIY 3D printers, was designed in OpenSCAD, and even Makerbot, the company that sold 100.000 3D printers, uses the language for its “Customizer” – an online tool that allows users to customize 3D printable models with minimal effort.

OpenSCAD is indeed a wonderful tool, and we have been using it a lot. We have become used to its quirks and accepted working with polygon mesh approximations of the models we are trying to design. We have made our peace with excessive rendering times, scripting workarounds and the pain of creating fillets, and we have learned to keep our aesthetic expectations low. We are happy with the fact that there is a way to programmatically create and share virtually any object, but sometimes we wish there was a better way in the open source world. Hint: there is.

ImplicitCAD

Inspired by OpenSCAD, ImplicitCAD was originally started by Christopher Olah in early 2012, aiming to create a solid programmatic CAD tool to create complex models for 3D printing. It borrows the OpenSCAD language for modeling but has its own 3D geometry engine. At the core, the engine relies on continuous mathematical descriptions of 3D geometries rather than polygon mesh approximations. The finished model can then be translated into a mesh-based format such as STL, rendered into an image via raytracing, or turned into G-code directly. In many cases, this happens much faster and more efficiently in ImplicitCAD than in OpenSCAD. Also, ImplicitCAD offers a bit more flexibility in programming – and rounded CSG operations. ImplicitCAD is written entirely in Haskell and, despite having a common modeling language, shares no common code with OpenSCAD.

Getting Started

ImplicitCAD doesn’t come in a precompiled binary with an IDE on board. There are ambitions to create a web based editor, but currently, it is not functional. I recommend you to use MeshLab for previewing your models along with your favorite text editor.

The installation and build instructions for Linux, Mac and Windows are easy to follow and should be sufficient to get you started. To get the most recent development version 0.0.6, you will need to create your own build from the ImplicitCAD source [EDIT: this ImplicitCAD source, thanks Julia].

Hello World

With ImplicitCAD installed on your system, you can start modeling. Just create an empty text file named ‘helloworld.escad’ on your Desktop and open it in your favorite editor. Type:

Mesh output quality at default rendering resolution.
sphere(r=10);

Then open a terminal and render your model by typing:

$ extopenscad ~/Desktop/helloworld.escad

Mac users may try this:

$ ~/.cabal/bin/extopenscad ~/Desktop/helloworld.escad

This will create a ‘helloworld.stl’ on your desktop. Open the file in mesh lab. Wow, a rough sphere.

ImplicitCAD automatically sets the rendering resolution to a reasonable value (and shows this in its terminal output), but you can specify a rendering resolution by defining $res in your model file. Smaller values result in a higher rendering quality:

$res=0.5;
sphere(r=10);

Render this and have a look at the STL again. The quality should be much better now.

Where It Shines

Rounded CSG transformations

ImplicitCAD can perform rounded unions. This creates smooth transitions between fused objects.

Passing the ‘r’ parameter to the ‘union()’ module smooths out the transition between arbitrary geometries.
$res=0.5;
sphere_size=10;
fillet_radius=2;
union(r=fillet_radius)
{
  translate([-0.8*sphere_size,0,0])
    sphere(sphere_size);
  translate([0.8*sphere_size,0,0])
    sphere(sphere_size);
}

Rounded differences work just as well:

OpenSCAD’s ‘minkowski()’ module also allows convex smoothing – too bad it is such a handbrake. ImplicitCAD does this on the fly.
$res=0.5;
cube_size=10;
fillet_radius=2;

difference(r=fillet_radius){
  cube(cube_size,center=true);
  cylinder(r=cube_size/4, h=2*cube_size, center=true);
}

Threads

Unfortunately, lots of CSG work is necessary to get a proper thread out of OpenSCAD. ImplicitCAD however, supports translation in the rotate_extrude module, making threads easier and faster:

An M16 thread in ImplicitCAD.
$res=0.05;
inner_diameter=13.55;
outer_diameter=16;
pitch=2;
turns=5;

union()
{
  cylinder(r=inner_diameter/2,h=(turns+1)*pitch);
  rotate_extrude(a=turns*360,translate=[0,turns*pitch],r=1)
    polygon([
      (inner_diameter/2-pitch,pitch),
      (inner_diameter/2,pitch),
      (outer_diameter/2,pitch/2),
      (inner_diameter/2,0),
      (inner_diameter/2-pitch,0)
    ]);
}

Functions

Many modules in ImplicitCAD accept functions as parameters. This example sets the extrusion height to a function of x and y:

$res=0.05;
linear_extrude(height(x,y)=15+5*cos(x/4)+5*cos(x/2)+5*cos(y/4)+5*cos(y/2))
 circle(r=10);

What It Does

These are just a few examples, you can find more on the project’s website. Besides rounded ‘union()’, ‘difference()’ and ‘intersection()’ transformations, ImplicitCAD also offers rounded primitives such as the ‘cube()’. Some modules accept functions instead of only parameters, which allows creating curved surfaces more efficiently. For more detail, have a look at the API documentation. Unlike OpenSCAD, which relies on the single threaded OpenCSG, ImplicitCAD’s geometry engine renders highly parallelized on multiple cores. Besides STL files, ImplicitCAD exports raytraced PNG images, DXF files and G-Code for laser cutters.

What It Doesn’t

There are still tons of things ImplicitCAD can’t do. It misses a dedicated text module, although text may still be rendered by using polygons. Thanks to the other rounding tools, I can certainly live without ‘minkowski()’, but I really miss the ‘hull()’ module. At the moment, user defined modules can’t process child modules, and the 2D subsystem lacks an ‘offset’ operation. Multiple objects must be combined using ‘union()’ before rendering, and ImplicitCAD apparantly doesn’t do this implicitly.

Potential For 3D Printing

ImplicitCAD extends your 3D printing toolbox by another great tool for modeling parts. However, in 3D printing, we currently rely on a toolchain that first creates mesh approximations of models, and then creates another, even worse approximation of the first one when generating toolpaths, usually G-code. ImplicitCAD has been built with 3D printing in mind and already includes some rough G-Code export functionality. Generating G-Code for 3D printing directly from the model, bypassing the mesh generation, may allow for a faster and more accurate slicing process in the future.

Past And Future Of ImplicitCAD

The development progress has been a bit unsteady, but ImplitCAD’s codebase has always been clean, concise and readable. After Christopher dropped the project and moved on to machine learning, the development idled for a while until Julia Longtin took over as the new maintainer. She now uses ImplicitCAD as a teaching tool for her 3D printing and microcontroller classes at HacDC. The original features are pretty much untouched, but Julia has successfully increased the precision and speed of the geometry engine. She is also trying to fix the browser based editor, which will lower the entry barrier to using ImplicitCAD. By adding comments throughout the code, she aims to make the code more readable for new contributors. Right now, the project is in a “rebuilding year”, and we may have good chances to see it gain new momentum in 2016.

Thanks to [Jasper1984] for the ImplicitCAD script for the open hardware logo used in this posts featured image.

25 thoughts on “ImplicitCAD: Programmatic CAD Built with 3D Printing in Mind

      1. Would it be appropriate, and would you be willing to post a link to the more current Kallithea instance on the github readme?

        I love the promise of this project and want to see it get more traction. It’s the reason I’m learning Haskell in 2017. I hope to be able to contribute to the project soon.

  1. Those geometry features are nice, but a CAD package with no GUI for quick iterative viewing? Get out of here.

    Seems like the rounded boolean operations are 90% of the value here, and there’s no technical reason why that couldn’t be done in the OpenSCAD codebase (other than someone finding the time to do so).

      1. That’s what we used to do in POVRay – very similar to OpenSCAD in terms of being a declarative, text based language to define 3D scenes. I used to use the Moray GUI, which simply was a text editor that could run POVRay in the background and update preview panes as they got rendered.

        POVRay took minutes to render, much like OpenSCAD today, so the workflow would probably be very similar.

    1. When using OpenSCAD I use a more full featured text editor anyway. I keep the GUI open to get the OpenGL previews and the renders when needed.

      The often recommended viewer for ImplicitCAD is Meshlab.

      1. An offset is a super basic operation in CAD, I think you’d normally learn it the first or second hour of a conventional CAD class.

        Oversights like this cause me to wonder how these systems come about, how much experience these programmers of OpenSCAD and ImplicitCAD had in existing platforms before developing their own. If you don’t have any such experience, you’ll have a hard time making something of practical use.

        CAD is hard and complicated.

  2. Sorry, I just checked it out: it’s definetely not using all cores and the cosine extrusion takes a serious amount of time to compile. Well, I think it is seriously faster to make a little octave script and use openscad for that job. But I like it anyway.

  3. Haskell is actually a pretty good fit for the underlying language. It can be very declarative as you can see in the examples.

    And having a full blown language at your proposal can be quite advantageous. Want to create 100 parameterized models of something? No problem

  4. STL is like the JPEG of 3D. No STEP and no IGES means no recommendation.

    Ideally, we want tools that allow an ordinary person to obtain professional skills that can be transferred to other tools.

    I think it is useful, but only after having graphical parametric CAD skills first. It should be used to supplement, not used as a starting point.

  5. I’m a huge nerd and I’ve played with OpenSCAD and more specifically OpenJSCAD a bit and so far my biggest complaints were related to:
    1- spending 3 hours to make a model that would take 2 minutes to make in Adobe Inventor or SolidWorks
    2- producing ugly discretized shapes

    A common workaround to #2 is to leave the resolution of spheres and circles as a parameter when debugging a model and later increasing that parameter before producing the final STL to be printed. Still, a more professional solution is totally welcome. I’m happy to hear about this Implicad because it means someone has had the same thoughts as myself and had the skills to work on a potential solution. It seems the project is somehow stuck though.. any chance to extend OpenSCAD to implement the round geometries?

  6. Has potential but for now I can’t see it being much use outside of perhaps being part of a larger geometry pipeline, where it’s advantages make it appropriate to use.

  7. Well, local install is kind of messy and Linux only. The “Cloud” version seems broken – it perpetually says: “Please hold. Our best server imps are now rendering your file.” But nothing ever gets rendered. Sigh…

  8. These geometrical programming languages – ImplicitCAD as well as OpenSCAD – are a nice toy. Especially for those who are already used to think in algorithms.

    With real world geometries one needs to operate on the visible model. Like clicking vertices, like clicking lines, surfaces. So far the only promising Open Source software for technical CAD I’m aware of is FreeCAD. Quite a bit buggy, but at least on the right track. Try to model the fender of your car with all its beads, holes, seams and you’ll see what I mean.

    1. Yeah, I suspect the extremely low default number is to reduce the pain of a certain complication of the OpenSCAD work flow, that “rendering” the final output is very, very slow. It seems I can design a nicer part in a conventional solid modeling package in the time the OpenSCAD can render the object as a coarsely faceted potato.

  9. The article mentions that ImplicitCAD exports DXF. Anyone know how to do this? extopenscad takes an output format option, -f,–format, but it doesn’t accept dxf.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.