Jump to content

Ẩ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)
)
			

Cách dùng

  1. Tải tệp 268058_ciso_cuniso.lsp về máy.
  2. 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ẽ.
  3. Gõ lệnh CISO CUNISO để chạy lisp.

Mã nguồn 268058_ciso_cuniso.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/88632-y%C3%AAu-c%E1%BA%A7u-%E1%BA%A9n-hi%E1%BB%87n-%C4%91%E1%BB%91i-t%C6%B0%E1%BB%A3ng-theo-m%C3%A0u/
(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 #268058 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 147)