MicroCAD Programs CAD

We love and hate OpenSCAD. As programmers, we like describing objects we want to 3D print or otherwise model. As programmers, we hate all the strange things about OpenSCAD that make it not like a normal programming language. Maybe µCAD (or Microcad) is the answer. This new entry in the field lets you build things programmatically and is written in Rust.

In fact, the only way to get it right now is to build it from source using cargo. Assuming you already have Rust, that’s not hard. Simply enter: cargo install microcad. If you don’t already have Rust, well, then that’s a problem. However, we did try to build it, and despite having the native library libmanifold available, Rust couldn’t find it. You might have better luck.

You can get a feel for the language by going through one of the tutorials, like the one for building a LEGO-like shape. Here’s a bit of code from that tutorial:


use std::geo2d::*;
use std::ops::*;

const SPACING = 8mm;

op grid(columns: Integer, rows: Integer) {
@input
.translate(x = [1..columns] * SPACING, y = [1..rows] * SPACING)
.align()
}

sketch Base(
columns: Integer,
rows: Integer,
width: Length,
height: Length
) {
thickness = 1.2mm;
frame = Frame(width, height, thickness);
struts = Ring(outer_d = 6.51mm, inner_d = 4.8mm)
.grid(columns = columns-1, rows = rows-1);
frame | struts;
}

There are proper functions, support for 2D sketches and 3D objects, and even a VSCode extension.

Will you try it? If we can get it to build, we will. Meanwhile, there’s always OpenSCAD. Even TinkerCAD can do some parametric modeling.

23 thoughts on “MicroCAD Programs CAD

  1. Does Ai knows this new language? considering it’s just Alpha Release 0.2.14
    probably not. Someone should just make good OS AI CAD

    1. To each their own, but I’m asking if it does chamfers. :)

      It’s code — you either wrote the fillet function yourself, copied it off the interwebs somewhere, or are using someone’s fillet library.

      1. Nope, it’s not that simple. You need BREP representation to do “surface dress-up” features such as fillets, chamfers, drafts and face offsets. If it uses a strictly CSG representation then it can only do the aforementioned features (with extra work to convert the surface dressup operators into volumetric subtraction operations in very trivial cases.)
        In more complex cases, such as when you neted tangent propagation across a non-planar wire of edges then you can’t do it by “just coding your own” you’d effectively have to write your own tiny BREP kernel.

        1. Those tend to rely on the Open Cascade geometric kernel, I think FreeCad also uses the same one. It’s the kernel that does all the actual calculations with things like CadQuery being a frontend to it.

  2. It seems to use the same geometry library as OpenSCAD, so it is equally limited in not being able to output true curves to .step. Just a different syntax to make sure you can’t take advantage of the huge amount of already existing OpenSCAD scripts.

    One of the greatest features of OpenSCAD is the quick preview through libopencsg. Does MicroCAD have that?

  3. In their page there’s a blog post saying about a bug stopping builds from working. But from what I could understand, it’s already solved. I’ll try to play with it after work

  4. But cargo’s over-complication and excessive dependencies isn’t a problem because it always just works :)

    I’ve seen a handful of versions of this kind of approach, where the “scripted cad language” is just a regular programming language with a library of useful primitives. I understand the draw of this approach but i’m not interested in it myself. Especially with a moving target like Rust. It makes it too hard to even implicitly standardize the CAD language. The opportunity for whacky and delicate idioms is too large. The demarcation between internal details and user-facing language features is too murky. The ability to fundamentally restructure the rendering pipeline without changing the input language is almost completely eliminated (and has been a huge source of profit lately for OpenSCAD).

    Say what you want about OpenSCAD, but even though i have a few models that rely on relatively new versions of openscad…all my old models still build with the newest version. I like that.

    The longer i use it, the less i chafe against its limits…they’re odd at first but ultimately not that hard for me to work around. I’m demonstrating my attachment to the tool i know over the tool i don’t :)

    1. Nah, all of these “openSCAD but with better syntax” proiects are a waste of time better spent making OCCT actually usable.

      Build123D is the ONLY one that actually justifies its existence because they realized openSCAD doesnt only suffer from a syntax problem, it suffers from a representation problem. B123D lets you have both feature stack modelling AND CSG tree modelling, and, crucially, you can combine both these workflows.

  5. As a programmer, I quickly ran into limitations with OpenSCAD. It really got bogged down on more complex models. Granted, that was over a decade ago, so I don’t know if that got fixed or not. I switched to using a parametric CAD program (Fusion for a while, but have tried FreeCAD over the years, and start switching over completely since the 1.0 release). If I really wanted to go back to programming my CAD models, I would just use Python inside of FreeCAD to do it.

  6. I love OpenScad language. It is clean descriptive and functional. I programmed in Python before Openscad and yearned for some imperative language features but “let” in functions and comphensions but now I dont. That you cant re-assign variables took a bit of getting used to but now I think it is probably a good thing. Functions can be recursive.

    What would I like? 1. More introspection. 2, Modules are not functions and geometry is just a “side effect”. I would be great if modules returned geometry but something like this is in the BOSL2 library.

  7. I am both a programmer and a language designer who doesn’t hate OpenSCAD. The very first time I used it, I was able to quickly build a pretty cool, fully parametric model, “rigging” that my son used for his animation project. The model was both dramatically more complicated and more convenient to write than I would have been able to do using parametric CAD software like SolidWorks. What is important to note is that OpenSCAD is a representation language not a programming language. You write “functions” that are more like macros, and these get “macro-expanded” into your 3D model with just enough ability to computate dimensions, solids, and coordinate frames along the way. Sure, I silently griped a bit while I was building my model, but if I had to do it again, I’d use OpenSCAD before I’d ever consider ramping up on a WYSIWYG CAD program again. Too much to learn, too little time.

    1. P.S. I have to imagine that there are some clever folks who write Python code (or other popular “real” programming language) that generates OpenSCAD code. If so, I’d love to hear about it.

  8. Been working on an early stage BREP kernel my self. https://github.com/mmiscool/BREP
    I can’t live with modeling that dose not have faces and edges. Using the manifold 3d library in that also. For doing all the boolean operations. Works great. I had to make my own abstractions for the rest of it to have proper faces and edges. Also been working on doing fillets on meshes. Getting surprising good results.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

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