Register
 
DoubleCAD XT v5 has released

(Pro only) A script for generating hex grids
Read 1926 times
May 21, 2009, 02:08:14 PM
This script creates a hexagraphic grid, which I use for a number of purposes.

S = Parameter("HexSize", 1, LINEAR); //size
CL = Parameter("Columns", 2, Set(2,4,6,8,10,12,14,16,18,20));
RW = Parameter("Rows", 2, Set(2,4,6,8,10,12,14,16,18,20));

//Units(1[mm]);
//base hexagon

R = S/(2*cos(30));
A = S*tan(30);
B=2*A


Hex = Polyline( Point(0, R),
                   Point(S/2, A/2),
                   Point(S/2, A/(-2)),
                   Point(0, R*(-1)),
                   Point(S/(-2), A/(-2)),
                   Point(S/(-2), A/2),
                   Point(0, R)
                  );
Col = Move(Hex,S,0,0,1);
G1 = Group(Hex, Col)
Row = Move(G1,S/2,1.5*R,0,1);
G2 = Group(G1,Row);

Col2 = Move(G2,2*S,0,0,CL/2-1);
G3 = Group(G2,Col2);

Row2 = Move(G3,0,3*R,0,RW/2-1);
G4 = Group(G3,Row2);

Output(G4);



Logged