Lisp lệnh LOCSO trong chủ đề “Hỏi cách lấy giá trị trong text”
tôi sử dụng thì gặp lỗi sau:
Command: locso
Select object: ; error: misplaced dot on input
Mong các bạn xem lại giúp. Thanks
Bạn sửa như sau:
(defun c:locso() (setq te (car (entsel)) text (cdr (assoc 1 (entget te))) sl (strlen text) kq "" i 1) (while (< i sl) (setq so (substr text i 1)) (if (/= so ".") (progn (if (numberp (read so)) (setq kq (strcat kq so)) ) ) (setq kq (strcat kq so)) ) (setq i (1+ i)) ) kq )
- Tải lisp
- 133800_locso.lsp
Cách dùng
- Tải tệp 133800_locso.lsp về máy.
- 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 LOCSO để chạy lisp.
Mã nguồn 133800_locso.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/35796-h%E1%BB%8Fi-c%C3%A1ch-l%E1%BA%A5y-gi%C3%A1-tr%E1%BB%8B-trong-text/
(defun c:locso()
(setq te (car (entsel))
text (cdr (assoc 1 (entget te)))
sl (strlen text)
kq ""
i 1)
(while (< i sl)
(setq so (substr text i 1))
(if (/= so ".")
(progn
(if (numberp (read so))
(setq kq (strcat kq so))
)
)
(setq kq (strcat kq so))
)
(setq i (1+ i))
)
kq
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề Hỏi cách lấy giá trị trong text. Xem đúng bài viết #133800 để đọc hướng dẫn và trao đổi thêm.