Last active
          June 12, 2020 08:55 
        
      - 
      
- 
        Save marmakoide/31af0219b1cf9040e4ab19e930da4b61 to your computer and use it in GitHub Desktop. 
    Bevel rectangle and boxes for OpenSCAD
  
        
  
    
      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
    
  
  
    
  | module bevel_rectangle(size, bevel) { | |
| s = (size[0] + size[1] - 2 * bevel) / sqrt(2); | |
| intersection() { | |
| square(size, center = true); | |
| rotate(45) | |
| square([s, s], center = true); | |
| } | |
| } | |
| module octahedron() { | |
| X = [1, 0, 0]; | |
| Y = [0, 1, 0]; | |
| Z = [0, 0, 1]; | |
| polyhedron( | |
| points = [X, Y, Z, -X, -Y, -Z], | |
| faces = [ | |
| [1, 0, 2], | |
| [0, 1, 5], | |
| [0, 4, 2], | |
| [4, 0, 5], | |
| [4, 3, 2], | |
| [3, 4, 5], | |
| [3, 1, 2], | |
| [1, 3, 5] | |
| ], | |
| convexity = 2); | |
| } | |
| module bevel_box(size, bevel) { | |
| s = (size[0] + size[1] + size[2]) / 2 - 2 * bevel; | |
| sz = (size[0] + size[1] - 2 * bevel) / sqrt(2); | |
| sx = (size[1] + size[2] - 2 * bevel) / sqrt(2); | |
| sy = (size[2] + size[0] - 2 * bevel) / sqrt(2); | |
| intersection() { | |
| cube(size, center = true); | |
| rotate(45, [0, 0, 1]) | |
| cube([sz, sz, size[2]], center = true); | |
| rotate(45, [1, 0, 0]) | |
| cube([size[0], sx, sx], center = true); | |
| rotate(45, [0, 1, 0]) | |
| cube([sy, size[1], sy], center = true); | |
| scale(s) | |
| octahedron(); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment