BarsAndTubes.scad 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. $fn=50;
  2. // Bars
  3. //// Rectangular Bars: width=x-axis; height=y-axis; lenght=z-axis
  4. module rectangularBar(width, height, length)
  5. {
  6. cube( [width,height,length] );
  7. }
  8. //// Square Bars: lenght=z-axis
  9. module squareBar(height, length)
  10. {
  11. cube( [height,height,length] );
  12. }
  13. //// Round Bars: lenght=z-axis
  14. module roundBar(diameter, length)
  15. {
  16. cylinder(h=length,d=diameter,center=false);
  17. }
  18. //// Hexagonal Bars: lenght=z-axis ; Attention: width is measured along the flats = inner Diameter !
  19. module hexBar(width, length)
  20. { // see: https://en.wikipedia.org/wiki/Hexagon
  21. // d = (sqrt(3)/2) * D
  22. // => D = d / (sqrt(3)/2) and R = D/2
  23. // where d=innerDiameter=width and D=outerDiameter and r = innerRadius and R = outerRadius
  24. //outerDiameter = width / (sqrt(3.0)/2.0);
  25. // or:
  26. // R = r / cos(30°)
  27. // or:
  28. // R = r / (sqrt(3.0)/2.0)
  29. // outerRadius1 = (width/(sqrt(3.0)/2.0)) / 2.0;
  30. // outerRadius2 = (width/2)/cos(30.0);
  31. // outerRadius3 = (width/2)/(sqrt(3.0)/2.0);
  32. // echo(width=width);
  33. // echo(outerRadius1=outerRadius1);
  34. // echo(outerRadius2=outerRadius2);
  35. // echo(outerRadius3=outerRadius3);
  36. linear_extrude(height=length)
  37. {
  38. outerRadius = (width/2)/cos(30.0);
  39. circle(r=outerRadius,$fn=6);
  40. }
  41. }
  42. // Tubes
  43. //// Rectangular Tube: width=x-axis; height=y-axis; lenght=z-axis
  44. module rectangularTube(width, height, length, wall)
  45. {
  46. difference()
  47. {
  48. cube( [width,height,length] );
  49. translate([wall,wall,-2])
  50. cube( [width-2*wall,height-2*wall,length+4] );
  51. }
  52. }
  53. //// Square Tubes: lenght=z-axis
  54. module squareTube(height, length, wall)
  55. {
  56. difference()
  57. {
  58. cube( [height,height,length] );
  59. translate([wall,wall,-2])
  60. cube( [height-2*wall,height-2*wall,length+4] );
  61. }
  62. }
  63. //// Round Tubes: lenght=z-axis
  64. module roundTube(diameter, length, wall)
  65. {
  66. difference()
  67. {
  68. cylinder(h=length,d=diameter,center=false);
  69. translate([0,0,-2])
  70. cylinder(h=length+4,d=diameter-2*wall,center=false);
  71. }
  72. }
  73. // Angle Irons
  74. module angleIron(width, height, length, wall)
  75. {
  76. union()
  77. {
  78. cube( [width, wall,length] );
  79. translate( [wall,0,0] )
  80. rotate( [0,0,90] )
  81. cube( [height, wall,length] );
  82. }
  83. }
  84. // U-Profile
  85. module uProfile(width, height, length, wall)
  86. {
  87. difference()
  88. {
  89. cube( [width, height, length] );
  90. translate( [wall,wall,-2] )
  91. cube( [width-2*wall, height, length+4] );
  92. }
  93. }
  94. // bars
  95. barWidth=60;
  96. barHeight=40;
  97. barLength=500;
  98. barDiameter=50;
  99. // tubes
  100. tubeWidth=60;
  101. tubeHeight=40;
  102. tubeLength=500;
  103. tubeDiameter=50;
  104. tubeWall=2;
  105. // angle iron
  106. angleWidth=50;
  107. angleHeight=40;
  108. angleLength=500;
  109. angleWall=5;
  110. // u-profiles
  111. uprofileWidth=60;
  112. uprofileHeight=40;
  113. uprofileLength=500;
  114. uprofileWall=4;
  115. color( "LightSkyBlue", 9.0 )
  116. {
  117. translate([600+barWidth/2,barWidth/2,0])
  118. hexBar( barWidth,barLength );
  119. translate([500,0,0])
  120. rectangularBar( barWidth,barHeight,barLength );
  121. translate([400,0,0])
  122. squareBar( barWidth,barLength );
  123. translate([300+barDiameter/2,barDiameter/2,0])
  124. roundBar( barDiameter,barLength );
  125. translate([200,0,0])
  126. rectangularTube( tubeWidth, tubeHeight, tubeLength, tubeWall );
  127. translate([100,0,0])
  128. squareTube( tubeHeight, tubeLength, tubeWall );
  129. translate([barDiameter/2,barDiameter/2,0])
  130. roundTube( tubeDiameter, tubeLength, tubeWall );
  131. translate([-100,0,0])
  132. angleIron( angleWidth, angleHeight, angleLength, angleWall );
  133. translate([-200,0,0])
  134. uProfile( uprofileWidth, uprofileHeight, uprofileLength, uprofileWall );
  135. }