Lisp lệnh MCS trong chủ đề “Tổng hợp LISP và nhờ các cao thủ CHỈNH SỬA”
Trong khi chờ mình tim cái mặt cắt dọc dầm bạn dùng thừ cái Mặt cắt sàn này nhé.;VE MAT CAT SAN (defun c:Mcs (/ A1 A2 A3 A4 A5 A6 A7 AA AA1 AM4 B2 B3 B4 B5 B6 B66 B67 B7 BB BB11 BB12 BX BX1 C1 C2 C3 C4 C5 C6 CC CL1 DD1 DDAM DDT DY DY1 G1 G10 G11 G12 G2 G7 G8 G9 GG7 GG8 J1 J10 J11 J12 J13 J14 J2 J3 J4 J5 J6 J7 J8 J9 JJ1 JJ2 K12 K19 KC KC1 LX LX1 LXY1 LY LY1 MM MM1 MM2 N10 N11 N12 N13 N14 N15 N16 N17 N18 N19 N7 N8 N9 NBC OD OU OV P1 P10 P67 P9 Q1 Q2 Q3 TDD TDD1 TIEP TONG TT1 TTR1 TTR2 TTR3 U1 U2 U3 V1 XG YG) (taolayer) (SETQ NBC (GETVAR "CLAYER")) (setvar "osmode" 1) (setq tiep "C") (setq tong 0) (setq ddam 350) (setq dy1 (getreal (strcat "Chieu cao dam < " (itoa ddam) " >: "))) (if (null dy1) (setq dy1 ddam)) (setq ou 20) (setq od 100) (setq ov 200) (initget 6) (setq kc1 (getreal (strcat "\nkhoang bao ve (mm) <" (itoa ou) ">: "))) (if (null kc1) (setq kc1 ou)) (setq dy (* dy1 5)) (setq kc (* kc1 4)) (while (= tiep "C") (setvar "cmdecho" 0) (setvar "osmode" 15359) (setq BB (getpoint "Diem chen :")) (setvar "osmode" 0) (setq xg (car BB)) (setq yg (cadr BB)) (initget 6) (setq Ly1 (getreal (strcat "\nChieu day ban (mm) <" (itoa od) ">: "))) (if (null Ly1) (setq Ly1 od)) (setq Lxy1 (getreal "Chieu dai nhip(m) :")) (setq Lx1 (* Lxy1 1000)) (setq Bx1 (getreal "Chieu dai thep am (mm):")) (setq tdd1 (getreal (strcat "\nKhoang cach cac thanh thep (mm) <" (itoa ov) ">: "))) (if (null tdd1) (setq tdd1 ov)) (SETQ TTR1 200) (setq TTR2 (RTOS TTR1 2 0)) (setq Tt1 (RTOS TDD1 2 0)) (setq dd1 (STRCAT "a"TT1"")) (setq ddT (STRCAT "a"TTR2"")) (setq Lx (* Lx1 4)) (setq tong (+ tong Lx)) (setq Ly (* Ly1 5)) (setq Bx (* Bx1 4)) (setq tdd (* tdd1 4)) (setq TTR3 (* TTR1 4)) (setq B2 (list xg (+ yg Ly))) (setq B3 (list xg (+ (- yg dy) Ly))) (setq B4 (polar B3 0 880)) (setq B5 (polar BB 0 880)) (setq B6 (polar BB 0 Lx)) (setq B66 (polar B6 (* Pi 1.5) (- dy Ly))) (setq B67 (polar B66 0 440)) (setq B7 (polar B2 0 (+ Lx 440))) (setq p1 (/ Bx TTR3)) (setq g1 (fix p1)) (setq g2 (- g1 1)) (setq v1 (/ (- Lx 880) tdd)) (setq u1 (fix v1)) (setq u2 (+ u1 1)) (setq u3 (- (/ (- Lx (* u1 tdd)) 2) 440)) (setq A1 (list (+ xg 440) (+ yg kc))) (setq A2 (list (+ xg 440) (- (cadr B2) kc))) (setq A3 (polar A2 0 Bx)) (setq A4 (polar A1 0 Bx)) (setq Am4 (polar A4 (* Pi 1.5) kc)) (setq A5 (list (- (car A3) 50) (- (cadr A3) 50))) (setq J5 A5) (setq A7 (list (+ (+ (car A1) 440) u3) (+ (cadr A1) 50))) (setq N7 (polar A7 0 tdd)) (setq N8 (polar N7 0 tdd)) (setq N9 (list (+ (car N7) (* 0.5 tdd)) (- (cadr n7) (+ 900 (* 1.5 KC))))) (setq N10 (polar N9 0 900)) (setq N11 (polar N10 0 250)) (setq N12 (list (+ (car N9) 450) (+ (cadr N9) 220))) (setq K12 (polar N12 (* Pi 1.5) 440)) (setq N13 (list (+ (car a7) (* tdd 6.5)) (cadr a1))) (setq N14 (polar N13 (* Pi 1.25) kc)) (setq N15 (polar N13 (* Pi 0.25) kc)) (setq N16 (polar N13 (* Pi 1.5) (+ 900 kc))) (setq N17 (polar N16 0 900)) (setq N18 (polar N17 0 250)) (setq N19 (list (+ (car N16) 450) (+ (cadr N16) 220))) (setq K19 (polar N19 (* Pi 1.5) 440)) (command "osmode" 0 "") (setvar "CLAYER" "8") (command ".line" N7 N9 N8 "") (command ".line" N10 N9 "") (command ".line" N14 N15 "") (command ".line" N13 N16 N17 "") (setvar "CLAYER" "3") (command ".text" "mc" N12 "250" "0" "/G10" "") (command ".text" "mc" N19 "250" "0" "/g10" "") (command ".text" "mc" K12 "250" "0" DD1 "") (command ".text" "mc" K19 "250" "0" DD1 "") (setq A6 (polar A1 0 Lx)) (setq AA1 (polar A3 (* 1.5 Pi) Ly)) (setq AA (polar A2 (* 0.5 Pi) 1500)) (setq C1 (polar B3 0 440)) (setq C3 (polar C1 0 Lx)) (setq C5 (polar C1 (* 1.5 Pi) 800)) (setq C2 (polar C5 0 (/ Lx 2))) (setq C6 (polar C5 (* 1.5 Pi) 100)) (setq C4 (polar C6 (* 1.5 Pi) 350)) (setq CC (polar C2 (* 0.5 Pi) 250)) (command "osmode" 0 "") (setvar "CLAYER" "3") (command "donut" "0" kc A5 A7"") (repeat g2 (setq A5 (polar A5 Pi TTR3)) (command "donut" "0" kc A5 "") ) (setq mm (ssget "W" A2 AA1)) (setq J6 (polar J5 Pi TTR3)) (setq J4 (polar A3 Pi (* TTR3 1.5))) (setq jj1 (polar j4 (* Pi 1.25) kc)) (setq jj2 (polar j4 (* Pi 0.25) kc)) (setvar "CLAYER" "8") (command ".line" JJ1 JJ2 "") (setq J7 (polar J6 0 (* TTR3 0.5))) (setq J8 (polar J7 (* 0.5 Pi) 800)) (setq J3 (polar J4 (* 0.5 Pi) 800)) (setq J2 (polar J3 Pi 900)) (setq J9 (polar J8 0 900)) (setq J10 (polar J9 0 250)) (setq J1 (polar J2 Pi 250)) (command ".line" J5 J8 J6 "") (command ".line" J8 J9 "") (command ".line" J4 J3 J2 "") (command ".circle" J1 "d" 500) (setq cl1 (entlast)) (setq J11 (list (+ (car J2) 450) (+ (cadr J2) 220))) (setq J12 (polar J11 (* Pi 1.5) 440)) (setq J13 (list (+ (car J8) 450) (+ (cadr J8) 220))) (setq J14 (polar J13 (* Pi 1.5) 440)) (setvar "CLAYER" "3") (command ".text" "mc" J11 "250" "0" "/G10" "") (command ".text" "mc" J13 "250" "0" "%%c6" "") (command ".text" "mc" J12 "250" "0" DDT "") (command ".text" "mc" J14 "250" "0" "a200" "") (command "-ATTDEF" "" "+" "1" "1" "j" "mc" J1 "250" "") (if (= (tblsearch "block" "ghithep") nil) (command "block" "ghithep" J1 (entlast) cl1 "") ) (if (/= (tblsearch "block" "ghithep") nil) (command "block" "ghithep" "y" J1 (entlast) cl1 "") ) (repeat u1 (setq A7 (polar A7 0 tdd)) (command "donut" "0" kc A7 "") ) (setvar "CLAYER" "7") (command ".line" BB B3 B4 B5 B6 "") (command ".line" B2 B7 "") (command ".line" B6 B66 B67 "") (command ".line" C5 C6 "") (setvar "CLAYER" "4") (command ".pline" A2 A3 Am4 "") (setq mm1 (ssget "L")) (command ".line" A1 A6 "") (setvar "CLAYER" "100") (command ".DIMLINEAR" C1 C3 C2) (setq BB11 (polar BB (* 1 Pi) 500)) (setq BB12 (polar BB11 (* 1 Pi) 700)) (setvar "CLAYER" "20") (command ".DIMLINEAR" BB B2 BB11) (command ".DIMLINEAR" B3 B2 BB12) (setvar "CLAYER" "100") (command ".DIMLINEAR" A2 A3 AA) (setq mm2 (ssget "L")) (chenblock N11 1 1) (chenblock N18 1 1) (chenblock J1 "1" "1") (chenblock J10 "1" "1") (chenblock C4 "1.4" "1.4") (command ".select" mm mm1 mm2 "") (command ".mirror" "p" "" C2 CC "") (initget 1 "C K") (setq tiep (strcase (getkword "Lam tiep cau kien khac :"))) ) (setq g7 (polar B67 (* Pi 0) 440)) (setq g8 (polar g7 (* Pi 0.5) dy)) (setq g9 (polar g8 (* Pi 1) 440)) (setq g10 (polar g9 (* Pi 1.5) kc)) (setq j10 (polar g9 (* Pi 1.5) (- Ly kc))) (setq g11 (polar g10 (* Pi 0) 360)) (setq g12 (polar g11 (* Pi 1.5) (- Ly kc))) (setq p67 (polar b67 (* 1.5 Pi) 800)) (setq p9 (polar p67 (* 1.5 Pi) 100)) (setq p10 (polar p9 (* 1.5 Pi) 350)) (setq j11 (polar j10 0 300)) (setq j12 (polar j11 (* 0.5 Pi) 100)) (setq j13 (polar j12 Pi 90)) (chenblock p10 "1.4" "1.4") (setvar "CLAYER" "4") (command "pline" j13 j12 "a" "a" -180 j11 "l" j10 "") (setq Q1 (ssget "L")) (command "pline" g10 g11 g12 "") (setq Q2 (ssget "L")) (setvar "CLAYER" "7") (command ".line" B67 g7 "") (command ".line" g8 g9 "") (command ".line" g8 g7 "") (setq gG7 (polar G7 Pi (/ (+ tong 880) 2))) (setq gG8 (polar G8 Pi (/ (+ tong 880) 2))) (setq Q3 (ssget "L")) (command ".line" p9 p67 "") (command ".select" Q1 Q2 Q3 "") (command ".mirror" "p" "" GG7 GG8 "") (setvar "osmode" 691) (SETVAR "CLAYER" NBC) ) (defun taolayer () (if (= (tblsearch "layer" "3") nil) (command "layer" "n" "3" "")) (if (= (tblsearch "layer" "4") nil) (command "layer" "n" "4" "")) (if (= (tblsearch "layer" "7") nil) (command "layer" "n" "7" "")) (if (= (tblsearch "layer" "8") nil) (command "layer" "n" "8" "")) (if (= (tblsearch "layer" "20") nil) (command "layer" "n" "20" "")) (if (= (tblsearch "layer" "100") nil) (command "layer" "n" "100" "")) ) (defun chenblock ( dcb x y /) (command "-insert" "ghithep" dcb x y "" "") )
Bạn có thể chỉ giùm mình đoạn nào trong code này để vẽ ký hiệu trục là vòng tròn lớn trong lisp này không?Cảm ơn bạn trước.
Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.
Cách dùng
- Chép mã nguồn, lưu thành tệp 119001_mcs.lsp.
- Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
- Gõ lệnh MCS để chạy lisp.
Mã nguồn 119001_mcs.lsp (trích từ bài viết gốc)
;VE MAT CAT SAN
(defun c:Mcs (/ A1 A2 A3 A4 A5 A6 A7 AA AA1 AM4 B2 B3 B4 B5 B6 B66 B67 B7 BB
BB11 BB12 BX BX1 C1 C2 C3 C4 C5 C6 CC CL1 DD1 DDAM DDT DY DY1 G1
G10 G11 G12 G2 G7 G8 G9 GG7 GG8 J1 J10 J11 J12 J13 J14 J2 J3 J4
J5 J6 J7 J8 J9 JJ1 JJ2 K12 K19 KC KC1 LX LX1 LXY1 LY LY1 MM MM1
MM2 N10 N11 N12 N13 N14 N15 N16 N17 N18 N19 N7 N8 N9 NBC OD OU OV
P1 P10 P67 P9 Q1 Q2 Q3 TDD TDD1 TIEP TONG TT1 TTR1 TTR2 TTR3 U1 U2 U3 V1 XG YG)
(taolayer)
(SETQ NBC (GETVAR "CLAYER"))
(setvar "osmode" 1)
(setq tiep "C")
(setq tong 0)
(setq ddam 350)
(setq dy1 (getreal (strcat "Chieu cao dam < " (itoa ddam) " >: ")))
(if (null dy1) (setq dy1 ddam))
(setq ou 20)
(setq od 100)
(setq ov 200)
(initget 6)
(setq kc1 (getreal (strcat "\nkhoang bao ve (mm) <" (itoa ou) ">: ")))
(if (null kc1) (setq kc1 ou))
(setq dy (* dy1 5))
(setq kc (* kc1 4))
(while (= tiep "C")
(setvar "cmdecho" 0)
(setvar "osmode" 15359)
(setq BB (getpoint "Diem chen :"))
(setvar "osmode" 0)
(setq xg (car BB))
(setq yg (cadr BB))
(initget 6)
(setq Ly1 (getreal (strcat "\nChieu day ban (mm) <" (itoa od) ">: ")))
(if (null Ly1) (setq Ly1 od))
(setq Lxy1 (getreal "Chieu dai nhip(m) :"))
(setq Lx1 (* Lxy1 1000))
(setq Bx1 (getreal "Chieu dai thep am (mm):"))
(setq tdd1 (getreal (strcat "\nKhoang cach cac thanh thep (mm) <" (itoa ov) ">: ")))
(if (null tdd1) (setq tdd1 ov))
(SETQ TTR1 200)
(setq TTR2 (RTOS TTR1 2 0))
(setq Tt1 (RTOS TDD1 2 0))
(setq dd1 (STRCAT "a"TT1""))
(setq ddT (STRCAT "a"TTR2""))
(setq Lx (* Lx1 4))
(setq tong (+ tong Lx))
(setq Ly (* Ly1 5))
(setq Bx (* Bx1 4))
(setq tdd (* tdd1 4))
(setq TTR3 (* TTR1 4))
(setq B2 (list xg (+ yg Ly)))
(setq B3 (list xg (+ (- yg dy) Ly)))
(setq B4 (polar B3 0 880))
(setq B5 (polar BB 0 880))
(setq B6 (polar BB 0 Lx))
(setq B66 (polar B6 (* Pi 1.5) (- dy Ly)))
(setq B67 (polar B66 0 440))
(setq B7 (polar B2 0 (+ Lx 440)))
(setq p1 (/ Bx TTR3))
(setq g1 (fix p1))
(setq g2 (- g1 1))
(setq v1 (/ (- Lx 880) tdd))
(setq u1 (fix v1))
(setq u2 (+ u1 1))
(setq u3 (- (/ (- Lx (* u1 tdd)) 2) 440))
(setq A1 (list (+ xg 440) (+ yg kc)))
(setq A2 (list (+ xg 440) (- (cadr B2) kc)))
(setq A3 (polar A2 0 Bx))
(setq A4 (polar A1 0 Bx))
(setq Am4 (polar A4 (* Pi 1.5) kc))
(setq A5 (list (- (car A3) 50) (- (cadr A3) 50)))
(setq J5 A5)
(setq A7 (list (+ (+ (car A1) 440) u3) (+ (cadr A1) 50)))
(setq N7 (polar A7 0 tdd))
(setq N8 (polar N7 0 tdd))
(setq N9 (list (+ (car N7) (* 0.5 tdd)) (- (cadr n7) (+ 900 (* 1.5 KC)))))
(setq N10 (polar N9 0 900))
(setq N11 (polar N10 0 250))
(setq N12 (list (+ (car N9) 450) (+ (cadr N9) 220)))
(setq K12 (polar N12 (* Pi 1.5) 440))
(setq N13 (list (+ (car a7) (* tdd 6.5)) (cadr a1)))
(setq N14 (polar N13 (* Pi 1.25) kc))
(setq N15 (polar N13 (* Pi 0.25) kc))
(setq N16 (polar N13 (* Pi 1.5) (+ 900 kc)))
(setq N17 (polar N16 0 900))
(setq N18 (polar N17 0 250))
(setq N19 (list (+ (car N16) 450) (+ (cadr N16) 220)))
(setq K19 (polar N19 (* Pi 1.5) 440))
(command "osmode" 0 "")
(setvar "CLAYER" "8")
(command ".line" N7 N9 N8 "")
(command ".line" N10 N9 "")
(command ".line" N14 N15 "")
(command ".line" N13 N16 N17 "")
(setvar "CLAYER" "3")
(command ".text" "mc" N12 "250" "0" "/G10" "")
(command ".text" "mc" N19 "250" "0" "/g10" "")
(command ".text" "mc" K12 "250" "0" DD1 "")
(command ".text" "mc" K19 "250" "0" DD1 "")
(setq A6 (polar A1 0 Lx))
(setq AA1 (polar A3 (* 1.5 Pi) Ly))
(setq AA (polar A2 (* 0.5 Pi) 1500))
(setq C1 (polar B3 0 440))
(setq C3 (polar C1 0 Lx))
(setq C5 (polar C1 (* 1.5 Pi) 800))
(setq C2 (polar C5 0 (/ Lx 2)))
(setq C6 (polar C5 (* 1.5 Pi) 100))
(setq C4 (polar C6 (* 1.5 Pi) 350))
(setq CC (polar C2 (* 0.5 Pi) 250))
(command "osmode" 0 "")
(setvar "CLAYER" "3")
(command "donut" "0" kc A5 A7"")
(repeat g2
(setq A5 (polar A5 Pi TTR3))
(command "donut" "0" kc A5 "")
)
(setq mm (ssget "W" A2 AA1))
(setq J6 (polar J5 Pi TTR3))
(setq J4 (polar A3 Pi (* TTR3 1.5)))
(setq jj1 (polar j4 (* Pi 1.25) kc))
(setq jj2 (polar j4 (* Pi 0.25) kc))
(setvar "CLAYER" "8")
(command ".line" JJ1 JJ2 "")
(setq J7 (polar J6 0 (* TTR3 0.5)))
(setq J8 (polar J7 (* 0.5 Pi) 800))
(setq J3 (polar J4 (* 0.5 Pi) 800))
(setq J2 (polar J3 Pi 900))
(setq J9 (polar J8 0 900))
(setq J10 (polar J9 0 250))
(setq J1 (polar J2 Pi 250))
(command ".line" J5 J8 J6 "")
(command ".line" J8 J9 "")
(command ".line" J4 J3 J2 "")
(command ".circle" J1 "d" 500)
(setq cl1 (entlast))
(setq J11 (list (+ (car J2) 450) (+ (cadr J2) 220)))
(setq J12 (polar J11 (* Pi 1.5) 440))
(setq J13 (list (+ (car J8) 450) (+ (cadr J8) 220)))
(setq J14 (polar J13 (* Pi 1.5) 440))
(setvar "CLAYER" "3")
(command ".text" "mc" J11 "250" "0" "/G10" "")
(command ".text" "mc" J13 "250" "0" "%%c6" "")
(command ".text" "mc" J12 "250" "0" DDT "")
(command ".text" "mc" J14 "250" "0" "a200" "")
(command "-ATTDEF" "" "+" "1" "1" "j" "mc" J1 "250" "")
(if (= (tblsearch "block" "ghithep") nil)
(command "block" "ghithep" J1 (entlast) cl1 "")
)
(if (/= (tblsearch "block" "ghithep") nil)
(command "block" "ghithep" "y" J1 (entlast) cl1 "")
)
(repeat u1
(setq A7 (polar A7 0 tdd))
(command "donut" "0" kc A7 "")
)
(setvar "CLAYER" "7")
(command ".line" BB B3 B4 B5 B6 "")
(command ".line" B2 B7 "")
(command ".line" B6 B66 B67 "")
(command ".line" C5 C6 "")
(setvar "CLAYER" "4")
(command ".pline" A2 A3 Am4 "")
(setq mm1 (ssget "L"))
(command ".line" A1 A6 "")
(setvar "CLAYER" "100")
(command ".DIMLINEAR" C1 C3 C2)
(setq BB11 (polar BB (* 1 Pi) 500))
(setq BB12 (polar BB11 (* 1 Pi) 700))
(setvar "CLAYER" "20")
(command ".DIMLINEAR" BB B2 BB11)
(command ".DIMLINEAR" B3 B2 BB12)
(setvar "CLAYER" "100")
(command ".DIMLINEAR" A2 A3 AA)
(setq mm2 (ssget "L"))
(chenblock N11 1 1)
(chenblock N18 1 1)
(chenblock J1 "1" "1")
(chenblock J10 "1" "1")
(chenblock C4 "1.4" "1.4")
(command ".select" mm mm1 mm2 "")
(command ".mirror" "p" "" C2 CC "")
(initget 1 "C K")
(setq tiep (strcase (getkword "Lam tiep cau kien khac [1©/2(K)] :")))
)
(setq g7 (polar B67 (* Pi 0) 440))
(setq g8 (polar g7 (* Pi 0.5) dy))
(setq g9 (polar g8 (* Pi 1) 440))
(setq g10 (polar g9 (* Pi 1.5) kc))
(setq j10 (polar g9 (* Pi 1.5) (- Ly kc)))
(setq g11 (polar g10 (* Pi 0) 360))
(setq g12 (polar g11 (* Pi 1.5) (- Ly kc)))
(setq p67 (polar b67 (* 1.5 Pi) 800))
(setq p9 (polar p67 (* 1.5 Pi) 100))
(setq p10 (polar p9 (* 1.5 Pi) 350))
(setq j11 (polar j10 0 300))
(setq j12 (polar j11 (* 0.5 Pi) 100))
(setq j13 (polar j12 Pi 90))
(chenblock p10 "1.4" "1.4")
(setvar "CLAYER" "4")
(command "pline" j13 j12 "a" "a" -180 j11 "l" j10 "")
(setq Q1 (ssget "L"))
(command "pline" g10 g11 g12 "")
(setq Q2 (ssget "L"))
(setvar "CLAYER" "7")
(command ".line" B67 g7 "")
(command ".line" g8 g9 "")
(command ".line" g8 g7 "")
(setq gG7 (polar G7 Pi (/ (+ tong 880) 2)))
(setq gG8 (polar G8 Pi (/ (+ tong 880) 2)))
(setq Q3 (ssget "L"))
(command ".line" p9 p67 "")
(command ".select" Q1 Q2 Q3 "")
(command ".mirror" "p" "" GG7 GG8 "")
(setvar "osmode" 691)
(SETVAR "CLAYER" NBC)
)
(defun taolayer ()
(if (= (tblsearch "layer" "3") nil) (command "layer" "n" "3" ""))
(if (= (tblsearch "layer" "4") nil) (command "layer" "n" "4" ""))
(if (= (tblsearch "layer" "7") nil) (command "layer" "n" "7" ""))
(if (= (tblsearch "layer" "8") nil) (command "layer" "n" "8" ""))
(if (= (tblsearch "layer" "20") nil) (command "layer" "n" "20" ""))
(if (= (tblsearch "layer" "100") nil) (command "layer" "n" "100" ""))
)
(defun chenblock ( dcb x y /)
(command "-insert" "ghithep" dcb x y "" "")
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Tổng hợp LISP và nhờ các cao thủ CHỈNH SỬA. Xem đúng bài viết #119001 để đọc hướng dẫn và trao đổi thêm.