Make the Coque module generic, adding specific changes to a separate
TopShell and BottomShell module. The color() function is moved to Coque
to prevent coloring the PCB model. I left the legs and holes in the
separate modules to prepare for more customization of them for top and
bottom.
If the filet is more than double the thickness, scale the interior
filets so that the walls have a constant thickness around the corners
and the interior and exterior filets have a common center axis. If the
filets are smaller, then keep the old behavior, making the corners
mostly square.
Panel and Holes are all in 2D. Leave the LinearExtrude to the PanL
modules just before adding text. Perform all translating in the PanL
modules, rather than the top level code.
Generate a cross-section of the foot in 2D, then rotate/extrude the
whole thing at once. This is a little easier to reason about than
working in 3D. You can use debug view to see just the cross section with
more ease. It save a line of code, too.
split a single decoration into its own module, and give it a most
generic translation. This makes the Decorations module cleaner and
easier to understand, because you can easily see exactly how much you
are translating each decoration.
Rather than translating the decoration to make it fit the other side of
the box, rotate it. It makes the translation cleaner, and it's a little
easier to understand. The decorations are the same on each side, just
rotated 180 degrees from one another.
I might still make all the left side decorations and rotate that 180
degrees for the right side.
RoundBox now takes an xshrink and yzshrink argument, which tell it how
much to shrink the box from the Length, Width, and Height parameters.
They defaul to 0. The removes the need to translate the calls to
RoundBox or to repeatedly provide adjustments to its arguments that are
very similar. As a result, the MainBox module is now much simpler and
easier to understand.
The Coque module is now very simple and self-commenting about what it
does. The complexity is in the referenced modules, which are much
shorter and easier to read. I'll split things up just a bit more, but
wanted to check this in first.
This is the last part to make the box fully scalable. Now if you double
every parameter, the box doubles in all dimensions. The panel features
are not changed, however. That's up to you to fix.
The tab cutouts are now scaled off of the screw hole size, since that
fixes the diameter of the tab.
I've also added an OuterMargin which adjusts the spacing you need
between the tab and the box wall. This is a property of your printer,
and shouldn't be changed when you scale other aspects of the box. I
might base other dimensions, like the panel gap on this value as well.
Make the tab size relative to the screw hole size.
Position the tabs based on Thick, PanelThick, and the tab size.
The are now scaled properly as you increase the related parameters.
There was some artifacting and errors resulting from the inner rails not
producing a valid 2-manifold object. Make the rails larger so they
interect the box, and make the subtraction the full height and width of
the box so the boundary isn't indeterminate.
The last change didn't work if Filet is 0. minkowski didn't work well
with a 2D null argument either. This is a better solution, plus it saves
a line.
The preview works fine, but there's still an issue with the full render.
Do the minkowski in 2D so that if Filet is 0, and half the minkowski is
null, you don't have to fix the height. Then translate, extrude, and
rotate it.
Update the comment at the top, which described Filet as a diameter,
which was incorrect for most of the file.
Make it clear that the circle used in foot creation is a radius. It
already was, but provide r= in the argument so it's unambiguous.
SquareHole was treating its filet as a diameter, rather than a radius.
Switch it to treat Filet as a radius. This does make the example square
holes rounder.
Make all vent holes Thick + Filet thick so they extend to the end of the
rounded corner, particularly for large filets, but not too far in for
small filets.
Make all decorations Thick/2 so they scale with the thickness.
Separate the vents by a square Thick x Thick pillar.
Generate the position of the first vent/decoration based on the panel
thickness, wall thickness, margin, and vent spacing so that there is one
pillar's width beteween the interior edge and the first vent.
Bring the decoration/vent in from 1mm outside the box both horizontally
and vertically to prevent artifacts. This does result in vents reaching
under the box farther than previously, but I think the aesthetic is
pleasing, and it handles strange cases better, such as thick walls and
tiny filets.
I suspect this was an artifact before text was linear_extruded, as it
has a default thickness of 1, so shifting by 0.5 placed it on the
surface. Linear extrude was added, and then the calls to LText and CText
were shifted the other direction by 0.5 to get them on the surface. This
now just results in two unnecessary translates, so I've removed them.
I also removed the shift from the "PCB" text. It's thickness has no
bearing on the print, so there's no reason to shift it. If you wanted to
later linear_extrude it, this would get in your way.
Use it to set either a round or beveled corner. Use it for RoundBox,
Panel, and the feet edge.
Set all other circles (except the tabs) to fn=100 for smoothness.
Make the foot exterior cutout square as tall as FootHeight.
Previously making it taller than 100 made the top wider.
This is obviously ridiculous, but no harder to do right, and looks nicer
when debugging.
If PanelThick is equal to Thick, all is the same. If it is different,
then only the ends are scaled. Everything in the middle, including box
decorations and feet remain in the same position relative to the
interior of the panels.
The 45 degree box for the bottom angled cutout of the box tabs was
unnecessarily shifted.
The rectangular cutout for the sides of the tabs was unnecessarily wide,
and the margin depended on the thickness, which doesn't make much sense.
It depends more on the printer, so this margin should be parametrized in
a later CL.
While it has no impact on the outcome, the large outer box was taller
than it needed to be, and didn't accurately represent the box size when
debugged. This was probably an error of the Thick = Thick*2 change.