From 9ddb6d751600d97cbd8e7a129054e10aa903322c Mon Sep 17 00:00:00 2001 From: Joel Ebel Date: Fri, 18 May 2018 00:55:11 -0400 Subject: [PATCH] Simplify Decorations module 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. --- files/U_Box_V104_Test_Cleaned.scad | 39 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/files/U_Box_V104_Test_Cleaned.scad b/files/U_Box_V104_Test_Cleaned.scad index 942628f..f5b8a94 100644 --- a/files/U_Box_V104_Test_Cleaned.scad +++ b/files/U_Box_V104_Test_Cleaned.scad @@ -129,6 +129,8 @@ TextColor = "White"; Dec_Thick = Vent ? Thick*1.001 + Filet : Thick/2; // Separate vents with a square pillar by default. Dec_Spacing = Thick + Vent_width; +// X offset to center of first vent +Dec_Offset = Thick*2 + PanelThick + PanelGap + Dec_Spacing - Vent_width/2; // Resolution based on Round parameter Resolution = Round ? 100: 4; @@ -207,26 +209,35 @@ module MainBox() { } +/* Decoration: a single box decoration +*/ +module decoration() { + translate([-Vent_width/2, -Thick, -Thick]) { + cube([Vent_width, Dec_Thick + Thick, Height/4 + Thick]); + } +} + + /* 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]); + for (i=[0 : Dec_Spacing : Length/4]) { + translate([Dec_Offset + i, 0, 0]) { + decoration(); + } + translate([Length - Dec_Offset - i, 0, 0]) { + decoration(); + } + translate([Length - Dec_Offset - i, Width, 0]) { + rotate([0, 0, 180]) { + decoration(); } - 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]); + } + translate([Dec_Offset + i, Width, 0]) { + rotate([0, 0, 180]) { + decoration(); } } }