Skip to content

Instantly share code, notes, and snippets.

@raidzero
Created June 14, 2018 20:06
Show Gist options
  • Save raidzero/7df5833fd91b363a086bf871264ddb0a to your computer and use it in GitHub Desktop.
Save raidzero/7df5833fd91b363a086bf871264ddb0a to your computer and use it in GitHub Desktop.
switch box scad design
// make a 75wx40dx25h hollow square
height = 25;
width = 75;
depth = 45;
thickness = 2;
// stereo jack/switch mounting holes
hole_diameter = 6;
// width of corner support columns
support_size = 6;
difference() {
// make outer shell
difference() {
// outer shell
cube(size = [width, depth, height], center = true);
// make cube hollow, with columns for corner supports
difference() {
// inner cube
cube(size = [width - thickness, depth - thickness, height - thickness], center = true);
// but leave corner supports
translate([((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([-((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([-((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
}
// cut out right side holes: 6mm diameter
rotate([90, 0, 0])
translate([15,0,0])
cylinder(h=depth, r1=hole_diameter, r2=hole_diameter, center=true);
// cut out left side holes: 6mm diameter
rotate([90, 0, 0])
translate([-15,0,0])
cylinder(h=depth, r1=hole_diameter, r2=hole_diameter, center=true);
// cut out screw holes in top and into top part of supports
translate([((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([-((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([-((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
}
// subtract top 2mm
translate([0, 0, height - 2])
cube(size = [width, depth, height], center = true);
}
// make a 75wx40dx25h hollow square
height = 25;
width = 75;
depth = 45;
thickness = 2;
// stereo jack/switch mounting holes
hole_diameter = 6;
// width of corner support columns
support_size = 6;
difference() {
// make outer shell
difference() {
// outer shell
cube(size = [width, depth, height], center = true);
// make cube hollow, with columns for corner supports
difference() {
// inner cube
cube(size = [width - thickness, depth - thickness, height - thickness], center = true);
// but leave corner supports
translate([((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([-((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([-((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
}
// cut out right side holes: 6mm diameter
rotate([90, 0, 0])
translate([15,0,0])
cylinder(h=depth, r1=hole_diameter, r2=hole_diameter, center=true);
// cut out left side holes: 6mm diameter
rotate([90, 0, 0])
translate([-15,0,0])
cylinder(h=depth, r1=hole_diameter, r2=hole_diameter, center=true);
// cut out screw holes in top and into top part of supports
translate([((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([-((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([-((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
}
// subtract all but top 2mm
translate([0, 0, -2])
cube(size = [width, depth, height - 2], center = true);
}
// make a 75wx40dx25h hollow square
height = 25;
width = 75;
depth = 45;
thickness = 2;
// stereo jack/switch mounting holes
hole_diameter = 6;
// width of corner support columns
support_size = 6;
// make outer shell
difference() {
// outer shell
cube(size = [width, depth, height], center = true);
// make cube hollow, with columns for corner supports
difference() {
// inner cube
cube(size = [width - thickness, depth - thickness, height - thickness], center = true);
// but leave corner supports
translate([((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([-((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
translate([-((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 0])
cube(size = [support_size, support_size, height], center = true);
}
// cut out right side holes: 6mm diameter
rotate([90, 0, 0])
translate([15,0,0])
cylinder(h=depth, r1=hole_diameter, r2=hole_diameter, center=true);
// cut out left side holes: 6mm diameter
rotate([90, 0, 0])
translate([-15,0,0])
cylinder(h=depth, r1=hole_diameter, r2=hole_diameter, center=true);
// cut out screw holes in top and into top part of supports
translate([((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([-((width / 2.0) - thickness * 2), ((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
translate([-((width / 2.0) - thickness * 2), -((depth / 2.0) - thickness * 2), 10])
cylinder(h=height/2, r1=2, r2=2, center=true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment