CHƯƠNG TRÌNH TỰ ĐỘNG VẼ BÁNH RĂNG CÔN (NÓN)
(defun c:chodaika ()
(setq osmode (getvar "osmode"))
(setvar "osmode" 0)
(setq color (getvar "cecolor"))
(setq g0 0
g45 (/ pi 4)
g135 (* 0.75 pi)
g315 (* pi 1.75)
g90 (/ pi 2)
g180 pi
g225 (* 1.25 pi)
g270 (* pi 1.5)
g360 (* pi 2)
)
;; nhap danh sach thong so banh rang con
(initget 6)
(setq re (getreal
"\n Nhap Re( <130>: "
)
)
(if (null re)
(setq re 130)
)
(initget 6)
(setq goc1 (getreal
"\n Nhap goc nghieng con xichma1( <14.04>: "
Trang 2)
)
(if (null goc1)
(setq goc1 14.04)
)
(initget 6)
(setq bw (getreal
"\n Nhap be rong rang bw( <40>: "
)
)
(if (null bw)
(setq bw 40)
)
(initget 6)
(setq dtbr2 (getreal
"\n Nhap duong kinh truc lap banh rang con truc 2( <35>: " )
)
(if (null dtbr2)
(setq dtbr2 35)
)
(initget 6)
(setq dtbr1 (getreal
"\n Nhap duong kinh truc lap banh rang con truc 1( <21>: " )
)
(if (null dtbr1)
Trang 3(setq dtbr1 21)
)
(initget 6)
(setq hae2 (getreal
"\n Nhap hae2( <1.55>: "
)
)
(if (null hae2)
(setq hae2 1.55)
)
(initget 6)
(setq hfe2 (getreal
"\n Nhap hfe2( <3.95>: "
)
)
(if (null hfe2)
(setq hfe2 3.95)
)
(initget 6)
(setq kieu (getreal
"\n Nhap kieu may o (bt-1.nguoc-2 <2>: " )
)
(if (null kieu)
Trang 4(setq kieu 2)
)
(initget 6)
(setq hae1 (getreal
"\n Nhap hae1( <3.45>: "
)
)
(if (null hae1)
(setq hae1 3.45)
)
(initget 6)
(setq hfe1 (getreal
"\n Nhap hfe1( <2.05>: "
)
)
(if (null hfe1)
(setq hfe1 2.05)
)
(initget 6)
(setq k1 (getreal
"\n Nhap khoang cach chi tiet quay toi thanh trong vo hop k1( <10>: "
)
)
Trang 5(if (null k1)
(setq k1 10)
)
(initget 6)
(setq k2 (getreal
"\n Nhap khoang cach o lan toi thanh trong vo hop k2( <10>: "
)
)
(if (null k2)
(setq k2 10)
)
(initget 6)
(setq day (getreal
"\n Nhap chieu day thanh ( <8>: "
)
)
(if (null day)
(setq day 8)
)
;; nhap danh sach thong so o dua con
(setq lsto
'(
(7202 15 35 27.9 25.8 11 9 11.75 10.75 2 0.5)
(7203 17 40 31.6 27.8 12 11 13.25 11.83 2 0.5)
(7204 20 47 37 32.5 14 12 15.25 13.5 2 0.5)
(7205 25 52 41.6 38 15 13 16.25 13.5 2.5 0.5)
Trang 6(7206 30 62 50 45.6 16 14 17.25 13.67 3 0.7) (7207 35 72 58.5 52.7 17 15 18.25 13.83 3 1) (7208 40 80 65.2 59.3 18 16 19.75 14.33 3 1.2) (7209 45 85 69.7 64.8 19 16 20.75 15.33 3 1) (7210 50 90 75 68.4 20 17 21.75 14.0 3.0 1) (7211 55 100 83 76.4 21 18 22.75 15.33 3 1) (7212 60 110 92 83 22 19 23.75 13.17 3 1.5) (7506 30 62 49.2 45.6 20 17 21.25 13.57 2.5 0) (7507 35 72 57.5 52.5 23 20 24.25 13.0 3 0) (7508 40 80 64.2 58.5 23 19 24.75 14.25 3 0) (7509 45 85 68.9 65.4 23 19 24.75 15.5 3 0) (7510 50 90 73.7 71 23 19 24.75 15.67 3 0) (7511 55 100 82.8 75.4 25 21 26.75 13.5 3 0) (7512 60 110 90 85 28 24 29.75 14.67 3 0)
(7304 20 52 40.6 35.4 15 13 16.25 11.17 2.5 1) (7305 25 62 48.5 43.5 17 15 18.25 13.5 3 1) (7306 30 72 56.8 50.6 19 17 20.75 13.5 3 1.5) (7307 35 80 63.8 56.3 21 18 22.75 12.0 3 1.5) (7308 40 90 73 62.5 23 20 25.25 10.5 3 1.5) (7309 45 100 81 70.5 25 22 27.25 10.83 3 1.5) (7310 50 110 89 76.5 27 23 29.25 11.67 3 2) (7311 55 120 97 84 29 25 31.5 12.5 3 2)
(7312 60 130 106 94 31 27 33.5 11.5 3.5 2) (7604 20 52 40.1 35.8 21 18.5 22.25 11.25 2.5 0) (7605 25 62 48 42 24 21 25.25 11.33 2.5 0) (7606 30 72 55.5 50 27 23 28.75 12.0 3 0)
(7607 35 80 62.8 56.5 33 27 32.75 11.17 3 0)
Trang 7(7608 40 90 71 64 33 28.5 35.25 11.17 3 0)
(7609 45 100 79 70.3 36 31 38.25 11.0 3.5 0)
(7610 50 110 87 78 40 34 42.25 11.17 3.5 0)
(7611 55 120 94.5 87 43 35 45.5 12.17 3.5 0)
(7612 60 130 103.5 93.5 46 37 48.5 11.5 3.5 0)
)
)
(initget 6)
(setq kihieu (getreal
"\n Nhap ki hieu o dua con truc 2 ( <7306>: "
)
)
(if (null kihieu)
(setq kihieu 7306)
)
(initget 6)
(setq kihieu1 (getreal
"\n Nhap ki hieu o dua con truc 1 ( <7305>: "
)
)
(if (null kihieu1)
(setq kihieu1 7305)
)
(setq clay (getvar "clayer"))
(command "-layer" "m" "chodaika.dam" "c" 7 "" "lt" "continuous" "" "") (command "-layer" "m" "chodaika.dut" "c" 3 "" "lt" "hiddenx2" "" "") (command "-layer" "m" "chodk.tam" "c" 3 "" "lt" "center" "" "")
Trang 8(command "-layer" "m" "chodk.manh" "c" 3 "" "lt" "continuous" "" "") (command "-layer" "m" "chodk.text" "c"3 "" "lt" "continuous" "" "") (setvar "clayer" clay)
;;gan cac gia tri cua thep chu u
(if (= kieu 1) (setq k1 5))
(setq goc (* (/ goc1 180) pi))
(setq x00 (getpoint "\n Chon diem bat ky 'designe by chodaika':"))
(setq x01 (polar x00 g270 3)
x02 (polar x00 g180 3))
;;gan cac diem banh rang con 2
(setq xb20 (polar x00 (+ pi goc) re)
xb21 (polar xb20 (+ g90 goc) hae2)
xb200 (polar xb20 (angle xb20 x00) bw)
xb200b (polar xb200 (angle xb20 xb21) 3)
xb22 (inters xb21 x00 xb200 xb200b NIL)
xb23 (polar xb20 (angle xb21 xb20) hfe2)
xb24 (inters xb23 x00 xb200 xb200b NIL)
xb25 (polar xb24 (angle xb22 xb24) 2)
xb29 (polar xb23 (angle xb21 xb20) 8)
x01a (polar x01 g180 (* 0.5 dtbr2))
)
(if (= kieu 2) (setq xb232 (inters xb29 (polar xb29 g0 3) x01a (polar x01a g90 3) NIL)
xb233 (polar xb232 g90 (* 5 (fix (/ (* 1.3 dtbr2) 5))))))
Trang 9(if (= kieu 1) (setq xb233 (inters xb22 (polar xb22 g0 3) x01a (polar x01a g90 3) NIL)
xb232 (polar xb233 g270 (* 5 (fix (/ (* 1.3 dtbr2) 5)))))) (setq
xb231 (polar xb232 g180 (fix (* 0.4 dtbr2)))
xb234 (polar xb233 g180 (fix (* 0.4 dtbr2)))
xb234a (polar xb234 4.660029 3)
xb236 (inters xb234 xb234a xb25 (polar xb25 g0 3) NIL)
xb241 (polar xb236 g180 (* 0.5 (distance xb25 xb236)))
xb237 (polar xb241 g0 10 )
xb26 (polar xb241 g180 10)
xb27 (polar xb26 g270 (fix (* 0.3 bw) ))
xb240 (polar xb241 g270 (fix (* 0.3 bw) ))
xb238 (polar xb237 g270 (fix (* 0.3 bw) ))
xb239 (inters xb27 xb238 xb231 (polar xb231 1.6231562 3) NIL)
xb28 (inters xb27 xb238 xb29 (polar xb29 (angle xb23 xb24) 3) NIL) xb242 (inters xb231 xb239 xb29 (polar xb29 g0 3) NIL)
xb235 (inters xb234 xb236 xb22 (polar xb22 g0 3) NIL)
)
;;; ve banh rang con 2
(setq ssbr2 (ssadd)) ;tao ss rong de tao mat cat sau nay
(command "-layer" "m" "_mss.dam" "c" 7 "" "lt" "continuous" "" "") (command ".pline" xb24 xb25 xb26 "")
(command ".fillet" "r" 2 "")
(command ".fillet" "p" "l")
(ssadd (entlast) ssbr2)
(command ".pline" xb26 xb27 xb28 xb29 xb23 xb24 "")
Trang 10(ssadd (entlast) ssbr2)
(command ".pline" xb231 xb232 (polar xb232 g90 3) "")
(command ".chamfer" "d" 1 "") ;lenh chamfer
(command ".chamfer" "p" "l")
(ssadd (entlast) ssbr2)
(command ".pline" (polar xb232 g90 3) xb233 xb234 "")
(command ".chamfer" "d" 1.5 "") ;lenh chamfer
(command ".chamfer" "p" "l")
(ssadd (entlast) ssbr2)
(command ".pline" xb234 xb236 xb237 "")
(command ".fillet" "r" 3 "")
(command ".fillet" "p" "l")
(ssadd (entlast) ssbr2)
(command ".pline" xb237 xb238 "")
(ssadd (entlast) ssbr2)
(command ".pline" xb238 xb239 xb231 "")
(command ".fillet" "r" 3 "")
(command ".fillet" "p" "l")
(ssadd (entlast) ssbr2)
(setq ssbr22 (ss-mirror ssbr2 x00 x01 1))
(command "-layer" "m" "chodk.manh" "c" 3 "" "lt" "continuous" "" "") (command "-hatch" "s" ssbr2 ssbr22 "" "p" "ansi31" 20 0 "" "")
(setq ssbr23 (ssadd))
(command "-layer" "m" "chodaika.dam" "c" 7 "" "lt" "continuous" "" "") (command ".pline" xb242 xb29 "")
(ssadd (entlast) ssbr23)
(command ".pline" xb23 xb21 "")
Trang 11(ssadd (entlast) ssbr23)
(command ".pline" xb24 xb22 xb235 "")
(ssadd (entlast) ssbr23)
(command ".pline" xb26 xb237 "")
(ssadd (entlast) ssbr23)
(command ".pline" xb27 xb238 "")
(ssadd (entlast) ssbr23)
(command "-layer" "m" "chodk.tam" "c" 3 "" "lt" "center" "" "")
(command ".pline" xb20 x00 "")
(ssadd (entlast) ssbr23)
(command ".mirror" "l" "" x00 x02 "")
(command ".pline" (polar xb241 g90 5) (polar xb240 g270 5) "")
(ssadd (entlast) ssbr23)
(command ".mirror" ssbr23 "" x00 x01 "")
(command "-layer" "m" "chodaika.dut" "c" 3 "" "lt" "hiddenx2" "" "") (command ".pline" xb21 xb22 "")
(setq ssbr24 (ssadd))
(command "-layer" "m" "chodaika.dam" "c" 7 "" "lt" "continuous" "" "") (command ".pline" xb21 xb22 "")
(ssadd (entlast) ssbr24)
(command ".mirror" ssbr24 "" x00 x01 "")
(command ".ERASE" ssbr24 "") ;xoa doi tuong
; gan diem banh rang con 1
(setq
xb11 (polar xb20 (angle xb20 xb23) hae1)
xb14 (polar xb20 (angle xb20 xb21) hfe1)
xb12 (inters xb11 x00 xb22 xb24 NIL)
Trang 12xb13 (inters xb14 x00 xb22 xb24 NIL)
x02a (polar x02 g270 (* dtbr1 0.5))
x02b (polar x02a g0 3)
x02c (polar x02a g270 10)
xb15 (inters x02a x02b xb13 (polar xb13 g90 3) NIL)
xb17 (inters xb11 xb14 x02c (polar x02c g0 3) NIL)
xb16 (inters x02a x02b xb17 (polar xb17 g90 3) NIL)
)
;ve banh rang 1
(setq ssbr1 (ssadd))
(command ".pline" xb17 xb16 xb15 "")
(command ".chamfer" "d" 1.5 "") ;lenh chamfer
(command ".chamfer" "p" "l")
(ssadd (entlast) ssbr1)
(command ".pline" xb15 xb13 xb14 xb17 "")
(ssadd (entlast) ssbr1)
(setq ssbr12 (ss-mirror ssbr1 x00 x02 1))
(command "-layer" "m" "_mss.manh" "c" 3 "" "lt" "continuous" "" "") (command "-hatch" "s" ssbr1 ssbr12 "" "p" "ansi31" 20 90 "" "")
(command "-layer" "m" "_mss.dam" "c" 7 "" "lt" "continuous" "" "") (command ".pline" xb14 xb11 xb12 xb13 "")
(command ".mirror" "l" "" x00 x02 "")
; ve o dua con truc 2
(setq o_lst (assoc kihieu lsto))
(setq dto (nth 1 o_lst)
dno (nth 2 o_lst)
d1o (nth 3 o_lst)
Trang 13d2o (nth 4 o_lst)
bo (nth 5 o_lst)
co (nth 6 o_lst)
to (nth 7 o_lst)
anfa (nth 8 o_lst)
rr2 (nth 9 o_lst)
bu2 (nth 10 o_lst)
)
(setq ho (* 0.5 (- dno dto)))
;;gan cac diem o dua con truc 2
(setq xbr2 (polar xb232 g0 (* dtbr2 0.5))
o20 (polar xbr2 g270 (+ k1 k2))
o1 (polar o20 g180 (* 0.5 dto))
o2 (polar o1 g180 (* 0.5 (- d2o dto)))
o3 (polar o1 g180 ho)
o5 (polar o3 g270 to)
o4 (polar o5 g90 co)
o6 (polar o5 g0 (* 0.5 (- dno d1o)))
o6b (polar o6 (+ (* 0.5 pi) (* (/ anfa 180) pi)) 3)
o4b (polar o4 g0 3)
o7 (inters o4 o4b o6 o6b NIL)
o5b (polar o5 g0 (* 0.5 ho))
o8 (polar o5b g90 (* 0.4 to))
o8b (polar o8 (+ (* (/ anfa 180) pi) pi) 3)
o9 (inters o6 o7 o8 o8b NIL)
o10 (polar o9 (angle o6 o7) (sqrt (- (+ (expt (* 0.25 ho) 2) (expt (* 0.34 ho) 2)) (expt (distance o8 o9) 2))))
Trang 14o11 (polar o10 (- 0.93678 (- pi (angle o8 o10))) (* 0.25 ho))
o12 (polar o10 (angle o10 o11) (* 0.5 ho))
o14 (polar o11 (+ pi (angle o8 o11)) (- (* 0.68 ho) bu2)) ; thay doi dua o14b(polar o14 (+ pi (angle o10 o11)) 3)
o15 (inters o6 o7 o14 o14b NIL)
o13 (polar o14 (angle o10 o11) (distance o14 o15))
o17 (polar o1 g270 bo)
o19 (polar o14 (angle o10 o11) (* 0.666 (distance o14 o15)))
o19b(polar o19 g90 3)
o17b(polar o17 g0 3)
o18 (inters o19 o19b o17 o17b NIL)
o2b (polar o2 g90 3)
o16 (inters o2 o2b o10 o12 NIL)
o7b (inters o4 o7 o2 o16 NIL)
)
(setq sso2 (ssadd)) ;tao ss rong de tao mat cat sau nay (command ".pline" o4 o5 o6 "")
(command ".fillet" "r" rr2 "")
(command ".fillet" "p" "l")
(ssadd (entlast) sso2)
(command ".pline" o6 o7 o4 "")
(ssadd (entlast) sso2)
(command ".pline" o10 o12 o13 o15 o10 "")
(command ".mirror" "l" "" x00 x01 "")
(command ".mirror" "l" "" x00 x02 "")
(command ".mirror" "l" "" x00 x01 "")
(setq sso2_2 (ss-mirror sso2 x00 x01 1))
Trang 15(setq sso2_3 (ss-mirror sso2 x00 x02 1))
(setq sso2_4 (ss-mirror sso2_2 x00 x02 1))
(setq sso2_1 (ssadd))
(command ".pline" o2 o1 (polar o1 g270 5 ) "")
(command ".chamfer" "d" 1.5 "")
(command ".chamfer" "p" "l")
(ssadd (entlast) sso2_1)
(command ".pline" (polar o1 g270 5 ) o17 o18 "")
(command ".chamfer" "d" 1 "")
(command ".chamfer" "p" "l")
(ssadd (entlast) sso2_1)
(command ".pline" o2 o16 o12 o13 o19 o18 "")
(ssadd (entlast) sso2_1)
(setq sso2_1_2 (ss-mirror sso2_1 x00 x01 1))
(setq sso2_1_3 (ss-mirror sso2_1_2 x00 x02 1))
(setq sso2_1_4 (ss-mirror sso2_1 x00 x02 1))
(command ".pline" o7 o7b "")
(command ".mirror" "l" "" x00 x01 "")
(command ".mirror" "l" "" x00 x02 "")
(command ".mirror" "l" "" x00 x01 "")
(command "-layer" "m" "chodk.manh" "c" 3 "" "lt" "continuous" "" "") (command "-hatch" "s" sso2 sso2_2 sso2_3 sso2_4 "" "p" "ansi31" 15 90 "" "") (command "-hatch" "s" sso2_1 sso2_1_2 sso2_1_3 sso2_1_4 "" "p" "ansi31" 15 0
"" "")
(command "-layer" "m" "_mss.tam" "c" 3 "" "lt" "center" "" "")
(command ".pline" (polar o14 (angle o11 o14) 5) (polar o11 (angle o14 o11) 5)
"")