discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

How best to apply offset on 2D square?

M
MichaelAtOz
Thu, Jul 29, 2021 8:36 AM

You want a higher $fn on that corner, ie round(2,$fn=16)

-----Original Message-----
From: Terry [mailto:terrypingm@gmail.com]
Sent: Thu, 29 Jul 2021 18:30
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: How best to apply offset on 2D square?

Thanks Ray, that should prove handy. Heading out so yet to study
it properly. But something odd about one of the corners that's
more obvious when viewed from the top. Attached or here:
https://www.dropbox.com/s/q18jwxjvs2r6y15/Rounding-Ray-1.jpg?raw=1

Presumably dependent on $fn?


I'm surprised there's no OpenSCAD command that emulates scissors,
or Tipp-Ex, or pasting a bit of white paper over your mistakes. It
would just make a quadrant of specified radius and let you move
(translate) it to a precise position. That's what I intuitively
wanted to do with my square corners ;-)

Terry

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

On Thu, 29 Jul 2021 00:52:48 +0100, you wrote:

If I want to round off square corners I do this (or a 3d version.)

//corner rounder
module round(r){
    difference(){
       square(r*2,true);
          translate([r,r]) circle(r);
          translate([-r,r]) circle(r);
          translate([r,-r]) circle(r);
          translate([-r,-r]) circle(r);
    }
}

//example to round a couple of corners of a 30 by 20 rectangle
difference(){
     square([30,20]);
         translate([30,20]) round(6);
         translate ([0,20]) round(2);
}

On 28/07/2021 16:43, Terry wrote:

Decades ago I bought plastic rain guttering as one of many sources
for making electronics project cases.

Attached or here:
https://www.dropbox.com/s/itbg6n7mh58d2fe/Guttering.jpg?raw=1

I've got some guttering left but no end caps (which are no longer
available). To 3D print a simple push-on replacement my first
approach is to linearly extrude the difference between two
rectangles to make the push-on 'lip'. (I'll then add a 2mm thick
cube for the back.) But I find it hard going using offset,
difference and translate on squares to see exactly what's
happening to the dimensions. I'm about to try 'center = true' on
the squares to see if that helps.

Attached or here:

https://www.dropbox.com/s/lmtrwvtct0aclia/OffsetChangesThickness.jpg?raw=1

Specifically, after adding offset (r=3) to get the corners
rounded, thickness is also increased by 3mm and I'm not clear how
to avoid that? Is it possible for offset to add rounding without
changing the other dimensions?

Or should I go straight to 3D and use hull or minkowski? Or some
other method?

Terry


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

--
This email has been checked for viruses by AVG.
https://www.avg.com

You want a higher $fn on that corner, ie round(2,$fn=16) > -----Original Message----- > From: Terry [mailto:terrypingm@gmail.com] > Sent: Thu, 29 Jul 2021 18:30 > To: OpenSCAD general discussion > Subject: [OpenSCAD] Re: How best to apply offset on 2D square? > > Thanks Ray, that should prove handy. Heading out so yet to study > it properly. But something odd about one of the corners that's > more obvious when viewed from the top. Attached or here: > https://www.dropbox.com/s/q18jwxjvs2r6y15/Rounding-Ray-1.jpg?raw=1 > > Presumably dependent on $fn? > > -------------------- > > I'm surprised there's no OpenSCAD command that emulates scissors, > or Tipp-Ex, or pasting a bit of white paper over your mistakes. It > would just make a quadrant of specified radius and let you move > (translate) it to a precise position. That's what I intuitively > wanted to do with my square corners ;-) > > Terry > > ==================== > > > On Thu, 29 Jul 2021 00:52:48 +0100, you wrote: > > >If I want to round off square corners I do this (or a 3d version.) > > > >//corner rounder > >module round(r){ > >     difference(){ > >        square(r*2,true); > >           translate([r,r]) circle(r); > >           translate([-r,r]) circle(r); > >           translate([r,-r]) circle(r); > >           translate([-r,-r]) circle(r); > >     } > >} > > > >//example to round a couple of corners of a 30 by 20 rectangle > >difference(){ > >      square([30,20]); > >          translate([30,20]) round(6); > >          translate ([0,20]) round(2); > >} > > > >On 28/07/2021 16:43, Terry wrote: > >> Decades ago I bought plastic rain guttering as one of many sources > >> for making electronics project cases. > >> > >> Attached or here: > >> https://www.dropbox.com/s/itbg6n7mh58d2fe/Guttering.jpg?raw=1 > >> > >> I've got some guttering left but no end caps (which are no longer > >> available). To 3D print a simple push-on replacement my first > >> approach is to linearly extrude the difference between two > >> rectangles to make the push-on 'lip'. (I'll then add a 2mm thick > >> cube for the back.) But I find it hard going using offset, > >> difference and translate on squares to see exactly what's > >> happening to the dimensions. I'm about to try 'center = true' on > >> the squares to see if that helps. > >> > >> Attached or here: > >> > >> https://www.dropbox.com/s/lmtrwvtct0aclia/OffsetChangesThickness.jpg?raw=1 > >> > >> > >> Specifically, after adding offset (r=3) to get the corners > >> rounded, thickness is also increased by 3mm and I'm not clear how > >> to avoid that? Is it possible for offset to add rounding without > >> changing the other dimensions? > >> > >> Or should I go straight to 3D and use hull or minkowski? Or some > >> other method? > >> > >> Terry > >> > >> _______________________________________________ > >> OpenSCAD mailing list > >> To unsubscribe send an email to discuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG. https://www.avg.com
RW
Ray West
Thu, Jul 29, 2021 8:59 AM

Yes, you need a $fn = or similar. Also, for the 3d version you'll maybe
get a bit of z fighting, so make the cube a bit bigger, or cylinder a
bit smaller. (I rarely am able to give the fish, maybe I may not even be
able to say where to buy the rod.) The same 'round module' can radius
inside corners, too.

On 29/07/2021 09:30, Terry wrote:

Thanks Ray, that should prove handy. Heading out so yet to study
it properly. But something odd about one of the corners that's
more obvious when viewed from the top. Attached or here:
https://www.dropbox.com/s/q18jwxjvs2r6y15/Rounding-Ray-1.jpg?raw=1

Presumably dependent on $fn?


I'm surprised there's no OpenSCAD command that emulates scissors,
or Tipp-Ex, or pasting a bit of white paper over your mistakes. It
would just make a quadrant of specified radius and let you move
(translate) it to a precise position. That's what I intuitively
wanted to do with my square corners ;-)

Terry

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

On Thu, 29 Jul 2021 00:52:48 +0100, you wrote:

If I want to round off square corners I do this (or a 3d version.)

//corner rounder
module round(r){
    difference(){
       square(r*2,true);
          translate([r,r]) circle(r);
          translate([-r,r]) circle(r);
          translate([r,-r]) circle(r);
          translate([-r,-r]) circle(r);
    }
}

//example to round a couple of corners of a 30 by 20 rectangle
difference(){
     square([30,20]);
         translate([30,20]) round(6);
         translate ([0,20]) round(2);
}

On 28/07/2021 16:43, Terry wrote:

Decades ago I bought plastic rain guttering as one of many sources
for making electronics project cases.

Attached or here:
https://www.dropbox.com/s/itbg6n7mh58d2fe/Guttering.jpg?raw=1

I've got some guttering left but no end caps (which are no longer
available). To 3D print a simple push-on replacement my first
approach is to linearly extrude the difference between two
rectangles to make the push-on 'lip'. (I'll then add a 2mm thick
cube for the back.) But I find it hard going using offset,
difference and translate on squares to see exactly what's
happening to the dimensions. I'm about to try 'center = true' on
the squares to see if that helps.

Attached or here:

https://www.dropbox.com/s/lmtrwvtct0aclia/OffsetChangesThickness.jpg?raw=1

Specifically, after adding offset (r=3) to get the corners
rounded, thickness is also increased by 3mm and I'm not clear how
to avoid that? Is it possible for offset to add rounding without
changing the other dimensions?

Or should I go straight to 3D and use hull or minkowski? Or some
other method?

Terry


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

Yes, you need a $fn = or similar. Also, for the 3d version you'll maybe get a bit of z fighting, so make the cube a bit bigger, or cylinder a bit smaller. (I rarely am able to give the fish, maybe I may not even be able to say where to buy the rod.) The same 'round module' can radius inside corners, too. On 29/07/2021 09:30, Terry wrote: > Thanks Ray, that should prove handy. Heading out so yet to study > it properly. But something odd about one of the corners that's > more obvious when viewed from the top. Attached or here: > https://www.dropbox.com/s/q18jwxjvs2r6y15/Rounding-Ray-1.jpg?raw=1 > > Presumably dependent on $fn? > > -------------------- > > I'm surprised there's no OpenSCAD command that emulates scissors, > or Tipp-Ex, or pasting a bit of white paper over your mistakes. It > would just make a quadrant of specified radius and let you move > (translate) it to a precise position. That's what I intuitively > wanted to do with my square corners ;-) > > Terry > > ==================== > > > On Thu, 29 Jul 2021 00:52:48 +0100, you wrote: > >> If I want to round off square corners I do this (or a 3d version.) >> >> //corner rounder >> module round(r){ >>     difference(){ >>        square(r*2,true); >>           translate([r,r]) circle(r); >>           translate([-r,r]) circle(r); >>           translate([r,-r]) circle(r); >>           translate([-r,-r]) circle(r); >>     } >> } >> >> //example to round a couple of corners of a 30 by 20 rectangle >> difference(){ >>      square([30,20]); >>          translate([30,20]) round(6); >>          translate ([0,20]) round(2); >> } >> >> On 28/07/2021 16:43, Terry wrote: >>> Decades ago I bought plastic rain guttering as one of many sources >>> for making electronics project cases. >>> >>> Attached or here: >>> https://www.dropbox.com/s/itbg6n7mh58d2fe/Guttering.jpg?raw=1 >>> >>> I've got some guttering left but no end caps (which are no longer >>> available). To 3D print a simple push-on replacement my first >>> approach is to linearly extrude the difference between two >>> rectangles to make the push-on 'lip'. (I'll then add a 2mm thick >>> cube for the back.) But I find it hard going using offset, >>> difference and translate on squares to see exactly what's >>> happening to the dimensions. I'm about to try 'center = true' on >>> the squares to see if that helps. >>> >>> Attached or here: >>> >>> https://www.dropbox.com/s/lmtrwvtct0aclia/OffsetChangesThickness.jpg?raw=1 >>> >>> >>> Specifically, after adding offset (r=3) to get the corners >>> rounded, thickness is also increased by 3mm and I'm not clear how >>> to avoid that? Is it possible for offset to add rounding without >>> changing the other dimensions? >>> >>> Or should I go straight to 3D and use hull or minkowski? Or some >>> other method? >>> >>> Terry >>> >>> _______________________________________________ >>> 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
NH
nop head
Thu, Jul 29, 2021 9:57 AM

The simplest way is to offset a square inwards by the radius and and then
outwards by the radius, making sure $fn is a multiple of four. See
https://github.com/nophead/NopSCADlib/blob/master/utils/core/rounded_rectangle.scad#L23

If you want each corner a different radius then hull four circles offset
inwards by their radius. See
https://github.com/nophead/NopSCADlib/blob/master/vitamins/sheet.scad#L47.
There I hull four corners that can be square, rounded or chamfered.

On Thu, 29 Jul 2021 at 09:59, Ray West raywest@raywest.com wrote:

Yes, you need a $fn = or similar. Also, for the 3d version you'll maybe
get a bit of z fighting, so make the cube a bit bigger, or cylinder a bit
smaller. (I rarely am able to give the fish, maybe I may not even be able
to say where to buy the rod.) The same 'round module' can radius inside
corners, too.
On 29/07/2021 09:30, Terry wrote:

Thanks Ray, that should prove handy. Heading out so yet to study
it properly. But something odd about one of the corners that's
more obvious when viewed from the top. Attached or here:https://www.dropbox.com/s/q18jwxjvs2r6y15/Rounding-Ray-1.jpg?raw=1

Presumably dependent on $fn?


I'm surprised there's no OpenSCAD command that emulates scissors,
or Tipp-Ex, or pasting a bit of white paper over your mistakes. It
would just make a quadrant of specified radius and let you move
(translate) it to a precise position. That's what I intuitively
wanted to do with my square corners ;-)

Terry

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

On Thu, 29 Jul 2021 00:52:48 +0100, you wrote:

If I want to round off square corners I do this (or a 3d version.)

//corner rounder
module round(r){
difference(){
square(r*2,true);
translate([r,r]) circle(r);
translate([-r,r]) circle(r);
translate([r,-r]) circle(r);
translate([-r,-r]) circle(r);
}
}

//example to round a couple of corners of a 30 by 20 rectangle
difference(){
square([30,20]);
translate([30,20]) round(6);
translate ([0,20]) round(2);
}

On 28/07/2021 16:43, Terry wrote:

Decades ago I bought plastic rain guttering as one of many sources
for making electronics project cases.

Attached or here:https://www.dropbox.com/s/itbg6n7mh58d2fe/Guttering.jpg?raw=1

I've got some guttering left but no end caps (which are no longer
available). To 3D print a simple push-on replacement my first
approach is to linearly extrude the difference between two
rectangles to make the push-on 'lip'. (I'll then add a 2mm thick
cube for the back.) But I find it hard going using offset,
difference and translate on squares to see exactly what's
happening to the dimensions. I'm about to try 'center = true' on
the squares to see if that helps.

Attached or here:
https://www.dropbox.com/s/lmtrwvtct0aclia/OffsetChangesThickness.jpg?raw=1

Specifically, after adding offset (r=3) to get the corners
rounded, thickness is also increased by 3mm and I'm not clear how
to avoid that? Is it possible for offset to add rounding without
changing the other dimensions?

Or should I go straight to 3D and use hull or minkowski? Or some
other method?

Terry


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


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

The simplest way is to offset a square inwards by the radius and and then outwards by the radius, making sure $fn is a multiple of four. See https://github.com/nophead/NopSCADlib/blob/master/utils/core/rounded_rectangle.scad#L23 If you want each corner a different radius then hull four circles offset inwards by their radius. See https://github.com/nophead/NopSCADlib/blob/master/vitamins/sheet.scad#L47. There I hull four corners that can be square, rounded or chamfered. On Thu, 29 Jul 2021 at 09:59, Ray West <raywest@raywest.com> wrote: > Yes, you need a $fn = or similar. Also, for the 3d version you'll maybe > get a bit of z fighting, so make the cube a bit bigger, or cylinder a bit > smaller. (I rarely am able to give the fish, maybe I may not even be able > to say where to buy the rod.) The same 'round module' can radius inside > corners, too. > On 29/07/2021 09:30, Terry wrote: > > Thanks Ray, that should prove handy. Heading out so yet to study > it properly. But something odd about one of the corners that's > more obvious when viewed from the top. Attached or here:https://www.dropbox.com/s/q18jwxjvs2r6y15/Rounding-Ray-1.jpg?raw=1 > > Presumably dependent on $fn? > > -------------------- > > I'm surprised there's no OpenSCAD command that emulates scissors, > or Tipp-Ex, or pasting a bit of white paper over your mistakes. It > would just make a quadrant of specified radius and let you move > (translate) it to a precise position. That's what I intuitively > wanted to do with my square corners ;-) > > Terry > > ==================== > > > On Thu, 29 Jul 2021 00:52:48 +0100, you wrote: > > > If I want to round off square corners I do this (or a 3d version.) > > //corner rounder > module round(r){ > difference(){ > square(r*2,true); > translate([r,r]) circle(r); > translate([-r,r]) circle(r); > translate([r,-r]) circle(r); > translate([-r,-r]) circle(r); > } > } > > //example to round a couple of corners of a 30 by 20 rectangle > difference(){ > square([30,20]); > translate([30,20]) round(6); > translate ([0,20]) round(2); > } > > On 28/07/2021 16:43, Terry wrote: > > Decades ago I bought plastic rain guttering as one of many sources > for making electronics project cases. > > Attached or here:https://www.dropbox.com/s/itbg6n7mh58d2fe/Guttering.jpg?raw=1 > > I've got some guttering left but no end caps (which are no longer > available). To 3D print a simple push-on replacement my first > approach is to linearly extrude the difference between two > rectangles to make the push-on 'lip'. (I'll then add a 2mm thick > cube for the back.) But I find it hard going using offset, > difference and translate on squares to see exactly what's > happening to the dimensions. I'm about to try 'center = true' on > the squares to see if that helps. > > Attached or here: > https://www.dropbox.com/s/lmtrwvtct0aclia/OffsetChangesThickness.jpg?raw=1 > > > Specifically, after adding offset (r=3) to get the corners > rounded, thickness is also increased by 3mm and I'm not clear how > to avoid that? Is it possible for offset to add rounding without > changing the other dimensions? > > Or should I go straight to 3D and use hull or minkowski? Or some > other method? > > Terry > > _______________________________________________ > 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 > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >