standard logo    Personal Education

3D Central


Egguardo Loves Libraries

I was thinking about the approach of spring and it's traditions. I've already done a bunny, so some sort of egg theme seemed appropriate this year.

egg2 egguardo egguardo egg crate



At the same time, I was trying to come to grips with the idea of library files. Making my own egg shape was a challenge. My best effort using hull() around some spheres is "good enough", but it has some slight bumps in the curve. I considered finding out if somebody had developed a useful technique for doing a bezier curve which I could use. Bezier curves are nicely smooth.

While a bezier curve is at least a familiar concept for me from using Inkscape, the vector drawing program I use for making clipart, doing such curves in OpenSCAD involves more math than I was ready to process right now.

bezier curve

All the bezier curve implementations come in libraries which can be downloaded from the Internet and installed on my own computer, and they were more complicated than I was ready to handle. I decided to study bezier curve libraries further and focused on just the library concept this time, making do with the "good enough" egg I had.

There is good news. While looking at bezier libraries, the concepts of libraries, in general, became clearer to me.

OpenSCAD is a labor of love for a small group of programmers. Adding features takes a lot of work and time. I'm using the stable version from 2015 and am very happy with it. A new version is nearing release in 2019. For those who need added tricks, the answer is often modules that have been collected into a "library" file. The tricks are often advanced techniques of OpenSCAD written by skilled OpenSCAD users and then shared on the Web at sites like Github or Thingiverse or Instructables. One of those libraries which contains a bezier offering is called BOSL with an associated set of documentation.

To come to grips with libraries, I decided to try a simple implementation, building a set of component files to use in making an egg-shaped cartoon character. My daughter suggested "Egguardo" for the name. (A cartoon character named "Eggbert" already exists and I've also been told that Egguardo looks much like the M&M peanut character. So be it.)

OpenSCAD Libraries are reusable. In their simplest implementation, a module of code is copied from the library, pasted right into your file and you write the other elements yourself. In the following example, I used a foot() module which I originally used in my clippy character.

  // foot
   module foot(){
   // right foot and leg

   // code continues

Single Module File

The next step in my effort was to make a cartoon hand. I built it as a module (that's just like the way the foot is done above), but this time I saved it as a separate file into the same folder as my current project. Then, writing my version of Egguardo, I began the program with use<hand.scad>. That program command needs to be at the top, before the rest of your code. Then you make the arm and hand something like the next code example.


// right arm and hand


Multi-Module File

Not being satisfied with building only an open hand, I worked on two other hand versions, a pointing hand and a fist. My first thought was to make each a separate file, but finally, the real sense of a library file hit me. All three (or more) hands could be modules in the same file. As I took that step, I also found out that the modules could not have dashes to separate the words. fist() worked fine, but OpenSCAD interpreted the dash in pointing-hand() as a minus sign. At that point, I saw the reason library file modules use underscores in module names. pointing_hand() and open_hand() are workable module names when pulled from a library. While I stopped there for this project, you have probably jumped ahead to understand that the lips modules and the foot module could all be part of a bodyparts.scad library! For me, maybe next time.

"Official" Libraries

There is a folder where your computer stores shared OpenSCAD library files so that everyone using the computer (not just the current user) can call for them. On my Linux computer that is a hidden folder .local/share/OpenSCAD/libraries. I leave it to you to do your own reading to find out where your computer stores the OpenSCAD libraries.

One last note about library modules: any part you make for easy re-use should be designed at the origin, the crossroads of the X, Y and Z axis lines. When you use it in your file, it will move out from there using translate([x,y,z]) and rotate([x,y,z]) the way you expect.

Library Options in Review

You should read much more about OpenSCAD libraries than the information included here. The OpenSCAD help menu will lead you to the documentation. Other people have much more detailed information. Do an Internet search for "OpenSCAD libraries" as a starting point.

In the meantime, I hope you will enjoy making your own combinations of Egguardo and his available parts. Go further and make some more parts. I would love to see photos of your creations! Use the email shown at the bottom of the page.

Available Files:

(In most browsers, right click each file you wish to download and select "save-as" from the menu options.)

The main Egguardo file will not work alone. You will need to download the library files as well AND put all the files into the same folder on your computer.

SCAD files for study/modification and STL files for quick prints. This version does not need added support to print with my Lulzbot Mini.

egguardo-wave.scad - egguardo-wave.stl
egg2.scad - egg2.stl - needs support to print
egg-box.scad - egg-box.stl
hand.scad - a library - no STL
hands-cartoon.scad - a library - no STL
lips-cartoon.scad - a library - no STL
GPL3 License