[OpenSCAD] Accumulating variable in openSCAD

Philip Jones philip.h.jones at btinternet.com
Mon Oct 22 04:49:55 EDT 2018


I'm new here, so thanks for adding me to the list.


I would like some advice on how to achieve something in openSCAD programming
language. I want to put a row of holes into something where each hole is
larger than the last and with the holes spaced apart by the diameter of the
previous hole (basically a drill size guide).


Something like:



  cube([90, 30, 5]);

  offset = 0;

  for (a = [0: 1: 20])


    dia = 1.0+(a/10.0);

    offset = 4 + (2 * dia);

    translate([offset, 4, -1])


      cylinder(h=7, d=dia);





This produces a row of holes of increasing size, but the increasing offset
doesn't work. I think I read that autoSCAD doesn't have "variables" like
other programming languages (clearly 'offset' isn't working how I am
expecting it to) but not being an expert (except perhaps in 'C' which I've
used for about 30 years) I don't really know what that means or how to write
something that would work.


Any advice, or code example would be gratefully received.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20181022/f1ff3153/attachment.html>

More information about the Discuss mailing list