Lisp lệnh CDTHEP trong chủ đề “Các pro giúp e! LISP Tính tổng dim và paste giá trị vào block attribute”
40 phút trước, quocmanh04tt đã nói:Dùng nentsel.
Làm thử cái xem sao
(Defun c:cdthep(/ oldos s dtltc thongtin giatricu giatrimoi)
(setq oldos (getvar "OSMODE"))
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq dtltc (car (entsel "\nChon doi tuong pline.")))
(Command "area" "o" dtltc)
(setq s (getvar "PERIMETER"))
(setq thongtin (entget (car (nentsel "\nChon text trong block can thay the."))))
(setq giatricu (assoc 1 thongtin))
(setq giatrimoi (cons 1 (rtos s 2 2)))
(setq thongtin (subst giatrimoi giatricu thongtin))
(entmod thongtin)
(setvar "osmode" oldos)
(princ)
)
- Tải lisp
- 428729_cdthep.lsp
Cách dùng
- Tải tệp 428729_cdthep.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 CDTHEP để chạy lisp.
Mã nguồn 428729_cdthep.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/173422-c%C3%A1c-pro-gi%C3%BAp-e-lisp-t%C3%ADnh-t%E1%BB%95ng-dim-v%C3%A0-paste-gi%C3%A1-tr%E1%BB%8B-v%C3%A0o-block-attribute/
(Defun c:cdthep(/ oldos s dtltc thongtin giatricu giatrimoi)
(setq oldos (getvar "OSMODE"))
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setq dtltc (car (entsel "\nChon doi tuong pline.")))
(Command "area" "o" dtltc)
(setq s (getvar "PERIMETER"))
(setq thongtin (entget (car (nentsel "\nChon text trong block can thay the."))))
(setq giatricu (assoc 1 thongtin))
(setq giatrimoi (cons 1 (rtos s 2 2)))
(setq thongtin (subst giatrimoi giatricu thongtin))
(entmod thongtin)
(setvar "osmode" oldos)
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Các pro giúp e! LISP Tính tổng dim và paste giá trị vào block attribute. Xem đúng bài viết #428729 để đọc hướng dẫn và trao đổi thêm.