Lisp ghi bước thép với khoảng cách thép đều nhau
Thêm 1 phương án :
(defun C:bt(/ ctc ss)
(or *ctc* (setq *ctc* 200))
(initget 6)
(setq ctc (getint (strcat"\nNhap buoc thep <" (itoa *ctc*) ">:")) )
(if ctc (setq *ctc* ctc))
(if (setq ss (ssget"_:L" (list (cons 0 "DIMENSION")) ))
(progn
(command "_.undo" "_begin")
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(vla-put-TextOverride (vlax-ename->vla-object ent)
(strcat (itoa (fix(/ (cdr (assoc 42 (entget ent))) *ctc*)))
"x" (itoa *ctc*) "=<>")) )
(command "_.undo" "_end") (princ) )))
(defun C:10(/ num ss)
(if (setq ss (ssget"_:L"))
(progn
(command "_.undo" "_begin")
(or *num* (setq *num* 15))
(initget 4)
(setq num (getint (strcat"\nNhap color <" (itoa *num*) ">:")) )
(while (not (if num (<= num 256)T) )
(princ "\nGia tri <=256.")
(setq num (getint (strcat"\nNhap color <" (itoa *num*) ">:")) ))
(if num (setq *num* num))
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(vla-put-Color (vlax-ename->vla-object ent)*num* ) )
(command "_.undo" "_end") (princ) )))
- Tải lisp
- 202939_bt_10.lsp
Cách dùng
- Tải tệp 202939_bt_10.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 BT 10 để chạy lisp.
Mã nguồn 202939_bt_10.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/64712-y%C3%AAu-c%E1%BA%A7u-lisp-ghi-b%C6%B0%E1%BB%9Bc-th%C3%A9p-v%E1%BB%9Bi-kho%E1%BA%A3ng-c%C3%A1ch-th%C3%A9p-%C4%91%E1%BB%81u-nhau/
(defun C:bt(/ ctc ss)
(or *ctc* (setq *ctc* 200))
(initget 6)
(setq ctc (getint (strcat"\nNhap buoc thep <" (itoa *ctc*) ">:")) )
(if ctc (setq *ctc* ctc))
(if (setq ss (ssget"_:L" (list (cons 0 "DIMENSION")) ))
(progn
(command "_.undo" "_begin")
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(vla-put-TextOverride (vlax-ename->vla-object ent)
(strcat (itoa (fix(/ (cdr (assoc 42 (entget ent))) *ctc*)))
"x" (itoa *ctc*) "=<>")) )
(command "_.undo" "_end") (princ) )))
(defun C:10(/ num ss)
(if (setq ss (ssget"_:L"))
(progn
(command "_.undo" "_begin")
(or *num* (setq *num* 15))
(initget 4)
(setq num (getint (strcat"\nNhap color <" (itoa *num*) ">:")) )
(while (not (if num (<= num 256)T) )
(princ "\nGia tri <=256.")
(setq num (getint (strcat"\nNhap color <" (itoa *num*) ">:")) ))
(if num (setq *num* num))
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(vla-put-Color (vlax-ename->vla-object ent)*num* ) )
(command "_.undo" "_end") (princ) )))
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu cầu] Lisp ghi bước thép với khoảng cách thép đều nhau. Xem đúng bài viết #202939 để đọc hướng dẫn và trao đổi thêm.