/ src / box_extrude.scad
box_extrude.scad
 1  /**
 2  * box_extrude.scad
 3  *
 4  * @copyright Justin Lin, 2017
 5  * @license https://opensource.org/licenses/lgpl-3.0.html
 6  *
 7  * @see https://openhome.cc/eGossip/OpenSCAD/lib3x-box_extrude.html
 8  *
 9  **/
10  
11  module box_extrude(height, shell_thickness,
12                     bottom_thickness,
13                     offset_mode = "delta", chamfer = false, convexity = 3,
14                     twist, slices, scale) {
15  
16      btm_thickness = is_undef(bottom_thickness) ? shell_thickness : bottom_thickness;
17  
18      intersection() {
19          linear_extrude(btm_thickness)
20              square(65536, center = true); // 65536: just a large enough size to cover the children
21                      
22          linear_extrude(height, convexity = convexity, twist = twist, slices = slices, scale = scale) 
23              children();
24      }
25  
26      linear_extrude(height, convexity = convexity, twist = twist, slices = slices, scale = scale) 
27          difference() {
28              children();
29              if(offset_mode == "delta") {
30                  offset(delta = -shell_thickness, chamfer = chamfer) 
31                      children(); 
32              } else {
33                  offset(r = -shell_thickness) 
34                      children(); 
35              } 
36          }    
37  }