Translate generator to module

This commit is contained in:
maride 2017-11-22 21:57:25 +01:00
parent a1df26afeb
commit 39057113bc

View File

@ -1,23 +1,34 @@
INNER_X=60;
INNER_Y=60;
INNER_Z=30;
WALLSIZE=4;
OVERLAP_Z=WALLSIZE;
/*
* hello.scad! :)
* It is possible to use this generator in two ways:
* - Simply, generate boxes (see [1])
* - Include this file to generate boxes in other SCAD files (see [2])
*
* [1] Generate boxes
* Uncomment one of the three following lines: */
// generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE);
// generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE, OVERLAP_Z);
// generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE, OVERLAP_Z, [NOTCH_WIDTH, NOTCH_DEPTH]);
// Small example for a box width inner size 60x60x30, wall size 4, wall-sized overlap and a small notch:
generate_box(60, 60, 30, 4, 4, 5, 2);
/*
* [2] Include & Generate
* Copy and paste this line to another file: */
// use Box_Type2_Generator.scad;
/* Some explanations to the parameters:
* === OVERLAP_Z ===
* The size of the inner overlap size
* Set OVERLAP_Z to 0 to deactivate the overlap area at all.
* In most cases, it should be enough to set it to WALLSIZE.
*/
NOTCH_WIDTH=5;
NOTCH_DEPTH=2;
/*
*
* === NOTCH_DEPTH ===
* NOTCH_DEPTH < WALLSIZE for obvious reasons.
* Set NOTCH_DEPTH to 0 to deactivate the notch at all.
* Idea behind the notch: you can secure the box lid with e.g. a rubber band
*/
module generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE, OVERLAP_Z, NOTCH_WIDTH, NOTCH_DEPTH) {
difference() {
union() {
// The main box
@ -43,3 +54,4 @@ difference() {
cube([NOTCH_WIDTH, NOTCH_DEPTH, INNER_Z+WALLSIZE*6]);
}
}
}