Lisp lệnh SELECTBYCOLOUR trong chủ đề “Lisp Quick Filter: Lọc nhanh theo một số thuộc tính thông dụng”
11 giờ trước, vanlam6408 đã nói:vâng.hi
(defun c:SelectByColour ( / c d e l ) (if (setq e (car (entsel))) (progn (setq c (cond ( (cdr (assoc 62 (entget e))) ) ( (abs (cdr (assoc 62 (tblsearch "LAYER" (cdr (assoc 8 (entget e))))))) ) ) ) (while (setq d (tblnext "LAYER" (null d))) (if (= c (abs (cdr (assoc 62 d)))) (setq l (cons "," (cons (cdr (assoc 2 d)) l))) ) ) (sssetfirst nil (ssget "_X" (if l (list (cons -4 "<OR") (cons 62 c) (cons -4 "<AND") (cons 62 256) (cons 8 (apply 'strcat (cdr l))) (cons -4 "AND>") (cons -4 "OR>") ) (list (cons 62 c)) ) ) ) ) ) (princ) )
Mình tìm thấy cái chọn màu kể cả By layer của Lee Mac đây. Để lúc nào m thêm tuỳ chọn chọn cả theo màu của layer xem sao :)
- Tải lisp
- 448775_selectbycolour.lsp
Cách dùng
- Tải tệp 448775_selectbycolour.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 SELECTBYCOLOUR để chạy lisp.
Mã nguồn 448775_selectbycolour.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/182351-lisp-quick-filter-l%E1%BB%8Dc-nhanh-theo-m%E1%BB%99t-s%E1%BB%91-thu%E1%BB%99c-t%C3%ADnh-th%C3%B4ng-d%E1%BB%A5ng/
(defun c:SelectByColour ( / c d e l )
(if (setq e (car (entsel)))
(progn
(setq c
(cond
( (cdr (assoc 62 (entget e))) )
( (abs (cdr (assoc 62 (tblsearch "LAYER" (cdr (assoc 8 (entget e))))))) )
)
)
(while (setq d (tblnext "LAYER" (null d)))
(if (= c (abs (cdr (assoc 62 d))))
(setq l (cons "," (cons (cdr (assoc 2 d)) l)))
)
)
(sssetfirst nil
(ssget "_X"
(if l
(list
(cons -4 "<OR")
(cons 62 c)
(cons -4 "<AND")
(cons 62 256)
(cons 8 (apply 'strcat (cdr l)))
(cons -4 "AND>")
(cons -4 "OR>")
)
(list (cons 62 c))
)
)
)
)
)
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Lisp Quick Filter: Lọc nhanh theo một số thuộc tính thông dụng. Xem đúng bài viết #448775 để đọc hướng dẫn và trao đổi thêm.