Skip to main content

Modifiers

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

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

Live Demo

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

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

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

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

Live Demo

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:

module pin2() {  translate([0,pivotRadius,hingeHalfExtrudeLength+tiny]){//

Live Demo

Fixed!