Panel gaps were previously for both edges, as in the reduction in size
of the panel. The code often divides this value by 2 to think about a
single edge. It makes more sense to just store this value as on a single
edge and just double it in the cases we need it, which is fewer than the
cases were we previously cut it in half. This is fewer opterations and
easier to reason about.
Turns out we still need more in the horizontal due to cutout margins at
the bottom of the slot. This isn't needed in the vertical. Separating
these lets us give more horizontal gap again without sacrificing tight
vertical tolerancees.
Shrink the button size so it fits inside the outer divet with a margin
of PartMargin, rather than giving both the same radius.
Cut off the button sphere at a more accurate position in case the tab
thickness is smaller than half the button radius.
The panel gap didn't need to be as large around the outer edge, so call
that PanelEdgeGap and default it to PartMargin*2. Leave the thickness
margin at CutoutMargin*2 + PartMargin*2 and rename it to PanelThickGap.
Major cleanup of commenting for style and completeness.
Also removed TopMargin and replaced it with TopPCBMargin, as nothing was
using TopMargin other than Height.
If Screwless is true, use feet with a peg in them that goes through the
PCB holes. Feet then come down from the top shell to press against the
PCB and hold it in place. These have a hole in the center so the peg
from the bottom shell will insert into it and keep the shells in a
stable position in the X-Y plane. If you combine this with screwless
snap tabs, you can have a fully screwless box.
Change CutoutMargin from a diameter to a radius/single edge (cut it in half)
Change OuterMargin to a more generic part margin for mating parts
Derive PanelGap from CutoutMargin and OuterMargin
Make the back margin 0 so the PCB is up against the back panel. Make use
of the variables describing the panel with respect to the PCB to show
how they can be used.
Break out the panel holes and text into separate modules.
Put those modules at the top of the file so they are easier to find.
This unfortunately puts them before the modules they instantiate, but I
think this is a fair trade-off for readability and findability of things
that should be customized.
Set SnapTabs to 1 and get tabs with buttons and semispherical holes in
the box. This is experimental because I haven't built a box like this
and don't know how well it will work. The thickness of the tab is
probably important since you need it to flex just the right amount to
allow the button to fit. Also, the ScrewHole value is used for the size
of the button, so it should not exceed 2*Thick.
Add BLLeg, FLLeg, BRLeg, and FRLeg parameters where 0 means put that leg
on the bottom shell, and 1 means put it on the top. Call the legs and
hols modules with a "top" argument where 0 means build the bottom shell
legs/holes, and 1 means build the top. Gate each leg or hole creation
based on logic between XXLeg and top.
This also required making the top shell using mirror() rather than
rotate, since that kept the same leg/hole in the same position when
flipped to the top.
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.