Since we've started thinking about how the hinge will be assembled with the pin taper, we also need to think about tolerances and clearance gaps. Because we want this hinge to be "print in place" which mean it prints pre-assembled, we need to add clearance gaps so that our part doesn't print solid!
Let start by adding a
clearance variable and first thing we need to do is extrude our
hingeBodyHalf slightly less than
hingeLength/2 since there needs to be some play between the two halves.
Oh no! there's now a gap between our
Here's the fix for that:
We've done something new here, we've defined a variable with other variables and some arithmetic with
This variable is then used both in
The benefit of doing so is if we need to update this length again we only need to update it in one place since both of the modules need the same calculated length.
Also notice that've we increased the length of the
cylinder too so that it reaches the full
We still have more work to do on the pin though.
We want to re-use the pin to "subtract" its shape from the other half of the hinge, basically we can use our current pint to make a hole.
Lets make a temporary new module called
pin2. In this new module and we're going to introduce a new function
rotate to re-orientate the pin
This is not where we want to leave our pin, but it's a good way to introduce
rotate as well as using multiple modifiers, i.e. we're using both
rotate together here.
rotate is similar to
translate in that it takes an argument
[x, y, z] but instead of moving, it rotates about each of those axes. In the above example of
[0, 45, 0] it's as if were were to put a pin into the object along the
y axis and then rotate 45 degrees around that pin.
Notice the order that we applied the
transform we applied the
rotate first and then the
This might seem counter intuitive because
translate is on top, but nesting operations should be read from the most nest outward in openscad.
Here's the correct way to read the above code:
The same thing applies to
hingeBodyHalf that should read as follows:
Back to our pin and
rotate. The reason we
rotate first is because openscad shapes always rotates around the origin point
[0,0,0] and translating first can make things very confusing, in general you should ALWAYS
rotate first unless you have a good reason not to.