// Hex. grid of polys and optionally, lines! proc genHex(float $xCen, float $yCen, float $hexRad) { string $tst[]; // Gen. geom. $cmdToExec = "polyCreateFacet "; $spareCmd = "curve -d 1 "; print("# Simple polys\n"); print("Polygon \"P\" ["); for($i=0;$i<6;$i++) { float $ang = $i*60*3.14159278/180.; $x = $hexRad*cos($ang); $y = $hexRad*sin($ang); $z = 0.0; $zCurv = 0.01; $cmdToExec += "-p " + $x + " " + $y + " " + $z + " "; $spareCmd += "-p " + $x + " " + $y + " " + $zCurv + " "; print($x + " " + $y + " " + $z + " "); } print("]\n"); $tst = `evalEcho($cmdToExec)`; string $faceNm = $tst[0]; print($faceNm + "\n"); // Close the curve! $x = $hexRad; $y = 0.0; $z = 0.0; $zCurv = 0.01; $spareCmd += "-p " + $x + " " + $y + " " + $zCurv + " "; // print($spareCmd + ";\n"); string $curveNm = `eval($spareCmd)`; // Relocate select $faceNm $curveNm; string $grpNm = `group`; select $grpNm; move -a $xCen $yCen 0.0; } global proc genHexGrid(int $chainLen, int $nCols, float $gridRad, float $hexRad) { for($i=0;$i<$chainLen;$i++) { for($j=0;$j<$nCols;$j++) { float $xCen = $j*$gridRad*1.5; float $yCen = -$i*2*$gridRad*sin(60*3.1415/180); if(($j%2)==1) // offset for odd columns { $yCen += $gridRad*sin(60*3.1415/180); } genHex($xCen, $yCen, $hexRad); } }// next column }// genHexGrid() // genHexGrid 8 8 1 1;