acorn: add option to control generated parts
[clinton/3d-models.git] / acorn / acorn-threads.scad
index 1abc99e..50eb524 100644 (file)
@@ -5,10 +5,15 @@ use <screw_threads.scad> // http://www.thingiverse.com/thing:1686322
 
 AUTO_CALCULATE = -1;
 
+acorn_parts = [ "body", "cap", "gasket" ];
+
 internal_thread_tolerance = 0.3;
 external_thread_tolerance = 0.2;
 thread_angle = 50;
 
+
+function contains (x, lst) = len([ for (i = lst) if (x == i) i]) > 0;
+
 module acorn (thread_pitch = 3.0,
              thread_size = 2.5,
              thread_height = 3.5,
@@ -98,9 +103,12 @@ module acorn (thread_pitch = 3.0,
      }
 
      module nuts () {
-         translate ([outer_d+10, 0, 0,])  nut ();
-         cap ();
-         translate ([-(outer_d+10), 0, 0,])  gasket ();
+         if (contains ("body", acorn_parts))
+              translate ([outer_d+10, 0, 0,])  nut ();
+         if (contains ("cap", acorn_parts))
+              cap ();
+         if (contains ("gasket", acorn_parts))
+             translate ([-(outer_d+10), 0, 0,])  gasket ();
      }
 
      nuts ();