Liking cljdoc? Tell your friends :D

scad-tarmi: Commonplace items for scad-clj

This is a Clojure library of miscellaneous abstractions and conveniences for use in CAD work with Matthew Farrell’s scad-clj.

Clojars Project

The Lojban word tarmi refers to a conceptual shape.

Usage

The core module is trivial, meant only to reduce boilerplate.

The util module contains a few utilities that leverage the power of Clojure to do fairly common CAD operations with OpenSCAD primitives. It has a loft function, but please read the fine print.

Three families of drop-in replacements

The maybe module is very simple: It carries drop-in replacements for scad-clj functions that will produce as little output as possible, for slightly shorter OpenSCAD artefacts.

The reckon and flex modules also contain drop-in replacements, but for the purpose of reasoning about what a model will look like. reckon has numeric versions of OpenSCAD operations. flex uses either reckon or standard scad-clj functions depending on input.

Design for manufacturability

The dfm module exposes an error-fn function.

This simple function represents a compromise between several concerns in DFM for ordinary 3D printers. It is based on these assumptions:

  • The target printer is correctly calibrated, but the combination of printer firmware and slicer software causes printed models to be larger than indicated by their blueprint: A measurable error.

  • z-level accuracy is beyond software control, as in FDM.

  • The size of the error is absolute for a given combination of printer nozzle, flow rate, material properties, temperature, cooling method etc. Thus, unlike errors due to a process of annealing, the size of the error predicted by error-fn does not itself vary with the size of the printed part, except at very small multiples of the nozzle diameter.

  • The size of the error is about twice as big on the inside of a gap in the model as it is on the outside. In other words, if the outside diameter of a model grows by 0.1 mm in printing, a hole (i.e. negative space) in that model, caused by a difference() operation in OpenSCAD, will shrink by 0.2 mm.

These assumptions, and default values applied in error-fn, are based on tests of a LulzBot TAZ 6, an FDM printer with a 0.5 mm nozzle, running its default Marlin firmware (version current as of 2018-11), slicing in Cura (LulzBot edition, v3.2) and printing PLA at 100% flow. Results will vary with other printers, slicers and materials. Measure the size of your error with a test print and pass it to error-fn to get a compensator.

Lastly, error-fn assumes that negative space will be used to fit other parts, such as threaded fasteners, where dimensions are sensitive. Therefore, negative space is the primary use case. error-fn primarily expects a negative value as a measurement of error and will assume that any passed nominal measurement passed to a compensator should be enlarged.

Threaded fasteners

The threaded module describes threaded fasteners using the core, maybe and dfm modules.

If in your ns declaration you (:require [scad-tarmi.threaded :refer [nut]]), you can then call (nut :iso-size 6) for an ISO 262 M6 hex nut. Its height and diameter are inferred from the standard, unless you pass overrides. It is internally threaded.

Models of fasteners, as produced by this library, are neither perfectly accurate with respect to standards, nor engineered for ease of printing. Their main purpose is to form negative space: Relatively simple shapes used to carve out screw holes, nut pockets and similar cavities in 3D-printable designs. These holes would then be filled by ordinary steel nuts and bolts in the assembly of your product.

If you do intend to model an M6 nut to carve out negative space for a real nut, the call would be (nut :iso-size 6 :negative true), a less complicated shape.

Either way, you will need to use scad-clj to produce OpenSCAD code for the object. Check the showcase code for examples of how to do that. A selection of the models produced by that code are shown here.

Acknowledgements

The thread-drawing function (threaded/thread) is a reimplementation in Clojure of a corresponding function in polyScrewThread_r1.scad, created by aubenc at Thingiverse and released by the author into the public domain.

License

Copyright © 2018-2019 Viktor Eikman

This software is distributed under the Eclipse Public License, (EPL) v2.0 or any later version thereof. This software may also be made available under the GNU General Public License (GPL), v3.0 or any later version thereof, as a secondary license hereby granted under the terms of the EPL.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close