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) )))
Bác gia_bach ơi bác có thể xem giúp em đoạn lisp trên với. Em mới cài Cad 2008 và khi ghi bước thép cũng như khi đổi màu đối tượng thì nó báo lỗi. Kiểu như sau:
Command: bt
Nhap buoc thep <200>:
Select objects: 1 found
Select objects: _.undo Current settings: Auto = On, Control = All, Combine =
Yes
Enter the number of operations to undo or
<1>: _begin
Command: ; error: no function definition: VLAX-ENAME->VLA-OBJECT
Em không biết nó là lỗi gì. Bác xem giúp em với nhé.
Thanks bác nhiều.
- Tải lisp
- 203735_bt_10.lsp
Cách dùng
- Tải tệp 203735_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 203735_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 #203735 để đọc hướng dẫn và trao đổi thêm.