Ẩn hiện đối tượng theo màu
Tí quên ^^ Của bạn đây. Mình quick code iso 1 màu thôi nhé :) 1 cái CISO và 1 cái CUNISO
(defun get_col(e)(setq e (entget e))(cdr (cond ((assoc 62 e))((assoc 62 (tblsearch "layer" (cdr (assoc 8 e)))))))) (defun C:ciso(/ e col s o) (while (not (setq e (nentsel "\nSelect object :")))) (cond ( (and (setq col (get_col (car e))) (setq s (ssget "X") i -1) ) (while (setq o (ssname s (setq i (1+ i)))) (if (/= (get_col o) col)(entmod (append (entget o) (list (cons 60 1))))) ) ) ) (princ) ) (defun c:cuniso(/ s o) (setq s (ssget "_X" '((60 . 1)))) (or (and acet-ss-visible (acet-ss-visible s 0)) (while (setq o (ssname s (setq i (1+ i))))(entmod (append (entget o) (list (cons 60 0))))) ) (prompt (strcat "Hi\U+1EC7n l\U+1EA1i c\U+00E1c \U+0111\U+1ED1i t\U+01B0\U+1EE3ng \U+0111\U+00E3 b\U+1ECB \U+1EA9n :" (vl-princ-to-string (sslength s)))) (princ) )em chạy sao nó nặng thế bác, nó thực hiện lệnh lâu lắm bác, đơ 1 lúc rồi đc@@!
Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.
Cách dùng
- Chép mã nguồn, lưu thành tệp 268168_ciso_cuniso.lsp.
- 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 CISO CUNISO để chạy lisp.
Mã nguồn 268168_ciso_cuniso.lsp (trích từ bài viết gốc)
(defun get_col(e)(setq e (entget e))(cdr (cond ((assoc 62 e))((assoc 62 (tblsearch "layer" (cdr (assoc 8 e))))))))
(defun C:ciso(/ e col s o)
(while (not (setq e (nentsel "\nSelect object :"))))
(cond
(
(and
(setq col (get_col (car e)))
(setq s (ssget "X") i -1)
)
(while (setq o (ssname s (setq i (1+ i))))
(if (/= (get_col o) col)(entmod (append (entget o) (list (cons 60 1)))))
)
)
)
(princ)
)
(defun c:cuniso(/ s o)
(setq s (ssget "_X" '((60 . 1))))
(or
(and acet-ss-visible (acet-ss-visible s 0))
(while (setq o (ssname s (setq i (1+ i))))(entmod (append (entget o) (list (cons 60 0)))))
)
(prompt (strcat "Hi\U+1EC7n l\U+1EA1i c\U+00E1c \U+0111\U+1ED1i t\U+01B0\U+1EE3ng \U+0111\U+00E3 b\U+1ECB \U+1EA9n :" (vl-princ-to-string (sslength s))))
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu cầu] Ẩn hiện đối tượng theo màu. Xem đúng bài viết #268168 để đọc hướng dẫn và trao đổi thêm.