discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

How best to apply offset on 2D square?

T
Terry
Sat, Jul 31, 2021 8:54 AM

I suspect that a post I made yesterday from my bt.internet address did
not make it to the list. (One acid test I can normally rely on is that
it immediately appears in Empathy, and it didn't.) So I'm posting again
from my gmail address.

I've also now added a photo of the latest covers. Following the advice
on rounding the inside corners, these are now a pleasingly tight fit.
Attached or here:

https://www.dropbox.com/s/oqyf075xhf70mzg/EndCoversSmallWhite-20210730.jpg?raw=1

I printed several covers of various sizes. But I'm now trying to
parameterise the code. I'm baffled why the thickness is not 2mm on all
four sides?

Screenshot attached or here:
https://www.dropbox.com/s/n1nczlc1ksue0fc/PuzzlingError.jpg?raw=1

Current code:

$fn=40;

//Example
Thick = 2;
InnerWidth = 67.8;
InnerHeight = 54.9;
Lip = 8;
Round = 3;
OuterWidth = InnerWidth + 2Thick;
OuterHeight = InnerHeight + 2
Thick;

linear_extrude(Lip)

difference() {

// Apply rounding of Round to both
// outer and inner squares
// Before applying offset, reduce
// dimensions to compensate
offset (Round) // Applies rounding
offset(-Round) // Reduces dimensions  
square([OuterWidth, InnerWidth], true);
// Required inner square has same inner
// dimensions as exterior of guttering
// and thickness of 2mm
// Before applying offset reduce
// dimensions to compensate
offset (Round) // Applies rounding
offset(-Round) // Reduces dimensions  
square([InnerWidth, InnerHeight], true);

}
// Add back cover, 1 larger than inner square
translate([0,0,1])
#cube([InnerWidth+1, InnerHeight+1, Thick], true);

Terry

I suspect that a post I made yesterday from my bt.internet address did not make it to the list. (One acid test I can normally rely on is that it immediately appears in Empathy, and it didn't.) So I'm posting again from my gmail address. I've also now added a photo of the latest covers. Following the advice on rounding the *inside* corners, these are now a pleasingly tight fit. Attached or here: https://www.dropbox.com/s/oqyf075xhf70mzg/EndCoversSmallWhite-20210730.jpg?raw=1 -------------------- I printed several covers of various sizes. But I'm now trying to parameterise the code. I'm baffled why the thickness is not 2mm on all four sides? Screenshot attached or here: https://www.dropbox.com/s/n1nczlc1ksue0fc/PuzzlingError.jpg?raw=1 Current code: $fn=40; //Example Thick = 2; InnerWidth = 67.8; InnerHeight = 54.9; Lip = 8; Round = 3; OuterWidth = InnerWidth + 2*Thick; OuterHeight = InnerHeight + 2*Thick; linear_extrude(Lip) difference() { // Apply rounding of Round to both // outer and inner squares // Before applying offset, reduce // dimensions to compensate offset (Round) // Applies rounding offset(-Round) // Reduces dimensions square([OuterWidth, InnerWidth], true); // Required inner square has same inner // dimensions as exterior of guttering // and thickness of 2mm // Before applying offset reduce // dimensions to compensate offset (Round) // Applies rounding offset(-Round) // Reduces dimensions square([InnerWidth, InnerHeight], true); } // Add back cover, 1 larger than inner square translate([0,0,1]) #cube([InnerWidth+1, InnerHeight+1, Thick], true); Terry
NH
nop head
Sat, Jul 31, 2021 9:52 AM

I think your first square should be: square([OuterWidth,OuterWidth], true);

On Sat, 31 Jul 2021 at 09:55, Terry terrypingm@gmail.com wrote:

I suspect that a post I made yesterday from my bt.internet address did
not make it to the list. (One acid test I can normally rely on is that
it immediately appears in Empathy, and it didn't.) So I'm posting again
from my gmail address.

I've also now added a photo of the latest covers. Following the advice
on rounding the inside corners, these are now a pleasingly tight fit.
Attached or here:

https://www.dropbox.com/s/oqyf075xhf70mzg/EndCoversSmallWhite-20210730.jpg?raw=1

I printed several covers of various sizes. But I'm now trying to
parameterise the code. I'm baffled why the thickness is not 2mm on all
four sides?

Screenshot attached or here:
https://www.dropbox.com/s/n1nczlc1ksue0fc/PuzzlingError.jpg?raw=1

Current code:

$fn=40;

//Example
Thick = 2;
InnerWidth = 67.8;
InnerHeight = 54.9;
Lip = 8;
Round = 3;
OuterWidth = InnerWidth + 2Thick;
OuterHeight = InnerHeight + 2
Thick;

linear_extrude(Lip)

difference() {

 // Apply rounding of Round to both
 // outer and inner squares
 // Before applying offset, reduce
 // dimensions to compensate
 offset (Round) // Applies rounding
 offset(-Round) // Reduces dimensions
 square([OuterWidth, InnerWidth], true);
 // Required inner square has same inner
 // dimensions as exterior of guttering
 // and thickness of 2mm
 // Before applying offset reduce
 // dimensions to compensate
 offset (Round) // Applies rounding
 offset(-Round) // Reduces dimensions
 square([InnerWidth, InnerHeight], true);

}
// Add back cover, 1 larger than inner square
translate([0,0,1])
#cube([InnerWidth+1, InnerHeight+1, Thick], true);

Terry


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I think your first square should be: square([OuterWidth,OuterWidth], true); On Sat, 31 Jul 2021 at 09:55, Terry <terrypingm@gmail.com> wrote: > I suspect that a post I made yesterday from my bt.internet address did > not make it to the list. (One acid test I can normally rely on is that > it immediately appears in Empathy, and it didn't.) So I'm posting again > from my gmail address. > > I've also now added a photo of the latest covers. Following the advice > on rounding the *inside* corners, these are now a pleasingly tight fit. > Attached or here: > > > https://www.dropbox.com/s/oqyf075xhf70mzg/EndCoversSmallWhite-20210730.jpg?raw=1 > -------------------- > > I printed several covers of various sizes. But I'm now trying to > parameterise the code. I'm baffled why the thickness is not 2mm on all > four sides? > > Screenshot attached or here: > https://www.dropbox.com/s/n1nczlc1ksue0fc/PuzzlingError.jpg?raw=1 > > Current code: > > $fn=40; > > //Example > Thick = 2; > InnerWidth = 67.8; > InnerHeight = 54.9; > Lip = 8; > Round = 3; > OuterWidth = InnerWidth + 2*Thick; > OuterHeight = InnerHeight + 2*Thick; > > > linear_extrude(Lip) > > difference() { > > // Apply rounding of Round to both > // outer and inner squares > // Before applying offset, reduce > // dimensions to compensate > offset (Round) // Applies rounding > offset(-Round) // Reduces dimensions > square([OuterWidth, InnerWidth], true); > // Required inner square has same inner > // dimensions as exterior of guttering > // and thickness of 2mm > // Before applying offset reduce > // dimensions to compensate > offset (Round) // Applies rounding > offset(-Round) // Reduces dimensions > square([InnerWidth, InnerHeight], true); > > } > // Add back cover, 1 larger than inner square > translate([0,0,1]) > #cube([InnerWidth+1, InnerHeight+1, Thick], true); > > Terry > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
T
Terry
Sat, Jul 31, 2021 11:01 AM

Thanks nop head, that was indeed the incorrect line! Been head
scratching for hours ;-)

But I think you meant to type

square([OuterWidth,OuterHeight], true);

Terry

====================

On Sat, 31 Jul 2021 10:52:54 +0100, you wrote:

I think your first square should be: square([OuterWidth,OuterWidth], true);

On Sat, 31 Jul 2021 at 09:55, Terry terrypingm@gmail.com wrote:

I suspect that a post I made yesterday from my bt.internet address did
not make it to the list. (One acid test I can normally rely on is that
it immediately appears in Empathy, and it didn't.) So I'm posting again
from my gmail address.

I've also now added a photo of the latest covers. Following the advice
on rounding the inside corners, these are now a pleasingly tight fit.
Attached or here:

https://www.dropbox.com/s/oqyf075xhf70mzg/EndCoversSmallWhite-20210730.jpg?raw=1

I printed several covers of various sizes. But I'm now trying to
parameterise the code. I'm baffled why the thickness is not 2mm on all
four sides?

Screenshot attached or here:
https://www.dropbox.com/s/n1nczlc1ksue0fc/PuzzlingError.jpg?raw=1

Current code:

$fn=40;

//Example
Thick = 2;
InnerWidth = 67.8;
InnerHeight = 54.9;
Lip = 8;
Round = 3;
OuterWidth = InnerWidth + 2Thick;
OuterHeight = InnerHeight + 2
Thick;

linear_extrude(Lip)

difference() {

// Apply rounding of Round to both
// outer and inner squares
// Before applying offset, reduce
// dimensions to compensate
offset (Round) // Applies rounding
offset(-Round) // Reduces dimensions
square([OuterWidth, InnerWidth], true);
// Required inner square has same inner
// dimensions as exterior of guttering
// and thickness of 2mm
// Before applying offset reduce
// dimensions to compensate
offset (Round) // Applies rounding
offset(-Round) // Reduces dimensions
square([InnerWidth, InnerHeight], true);

}
// Add back cover, 1 larger than inner square
translate([0,0,1])
#cube([InnerWidth+1, InnerHeight+1, Thick], true);

Terry


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Thanks nop head, that was indeed the incorrect line! Been head scratching for hours ;-) But I think you meant to type square([OuterWidth,OuterHeight], true); Terry ==================== On Sat, 31 Jul 2021 10:52:54 +0100, you wrote: >I think your first square should be: square([OuterWidth,OuterWidth], true); > >On Sat, 31 Jul 2021 at 09:55, Terry <terrypingm@gmail.com> wrote: > >> I suspect that a post I made yesterday from my bt.internet address did >> not make it to the list. (One acid test I can normally rely on is that >> it immediately appears in Empathy, and it didn't.) So I'm posting again >> from my gmail address. >> >> I've also now added a photo of the latest covers. Following the advice >> on rounding the *inside* corners, these are now a pleasingly tight fit. >> Attached or here: >> >> >> https://www.dropbox.com/s/oqyf075xhf70mzg/EndCoversSmallWhite-20210730.jpg?raw=1 >> -------------------- >> >> I printed several covers of various sizes. But I'm now trying to >> parameterise the code. I'm baffled why the thickness is not 2mm on all >> four sides? >> >> Screenshot attached or here: >> https://www.dropbox.com/s/n1nczlc1ksue0fc/PuzzlingError.jpg?raw=1 >> >> Current code: >> >> $fn=40; >> >> //Example >> Thick = 2; >> InnerWidth = 67.8; >> InnerHeight = 54.9; >> Lip = 8; >> Round = 3; >> OuterWidth = InnerWidth + 2*Thick; >> OuterHeight = InnerHeight + 2*Thick; >> >> >> linear_extrude(Lip) >> >> difference() { >> >> // Apply rounding of Round to both >> // outer and inner squares >> // Before applying offset, reduce >> // dimensions to compensate >> offset (Round) // Applies rounding >> offset(-Round) // Reduces dimensions >> square([OuterWidth, InnerWidth], true); >> // Required inner square has same inner >> // dimensions as exterior of guttering >> // and thickness of 2mm >> // Before applying offset reduce >> // dimensions to compensate >> offset (Round) // Applies rounding >> offset(-Round) // Reduces dimensions >> square([InnerWidth, InnerHeight], true); >> >> } >> // Add back cover, 1 larger than inner square >> translate([0,0,1]) >> #cube([InnerWidth+1, InnerHeight+1, Thick], true); >> >> Terry >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >>
RW
Ray West
Sat, Jul 31, 2021 11:42 AM

Hi Terry,

Here's a fishing rod -

//rounded cube etc.

 ht = 30;     // height of profile
  lno = 40 ;    // length outside
  wh = 50;  // width outside
  th = 1.5 ;    // wall thickness
 rot = 3;   // outside radius
 rin = 1.5;    // inside radius

  cutt= 20; //height of box to top cut

  cutlid =6; //height of lid
  cl=0.3; // clearance for lid

   $fn=100;

  //profile(lno,wh,ht,th,rot,rin);
 // base(cutt,lno,wh,ht,th,rot,rin);
  lid(cutlid,lno,wh,ht,th,rot,rin,cl);

////////////////////////////////////////////////////////////////////////////////////////////////////

   module lid(cutl,l,w,h,t,ro,ri,cl){
   cut1=cutl;
   l1=l+cl+t+t;
   w1=w+cl+t+t;
   h1=h+t;
   t1=t;
   ri1=ro+cl;
   ro1=ri1+t;
   base (cut1,l1,w1,h1,t1,ro1,ri1);
     }

   module base(cut,l,w,h,t,ro,ri)   {
       difference(){
          profile(l,w,h,t,ro,ri);
            translate([0,0, h+cut])   cube([3l,3w,3*h],true);
          }
   }

   module profile(l,w,h,t,ro,ri){
       li=l-t-t;
       wi=w-t-t;
       hi=h-t-t;
       echo(li,wi);
    difference(){
       rounded(l,w,h,ro);
         rounded(li,wi,hi,ri);
  }
  }

   module rounded(l,w,h,r){
       x=(l/2)-r;
       y=(w/2)-r;
       z=(h/2)-r;
     hull(){
       translate([x,y,z])sphere(r);
       translate([x,-y,z])sphere(r);
       translate([-x,-y,z])sphere(r);
       translate([-x,y,z])sphere(r);
       translate([x,y,-z])sphere(r);
       translate([x,-y,-z])sphere(r);
       translate([-x,-y,-z])sphere(r);
       translate([-x,y,-z])sphere(r);
     }
   }

// that's it

A generic solution for a box, which rounds all corners, not very fast in
rendering 'cos of the hulls. it will make a box with outside fitted lid,
you can use it as a cap, just set profile values to size of your
trunking, then the cutlid to the depth of the lid/cover that you want.
make ht greater than cutlid of course.  Although it could be made more
parametric, in as much as usually ro=ri*th, sometimes you may need a
sharper inner corner, and are happy with a thinner wall thickness at the
corner. Uncomment/comment the items you want to look at - profile, base, lid

NB, had some fun using 'ln' instead of 'lno' ;-)

NB2, 'ht' will be the length of your pipe   set 'rot' to corner radius
of pipe, ('rin' to something a bit smaller) and 'cutlid' to height of
your lid, 'cutt' to something bigger than 'cutlid', but less than 'ht',
set 'cl' to allow for printing errors/whatever. I think that is all the
oddities. Your slicer will place it on the build plate.

Hi Terry, Here's a fishing rod - //rounded cube etc.  ht = 30;     // height of profile   lno = 40 ;    // length outside   wh = 50;  // width outside   th = 1.5 ;    // wall thickness  rot = 3;   // outside radius  rin = 1.5;    // inside radius   cutt= 20; //height of box to top cut   cutlid =6; //height of lid   cl=0.3; // clearance for lid    $fn=100;   //profile(lno,wh,ht,th,rot,rin);  // base(cutt,lno,wh,ht,th,rot,rin);   lid(cutlid,lno,wh,ht,th,rot,rin,cl); ////////////////////////////////////////////////////////////////////////////////////////////////////    module lid(cutl,l,w,h,t,ro,ri,cl){    cut1=cutl;    l1=l+cl+t+t;    w1=w+cl+t+t;    h1=h+t;    t1=t;    ri1=ro+cl;    ro1=ri1+t;    base (cut1,l1,w1,h1,t1,ro1,ri1);      }    module base(cut,l,w,h,t,ro,ri)   {        difference(){           profile(l,w,h,t,ro,ri);             translate([0,0, h+cut])   cube([3*l,3*w,3*h],true);           }    }    module profile(l,w,h,t,ro,ri){        li=l-t-t;        wi=w-t-t;        hi=h-t-t;        echo(li,wi);     difference(){        rounded(l,w,h,ro);          rounded(li,wi,hi,ri);   }   }    module rounded(l,w,h,r){        x=(l/2)-r;        y=(w/2)-r;        z=(h/2)-r;      hull(){        translate([x,y,z])sphere(r);        translate([x,-y,z])sphere(r);        translate([-x,-y,z])sphere(r);        translate([-x,y,z])sphere(r);        translate([x,y,-z])sphere(r);        translate([x,-y,-z])sphere(r);        translate([-x,-y,-z])sphere(r);        translate([-x,y,-z])sphere(r);      }    } // that's it A generic solution for a box, which rounds all corners, not very fast in rendering 'cos of the hulls. it will make a box with outside fitted lid, you can use it as a cap, just set profile values to size of your trunking, then the cutlid to the depth of the lid/cover that you want. make ht greater than cutlid of course.  Although it could be made more parametric, in as much as usually ro=ri*th, sometimes you may need a sharper inner corner, and are happy with a thinner wall thickness at the corner. Uncomment/comment the items you want to look at - profile, base, lid NB, had some fun using 'ln' instead of 'lno' ;-) NB2, 'ht' will be the length of your pipe   set 'rot' to corner radius of pipe, ('rin' to something a bit smaller) and 'cutlid' to height of your lid, 'cutt' to something bigger than 'cutlid', but less than 'ht', set 'cl' to allow for printing errors/whatever. I think that is all the oddities. Your slicer will place it on the build plate.
NH
nop head
Sat, Jul 31, 2021 12:11 PM

But I think you meant to type square([OuterWidth,OuterHeight], true);

Indeed. I would code that a lot more simpler with the help of my library
where I have round() which encapsulates the two offsets. And instead of two
radii I simply offset the inside to make the outside. And I also have a
rounded_square() module.

So I do this:

include <NopSCADlib/lib.scad>

module inside_shape() rounded_square([OuterWidth,OuterHeight], rin, true);
module outside_shape() offset(th) inside_shape();

linear_extrude(Lip)
difference() {
outside_shape();
inside_shape();
}
linear_extrude(Thick)
outside_shape();

I don't like typing and I try to avoid repeating anything.

On Sat, 31 Jul 2021 at 12:43, Ray West raywest@raywest.com wrote:

Hi Terry,

Here's a fishing rod -

//rounded cube etc.

ht = 30;    // height of profile
lno = 40 ;    // length outside
wh = 50;  // width outside
th = 1.5 ;    // wall thickness
rot = 3;  // outside radius
rin = 1.5;    // inside radius

cutt= 20; //height of box to top cut

cutlid =6; //height of lid
cl=0.3; // clearance for lid

 $fn=100;


//profile(lno,wh,ht,th,rot,rin);

// base(cutt,lno,wh,ht,th,rot,rin);
lid(cutlid,lno,wh,ht,th,rot,rin,cl);

////////////////////////////////////////////////////////////////////////////////////////////////////

 module lid(cutl,l,w,h,t,ro,ri,cl){
 cut1=cutl;
 l1=l+cl+t+t;
 w1=w+cl+t+t;
 h1=h+t;
 t1=t;
 ri1=ro+cl;
 ro1=ri1+t;
 base (cut1,l1,w1,h1,t1,ro1,ri1);
   }

 module base(cut,l,w,h,t,ro,ri)   {
     difference(){
        profile(l,w,h,t,ro,ri);
          translate([0,0, h+cut])   cube([3*l,3*w,3*h],true);
        }
 }

 module profile(l,w,h,t,ro,ri){
     li=l-t-t;
     wi=w-t-t;
     hi=h-t-t;
     echo(li,wi);
  difference(){
     rounded(l,w,h,ro);
       rounded(li,wi,hi,ri);
}
}


 module rounded(l,w,h,r){
     x=(l/2)-r;
     y=(w/2)-r;
     z=(h/2)-r;
   hull(){
     translate([x,y,z])sphere(r);
     translate([x,-y,z])sphere(r);
     translate([-x,-y,z])sphere(r);
     translate([-x,y,z])sphere(r);
     translate([x,y,-z])sphere(r);
     translate([x,-y,-z])sphere(r);
     translate([-x,-y,-z])sphere(r);
     translate([-x,y,-z])sphere(r);
   }
 }

// that's it

A generic solution for a box, which rounds all corners, not very fast in
rendering 'cos of the hulls. it will make a box with outside fitted lid,
you can use it as a cap, just set profile values to size of your
trunking, then the cutlid to the depth of the lid/cover that you want.
make ht greater than cutlid of course.  Although it could be made more
parametric, in as much as usually ro=ri*th, sometimes you may need a
sharper inner corner, and are happy with a thinner wall thickness at the
corner. Uncomment/comment the items you want to look at - profile, base,
lid

NB, had some fun using 'ln' instead of 'lno' ;-)

NB2, 'ht' will be the length of your pipe  set 'rot' to corner radius
of pipe, ('rin' to something a bit smaller) and 'cutlid' to height of
your lid, 'cutt' to something bigger than 'cutlid', but less than 'ht',
set 'cl' to allow for printing errors/whatever. I think that is all the
oddities. Your slicer will place it on the build plate.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

> But I think you meant to type square([OuterWidth,OuterHeight], true); Indeed. I would code that a lot more simpler with the help of my library where I have round() which encapsulates the two offsets. And instead of two radii I simply offset the inside to make the outside. And I also have a rounded_square() module. So I do this: include <NopSCADlib/lib.scad> module inside_shape() rounded_square([OuterWidth,OuterHeight], rin, true); module outside_shape() offset(th) inside_shape(); linear_extrude(Lip) difference() { outside_shape(); inside_shape(); } linear_extrude(Thick) outside_shape(); I don't like typing and I try to avoid repeating anything. On Sat, 31 Jul 2021 at 12:43, Ray West <raywest@raywest.com> wrote: > Hi Terry, > > Here's a fishing rod - > > //rounded cube etc. > > ht = 30; // height of profile > lno = 40 ; // length outside > wh = 50; // width outside > th = 1.5 ; // wall thickness > rot = 3; // outside radius > rin = 1.5; // inside radius > > > cutt= 20; //height of box to top cut > > cutlid =6; //height of lid > cl=0.3; // clearance for lid > > $fn=100; > > > //profile(lno,wh,ht,th,rot,rin); > // base(cutt,lno,wh,ht,th,rot,rin); > lid(cutlid,lno,wh,ht,th,rot,rin,cl); > > > //////////////////////////////////////////////////////////////////////////////////////////////////// > > module lid(cutl,l,w,h,t,ro,ri,cl){ > cut1=cutl; > l1=l+cl+t+t; > w1=w+cl+t+t; > h1=h+t; > t1=t; > ri1=ro+cl; > ro1=ri1+t; > base (cut1,l1,w1,h1,t1,ro1,ri1); > } > > module base(cut,l,w,h,t,ro,ri) { > difference(){ > profile(l,w,h,t,ro,ri); > translate([0,0, h+cut]) cube([3*l,3*w,3*h],true); > } > } > > module profile(l,w,h,t,ro,ri){ > li=l-t-t; > wi=w-t-t; > hi=h-t-t; > echo(li,wi); > difference(){ > rounded(l,w,h,ro); > rounded(li,wi,hi,ri); > } > } > > > module rounded(l,w,h,r){ > x=(l/2)-r; > y=(w/2)-r; > z=(h/2)-r; > hull(){ > translate([x,y,z])sphere(r); > translate([x,-y,z])sphere(r); > translate([-x,-y,z])sphere(r); > translate([-x,y,z])sphere(r); > translate([x,y,-z])sphere(r); > translate([x,-y,-z])sphere(r); > translate([-x,-y,-z])sphere(r); > translate([-x,y,-z])sphere(r); > } > } > > // that's it > > A generic solution for a box, which rounds all corners, not very fast in > rendering 'cos of the hulls. it will make a box with outside fitted lid, > you can use it as a cap, just set profile values to size of your > trunking, then the cutlid to the depth of the lid/cover that you want. > make ht greater than cutlid of course. Although it could be made more > parametric, in as much as usually ro=ri*th, sometimes you may need a > sharper inner corner, and are happy with a thinner wall thickness at the > corner. Uncomment/comment the items you want to look at - profile, base, > lid > > NB, had some fun using 'ln' instead of 'lno' ;-) > > NB2, 'ht' will be the length of your pipe set 'rot' to corner radius > of pipe, ('rin' to something a bit smaller) and 'cutlid' to height of > your lid, 'cutt' to something bigger than 'cutlid', but less than 'ht', > set 'cl' to allow for printing errors/whatever. I think that is all the > oddities. Your slicer will place it on the build plate. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RW
Ray West
Sat, Jul 31, 2021 1:04 PM

On 31/07/2021 13:11, nop head wrote:

I don't like typing and I try to avoid repeating anything.

I'm with you in that. A hang over from when punch card operators entered
my code, and variable names restricted to max of 4 chars, starting with
i to n for integers, etc. Fortran IV, g and h, iirc. 8k core memory, etc.

On 31/07/2021 13:11, nop head wrote: > I don't like typing and I try to avoid repeating anything. I'm with you in that. A hang over from when punch card operators entered my code, and variable names restricted to max of 4 chars, starting with i to n for integers, etc. Fortran IV, g and h, iirc. 8k core memory, etc.
T
Terry
Sat, Jul 31, 2021 2:10 PM

Excellent, thanks Ray, I'll have fun with that.

Yeah, I too struggle with that lack of distinction between EYE, ONE and
ELL. Is it the same on a Mac?

An ambiguity of another type that sometimes gets me in trouble is
width/length/height!

BTW, they didn't interfere with preview or rendering so what do these
warnings mean?

WARNING: Ignoring unknown variable '3l' in file Ray.scad, line 37
WARNING: Ignoring unknown variable '3w' in file Ray.scad, line 37
WARNING: Unable to convert cube(size=[undef, undef, 154.5], ...)
parameter to a number or a vec3 of numbers in file Ray.scad, line 37

Terry

====================

On Sat, 31 Jul 2021 12:42:54 +0100, you wrote:

Hi Terry,

Here's a fishing rod -

//rounded cube etc.

 ht = 30;     // height of profile
  lno = 40 ;    // length outside
  wh = 50;  // width outside
  th = 1.5 ;    // wall thickness
 rot = 3;   // outside radius
 rin = 1.5;    // inside radius

  cutt= 20; //height of box to top cut

  cutlid =6; //height of lid
  cl=0.3; // clearance for lid

   $fn=100;

  //profile(lno,wh,ht,th,rot,rin);
 // base(cutt,lno,wh,ht,th,rot,rin);
  lid(cutlid,lno,wh,ht,th,rot,rin,cl);

////////////////////////////////////////////////////////////////////////////////////////////////////

   module lid(cutl,l,w,h,t,ro,ri,cl){
   cut1=cutl;
   l1=l+cl+t+t;
   w1=w+cl+t+t;
   h1=h+t;
   t1=t;
   ri1=ro+cl;
   ro1=ri1+t;
   base (cut1,l1,w1,h1,t1,ro1,ri1);
     }

   module base(cut,l,w,h,t,ro,ri)   {
       difference(){
          profile(l,w,h,t,ro,ri);
            translate([0,0, h+cut])   cube([3l,3w,3*h],true);
          }
   }

   module profile(l,w,h,t,ro,ri){
       li=l-t-t;
       wi=w-t-t;
       hi=h-t-t;
       echo(li,wi);
    difference(){
       rounded(l,w,h,ro);
         rounded(li,wi,hi,ri);
  }
  }

   module rounded(l,w,h,r){
       x=(l/2)-r;
       y=(w/2)-r;
       z=(h/2)-r;
     hull(){
       translate([x,y,z])sphere(r);
       translate([x,-y,z])sphere(r);
       translate([-x,-y,z])sphere(r);
       translate([-x,y,z])sphere(r);
       translate([x,y,-z])sphere(r);
       translate([x,-y,-z])sphere(r);
       translate([-x,-y,-z])sphere(r);
       translate([-x,y,-z])sphere(r);
     }
   }

// that's it

A generic solution for a box, which rounds all corners, not very fast in
rendering 'cos of the hulls. it will make a box with outside fitted lid,
you can use it as a cap, just set profile values to size of your
trunking, then the cutlid to the depth of the lid/cover that you want.
make ht greater than cutlid of course.  Although it could be made more
parametric, in as much as usually ro=ri*th, sometimes you may need a
sharper inner corner, and are happy with a thinner wall thickness at the
corner. Uncomment/comment the items you want to look at - profile, base, lid

NB, had some fun using 'ln' instead of 'lno' ;-)

NB2, 'ht' will be the length of your pipe   set 'rot' to corner radius
of pipe, ('rin' to something a bit smaller) and 'cutlid' to height of
your lid, 'cutt' to something bigger than 'cutlid', but less than 'ht',
set 'cl' to allow for printing errors/whatever. I think that is all the
oddities. Your slicer will place it on the build plate.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Excellent, thanks Ray, I'll have fun with that. Yeah, I too struggle with that lack of distinction between EYE, ONE and ELL. Is it the same on a Mac? An ambiguity of another type that sometimes gets me in trouble is width/length/height! BTW, they didn't interfere with preview or rendering so what do these warnings mean? WARNING: Ignoring unknown variable '3l' in file Ray.scad, line 37 WARNING: Ignoring unknown variable '3w' in file Ray.scad, line 37 WARNING: Unable to convert cube(size=[undef, undef, 154.5], ...) parameter to a number or a vec3 of numbers in file Ray.scad, line 37 Terry ==================== On Sat, 31 Jul 2021 12:42:54 +0100, you wrote: >Hi Terry, > >Here's a fishing rod - > >//rounded cube etc. > >  ht = 30;     // height of profile >   lno = 40 ;    // length outside >   wh = 50;  // width outside >   th = 1.5 ;    // wall thickness >  rot = 3;   // outside radius >  rin = 1.5;    // inside radius > > >   cutt= 20; //height of box to top cut > >   cutlid =6; //height of lid >   cl=0.3; // clearance for lid > >    $fn=100; > > >   //profile(lno,wh,ht,th,rot,rin); >  // base(cutt,lno,wh,ht,th,rot,rin); >   lid(cutlid,lno,wh,ht,th,rot,rin,cl); > >//////////////////////////////////////////////////////////////////////////////////////////////////// > >    module lid(cutl,l,w,h,t,ro,ri,cl){ >    cut1=cutl; >    l1=l+cl+t+t; >    w1=w+cl+t+t; >    h1=h+t; >    t1=t; >    ri1=ro+cl; >    ro1=ri1+t; >    base (cut1,l1,w1,h1,t1,ro1,ri1); >      } > >    module base(cut,l,w,h,t,ro,ri)   { >        difference(){ >           profile(l,w,h,t,ro,ri); >             translate([0,0, h+cut])   cube([3*l,3*w,3*h],true); >           } >    } > >    module profile(l,w,h,t,ro,ri){ >        li=l-t-t; >        wi=w-t-t; >        hi=h-t-t; >        echo(li,wi); >     difference(){ >        rounded(l,w,h,ro); >          rounded(li,wi,hi,ri); >   } >   } > > >    module rounded(l,w,h,r){ >        x=(l/2)-r; >        y=(w/2)-r; >        z=(h/2)-r; >      hull(){ >        translate([x,y,z])sphere(r); >        translate([x,-y,z])sphere(r); >        translate([-x,-y,z])sphere(r); >        translate([-x,y,z])sphere(r); >        translate([x,y,-z])sphere(r); >        translate([x,-y,-z])sphere(r); >        translate([-x,-y,-z])sphere(r); >        translate([-x,y,-z])sphere(r); >      } >    } > >// that's it > >A generic solution for a box, which rounds all corners, not very fast in >rendering 'cos of the hulls. it will make a box with outside fitted lid, >you can use it as a cap, just set profile values to size of your >trunking, then the cutlid to the depth of the lid/cover that you want. >make ht greater than cutlid of course.  Although it could be made more >parametric, in as much as usually ro=ri*th, sometimes you may need a >sharper inner corner, and are happy with a thinner wall thickness at the >corner. Uncomment/comment the items you want to look at - profile, base, lid > >NB, had some fun using 'ln' instead of 'lno' ;-) > >NB2, 'ht' will be the length of your pipe   set 'rot' to corner radius >of pipe, ('rin' to something a bit smaller) and 'cutlid' to height of >your lid, 'cutt' to something bigger than 'cutlid', but less than 'ht', >set 'cl' to allow for printing errors/whatever. I think that is all the >oddities. Your slicer will place it on the build plate. > >_______________________________________________ >OpenSCAD mailing list >To unsubscribe send an email to discuss-leave@lists.openscad.org
TP
Torsten Paul
Sat, Jul 31, 2021 2:40 PM

On 31.07.21 16:10, Terry wrote:

WARNING: Ignoring unknown variable '3l' in file Ray.scad, line 37
WARNING: Ignoring unknown variable '3w' in file Ray.scad, line 37
WARNING: Unable to convert cube(size=[undef, undef, 154.5], ...)
parameter to a number or a vec3 of numbers in file Ray.scad, line 37

That's very likely this line:

translate([0,0, h+cut])   cube([3l,3w,3*h],true);

missing two "*" so instead of calculating 3 * l it's trying to find
the variable "3l". In turn that's then causing those 2 undef of the
3rd warning.

ciao,
Torsten.

On 31.07.21 16:10, Terry wrote: > WARNING: Ignoring unknown variable '3l' in file Ray.scad, line 37 > WARNING: Ignoring unknown variable '3w' in file Ray.scad, line 37 > WARNING: Unable to convert cube(size=[undef, undef, 154.5], ...) > parameter to a number or a vec3 of numbers in file Ray.scad, line 37 That's very likely this line: > translate([0,0, h+cut])   cube([3*l,3*w,3*h],true); missing two "*" so instead of calculating 3 * l it's trying to find the variable "3l". In turn that's then causing those 2 undef of the 3rd warning. ciao, Torsten.
RW
Ray West
Sat, Jul 31, 2021 3:15 PM

Hi Terry,

I think Torsten is correct, but the code I copied and pasted to the
email, is correct, no warning messages (but I'd  left in a few echo's).
You ought to be able to highlight the text in the email, copy to
clipboard, then paste into a new openscad edit window. I've just done
that to check, and all 3's are followed by an *. It is all OK.  Not sure
if that works on apple or linux, but fine on windoze.

fwiw, 'ln' is a reserved openscad word for log, luckily it showed as
green, but it sort of froze the calculation, and the editor window. A
courier font is probably better for distinguishing characters, but I
expect there are better ones now - Verdana seems pretty good.

On 31/07/2021 15:10, Terry wrote:

Excellent, thanks Ray, I'll have fun with that.

Yeah, I too struggle with that lack of distinction between EYE, ONE and
ELL. Is it the same on a Mac?

An ambiguity of another type that sometimes gets me in trouble is
width/length/height!

BTW, they didn't interfere with preview or rendering so what do these
warnings mean?

WARNING: Ignoring unknown variable '3l' in file Ray.scad, line 37
WARNING: Ignoring unknown variable '3w' in file Ray.scad, line 37
WARNING: Unable to convert cube(size=[undef, undef, 154.5], ...)
parameter to a number or a vec3 of numbers in file Ray.scad, line 37

Terry

====================

On Sat, 31 Jul 2021 12:42:54 +0100, you wrote:

Hi Terry,

Here's a fishing rod -

//rounded cube etc.

 ht = 30;     // height of profile
  lno = 40 ;    // length outside
  wh = 50;  // width outside
  th = 1.5 ;    // wall thickness
 rot = 3;   // outside radius
 rin = 1.5;    // inside radius

  cutt= 20; //height of box to top cut

  cutlid =6; //height of lid
  cl=0.3; // clearance for lid

   $fn=100;

  //profile(lno,wh,ht,th,rot,rin);
 // base(cutt,lno,wh,ht,th,rot,rin);
  lid(cutlid,lno,wh,ht,th,rot,rin,cl);

////////////////////////////////////////////////////////////////////////////////////////////////////

   module lid(cutl,l,w,h,t,ro,ri,cl){
   cut1=cutl;
   l1=l+cl+t+t;
   w1=w+cl+t+t;
   h1=h+t;
   t1=t;
   ri1=ro+cl;
   ro1=ri1+t;
   base (cut1,l1,w1,h1,t1,ro1,ri1);
     }

   module base(cut,l,w,h,t,ro,ri)   {
       difference(){
          profile(l,w,h,t,ro,ri);
            translate([0,0, h+cut])   cube([3l,3w,3*h],true);
          }
   }

   module profile(l,w,h,t,ro,ri){
       li=l-t-t;
       wi=w-t-t;
       hi=h-t-t;
       echo(li,wi);
    difference(){
       rounded(l,w,h,ro);
         rounded(li,wi,hi,ri);
  }
  }

   module rounded(l,w,h,r){
       x=(l/2)-r;
       y=(w/2)-r;
       z=(h/2)-r;
     hull(){
       translate([x,y,z])sphere(r);
       translate([x,-y,z])sphere(r);
       translate([-x,-y,z])sphere(r);
       translate([-x,y,z])sphere(r);
       translate([x,y,-z])sphere(r);
       translate([x,-y,-z])sphere(r);
       translate([-x,-y,-z])sphere(r);
       translate([-x,y,-z])sphere(r);
     }
   }

// that's it

A generic solution for a box, which rounds all corners, not very fast in
rendering 'cos of the hulls. it will make a box with outside fitted lid,
you can use it as a cap, just set profile values to size of your
trunking, then the cutlid to the depth of the lid/cover that you want.
make ht greater than cutlid of course.  Although it could be made more
parametric, in as much as usually ro=ri*th, sometimes you may need a
sharper inner corner, and are happy with a thinner wall thickness at the
corner. Uncomment/comment the items you want to look at - profile, base, lid

NB, had some fun using 'ln' instead of 'lno' ;-)

NB2, 'ht' will be the length of your pipe   set 'rot' to corner radius
of pipe, ('rin' to something a bit smaller) and 'cutlid' to height of
your lid, 'cutt' to something bigger than 'cutlid', but less than 'ht',
set 'cl' to allow for printing errors/whatever. I think that is all the
oddities. Your slicer will place it on the build plate.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Hi Terry, I think Torsten is correct, but the code I copied and pasted to the email, is correct, no warning messages (but I'd  left in a few echo's). You ought to be able to highlight the text in the email, copy to clipboard, then paste into a new openscad edit window. I've just done that to check, and all 3's are followed by an *. It is all OK.  Not sure if that works on apple or linux, but fine on windoze. fwiw, 'ln' is a reserved openscad word for log, luckily it showed as green, but it sort of froze the calculation, and the editor window. A courier font is probably better for distinguishing characters, but I expect there are better ones now - Verdana seems pretty good. On 31/07/2021 15:10, Terry wrote: > Excellent, thanks Ray, I'll have fun with that. > > Yeah, I too struggle with that lack of distinction between EYE, ONE and > ELL. Is it the same on a Mac? > > An ambiguity of another type that sometimes gets me in trouble is > width/length/height! > > BTW, they didn't interfere with preview or rendering so what do these > warnings mean? > > WARNING: Ignoring unknown variable '3l' in file Ray.scad, line 37 > WARNING: Ignoring unknown variable '3w' in file Ray.scad, line 37 > WARNING: Unable to convert cube(size=[undef, undef, 154.5], ...) > parameter to a number or a vec3 of numbers in file Ray.scad, line 37 > > Terry > > ==================== > > > On Sat, 31 Jul 2021 12:42:54 +0100, you wrote: > >> Hi Terry, >> >> Here's a fishing rod - >> >> //rounded cube etc. >> >>  ht = 30;     // height of profile >>   lno = 40 ;    // length outside >>   wh = 50;  // width outside >>   th = 1.5 ;    // wall thickness >>  rot = 3;   // outside radius >>  rin = 1.5;    // inside radius >> >> >>   cutt= 20; //height of box to top cut >> >>   cutlid =6; //height of lid >>   cl=0.3; // clearance for lid >> >>    $fn=100; >> >> >>   //profile(lno,wh,ht,th,rot,rin); >>  // base(cutt,lno,wh,ht,th,rot,rin); >>   lid(cutlid,lno,wh,ht,th,rot,rin,cl); >> >> //////////////////////////////////////////////////////////////////////////////////////////////////// >> >>    module lid(cutl,l,w,h,t,ro,ri,cl){ >>    cut1=cutl; >>    l1=l+cl+t+t; >>    w1=w+cl+t+t; >>    h1=h+t; >>    t1=t; >>    ri1=ro+cl; >>    ro1=ri1+t; >>    base (cut1,l1,w1,h1,t1,ro1,ri1); >>      } >> >>    module base(cut,l,w,h,t,ro,ri)   { >>        difference(){ >>           profile(l,w,h,t,ro,ri); >>             translate([0,0, h+cut])   cube([3*l,3*w,3*h],true); >>           } >>    } >> >>    module profile(l,w,h,t,ro,ri){ >>        li=l-t-t; >>        wi=w-t-t; >>        hi=h-t-t; >>        echo(li,wi); >>     difference(){ >>        rounded(l,w,h,ro); >>          rounded(li,wi,hi,ri); >>   } >>   } >> >> >>    module rounded(l,w,h,r){ >>        x=(l/2)-r; >>        y=(w/2)-r; >>        z=(h/2)-r; >>      hull(){ >>        translate([x,y,z])sphere(r); >>        translate([x,-y,z])sphere(r); >>        translate([-x,-y,z])sphere(r); >>        translate([-x,y,z])sphere(r); >>        translate([x,y,-z])sphere(r); >>        translate([x,-y,-z])sphere(r); >>        translate([-x,-y,-z])sphere(r); >>        translate([-x,y,-z])sphere(r); >>      } >>    } >> >> // that's it >> >> A generic solution for a box, which rounds all corners, not very fast in >> rendering 'cos of the hulls. it will make a box with outside fitted lid, >> you can use it as a cap, just set profile values to size of your >> trunking, then the cutlid to the depth of the lid/cover that you want. >> make ht greater than cutlid of course.  Although it could be made more >> parametric, in as much as usually ro=ri*th, sometimes you may need a >> sharper inner corner, and are happy with a thinner wall thickness at the >> corner. Uncomment/comment the items you want to look at - profile, base, lid >> >> NB, had some fun using 'ln' instead of 'lno' ;-) >> >> NB2, 'ht' will be the length of your pipe   set 'rot' to corner radius >> of pipe, ('rin' to something a bit smaller) and 'cutlid' to height of >> your lid, 'cutt' to something bigger than 'cutlid', but less than 'ht', >> set 'cl' to allow for printing errors/whatever. I think that is all the >> oddities. Your slicer will place it on the build plate. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
TP
Torsten Paul
Sat, Jul 31, 2021 3:30 PM

On 31.07.21 17:15, Ray West wrote:

A courier font is probably better for distinguishing characters, but
I expect there are better ones now - Verdana seems pretty good.

I'm using "Iosevka Nerd Font" as it has extra combined glyphs for
things like >= and runs quite compact.

For a long selection of such fonts, including version extended with
those special glyphs, see:

https://github.com/ryanoasis/nerd-fonts

List of fonts with some example images:

https://www.nerdfonts.com/font-downloads

There should be something for everyone's taste :-). The overview
page also links to the original font versions, in case the hacked
ones are not preferred.

ciao,
Torsten.

On 31.07.21 17:15, Ray West wrote: > A courier font is probably better for distinguishing characters, but > I expect there are better ones now - Verdana seems pretty good. I'm using "Iosevka Nerd Font" as it has extra combined glyphs for things like >= and runs quite compact. For a long selection of such fonts, including version extended with those special glyphs, see: https://github.com/ryanoasis/nerd-fonts List of fonts with some example images: https://www.nerdfonts.com/font-downloads There should be something for everyone's taste :-). The overview page also links to the original font versions, in case the hacked ones are not preferred. ciao, Torsten.