LẬP CHƯƠNG TRÌNH TỰ ĐỘNG VẼ BÁNH RĂNG CÔN (NÓN); đại học bách khoa

20 705 0
LẬP CHƯƠNG TRÌNH TỰ ĐỘNG VẼ BÁNH RĂNG CÔN (NÓN); đại học bách khoa

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

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 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 (initget 6) (setq re (getreal "\n Nhap Re( : " ) ) (if (null re) (setq re 130) ) (initget 6) (setq goc1 (getreal "\n Nhap goc nghieng xichma1( : " ) ) (if (null goc1) (setq goc1 14.04) ) (initget 6) (setq bw (getreal "\n Nhap be rong rang bw( : " ) ) (if (null bw) (setq bw 40) ) (initget 6) (setq dtbr2 (getreal "\n Nhap duong kinh truc lap banh rang truc 2( : " ) ) (if (null dtbr2) (setq dtbr2 35) ) (initget 6) (setq dtbr1 (getreal "\n Nhap duong kinh truc lap banh rang truc 1( : " ) ) (if (null dtbr1) (setq dtbr1 21) ) (initget 6) (setq hae2 (getreal "\n Nhap hae2( : " ) ) (if (null hae2) (setq hae2 1.55) ) (initget 6) (setq hfe2 (getreal "\n Nhap hfe2( : " ) ) (if (null hfe2) (setq hfe2 3.95) ) (initget 6) (setq kieu (getreal "\n Nhap kieu may o (bt-1.nguoc-2 : " ) ) (if (null kieu) (setq kieu 2) ) (initget 6) (setq hae1 (getreal "\n Nhap hae1( : " ) ) (if (null hae1) (setq hae1 3.45) ) (initget 6) (setq hfe1 (getreal "\n Nhap hfe1( : " ) ) (if (null hfe1) (setq hfe1 2.05) ) (initget 6) (setq k1 (getreal "\n Nhap khoang cach chi tiet quay toi vo hop k1( : " ) ) (if (null k1) (setq k1 10) ) (initget 6) (setq k2 (getreal "\n Nhap khoang cach o lan toi vo hop k2( : " ) ) (if (null k2) (setq k2 10) ) (initget 6) (setq day (getreal "\n Nhap chieu day ( : " ) ) (if (null day) (setq day 8) ) ;; nhap danh sach thong so o dua (setq lsto '( (7202 15 35 27.9 25.8 11 11.75 10.75 0.5) (7203 17 40 31.6 27.8 12 11 13.25 11.83 0.5) (7204 20 47 37 32.5 14 12 15.25 13.5 0.5) (7205 25 52 41.6 38 15 13 16.25 13.5 2.5 0.5) (7206 30 62 50 45.6 16 14 17.25 13.67 0.7) (7207 35 72 58.5 52.7 17 15 18.25 13.83 1) (7208 40 80 65.2 59.3 18 16 19.75 14.33 1.2) (7209 45 85 69.7 64.8 19 16 20.75 15.33 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 1) (7212 60 110 92 83 22 19 23.75 13.17 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 0) (7508 40 80 64.2 58.5 23 19 24.75 14.25 0) (7509 45 85 68.9 65.4 23 19 24.75 15.5 0) (7510 50 90 73.7 71 23 19 24.75 15.67 0) (7511 55 100 82.8 75.4 25 21 26.75 13.5 0) (7512 60 110 90 85 28 24 29.75 14.67 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 1) (7306 30 72 56.8 50.6 19 17 20.75 13.5 1.5) (7307 35 80 63.8 56.3 21 18 22.75 12.0 1.5) (7308 40 90 73 62.5 23 20 25.25 10.5 1.5) (7309 45 100 81 70.5 25 22 27.25 10.83 1.5) (7310 50 110 89 76.5 27 23 29.25 11.67 2) (7311 55 120 97 84 29 25 31.5 12.5 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 0) (7607 35 80 62.8 56.5 33 27 32.75 11.17 0) (7608 40 90 71 64 33 28.5 35.25 11.17 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 truc ( : " ) ) (if (null kihieu) (setq kihieu 7306) ) (initget 6) (setq kihieu1 (getreal "\n Nhap ki hieu o dua truc ( : " ) ) (if (null kihieu1) (setq kihieu1 7305) ) (setq clay (getvar "clayer")) (command "-layer" "m" "chodaika.dam" "c" "" "lt" "continuous" "" "") (command "-layer" "m" "chodaika.dut" "c" "" "lt" "hiddenx2" "" "") (command "-layer" "m" "chodk.tam" "c" "" "lt" "center" "" "") (command "-layer" "m" "chodk.manh" "c" "" "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 (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 (* (fix (/ (* 1.3 dtbr2) 5)))))) (if (= kieu 1) (setq xb233 (inters xb22 (polar xb22 g0 3) x01a (polar x01a g90 3) NIL) xb232 (polar xb233 g270 (* (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 (setq ssbr2 (ssadd)) (command "-layer" "m" ;tao ss rong de tao mat cat sau "_mss.dam" "c" "" "lt" "continuous" "" "") (command ".pline" xb24 xb25 xb26 "") (command ".fillet" "r" "") (command ".fillet" "p" "l") (ssadd (entlast) ssbr2) (command ".pline" xb26 xb27 xb28 xb29 xb23 xb24 "") (ssadd (entlast) ssbr2) (command ".pline" xb231 xb232 (polar xb232 g90 3) "") (command ".chamfer" "d" "") ;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" "") (command ".fillet" "p" "l") (ssadd (entlast) ssbr2) (command ".pline" xb237 xb238 "") (ssadd (entlast) ssbr2) (command ".pline" xb238 xb239 xb231 "") (command ".fillet" "r" "") (command ".fillet" "p" "l") (ssadd (entlast) ssbr2) (setq ssbr22 (ss-mirror ssbr2 x00 x01 1)) (command "-layer" "m" "chodk.manh" "c" "" "lt" "continuous" "" "") (command "-hatch" "s" ssbr2 ssbr22 "" "p" "ansi31" 20 "" "") (setq ssbr23 (ssadd)) (command "-layer" "m" "chodaika.dam" "c" "" "lt" "continuous" "" "") (command ".pline" xb242 xb29 "") (ssadd (entlast) ssbr23) (command ".pline" xb23 xb21 "") (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" "" "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" "" "lt" "hiddenx2" "" "") (command ".pline" xb21 xb22 "") (setq ssbr24 (ssadd)) (command "-layer" "m" "chodaika.dam" "c" "" "lt" "continuous" "" "") (command ".pline" xb21 xb22 "") (ssadd (entlast) ssbr24) (command ".mirror" ssbr24 "" x00 x01 "") (command ".ERASE" ssbr24 "") ;xoa doi tuong ; gan diem banh rang (setq xb11 (polar xb20 (angle xb20 xb23) hae1) xb14 (polar xb20 (angle xb20 xb21) hfe1) xb12 (inters xb11 x00 xb22 xb24 NIL) xb13 (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 (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" "" "lt" "continuous" "" "") (command "-hatch" "s" ssbr1 ssbr12 "" "p" "ansi31" 20 90 "" "") (command "-layer" "m" "_mss.dam" "c" "" "lt" "continuous" "" "") (command ".pline" xb14 xb11 xb12 xb13 "") (command ".mirror" "l" "" x00 x02 "") ; ve o dua truc (setq o_lst (assoc kihieu lsto)) (setq dto (nth o_lst) dno (nth o_lst) d1o (nth o_lst) d2o (nth o_lst) bo (nth o_lst) co (nth o_lst) to (nth o_lst) anfa (nth o_lst) rr2 (nth o_lst) bu2 (nth 10 o_lst) ) (setq ho (* 0.5 (- dno dto))) ;;gan cac diem o dua truc (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)))) o11 (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 (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)) (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 ) "") (command ".chamfer" "d" 1.5 "") (command ".chamfer" "p" "l") (ssadd (entlast) sso2_1) (command ".pline" (polar o1 g270 ) o17 o18 "") (command ".chamfer" "d" "") (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" "" "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 "" "") (command "-layer" "m" "_mss.tam" "c" "" "lt" "center" "" "") (command ".pline" (polar o14 (angle o11 o14) 5) (polar o11 (angle o14 o11) 5) "") (command ".mirror" "l" "" x00 x01 "") (command ".mirror" "l" "" x00 x02 "") (command ".mirror" "l" "" x00 x01 "") ;ve o dua truc (setq o_lst1 (assoc kihieu1 lsto)) (setq dto1 (nth o_lst1) dno1 (nth o_lst1) d1o1 (nth o_lst1) d2o1 (nth o_lst1) bo1 (nth o_lst1) co1 (nth o_lst1) to1 (nth o_lst1) anfa1 (nth o_lst1) rr1 (nth o_lst1) bu1 (nth 10 o_lst1) ) (setq ho1 (* 0.5 (- dno1 dto1))) (setq xbr1 (polar xb16 g90 (* dtbr1 0.5)) oo20 (polar xbr1 g180 (+ (+ k1 ) to1)) oo1 (polar oo20 g270 (* 0.5 dto1)) oo2 (polar oo1 g270 (* 0.5 (- d2o1 dto1))) oo3 (polar oo1 g270 ho1) oo5 (polar oo3 g0 to1) oo4 (polar oo5 g180 co1) oo6 (polar oo5 g90 (* 0.5 (- dno1 d1o1))) oo6b (polar oo6 (+ pi (* (/ anfa1 180) pi)) 3) oo4b (polar oo4 g90 3) oo7 (inters oo4 oo4b oo6 oo6b NIL) oo5b (polar oo5 g90 (* 0.5 ho1)) oo8 (polar oo5b g180 (* 0.4 to1)) oo8b (polar oo8 (+ (* (/ anfa1 180) pi) (* 1.5 pi)) 3) oo9 (inters oo6 oo7 oo8 oo8b NIL) oo10 (polar oo9 (angle oo6 oo7) (sqrt (- (+ (expt (* 0.25 ho1) 2) (expt (* 0.34 ho1) 2)) (expt (distance oo8 oo9) 2)))) oo11 (polar oo10 (- 0.93678 (- pi (angle oo8 oo10))) (* 0.25 ho1)) oo12 (polar oo10 (angle oo10 oo11) (* 0.5 ho1)) oo14 (polar oo11 (angle oo11 oo8) (- (* 0.68 ho1) bu1)) ; thay doi dua oo14b(polar oo14 (angle oo10 oo11) 3) oo15 (inters oo6 oo7 oo14 oo14b NIL) oo13 (polar oo14 (angle oo10 oo11) (distance oo14 oo15)) oo17 (polar oo1 g0 bo1) oo19 (polar oo14 (angle oo10 oo11) (* 0.666 (distance oo14 oo15))) oo19b(polar oo19 g180 3) oo17b(polar oo17 g90 3) oo18 (inters oo19 oo19b oo17 oo17b NIL) oo2b (polar oo2 g180 3) oo16 (inters oo2 oo2b oo10 oo12 NIL) oo7b (inters oo4 oo7 oo2 oo16 NIL) x03 (polar oo20 g180 (- (* 1.25 dto1) (* 0.5 bo1))) x03a (polar x03 g90 3) ) (setq sso1 (ssadd)) (command "-layer" "m" "chodaika.dam" "c" "" "lt" "continuous" "" "") (command ".pline" oo4 oo5 oo6 "") (command ".fillet" "r" rr1 "") (command ".fillet" "p" "l") (ssadd (entlast) sso1) (command ".pline" oo6 oo7 oo4 "") (ssadd (entlast) sso1) (command ".pline" oo10 oo12 oo13 oo15 oo10 "") (command ".mirror" "l" "" x00 x02 "") (command ".mirror" "l" "" x03 x03a "") (command ".mirror" "l" "" x00 x02 "") (setq sso1_2 (ss-mirror sso1 x00 x02 1)) (setq sso1_3 (ss-mirror sso1 x03 x03a 1)) (setq sso1_4 (ss-mirror sso1_2 x03 x03a 1)) (setq sso1_1 (ssadd)) (command ".pline" oo2 oo1 (polar oo1 g0 ) "") (command ".chamfer" "d" 1.5 "") (command ".chamfer" "p" "l") (ssadd (entlast) sso1_1) (command ".pline" (polar oo1 g0 ) oo17 oo18 "") (command ".chamfer" "d" "") (command ".chamfer" "p" "l") (ssadd (entlast) sso1_1) (command ".pline" oo2 oo16 oo12 oo13 oo19 oo18 "") (ssadd (entlast) sso1_1) (setq sso1_1_2 (ss-mirror sso1_1 x00 x02 1)) (setq sso1_1_3 (ss-mirror sso1_1_2 x03 x03a 1)) (setq sso1_1_4 (ss-mirror sso1_1 x03 x03a 1)) (command ".pline" oo7 oo7b "") (command ".mirror" "l" "" x00 x02 "") (command ".mirror" "l" "" x03 x03a "") (command ".mirror" "l" "" x00 x02 "") (command "-layer" "m" "chodk.manh" "c" "" "lt" "continuous" "" "") (command "-hatch" "s" sso1 sso1_2 sso1_3 sso1_4 "" "p" "ansi31" 15 90 "" "") (command "-hatch" "s" sso1_1 sso1_1_2 sso1_1_3 sso1_1_4 "" "p" "ansi31" 15 "" "") (command "-layer" "m" "chodk.tam" "c" "" "lt" "center" "" "") (command ".pline" (polar oo14 (angle oo11 oo14) 5) (polar oo11 (angle oo14 oo11) 5) "") (command ".mirror" "l" "" x00 x02 "") (command ".mirror" "l" "" x03 x03a "") (command ".mirror" "l" "" x00 x02 "") ; ve coc lot (command "-layer" "m" "chodk.manh" "c" "" "lt" "continuous" "" "") (command "_style" "" "TIMES NEW ROMAN" "0" "1" "0" "n" "n") (command ".text" "M" (polar x00 g90 15) "DESIGNE BY CHODAIKA (moi chep xin ghi ro nguon chodk.tk)" ) ; -(command ".ERASE" ssxoa "") ) ;; ; ; (defun ss-mirror (ss p1 p2 flag / ss1 num ind) (if (null ss) (setq ss1 NIL) (progn (if (= flag 0) (progn (command "._mirror" ss "" p1 p2 "y") (setq ss1 ss) ) (progn (setq ss1 (ssadd)) (setq num (sslength ss)) (setq ind 0) (while (< ind num) (setq ent (ssname ss ind)) (command "._mirror" ent "" p1 p2 "n") (ssadd (entlast) ss1) (setq ind (1+ ind)) ) ) ) ) ) ;while ;progn ;if flag ;progn ) ;if ss not null ss1 ;ket qua tra ve

Ngày đăng: 06/10/2016, 21:04

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan