56 lines
1.1 KiB
OpenSCAD
56 lines
1.1 KiB
OpenSCAD
/* [Lego Type] */
|
|
type = 1; // [1:Standard]
|
|
studs_x = 4;
|
|
studs_y = 2;
|
|
|
|
/* [Hidden] */
|
|
block_height = 9.6; // The height of the block without studs
|
|
length_per_stud = 31.8 / 4;
|
|
stud_details = 4 * ($preview ? 5 : 10);
|
|
wall_width = 1.4;
|
|
ceiling_width = 1;
|
|
|
|
module stud() {
|
|
cylinder(d = 4.8, h = 1.8, $fn = stud_details);
|
|
}
|
|
|
|
module studs() {
|
|
for (x = [0:studs_x-1], y = [0:studs_y-1])
|
|
translate([(x+0.5) * length_per_stud, (y+0.5) * length_per_stud, 0])
|
|
stud();
|
|
}
|
|
|
|
module base() {
|
|
difference() {
|
|
cube([ studs_x*length_per_stud, studs_y*length_per_stud, block_height ]);
|
|
translate([wall_width, wall_width, -ceiling_width]) {
|
|
cube([
|
|
studs_x*length_per_stud - wall_width * 2,
|
|
studs_y*length_per_stud - wall_width * 2,
|
|
block_height
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
|
|
module pillar() {
|
|
cylinder(h = block_height, d = 6.51, $fn = stud_details);
|
|
}
|
|
|
|
module pillars() {
|
|
if (studs_x >= 2 && studs_y >= 2) {
|
|
for (x = [0:studs_x-2], y = [0:studs_y-2])
|
|
translate([(x+1) * length_per_stud, (y+1) * length_per_stud, 0])
|
|
pillar();
|
|
}
|
|
}
|
|
|
|
module block() {
|
|
base();
|
|
pillars();
|
|
translate([0, 0, block_height])
|
|
studs();
|
|
}
|
|
|
|
block();
|