purge frozen & empty layers

Discussion in 'AutoCAD' started by yavid, Dec 23, 2004.

  1. yavid

    yavid Guest

    Does anyone have a LISP that will purge a drawing of layers that are frozen but do not contain entities? I often have to thaw a dozen layers only to find that they don't contain anything, it would be nice to be able to automatically turf them without thawing them. I am fairly new to LISP and I think this one is beyond me. Thanks in advance for any and all help.
     
    yavid, Dec 23, 2004
    #1
  2. If the layers are simply frozen, not frozen in a
    viewport the stock PURGE command will do
    what you want.

    --
    Autodesk Discussion Group Facilitator



    frozen but do not contain entities? I often have to thaw a dozen layers
    only to find that they don't contain anything, it would be nice to be able
    to automatically turf them without thawing them. I am fairly new to LISP
    and I think this one is beyond me. Thanks in advance for any and all help.
     
    Jason Piercey, Dec 23, 2004
    #2
  3. yavid

    yavid Guest

    I apologize, I neglected to mention that they are frozen in the viewports.
     
    yavid, Dec 23, 2004
    #3
  4. yavid

    Don Reichle Guest

    Hopefully you don't have more than two or three Viewports. If quite a few, I
    would consider using a script in a User button, if I had this task to do.

    Hopefully this would be the only instance where this is necessary.

    Otherwise, I would recommend some training for whoever is doing this.

    Without Lisp...

    Starting from Paper Space;

    Double-click in 1st Viewport;

    LMAN;

    Save a JUNK state with them all frozen in the viewport;

    Close LMAN;

    LAYER;

    Thaw all in the Current Viewport;

    Close Layer Manager;

    Purge.

    Repeat until you have done all the Viewports.

    Now you might see why I recommend a Button Script.

    HTH

    --
    Don Reichle
    "King Of Work-Arounds"
    Barghausen Consulting Engineers
    Kent, WA USA
    LDT3 - SP1/CD3 - SP1
    On WIN2K SP4
    Dell 1.6 Ghz P4
    512MB RAM
    NVIDIA 32MB AGP
     
    Don Reichle, Dec 23, 2004
    #4
  5. It appears that vla-delete will remove layers that
    are unreferenced but frozen in a viewport. Kinda
    handy.
     
    Jason Piercey, Dec 27, 2004
    #5
  6. yavid

    tstright Guest

    Picked this up somewhere....
    Use with Care.

    ;PLA-deletes all entities on frozen or off layers and purges everything
    (defun C:pLA (/ cmde tmod llst la lnam lfrz loff)
    (setq cmde (getvar "cmdecho")
    tmod (getvar "tilemode")
    llst ""
    la (tblnext "layer" T))
    (setvar "cmdecho" 0)
    (while la
    (setq lnam (cdr (assoc 2 la))
    lfrz (= (logand (cdr (assoc 70 la)) 1) 1)
    loff (minusp (cdr (assoc 62 la))))
    (if (or lfrz loff)
    (progn
    (if (setq ss (ssget "x" (list (cons 8 lnam))))
    (command "_.-layer" "_u" lnam ""
    "_.erase" ss ""))
    (setq llst (strcat lnam "," llst)
    la (entget (tblobjname "layer" lnam))
    la (subst '(70 . 0)(assoc 70 la) la))
    (entmod la)))
    (setq la (tblnext "layer")))
    (if (> llst "")
    (command "_.tilemode" 0
    "_.vplayer" "_t" llst "_a" ""))
    (repeat 3
    (command "_.purge" "_a" "*" "_n"))
    (setvar "cmdecho" cmde)
    (setvar "tilemode" tmod)
    (princ)
    )
     
    tstright, Dec 28, 2004
    #6
  7. yavid

    yavid Guest

    Is there a way to tweak this LISP so it will not delete entities on frozen layers? I need a LISP that will purge out the layers that do not contain entities but are frozen in VP. The layers frozen in VP that do contain entities must be left unchanged (not purged, not thawed).
     
    yavid, Dec 29, 2004
    #7
  8. yavid

    T.Willey Guest

    Try this. It will thaw all layers that have nothing on them in all viewports so you can purge them out.

    Tim

    (defun ThawVPLayers (/ ss Ent temp1 LayList)

    (setq ss (ssget "x" '((0 . "VIEWPORT"))))
    (while (setq Ent (ssname ss 0))
    (setq temp1 (entget Ent))
    (foreach item temp1
    (if (= (car item) 331)
    (setq LayList (cons (cdr (assoc 2 (entget (cdr item)))) LayList))
    )
    )
    (ssdel Ent ss)
    )
    (foreach item LayList
    (if (not (setq ss (ssget "x" (list (cons 8 item)))))
    (command "_.vplayer" "_t" item "_a" "")
    )
    )
    )
     
    T.Willey, Dec 29, 2004
    #8
  9. Try this:

    (defun c:removeUnreferencedLayers ()
    (vlax-for
    item
    (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (vl-catch-all-apply 'vla-delete (list item))
    )
    (princ "\nunreferenced layers have been removed")
    (princ)
    )

    --
    Autodesk Discussion Group Facilitator



    layers? I need a LISP that will purge out the layers that do not contain
    entities but are frozen in VP. The layers frozen in VP that do contain
    entities must be left unchanged (not purged, not thawed).
     
    Jason Piercey, Dec 29, 2004
    #9
  10. yavid

    James Allen Guest

    I believe I discovered recently that it will even get those frozen in a
    viewport (a2k5), but I'm not at work today so I can't verify.
     
    James Allen, Dec 31, 2004
    #10
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.