From 7f21aa7774d045f25c7f5d489b7fd6581e5273c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Sat, 6 Nov 2021 15:37:00 +0100 Subject: [PATCH 01/11] link examples improved , round added MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usability of uncommenting upper examples thingiverse link https://www.thingiverse.com/thing:9512 removal as link is dead (reported&blocked) as https://www.thingiverse.com/thing:9512/report shows it was there add round option to make 1×1 2×2 5×5 round --- lego_compatibility.scad | 54 ++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index 4e402d9b..ee8c324d 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -1,19 +1,21 @@ // This file is placed under the public domain -// from: http://www.thingiverse.com/thing:9512 // Author: nefercheprure -// Examples: -// standard LEGO 2x1 tile has no pin -// block(1,2,1/3,reinforcement=false,flat_top=true); -// standard LEGO 2x1 flat has pin + +// // Examples: +// // standard LEGO 2x1 tile has no pin +// block(1,2,1/3,reinforcement=false,flat_top=true); +// // standard LEGO 2x1 flat has pin // block(1,2,1/3,reinforcement=true); -// standard LEGO 2x1 brick has pin +// // standard LEGO 2x1 brick has pin // block(1,2,1,reinforcement=true); -// standard LEGO 2x1 brick without pin +// // standard LEGO 2x1 brick without pin // block(1,2,1,reinforcement=false); -// standard LEGO 2x1x5 brick has no pin and has hollow knobs +// // standard LEGO 2x1x5 brick has no pin and has hollow knobs // block(1,2,5,reinforcement=false,hollow_knob=true); +// // standard LEGO 2x2x1/3 brick round no solid bottom +// block(2,2,1/3,reinforcement=true,solid_bottom=false,round=true); knob_diameter=4.8; //knobs on top of blocks @@ -31,32 +33,32 @@ cylinder_precision=0.5; /* EXAMPLES: -block(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); +block(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true, solid_bottom=true); translate([50,-10,0]) - block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true); + block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true, solid_bottom=true); translate([10,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true, solid_bottom=true); translate([30,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([50,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); translate([0,20,0]) - block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false); + block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); translate([20,20,0]) - block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); + block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([40,20,0]) - block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false); + block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false, solid_bottom=true); translate([0,-10,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([0,-20,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); translate([0,-30,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true,solid_bottom=true); //*/ -module block(width,length,height,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false) { +module block(width,length,height,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false,round=false) { overall_length=(length-1)*knob_spacing+knob_diameter+wall_thickness*2; overall_width=(width-1)*knob_spacing+knob_diameter+wall_thickness*2; center= center==true ? 1 : 0; @@ -104,6 +106,10 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno for (xcount=[1:length-1]) translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); + if(round==true&&width==length)difference(){ + translate([-1,-1,-1])cube([overall_width*2,overall_length*2,height*block_height*2]); + translate([overall_width/2,overall_length/2,-1])cylinder(d=overall_width, h=height*block_height*2,$fs=cylinder_precision,$fa=5); + } } if (reinforcement==true && width>1 && length>1) @@ -116,11 +122,15 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/2]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); } // posts: - if (solid_bottom == false) + if (solid_bottom == false){ if (width>1 && length>1) for (ycount=[1:width-1]) for (xcount=[1:length-1]) translate([xcount*knob_spacing,ycount*knob_spacing,0]) post(height); - + if(round == true && width == length)translate([overall_width/2,overall_length/2,block_height/3-roof_thickness]) difference(){ + cylinder((height-1/3)*block_height+roof_thickness,d=overall_width,$fs=cylinder_precision,$fa=5); + cylinder(height*block_height*2,d=overall_width-wall_thickness*2,center=true,$fs=cylinder_precision,$fa=5); + } + } if (reinforcement == true && width==1 && length!=1) for (xcount=[1:length-1]) translate([xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); From 7cbed99020b8254ad4bf8e48ecba610cd5497451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Sat, 6 Nov 2021 17:07:45 +0100 Subject: [PATCH 02/11] eliminated z-fighting --- lego_compatibility.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index ee8c324d..1f3d48ef 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -126,7 +126,7 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno if (width>1 && length>1) for (ycount=[1:width-1]) for (xcount=[1:length-1]) translate([xcount*knob_spacing,ycount*knob_spacing,0]) post(height); - if(round == true && width == length)translate([overall_width/2,overall_length/2,block_height/3-roof_thickness]) difference(){ + if(round == true && width == length && height>1/3)translate([overall_width/2,overall_length/2,block_height/3-roof_thickness]) difference(){ cylinder((height-1/3)*block_height+roof_thickness,d=overall_width,$fs=cylinder_precision,$fa=5); cylinder(height*block_height*2,d=overall_width-wall_thickness*2,center=true,$fs=cylinder_precision,$fa=5); } From ea5bd5a4b008ed27abfb46a04c90bb2ea20a5d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Sun, 7 Nov 2021 10:27:53 +0100 Subject: [PATCH 03/11] fixed multiple MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed misaligned reinforcement pin placing in All blocks 1×n / n×1 fixed 1x1 round axel now through blocks added examples --- lego_compatibility.scad | 61 ++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index 1f3d48ef..1f35c3ad 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -5,9 +5,9 @@ // // Examples: // // standard LEGO 2x1 tile has no pin -// block(1,2,1/3,reinforcement=false,flat_top=true); +// block(1,2,1/3,reinforcement=false,flat_top=true); // // standard LEGO 2x1 flat has pin -// block(1,2,1/3,reinforcement=true); +// block(1,2,1/3,reinforcement=false,solid_bottom=true,center=false); // // standard LEGO 2x1 brick has pin // block(1,2,1,reinforcement=true); // // standard LEGO 2x1 brick without pin @@ -16,7 +16,10 @@ // block(1,2,5,reinforcement=false,hollow_knob=true); // // standard LEGO 2x2x1/3 brick round no solid bottom // block(2,2,1/3,reinforcement=true,solid_bottom=false,round=true); +// // standard LEGO 1x1x1 brick round no solid bottom +// block(1,1,1,reinforcement=true,solid_bottom=false,round=true,center=1); + knob_diameter=4.8; //knobs on top of blocks knob_height=2; @@ -37,6 +40,8 @@ block(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob= translate([50,-10,0]) block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true, solid_bottom=true); +translate([74,-10,0]) + block(1,1,1,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); translate([10,0,0]) block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true, solid_bottom=true); @@ -44,12 +49,18 @@ translate([30,0,0]) block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([50,0,0]) block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); +translate([70,0,0]) + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true,round=true); +translate([90,0,0]) + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); + translate([0,20,0]) block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); translate([20,20,0]) block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([40,20,0]) block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false, solid_bottom=true); + translate([0,-10,0]) block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([0,-20,0]) @@ -66,8 +77,12 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno union() { difference() { union() { - // body: - cube([overall_length,overall_width,height*block_height]); + // body: use cylinder if round + if (width == length && round == true ) translate([overall_length/2,overall_width/2]) + linear_extrude(height*block_height,convexity=2){ + circle(d=overall_length-.01,$fs=cylinder_precision,$fa=5); + } + else cube([overall_length,overall_width,height*block_height]); // knobs: if (flat_top != true) translate([knob_diameter/2+wall_thickness,knob_diameter/2+wall_thickness,0]) @@ -84,7 +99,18 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno } // hollow bottom: if (solid_bottom == false) - translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); + if(width == length && round == true ){ + translate([overall_width/2,overall_length/2,-roof_thickness]) cylinder(block_height*height,d=overall_length-wall_thickness*2,$fs=cylinder_precision,$fa=5); + // place for knobs if >1 + if(width > 1 || length >1) translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height/3]); + } + else translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); + + + // round 1x1 -> groove around bottom + if(round == true && width == 1 && length ==1)translate([overall_length/2,overall_width/2]) + rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0])square([wall_thickness*2/3,wall_thickness],true); + // flat_top -> groove around bottom if (flat_top == true) { translate([-wall_thickness/2,-wall_thickness*2/3,-wall_thickness/2]) @@ -100,16 +126,17 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno if (axle_hole==true) if (width>1 && length>1) for (ycount=[1:width-1]) for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) axle(height); + translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness]) axle(height+roof_thickness/2); if (circular_hole==true) if (width>1 && length>1) for (ycount=[1:width-1]) for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,roof_thickness]) + translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/8]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); - if(round==true&&width==length)difference(){ - translate([-1,-1,-1])cube([overall_width*2,overall_length*2,height*block_height*2]); - translate([overall_width/2,overall_length/2,-1])cylinder(d=overall_width, h=height*block_height*2,$fs=cylinder_precision,$fa=5); - } + + + + // cut knobs if round + if(round==true&&width==length)translate([overall_length/2,overall_width/2])rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,-1])square([20,height*block_height+10],false); } if (reinforcement==true && width>1 && length>1) @@ -126,18 +153,14 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno if (width>1 && length>1) for (ycount=[1:width-1]) for (xcount=[1:length-1]) translate([xcount*knob_spacing,ycount*knob_spacing,0]) post(height); - if(round == true && width == length && height>1/3)translate([overall_width/2,overall_length/2,block_height/3-roof_thickness]) difference(){ - cylinder((height-1/3)*block_height+roof_thickness,d=overall_width,$fs=cylinder_precision,$fa=5); - cylinder(height*block_height*2,d=overall_width-wall_thickness*2,center=true,$fs=cylinder_precision,$fa=5); - } } if (reinforcement == true && width==1 && length!=1) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + for (xcount=[0:length -2]) + translate([knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); if (reinforcement == true && length==1 && width!=1) - for (ycount=[1:width-1]) - translate([overall_length/2,ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + for (ycount=[0:width -2]) + translate([overall_length/2,knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); } } From 5c8c32981eb4c8f4d19cb37c9c35d0e2797e8351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:25:30 +0100 Subject: [PATCH 04/11] fix alignment issue bottom --- lego_compatibility.scad | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index 1f35c3ad..e6c3cdd6 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -19,7 +19,7 @@ // // standard LEGO 1x1x1 brick round no solid bottom // block(1,1,1,reinforcement=true,solid_bottom=false,round=true,center=1); - + knob_diameter=4.8; //knobs on top of blocks knob_height=2; @@ -141,18 +141,29 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno if (reinforcement==true && width>1 && length>1) difference() { - for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,0]) reinforcement(height); - for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/2]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); + for (ycount=[0:width-2]) + for (xcount=[0:length-2])translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + 0]) + reinforcement(height); + for (ycount=[0:width-2]) + for (xcount=[0:length-2]) + translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + -roof_thickness/2]) + cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); } // posts: if (solid_bottom == false){ - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,0]) post(height); + if (width>1 && length>1) + for (ycount=[0:width -2]) + for (xcount=[0:length -2])translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + 0]) + post(height); } if (reinforcement == true && width==1 && length!=1) for (xcount=[0:length -2]) From e4a546873d999f4b9f5f2e90fc3c6bc27b16fb85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:53:24 +0100 Subject: [PATCH 05/11] formatting cleaned --- lego_compatibility.scad | 66 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index e6c3cdd6..9fae0a95 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -78,10 +78,9 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno difference() { union() { // body: use cylinder if round - if (width == length && round == true ) translate([overall_length/2,overall_width/2]) - linear_extrude(height*block_height,convexity=2){ - circle(d=overall_length-.01,$fs=cylinder_precision,$fa=5); - } + if (width == length && round == true ) translate([overall_length/2,overall_width/2]) + linear_extrude(height*block_height,convexity=2) + circle(d=overall_length-.01,$fs=cylinder_precision,$fa=5); else cube([overall_length,overall_width,height*block_height]); // knobs: if (flat_top != true) @@ -99,18 +98,18 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno } // hollow bottom: if (solid_bottom == false) - if(width == length && round == true ){ - translate([overall_width/2,overall_length/2,-roof_thickness]) cylinder(block_height*height,d=overall_length-wall_thickness*2,$fs=cylinder_precision,$fa=5); - // place for knobs if >1 - if(width > 1 || length >1) translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height/3]); - } - else translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); - + if(width == length && round == true ){ + translate([overall_width/2,overall_length/2,-roof_thickness]) cylinder(block_height*height,d=overall_length-wall_thickness*2,$fs=cylinder_precision,$fa=5); + // place for knobs if >1 + if(width > 1 || length >1) translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height/3]); + } + else translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); + // round 1x1 -> groove around bottom - if(round == true && width == 1 && length ==1)translate([overall_length/2,overall_width/2]) - rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0])square([wall_thickness*2/3,wall_thickness],true); - + if(round == true && width == 1 && length ==1)translate([overall_length/2,overall_width/2]) + rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0])square([wall_thickness*2/3,wall_thickness],true); + // flat_top -> groove around bottom if (flat_top == true) { translate([-wall_thickness/2,-wall_thickness*2/3,-wall_thickness/2]) @@ -132,38 +131,37 @@ module block(width,length,height,axle_hole=false,reinforcement=false, hollow_kno for (xcount=[1:length-1]) translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/8]) cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); - - - - // cut knobs if round + +// cut knobs if round if(round==true&&width==length)translate([overall_length/2,overall_width/2])rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,-1])square([20,height*block_height+10],false); } if (reinforcement==true && width>1 && length>1) difference() { for (ycount=[0:width-2]) - for (xcount=[0:length-2])translate([ - knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, - knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, - 0]) - reinforcement(height); + for (xcount=[0:length-2]) + translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + 0]) + reinforcement(height); for (ycount=[0:width-2]) for (xcount=[0:length-2]) translate([ - knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, - knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, - -roof_thickness/2]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + -roof_thickness/2]) + cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); } // posts: if (solid_bottom == false){ if (width>1 && length>1) - for (ycount=[0:width -2]) - for (xcount=[0:length -2])translate([ - knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, - knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, - 0]) - post(height); + for (ycount=[0:width -2]) + for (xcount=[0:length -2])translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + 0]) + post(height); } if (reinforcement == true && width==1 && length!=1) for (xcount=[0:length -2]) @@ -198,4 +196,4 @@ module axle(height) { cube([axle_spline_width,axle_diameter,height*block_height],center=true); } } - + From 1c78d0004ef019bb76e2c20cb7ad8208ce67c8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Mon, 8 Nov 2021 20:14:59 +0100 Subject: [PATCH 06/11] tab indents cleared --- lego_compatibility.scad | 267 ++++++++++++++++++++-------------------- 1 file changed, 135 insertions(+), 132 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index 9fae0a95..d456eddb 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -4,6 +4,9 @@ // // Examples: +// // standard LEGO 4×2×1 brick solid_bottom +// block(); + // // standard LEGO 2x1 tile has no pin // block(1,2,1/3,reinforcement=false,flat_top=true); // // standard LEGO 2x1 flat has pin @@ -21,13 +24,13 @@ -knob_diameter=4.8; //knobs on top of blocks +knob_diameter=4.8; //knobs on top of blocks knob_height=2; knob_spacing=8.0; wall_thickness=1.45; roof_thickness=1.05; block_height=9.5; -pin_diameter=3; //pin for bottom blocks with width or length of 1 +pin_diameter=3; //pin for bottom blocks with width or length of 1 post_diameter=6.5; reinforcing_width=1.5; axle_spline_width=2.0; @@ -39,161 +42,161 @@ cylinder_precision=0.5; block(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true, solid_bottom=true); translate([50,-10,0]) - block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true, solid_bottom=true); + block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true, solid_bottom=true); translate([74,-10,0]) - block(1,1,1,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); + block(1,1,1,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); translate([10,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true, solid_bottom=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true, solid_bottom=true); translate([30,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([50,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); translate([70,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true,round=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true,round=true); translate([90,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); - + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); + translate([0,20,0]) - block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); + block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); translate([20,20,0]) - block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); + block(3,2,1,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([40,20,0]) - block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false, solid_bottom=true); - + block(3,2,1/3,axle_hole=false,circular_hole=false,reinforcement=false,hollow_knob=false,flat_top=false, solid_bottom=true); + translate([0,-10,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true); translate([0,-20,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); translate([0,-30,0]) - block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true,solid_bottom=true); + block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true,solid_bottom=true); //*/ -module block(width,length,height,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false,round=false) { - overall_length=(length-1)*knob_spacing+knob_diameter+wall_thickness*2; - overall_width=(width-1)*knob_spacing+knob_diameter+wall_thickness*2; - center= center==true ? 1 : 0; - translate(center*[-overall_length/2, -overall_width/2, 0]) - union() { - difference() { - union() { - // body: use cylinder if round - if (width == length && round == true ) translate([overall_length/2,overall_width/2]) - linear_extrude(height*block_height,convexity=2) - circle(d=overall_length-.01,$fs=cylinder_precision,$fa=5); - else cube([overall_length,overall_width,height*block_height]); - // knobs: - if (flat_top != true) - translate([knob_diameter/2+wall_thickness,knob_diameter/2+wall_thickness,0]) - for (ycount=[0:width-1]) - for (xcount=[0:length-1]) { - translate([xcount*knob_spacing,ycount*knob_spacing,0]) - difference() { - cylinder(r=knob_diameter/2,h=block_height*height+knob_height,$fs=cylinder_precision); - if (hollow_knob==true) - translate([0,0,-roof_thickness]) - cylinder(r=pin_diameter/2,h=block_height*height+knob_height+2*roof_thickness,$fs=cylinder_precision); - } - } - } - // hollow bottom: - if (solid_bottom == false) - if(width == length && round == true ){ - translate([overall_width/2,overall_length/2,-roof_thickness]) cylinder(block_height*height,d=overall_length-wall_thickness*2,$fs=cylinder_precision,$fa=5); - // place for knobs if >1 - if(width > 1 || length >1) translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height/3]); - } - else translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); - - - // round 1x1 -> groove around bottom - if(round == true && width == 1 && length ==1)translate([overall_length/2,overall_width/2]) - rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0])square([wall_thickness*2/3,wall_thickness],true); - - // flat_top -> groove around bottom - if (flat_top == true) { - translate([-wall_thickness/2,-wall_thickness*2/3,-wall_thickness/2]) - cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); - translate([-wall_thickness/2,overall_width-wall_thickness/3,-wall_thickness/2]) - cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); - - translate([-wall_thickness*2/3,-wall_thickness/2,-wall_thickness/2]) - cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); - translate([overall_length-wall_thickness/3,0,-wall_thickness/2]) - cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); - } - if (axle_hole==true) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness]) axle(height+roof_thickness/2); - if (circular_hole==true) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/8]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); +module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false,round=false) { + overall_length=(length-1)*knob_spacing+knob_diameter+wall_thickness*2; + overall_width=(width-1)*knob_spacing+knob_diameter+wall_thickness*2; + center= center==true ? 1 : 0; + translate(center*[-overall_length/2, -overall_width/2, 0]) + union() { + difference() { + union() { + // body: use cylinder if round + if (width == length && round == true ) translate([overall_length/2,overall_width/2]) + linear_extrude(height*block_height,convexity=2) + circle(d=overall_length-.01,$fs=cylinder_precision,$fa=5); + else cube([overall_length,overall_width,height*block_height]); + // knobs: + if (flat_top != true) + translate([knob_diameter/2+wall_thickness,knob_diameter/2+wall_thickness,0]) + for (ycount=[0:width-1]) + for (xcount=[0:length-1]) { + translate([xcount*knob_spacing,ycount*knob_spacing,0]) + difference() { + cylinder(r=knob_diameter/2,h=block_height*height+knob_height,$fs=cylinder_precision); + if (hollow_knob==true) + translate([0,0,-roof_thickness]) + cylinder(r=pin_diameter/2,h=block_height*height+knob_height+2*roof_thickness,$fs=cylinder_precision); + } + } + } + // hollow bottom: + if (solid_bottom == false) + if(width == length && round == true ){ + translate([overall_width/2,overall_length/2,-roof_thickness]) cylinder(block_height*height,d=overall_length-wall_thickness*2,$fs=cylinder_precision,$fa=5); + // place for knobs if >1 + if(width > 1 || length >1) translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height/3]); + } + else translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); + + + // round 1x1 -> groove around bottom + if(round == true && width == 1 && length ==1)translate([overall_length/2,overall_width/2]) + rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0])square([wall_thickness*2/3,wall_thickness],true); + + // flat_top -> groove around bottom + if (flat_top == true) { + translate([-wall_thickness/2,-wall_thickness*2/3,-wall_thickness/2]) + cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); + translate([-wall_thickness/2,overall_width-wall_thickness/3,-wall_thickness/2]) + cube([overall_length+wall_thickness,wall_thickness,wall_thickness]); + + translate([-wall_thickness*2/3,-wall_thickness/2,-wall_thickness/2]) + cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); + translate([overall_length-wall_thickness/3,0,-wall_thickness/2]) + cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); + } + if (axle_hole==true) + if (width>1 && length>1) for (ycount=[1:width-1]) + for (xcount=[1:length-1]) + translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness]) axle(height+roof_thickness/2); + if (circular_hole==true) + if (width>1 && length>1) for (ycount=[1:width-1]) + for (xcount=[1:length-1]) + translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/8]) + cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); // cut knobs if round - if(round==true&&width==length)translate([overall_length/2,overall_width/2])rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,-1])square([20,height*block_height+10],false); - } - - if (reinforcement==true && width>1 && length>1) - difference() { - for (ycount=[0:width-2]) - for (xcount=[0:length-2]) - translate([ - knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, - knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, - 0]) - reinforcement(height); - for (ycount=[0:width-2]) - for (xcount=[0:length-2]) - translate([ - knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, - knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, - -roof_thickness/2]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); - } - // posts: - if (solid_bottom == false){ - if (width>1 && length>1) - for (ycount=[0:width -2]) - for (xcount=[0:length -2])translate([ - knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, - knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, - 0]) - post(height); - } - if (reinforcement == true && width==1 && length!=1) - for (xcount=[0:length -2]) - translate([knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); - - if (reinforcement == true && length==1 && width!=1) - for (ycount=[0:width -2]) - translate([overall_length/2,knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); - } + if(round==true&&width==length)translate([overall_length/2,overall_width/2])rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,-1])square([20,height*block_height+10],false); + } + + if (reinforcement==true && width>1 && length>1) + difference() { + for (ycount=[0:width-2]) + for (xcount=[0:length-2]) + translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + 0]) + reinforcement(height); + for (ycount=[0:width-2]) + for (xcount=[0:length-2]) + translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + -roof_thickness/2]) + cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); + } + // posts: + if (solid_bottom == false){ + if (width>1 && length>1) + for (ycount=[0:width -2]) + for (xcount=[0:length -2])translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + 0]) + post(height); + } + if (reinforcement == true && width==1 && length!=1) + for (xcount=[0:length -2]) + translate([knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + + if (reinforcement == true && length==1 && width!=1) + for (ycount=[0:width -2]) + translate([overall_length/2,knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + } } module post(height) { - difference() { - cylinder(r=post_diameter/2, h=height*block_height-roof_thickness/2,$fs=cylinder_precision); - translate([0,0,-roof_thickness/2]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); - } + difference() { + cylinder(r=post_diameter/2, h=height*block_height-roof_thickness/2,$fs=cylinder_precision); + translate([0,0,-roof_thickness/2]) + cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); + } } module reinforcement(height) { - union() { - translate([0,0,height*block_height/2]) union() { - cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height],center=true); - rotate(v=[0,0,1],a=90) cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height], center=true); - } - } + union() { + translate([0,0,height*block_height/2]) union() { + cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height],center=true); + rotate(v=[0,0,1],a=90) cube([reinforcing_width,knob_spacing+knob_diameter+wall_thickness/2,height*block_height], center=true); + } + } } module axle(height) { - translate([0,0,height*block_height/2]) union() { - cube([axle_diameter,axle_spline_width,height*block_height],center=true); - cube([axle_spline_width,axle_diameter,height*block_height],center=true); - } + translate([0,0,height*block_height/2]) union() { + cube([axle_diameter,axle_spline_width,height*block_height],center=true); + cube([axle_spline_width,axle_diameter,height*block_height],center=true); + } } From 502a93f013cc4836183ea6460455c993b4255348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Mon, 8 Nov 2021 21:08:41 +0100 Subject: [PATCH 07/11] axles centered --- lego_compatibility.scad | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index d456eddb..b8f3e153 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -126,14 +126,25 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); } if (axle_hole==true) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness]) axle(height+roof_thickness/2); + if (width>1 && length>1) + for (ycount=[0:width-2]) + for (xcount=[0:length-2]) + translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + -roof_thickness + ]) + axle(height+roof_thickness/2); if (circular_hole==true) - if (width>1 && length>1) for (ycount=[1:width-1]) - for (xcount=[1:length-1]) - translate([xcount*knob_spacing,ycount*knob_spacing,-roof_thickness/8]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); + if (width>1 && length>1) + for (ycount=[0:width-2]) + for (xcount=[0:length-2]) + translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + -roof_thickness/8 + ]) + cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); // cut knobs if round if(round==true&&width==length)translate([overall_length/2,overall_width/2])rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,-1])square([20,height*block_height+10],false); @@ -168,11 +179,19 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl } if (reinforcement == true && width==1 && length!=1) for (xcount=[0:length -2]) - translate([knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing,overall_width/2,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + translate([ + knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, + overall_width/2, + 0]) + cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); if (reinforcement == true && length==1 && width!=1) for (ycount=[0:width -2]) - translate([overall_length/2,knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing,0]) cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); + translate([ + overall_length/2, + knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, + 0]) + cylinder(r=pin_diameter/2,h=block_height*height,$fs=cylinder_precision); } } From 4895598cf08c397bedfbbb22c47aa3bba4e85e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Mon, 8 Nov 2021 22:18:28 +0100 Subject: [PATCH 08/11] fixed axle shape + hole hole wasn't fitting the axle axle hole was only roof_thickness pole was blocking axle reinforcement were blocking axle --- lego_compatibility.scad | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index b8f3e153..cd5f0290 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -132,9 +132,10 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl translate([ knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, - -roof_thickness + solid_bottom?-.1:+block_height/3-roof_thickness ]) - axle(height+roof_thickness/2); + axle(height*block_height+roof_thickness/2); +// circular hole if (circular_hole==true) if (width>1 && length>1) for (ycount=[0:width-2]) @@ -144,11 +145,11 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, -roof_thickness/8 ]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); + cylinder(r=axle_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); // cut knobs if round if(round==true&&width==length)translate([overall_length/2,overall_width/2])rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,-1])square([20,height*block_height+10],false); - } + } // end difference line 81 if (reinforcement==true && width>1 && length>1) difference() { @@ -165,7 +166,7 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, -roof_thickness/2]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision); + cylinder(r=axle_diameter/2, h=height*block_height+roof_thickness, $fs=cylinder_precision,$fa=5); } // posts: if (solid_bottom == false){ @@ -175,7 +176,7 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl knob_diameter/2+wall_thickness+knob_spacing/2+xcount*knob_spacing, knob_diameter/2+wall_thickness+knob_spacing/2+ycount*knob_spacing, 0]) - post(height); + post(height,axle_hole,circular_hole); } if (reinforcement == true && width==1 && length!=1) for (xcount=[0:length -2]) @@ -195,11 +196,17 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl } } -module post(height) { +module post(height,axle_hole,circular_hole) { difference() { cylinder(r=post_diameter/2, h=height*block_height-roof_thickness/2,$fs=cylinder_precision); translate([0,0,-roof_thickness/2]) - cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); + if(!axle_hole)cylinder(r=knob_diameter/2, h=height*block_height+roof_thickness/4,$fs=cylinder_precision); + + if(axle_hole){ + translate([0,0,-roof_thickness/4])axle(height*block_height+roof_thickness/2); + cylinder(r=axle_diameter/2, h=(block_height/3-roof_thickness)*2,center=true,$fs=cylinder_precision,$fa=5); + } + if(circular_hole)translate([0,0,-roof_thickness/4])cylinder(r=axle_diameter/2, h=height*block_height+roof_thickness/2,$fs=cylinder_precision,$fa=5); } } @@ -213,9 +220,15 @@ module reinforcement(height) { } module axle(height) { - translate([0,0,height*block_height/2]) union() { - cube([axle_diameter,axle_spline_width,height*block_height],center=true); - cube([axle_spline_width,axle_diameter,height*block_height],center=true); + assert(height); + translate([0,0,height/2-.01]) + intersection(){ + union(){ + cube([axle_diameter,axle_spline_width,height],center=true); + cube([axle_spline_width,axle_diameter,height],center=true); + } + cylinder(r=axle_diameter/2, h=height,center=true,$fa=5,$fs=cylinder_precision); } } +//EOF \ No newline at end of file From cdd7e0d79c5791ef1ce85311f95ed014bf4186a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Tue, 9 Nov 2021 00:14:49 +0100 Subject: [PATCH 09/11] fixed round add examples x add module help MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1×1 now placeable on top and between except 1/3 flat top caps fixed flat top groove for all round added examples for 1×1 round add module echo when included to know what can be used without reading the lib --- lego_compatibility.scad | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index cd5f0290..33964c24 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -39,12 +39,18 @@ cylinder_precision=0.5; /* EXAMPLES: +// 1×1 +translate([0,-40,0])block(1,1,1,round=true,flat_top=false,hollow_knob=true,solid_bottom=false,center=false); +translate([10,-40,0])block(1,1,1/3,round=true,flat_top=true,hollow_knob=true,solid_bottom=false,center=false); +translate([20,-40,0])block(1,1,1,round=true,flat_top=true,hollow_knob=true,solid_bottom=false,center=false); +translate([30,-40,0])block(1,1,1/3,round=true,flat_top=false,hollow_knob=false,solid_bottom=false,center=false); +translate([40,-40,0])block(1,1,1/3,round=true,flat_top=false,hollow_knob=true,solid_bottom=false,center=false); + block(2,1,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true, solid_bottom=true); translate([50,-10,0]) block(1,2,1/3,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=true, solid_bottom=true); -translate([74,-10,0]) - block(1,1,1,axle_hole=false,circular_hole=true,reinforcement=false,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); + translate([10,0,0]) block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=true, solid_bottom=true); @@ -53,9 +59,11 @@ translate([30,0,0]) translate([50,0,0]) block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); translate([70,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true,round=true); + block(2,2,1/3,axle_hole=false,circular_hole=false,reinforcement=true,hollow_knob=false,flat_top=true, solid_bottom=true,round=true); translate([90,0,0]) - block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); + block(2,2,1/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=false,flat_top=false, solid_bottom=true,round=true); +translate([110,0,0]) + block(2,2,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=false,round=true); translate([0,20,0]) block(3,2,2/3,axle_hole=false,circular_hole=true,reinforcement=true,hollow_knob=true,flat_top=false, solid_bottom=true); @@ -71,7 +79,7 @@ translate([0,-20,0]) translate([0,-30,0]) block(1,5,1/3,axle_hole=true,circular_hole=false,reinforcement=true,hollow_knob=true,flat_top=true,solid_bottom=true); //*/ - +echo("lego_compatibility.scad useable module: \nblock(width=2,length=4,height=1,\n axle_hole=false,\n reinforcement=false,\n hollow_knob=false,\n flat_top=false,\n circular_hole=false,\n solid_bottom=true,\n center=false,\n round=false\n);\n"); module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, hollow_knob=false, flat_top=false, circular_hole=false, solid_bottom=true, center=false,round=false) { overall_length=(length-1)*knob_spacing+knob_diameter+wall_thickness*2; overall_width=(width-1)*knob_spacing+knob_diameter+wall_thickness*2; @@ -102,16 +110,18 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl // hollow bottom: if (solid_bottom == false) if(width == length && round == true ){ - translate([overall_width/2,overall_length/2,-roof_thickness]) cylinder(block_height*height,d=overall_length-wall_thickness*2,$fs=cylinder_precision,$fa=5); + translate([overall_width/2,overall_length/2,-roof_thickness]) cylinder(block_height*height,d=overall_length-wall_thickness*2,$fs=cylinder_precision,$fa=5); + if(width == 1) translate([overall_width/2,overall_length/2,-roof_thickness]) cylinder(block_height/3,d=(overall_length-wall_thickness*2)/cos(180/8),$fn=8); // place for knobs if >1 if(width > 1 || length >1) translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height/3]); - } + }// end round else translate([wall_thickness,wall_thickness,-roof_thickness]) cube([overall_length-wall_thickness*2,overall_width-wall_thickness*2,block_height*height]); // round 1x1 -> groove around bottom - if(round == true && width == 1 && length ==1)translate([overall_length/2,overall_width/2]) - rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0])square([wall_thickness*2/3,wall_thickness],true); + if(round == true && width == 1 && length ==1 && !(height==1/3&&flat_top))translate([overall_length/2,overall_width/2]) + rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0]) + square([overall_length-(sqrt(2)*knob_spacing-knob_diameter),block_height/2-wall_thickness/2],true); // flat_top -> groove around bottom if (flat_top == true) { @@ -124,6 +134,8 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); translate([overall_length-wall_thickness/3,0,-wall_thickness/2]) cube([wall_thickness,overall_width+wall_thickness,wall_thickness]); + if(round)translate([overall_length/2,overall_width/2]) + rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0])square([wall_thickness*2/3,wall_thickness],true); } if (axle_hole==true) if (width>1 && length>1) From 0ef32fcdb6c80fc3f4935cdd18e96142039a92f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Tue, 9 Nov 2021 08:27:08 +0100 Subject: [PATCH 10/11] switch calculation to existing variable --- lego_compatibility.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index 33964c24..c68b9498 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -121,7 +121,7 @@ module block(width=2,length=4,height=1,axle_hole=false,reinforcement=false, holl // round 1x1 -> groove around bottom if(round == true && width == 1 && length ==1 && !(height==1/3&&flat_top))translate([overall_length/2,overall_width/2]) rotate_extrude($fs=cylinder_precision,$fa=5)translate([overall_length/2,0]) - square([overall_length-(sqrt(2)*knob_spacing-knob_diameter),block_height/2-wall_thickness/2],true); + square([overall_length-post_diameter,block_height/2-wall_thickness/2],true); // flat_top -> groove around bottom if (flat_top == true) { From b2cd837d07af3a96639bc13aaa668f2006c77d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20B=C3=A4r?= <93376232+UBaer21@users.noreply.github.com> Date: Tue, 9 Nov 2021 17:38:16 +0100 Subject: [PATCH 11/11] Removed name LEGO from examples --- lego_compatibility.scad | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lego_compatibility.scad b/lego_compatibility.scad index c68b9498..0dc6d3ce 100644 --- a/lego_compatibility.scad +++ b/lego_compatibility.scad @@ -4,22 +4,22 @@ // // Examples: -// // standard LEGO 4×2×1 brick solid_bottom +// // standard 4×2×1 brick solid_bottom // block(); - -// // standard LEGO 2x1 tile has no pin +// +// // standard 2x1 brick tile has no pin // block(1,2,1/3,reinforcement=false,flat_top=true); -// // standard LEGO 2x1 flat has pin +// // standard 2x1 brick flat has pin // block(1,2,1/3,reinforcement=false,solid_bottom=true,center=false); -// // standard LEGO 2x1 brick has pin +// // standard 2x1 brick has pin // block(1,2,1,reinforcement=true); -// // standard LEGO 2x1 brick without pin +// // standard 2x1 brick without pin // block(1,2,1,reinforcement=false); -// // standard LEGO 2x1x5 brick has no pin and has hollow knobs +// // standard 2x1x5 brick has no pin and has hollow knobs // block(1,2,5,reinforcement=false,hollow_knob=true); -// // standard LEGO 2x2x1/3 brick round no solid bottom +// // standard 2x2x1/3 brick round no solid bottom // block(2,2,1/3,reinforcement=true,solid_bottom=false,round=true); -// // standard LEGO 1x1x1 brick round no solid bottom +// // standard 1x1x1 brick round no solid bottom // block(1,1,1,reinforcement=true,solid_bottom=false,round=true,center=1);