Add slope45

This commit is contained in:
Sebastiaan de Schaetzen 2023-02-17 19:17:50 +01:00
parent 845fb955fd
commit 61ed2eceb9
2 changed files with 51 additions and 14 deletions

View File

@ -34,6 +34,11 @@
"type": "plate", "type": "plate",
"studs_x": "2", "studs_x": "2",
"studs_y": "1" "studs_y": "1"
},
"Slope45_2x1": {
"type": "slope45",
"studs_x": "2",
"studs_y": "1"
} }
}, },
"fileFormatVersion": "1" "fileFormatVersion": "1"

View File

@ -1,11 +1,12 @@
/* [Lego Type] */ /* [Lego Type] */
type = "brick"; // ["brick":Brick, "plate":Plate] type = "brick"; // ["brick":Brick, "plate":Plate, "slope45":"Slope 45"]
studs_x = 4; studs_x = 4;
studs_y = 2; studs_y = 2;
slice_x = false;
/* [Hidden] */ /* [Hidden] */
block_height = block_height =
type == "brick" ? 9.6 : (type == "brick" || type == "slope45") ? 9.6 :
type == "plate" ? 3.2 : type == "plate" ? 3.2 :
0; 0;
length_per_stud = 31.8 / 4; length_per_stud = 31.8 / 4;
@ -27,14 +28,23 @@ module studs() {
} }
module base() { module base() {
width = (studs_y + (type == "slope45" ? 1 : 0)) * length_per_stud;
length = studs_x * length_per_stud;
difference() { difference() {
cube([ studs_x*length_per_stud, studs_y*length_per_stud, block_height ]); cube([ length, width, block_height ]);
translate([wall_width, wall_width, -ceiling_width]) { translate([wall_width, wall_width, -ceiling_width]) {
difference() {
cube([ cube([
studs_x*length_per_stud - wall_width * 2, length - wall_width * 2,
studs_y*length_per_stud - wall_width * 2, width - wall_width * 2,
block_height block_height
]); ]);
if (type == "slope45") {
translate([-wall_width, width-wall_width/2-wall_width*1.4, 3.2])
rotate([45, 0, 0])
cube([length + 2, length_per_stud, block_height]);
}
}
} }
} }
} }
@ -48,7 +58,11 @@ module small_pillar() {
} }
module pillars() { module pillars() {
if (studs_x >= 2 && studs_y >= 2) { if (type == "slope45") {
for (x = [0:studs_x-2], y = [0:studs_y-1])
translate([(x+1) * length_per_stud, (y+1) * length_per_stud, 0])
pillar();
} else if (studs_x >= 2 && studs_y >= 2) {
for (x = [0:studs_x-2], y = [0: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]) translate([(x+1) * length_per_stud, (y+1) * length_per_stud, 0])
pillar(); pillar();
@ -60,10 +74,28 @@ module pillars() {
} }
module block() { module block() {
width = (studs_y + (type == "slope45" ? 1 : 0)) * length_per_stud;
length = studs_x * length_per_stud;
difference() {
union() {
base(); base();
pillars(); pillars();
translate([0, 0, block_height]) translate([0, 0, block_height])
studs(); studs();
} }
if (type == "slope45") {
translate([-1, width-wall_width, 3.2])
rotate([45, 0, 0])
translate([0, 1, -10])
cube([length + 2, 10, 20]);
}
}
}
difference() {
block(); block();
if (slice_x) {
translate([10, -10, -10])
cube([100, 100, 100]);
}
}