I'm able to generate an array of objects, 9 x 9 translating the desired distances, by using a pair of nested for loops. Conveniently centered, the 81 items appear as expected.
thick = 5;
pin = 1;
base = 5;
x_spacing = 15;
y_spacing = 20;
module pocket(){
cylinder(h = thick, r1 = pin, r2 = base);
}
module pockets(){
for (col_counter = [-4 : 1 : 4])
//if (col_counter % 4 != 0)
for (row_counter = [-4 : 1 : 4])
translate([col_counter * x_spacing, row_counter * y_spacing, 0])
pocket();
}
pockets();
The commented line does not behave as I'd like, but it does behave as expected, removing the center column and the outer columns. It's an easy matter to reposition the conditional and vanish the rows instead of the columns, but my objective is different.
I'd like to combine the if (col_counter % 4 != 0) and the if (row_counter % 4 != 0) in such a way as to remove only the center pocket() and the corner pocket()s and the edge-centered pocket()s.
I'm not sure of the logic necessary to get only those nine locations ignored/skipped over/bypassed.
This image above was created with a graphics editor and represents the objective.These pocket()s will be subtracted from a larger monolith and the "blank" spots will have other shapes subtracted, in a less challenging approach, I hope.
Is there an if-statement using boolean operators that will exclude the mod_4 locations that can be nested in the loops?