SHARE
TWEET

Untitled

a guest Aug 15th, 2016 259 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. module coilsBase(radius, height, size)
  4. {
  5.     render(1) difference() {
  6.         cylinder(r=radius, h=height, $fn=150);
  7.         cylinder(r=radius-size, h=height, $fn=150);
  8.     }
  9. }
  10.  
  11. module coil(width, botLength, topLength, height, extrudeDeep, extrudeWidth)
  12. {
  13.     //main polyhedron
  14.     points = [
  15.         //bottom side
  16.         [0, 0, 0], //down-left
  17.         [width, 0, 0], //down-right
  18.         [width, botLength, 0], //up-right
  19.         [0, botLength, 0], //up-left
  20.    
  21.         //top side
  22.         [0, 0, height], //down-left
  23.         [width, 0, height], //down-right
  24.         [width, topLength, height], //up-right
  25.         [0, topLength, height] //up-left
  26.     ];
  27.    
  28.     faces = [
  29.         [0, 1, 2, 3], //down face
  30.         [1, 0, 4, 5], //back face
  31.         [0, 3, 7, 4], //left face
  32.         [3, 2, 6, 7], //front face
  33.         [2, 1, 5, 6], //right face
  34.         [5, 4, 7, 6] //top face
  35.     ];
  36.    
  37.     //extrude cubes
  38.     frontFaceLenght = sqrt(pow(height,2) + pow(botLength-topLength,2));
  39.     extBackBox = [width-(2*extrudeWidth), extrudeDeep, height];
  40.     extTopBox = [width-(2*extrudeWidth), topLength-extrudeDeep, extrudeDeep];
  41.     extFrontBox = [width-(2*extrudeWidth), frontFaceLenght, extrudeDeep];
  42.     extFrontBoxRotation = atan2(botLength-topLength, height)+90;
  43.     extBotBox = [width-(2*extrudeWidth), botLength-extrudeDeep, extrudeDeep];
  44.    
  45.     render(1) difference() {
  46.         polyhedron(points, faces, 10);
  47.         union() {
  48.             translate([extrudeWidth, 0, 0])
  49.              cube(extBackBox);
  50.             translate([extrudeWidth, extrudeDeep, height-extrudeDeep])
  51.              cube(extTopBox);
  52.             translate([extrudeWidth, botLength, 0])
  53.              rotate(extFrontBoxRotation, [1,0,0])
  54.               cube(extFrontBox);
  55.             translate([extrudeWidth, extrudeDeep, 0])
  56.              cube(extBotBox);
  57.             }
  58.        
  59.     }
  60. }
  61.  
  62. color("Silver") coilsBase(radius=10, height=2, size=3);
  63.  
  64. color("Gold") translate([0, 0, 15]) coil(width=3, botLength=5, topLength=4, height=3, extrudeDeep=0.5, extrudeWidth=0.5);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top