From 61ed2eceb99edf3f14e49c210ab61b334b2d16ad Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Fri, 17 Feb 2023 19:17:50 +0100 Subject: [PATCH] Add slope45 --- Lego.json | 5 +++++ Lego.scad | 60 ++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 14 deletions(-) diff --git a/Lego.json b/Lego.json index 97e5ddd..392c8e3 100644 --- a/Lego.json +++ b/Lego.json @@ -34,6 +34,11 @@ "type": "plate", "studs_x": "2", "studs_y": "1" + }, + "Slope45_2x1": { + "type": "slope45", + "studs_x": "2", + "studs_y": "1" } }, "fileFormatVersion": "1" diff --git a/Lego.scad b/Lego.scad index 4a99191..8a6d972 100644 --- a/Lego.scad +++ b/Lego.scad @@ -1,11 +1,12 @@ /* [Lego Type] */ -type = "brick"; // ["brick":Brick, "plate":Plate] +type = "brick"; // ["brick":Brick, "plate":Plate, "slope45":"Slope 45"] studs_x = 4; studs_y = 2; +slice_x = false; /* [Hidden] */ block_height = - type == "brick" ? 9.6 : + (type == "brick" || type == "slope45") ? 9.6 : type == "plate" ? 3.2 : 0; length_per_stud = 31.8 / 4; @@ -27,14 +28,23 @@ module studs() { } module base() { + width = (studs_y + (type == "slope45" ? 1 : 0)) * length_per_stud; + length = studs_x * length_per_stud; 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]) { - cube([ - studs_x*length_per_stud - wall_width * 2, - studs_y*length_per_stud - wall_width * 2, - block_height - ]); + difference() { + cube([ + length - wall_width * 2, + width - wall_width * 2, + 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() { - 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]) translate([(x+1) * length_per_stud, (y+1) * length_per_stud, 0]) pillar(); @@ -60,10 +74,28 @@ module pillars() { } module block() { - base(); - pillars(); - translate([0, 0, block_height]) - studs(); + width = (studs_y + (type == "slope45" ? 1 : 0)) * length_per_stud; + length = studs_x * length_per_stud; + difference() { + union() { + base(); + pillars(); + translate([0, 0, block_height]) + studs(); + } + if (type == "slope45") { + translate([-1, width-wall_width, 3.2]) + rotate([45, 0, 0]) + translate([0, 1, -10]) + cube([length + 2, 10, 20]); + } + } } -block(); \ No newline at end of file +difference() { + block(); + if (slice_x) { + translate([10, -10, -10]) + cube([100, 100, 100]); + } +} \ No newline at end of file