Lisp lệnh BTD trong chủ đề “Nhờ viết lisp: vẽ hình của các tọa độ nhập và xuất ra bảng thông tin”
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 197787_btd.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 BTD để chạy lisp.
Mã nguồn 197787_btd.lsp (trích từ bài viết gốc)
(defun c:btd ()
(princ "\dai ca van dung")
(Command "-osnap" "")
(command "style" "textbangtoado" ".Vnarial narrowH" 0.5 "" "" "n" "n")
(setq
diemgoc (getpoint "\n chän ®iÓm chÌn b¶ng")
sodiem (getint "\n sè lîng ®iÓm cÇn xuÊt")
)
(setq
x (car diemgoc)
y (cadr diemgoc)
z (caddr diemgoc)
)
(setq soline (+ sodiem 2))
(setq caobang (+ soline 0))
(setq y1(- y 1))
(setq y2(- y caobang))
(setq diemchan1 (list x y1 x))
(setq diemchan2 (list x y2 z))
(command "line" diemgoc "@14<0" "")
(repeat soline
(command "copy" "L" "" diemgoc "@1<-90")
)
(command "line" diemchan1 diemchan2 "")
(command "copy" "L" "" diemgoc "@1<0")
(command "copy" "L" "" diemgoc "@2<0")
(command "copy" "L" "" diemgoc "@4<0")
(command "copy" "L" "" diemgoc "@4<0")
(command "copy" "L" "" diemgoc "@3<0")
(command "line" diemgoc diemchan1 "")
(command "copy" "L" "" diemgoc "@14<0")
; ghi ten bang
(setq xtenbang (+ x 7))
(setq ytenbang (- y 0.5))
(setq tenbang (list xtenbang ytenbang 0))
(command "text" "j" "mc" tenbang 0 "B¶ng To¹ ®é" "")
; ghi stt
(setq xstt (+ x 0.5))
(setq ystt (- y 1.5))
(setq stt (list xstt ystt 0))
(command "text" "j" "mc" stt 0 "TT" "")
; ghi TEN DIEM
(setq tendiem (polar stt 0 1.5))
(command "text" "j" "mc" tendiem 0 "Tªn" "")
; ghi X
(setq textx (polar stt 0 4.5))
(command "text" "j" "mc" textx 0 "x" "")
; ghi Y
(setq texty (polar stt 0 8.5))
(command "text" "j" "mc" texty 0 "y" "")
; ghi z
(setq textz (polar stt 0 12))
(command "text" "j" "mc" textz 0 "z" "")
; DA VE XOONG BANG
; ******************
(setq i 0)
(repeat sodiem
(command "_osnap" "Node")
(setq point(getpoint "\nChän ®iÓm cÇn xuÊt to¹ ®é"))
(setq ten(getstring "\n NhËp tªn ®iÓm"))
(setq i (1+ i))
(setq gocquay (/ (* 3 pi) 2))
(setq textstt (polar stt gocquay i)
texttendiem (polar textstt 0 1.5)
textpointx (polar textstt 0 4.5)
textpointy (polar textstt 0 8.5)
textpointz (polar textstt 0 12)
)
(setq
xpoint (rtos (car point))
ypoint (rtos (cadr point))
zpoint (rtos (caddr point))
)
(Command "-osnap" "")
(command "text" "j" "mc" textstt 0 i "")
(command "text" "j" "mc" texttendiem 0 ten "")
(command "text" "j" "mc" textpointx 0 ypoint "")
(command "text" "j" "mc" textpointy 0 xpoint "")
(command "text" "j" "mc" textpointz 0 zpoint "")
)
;(repeat sodiem
;(setq ssp (getpoint))
; (setq ent (ssname ssp i)
; i (1+ i)
; p (cdr (assoc 10 (entget ent)))
; x (car p)
; y (cadr p)
; z (caddr p)
; )
;(setq linegoc (ssget "L"))
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Nhờ viết lisp: vẽ hình của các tọa độ nhập và xuất ra bảng thông tin. Xem đúng bài viết #197787 để đọc hướng dẫn và trao đổi thêm.