[OpenSCAD] Missing operators

andy@kirbyand.co.uk andy at kirbyand.co.uk
Mon Sep 13 16:19:26 CEST 2010

OK Guys

The code segment I promised. The commented out bit in the middle is the
bit I need to arrange the objects so that they union into the right
shape. A cell is a haxagonal object think of it as a tube. An array is a
unioned diagonal array of cells starting lower right and growing up and
left by the number of items it is told to make.

The tile then is a union of arrays.

All in all easy enough to do with sufficient support from the scripting
language. It is made messy by the way that a hexagonal array doesn't
have a neat east equation that describes it and can fit into the
translate statement.

I think though that irregular matrices of objects is something that
OpenSCAD will need to support at some time, some way or other.

An explicit assign function would do for now.

   module to create a haxagonal tile of hexagonal cells
   that can teselate to make a larger array of cells
   cells are h high and of characterisitc radius r
module tile( h, r, w, m){

   arrx = m;
   arry = 0;
   arrsize = m;

  // if module size is only 1 just draw it at the origin
   if(m == 1) {
      // move to origin and draw one cell
      translate(v = [0,0,0]) {
         cell( h, r, w);
   } else {
      //create a tesselating tile of module m units per side
      union( ) {
         // union together a bunch of arrays of single cells
         for( i = [0:hexdia] ){
            translate(v = [dispx * arrx,dispy * arry,0])  array( h, r,
w, arrsize);
            if( arrx > 0 ){
               arrx =  arrx -1;
            if( arry < m) (
               arry = arry + 1;
            } else {
               arry = arry + 2;

More information about the OpenSCAD mailing list