discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Build a wall for a box - here is the profile

Jan Öhman
Tue, Mar 22, 2022 11:45 PM

Hi!

Background .:( I'm trying to learn openSCAD)
Had intended to build a protective box for a position light to be placed on a trailer.
Instead of drawing a "boring" square box, I thought it would follow the shape of the lamp. (which requires rounded shapes)
I have built a 2D model of the wall.It has a straight outside and a sloping inside.(and looks a bit like an "L") Later I thought to supplement with a bottom.

My desire .:
Did I start right? (or is it better to start with a block and remove unwanted material?)Is it difficult to build a shape and make it follow a curve (eg Bezzier)

Below I have made a "shape" and two examples of "curves" to follow.

A "shape" of the wall  to the box .: (excuse comments in Swedish)_______________________________________________________________________
$fn=20;wall();
module wall(){    b =  4;     // botten - tjocklek    f =  6;     // Foten    h = 15;     // Höjd    t =  3.5;   // Top        // Beräkna skärningspunkt mellan botten och fot - y = kx + m - den inre radien    /*    k = -h / (f-t);    m = h - (k*t);    x = (b - m) / k;    echo(k,m,x);    */    // x = (b - (h - ( (-h / (f-t)) *t) )) / (-h / (f-t));    x = (b+(t/2) - (h - ( (-h / (f-t)) *t) )) / (-h / (f-t));    // echo(x);            rotate([90, 0, 180]){        polygon( points=[[0,0], [f,0], [t,h], [0,h]] );            translate([t/2, h, 0])            circle(d=t);            square([10, b]);                difference(){        translate([x, b])            square([t/2, t/2]);            translate([x+(t/2), b+(t/2), 0])            circle(d = t);  // Samma radie som toppen}}}_______________________________________________________________________

First thought to build the wall in the following way (but did not get the right structure)
Now this is only teslines as the wall above maybe can follow? (if possible)_______________________________________________________________________

// a curve (line) [p1, p2] with two pointsp1a = [2, 5];p2a = [3, 15];n1 = 5;
for (i = [0 : 1/n1 : 1 - (1 / n1)]){    i1 = i + (1/n1);    echo(i,   i1);    hull(){         translate( p1a * i  + p2a * (1-i))            color("pink") sphere(0.2);        translate( p1a * i1 + p2a * (1-i1))            color("green") sphere(0.2);    }}

// a Bézier curve [p1, p2, p3]$fn = 30;   // Upplösningn2 = 80;    // Antal beräkningspunkter
p1b = [5, 7.5];p2b = [8, 2];p3b = [1, 1.7];
for (i3 = [0 : 1/n2 : 1 - (1 / n2)]){    i4 = i3 + (1/n2);    hull(){    translate((p1b * i3 + p2b * (1-i3)) * i3 + (p2b * i3 + p3b * (1 - i3)) * (1 - i3))        color("pink") cylinder(r1=0.6, r2=0.3, h=1, center=true);    translate((p1b * i4 + p2b * (1-i4)) * i4 + (p2b * i4 + p3b * (1 - i4)) * (1 - i4))        color("cyan") cylinder(r1=0.6, r2=0.3, h=1, center=true);}}

Hi! Background .:( I'm trying to learn openSCAD) Had intended to build a protective box for a position light to be placed on a trailer. Instead of drawing a "boring" square box, I thought it would follow the shape of the lamp. (which requires rounded shapes) I have built a 2D model of the wall.It has a straight outside and a sloping inside.(and looks a bit like an "L") Later I thought to supplement with a bottom. My desire .: Did I start right? (or is it better to start with a block and remove unwanted material?)Is it difficult to build a shape and make it follow a curve (eg Bezzier) Below I have made a "shape" and two examples of "curves" to follow. A "shape" of the wall  to the box .: (excuse comments in Swedish)_______________________________________________________________________ $fn=20;wall(); module wall(){    b =  4;     // botten - tjocklek    f =  6;     // Foten    h = 15;     // Höjd    t =  3.5;   // Top        // Beräkna skärningspunkt mellan botten och fot - y = kx + m - den inre radien    /*    k = -h / (f-t);    m = h - (k*t);    x = (b - m) / k;    echo(k,m,x);    */    // x = (b - (h - ( (-h / (f-t)) *t) )) / (-h / (f-t));    x = (b+(t/2) - (h - ( (-h / (f-t)) *t) )) / (-h / (f-t));    // echo(x);            rotate([90, 0, 180]){        polygon( points=[[0,0], [f,0], [t,h], [0,h]] );            translate([t/2, h, 0])            circle(d=t);            square([10, b]);                difference(){        translate([x, b])            square([t/2, t/2]);            translate([x+(t/2), b+(t/2), 0])            circle(d = t);  // Samma radie som toppen}}}_______________________________________________________________________ First thought to build the wall in the following way (but did not get the right structure) Now this is only teslines as the wall above maybe can follow? (if possible)_______________________________________________________________________ // a curve (line) [p1, p2] with two pointsp1a = [2, 5];p2a = [3, 15];n1 = 5; for (i = [0 : 1/n1 : 1 - (1 / n1)]){    i1 = i + (1/n1);    echo(i,   i1);    hull(){         translate( p1a * i  + p2a * (1-i))            color("pink") sphere(0.2);        translate( p1a * i1 + p2a * (1-i1))            color("green") sphere(0.2);    }} // a Bézier curve [p1, p2, p3]$fn = 30;   // Upplösningn2 = 80;    // Antal beräkningspunkter p1b = [5, 7.5];p2b = [8, 2];p3b = [1, 1.7]; for (i3 = [0 : 1/n2 : 1 - (1 / n2)]){    i4 = i3 + (1/n2);    hull(){    translate((p1b * i3 + p2b * (1-i3)) * i3 + (p2b * i3 + p3b * (1 - i3)) * (1 - i3))        color("pink") cylinder(r1=0.6, r2=0.3, h=1, center=true);    translate((p1b * i4 + p2b * (1-i4)) * i4 + (p2b * i4 + p3b * (1 - i4)) * (1 - i4))        color("cyan") cylinder(r1=0.6, r2=0.3, h=1, center=true);}}