Split up the man box code into modules
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 commit is contained in:
parent
d6f26ae90d
commit
300029c3d2
@ -164,7 +164,7 @@ LeftEdgeOfBoardWRTBPanel = RightEdgeMargin - (PanelGap/2);
|
|||||||
b: The width of the box. Defaults to the "Width" parameter.
|
b: The width of the box. Defaults to the "Width" parameter.
|
||||||
c: The height of the box. Defaults to the "Height" parameter.
|
c: The height of the box. Defaults to the "Height" parameter.
|
||||||
*/
|
*/
|
||||||
module RoundBox($a=Length, $b=Width, $c=Height) { // Cube bords arrondis
|
module RoundBox($a=Length, $b=Width, $c=Height) {
|
||||||
rotate([90, 0, 90]) {
|
rotate([90, 0, 90]) {
|
||||||
linear_extrude(height=$a) {
|
linear_extrude(height=$a) {
|
||||||
translate([Filet, Filet, 0]) {
|
translate([Filet, Filet, 0]) {
|
||||||
@ -174,51 +174,78 @@ module RoundBox($a=Length, $b=Width, $c=Height) { // Cube bords arrondis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // End of RoundBox Module
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Coque: Shell module
|
/* MainBox: Main box module
|
||||||
|
|
||||||
This module takes no arguments, but produces a box shell. This is half the box,
|
This module produces the simple main box half. No feet, legs, vents or fixation
|
||||||
including slots for end panels, rounded corners according to Filet and Resolution,
|
is applied here.
|
||||||
wall fixation legs and holes, and vents/decorations according to parameters.
|
|
||||||
*/
|
*/
|
||||||
module Coque() { //Coque - Shell
|
module MainBox() {
|
||||||
difference() {
|
difference() {
|
||||||
difference() { //sides decoration
|
|
||||||
union() {
|
union() {
|
||||||
difference() { //soustraction de la forme centrale - Substraction Fileted box
|
difference() { // Makes a hollow box with walls of Thick thickness.
|
||||||
difference() { //soustraction cube median - Median cube slicer
|
|
||||||
union() { //union
|
|
||||||
difference() { //Coque
|
|
||||||
RoundBox();
|
RoundBox();
|
||||||
translate([Thick, Thick, Thick]) {
|
translate([Thick, Thick, Thick]) {
|
||||||
RoundBox($a=(Length - Thick*2),
|
RoundBox($a=(Length - Thick*2),
|
||||||
$b=(Width - Thick*2),
|
$b=(Width - Thick*2),
|
||||||
$c=(Height - Thick*2));
|
$c=(Height - Thick*2));
|
||||||
}
|
}
|
||||||
} //Fin diff Coque
|
}
|
||||||
difference() { //largeur Rails
|
difference() { // Makes interior backing for panel
|
||||||
translate([Thick + PanelThick + PanelGap, Thick/2, Thick/2]) { // Rails
|
translate([Thick + PanelThick + PanelGap, Thick/2, Thick/2]) { // Rails
|
||||||
RoundBox($a=(Length - ((Thick + PanelThick + PanelGap)*2)),
|
RoundBox($a=(Length - ((Thick + PanelThick + PanelGap)*2)),
|
||||||
$b=(Width - Thick),
|
$b=(Width - Thick),
|
||||||
$c=(Height - Thick));
|
$c=(Height - Thick));
|
||||||
} //fin Rails
|
}
|
||||||
translate([Thick*2 + PanelThick + PanelGap, 0, 0]) {
|
translate([Thick*2 + PanelThick + PanelGap, 0, 0]) {
|
||||||
RoundBox($a=(Length - ((Thick*2 + PanelThick + PanelGap) * 2)));
|
RoundBox($a=(Length - ((Thick*2 + PanelThick + PanelGap) * 2)));
|
||||||
}
|
}
|
||||||
} //Fin largeur Rails
|
}
|
||||||
} //Fin union
|
} // /union
|
||||||
translate([-Thick, -Thick, Height/2]) { // Cube à soustraire
|
translate([-Thick, -Thick, Height/2]) { // Remove the top half
|
||||||
cube([Length + Thick*2, Width + Thick*2, Height]);
|
cube([Length + Thick*2, Width + Thick*2, Height]);
|
||||||
}
|
}
|
||||||
} //fin soustraction cube median - End Median cube slicer
|
translate([-Thick, Thick*2, Thick*2]) { // Remove the center for panel visibility.
|
||||||
translate([-Thick, Thick*2, Thick*2]) { // Forme de soustraction centrale
|
|
||||||
RoundBox($a=(Length + Thick*2), $b=(Width - Thick*4), $c=(Height - Thick*4));
|
RoundBox($a=(Length + Thick*2), $b=(Width - Thick*4), $c=(Height - Thick*4));
|
||||||
}
|
}
|
||||||
} // End difference for main box
|
}
|
||||||
|
}
|
||||||
|
|
||||||
difference() { // wall fixation box legs
|
|
||||||
|
/* Decorations: decorations module
|
||||||
|
|
||||||
|
This module produces the box vents or decorations.
|
||||||
|
*/
|
||||||
|
module Decorations() {
|
||||||
|
union() {
|
||||||
|
// X offset to center of first vent
|
||||||
|
DecOffset = Thick*2 + PanelThick + PanelGap + Dec_Spacing - Vent_width/2;
|
||||||
|
for (i=[0 : Dec_Spacing : Length/4]) {
|
||||||
|
translate([DecOffset + i - Vent_width/2, -1, -1]) {
|
||||||
|
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
|
||||||
|
}
|
||||||
|
translate([Length - DecOffset - i - Vent_width/2, -1, -1]) {
|
||||||
|
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
|
||||||
|
}
|
||||||
|
translate([Length - DecOffset - i - Vent_width/2, Width - Dec_Thick, -1]) {
|
||||||
|
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
|
||||||
|
}
|
||||||
|
translate([DecOffset + i - Vent_width/2, Width - Dec_Thick, -1]) {
|
||||||
|
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Legs: legs module
|
||||||
|
|
||||||
|
This module produces the wall fixation box legs.
|
||||||
|
*/
|
||||||
|
module Legs() {
|
||||||
|
difference() {
|
||||||
union() {
|
union() {
|
||||||
translate([MountInset, Thick, Height/2]) {
|
translate([MountInset, Thick, Height/2]) {
|
||||||
rotate([270, 0, 0]) {
|
rotate([270, 0, 0]) {
|
||||||
@ -239,32 +266,17 @@ module Coque() { //Coque - Shell
|
|||||||
translate([0, 0, Height/2]) {
|
translate([0, 0, Height/2]) {
|
||||||
cube([Length, Thick + OuterMargin, 4*ScrewHole]);
|
cube([Length, Thick + OuterMargin, 4*ScrewHole]);
|
||||||
}
|
}
|
||||||
} //Fin fixation box legs
|
}
|
||||||
} // End union for box and legs
|
}
|
||||||
|
|
||||||
union() { // outbox sides decorations
|
|
||||||
// X offset to center of first vent
|
|
||||||
DecOffset = Thick*2 + PanelThick + PanelGap + Dec_Spacing - Vent_width/2;
|
|
||||||
for (i=[0 : Dec_Spacing : Length/4]) {
|
|
||||||
// Ventilation holes part code submitted by Ettie - Thanks ;)
|
|
||||||
translate([DecOffset + i - Vent_width/2, -1, -1]) {
|
|
||||||
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
|
|
||||||
}
|
|
||||||
translate([Length - DecOffset - i - Vent_width/2, -1, -1]) {
|
|
||||||
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
|
|
||||||
}
|
|
||||||
translate([Length - DecOffset - i - Vent_width/2, Width - Dec_Thick, -1]) {
|
|
||||||
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
|
|
||||||
}
|
|
||||||
translate([DecOffset + i - Vent_width/2, Width - Dec_Thick, -1]) {
|
|
||||||
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
|
|
||||||
}
|
|
||||||
} // fin de for
|
|
||||||
} //fin union decoration
|
|
||||||
|
|
||||||
} //fin difference decoration
|
/* Holes: holes module
|
||||||
|
|
||||||
union() { //sides holes
|
This module produces the holes necessary in the box fixation tabs and in the wall
|
||||||
|
of the box for the corresponding tabs to affix to.
|
||||||
|
*/
|
||||||
|
module Holes() {
|
||||||
|
union() {
|
||||||
$fn = 100;
|
$fn = 100;
|
||||||
translate([MountInset, 0, Height/2 + 2*ScrewHole]) {
|
translate([MountInset, 0, Height/2 + 2*ScrewHole]) {
|
||||||
rotate([270, 0, 0]) {
|
rotate([270, 0, 0]) {
|
||||||
@ -286,10 +298,26 @@ module Coque() { //Coque - Shell
|
|||||||
cylinder(Thick*3, d=ScrewHole);
|
cylinder(Thick*3, d=ScrewHole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //fin de sides holes
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} //fin de difference holes
|
|
||||||
} // fin coque
|
/* Coque: Shell module
|
||||||
|
|
||||||
|
This module takes no arguments, but produces a box shell. This is half the box,
|
||||||
|
including slots for end panels, rounded corners according to Filet and Resolution,
|
||||||
|
wall fixation legs and holes, and vents/decorations according to parameters.
|
||||||
|
*/
|
||||||
|
module Coque() { //Coque - Shell
|
||||||
|
difference() {
|
||||||
|
union() {
|
||||||
|
MainBox();
|
||||||
|
Legs();
|
||||||
|
}
|
||||||
|
Decorations();
|
||||||
|
Holes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* foot module
|
/* foot module
|
||||||
|
Loading…
Reference in New Issue
Block a user