Add knobbed plate

This commit is contained in:
Sebastiaan de Schaetzen 2023-02-17 23:11:13 +01:00
parent 7a792f0a91
commit 832b70605e
2 changed files with 31 additions and 7 deletions

View File

@ -25,6 +25,11 @@
"studs_x": "6", "studs_x": "6",
"studs_y": "6" "studs_y": "6"
}, },
"Plate_10x2": {
"type": "plate",
"studs_x": "10",
"studs_y": "2"
},
"Plate_4x2": { "Plate_4x2": {
"type": "plate", "type": "plate",
"studs_x": "4", "studs_x": "4",
@ -49,6 +54,11 @@
"type": "slope45", "type": "slope45",
"studs_x": "2", "studs_x": "2",
"studs_y": "1" "studs_y": "1"
},
"Knob_2x2": {
"type": "knob",
"studs_x": "2",
"studs_y": "2"
} }
}, },
"fileFormatVersion": "1" "fileFormatVersion": "1"

View File

@ -1,5 +1,5 @@
/* [Lego Type] */ /* [Lego Type] */
type = "brick"; // ["brick":Brick, "plate":Plate, "slope45":"Slope 45"] type = "brick"; // ["brick":Brick, "plate":Plate, "slope45":"Slope 45","knob":Knob]
studs_x = 4; studs_x = 4;
studs_y = 2; studs_y = 2;
slice_x = false; slice_x = false;
@ -7,25 +7,39 @@ slice_x = false;
/* [Hidden] */ /* [Hidden] */
block_height = block_height =
(type == "brick" || type == "slope45") ? 9.6 : (type == "brick" || type == "slope45") ? 9.6 :
type == "plate" ? 3.2 : (type == "plate" || type == "knob") ? 3.2 :
0; 0;
length_per_stud = 31.8 / 4; length_per_stud = 31.8 / 4;
wall_width = 1.6; wall_width = 1.6;
ceiling_width = 1; ceiling_width = 1;
centered_knob = type == "knob";
$fs = 1; $fs = 1;
assert(block_height > 0, "Invalid block height. Perhaps type is not correct?"); assert(block_height > 0, "Invalid block height. Perhaps type is not correct?");
assert(studs_x >= studs_y, "studs_x must be equal or larger than studs_y"); assert(studs_x >= studs_y, "studs_x must be equal or larger than studs_y");
module stud() { module stud() {
if (type == "knob") {
difference() {
cylinder(d = 4.8, h = 1.8); cylinder(d = 4.8, h = 1.8);
cylinder(d = 3.2, h = 1.9);
}
} else {
cylinder(d = 4.8, h = 1.8);
}
} }
module studs() { module studs() {
if (centered_knob) {
for (x = [0:studs_x-2], y = [0:studs_y-2])
translate([(x+1) * length_per_stud, (y+1) * length_per_stud, 0])
stud();
} else {
for (x = [0:studs_x-1], y = [0:studs_y-1]) 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]) translate([(x+0.5) * length_per_stud, (y+0.5) * length_per_stud, 0])
stud(); stud();
} }
}
module base() { module base() {
width = (studs_y + (type == "slope45" ? 1 : 0)) * length_per_stud; width = (studs_y + (type == "slope45" ? 1 : 0)) * length_per_stud;
@ -50,7 +64,7 @@ module base() {
} }
module pillar() { module pillar() {
cylinder(h = block_height, d = 6.48); cylinder(h = block_height, d = 6.55);
} }
module small_pillar() { module small_pillar() {