Advertisement
lilo_booter

OpenJSCAD PLA Lubricator

Jul 15th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 3D Printer PLA Lubricator
  2.  
  3. // Copyright (C) 2013 Charles Yates
  4. // Released under the LGPL.
  5.  
  6. // Provides a small box to hold a cut sponge which should be lubricated with WD40.
  7. // PLA can be threaded through the filament holes. Additional WD40 can be squirted
  8. // through the grills provided on the lid. Customisation options provided.
  9.  
  10. function base( p )
  11. {
  12.     return difference(
  13.         cube( { size: [ p.w + 2 * p.s, p.b + 2 * p.s, p.h + p.s ] } ),
  14.         cube( { size: [ p.w, p.b, p.h ] } ).translate( p.s, p.s, p.s ),
  15.         cylinder( { r: p.r, h: p.b + 2 * p.s } ).rotateX( -90 ).translate( [ p.s + p.w / 2, 0, p.s + p.h / 2 ] )
  16.     );
  17. }
  18.  
  19. function top( p )
  20. {
  21.     var top = union(
  22.         cube( { size: [ p.w + 2 * p.s, p.b + 2 * p.s, p.s ] } ),
  23.         difference(
  24.             cube( { size: [ p.w, p.b, p.s ] } ).translate( [ p.s, p.s, p.s ] ),
  25.             cube( { size: [ p.w - 2 * p.s, p.b - 2 * p.s, p.s ] } ).translate( [ p.s * 2, p.s * 2, p.s ] )
  26.         )
  27.     );
  28.    
  29.     var grill = [ ];
  30.  
  31.     function position( p, i ) { return i * p.g + p.s * 2 + 2 * ( i + 1 ); }
  32.  
  33.     for ( var i = 0; position( p, i ) + p.g < p.b; i ++ )
  34.         grill.push( cube( { size: [ p.w - p.s * 2 - 2, p.g, p.s ] } ).translate( [ p.s * 2 + 1, position( p, i ), 0 ] ) );
  35.  
  36.     return difference(
  37.         top,
  38.         union( grill )
  39.     );
  40. }
  41.  
  42. function getParameterDefinitions()
  43. {
  44.     return [
  45.         { name: 'w', type: 'float', initial: 24, caption: "Width:" },
  46.         { name: 'b', type: 'float', initial: 50, caption: "Breadth:" },
  47.         { name: 'h', type: 'float', initial: 12, caption: "Height:" },
  48.         { name: 's', type: 'float', initial: 1.5, caption: "Support:" },
  49.         { name: 'r', type: 'float', initial: 1.8, caption: "Radius:" },
  50.         { name: 'g', type: 'float', initial: 3, caption: "Grill:" }
  51.     ];
  52. }
  53.  
  54. function main( p )
  55. {
  56.     return union(
  57.         base( p ),
  58.         top( p ).translate( [ - p.w - 5 * p.s, 0, 0 ] )
  59.     );
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement