Skip to content

Instantly share code, notes, and snippets.

@oisin
Last active July 13, 2019 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oisin/8f652623e9d6990486b32261d9641fb4 to your computer and use it in GitHub Desktop.
Save oisin/8f652623e9d6990486b32261d9641fb4 to your computer and use it in GitHub Desktop.
My First 3D Design -- tray for tiny oscilloscope
// $fn = 24; // uncomment for production
// set to true for production -- this prevents hex render which takes
// a couple minutes
use_hex_base = false;
module tab(ringw=6.5, stemh=20, stemw=8, thick=3) {
cube([stemw, thick, stemh]);
translate([stemw / 2, 0, stemh + ringw]){
rotate(270,v=[1,0,0]) {
rotate_extrude() {
translate([ringw, 0, 0])
square([thick + 1,thick]);
};
};
};
};
module hex(x,y, render=true)
{
if (!render) {
difference()
{
translate([x,y,-height2/20])
cylinder(r=(hex_radius+hex_border_width/20), h=height2/10, $fn=6);
translate([x,y,-height2/20])
cylinder(r=(hex_radius-hex_border_width/20), h=height2/10, $fn=6);
}
}
}
module tray(x,y,z,wt,open_face=false) {
difference() {
// basic cuboid shape
cube([x, y, z]);
// cut out the space from the basic cuboid shape
// to make the tray
translate([wt,wt,0]) {
cube([x - wt * 2, y - wt * 2, z]);
}
if (open_face) {
difference() {
translate([0, 0, z / 4]) {
// cut out part of the front face to reduce material
cube([x, y - wt, z / 2]);
};
// rigidity supports are useful to keep the shape if
// content is a little weighty
translate([0,0,0]) cube([wt, wt, z]);
translate([x-wt, 0, 0]) cube([wt, wt, z]);
}
};
}
};
module tabs_for_tray(x, y, z, sep, tabdepth, tabheight=10) {
tab1 = (x - sep) / 2;
translate([tab1, y -tabdepth, z]) {
tab(stemh = tabheight, thick = tabdepth);
};
translate([tab_separation, y-tabdepth, z]) {
tab(stemh = tabheight, thick = tabdepth);
};
}
length = 100;
depth = 40;
height = 35;
wall_thickness = 3;
tray(length, depth, height, wall_thickness, true);
tab_separation = 80;
tabs_for_tray(length, depth, height, tab_separation, wall_thickness);
// first arg is vector that defines the bounding box, length, width, height
// second arg in the 'diameter' of the holes. In OpenScad, this refers to the corner-to-corner diameter, not flat-to-flat
// this diameter is 2/sqrt(3) times larger than flat to flat
// third arg is wall thickness. This also is measured that the corners, not the flats.
//hexgrid([length, depth, 2], 10, 5);
// Customizable hex pattern
// Created by Kjell Kernen
// Date 22.9.2014
/*[Pattern Parameters]*/
// of the pattern in mm:
width=100; // [10:100]
// of the pattern in mm:
lenght=40; // [10:100]
// of the pattern in tens of mm:
height2=5; // [2:200]
// in tens of mm:
border_width=20;// [2:100]
// in mm:
hex_radius=5; // [1:20]
// in tens of mm:
hex_border_width=30; // [2:50]
/*[Hidden]*/
if (use_hex_base) {
xborder=(border_width/10<width)?width-border_width/10:0;
yborder=(border_width/10<lenght)?lenght-border_width/10:0;
x=sqrt(3/4*hex_radius*hex_radius);
ystep=2*x;
xstep=3*hex_radius/2;
translate([50,20,0]){
//Pattern
intersection()
{
for (xi=[0:xstep:width])
for(yi=[0:ystep:lenght])
hex(xi-width/2,((((xi/xstep)%2)==0)?0:ystep/2)+yi-lenght/2);
translate([-width/2, -lenght/2, -height2/20])
cube([width,lenght,height2/10]);
}
// Frame
difference()
{
translate([-width/2, -lenght/2, -height2/20])
cube([width,lenght,height2/10]);
translate([-xborder/2, -yborder/2, -(height2/20+0.1)])
cube([xborder,yborder,height2/10+0.2]);
}
}
} else {
translate([0,0,0]) #cube([length, depth, wall_thickness]);
}
@oisin
Copy link
Author

oisin commented Jul 13, 2019

Revision 6 contains an option to switch on the hex base or leave a solid base. Use the solid base for test renders and switch to hex for a nicer thing that takes longer to render (90 sec vs 0 sec eg). Tabs are not standing out from the body of the tray anymore, they are incorporated, and by default shorter too. Increased the wall thickness to 3mm. For more rigidity, have put supports in at the front corners of the open tray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment