discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: How to round the top inner and outer edges?

AM
Adrian Mariano
Sun, Sep 3, 2023 11:57 PM

Apologies.

The second version I posted doesn't work right now due to a bug in BOSL2.
Change the line

down(1)offset_sweep(inside, h=H+1, top=os_circle(r=-2),extra=1);

to

down(1)offset_sweep(inside, h=H+1, top=os_circle(r=-2,extra=1));

The first version should work, so when I found the bug I fixed it...but the
fix isn't out yet and I forgot to switch things around to dodge the bug
when I posted the code.  (The bug is that you can't apply the extra
argument to an end with no end treatment.)

On Sun, Sep 3, 2023 at 6:12 PM Ken bats059@gmail.com wrote:

Adrian, your first solution works beautifully, but with your second
solution, I get an error

WARNING: undefined operation (undefined + vector) in file
../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 595
followed by a heap of trace calls-

TRACE: called by 'concat' in file
../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 595

TRACE: called by '_rounding_offsets' in file
../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 1583

TRACE: called by 'offset_sweep' in file
../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 1644

TRACE: assignment to 'vnf' in file
../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 1644

TRACE: called by 'offset_sweep' in file code.scad, line 22

TRACE: called by 'children' in file
../../Users/user/Documents/OpenSCAD/libraries/BOSL2/transforms.scad, line
395

TRACE: called by 'translate' in file
../../Users/user/Documents/OpenSCAD/libraries/BOSL2/transforms.scad, line
395

TRACE: call of 'down(z = 1, p = undef)' in file
../../Users/user/Documents/OpenSCAD/libraries/BOSL2/transforms.scad, line
392

TRACE: called by 'down' in file code.scad, line 22

TRACE: called by 'difference' in file code.scad, line 20

Execution aborted

and I'm afraid my openscad skills are not up to finding what the error is-
what am I doing wrong?

On 2023-09-03 22:59, Adrian Mariano wrote:

I think that Sanjeev has identified the two main approaches.  You can make
a rounded rectangle shape and sweep.  That would look like this:

include<BOSL2/std.scad>

$fa=1;$fs=1;
W=34;L=60;H=10;Or = 8;Ir = 3;

section = rect([Or-Ir,H], rounding=[2,2,0,0],anchor=BOT+LEFT);
path = rect([W,L],rounding=Ir);
path_sweep(section,path,closed=true);

Note that I have chosen as the sweep path the inner rounded rectangle
which avoids issues with self-intersection of the sweep.  This is probably
the best way to do this in terms of efficiency.  Note also that using
turtle() to compute a rounded rectangle is overkill.  I only use turtle()
for shapes that are somehow irregular.

Sanjeev's second approach is to use offsetting.  This is possible using
offset_sweep(), but will likely be slower than path_sweep() because
computing offset in userspace is slow.  To do this, you have to compute the
outside rounded shape and then subtract the inner rounded shape.  So it
could be done like this:

include<BOSL2/std.scad>
include<BOSL2/rounding.scad>

$fa=1;$fs=1;
W=34;L=60;H=10;Or = 8;Ir = 3;

inside = rect([W,L]-(Or-Ir)*[2,2], rounding=Ir);
outside = rect([W,L], rounding=Or);

difference(){
offset_sweep(outside, h=H, top=os_circle(r=2));
down(1)offset_sweep(inside, h=H+1, top=os_circle(r=-2),extra=1);
}

Note that you could also compute just one of inside and outside directly
and get the other one with offset().

A third way to make a shape like this is to use rounded_prism(), again
with a difference.  However, rounded_prism doesn't make circular roundings,
so the results will be a bit different, and it will not be possible to
assure a uniform width at the corners.  (Roundovers here are continuous
curvature beziers.  The k parameter controls how gentle the transition,
with a value of .8 close to circular.  Smaller k values will give gentler
transitions, but then large joint distance may be desired.  Try changing k
to 0.5 to see the difference.)

include<BOSL2/std.scad>
include<BOSL2/rounding.scad>

$fa=1;$fs=1;
W=34;L=60;H=10;Or = 8;Ir = 3;

diff(){
rounded_prism(rect([W,L]),height=H, joint_top=2, joint_sides=8,k=.8)
up(.01)align(TOP,inside=true)rounded_prism(rect([W,L]-[5,5]),height=H+1,
joint_top=-2, joint_sides=6,k=.8);
}

On Sun, Sep 3, 2023 at 7:18 AM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

I will explain the process
I think this is important.

There are 2 approaches.

  1. Extrude a section along a path
  2. Make a section and offset it multiple times to generate a solid.

I am sure this explanation is not enough. Will create a visual
description and send it to you.

For approach 2:
The key is writing a function to offset a section, which I think is not
so easy.

On Sun, 3 Sept, 2023, 4:32 pm Bob Roos, roosbob@wybatap.com wrote:

Hi Sanjeev,

Thank you. It's beautiful, but how did you generate all those points??

I had to hollow out the part a bit and change the shape some so I would
like to find a more generic way to round the edges.

Bob

Sunday, September 3, 2023, 6:17:54 AM, you wrote:

attached file
[image: Screenshot 2023-09-03 at 3.45.43 PM.png]

On Sun, 3 Sept 2023 at 06:50, Bob Roos roosbob@wybatap.com wrote:

Hello OpenSCAD,

I want the bottom to be straight and the top inside and outside edges
to have 2mm roundover

Thank you.

include <BOSL2/std.scad> //or screws or threading

W=34;
L=60;
H=10;
Or = 8;
Ir = 3;

rect_tube(size=[W,L], wall=5, rounding=Or, h=H,irounding=3);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com


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

--
have Fun,
Bob                          mailto:roosbob@wybatap.com
roosbob@wybatap.com


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

--
Cheers, Kenbats059@gmail.comhttps://vk7krj.comhttps://vk7krj.com/running.html

A baby can be defined as an ego with a noise at one end and a smell at the other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!

Apologies. The second version I posted doesn't work right now due to a bug in BOSL2. Change the line down(1)offset_sweep(inside, h=H+1, top=os_circle(r=-2),extra=1); to down(1)offset_sweep(inside, h=H+1, top=os_circle(r=-2,extra=1)); The first version should work, so when I found the bug I fixed it...but the fix isn't out yet and I forgot to switch things around to dodge the bug when I posted the code. (The bug is that you can't apply the extra argument to an end with no end treatment.) On Sun, Sep 3, 2023 at 6:12 PM Ken <bats059@gmail.com> wrote: > Adrian, your first solution works beautifully, but with your second > solution, I get an error > > WARNING: undefined operation (undefined + vector) in file > ../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 595 > followed by a heap of trace calls- > > TRACE: called by 'concat' in file > ../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 595 > > TRACE: called by '_rounding_offsets' in file > ../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 1583 > > TRACE: called by 'offset_sweep' in file > ../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 1644 > > TRACE: assignment to 'vnf' in file > ../../Users/user/Documents/OpenSCAD/libraries/BOSL2/rounding.scad, line 1644 > > TRACE: called by 'offset_sweep' in file code.scad, line 22 > > TRACE: called by 'children' in file > ../../Users/user/Documents/OpenSCAD/libraries/BOSL2/transforms.scad, line > 395 > > TRACE: called by 'translate' in file > ../../Users/user/Documents/OpenSCAD/libraries/BOSL2/transforms.scad, line > 395 > > TRACE: call of 'down(z = 1, p = undef)' in file > ../../Users/user/Documents/OpenSCAD/libraries/BOSL2/transforms.scad, line > 392 > > TRACE: called by 'down' in file code.scad, line 22 > > TRACE: called by 'difference' in file code.scad, line 20 > > Execution aborted > > > and I'm afraid my openscad skills are not up to finding what the error is- > what am I doing wrong? > > On 2023-09-03 22:59, Adrian Mariano wrote: > > I think that Sanjeev has identified the two main approaches. You can make > a rounded rectangle shape and sweep. That would look like this: > > include<BOSL2/std.scad> > > $fa=1;$fs=1; > W=34;L=60;H=10;Or = 8;Ir = 3; > > section = rect([Or-Ir,H], rounding=[2,2,0,0],anchor=BOT+LEFT); > path = rect([W,L],rounding=Ir); > path_sweep(section,path,closed=true); > > Note that I have chosen as the sweep path the inner rounded rectangle > which avoids issues with self-intersection of the sweep. This is probably > the best way to do this in terms of efficiency. Note also that using > turtle() to compute a rounded rectangle is overkill. I only use turtle() > for shapes that are somehow irregular. > > Sanjeev's second approach is to use offsetting. This is possible using > offset_sweep(), but will likely be slower than path_sweep() because > computing offset in userspace is slow. To do this, you have to compute the > outside rounded shape and then subtract the inner rounded shape. So it > could be done like this: > > include<BOSL2/std.scad> > include<BOSL2/rounding.scad> > > $fa=1;$fs=1; > W=34;L=60;H=10;Or = 8;Ir = 3; > > inside = rect([W,L]-(Or-Ir)*[2,2], rounding=Ir); > outside = rect([W,L], rounding=Or); > > difference(){ > offset_sweep(outside, h=H, top=os_circle(r=2)); > down(1)offset_sweep(inside, h=H+1, top=os_circle(r=-2),extra=1); > } > > Note that you could also compute just one of inside and outside directly > and get the other one with offset(). > > A third way to make a shape like this is to use rounded_prism(), again > with a difference. However, rounded_prism doesn't make circular roundings, > so the results will be a bit different, and it will not be possible to > assure a uniform width at the corners. (Roundovers here are continuous > curvature beziers. The k parameter controls how gentle the transition, > with a value of .8 close to circular. Smaller k values will give gentler > transitions, but then large joint distance may be desired. Try changing k > to 0.5 to see the difference.) > > include<BOSL2/std.scad> > include<BOSL2/rounding.scad> > > $fa=1;$fs=1; > W=34;L=60;H=10;Or = 8;Ir = 3; > > diff(){ > rounded_prism(rect([W,L]),height=H, joint_top=2, joint_sides=8,k=.8) > up(.01)align(TOP,inside=true)rounded_prism(rect([W,L]-[5,5]),height=H+1, > joint_top=-2, joint_sides=6,k=.8); > } > > > On Sun, Sep 3, 2023 at 7:18 AM Sanjeev Prabhakar <sprabhakar2006@gmail.com> > wrote: > >> I will explain the process >> I think this is important. >> >> There are 2 approaches. >> 1. Extrude a section along a path >> 2. Make a section and offset it multiple times to generate a solid. >> >> I am sure this explanation is not enough. Will create a visual >> description and send it to you. >> >> For approach 2: >> The key is writing a function to offset a section, which I think is not >> so easy. >> >> >> >> >> On Sun, 3 Sept, 2023, 4:32 pm Bob Roos, <roosbob@wybatap.com> wrote: >> >>> Hi Sanjeev, >>> >>> >>> Thank you. It's beautiful, but how did you generate all those points?? >>> >>> >>> I had to hollow out the part a bit and change the shape some so I would >>> like to find a more generic way to round the edges. >>> >>> >>> >>> Bob >>> >>> >>> >>> Sunday, September 3, 2023, 6:17:54 AM, you wrote: >>> >>> attached file >>> [image: Screenshot 2023-09-03 at 3.45.43 PM.png] >>> >>> >>> >>> On Sun, 3 Sept 2023 at 06:50, Bob Roos <roosbob@wybatap.com> wrote: >>> >>>> Hello OpenSCAD, >>>> >>>> I want the bottom to be straight and the top inside and outside edges >>>> to have 2mm roundover >>>> >>>> Thank you. >>>> >>>> include <BOSL2/std.scad> //or screws or threading >>>> >>>> W=34; >>>> L=60; >>>> H=10; >>>> Or = 8; >>>> Ir = 3; >>>> >>>> rect_tube(size=[W,L], wall=5, rounding=Or, h=H,irounding=3); >>>> >>>> -- >>>> Best regards, >>>> Bob mailto:roosbob@wybatap.com >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> >>> -- >>> have Fun, >>> Bob mailto:roosbob@wybatap.com >>> <roosbob@wybatap.com> >>> _______________________________________________ >>> 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 > > -- > Cheers, Kenbats059@gmail.comhttps://vk7krj.comhttps://vk7krj.com/running.html > ---------------------------------------- > A baby can be defined as an ego with a noise at one end and a smell at the other. > Your job as parents is to teach them to control all three. > My job as a grandad is to tell you how you are doing it all wrong! > >