Quét, lọc và thay đổi Layer cho nhóm đối tượng.
Quick code cho bạn
(defun c:doi(/ lstSource ss i e)
(setq lstSource '(("1" . "1a")("2" . "2a") ("3" . "3a")) ;Them danh sach nguon, dich vao day
ss (ssget
(list (cons 8
(substr
(apply 'strcat (mapcar '(lambda(x)(strcat "," x))(mapcar 'car lstSource)))
2
))
))
i -1
)
(while (setq e (ssname ss (setq i (1+ i))))
(entmod (append (setq e (entget e))(list (cons 8 (cdr (assoc (cdr (assoc 8 e)) lstSource))))))
)
(princ)
)
(defun c:doi(/ lstSource ss i e)
(setq lstSource '(("1" . "1a")("2" . "2a") ("3" . "3a")) ;Them danh sach nguon, dich vao day
ss (ssget
(list (cons 8
(substr
(apply 'strcat (mapcar '(lambda(x)(strcat "," x))(mapcar 'car lstSource)))
2
))
))
i -1
)
(while (setq e (ssname ss (setq i (1+ i))))
(entmod (append (setq e (entget e))(list (cons 8 (cdr (assoc (cdr (assoc 8 e)) lstSource))))))
)
(princ)
(defun c:doi(/ lstSource ss i e)
(setq lstSource '(("1" . "1a")("2" . "2a") ("3" . "3a")) ;Them danh sach nguon, dich vao day
ss (ssget
(list (cons 8
(substr
(apply 'strcat (mapcar '(lambda(x)(strcat "," x))(mapcar 'car lstSource)))
2
))
))
i -1
)
(while (setq e (ssname ss (setq i (1+ i))))
(entmod (append (setq e (entget e))(list (cons 8 (cdr (assoc (cdr (assoc 8 e)) lstSource))))))
)
(princ)
)
(defun c:doi(/ lstSource ss i e)
(setq lstSource '(("1" . "1a")("2" . "2a") ("3" . "3a")) ;Them danh sach nguon, dich vao day
ss (ssget
(list (cons 8
(substr
(apply 'strcat (mapcar '(lambda(x)(strcat "," x))(mapcar 'car lstSource)))
2
))
))
i -1
)
(while (setq e (ssname ss (setq i (1+ i))))
(entmod (append (setq e (entget e))(list (cons 8 (cdr (assoc (cdr (assoc 8 e)) lstSource))))))
)
(princ)
)
(defun c:doi(/ lstSource ss i e)
(setq lstSource '(("1" . "1a")("2" . "2a") ("3" . "3a")) ;Them danh sach nguon, dich vao day
ss (ssget
(list (cons 8
(substr
(apply 'strcat (mapcar '(lambda(x)(strcat "," x))(mapcar 'car lstSource)))
2
))
))
i -1
)
(while (setq e (ssname ss (setq i (1+ i))))
(entmod (append (setq e (entget e))(list (cons 8 (cdr (assoc (cdr (assoc 8 e)) lstSource))))))
)
(princ)
(defun c:doi(/ lstSource ss i e)
(setq lstSource '(("1" . "1a")("2" . "2a") ("3" . "3a")) ;Them danh sach nguon, dich vao day
ss (ssget
(list (cons 8
(substr
(apply 'strcat (mapcar '(lambda(x)(strcat "," x))(mapcar 'car lstSource)))
2
))
))
i -1
)
(while (setq e (ssname ss (setq i (1+ i))))
(entmod (append (setq e (entget e))(list (cons 8 (cdr (assoc (cdr (assoc 8 e)) lstSource))))))
)
(princ)
(defun c:doi(/ lstSource ss i e)
(setq lstSource '(("1" . "1a")("2" . "2a") ("3" . "3a")) ;Them danh sach nguon, dich vao day
ss (ssget
(list (cons 8
(substr
(apply 'strcat (mapcar '(lambda(x)(strcat "," x))(mapcar 'car lstSource)))
2
))
))
i -1
)
(while (setq e (ssname ss (setq i (1+ i))))
(entmod (append (setq e (entget e))(list (cons 8 (cdr (assoc (cdr (assoc 8 e)) lstSource))))))
)
(princ)
)
- Tải lisp
- 238438_doi.lsp
Cách dùng
- Tải tệp 238438_doi.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 DOI để chạy lisp.
Mã nguồn 238438_doi.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/72422-xin-lisp-qu%C3%A9t-l%E1%BB%8Dc-v%C3%A0-thay-%C4%91%E1%BB%95i-layer-cho-nh%C3%B3m-%C4%91%E1%BB%91i-t%C6%B0%E1%BB%A3ng/
(defun c:doi(/ lstSource ss i e)
(setq lstSource '(("1" . "1a")("2" . "2a") ("3" . "3a")) ;Them danh sach nguon, dich vao day
ss (ssget
(list (cons 8
(substr
(apply 'strcat (mapcar '(lambda(x)(strcat "," x))(mapcar 'car lstSource)))
2
))
))
i -1
)
(while (setq e (ssname ss (setq i (1+ i))))
(entmod (append (setq e (entget e))(list (cons 8 (cdr (assoc (cdr (assoc 8 e)) lstSource))))))
)
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [XIN LISP] Quét, lọc và thay đổi Layer cho nhóm đối tượng.. Xem đúng bài viết #238438 để đọc hướng dẫn và trao đổi thêm.