---
title: Modifiers
---

import Image from '@theme/IdealImage';

import transparentRotate from '../../static/img/openscad-tutorial/transparent-rotate.png';
import difference from '../../static/img/openscad-tutorial/difference.png';
import removeArtifact from '../../static/img/openscad-tutorial/remove-artifact.png';

The reason we're using `rotate` here is because we want to re-orientate our `pin2` to be inside to form a hole, tricky part is that it can be hard to visualise parts that are going to be subtracted from another shape so we're going to use a modifying character `%` for our `hingeBodyHalf`

```cpp
module pin2() {
  translate([0,pivotRadius,hingeHalfExtrudeLength]){
    rotate([0,175,0]){
      cylinder(h=hingeLength/2+clearance/2, r1=pinRadius, r2=pinRadius+pinTaper);
    }
  }
}
// highlight-next-line
%hingeBodyHalf();
pin2();
```
**[Live Demo](https://cadhub.xyz/dev-ide/openscad#encoded_script_v2=eJytU8FqhDAQvecrcmhBWbdqlqUH8VIo9NBDKQs9FCmpxjXUxm0SS5fiv3fU6EZXemkFSSYzb+a9yeQiF/GGROjAPyv9SDNeq3gboVeq2K7g6ZtgSsWb/uCJZ7qIQ3AXXOzZPRN7sDdBixYG26USO3pgMg6uCMSmJaOSipS1toHe0TK//dKyzoYsVkafrEeMDwj0XmV1yXAXcgM8HmSV85I5Lv5GGGsIVCXVzHm2RHiBFyRu68dYfdRUgnvU4E3kJW4EYQ1qZpWq7NjyNGVKLoDTC+tZO8syTMEqzxXTTuiazZq441EfMaEdeBPiyRiDccol9MKx/B3Z9mvMOqizc1j7ZASc96/3NKj/lxT+Lit0l3PavYRpOL+oqeLlXg5tSI9ALGPSmQ3JyhoSD8swHocQLHKyVsM8LlEjf+MmK20w4fXWvrn/JT3cEVC/nM1mhHy/73H38Ei7/gBVCEAa)**

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

The `%` character before `hingeBodyHalf()` makes it transparent so that we can see `pin2` within it, and one thing that becomes obvious with this view is that a `rotate` of `175` is no right, it needs to be `180`! The `%` character is a "debugging" step, which means it's not going to end up in our final code, it's just helpful in the mean time. There are other characters that can be useful, the full list is

```xml
*  disable
!  show only
#  highlight / debug
%  transparent / background
```

To actually make the hole we'll use a `difference` operation like so:

```cpp
module pin2() {
  translate([0,pivotRadius,hingeHalfExtrudeLength]){
    rotate([0,180,0]){
      cylinder(h=hingeLength/2+clearance/2, r1=pinRadius, r2=pinRadius+pinTaper);
    }
  }
}

// highlight-next-line
difference() {
  hingeBodyHalf();
  pin2();
}
```
**[Live Demo](https://cadhub.xyz/dev-ide/openscad#encoded_script_v2=eJytUk1LxDAQvedX5OChZbv2YxEWSi+C4MGDyIIHKRLb6W6wpmuSiov0vzvdpDXdLV60EJrJvDd5bzIXlchWSUr2/KPRD6zkrcquUvLCFGx2vHgVoFS2MgePvNS7LMb0jost3IHYYryKeraw3GMpsWF7kFl0mSC2qIFJJgroY0u9ZXV186llWw5VnIphshw5ITLIW1O2NdAj5Bp13Mum4jV4Pv0ilGoEqppp8J4cE0EURLnf5ylV7y2TmB49BBN7uZ8irCPdyU1Neeh12mtqLlDTMxjV3rwNe2FTVQq0F/t2s0z88cggJrKjYCI8HzGUFlxiLzwnfxTbf539D+7cGs4+Hwnn/TOZjpg15/B3W7E/X9PtJU7D+UNNHc/3cmhDcUBhJUjvZEgWzpAEVMbZOIQYJT/RYpjHOWnJ37TJRltOvI7cl/tf0cMbofSSVxVIwAJW+cms9nDjK0V4GJr+p+Qbr+pF+Q==)**

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

There we, go a hole! The way to conceptualise how `difference` works is to think of it as subtracting the second child from the first. "child" simply means nested within `difference` so in the above example `pin2` is the second child that we are subtracting from `hingeBodyHalf`.

There is one minor annoyance is that the end of the hole looks like it's glitching a little, this can happen in openscad when two surfaces line up.
In this case the end of the `hingeBodyHalf` and the start of `pin2`, it only effects the preview and not the 3d STL export, but to make the preview a little nicer in this situations I'll define a variable with a very small value `tiny=0.005;` and add it strategically to resolve this issue, this part is optional but here's where I added it for pin2:

```cpp
module pin2() {
  translate([0,pivotRadius,hingeHalfExtrudeLength+tiny]){
//
```
**[Live Demo](https://cadhub.xyz/dev-ide/openscad# )**

Fixed!

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