Last active
December 23, 2015 18:39
-
-
Save makevoid/6677455 to your computer and use it in GitHub Desktop.
Parametric Decorated Box - http://www.thingiverse.com/thing:155282
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //$fn = 50; // very high version, uses a lot of resources | |
| //$fn = 20; // medium version, should render in ~5 minutes on a i7 with latest scad | |
| $fn = 5; // dev version, or if you don't have a good processor | |
| // use this bash script to export a lot of different stl files, so you can have unique boxes | |
| // | |
| // for i in {1..5}; do echo openscad -o "box_$i.stl" parametric_decorated_box.scad; done | |
| // | |
| // you may need to use the same approach for generating gcode... change 5 to your desired amount of boxes you want to create | |
| steps = 40; | |
| radius = 10; | |
| space = 20; | |
| min_rand = 1; | |
| max_rand = 12; | |
| module ccube_face() { | |
| union() { | |
| for (x = [0:steps:360]) { | |
| for (y = [0:steps:360]) { | |
| translate([sin(x)*space, sin(y)*space, 0]) | |
| // comment this if you want regular boxes, faster to render | |
| rotate([360/rands(min_rand, max_rand, 1)[0], 360/rands(min_rand, max_rand, 1)[0], 360/rands(min_rand, max_rand, 1)[0]]) | |
| sphere(radius); | |
| } | |
| } | |
| } | |
| } | |
| module ccube_faces() { | |
| ccube_face(); | |
| translate([0, 0, space*2]) ccube_face(); | |
| } | |
| module ccube() { | |
| translate([0, 0, -space]) union() { | |
| ccube_faces(); | |
| rotate([0, 90, 0]) translate([-space, 0, -space]) ccube_faces(); | |
| rotate([90, 0, 0]) translate([0, space, -space]) ccube_faces(); | |
| } | |
| } | |
| module cavity() { | |
| cube(space*2, center= true); | |
| } | |
| module box() { | |
| difference() { | |
| ccube(); | |
| // if in_module?(lid) ... | |
| cavity(); | |
| } | |
| } | |
| dim = space*2+radius*2; | |
| module container() { | |
| difference() { | |
| box(); | |
| translate([0, 0, -dim/4*3]) cube(dim, center= true); | |
| } | |
| } | |
| module lid() { | |
| difference() { | |
| box(); | |
| translate([0, 0, -dim/4]) cube(dim, center= true); | |
| } | |
| } | |
| // | |
| module lid_holed() { | |
| difference() { | |
| lid(); | |
| translate([0, radius/12, 0]) border(); | |
| translate([0, -radius/12, 0]) translate([0, -dim+radius*2+radius/6, 0]) border(); | |
| } | |
| } | |
| module border() { | |
| translate([0, dim/2-radius, radius/2]) cube([dim-radius*2, radius/3, dim-radius*3], center=true); | |
| } | |
| union() { | |
| container(); | |
| border(); | |
| translate([0, -dim+radius*2+radius/6, 0]) border(); | |
| } | |
| translate([space*3.5, 0, 0]) lid_holed(); | |
| // use this to debug your geometry, differences are slow to render | |
| // box(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment