尝试基于对象选择创建层过滤器。
- (defun c:foo (/ a d e f l n s x)
- ;; RJP 2.6.2018
- ;; Creates a layer filter from a selection of objects
- (cond
- ((null (setq s (ssget))) (print "Bye..."))
- ((null
- (and (setq a (cdr (assoc 330 (entget (tblobjname "layer" (getvar 'clayer))))))
- (setq d (cdr (assoc -1 (dictsearch (cdr (assoc 360 (entget a))) "ACAD_LAYERFILTERS"))))
- )
- )
- (print "No layer filter dictionary...")
- )
- (t
- (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
- (and (not (member (setq l (cdr (assoc 8 (entget x)))) f)) (setq f (cons l f)))
- )
- (setq n (strcat (getenv "username") "_SelectionFilter"))
- (and (setq e (dictsearch d n)) (entdel (cdr (assoc -1 e))))
- (dictadd d
- n
- (entmakex (list '(0 . "xrecord")
- '(100 . "AcDbXrecord")
- '(280 . 1)
- (cons 1 n)
- (cons 1 (apply 'strcat (mapcar '(lambda (x) (strcat x ",")) f)))
- '(1 . "*")
- '(1 . "*")
- '(70 . 0)
- '(1 . "*")
- '(1 . "*")
- )
- )
- )
- (command "_.+layer" n)
- ;; Qsave regenerates layer palette to show correct filter .. bit of a kludge
- (command "_.qsave")
- )
- )
- (princ)
- )
|