Lisp lệnh DD trong chủ đề “Thắc mắc lisp xuất cạnh của line”
Em có file CaD và em cần xuất cạnh của 1 cạnh như sau ạ
https://www.cadviet.com/upfiles/3/37777_nghiapeo.lsp
https://www.cadviet.com/upfiles/3/37777_thac_mac.dwg
Đây là file lisp và file CAD em thắc mắc ạ.

Sẽ chẳng vấn đề gì khi như mọi file khác em dùng lisp trên xuất từng cạnh mình cần
Nhưng khi em xuất cạnh ở file CAD trên bằng Lisp ở trên luôn thì no hiện là hiện 3D length (Mục 3) = 2.58
Hay khi em dùng lệnh DI ( Distance ) thì nó hiện kết quả là 1.47
Nhưng chiều dài thực tế của line này là 0.37 (Mục 2 ) ạ.
Bác nào giải thích giúp em với.
Em dùng máy Toàn đạc điện tử Gowin xuất ra tọa độ rồi triển điểm lên CAD ạ. @@
Nhiều file bị chứ k riêng file em ví dụ này. =>> Các máy toàn đạc khác thì em chưa thử. @@
// Mong các bác giải thích cho em với. :(
Đây là nội dung lisp ạ.@@
(defun c:dd ( )
(command "undo" "be")
(command "-style" "ktdt" "VNI-HELVE" "0" "1" "0" "n" "n")
(if (null dolora)(setq dolora "1"))
(Setq temp T)
(While temp
(setq a (strcat "\nD lon text hien hanh la (" dolora ") /<Diem dau tien>: "))
(Initget "d D")
(setq str (getpoint a))
(Cond
((= str "d") (setq dolora (getstring (strcat"\nDo lon text <" dolora "> :"))))
((= str "D") (setq dolora (getstring (strcat"\nDo lon text <" dolora "> :"))))
(Progn
(Setq a str)
(setq temp nil)
)
)
)
(setq b (getpoint a"\nChon diem tiep theo: "))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)
(setq doclora (atof dolora))
(setq gocxeo(angle a B))
(setq daiab (Distance a B))
(setq c (polar a gocxeo (/ daiab 2)))
(setq d (polar c (+ gocxeo (/ pi 2)) (/ doclora 4)))
z
(command ".line" a b "")
(command "text" "j" "c" c doclora b (rtos daiab 2 2) "")
(command ".move" "last" "" c d)
(cond
((> gocxeo (/ pi 2)) (command ".rotate" "last" "" c 0))
)
(setvar "osmode" luubatdiem)
(command "undo" "end")
(Princ)
)
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 301676_dd.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 DD để chạy lisp.
Mã nguồn 301676_dd.lsp (trích từ bài viết gốc)
(defun c:dd ( )
(command "undo" "be")
(command "-style" "ktdt" "VNI-HELVE" "0" "1" "0" "n" "n")
(if (null dolora)(setq dolora "1"))
(Setq temp T)
(While temp
(setq a (strcat "\nD lon text hien hanh la (" dolora ") /<Diem dau tien>: "))
(Initget "d D")
(setq str (getpoint a))
(Cond
((= str "d") (setq dolora (getstring (strcat"\nDo lon text <" dolora "> :"))))
((= str "D") (setq dolora (getstring (strcat"\nDo lon text <" dolora "> :"))))
(Progn
(Setq a str)
(setq temp nil)
)
)
)
(setq b (getpoint a"\nChon diem tiep theo: "))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)
(setq doclora (atof dolora))
(setq gocxeo(angle a B))
(setq daiab (Distance a B))
(setq c (polar a gocxeo (/ daiab 2)))
(setq d (polar c (+ gocxeo (/ pi 2)) (/ doclora 4)))
z
(command ".line" a b "")
(command "text" "j" "c" c doclora b (rtos daiab 2 2) "")
(command ".move" "last" "" c d)
(cond
((> gocxeo (/ pi 2)) (command ".rotate" "last" "" c 0))
)
(setvar "osmode" luubatdiem)
(command "undo" "end")
(Princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Thắc mắc lisp xuất cạnh của line. Xem đúng bài viết #301676 để đọc hướng dẫn và trao đổi thêm.