Initial commit

This commit is contained in:
Sebastiaan de Schaetzen 2023-02-17 11:21:57 +01:00
commit 96c98b8fd8
4 changed files with 74 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.stl

10
Lego.json Normal file
View File

@ -0,0 +1,10 @@
{
"parameterSets": {
"Brick_4x2": {
"type": "1",
"studs_x": "4",
"studs_y": "2"
}
},
"fileFormatVersion": "1"
}

55
Lego.scad Normal file
View File

@ -0,0 +1,55 @@
/* [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();

8
Makefile Normal file
View File

@ -0,0 +1,8 @@
PARAMETERS := $(shell cat Lego.json | grep -v '"parameterSets": ""' | jq -r '.parameterSets | keys[]')
STL = $(PARAMETERS:%=%.stl)
all: $(STL)
$(STL): Lego.scad Lego.json
openscad -o $@ -P $@ $<