62 comments

[ 3.5 ms ] story [ 115 ms ] thread
I keep finding myself falling back on OpenSCAD when trying to 3D model after getting frustrated with steep learning curve advanced CAD programs.

Even if you don't like the OpenSCAD DSL (it got it's quirks..) there are usually other options in more familiar languages. I use it via Clojure[1]. It's pretty fun, even for small stupid things like coding up a rolling oloid[2].

[1]: https://github.com/farrellm/scad-clj

[2]: https://www.youtube.com/watch?v=wXE3L8EU5U4

> Even if you don't like the OpenSCAD DSL

I've actually been working on making the DSL language modular so that you could use it with any programming language (given bindings)

Years ago I kept having trouble with openscad - even relatively simple loops would seemingly hang or use massive amounts of memory or give wired errors. Changing some tiny thing in the file would suddenly fix it, only for it to break again with a totally unrelated change.

It was as if it uses some stochastic algorithm that sometimes doesn't converge...

I think OpenSCAD is great compared to other options I've tried. My primary issue with OpenSCAD is that everything is a set of 4 sided polygons. If I want a sphere with decent resolution I need an absurd number of faces. It's slow to process/render, makes a large output file, and doesn't result in resolution I'm that happy with.
When I played around with 3d printers a number of years back, I tried a few free programs such as Blender, FreeCAD and Sketchup, but I found OpenSCAD for modeling and Meshlab for post-processing to be the best pipeline for my needs. OpenSCAD is particularly effective for making replacement parts where precision is more important than aesthetics. However I did find ways to have fun with it, such as building a printable dragon fractal: https://s3.amazonaws.com/www.subalpinetech.com/images/dragon... https://s3.amazonaws.com/www.subalpinetech.com/images/dragon...
I've been using OpenSCAD for personal projects for a couple of months, generally preparing models for 3D FDM printing. I'm a mechanical engineer by profession and a certified Solidworks professional. I'd estimate that designing in OpenSCAD - as in, modelling something up and iterating on the design as my understanding of the application develops and prototypes are trialled - takes me four to fives times as long as using commercial parametric 3D CAD that I'm already familiar with.

That's not a damning critique, but it is something I'd advise a friend or colleague who had a project to get on with. I'm still highly positive about OpenSCAD, because of its openness, its versatility, and the potential for using great programmers' tools (library code, scripting languages and version control) to make it much more powerful.

I've been working with vanilla OpenSCAD, downloading a few functions from people, and building little libraries of helper functions. Getting more familiar all along, figuring out the right way to do things. Some people have got a little further with creating scaffolding for mechanical design - projects like MCAD and OMDL. Of course, OpenSCAD is very versatile and people have many other uses for it. But I think when someone comes along and creates some really great libraries and frameworks on top of OpenSCAD - like LaTeX on top of TeX or Jupyter on top of iPython on top of Python - it would be suitable for any kind of design, competitive with the best GUI-based packages.

I can appreciate that point of view given your background.

However, as a programmer who dabbles in 3d printing / 2.5d CNC routing, I have the exact opposite experience. I spend a lot of time in Fusion 360 just battling the software because for some dumb reason it decided to align the top of my part with the bottom of the other when I actually wanted everything in the same plane.

OpenSCAD just makes a lot more sense to my programmer brain, and I'm often much more productive in it.

However, beyond the obvious graphical VS text interface, there's another significant difference between the two: OpenSCAD's base concept is making operations (add / subtract) on solid primitives (prisms, cylinders, spheres) whereas Fusion360 is based on 2d sketches that you extrude. That latter model works very well with a CNC router & plywood.

Funny thing is, also as a programmer, I find openSCAD annoying. I really want object-oriented objects. I want to be able to declare a cube and then refer to its corners. I want to be able to make a cylinder from point A to point B. Instead, everything is contextual and implicit, and there's no other way of doing anything.

I'm sure you can get used to it eventually. But I think we could do better in terms of 'cad designed by programmers'

I really like the idea of openSCAD, in fact I use it exclusively for 3D modeling. My biggest problem with it is the language implementation. Things like:

    x = 5;
    cylinder(d = x, h=10);
    x = 20;
Well, this will make a cylinder with a diameter of 20 instead of the expected value of 5. Yes, I'm familiar with various programming models and the idea of immutable variables. But when you have a language that looks and feels like something else familiar, this behavior can throw you for a loop.
This.

When I was using OpenSCAD about 10 years ago, I immediately found it very intuitive and easy to use for simple things. But for anything complex, I ran into this sort of thing constantly. At the time the documentation of the language mentioned such issues, but failed to specify the language completely, leaving lots of ambiguous cases that I just had to try out to see what would happen. The behavior really seemed to be something that just agglomerated as the author had added features, rather than something planned with a design philosophy behind it. I found it hard to work around and plan more complex shapes as a result. I haven't been back to look at the docs in ages; perhaps it's better-specified now.

I ended up doing my more complex stuff in an OpenSCAD clone I hacked together on top of https://evanw.github.io/csg.js/ until I ran into problems with non-manifold surfaces. Simple problems I could repair, but that library's really only intended for visualizations, not generating STLs for printing, so eventually I went beyond what I could fix.

So then I wrote an implicit surface renderer [also in JS] using https://github.com/mikolalysenko/surface-nets, and that was less-precise, and a bit limited [my code, not theirs], but got the job done. A short while later, I found implicitcad.org, and saw what I could have written, had I had just one more epiphany. I've never used it, but I like the philosophy behind it, and that may be what I try when I get back to 3D printing.

This is because you're expecting it to be an imperative language. It's not.

OpenSCAD really should throw an error on compile if you try to redefine variables, but its intent is a declarative language. Once you think of it as such, most of its design choices start to make sense.

I fully expected it to be an error. It should be an error.

In a declarative languages, one should not be able to update variables. In some contexts, rebiding makes sense, but not on OpenSCAD either.

As I understand it, This is how most traditional cad programs work if you work with their command line interface
Yes.

I've created a few small things in OpenSCAD. To build up a part, I haven't found a better way than just keep adding up the width of the subcomponents to get the origin of the next piece.

It is manageable for me, and I find traditional CAD programs difficult, so I'll keep using it. But I want a better way to do all this.

I strongly recommend taking a look at SolveSpace[1] and doing at least the first tutorial. It takes maybe 30 minutes and gets you knowing enough to be dangerous. SolveSpace is missing a lot of advanced features, but is reliable and quite adequate for many practical parts you might wish to print or CNC.

[1] http://solvespace.com/index.pl

>Funny thing is, also as a programmer, I find openSCAD annoying. I really want object-oriented objects

Have you tried OpenJSCAD? It's OpenSCAD meets Javascript.

Now, to address the things you mentioned:

>I want to be able to make a cylinder from point A to point B.

You can write a function that does it in OpenSCAD already

> I want to be able to declare a cube and then refer to its corners.

Referring to vertices of a solid in general seems to be incompatible with OpenSCAD's paradigm of modeling with boolean operations. You don't know where the vertices are until you render.

You can already write a helper function which returns you the vertices of a cube. More than that, you would need another tool. It's not about syntax, to my understanding.

[1]https://openjscad.org/

Haven't tried OpenJSCAD - thanks for the reference.

> Referring to vertices of a solid in general seems to be incompatible with OpenSCAD's paradigm of modeling with boolean operations. You don't know where the vertices are until you render.

Is it? Well I suppose it is in the general case. It would be hard to refer to an edge that has been created as a result of some difference operation. But the corners of a cube are still valid reference points even if they've been chopped off, and aren't part of the final solid.

I guess so, but I find it a mild inconvenience personally. I'd struggle to come up with an example where it would be a deal-breaker. Could you write about how you'd use it?

Incidentally, I ended up needing a function that places a cylinder between two points in OpenSCAD yesterday.

Here is my implementation - might come in handy!

    // Transpose of matrix A (swap rows and columns)
    function transpose(A) = [for (j = [0:len(A[0])-1]) [for(i = [0:len(A)-1]) A[i][j]]];

    //  Cylinder of radius r from P to Q
    module cyl_between(P, Q, r){
        v = Q - P;    // vector from P to Q
        L = norm(v);  // height of the cylnder = dist(P, Q) 
        c = v / L;    // unit vector: direction from P to Q    
        is_c_vertical = ( 1 - abs(c * [0, 0, 1]) < 1e-6); //is c parallel to z axis?
        u = is_c_vertical ? [1, 0, 0] : cross([0, 0, 1], c); // normal to c and Z axis
        a = u / norm(u); // unit vector normal to c and the Z axis
        b = cross(c, a); // unit vector normal to a and b
        // [a, b, c] is an orthonormal basis, i.e. the rotation matrix; P is the translation
        MT = [a, b, c, P]; // the transformation matrix
        M = transpose(MT); // OpenSCAD wants vectors in columns, so we need to transpose
        multmatrix(M)
            cylinder(h=L, r=r, $fn=24);        
    }
I used OpenSCAD almost exclusively for 5 years (Mech E by degree, but computer programmer by profession) and switched to Fusion360 in the last 3 months.

For me, within 6 hours Fusion was night and day more productive (even after a lot of experience in OpenSCAD). As one example, it was so much more productive that I can think of only 2 OpenSCAD designs in 5 years where I bothered to add fillets for strength and appearance. It's just too damn much trouble.

In Fusion360, I'll often have a simple part whipped up in 15 minutes and then spend 1 extra minute adding fillets and chamfers as needed. In OpenSCAD, that same part would likely be 30 minutes for the base part and the fillets another 15-30 minutes (with fairly poor performance once added).

My experience with Fusion for 3d printing is basically: looks great, is fast but my models fail to print correctly for some reason.

Can't wait for freecad to get a useable UI, because it is works fairly well for printing despite its UX shortcomings

My email's in my profile. If you have some examples of what didn't work well for you, I'm happy to have a look and see if I can get you unstuck and headed to success.

If it's a calibration issue on the printer (parts print, but are slightly the wrong size), I can recommend Teaching Tech's intro here and here:

https://teachingtechyt.github.io/calibration.html

https://www.youtube.com/watch?v=rp3r921DBGI

If it's in the Fusion->STL stage, I might be able to be of more help. If it's in the STL->physical part stage, the above or other 3DP videos might help.

I wiped the computer used for this whole ago, but the models are probably on the cloud somewhere.

My problem was that the produced STL had some errors that were hard to see but definitely showed up in prints, for example a wall section could be missing.

are you certain the STL stage had the error?

In the 3dp discords i'm a part of it seems that i'm continually reminding everyone that slicer features are usually the culprit. Features like 'detect thin walls', 'ensure vertical thickness' and 'extra perimeters if needed' can and will very quickly ruin a print where the STL is error-free.

That said, one can accomodate these features by modifying the STL so that the slicer transformation occurs in such a way that allows a usable product, but as far as where the error is introduced, 9 times out of 10 it's the slicer.

What should happen is that the slicer should err out to the user when the shape of the end product is predicted to be radically different than the request, but I haven't ran into such features yet. Most slicers just happily try to print stuff that is physically impossible to do, and might be radically different than the shape of the STL -- usually resulting in a plate of spaghetti if you're using an FDM machine.

Your slicing software should warn you if the model is non-manifold.

https://www.instructables.com/id/Non-manifolds-Your-Worst-3D...

Yeah, but there question is why fusion360 created such files. Similar designs in other tools worked just fine.

I've some years of experience with CAD and know often what causes such issues but in the case of fusion360 I just couldn't figure out why this happened - in sometimes extremely simple models.

I haven't used fusion360 for about a year so maybe they have fixed the bugs now.

That's fair enough. It's unfortunate that adding fillets is a big design change in OpenSCAD while it's something you can easily add last-thing in other packages.

Because it's so programmable, most things can be made fairly easy if you think of them in time, by writing procedures, once. I'm interested, actually: I would have thought that long-time users would have developed some sort of tip or trick for this, recognising at the start the kinds of changes that might be difficult to make laters and planning them in at the start. Maybe internal rounded corners are just too much hassle any way you look at it.

I never found a good way to semi-automatically do fillets. I did get good at many other kinds of manipulations, using the ! and % operators to help me "see what I'm doing", etc.

If you need boolean ops on cubes, cones, and spheres, OpenSCAD is great. If you need fillets on an oblique cylinder that intersects a curved surface, you're in for a much longer walk.

I have to admit that I’m not-so-secretly hoping someone will post “hey, here’s my secret to easy fillets in OpenSCAD” and I can learn a new trick.

For fillets / chamfers of simple objects I've been using BOSL2:

https://github.com/revarbat/BOSL2

They come with fillet / chamfer masks, but in general I've been just using their cylinder / cube replacements that generate rounded intenral corners, and just diff'ing them out of existing shapes.

In general, I've gotten a long way by just starting with chamfered/filleted shapes (the library includes a neat way of specifying which edges of the shapes you want filleted), and using the intersection / difference of filleted cubes, cones, and cylinders.

Intersections on curved surfaces seem impossible any way of looking at it (minus some projection nonsense, but that's expensive in openscad)

I started modeling in OpenSCAD. It fit really well with my programmer mentality. The language is small, the concepts simple and you can do some really amazing things with it, far more than might be obvious from the primitives... except filleting and chamfering.

The limitations caught up really quickly after that.

I echo what the other folks are saying. Its great, but there is no "I knocked this out in 10 minutes in OpenSCAD" for any part that couldn't be done in less time in TinkerCAD.

Its difficult to imagine how you could fix this elegantly. "Pick a path that follows the intersection of these two solids" is difficult to express in code, and easy to express by clicking on the vectors that represent the path.

It ain't perfect, but as a software guy with a 3D printer and almost no mechanical knowledge whatsoever, it has allowed me to make some things I'm really happy with, including this project I completed fairly recently:

https://imgur.com/gallery/RpY5WEe

Before I moved on to Fusion 360, I remember the only sane way to fillet the edges in OpenSCAD was to apply the Minkowski function. Of course, that has to be the absolutely last thing that you do with the model, because the perf after minkowski was truly horrifying, n many cases taking more time than the subsequent 3D printing. Has anything changed since?
My desktop is an Intel 3700K overclocked to 4.1 GHz. So fast, but also ancient compared to modern CPUs. I have no issue designing models with many minkowski functions applied to them. The final build before export can take ~30s but that doesn't bother me.
If you use openSCAD for 3d printing then you'll love hob3l

It takes OpenSCAD files and generates meshes vastly faster for complex models.

https://github.com/moehriegitt/hob3l

This might come handy, thanks!

A lot of big name 3d printing software are really badly written and perform horribly on complex models.

I love OpenSCAD. I use it for all personal projects in 3D printing at home.

I use SolidWorks for work. The contrast between these two is incredibly striking. OpenSCAD is like a bicycle in comparison to an automobile.

It would provide literally billions (maybe tens or hundreds of billions) of dollars of value to the world if a few million dollars was spent developing an open source CAD/CAM package that was more than a mere bicycle and that wasn't terrible (sorry, FreeCAD, but we both know it's true). There needs to be an indiegogo campaign or something.

I would check out SolveSpace for some of your personal projects. It is no SolidWorks but it is a parametric CAD program that works well, within its limitations. Very lightweight and not as crashy as FreeCAD.

If your part doesn't need lofts, NURBs, extrude-along-path, you can probably design it about as fast in SolveSpace as in SW, and with a similar mindset (vs. having to shift completely into programmer-mode for OpenSCAD).

e.g. Hood of a car? No way José, can't be done. Crankshaft and pistons? Easy.

Used a whole lot of openscad to design and print my own version of the mpcnc, but recently i switched to the much simpler tinkercad because openscad was just not productive enough.
I have used OpenSCAD for a while. I should write a more thoughtful critique but ... dang, it is often hard to know which approach will just dramatically consume days of CPU time and which will not. I suppose one gets a feel for it eventually.

Modeling objects in my head parametrically is a snap.

The language is a bit clunky and counter-intuitive but I have gotten used to it. I do not mind its imperative nature; adding and subtracting material is imperative at its heart. Still, it makes more abstract reference points more difficult.

I found myself resorting to hacks like moving one object .001 into another object just to make sure they would meld smoothly.

The underlying library, last I checked, did not support multi-threading so the aforementioned CPU consumption is especially painful.

Exporting to giant .STL files is a little annoying. Sometimes the .STL files are "broken" according to Shapeways, so that is also bothersome.

Yeah I wanted to make a small change to Prusa's mk2/s extruder a long time ago. Rendering that design takes five or six minutes on my relatively-fast desktop, and it's an extremely simple thing. It was not clear to me why it was so slow.

In general I see OpenSCAD as a fun toy for making software-generated artwork, but not as a serious tool to make real things.

IMO, I think if OpenSCAD somehow had an assembly feature it would really make it more attractive for users who are programmers to switch from the likes of Fusion360 etc.
What do you mean 'assembly' feature ?
The classic example is wheels on a car. You model one wheel with tire, rim, bolts, etc., then create 4 "instances", at different locations, that are references to the wheel. A tremendous boon for correctness and productivity. Imagine a programming language where you could only copy objects by value, no pointers or references.
"Assembly" as in if you have multiple parts in Fusion360 etc, you can select components and put them together by forming constraints. E.g. a screw into a mount hole with a nut on the other side. Expensive CAD software makes this relatively easy, you just select the objects and define the constraints. This is lacking in CAD software like FreeCAD (not very well supported), TinkerCad (where you have to create throw away objects), OpenScad is equally not easy, you have to manually position the objects and line them up in code to "assemble" them.
You can make 'modules', little repeatable chunks that can be replicated or turned on or turned off etc. OpenSCAD is programming so a 'module' is a 'function' or 'procedure' in other langs. My multi-part assembly is a bunch of modules that I have in one configuration for fit designing and one configuration for printing.
Years ago, I worked at a factory that had thousands of variations of a large, heavy product, some dating back to the 60s. This product has multiple units packed for shipping on pallets and random scrap pieces of wood and then strapped down like some sort of Jenga puzzle.

I created a generic OpenSCAD model for the product, and fed in parameters derrived from more than a dozen data sources to generate a model for every variation. Then, took the 90th percentile by production numbers, and overlaid the models to show the boundaries of the variations as one model. That shape was then used to generate stack-able, vacuum-formed trays to hold the product.

I had a couple of expensive 3D CAD products at my disposal there, but OpenSCAD was the solution I needed to programatically crank out models. That's how my foray into programming started and my career shifted from Manufacturing Engineering to Software. Thanks OpenSCAD team!

I really wish it supported multi threading
I do a bunch of random little things on my CNC router -- mostly I make and sell wood handgun grips.

I used 4 open-source CAD programs before finally just concluding I need SolidWorks to do serious modeling. But I do still use one of the open source alternatives sometimes.

* Blender

OK, technically I didn't really give this a try for CAD. I had used it in the past for scene modeling and I knew it was extremely powerful for that but a huge pain for doing CAD-type work. Doing CAD with triangle meshes is total madness, CSG is the only way to go.

* OpenSCAD

I'll write the most about this because it's the subject of the article. If you come into this from a Blender background, it is awesome: finally I can define my model with a few key parameters, and have the program generate all the other dimensions from there! And CSG makes way more sense than meshes -- I can make a box, then put a hole through that box, then cut a countersink on that hole. Awesome.

But all the other parametric CAD programs have that stuff too. You've got constraints in sketches, support for formulas in equations, and templating features like linear patterns. So you can typically get the same level of flexibility where if you want to change your model in a big way, you just edit the few dimensions from which all else is derived. There are cases where you can't "program" your model in terms of those 3 common CAD features, while you can in an OpenSCAD file. But they are few and far between.

And the way the other programs do it is not only easier to "write" by clicking buttons on a UI, but much, much easier to "read" by viewing the sketch drawing. You can see how a sketch is defined a lot faster than you can understand the OpenSCAD code that does the same thing. Trying to revisit an old OpenSCAD project has a steep learning curve.

I really did fall in love with this way of defining models for a short time, but I realized that I was making more work for myself when the models I get out of other parametric CAD tools are equally "programmable" for practical purposes.

* FreeCAD

First thoughts: Wow! This thing is pretty cool! I found the default controls for moving the view a little "off" based on my past experience but that's easy to adjust to. And at first, FreeCAD is really impressive because it brings complex features to the table like "loft", which is something I really missed from SolidWorks. It's almost a must-have for my grip designs.

The main problem I had with FreeCAD is that it just breaks too often. When I started making complex designs using those features I loved so much, FreeCAD would get unstable. It's very frustrating to work on parts when the editor keeps crashing, sometimes mid-save corrupting the current file. I would have to go back to the drawing board and try another way of defining the same shape in hopes that FreeCAD liked the new way better. Ultimately I just got too annoyed by it. Also, I really wished that I could use guide curves for lofts -- but here I am asking them both to make a complex feature MORE complex AND to fix the existing bugs with it, which is a really tall order.

FreeCAD is an amazing achievement for volunteer work but it's not useful to me.

* SolveSpace

With its unconventional looking UI, this seemed like it was going to be one of those idiosyncratic open source programs like Blender or GIMP where you spend half the time just cursing them out for doing things a weird way and making you learn it.

On the contrary, once I worked through the first tutorial on their official website, I felt like I had a pretty good understanding of the program. Some stuff like defining new workplanes was still a bit confusing, but I got the hang of it. The shortcut keys are super handy and easy to learn by hovering the buttons. Best of all, SolveSpace is fast and usually stable -- though you can get it to stack overflow, sometimes on save, by turning up the modeling resolution too far.

This lacks a...

OpenSCAD is my favourite programming language. I love the visual feedback, the quirky bugs, and the strict, functional nature of it. Learning OpenSCAD helped me really understand functional programming.

The documentation is also great. Once you have a basic grasp, this page is basically all you need.

https://www.openscad.org/cheatsheet/

Edit: Psych, you also need this:

https://en.wikipedia.org/wiki/List_of_trigonometric_identiti...

I've neglected this project, but I'm working on a library to make one's reasoning more explicit by providing math utilities.

https://github.com/MaxBondABE/batteries

OpenSCAD is really cool, but sadly very poorly implemented and very very slow. One can bring modern machine to it's knees for minutes rendering 10 cylinders in 10 cylinders in 10 cylinders. It's basically only appropriate for making a single parametric shape, but it's great for that job.