drill.tcl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. # Sample: creation of simple twist drill bit
  2. #Category: Modeling
  3. #Title: Drill
  4. pload MODELING VISUALIZATION
  5. # drill parameters (some terms taken from http://www.drill-bits.cn/drill-bits-quality.asp)
  6. dset R 4. ;# outer radius
  7. dset D 2*R ;# diameter
  8. dset Rr 3.5 ;# chisel radius (outer radius minus body clearance)
  9. dset b 1. ;# web thickness (approximate)
  10. dset d b/2
  11. dset H 80. ;# height of the spiral part
  12. dset a 3.*pi ;# total angle of spiral rotation
  13. dset sigma 118 ;# point angle, in degrees
  14. # Create section profile by sequence of Boolean operations
  15. # on simple planar objects
  16. puts "Creating the drill section profile..."
  17. polyline rectangle1 d -R 0 R -R 0 -d R 0 -R R 0 d -R 0
  18. circle circle1 0 0 0 0 0 1 R
  19. mkedge circle1 circle1
  20. wire circle1 circle1
  21. circle circle2 0 0 0 0 0 1 Rr
  22. mkedge circle2 circle2
  23. wire circle2 circle2
  24. plane p0
  25. mkface rectangle1 p0 rectangle1
  26. mkface circle1 p0 circle1
  27. mkface circle2 p0 circle2
  28. bcommon sec rectangle1 circle1
  29. bfuse sec sec circle2
  30. unifysamedom sec sec
  31. # Construct flute profile so as to have cutting lip straight after sharpening.
  32. # Here we need to take into account spiral shift of the flute edge
  33. # along the point length -- the way to do that is to make spiral
  34. # from the desired cutting lip edge and then intersect it by plane
  35. polyline lip d -d/2 0 d -R -R/tan(sigma/2*pi/180)
  36. polyline sp 0 0 0 0 0 H
  37. cylinder cc 0 0 0 0 0 1 0 -4 0 4
  38. line ll 0 0 a 80
  39. trim ll ll 0 sqrt(a*a+H*H)
  40. vertex v1 0 -R 0
  41. vertex v2 0 -R H
  42. trotate v2 0 0 0 0 0 1 180.*a/pi
  43. mkedge ee ll cc v1 v2
  44. wire gg ee
  45. mksweep sp
  46. setsweep -G gg 0 0
  47. addsweep lip
  48. buildsweep spiral -S
  49. mkface f0 p0 -R R -R R
  50. bsection sflute spiral f0
  51. # here we rely on that section curve is parameterized from 0 to 1
  52. # and directed as cutting lip edge;
  53. # note that this can change if intersection algorithm is modified
  54. explode sflute e
  55. mkcurve cflute sflute_1
  56. cvalue cflute 0. x0 y0 z0
  57. cvalue cflute 1. x1 y1 z1
  58. vertex vf0 x0 y0 z0
  59. vertex vf1 x1 y1 z1
  60. # -- variant: replace curve by arc with start at x0,y0,z0 and end at x1,y1,z1,
  61. # -- such that tangent at start point is along Y
  62. #dset Rflute ((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))/(2*(x1-x0))
  63. #circle aflute x0+Rflute y0 0 0 0 1 Rflute
  64. #mkedge sflute_1 aflute vf0 vf1
  65. # make rounding in the flute; use circle with radius Rr/2
  66. circle cround x0+Rr/2 y0 0 0 0 1 Rr/2
  67. vertex vf3 x0+Rr y0 0
  68. mkedge sflute_2 cround vf3 vf0
  69. vertex vf2 R -R 0
  70. edge sflute_3 vf3 vf2
  71. edge sflute_4 vf2 vf1
  72. wire w2 sflute_1 sflute_2 sflute_3 sflute_4
  73. mkface flute p0 w2
  74. # cut flute from profile
  75. bcut sec sec flute
  76. trotate flute 0 0 0 0 0 1 180.
  77. bcut sec sec flute
  78. donly sec
  79. # sweep profile to get a drill body
  80. puts "Sweeping the profile..."
  81. mksweep sp
  82. setsweep -G gg 0 0
  83. explode sec w
  84. addsweep sec_1
  85. buildsweep base -S
  86. # sharpen the drill (see http://tool-land.ru/zatochka-sverla.php)
  87. puts "Sharpening..."
  88. dset theta a*R/H*sin((90-sigma/2)*pi/180)
  89. plane ax1 d 1.9*D "H+1.9*D/tan(pi/180.*sigma/2.)" 0 -1 -1
  90. pcone sh1 ax1 0 100*sin((sigma-90)/2*pi/180.) 100
  91. trotate sh1 0 0 0 0 0 1 -theta*180/pi
  92. tcopy sh1 sh2
  93. trotate sh2 0 0 0 0 0 1 180
  94. box sh -D/2 -D/2 72 D D 20
  95. bcommon qq sh1 sh2
  96. bcut sharpener sh qq
  97. bcut body base sharpener
  98. # make a shank
  99. puts "Making a shank..."
  100. plane pl2 0 0 -40 0 0 1
  101. pcylinder shank pl2 4 40
  102. pcone transit R 0 R
  103. plane pl3 0 0 -40 0 0 -0.5
  104. pcone tail pl3 R 0 0.5
  105. bfuse shank shank tail
  106. bfuse shank shank transit
  107. bfuse drill body shank
  108. # check result
  109. checkshape drill
  110. # show result
  111. puts "Displaying result..."
  112. incmesh drill 0.01
  113. vdisplay drill
  114. vsetdispmode drill 1
  115. vrenderparams -msaa 8
  116. vfit
  117. # show section and sweep path
  118. ttranslate sec_1 0 0 H; trotate sec_1 0 0 0 0 0 1 a*180/pi; incmesh gg 0.01; vdisplay gg sec_1