how to make round chamfer at 2D object?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

how to make round chamfer at 2D object?

eexpss
This post has NOT been accepted by the mailing list yet.


round_chamfer=1;
translate([s,-s/2,0]) slot();
translate([s,0,0]) offset(round_chamfer)slot();
translate([s,s/2,0]) color("green")offset(-round_chamfer)offset(round_chamfer)slot();

slot is an 2D object. I want offset twice to make the round chamfer, but seems fail.
how understand this? "When negative, the polygon is offset inwards." in wiki.
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

Parkinbot
Next time please give a full code example.
If you do a negative and a positive offset() with the same parameter the result will be identity.

I guess you want to have your slot object with rounded edges at the "original" size. Using offset() this is only possible, if you construct the square part smaller and the hole part larger by the chamfer value.


<quote>
$fn = 30;

s = 40;
round_chamfer=1;
translate([0,-s/2,0]) slot();
translate([0,0,0])
 offset(round_chamfer)
   slot(offs=round_chamfer);

module slot(a = 12, b = 16, r = 4, offs = 0)
{
  difference()
  {
    square([a-2*offs, b-2*offs] , center = true);
    hull()
    {
      circle(r+offs, center = true);
      translate([a, 0])
      circle(r+offs, center = true);
    }
  }
}
<quote>
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

nophead
>If you do a negative and a positive offset() with the same parameter the result will be identity.

No it will round the convex or concave corners (depending on the order) with a radius equal to the offset. I use it regularly.

On 24 December 2016 at 12:08, Parkinbot <[hidden email]> wrote:
Next time please give a full code example.
If you do a negative and a positive offset() with the same parameter the
result will be identity.

I guess you want to have your slot object with rounded edges at the
"original" size. Using offset() this is only possible, if you construct the
square part smaller and the hole part larger by the chamfer value.



$fn = 30;

s = 40;
round_chamfer=1;
translate([0,-s/2,0]) slot();
translate([0,0,0])
 offset(round_chamfer)
   slot(offs=round_chamfer);

module slot(a = 12, b = 16, r = 4, offs = 0)
{
  difference()
  {
    square([a-2*offs, b-2*offs] , center = true);
    hull()
    {
      circle(r+offs, center = true);
      translate([a, 0])
      circle(r+offs, center = true);
    }
  }
}





--
View this message in context: http://forum.openscad.org/how-to-make-round-chamfer-at-2D-object-tp19714p19715.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

jon_bondy

If either of you (nop head, Parkinbot) could provide a small example, I would appreciate it.


On 12/24/2016 7:15 AM, nop head wrote:
>If you do a negative and a positive offset() with the same parameter the result will be identity.

No it will round the convex or concave corners (depending on the order) with a radius equal to the offset. I use it regularly.

On 24 December 2016 at 12:08, Parkinbot <[hidden email]> wrote:
Next time please give a full code example.
If you do a negative and a positive offset() with the same parameter the
result will be identity.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

cacb
In reply to this post by Parkinbot
On 24. des. 2016 13:08, Parkinbot wrote:
> I guess you want to have your slot object with rounded edges at the
> "original" size. Using offset() this is only possible, if you construct the
> square part smaller and the hole part larger by the chamfer value.


Using your slot() you can do the following to get rounded corners of the
original object, with original size and given radius:

$fn = 30;
rad = 1;
offset(r=rad)
offset(delta=-rad)
slot();


Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

nophead
In reply to this post by jon_bondy
$fn = 32;

module shape()
    difference() {
        square(40, center = true);
        square(20, center = true);
    }
   
   
color("red") offset(3) offset(-3) shape();

translate([50, 0, 0])
    color("blue") offset(-3) offset(3) shape();





On 24 December 2016 at 12:18, jon <[hidden email]> wrote:

If either of you (nop head, Parkinbot) could provide a small example, I would appreciate it.


On 12/24/2016 7:15 AM, nop head wrote:
>If you do a negative and a positive offset() with the same parameter the result will be identity.

No it will round the convex or concave corners (depending on the order) with a radius equal to the offset. I use it regularly.

On 24 December 2016 at 12:08, Parkinbot <[hidden email]> wrote:
Next time please give a full code example.
If you do a negative and a positive offset() with the same parameter the
result will be identity.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

eexpss
This post has NOT been accepted by the mailing list yet.
good example. thanks. I catch it now.
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

eexpss
This post has NOT been accepted by the mailing list yet.
In reply to this post by Parkinbot
I hate manually calculate. so not agree this method.

I usually use "include" and "use", so it hard to paste entire code. Next time I will paste full code. thanks.
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

Parkinbot
In reply to this post by nophead
runsun, you are right. It is obviously not identity (only the initial example). So what do you do, if you want to have inner and outer edges rounded?
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

cacb
On 25. des. 2016 00:19, Parkinbot wrote:
> So what do you do, if you want to have inner and outer edges
> rounded?

You apply both techniques at once.


module rectangle_with_hole(a = 12, b = 16, th = 4)
{
   difference()
   {
     square([a,b],center=true);
     square([a-2*th,b-2*th],center=true);
   }
}


$fn = 30;
rad = 1.5;

// causes outer loop rounding
offset(r=rad)
offset(r=-rad)
// causes inner loop rounding
offset(r=-rad)
offset(r=rad)
rectangle_with_hole();


Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

Parkinbot
Cool
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

eexpss
This post has NOT been accepted by the mailing list yet.
In reply to this post by cacb
interesting. maybe next version offset could add one parameter "both-direction=true",  so only one offset(5, true) can do it. lol
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

Parkinbot
eexpss wrote
interesting. maybe next version offset could add one parameter "both-direction=true",  so only one offset(5, true) can do it. lol
Would be good candidate to be included into a (standard) library:

$fn = 30;
rad = 1.5;

Offset(r = rad, keepsize=true) rectangle_with_hole();

module rectangle_with_hole(a = 12, b = 16, th = 4)
{
   difference()
   {
     square([a,b],center=true);
     square([a-2*th,b-2*th],center=true);
   }
}

module Offset(r=0, delta=0, chamfer=false, keepsize = false)
{
  if(keepsize)
    offset(r) offset(-r) offset(-r) offset(r) children();
  else
    offset(r = r, chamfer = chamfer) children();
}
If we had a qualified naming scheme or at least a synonym to refer to built-in primitives for overriding, like $offset() it could be expressed more transparently in this way:

module offset(r=0, delta=0, chamfer=false, keepsize = false)
{
  if(keepsize)
    $offset(r) $offset(-r) $offset(-r) $offset(r) children();
  else
    $offset(r = r, chamfer = chamfer) children();
}
Reply | Threaded
Open this post in threaded view
|

Re: how to make round chamfer at 2D object?

MichaelAtOz
Administrator
Parkinbot wrote
If we had a qualified naming scheme or at least a synonym to refer to built-in primitives for overriding, like $offset() it could be expressed more transparently in this way:
+1,000,000
Admin - email* me if you need anything,
or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!