1. 38
  1.  

  2. 9

    I’ve been using OpenSCAD for a few years and have made some pretty complicated parametric designs, but even in Chapter 2 I learned things I didn’t know about!

    Figure 4.: Preview individual geometry parts by temporarily prefixing them with a ! character

    Since our funnel shape is the subtractive part of a difference operation, it is somewhat difficult to model the shape “blindly”. If we prefix the funnel shape with an exclamation mark (!translate( … ) union() …) and run a preview, then only the funnel shape will be drawn and no other geometry (Figure 4.). This selective preview of individual geometry parts is very useful and you will probably use it very often as a modeling aid.

    1. 6

      After messing around with horrible mouse-driven tools like Fusion360 it’s so refreshing to come back to something I can just type into vim and it damn well works. Looking forward to checking out the projects. I’ll likely need them - I’m still quite new to OpenSCAD and using it to design components for my animatronic butterfly jewelry.

      I’ve found SolidPython really useful, since I already think in Python and this makes OpenSCAD a) more OOP and b) easier for me.

      1. 4

        Just sent this to a friend of mine who wants to do 3D printing but hates most existing CAD tools, and now he’s really excited again. Thank you for sharing!

        1. 4

          Really nice document.

          OpenSCAD is a gem for those with little patience with GUI tools. I draw my projects on an iPad and I design on openscad. I just can’t get anything done (on Linux) with libre/freecad, sweethome3d or sketch up …

          I like using an external text editor, so here’s how, from the official doc: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_an_external_Editor_with_OpenSCAD

          1. 2

            Some might be interested in techniques I used for colouring parts, positioning parts differently for preview and printing, and for cutaway view.

            https://www.thingiverse.com/thing:135065

            Back in August 2013, wow, time flies.

            1. 2

              Sounds like a book I want, I’ve been meaning to learn OpenSCAD for ages. Anyone know of a good way to get a dead tree copy in the US without giving Amazon money?

              1. 2

                I mostly design mounting brackets and panels using OpenSCAD, and I’ve frequently run into the problem that a given piece of geometry can’t be described with just an additive or a subtractive operation. Consider, for example, adding a keystone jack to a panel. You need a protruding part for the keystone jack to click into, but you also need an appropriately-sized hole in the panel for the jack to fit into. (Further, that hole isn’t just a simple cube because keystone jacks rotate as they’re installed).

                The pattern that I’ve found is that each type of slot is defined by a module with a “mode” parameter. When that parameter is negative, the module produces the subtractive parts of the geometry; positive produces the additive parts of the geometry, and zero produces a mockup of the part that will go into the slot.

                Then, the top-level geometry has the pattern:

                module slots(mode) {
                  // insert all of the connectors here
                  keystone(mode);
                  translate([60, 0, 0]) d_mount(mode);
                }
                
                difference() {
                  union() {
                    // The basic panel shape, centered on the Y axis
                    translate([0, -15, 0])
                      cube([200, 30, 5]);
                    slots(1);
                  }
                
                  slots(-1);
                }
                
                1. 1

                  Love me some OpenSCAD, I think the paradigm is great but the language has some serious issues. libfive is a promising contender in that field

                  1. 1

                    I’ve been using OpenSCAD for a few years, but I only recently really understood that it’s a pure functional programming language. Since mostly you’re generating objects, and the position of one object doesn’t depend on the previous object, you don’t have to worry about this for most simple use cases. But when you do have dependencies between objects, the only way to use values from object N-1 for object N is through recursion. You can’t change variables and you can’t really iterate (there is a for loop but it’s closer to a map operation).

                    The overall flavor of the language reminds me of R more than anything, since they are both functional languages with syntactic sugar to disguise them as procedural languages. I’m sure the book covers this, but I just thought it was interesting, especially since so many people here are programming language geeks more than they are CAD geeks.

                    At a lower level, OpenSCAD uses CGAL to do all the geometry operations. CGAL is a C++ library that uses templates so it can do the same operations using floating-point or high-precision math* (when you click “Render” OpenSCAD uses high-precision math). One side effect is that relatively simple designs can take a really, really long time to render… I have a vase model that takes over 5 minutes to render on a fast PC, because it’s really exercising the high-precision math operations. Unfortunately this is not tunable, and CGAL isn’t really designed to get decent performance (it is mostly intended for academic research).

                    The biggest problem with OpenSCAD is lack of tools to make non-ellipse curves easily. There are no splines/NURBS at all, which are actually the primary way that professional CAD engineers design objects today. Making a house in OpenSCAD is easy, but making a car or a dinosaur is close to impossible. To do that you’re switching to a traditional CAD or 3D modeling tool and lose all the advantages of a text-based interface.

                    (Technically you could implement arbitrary curves yourself, by computing the points and either drawing a convex hull or a polyhedron around them. It’s a lot of effort and I haven’t seen anyone do it.)

                    (*If you’re wondering why high-precision math is needed for computational geometry – if I have a two boxes next to each other, it is important for manufacturing purposes whether the gap between them is infinitesimally narrow or nonexistent! It’s easy to end up in situations where you have 0-thickness planes and lines even in simple designs. Floating point is not good enough.)

                    1. 1

                      Floating point is good enough.

                      If you have a measurement of something the size of the Earth, the possible imprecision in a standard double precision IEEE floating point number is less than 5 nanometers.

                      1. 1

                        Yes, but a plane that is 1 picometer thick has a fundamentally different topology from one that is 0 picometers thick. Unfortunately, with common designs this happens all the time. (You can put the burden on the designer to fix it, and that’s exactly what simpler CAD tools like OpenJSCAD do.)

                    2. 1

                      Project 3: Window Stopper is genius. Thanks!