---
title: Adding Fillets
---

import Image from '@theme/IdealImage';

import offset1 from '../../static/img/openscad-tutorial/offset1.png';
import offset2 from '../../static/img/openscad-tutorial/offset2.png';
import offset3 from '../../static/img/openscad-tutorial/offset3.png';

Next we're going to learn about a hack that every OpenSCAD coder should know, and that is you can create fillets with `offset`.
Fillets are often ignored in OpenSCAD because they can be difficult to do, but you're not going to ignore them because you're a good engineer.
We need to give fillets their due because they play an important role in reducing stress concentrations, have you ever seen an airplane with sharp square windows?? [Exactly](https://www.youtube.com/watch?v=7rXGRPMD-GQ)!

## Offset

Offset works by "expanding" the skin of your 2d shape but importantly it rounds external corners in the process. See our swole hinge profile below:

```cpp
// ... variables above
// highlight-next-line
offset(1){
  translate([0,pivotRadius,0]){
    circle(pivotRadius);
  }
  square([pivotRadius,pivotRadius]);
  translate([pivotRadius,0,0]){
    square([baseWidth,baseThickness]);
  }
}
```
**[Live Demo](https://cadhub.xyz/dev-ide/openscad#encoded_script_v2=eJxTScuzNTay5irILMsvCUpMySwttjW15kpKLE4NychMzs5LLS62NYYIhGemlGTYGgKlufLT0opTSzQMNau5FBRKihLzinMSS1I1og10kAzSMYgFyysoJGcWJeekaiDJaVoDJWqBuLiwNLEIqBNZHxI7FqwQyQYU8xE2wIyBu1MHxQuxUPtqAYDXUD0=)**

<Image img={offset1} className="mb-8 bg-contain rounded-md overflow-hidden" />

## Double Offset

Here's the rub, we can do this again in reverse using a negative number to bring us back to our original dimensions but with an internal fillet.

```cpp
offset(-1)offset(1){
  // ... hinge profile
}
```
**[Live Demo](https://cadhub.xyz/dev-ide/openscad#encoded_script_v2=eJxTScuzNTay5irILMsvCUpMySwttjW15kpKLE4NychMzs5LLS62NYYIhGemlGTYGgKlufLT0opTSzR0DTWhLEPNai4FhZKixLzinMSSVI1oAx0kI3UMYsHyCgrJmUXJOakaSHKa1kCJWiAuLixNLALqRNaHxI4FK0SyAcV8hA0wY+Au1kHxTCzUvloAmONTcw==)**

<Image img={offset2} className="mb-8 bg-contain rounded-md overflow-hidden" />

## Triple Offset

It gets even better, we can double our negative value and apply a third offset to get external fillets as well, to better understand what's happening here let's overlay the shapes after each offset.

<Image img={offset3} className="mb-8 bg-contain rounded-md overflow-hidden" />

In essence we over expand, then under expand before finally expanding back to the original dimensions, but we have gained fillets in the process, it's like kneading bread, the more you do it the better the bread . . . not really stick to 3 max.

```cpp
offset(1)offset(-2)offset(1){
  // ... hinge profile
}
```
**[Live Demo](https://cadhub.xyz/dev-ide/openscad#encoded_script_v2=eJxTScuzNTay5irILMsvCUpMySwttjW15kpKLE4NychMzs5LLS62NYYIhGemlGTYGgKlufLT0opTSzQMNaEMXSNNuFA1l4JCSVFiXnFOYkmqRrSBDpLZOgaxYHkFheTMouScVA0kOU1roEQtEBcXliYWAXUi60Nix4IVItmAYj7CBpgxcKfroPgqFmpfLQCaj1Z9)**
