Guest User

Untitled

a guest
Apr 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. import FreeCAD, Part, math
  2. from FreeCAD import Base
  3. from __future__ import division # allows floating point division from integers
  4. import sys
  5. import os
  6.  
  7. try:
  8. path = os.path.dirname(__file__)
  9. i = sys.path.index(path)
  10. except:
  11. sys.path.append(path)
  12.  
  13.  
  14. #all measurements are in mm until unit conversion is added
  15.  
  16. #extrusion_profile 20mm, 25mm, 1"
  17. extrusion_profile = 20
  18.  
  19. #how tall is the gap between the two bottom frame rectangles?
  20. frame_rectangle_spacing = 30
  21.  
  22. #size_type ["extrusion length", "build area", "bounding box"]
  23. size_type = "extrusion length"
  24.  
  25. extrusion_x_length = 300
  26. extrusion_y_length = 420
  27. extrusion_diagonal_length = 340
  28.  
  29. #build_x_length, build_y_width, build_z_height (build area)
  30. #outside_x_length, outside_y_width, outsize_z_height (bounding box)
  31.  
  32. #x_rail_type ["makerslide", "smooth rod"]
  33. x_rail_type = "smooth rod"
  34. x_rod_diameter = 8
  35. x_rod_spacing = 50
  36. #x_rod_orientation ["horizontal","vertical"]
  37. x_rod_orientation = "horizontal"
  38.  
  39. #y_rail_type ["makerslide", "smooth rod"]
  40. y_rail_type = "smooth rod"
  41. y_rod_diameter = 8
  42. y_rod_spacing = 100
  43.  
  44. #z_rail_type ["makerslide", "smooth rod"]
  45. z_rail_type = "smooth rod"
  46. z_rod_diameter = 8
  47. z_screw_diameter = 8
  48. #distance from z smooth rod to z threaded rod
  49. z_rod_spacing = 30
  50.  
  51. #["NEMA14", "NEMA17", "NEMA23"]
  52. #TODO: implement motor module for dimensions, etc
  53. x_motor_size = "NEMA17"
  54. y_motor_size = "NEMA17"
  55. z_motor_size = "NEMA17"
  56.  
  57. x_pulley_teeth_count = 36
  58. x_pulley_teeth_spacing = 2
  59. x_pulley_pitch_diameter = 72/math.pi
  60. y_pulley_teeth_count = 36
  61. y_pulley_teeth_spacing = 2
  62. y_pulley_pitch_diameter = 72/math.pi
  63.  
  64. #should we limit parts to 100mmx100mm build area?
  65. small_printer = True
  66.  
  67. #bushing_type ["printed","IGUS [part#]"LM8UU",etc]
  68. #y_carriage_height, y_carriage_width, y_carriage_depth
  69. #x_bearing_type, y_bearing_type ["608ZZ"]
  70. #build_platform_height, build_platform_width, build_platform_depth
  71.  
  72. #absolute minimum thickness of any printed part, this is usually a constraint of the printing method to be used
  73. thick_min = 1
  74. #minimum vertical (the layered direction) thickness of any printed part
  75. thick_min_vertical = 2
  76. #minimum thickness of a part under compression, such as the edge of bolt holes
  77. thick_compress = 3
  78. #typical thickness of printed parts, for flat plates and such
  79. thick_typical = 4.25
  80.  
  81. #TODO: better system for organizing these
  82. hole_spacing_narrow = 10
  83. hole_spacing_medium = 20
  84. hole_spacing_wide = 30
  85.  
  86. import partsrc.LowerVertexMiddle
  87. Part.show(partsrc.LowerVertexMiddle.LowerVertexMiddle())
  88.  
  89. ---------- partsrc/__init__.py
  90. (empty file)
  91.  
  92. ---------- partsrc/LowerVertexMiddle.py
  93. from __future__ import division # allows floating point division from integers
  94.  
  95.  
  96. from FreeCAD import Part
  97.  
  98.  
  99. import math
  100.  
  101. def LowerVertexMiddle(
  102. extrusion_profile = 20,
  103. frame_rectangle_spacing = 30,
  104. thick_typical = 4.25
  105. ):
  106.  
  107. #how big are the structural bolts?
  108. #TODO: replace with use of bolt module after it's written
  109. bolt_hole_diameter = 5.5
  110. bolt_head_diameter = 10
  111.  
  112. #should there be a visible hole for easy access to the "hidden" bolt?
  113. accessible_hole = 1
  114. #should we draw the extrusions for visualization purposes?
  115. render_extrusions = 0
  116.  
  117. #connect the two X extrusions
  118. box = Part.makeBox(frame_rectangle_spacing+extrusion_profile*2,thick_typical,extrusion_profile)
  119. box.translate(Base.Vector(0,-thick_typical,0))
  120. vertex = box
  121. cylinder = Part.makeCylinder(bolt_hole_diameter/2,thick_typical)
  122. cylinder.rotate(Base.Vector(0,0,0),Base.Vector(1,0,0),90)
  123. cylinder.translate(Base.Vector(extrusion_profile/2,0,extrusion_profile/2))
  124. vertex = vertex.cut(cylinder)
  125. cylinder.translate(Base.Vector(frame_rectangle_spacing+extrusion_profile,0,0))
  126. vertex = vertex.cut(cylinder)
  127.  
  128. #mount to the top of the top Y extrusion
  129. box = Part.makeBox(thick_typical,40+extrusion_profile,extrusion_profile)
  130. box.translate(Base.Vector(-thick_typical,-thick_typical,0))
  131. vertex = vertex.fuse(box)
  132. cylinder = Part.makeCylinder(bolt_hole_diameter/2,thick_typical)
  133. cylinder.rotate(Base.Vector(0,0,0),Base.Vector(0,1,0),-90)
  134. cylinder.translate(Base.Vector(0,40+extrusion_profile/2-thick_typical,extrusion_profile/2))
  135. vertex = vertex.cut(cylinder)
  136.  
  137. #mount to the top of the diagonal extrusion
  138. #TODO: cleaner calculation of length of this part to avoid trimming
  139. box = Part.makeBox(extrusion_profile+40,thick_typical,extrusion_profile)
  140. box.translate(Base.Vector(-extrusion_profile-15,-thick_typical,0))
  141. #fill the space below the diagonal extrusion
  142. box2 = Part.makeBox(extrusion_profile+5,extrusion_profile,extrusion_profile)
  143. box2.translate(Base.Vector(-15,0,0))
  144. box = box.fuse(box2)
  145. cylinder = Part.makeCylinder(bolt_hole_diameter/2,thick_typical)
  146. cylinder.rotate(Base.Vector(0,0,0),Base.Vector(1,0,0),90)
  147. cylinder.translate(Base.Vector(-15-extrusion_profile/2,0,extrusion_profile/2))
  148. box = box.cut(cylinder)
  149. box.rotate(Base.Vector(0,extrusion_profile,0),Base.Vector(0,0,1),-30)
  150. vertex = vertex.fuse(box)
  151.  
  152. if(accessible_hole):
  153. cylinder = Part.makeCylinder(bolt_hole_diameter/2,extrusion_profile+60)
  154. else:
  155. cylinder = Part.makeCylinder(bolt_hole_diameter/2,extrusion_profile+5)
  156. cylinder2 = Part.makeCylinder(bolt_head_diameter/2,extrusion_profile+5-thick_typical)
  157. cylinder2.translate(Base.Vector(0,0,thick_typical))
  158. cylinder = cylinder.fuse(cylinder2)
  159. cylinder.rotate(Base.Vector(0,0,0),Base.Vector(0,1,0),90)
  160. cylinder.translate(Base.Vector(-15,0,0))
  161. cylinder.translate(Base.Vector(0,extrusion_profile/2,extrusion_profile/2))
  162. cylinder.rotate(Base.Vector(0,extrusion_profile,0),Base.Vector(0,0,1),-30)
  163. vertex = vertex.cut(cylinder)
  164.  
  165. box = Part.makeBox(extrusion_profile,extrusion_profile,extrusion_profile)
  166. vertex = vertex.cut(box)
  167. #TODO: eliminate this trim by cleaning above
  168. box = Part.makeBox(40,10,extrusion_profile)
  169. box.translate(Base.Vector(-thick_typical-5,-10-thick_typical,0))
  170. vertex = vertex.cut(box)
  171.  
  172. return vertex
  173.  
  174. if __name__ == "__main__":
  175. Part.show(LowerVertexMiddle())
Add Comment
Please, Sign In to add comment