Lisp lệnh TKTH H%3F trong chủ đề “Viết Lisp theo yêu cầu”
Nhờ các bác viết giúp cái hộp thoại cho cái lệnh này của em, có một số ý muốn như thế này:
-Cố gắng giữ nguyên các câu lệnh của em chỉ sửa những chổ cần thiết
-Dùng thuần lisp giúp em vì em không biết VBA.
-Hình dáng hộp thoại gồm:
+03 imagebutton thể hiện 03 loại thép hình.
+03 nút : Chèn tiêu đề; kẻ bảng; chọn và hủy bỏ.
-Hộp thoại dùng các file: SLD rời đừng gộp chung lại (để em còn phát triển).
-Khi chọn 1 ảnh song bấm enter thì thực thi giống như chọn nút ok.
-Nhớ vị trí ảnh chọn ở lần gọi lệnh sau.
-Mổi ảnh và nút có thể chọn bằng chử ở bàn phím.
-Tạo giúp em cái vòng lặp khi thực hiện xong lệnh sẽ tiếp tục quay lại.
Cảm ơn các bác nhiều.
-Cố gắng giữ nguyên các câu lệnh của em chỉ sửa những chổ cần thiết
-Dùng thuần lisp giúp em vì em không biết VBA.
-Hình dáng hộp thoại gồm:
+03 imagebutton thể hiện 03 loại thép hình.
+03 nút : Chèn tiêu đề; kẻ bảng; chọn và hủy bỏ.
-Hộp thoại dùng các file: SLD rời đừng gộp chung lại (để em còn phát triển).
-Khi chọn 1 ảnh song bấm enter thì thực thi giống như chọn nút ok.
-Nhớ vị trí ảnh chọn ở lần gọi lệnh sau.
-Mổi ảnh và nút có thể chọn bằng chử ở bàn phím.
-Tạo giúp em cái vòng lặp khi thực hiện xong lệnh sẽ tiếp tục quay lại.
Cảm ơn các bác nhiều.
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 3394_tkth_h%3F.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 TKTH H%3F để chạy lisp.
Mã nguồn 3394_tkth_h%3F.lsp (trích từ bài viết gốc)
(Defun C:tkth ( )
(setvar "MODEMACRO" "THONG KE THEP HINH")
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq lc (strcase (getstring "\nCac lua chon :Tieu de/Ke khung/thepVuong/thepL/thepC:")))
(if (= lc "t")
(progn
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "INSERT" "tieudel" (list (+ x 0)(- y 0)) 1 1 0)
(command "-layer" "new" "Cat-20" "color" "20" "cat-20" "")
(command "-layer" "set" "Cat-20" "")
(command "LINE"(list (+ x 0) (- y 1500)) (list (+ x 0) (+ y 0))
(list (+ x 13214) (+ y 0)) (list (+ x 13214) (- y 1500)) "")
(traos)
)
)
(if (= lc "T")
(progn
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "INSERT" "tieudel" (list (+ x 0)(- y 0)) 1 1 0)
(command "-layer" "new" "Cat-20" "color" "20" "cat-20" "")
(command "-layer" "set" "Cat-20" "")
(command "LINE"(list (+ x 0) (- y 1500)) (list (+ x 0) (+ y 0))
(list (+ x 13214) (+ y 0)) (list (+ x 13214) (- y 1500)) "")
(traos)
)
)
(if (= lc "k")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "-layer" "new" "Cat-20" "color" "20" "cat-20" "")
(setq s (getreal "\nSo luong hang: "))
(setq h (* s 600))
(setq z (* s 300))
(command "-layer" "set" "Cat-20" "")
(command "LINE"(list (+ x 0) (- y 0)) (list (+ x 0) (- y h)) "")
(command "LINE"(list (+ x 13214) (- y 0)) (list (+ x 13214) (- y h)) "")
(traos)
(luuos)
(setvar "osmode" 0)
(command "LINE"(list (+ x 2000) (- y 0)) (list (+ x 2000) (- y h)) "")
(command "LINE"(list (+ x 4925) (- y 0)) (list (+ x 4925) (- y h)) "")
(command "LINE"(list (+ x 7261) (- y 0)) (list (+ x 7261) (- y h)) "")
(command "LINE"(list (+ x 8610) (- y 0)) (list (+ x 8610) (- y h)) "")
(command "LINE"(list (+ x 11214) (- y 0)) (list (+ x 11214) (- y h)) "")
(command "LINE"(list (+ x 1200) (- y 0)) (list (+ x 1200) (- y h)) "")
(command "TRIM" "last" "" "f" (list (+ x 1) (- y 1)) (list (+ x 1) (+ (- y h) 1)) "" "")
(command "INSERT" "vitrichuthep" (list (+ x 950)(- y z)) 1 1 90)
(setq w (getstring 5"\nSo luong cau kien : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 950)(- y z)) 250 90 "( CK)")
(command "TEXT" "c" (list (+ x 950)(- y z 250)) 250 90 w)
;(command "INSERT" "vitrichuthep" (list (+ x 500)(- y z)) 1 1 90)
(princ "\nChon mau lop :")
;(setq t (getstring 5"\nTen cau kien : "))
;(command "UNDO" "")
(command "TEXT" "c" (list (+ x 500)(- y z)) 250 90 "TEÂN")
(command "ddedit" "last" "")
(traos)
)
)
(if (= lc "K")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "-layer" "new" "Cat-20" "color" "20" "cat-20" "")
(setq s (getreal "\nSo luong hang: "))
(setq h (* s 600))
(setq z (* s 300))
(command "-layer" "set" "Cat-20" "")
(command "LINE"(list (+ x 0) (- y 0)) (list (+ x 0) (- y h)) "")
(command "LINE"(list (+ x 13214) (- y 0)) (list (+ x 13214) (- y h)) "")
(traos)
(luuos)
(setvar "osmode" 0)
(command "LINE"(list (+ x 2000) (- y 0)) (list (+ x 2000) (- y h)) "")
(command "LINE"(list (+ x 4925) (- y 0)) (list (+ x 4925) (- y h)) "")
(command "LINE"(list (+ x 7261) (- y 0)) (list (+ x 7261) (- y h)) "")
(command "LINE"(list (+ x 8610) (- y 0)) (list (+ x 8610) (- y h)) "")
(command "LINE"(list (+ x 11214) (- y 0)) (list (+ x 11214) (- y h)) "")
(command "LINE"(list (+ x 1200) (- y 0)) (list (+ x 1200) (- y h)) "")
(command "TRIM" "last" "" "f" (list (+ x 1) (- y 1)) (list (+ x 1) (+ (- y h) 1)) "" "")
(command "INSERT" "vitrichuthep" (list (+ x 950)(- y z)) 1 1 90)
(setq w (getstring 5"\nSo luong cau kien : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 950)(- y z)) 250 90 "( CK)")
(command "TEXT" "c" (list (+ x 950)(- y z 250)) 250 90 w)
;(command "INSERT" "vitrichuthep" (list (+ x 500)(- y z)) 1 1 90)
(princ "\nChon mau lop :")
;(setq t (getstring 5"\nTen cau kien : "))
;(command "UNDO" "")
(command "TEXT" "c" (list (+ x 500)(- y z)) 250 90 "TEÂN")
(command "ddedit" "last" "")
(traos)
)
)
(if (= lc "l")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(command "INSERT" "vitrichuthep" (list (+ x 1600)(- y 450)) 1 1 0)
(setq s (getstring 5"\nSo thu tu : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 1600)(- y 450)) 250 0 s )
(command "TEXT" "c" (list (+ x 3446)(- y 450)) 250 0 "L * *")
(command "INSERT" "vitrichuthep" (list (+ x 3082)(- y 450)) 1 1 0)
(setq d (getreal "\nCanh thu nhat : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3082)(- y 450)) 250 0 (fix d))
(command "INSERT" "vitrichuthep" (list (+ x 3791)(- y 450)) 1 1 0)
(setq b (getreal "\nCanh thu hai : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3791)(- y 450)) 250 0 (fix b ))
(command "INSERT" "vitrichuthep" (list (+ x 4404)(- y 450)) 1 1 0)
(setq w (getreal "\nDo day : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 4404)(- y 450)) 250 0 (fix w))
(command "INSERT" "vitrichuthep" (list (+ x 6092)(- y 450)) 1 1 0)
(setq l (getreal "\nChieu dai thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 6092)(- y 450)) 250 0 (fix l))
(command "INSERT" "vitrichuthep" (list (+ x 7935)(- y 450)) 1 1 0)
(setq n (getreal "\nSo luong thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 7935)(- y 450)) 250 0 (fix n))
(setq c (* n l))
(setq m (/ c 1000))
(command "TEXT" "c" (list (+ x 9912)(- y 450)) 250 0 (rtos m 2 2))
(setq r (+ d b ))
(setq k (* w r))
(setq v (* k 786))
(setq j (* v m))
(setq t (/ j 100000))
(command "TEXT" "c" (list (+ x 12214)(- y 450)) 250 0 (rtos t 2 2))
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(traos)
)
)
(if (= lc "L")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(command "INSERT" "vitrichuthep" (list (+ x 1600)(- y 450)) 1 1 0)
(setq s (getstring 5"\nSo thu tu : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 1600)(- y 450)) 250 0 s)
(command "TEXT" "c" (list (+ x 3446)(- y 450)) 250 0 "L * *")
(command "INSERT" "vitrichuthep" (list (+ x 3082)(- y 450)) 1 1 0)
(setq d (getreal "\nCanh thu nhat : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3082)(- y 450)) 250 0 (fix d))
(command "INSERT" "vitrichuthep" (list (+ x 3791)(- y 450)) 1 1 0)
(setq b (getreal "\nCanh thu hai : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3791)(- y 450)) 250 0 (fix b ))
(command "INSERT" "vitrichuthep" (list (+ x 4404)(- y 450)) 1 1 0)
(setq w (getreal "\nDo day : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 4404)(- y 450)) 250 0 (fix w))
(command "INSERT" "vitrichuthep" (list (+ x 6092)(- y 450)) 1 1 0)
(setq l (getreal "\nChieu dai thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 6092)(- y 450)) 250 0 (fix l))
(command "INSERT" "vitrichuthep" (list (+ x 7935)(- y 450)) 1 1 0)
(setq n (getreal "\nSo luong thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 7935)(- y 450)) 250 0 (fix n))
(setq c (* n l))
(setq m (/ c 1000))
(command "TEXT" "c" (list (+ x 9912)(- y 450)) 250 0 (rtos m 2 2))
(setq r (+ d b ))
(setq k (* w r))
(setq v (* k 786))
(setq j (* v m))
(setq t (/ j 100000))
(command "TEXT" "c" (list (+ x 12214)(- y 450)) 250 0 (rtos t 2 2))
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(traos)
)
)
(if (= lc "O")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "INSERT" "vitrichuthep" (list (+ x 1600)(- y 450)) 1 1 0)
(setq s (getstring 5"\nSo thu tu : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 1600)(- y 450)) 250 0 s)
(command "TEXT" "c" (list (+ x 3250)(- y 450)) 250 0 "%%254= -DAØY")
(command "INSERT" "vitrichuthep" (list (+ x 3000)(- y 450)) 1 1 0)
(setq d (getreal "\nDuong kinh : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3000)(- y 450)) 250 0 (fix d))
(command "INSERT" "vitrichuthep" (list (+ x 4550)(- y 450)) 1 1 0)
(setq b (getreal "\nDo day : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 4550)(- y 450)) 250 0 (fix b ))
(command "INSERT" "vitrichuthep" (list (+ x 6092)(- y 450)) 1 1 0)
(setq l (getreal "\nChieu dai thanh: "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 6092)(- y 450)) 250 0 (fix l))
(command "INSERT" "vitrichuthep" (list (+ x 7935)(- y 450)) 1 1 0)
(setq n (getreal "\nSo luong thanh: "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 7935)(- y 450)) 250 0 (fix n))
(setq c (* n l))
(setq m (/ c 1000))
(command "TEXT" "c" (list (+ x 9912)(- y 450)) 250 0 (rtos m 2 2))
(setq r (* pi d))
(setq k (* r b ))
(setq v (* k 786))
(setq j (* v m))
(setq t (/ j 50000))
(command "TEXT" "c" (list (+ x 12214)(- y 450)) 250 0 (rtos t 2 2))
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(traos)
)
)
(if (= lc "v")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "INSERT" "vitrichuthep" (list (+ x 1600)(- y 450)) 1 1 0)
(setq s (getstring 5"\nSo thu tu : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 1600)(- y 450)) 250 0 s)
(command "TEXT" "c" (list (+ x 3446)(- y 450)) 250 0 "[] * *")
(command "INSERT" "vitrichuthep" (list (+ x 3082)(- y 450)) 1 1 0)
(setq d (getreal "\nCanh thu nhat : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3082)(- y 450)) 250 0 (fix d))
(command "INSERT" "vitrichuthep" (list (+ x 3791)(- y 450)) 1 1 0)
(setq b (getreal "\nCanh thu hai : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3791)(- y 450)) 250 0 (fix b ))
(command "INSERT" "vitrichuthep" (list (+ x 4404)(- y 450)) 1 1 0)
(setq w (getreal "\nDo day : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 4404)(- y 450)) 250 0 (fix w))
(command "INSERT" "vitrichuthep" (list (+ x 6092)(- y 450)) 1 1 0)
(setq l (getreal "\nChieu dai thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 6092)(- y 450)) 250 0 (fix l))
(command "INSERT" "vitrichuthep" (list (+ x 7935)(- y 450)) 1 1 0)
(setq n (getreal "\nSo luong thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 7935)(- y 450)) 250 0 (fix n))
(setq c (* n l))
(setq m (/ c 1000))
(command "TEXT" "c" (list (+ x 9912)(- y 450)) 250 0 (rtos m 2 2))
(setq r (+ d b ))
(setq k (* w r))
(setq v (* k 786))
(setq j (* v m))
(setq t (/ j 50000))
(command "TEXT" "c" (list (+ x 12214)(- y 450)) 250 0 (rtos t 2 2))
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(traos)
)
)
(if (= lc "V")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "INSERT" "vitrichuthep" (list (+ x 1600)(- y 450)) 1 1 0)
(setq s (getstring 5"\nSo thu tu : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 1600)(- y 450)) 250 0 s)
(command "TEXT" "c" (list (+ x 3446)(- y 450)) 250 0 "[] * *")
(command "INSERT" "vitrichuthep" (list (+ x 3082)(- y 450)) 1 1 0)
(setq d (getreal "\nCanh thu nhat : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3082)(- y 450)) 250 0 (fix d))
(command "INSERT" "vitrichuthep" (list (+ x 3791)(- y 450)) 1 1 0)
(setq b (getreal "\nCanh thu hai : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3791)(- y 450)) 250 0 (fix b ))
(command "INSERT" "vitrichuthep" (list (+ x 4404)(- y 450)) 1 1 0)
(setq w (getreal "\nDo day : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 4404)(- y 450)) 250 0 (fix w))
(command "INSERT" "vitrichuthep" (list (+ x 6092)(- y 450)) 1 1 0)
(setq l (getreal "\nChieu dai thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 6092)(- y 450)) 250 0 (fix l))
(command "INSERT" "vitrichuthep" (list (+ x 7935)(- y 450)) 1 1 0)
(setq n (getreal "\nSo luong thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 7935)(- y 450)) 250 0 (fix n))
(setq c (* n l))
(setq m (/ c 1000))
(command "TEXT" "c" (list (+ x 9912)(- y 450)) 250 0 (rtos m 2 2))
(setq r (+ d b ))
(setq k (* w r))
(setq v (* k 786))
(setq j (* v m))
(setq t (/ j 50000))
(command "TEXT" "c" (list (+ x 12214)(- y 450)) 250 0 (rtos t 2 2))
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(traos)
)
)
(if (= lc "c")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(command "INSERT" "vitrichuthep" (list (+ x 1600)(- y 450)) 1 1 0)
(setq s (getstring 5"\nSo thu tu : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 1600)(- y 450)) 250 0 s)
(command "TEXT" "c" (list (+ x 3400)(- y 450)) 250 0 "C * *")
(command "INSERT" "vitrichuthep" (list (+ x 3082)(- y 450)) 1 1 0)
(setq d (getreal "\nCanh dai : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3082)(- y 450)) 250 0 (fix d))
(command "INSERT" "vitrichuthep" (list (+ x 3791)(- y 450)) 1 1 0)
(setq b (getreal "\nCanh ngan : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3791)(- y 450)) 250 0 (fix b ))
(command "INSERT" "vitrichuthep" (list (+ x 4404)(- y 450)) 1 1 0)
(setq w (getreal "\nDo day : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 4404)(- y 450)) 250 0 (fix w))
(command "INSERT" "vitrichuthep" (list (+ x 6092)(- y 450)) 1 1 0)
(setq l (getreal "\nChieu dai thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 6092)(- y 450)) 250 0 (fix l))
(command "INSERT" "vitrichuthep" (list (+ x 7935)(- y 450)) 1 1 0)
(setq n (getreal "\nSo luong thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 7935)(- y 450)) 250 0 (fix n))
(setq c (* n l))
(setq m (/ c 1000))
(command "TEXT" "c" (list (+ x 9912)(- y 450)) 250 0 (rtos m 2 2))
(setq r (+ d b b ))
(setq k (* w r))
(setq v (* k 786))
(setq j (* v m))
(setq t (/ j 100000))
(command "TEXT" "c" (list (+ x 12214)(- y 450)) 250 0 (rtos t 2 2))
(traos)
)
)
(if (= lc "C")
(progn
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(setq a (getpoint "\nChon diem tren ben trai: "))
(setq x (car a))
(setq y (cadr a))
(luuos)
(setvar "osmode" 0)
(command "LINE"(list (+ x 0) (- y 600)) (list (+ x 13214) (- y 600)) "")
(command "INSERT" "vitrichuthep" (list (+ x 1600)(- y 450)) 1 1 0)
(setq s (getstring 5"\nSo thu tu : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 1600)(- y 450)) 250 0 s)
(command "TEXT" "c" (list (+ x 3400)(- y 450)) 250 0 "C * *")
(command "INSERT" "vitrichuthep" (list (+ x 3082)(- y 450)) 1 1 0)
(setq d (getreal "\nCanh dai : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3082)(- y 450)) 250 0 (fix d))
(command "INSERT" "vitrichuthep" (list (+ x 3791)(- y 450)) 1 1 0)
(setq b (getreal "\nCanh ngan : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 3791)(- y 450)) 250 0 (fix b ))
(command "INSERT" "vitrichuthep" (list (+ x 4404)(- y 450)) 1 1 0)
(setq w (getreal "\nDo day : "))
(command "UNDO" "")
(command "TEXT" "c" (list (+ x 4404)(- y 450)) 250 0 (fix w))
(command "INSERT" "vitrichuthep" (list (+ x 6092)(- y 450)) 1 1 0)
(setq l (getreal "\nChieu dai thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 6092)(- y 450)) 250 0 (fix l))
(command "INSERT" "vitrichuthep" (list (+ x 7935)(- y 450)) 1 1 0)
(setq n (getreal "\nSo luong thanh: "))
(command "erase" "last" "")
(command "TEXT" "c" (list (+ x 7935)(- y 450)) 250 0 (fix n))
(setq c (* n l))
(setq m (/ c 1000))
(command "TEXT" "c" (list (+ x 9912)(- y 450)) 250 0 (rtos m 2 2))
(setq r (+ d b b ))
(setq k (* w r))
(setq v (* k 786))
(setq j (* v m))
(setq t (/ j 100000))
(command "TEXT" "c" (list (+ x 12214)(- y 450)) 250 0 (rtos t 2 2))
(traos))
)
(setvar "MODEMACRO" "**CHUC BAN LAM VIEC HIEU QUA** PHAM QUOC DUY - BINH SON - QUANG NGAI")
(Princ)
)
;-------
;;------------------------------------------------------------
(defun DUY_newerror (msg)
(if (and (/= msg "Function cancelled")
(/= msg "quit / exit abort")
)
(princ (strcat "\n" msg))
)
(done)
)
;;----------
(defun init ()
(setq
DUY_CMD (getvar "CMDECHO")
DUY_OLDERROR *error*
*error* DUY_newerror
)
(setvar "CMDECHO" 0)
(command ".undo" "BE")
)
;;----------
(defun done ()
(command ".redraw")
(command ".undo" "E")
(if DUY_CMD
(setvar "CMDECHO" DUY_CMD)
)
(if DUY_OLDERROR
(setq *error* DUY_OLDERROR)
)
(princ)
)
;;----------
(defun luuos ()
(setq
DUY_OSMODE (getvar "OSMODE")
DUY_AUTOSNAP (getvar "AUTOSNAP")
DUY_LAYERHH (getvar "CLAYER")
DUY_filletrad (getvar "FILLETRAD")
DUY_TEXTSTYLE (getvar "TEXTSTYLE")
)
)
(defun traos ()
(if DUY_OSMODE
(setvar "OSMODE" DUY_OSMODE)
)
(if DUY_LAYERHH
(setvar "CLAYER" DUY_LAYERHH)
)
(if DUY_AUTOSNAP
(setvar "AUTOSNAP" DUY_AUTOSNAP)
)
(if DUY_filletrad
(setvar "FILLETRAD" DUY_filletrad)
)
(if DUY_TEXTSTYLE
(setvar "TEXTSTYLE" DUY_TEXTSTYLE)
)
)
;;----------
(defun c:h? (/ tl index)
(setq index 0)
(foreach tl h_taptenlenh
(setq index (1+ index))
(princ (strcat "\n" (itoa index) ": " tl)
)
)
(princ)
)
;;----------
(setvar "MODEMACRO" "*_*CHUC BAN LAM VIEC HIEU QUA*_* ")
(setvar "UCSICON" 1)
(setvar "FILLETRAD" 0.0)
(setvar "GRIDMODE" 0)
(setvar "OSMODE" 191)
(setq h_tylebv 100.0)
(dangky_app)
(princ)
;-------
;---------------------------------------
(defun nstr (stri def)
(princ stri)
(princ "<")
(princ " ")
(princ def)
(princ ">")
(princ ":")
(princ " ")
);defun nstr
;--------------------
(defun nstr1 (stri)
(princ stri)
(princ "<")
(princ "Nhap vao")
(princ ">")
(princ ":")
(princ " ")
);defun nstr1
;---------------------
(defun nint (prompt def / temp)
(if def
(setq temp (getint (nstr prompt def)))
(setq def (getint (nstr1 prompt)))
);if def
(if temp
(setq def temp)
def
);if temp
);defun nint
;---------------------
(defun dnint (prompt def / temp)
(if def
(setq temp (getreal (nstr prompt def)))
(setq def (getreal (nstr1 prompt)))
);if def
(if temp
(setq def temp)
def
);if temp
);defun nint
;--------------------
(defun ndist (po prompt def / temp) ;nhan kh/cach va luu gia tri mac dinh
(if def
(setq temp (getdist po (nstr prompt def)))
(setq def (getdist po (nstr1 prompt)))
)if def
(if temp
(setq def temp)
def
);if temp
);defun ndist
;-----------------------------------Thảo luận gốc
Lisp được chia sẻ trong chủ đề Viết Lisp theo yêu cầu. Xem đúng bài viết #3394 để đọc hướng dẫn và trao đổi thêm.