Improve spacing

Add/remove lots of spacing for consistency. Add/remove a few parenthesis
for arithmetic readability.

Actually undo previous spacing because I disagree with the style guide
referenced previously.
This commit is contained in:
Joel Ebel 2018-05-04 00:01:57 -04:00
parent 3767d5bd27
commit 40e125b833

View File

@ -28,27 +28,27 @@
/* [Box dimensions] */ /* [Box dimensions] */
// - Longueur - Length // - Longueur - Length
Length = 160; Length = 160;
// - Largeur - Width // - Largeur - Width
Width = 170; Width = 170;
// - Hauteur - Height // - Hauteur - Height
Height = 100; Height = 100;
// - Epaisseur - Wall thickness // - Epaisseur - Wall thickness
Thick = 2;//[2:5] Thick = 2; //[2:5]
/* [Box options] */ /* [Box options] */
// - Diamètre Coin arrondi - Filet diameter // - Diamètre Coin arrondi - Filet diameter
Filet = 2;//[0.1:12] Filet = 2; //[0.1:12]
// - lissage de l'arrondi - Filet smoothness // - lissage de l'arrondi - Filet smoothness
Resolution = 50;//[1:100] Resolution = 50; //[1:100]
// - Tolérance - Tolerance (Panel/rails gap) // - Tolérance - Tolerance (Panel/rails gap)
m = 0.9; m = 0.9;
// Pieds PCB - PCB feet (x4) // Pieds PCB - PCB feet (x4)
PCBFeet = 1;// [0:No, 1:Yes] PCBFeet = 1; // [0:No, 1:Yes]
// - Decorations to ventilation holes // - Decorations to ventilation holes
Vent = 1;// [0:No, 1:Yes] Vent = 1; // [0:No, 1:Yes]
// - Decoration-Holes width (in mm) // - Decoration-Holes width (in mm)
Vent_width = 1.5; Vent_width = 1.5;
@ -56,42 +56,42 @@ Vent_width = 1.5;
//All dimensions are from the center foot axis //All dimensions are from the center foot axis
// - Coin bas gauche - Low left corner X position // - Coin bas gauche - Low left corner X position
PCBPosX = 7; PCBPosX = 7;
// - Coin bas gauche - Low left corner Y position // - Coin bas gauche - Low left corner Y position
PCBPosY = 6; PCBPosY = 6;
// - Longueur PCB - PCB Length // - Longueur PCB - PCB Length
PCBLength = 70; PCBLength = 70;
// - Largeur PCB - PCB Width // - Largeur PCB - PCB Width
PCBWidth = 50; PCBWidth = 50;
// - Heuteur pied - Feet height // - Heuteur pied - Feet height
FootHeight = 10; FootHeight = 10;
// - Diamètre pied - Foot diameter // - Diamètre pied - Foot diameter
FootDia = 8; FootDia = 8;
// - Diamètre trou - Hole diameter // - Diamètre trou - Hole diameter
FootHole = 3; FootHole = 3;
/* [STL element to export] */ /* [STL element to export] */
//Coque haut - Top shell //Coque haut - Top shell
TShell = 0;// [0:No, 1:Yes] TShell = 0; // [0:No, 1:Yes]
//Coque bas- Bottom shell //Coque bas- Bottom shell
BShell = 1;// [0:No, 1:Yes] BShell = 1; // [0:No, 1:Yes]
//Panneau avant - Front panel //Panneau avant - Front panel
FPanL = 1;// [0:No, 1:Yes] FPanL = 1; // [0:No, 1:Yes]
//Panneau arrière - Back panel //Panneau arrière - Back panel
BPanL = 1;// [0:No, 1:Yes] BPanL = 1; // [0:No, 1:Yes]
/* [Hidden] */ /* [Hidden] */
// - Couleur coque - Shell color // - Couleur coque - Shell color
Couleur1 = "Orange"; Couleur1 = "Orange";
// - Couleur panneaux - Panels color // - Couleur panneaux - Panels color
Couleur2 = "OrangeRed"; Couleur2 = "OrangeRed";
// Thick X 2 - making decorations thicker if it is a vent to make sure they go through shell // Thick X 2 - making decorations thicker if it is a vent to make sure they go through shell
Dec_Thick = Vent ? Thick*2 : Thick; Dec_Thick = Vent ? Thick*2 : Thick;
// - Depth decoration // - Depth decoration
Dec_size = Vent ? Thick*2 : 0.8; Dec_size = Vent ? Thick*2 : 0.8;
@ -99,13 +99,13 @@ Dec_size = Vent ? Thick*2 : 0.8;
/////////// - Boitier générique bord arrondis - Generic rounded box - ////////// /////////// - Boitier générique bord arrondis - Generic rounded box - //////////
module RoundBox($a=Length, $b=Width, $c=Height) {// Cube bords arrondis module RoundBox($a=Length, $b=Width, $c=Height) { // Cube bords arrondis
$fn=Resolution; $fn = Resolution;
translate([0,Filet,Filet]) { translate([0, Filet, Filet]) {
minkowski () { minkowski() {
cube ([$a-(Length/2),$b-(2*Filet),$c-(2*Filet)], center = false); cube([$a - Length/2, $b - 2*Filet, $c - 2*Filet], center=false);
rotate([0,90,0]) { rotate([0, 90, 0]) {
cylinder(r=Filet,h=Length/2, center = false); cylinder(r=Filet, h=(Length/2), center=false);
} }
} }
} }
@ -114,113 +114,113 @@ module RoundBox($a=Length, $b=Width, $c=Height) {// Cube bords arrondis
////////////////////////////////// - Module Coque/Shell - ////////////////////////////////// ////////////////////////////////// - Module Coque/Shell - //////////////////////////////////
module Coque() {//Coque - Shell module Coque() { //Coque - Shell
Thick = Thick*2; Thick = Thick*2;
difference() { difference() {
difference() {//sides decoration difference() { //sides decoration
union() { union() {
difference() {//soustraction de la forme centrale - Substraction Fileted box difference() { //soustraction de la forme centrale - Substraction Fileted box
difference() {//soustraction cube median - Median cube slicer difference() { //soustraction cube median - Median cube slicer
union() {//union union() { //union
difference() {//Coque difference() { //Coque
RoundBox(); RoundBox();
translate([Thick/2,Thick/2,Thick/2]) { translate([Thick/2, Thick/2, Thick/2]) {
RoundBox($a=Length-Thick, $b=Width-Thick, $c=Height-Thick); RoundBox($a=(Length - Thick), $b=(Width - Thick), $c=(Height - Thick));
} }
}//Fin diff Coque } //Fin diff Coque
difference() {//largeur Rails difference() { //largeur Rails
translate([Thick+m,Thick/2,Thick/2]) {// Rails translate([Thick + m, Thick/2, Thick/2]) { // Rails
RoundBox($a=Length-((2*Thick)+(2*m)), $b=Width-Thick, $c=Height-(Thick*2)); RoundBox($a=(Length - (2*Thick + 2*m)), $b=(Width - Thick), $c=(Height - Thick*2));
}//fin Rails }//fin Rails
translate([((Thick+m/2)*1.55),Thick/2,Thick/2+0.1]) { // +0.1 added to avoid the artefact translate([((Thick + m/2) * 1.55), Thick/2, Thick/2 + 0.1]) { // +0.1 added to avoid the artefact
RoundBox($a=Length-((Thick*3)+2*m), $b=Width-Thick, $c=Height-Thick); RoundBox($a=(Length - ((Thick*3) + 2*m)), $b=(Width - Thick), $c=(Height - Thick));
} }
}//Fin largeur Rails } //Fin largeur Rails
}//Fin union } //Fin union
translate([-Thick,-Thick,Height/2]) {// Cube à soustraire translate([ -Thick, -Thick, Height/2]) { // Cube à soustraire
cube ([Length+100, Width+100, Height], center=false); cube([Length + 100, Width + 100, Height], center=false);
} }
}//fin soustraction cube median - End Median cube slicer } //fin soustraction cube median - End Median cube slicer
translate([-Thick/2,Thick,Thick]) {// Forme de soustraction centrale translate([-Thick/2, Thick, Thick]) { // Forme de soustraction centrale
RoundBox($a=Length+Thick, $b=Width-Thick*2, $c=Height-Thick); RoundBox($a=(Length + Thick), $b=(Width - Thick*2), $c=(Height - Thick));
} }
} }
difference() {// wall fixation box legs difference() { // wall fixation box legs
union() { union() {
translate([3*Thick +5,Thick,Height/2]) { translate([3*Thick + 5, Thick, Height/2]) {
rotate([90,0,0]) { rotate([90, 0, 0]) {
$fn=6; $fn = 6;
cylinder(d=16,Thick/2); cylinder(d=16, Thick/2);
} }
} }
translate([Length-((3*Thick)+5),Thick,Height/2]) { translate([Length - (3*Thick + 5), Thick, Height/2]) {
rotate([90,0,0]) { rotate([90, 0, 0]) {
$fn=6; $fn = 6;
cylinder(d=16,Thick/2); cylinder(d=16, Thick/2);
} }
} }
} }
translate([4,Thick+Filet,Height/2-57]) { translate([4, Thick + Filet, Height/2 - 57]) {
rotate([45,0,0]) { rotate([45, 0, 0]) {
cube([Length,40,40]); cube([Length, 40, 40]);
} }
} }
translate([0,-(Thick*1.46),Height/2]) { translate([0, -(Thick*1.46), Height/2]) {
cube([Length,Thick*2,10]); cube([Length, Thick*2, 10]);
} }
} //Fin fixation box legs } //Fin fixation box legs
} }
union() {// outbox sides decorations union() { // outbox sides decorations
for(i=[0:Thick:Length/4]) { for(i=[0 : Thick : Length/4]) {
// Ventilation holes part code submitted by Ettie - Thanks ;) // Ventilation holes part code submitted by Ettie - Thanks ;)
translate([10+i,-Dec_Thick+Dec_size,1]) { translate([10 + i, -Dec_Thick + Dec_size, 1]) {
cube([Vent_width,Dec_Thick,Height/4]); cube([Vent_width, Dec_Thick, Height/4]);
} }
translate([(Length-10) - i,-Dec_Thick+Dec_size,1]) { translate([(Length - 10) - i, -Dec_Thick + Dec_size, 1]) {
cube([Vent_width,Dec_Thick,Height/4]); cube([Vent_width, Dec_Thick, Height/4]);
} }
translate([(Length-10) - i,Width-Dec_size,1]) { translate([(Length - 10) - i, Width - Dec_size, 1]) {
cube([Vent_width,Dec_Thick,Height/4]); cube([Vent_width, Dec_Thick, Height/4]);
} }
translate([10+i,Width-Dec_size,1]) { translate([10 + i, Width - Dec_size, 1]) {
cube([Vent_width,Dec_Thick,Height/4]); cube([Vent_width, Dec_Thick, Height/4]);
} }
}// fin de for } // fin de for
}//fin union decoration } //fin union decoration
}//fin difference decoration } //fin difference decoration
union() { //sides holes union() { //sides holes
$fn=50; $fn = 50;
translate([3*Thick+5,20,Height/2+4]) { translate([3*Thick + 5, 20, Height/2 + 4]) {
rotate([90,0,0]) { rotate([90, 0, 0]) {
cylinder(d=2,20); cylinder(d=2, 20);
} }
} }
translate([Length-((3*Thick)+5),20,Height/2+4]) { translate([Length - (3*Thick + 5), 20, Height/2 + 4]) {
rotate([90,0,0]) { rotate([90, 0, 0]) {
cylinder(d=2,20); cylinder(d=2, 20);
} }
} }
translate([3*Thick+5,Width+5,Height/2-4]) { translate([3*Thick + 5, Width + 5, Height/2 - 4]) {
rotate([90,0,0]) { rotate([90,0,0]) {
cylinder(d=2,20); cylinder(d=2, 20);
} }
} }
translate([Length-((3*Thick)+5),Width+5,Height/2-4]) { translate([Length - (3*Thick + 5), Width + 5, Height/2 - 4]) {
rotate([90,0,0]) { rotate([90, 0, 0]) {
cylinder(d=2,20); cylinder(d=2, 20);
} }
} }
}//fin de sides holes } //fin de sides holes
}//fin de difference holes } //fin de difference holes
}// fin coque } // fin coque
////////////////////////////// - Experiment - /////////////////////////////////////////// ////////////////////////////// - Experiment - ///////////////////////////////////////////
@ -229,16 +229,16 @@ module Coque() {//Coque - Shell
/////////////////////// - Foot with base filet - ///////////////////////////// /////////////////////// - Foot with base filet - /////////////////////////////
module foot(FootDia,FootHole,FootHeight) { module foot(FootDia, FootHole, FootHeight) {
Filet=2; Filet = 2;
color(Couleur1) color(Couleur1)
translate([0,0,Filet-1.5]) translate([0, 0, Filet - 1.5])
difference() { difference() {
difference() { difference() {
cylinder(d=FootDia+Filet,FootHeight-Thick, $fn=100); cylinder(d=(FootDia + Filet), FootHeight - Thick, $fn=100);
rotate_extrude($fn=100) { rotate_extrude($fn = 100) {
translate([(FootDia+Filet*2)/2,Filet,0]) { translate([(FootDia + Filet*2) / 2, Filet, 0]) {
minkowski() { minkowski() {
square(10); square(10);
circle(Filet, $fn=100); circle(Filet, $fn=100);
@ -246,16 +246,15 @@ module foot(FootDia,FootHole,FootHeight) {
} }
} }
} }
cylinder(d=FootHole,FootHeight+1, $fn=100); cylinder(d=FootHole, FootHeight + 1, $fn=100);
} }
}// Fin module foot } // Fin module foot
module Feet() { module Feet() {
//////////////////// - PCB only visible in the preview mode - ///////////////////// //////////////////// - PCB only visible in the preview mode - /////////////////////
translate([3*Thick+2,Thick+5,FootHeight+(Thick/2)-0.5]) { translate([(3*Thick + 2), Thick + 5, (FootHeight + Thick/2 - 0.5)]) {
%squar ([PCBLength + 10, PCBWidth + 10]);
%square ([PCBLength+10,PCBWidth+10]); translate([PCBLength/2, PCBWidth/2, 0.5]) {
translate([PCBLength/2,PCBWidth/2,0.5]) {
color("Olive") color("Olive")
%text("PCB", halign="center", valign="center", font="Arial black"); %text("PCB", halign="center", valign="center", font="Arial black");
} }
@ -263,17 +262,17 @@ module Feet() {
////////////////////////////// - 4 Feet - ////////////////////////////////////////// ////////////////////////////// - 4 Feet - //////////////////////////////////////////
translate([3*Thick+7,Thick+10,Thick/2]) { translate([3*Thick + 7, Thick + 10, Thick/2]) {
foot(FootDia,FootHole,FootHeight); foot(FootDia, FootHole, FootHeight);
} }
translate([(3*Thick)+PCBLength+7,Thick+10,Thick/2]) { translate([(3*Thick + PCBLength + 7), Thick + 10, Thick/2]) {
foot(FootDia,FootHole,FootHeight); foot(FootDia, FootHole, FootHeight);
} }
translate([(3*Thick)+PCBLength+7,(Thick)+PCBWidth+10,Thick/2]) { translate([3*Thick + PCBLength + 7, Thick + PCBWidth + 10, Thick/2]) {
foot(FootDia,FootHole,FootHeight); foot(FootDia, FootHole, FootHeight);
} }
translate([3*Thick+7,(Thick)+PCBWidth+10,Thick/2]) { translate([3*Thick + 7, Thick + PCBWidth + 10, Thick/2]) {
foot(FootDia,FootHole,FootHeight); foot(FootDia, FootHole, FootHeight);
} }
} // Fin du module Feet } // Fin du module Feet
@ -286,13 +285,13 @@ module Feet() {
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// <- Panel -> // <- Panel ->
module Panel(Length,Width,Thick,Filet) { module Panel(Length, Width, Thick, Filet) {
scale([0.5,1,1]) scale([0.5, 1, 1])
minkowski() { minkowski() {
cube([Thick,Width-(Thick*2+Filet*2+m),Height-(Thick*2+Filet*2+m)]); cube([Thick, Width - (Thick*2 + Filet*2 + m), Height - (Thick*2 + Filet*2 + m)]);
translate([0,Filet,Filet]) translate([0, Filet, Filet])
rotate([0,90,0]) rotate([0, 90, 0])
cylinder(r=Filet,h=Thick, $fn=100); cylinder(r=Filet, h=Thick, $fn=100);
} }
} }
@ -300,20 +299,20 @@ module Panel(Length,Width,Thick,Filet) {
// <- Circle hole -> // <- Circle hole ->
// Cx=Cylinder X position | Cy=Cylinder Y position | Cdia= Cylinder dia | Cheight=Cyl height // Cx=Cylinder X position | Cy=Cylinder Y position | Cdia= Cylinder dia | Cheight=Cyl height
module CylinderHole(OnOff,Cx,Cy,Cdia) { module CylinderHole(OnOff, Cx, Cy, Cdia) {
if(OnOff == 1) { if (OnOff == 1) {
translate([Cx,Cy,-1]) translate([Cx, Cy, -1])
cylinder(d=Cdia,10, $fn=50); cylinder(d=Cdia, 10, $fn=50);
} }
} }
// <- Square hole -> // <- Square hole ->
// Sx=Square X position | Sy=Square Y position | Sl= Square Length | Sw=Square Width | Filet = Round corner // Sx=Square X position | Sy=Square Y position | Sl= Square Length | Sw=Square Width | Filet = Round corner
module SquareHole(OnOff,Sx,Sy,Sl,Sw,Filet) { module SquareHole(OnOff, Sx, Sy, Sl, Sw, Filet) {
if(OnOff == 1) { if (OnOff == 1) {
minkowski() { minkowski() {
translate([Sx+Filet/2,Sy+Filet/2,-1]) translate([Sx + Filet/2, Sy + Filet/2, -1])
cube([Sl-Filet,Sw-Filet,10]); cube([Sl - Filet, Sw - Filet, 10]);
cylinder(d=Filet,h=10, $fn=100); cylinder(d=Filet, h=10, $fn=100);
} }
} }
} }
@ -322,23 +321,23 @@ module SquareHole(OnOff,Sx,Sy,Sl,Sw,Filet) {
// <- Linear text panel -> // <- Linear text panel ->
module LText(OnOff,Tx,Ty,Font,Size,Content) { module LText(OnOff,Tx,Ty,Font,Size,Content) {
if(OnOff == 1) { if (OnOff == 1) {
translate([Tx,Ty,Thick+.5]) translate([Tx, Ty, Thick + .5])
linear_extrude(height = 0.5) { linear_extrude(height=0.5) {
text(Content, size=Size, font=Font); text(Content, size=Size, font=Font);
} }
} }
} }
// <- Circular text panel-> // <- Circular text panel->
module CText(OnOff,Tx,Ty,Font,Size,TxtRadius,Angl,Turn,Content) { module CText(OnOff, Tx, Ty, Font, Size, TxtRadius, Angl, Turn, Content) {
if(OnOff == 1) { if (OnOff == 1) {
Angle = -Angl / len(Content); Angle = -Angl / len(Content);
translate([Tx,Ty,Thick+.5]) translate([Tx, Ty, Thick + .5])
for (i= [0:len(Content)-1] ) { for (i= [0 : len(Content) - 1] ) {
rotate([0,0,i*Angle+90+Turn]) rotate([0, 0, i*Angle + 90 + Turn])
translate([0,TxtRadius,0]) { translate([0, TxtRadius, 0]) {
linear_extrude(height = 0.5) { linear_extrude(height=0.5) {
text(Content[i], font = Font, size = Size, valign ="baseline", halign ="center"); text(Content[i], font=Font, size=Size, valign="baseline", halign="center");
} }
} }
} }
@ -348,33 +347,33 @@ module CText(OnOff,Tx,Ty,Font,Size,TxtRadius,Angl,Turn,Content) {
module FPanL() { module FPanL() {
difference() { difference() {
color(Couleur2) color(Couleur2)
Panel(Length,Width,Thick,Filet); Panel(Length, Width, Thick, Filet);
rotate([90,0,90]) { rotate([90, 0, 90]) {
color(Couleur2) { color(Couleur2) {
// <- Cutting shapes from here -> // <- Cutting shapes from here ->
SquareHole (1,20,20,15,10,1); //(On/Off, Xpos,Ypos,Length,Width,Filet) SquareHole(1, 20, 20, 15, 10, 1); //(On/Off, Xpos,Ypos,Length,Width,Filet)
SquareHole (1,40,20,15,10,1); SquareHole(1, 40, 20, 15, 10, 1);
SquareHole (1,60,20,15,10,1); SquareHole(1, 60, 20, 15, 10, 1);
CylinderHole(1,27,40,8); //(On/Off, Xpos, Ypos, Diameter) CylinderHole(1, 27, 40, 8); //(On/Off, Xpos, Ypos, Diameter)
CylinderHole(1,47,40,8); CylinderHole(1, 47, 40, 8);
CylinderHole(1,67,40,8); CylinderHole(1, 67, 40, 8);
SquareHole (1,20,50,80,30,3); SquareHole(1, 20, 50, 80, 30, 3);
CylinderHole(1,93,30,10); CylinderHole(1, 93, 30, 10);
SquareHole (1,120,20,30,60,3); SquareHole(1, 120, 20, 30, 60, 3);
// <- To here -> // <- To here ->
} }
} }
} }
color(Couleur1) { color(Couleur1) {
translate ([-.5,0,0]) translate ([-.5, 0, 0])
rotate([90,0,90]) { rotate([90, 0, 90]) {
// <- Adding text from here -> // <- Adding text from here ->
LText(1,20,83,"Arial Black",4,"Digital Screen");//(On/Off, Xpos, Ypos, "Font", Size, "Text") LText(1, 20, 83, "Arial Black", 4, "Digital Screen"); //(On/Off, Xpos, Ypos, "Font", Size, "Text")
LText(1,120,83,"Arial Black",4,"Level"); LText(1, 120, 83, "Arial Black", 4, "Level");
LText(1,20,11,"Arial Black",6," 1 2 3"); LText(1, 20, 11, "Arial Black", 6, " 1 2 3");
CText(1,93,29,"Arial Black",4,10,180,0,"1 . 2 . 3 . 4 . 5 . 6");//(On/Off, Xpos, Ypos, "Font", Size, Diameter, Arc(Deg), Starting Angle(Deg),"Text") CText(1, 93, 29, "Arial Black", 4, 10, 180, 0, "1 . 2 . 3 . 4 . 5 . 6"); //(On/Off, Xpos, Ypos, "Font", Size, Diameter, Arc(Deg), Starting Angle(Deg),"Text")
// <- To here -> // <- To here ->
} }
} }
@ -383,18 +382,18 @@ module FPanL() {
/////////////////////////// <- Main part -> ///////////////////////// /////////////////////////// <- Main part -> /////////////////////////
if(TShell == 1) { if (TShell == 1) {
// Coque haut - Top Shell // Coque haut - Top Shell
color( Couleur1,1) { color( Couleur1, 1) {
translate([0,Width,Height+0.2]) { translate([0, Width, Height + 0.2]) {
rotate([0,180,180]) { rotate([0, 180, 180]) {
Coque(); Coque();
} }
} }
} }
} }
if(BShell == 1) { if (BShell == 1) {
// Coque bas - Bottom shell // Coque bas - Bottom shell
color(Couleur1) { color(Couleur1) {
Coque(); Coque();
@ -402,23 +401,23 @@ if(BShell == 1) {
} }
// Pied support PCB - PCB feet // Pied support PCB - PCB feet
if(PCBFeet == 1) { if (PCBFeet == 1) {
// Feet // Feet
translate([PCBPosX,PCBPosY,0]) { translate([PCBPosX, PCBPosY, 0]) {
Feet(); Feet();
} }
} }
// Panneau avant - Front panel <<<<<< Text and holes only on this one. // Panneau avant - Front panel <<<<<< Text and holes only on this one.
//rotate([0,-90,-90]) //rotate([0,-90,-90])
if(FPanL == 1) { if (FPanL == 1) {
translate([Length-(Thick*2+m/2),Thick+m/2,Thick+m/2]) translate([Length - (Thick*2 + m/2), Thick + m/2, Thick + m/2])
FPanL(); FPanL();
} }
//Panneau arrière - Back panel //Panneau arrière - Back panel
if(BPanL == 1) { if (BPanL == 1) {
color(Couleur2) color(Couleur2)
translate([Thick+m/2,Thick+m/2,Thick+m/2]) translate([Thick + m/2, Thick + m/2, Thick + m/2])
Panel(Length,Width,Thick,Filet); Panel(Length, Width, Thick, Filet);
} }