kill layerfilters and layersates without vla

Discussion in 'AutoCAD' started by Phil, Apr 1, 2004.

  1. Phil

    Phil Guest

    here's the code I come up with to do it
    posting for those who don't want vla for whatever reason.

    ;;;
    ;;;
    ;;;by Phil L
    ;;;this layerfilter killer doesn't use vla for the vlax handicapped
    ;;;type in lfd and it will remove all layerfilters
    ;;;only way I know to get the table object, "layer", where the filter
    object
    ;;; pointer resides, is to get layer '0' and go to its owner since
    ;;; layer 0 always exists.
    ;;;Checks layer object for xdict, looks for a layerfilter object.
    ;;;if found deletes the layerfilter object entity.
    ;;;makes sure there are no more. (Which shouldn't be)
    ;;;also makes multi runs thru each xdict to be sure only one layerfilter
    ;;;I don't know if more than layerfilter object is allowed but
    ;;;this kills ALL of them
    ;;;added: kills acad_layerstates also, I don't know what this is but I
    ;;;don't need or want them. If you need these edit the code indicated
    ;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;
    ;;;
    (defun LFcount ( l / c)
    (setq c 0)
    (foreach x l
    (if (= 3 (car x))(setq c (1+ c))))
    c
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;
    ;;;
    (defun killdict (l s / el c )
    (setq c 0)
    (if (/= (car l) 360)
    (progn (alert "dxf structure problem")(exit))) ; dxf 360
    is pointer to dict item
    (while (setq el (dictsearch (cdr l) s))
    (setq c (+ c (LFcount el)))
    (entdel (cdr (assoc -1 el))))
    c
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;
    ;;; go thru list and return sublist starting with key data = s or nil
    ;;; (getsublist '((1 2)(3 4)(5 6)) '(4))==> ((3 4)(5 6))
    ;;;
    (defun getsublist (l s )
    (if (or (not l) (= (cdar l) s))
    l
    (getsublist (cdr l) s ))
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;
    ;;;
    ;;;
    (defun C:LFD ( / LT found found1 ) ;
    kill all layerfilters
    (setq LT (entget (cdr (assoc 330 (entget (tblobjname "layer" "0")))))
    found 0
    found1 0)
    ;; look for all acad_xdictionary
    ;; then look for all layerfilter entries
    ;; do for all layer table entity/object
    (while (setq LT (getsublist LT "{ACAD_XDICTIONARY" ))
    (setq found (+ found (killdict (cadr LT) "ACAD_LAYERFILTERS"))
    ;;remove following line if layerstates are wanted
    found1 (+ found1 (killdict (cadr LT) "ACAD_LAYERSTATES"))
    LT (cddr LT)))
    (princ (strcat "\nLAYERFILTERS/LAYERSTATES found and killed: " (itoa
    found) "/" (itoa found1)))
    (princ)
    )
    ;;;;;;;by Phil L
     
    Phil, Apr 1, 2004
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.