Enhancing openscad (II): Bevel library

(First part: Enhancing openscad with the attach library)

Introduction

There is one very common operation that has to be done in nearly all the designs: beveling edges. It can be done on the convex side, for avoiding sharp edges, or on the concave side, for reinforce the part (avoiding the 90 degrees connection between parts).

With the bevel library I am developing doing these two operations is a piece of cake. Let’s see some examples

Beveling the exterior edges

Let’s take a cube as an example. We want to bevel the top-right edge. We will use the concept of connector (the same that is used for the attach operator). First we draw the cube and define two connectors in the same position (the same attachment point). The first one is on the edge we want to bevel. The other is normal and should point to the exterior bisector.

Using the connector() module they can be easily viewed for debugging. It is also useful to make the cube transparent for seeing the connectors better:


size=[40,40,15];

//-- Define the Connectors
//-- position, orientation, 0
ec1 = [ [size[0]/2, 0, size[2]/2], [0,1,0], 0];
en1 = [ ec1[0], [1,0,1], 0];

//-- Debug! Show the connectors
connector(ec1);
connector(en1);

//-- Draw the cube (transparent for debugging)
color("Yellow",0.4)
cube(size,center=true);

Now is when the magic comes:

Invoke the bevel() module, passing the connectors as parameters, as well as the corner radius, the bevel resolution and the length (l). Automatically a beveled concave corner part is placed on the connectors, with the right orientation. In this example the color has been change to transparent blue to see the new part better.


color("Blue",0.4)
bevel(ec1, en1, cr = 8, cres=10, l=size[1]+2);

The edge has not been beveled yet… we still have to apply the difference() operator:


difference() {
cube(size,center=true);
bevel(ec1, en1, cr = 8, cres=10, l=size[1]+2);
}

and there it is!

Change the corner resolution, or the radius for modifying the beveling. Also you can easily add more bevel() operations into the difference() so that you bevel more egdes. Here is another part with different kind of beveled edges:

Reinforcing parts: buttress

Adding buttress to the union of orthogonal parts is done in a similar way than the edge beveling. First the 2 connectors should be defined, with a vector on the edge direction and another normal to it, pointing to the interior bisector.


//-- part parameters
size=[30,30,30];
th = 3;

//-- Define the connectors
ec1 = [ [0,-size[1]/2+th,-size[2]/2+th], [1,0,0], 0];
en1 = [ ec1[0], [0,1,1], 0];

//-- Show the connectors (Debug)
connector(ec1);
connector(en1);

//-- Part we want to reinforce
color("Yelow",0.5)
difference() {
cube(size,center=true);
translate([0,th,th])
cube([size[0]+2,size[1],size[2]],center=true);
}

Now one buttress is added:


bconcave_corner_attach(ec1,en1,l=th,cr=8,cres=0);

Easy, does not it? 🙂 Again, playing with the parameters, or adding more connectors, different reinforments are created:

Happy Beveling and reinforcing!!!

Obijuan