forked from D1plo1d/MCAD
-
Notifications
You must be signed in to change notification settings - Fork 69
/
layouts.scad
44 lines (40 loc) · 797 Bytes
/
layouts.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* OpenSCAD Layout Library (www.openscad.org)
* Copyright (C) 2012 Peter Uithoven
*
* License: LGPL 2.1 or later
*/
//list(iHeight);
//grid(iWidth,iHeight,inYDir = true,limit=3)
// Examples:
/*list(15)
{
square([25,10]);
square([25,10]);
square([25,10]);
square([25,10]);
square([25,10]);
}*/
/*grid(30,15,false,2)
{
square([25,10]);
square([25,10]);
square([25,10]);
square([25,10]);
square([25,10]);
}*/
//----------------------
module list(iHeight)
{
for (i = [0 : $children-1])
translate([0,i*iHeight]) child(i);
}
module grid(iWidth,iHeight,inYDir = true,limit=3)
{
for (i = [0 : $children-1])
{
translate([(inYDir)? (iWidth)*(i%limit) : (iWidth)*floor(i/limit),
(inYDir)? (iHeight)*floor(i/limit) : (iHeight)*(i%limit)])
child(i);
}
}