From 574499bfa78f335843e7ac5363c777860d54561f Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Fri, 17 Feb 2023 14:24:58 +0100 Subject: [PATCH] Add plates and refined wall and pillar sizes --- Lego.json | 21 ++++++++++++++++++--- Lego.scad | 14 +++++++++----- Makefile | 9 +++++++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Lego.json b/Lego.json index 61406c0..7725807 100644 --- a/Lego.json +++ b/Lego.json @@ -1,19 +1,34 @@ { "parameterSets": { "Brick_4x2": { - "type": "1", + "type": "brick", "studs_x": "4", "studs_y": "2" }, "Brick_2x2": { - "type": "1", + "type": "brick", "studs_x": "2", "studs_y": "2" }, "Brick_2x1": { - "type": "1", + "type": "brick", + "studs_x": "2", + "studs_y": "1" + }, + "Plate_4x2": { + "type": "plate", + "studs_x": "4", + "studs_y": "2" + }, + "Plate_2x2": { + "type": "plate", "studs_x": "2", "studs_y": "2" + }, + "Plate_2x1": { + "type": "plate", + "studs_x": "2", + "studs_y": "1" } }, "fileFormatVersion": "1" diff --git a/Lego.scad b/Lego.scad index 7082002..52c88e7 100644 --- a/Lego.scad +++ b/Lego.scad @@ -1,15 +1,19 @@ /* [Lego Type] */ -type = 1; // [1:Standard] +type = "brick"; // ["brick":Brick, "plate":Plate] studs_x = 4; studs_y = 2; /* [Hidden] */ -block_height = 9.6; // The height of the block without studs +block_height = + type == "brick" ? 9.6 : + type == "plate" ? 3.2 : + 0; length_per_stud = 31.8 / 4; stud_details = 4 * ($preview ? 5 : 10); -wall_width = 1.4; +wall_width = 1.5; ceiling_width = 1; +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"); module stud() { @@ -36,7 +40,7 @@ module base() { } module pillar() { - cylinder(h = block_height, d = 6.51, $fn = stud_details); + cylinder(h = block_height, d = 6.48, $fn = stud_details); } module small_pillar() { @@ -62,4 +66,4 @@ module block() { studs(); } -block(); +block(); \ No newline at end of file diff --git a/Makefile b/Makefile index bcac840..df207d3 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,13 @@ PARAMETERS := $(shell cat Lego.json | grep -v '"parameterSets": ""' | jq -r '.parameterSets | keys[]') STL = $(PARAMETERS:%=%.stl) +SCAD = Lego.scad +CONFIG = Lego.json all: $(STL) -$(STL): Lego.scad Lego.json - openscad -o $@ -P $@ $< +clean: + rm -f $(STL) + +$(STL): $(SCAD) $(CONFIG) Makefile + openscad -o $@ -p $(CONFIG) -P $(@:%.stl=%) $(SCAD)