NOT purging layers

Discussion in 'AutoCAD' started by andy drafter, Nov 30, 2004.

  1. andy drafter

    andy drafter Guest

    I'd like to be able to purge an entire drawing without deleting layers that have no objects. These layers may be used later in the drawing and I don't want to have to retype in layer names etc.

    I know I can be selective and not delete certain layers when purging but I'm wondering if there is a way to set up a drawing with protected layers so you can't delete them when you "purge all" even if they don't have objects.
     
    andy drafter, Nov 30, 2004
    #1
  2. andy drafter

    Paul Turvill Guest

    There are several ways. A layer won't be purged if it is "referenced" by an
    entity in a drawing. One way would be to create a (possibly dummy) viewport
    that has all layers "frozen in current viewport"; any layer that is frozen
    in one or more viewports is "referenced" and therefore not elegible for
    purging.
    ___
     
    Paul Turvill, Nov 30, 2004
    #2
  3. andy drafter

    C Witt Guest

    attached a bit of code that was given to me in the customization group
    months ago.. now i give it to you.

    ;;;Layer Purge
    ; the 3rd line of the code contains the list of layers that will NOT be purged
    (defun c:newlaypurge ()
    (setq all_layers (mapcar (function (lambda (i) (strcase i)))(ai_table "layer" 0)))
    (setq keep_layers (mapcar 'strcase (list "text" "pl" "el" "contours" "ant" "steel" "eq" "ha" "grid" "tree" "tray" "gnd" "power" "bolts" "fence" "vp" "0")))
    (or thisdwg (setq thisdwg (vla-get-activedocument (vlax-get-acad-object))))
    (foreach layname all_layers
    (if (not (vl-position layname keep_layers))
    (if (not (vl-catch-all-error-p (setq layer2 (vl-catch-all-apply 'vla-item (list (vla-get-layers thisdwg) layname)))))
    (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list layer2)))))))
    )
     
    C Witt, Nov 30, 2004
    #3
  4. andy drafter

    andy drafter Guest

    Thanks, er.........where do I put this nifty piece of code? In fact, where can I find out EXACTLY how to manipulate this code?

    Thanks again.
     
    andy drafter, Nov 30, 2004
    #4
  5. andy drafter

    Dave Jones Guest

    that have no objects. These layers may be used later in the drawing and I
    don't want to have to retype in layer names etc.
    I'm wondering if there is a way to set up a drawing with protected layers so
    you can't delete them when you "purge all" even if they don't have objects.

    all good ideas given by others but another thought is to not worry about it
    and have a simple routine to restore all of your standard layers with the
    push of a button, or in my case RL (restore layers) on the keyboard. I hard
    purge everything when archiving drawings and often have the need to restore
    my standard layers purged during the process while doing revisions. I have a
    routine that checks for layer names and recreates them if they don't exist.
    Loads the proper linetypes, sets non plotting layers, etc. I'd be happy to
    share it if you would like it.
    Dave
    DDP
     
    Dave Jones, Nov 30, 2004
    #5
  6. andy drafter

    Stephen R Guest

    That sounds like a useful routine. What version autocad is it written for?

    Stephen R.
     
    Stephen R, Nov 30, 2004
    #6
  7. andy drafter

    Tom Smith Guest

    I hard purge everything when archiving drawings and often have the need to
    restore my standard layers purged

    I agree that having a standard-layer-fixing tool is handy, and I also use
    one for restoring layers in old drawings that have been excessively purged.
    But another way of looking at it is: why purge the layers anyway? Maybe the
    OP is leaning toward a more direct solution of not purging layers in the
    first place.

    A lot of people are adamant (not to say compulsive) about "hard purging"
    everything, but I don't know how often they really analyze what they're
    doing. Unused blocks can obviously contribute to grossly inflated file
    sizes. But none of the other purgeable items normally have any significant
    effect on file size or performance.

    We have an "empty" standard drawing which contains all of out standard
    layers (just over 40), a couple of text styles, the few linetypes we use,
    our two dimstyles, and so forth. It's 33.5K in size. Purging out the 40
    layers down to just layer "0" reduces it to 32.3K -- a grand total of 1.2K
    saved by purging. So an unused layer seems to contribute around 30 bytes to
    a drawing file. It takes several dozen of them to total a kilobyte. For an
    average completed drawing, a 1K difference in file size just doesn't matter
    to me. There's been considerably more difference than that from one version
    of Acad to the next.

    Given the negligible effect on file size, I don't think it's really worth
    anybody's time to purge layers at all, especially when there's a
    corresponding need to be able to restore them later. I advise our users to
    purge unused blocks, and to just not worry about anything else.
     
    Tom Smith, Nov 30, 2004
    #7
  8. andy drafter

    Dave Jones Guest

    I hard purge simply for the simpilicity and speed of it. 90%+ of my archived
    drawings will never be seen again so only occasionally do I need to restore
    any defaults.
    Dave
     
    Dave Jones, Nov 30, 2004
    #8
  9. andy drafter

    Dave Jones Guest

    originally 2000 and now works fine in 2005
    Dave
     
    Dave Jones, Nov 30, 2004
    #9
  10. andy drafter

    Tom Smith Guest

    Convenience definitely matters. In earlier versions we used a PUA (purge
    all) macro that ran the command-line version of purge several times.
    However, historically, at the same time the dialog came along which made the
    "all" option easier, there was also a new bug introduced.

    In 2000i, we had continual sporadic cases of drawing corruption which traced
    back to an intermittent bug in purging dimstyles. The drawings were always
    recoverable, but it was a major annoyance. The corruption wasn't bad enough
    to trigger an automatic recovery, just bad enough to make the drawing crash
    without warning. We skipped 2000 and 2002, so I don't know which other
    versions had the same bug. As long as you didn't purge dimstyles, no
    problem.

    Therefore I told our users to stop using the "all" option and just purge
    blocks. The nifty "purge all" button had cost quite a few hours in "help
    desk" time and lost drafting time without gaining us any discernible
    benefit.

    Purging blocks is still a one-button operation, just with a different option
    selected. I haven't seen the dimstyle purging bug in 2004, but still see no
    reason to change my instructions to the users. The only real reason to purge
    is to save file space, and blocks are the only purgeable item that makes any
    difference in that regard.
     
    Tom Smith, Nov 30, 2004
    #10
  11. andy drafter

    C Witt Guest

    the only bit of code that you "should" need to change is noted in the
    lsp file.. is there another part you wanted to change?

    as to were to put it.. you can either place it in a file called
    acad.lsp (in one of your support paths, listed in cad).. or put the file
    I gave you, in one of those paths and have it auto loaded (via one of
    your companies other lisp files (if you use lisp files). or a very
    basic per use method of "drag and drop" the file into cad (whenever you
    want to use it).

    if you do a search of the customization newsgroups you should be able to
    find more than enough documentation on the first two methods.
     
    C Witt, Nov 30, 2004
    #11
  12. Reducing file size is not the only reason to purge a drawing. I personally,
    would rather not sift through 200 layers in the dialog box when only 40 are
    used. Same with dimension styles, text styles etc.

    Another reason may be proprietary blocks / information that you don't want
    to send when you distribute the files. (Engineers stamps etc...)

    Now if only purge included layer filters as an option... that can also
    reduce file size substantially. (for now I'll stick with my lisp)

    Just my 2 cents

    Casey
     
    Casey Roberts, Nov 30, 2004
    #12
  13. Dave,

    Would you post that routine? I think that would be something we could use
    here to standardize our drawings or so guys aren't asking things like "What
    kind of line do we use for contours?..." all the time.

    Thanks in advance....

    Rob

    "Make the rest of your life the best of your life."
     
    Robert Crenshaw, Dec 3, 2004
    #13
  14. andy drafter

    Dave Jones Guest

    here ya go...not elegant but it works :)
    Dave

    (defun C:RL ()

    (setq savcmd (getvar "CMDECHO"))
    (setq savlay (getvar "CLAYER"))
    (setvar "CMDECHO" 0)

    ;load required LTYPEs if not already loaded
    (if (not (tblsearch "LTYPE" "CENTER"))
    (command "LINETYPE" "LOAD" "CENTER" "" "")
    );end if
    (if (not (tblsearch "LTYPE" "HIDDEN"))
    (command "LINETYPE" "LOAD" "HIDDEN" "" "")
    );end if

    ;check to see if the layer exists and if not create it
    (defun create_layer (layr color on_off lttype / layr color on_off lttype)
    (cond
    ((=(tblobjname "layer" layr) nil)
    (entmake
    (list
    '(0 . "LAYER")
    '(100 . "AcDbSymbolTableRecord")
    '(100 . "AcDbLayerTableRecord")
    (cons 2 layr)
    (cons 70 on_off)
    (cons 62 color)
    (cons 6 lttype)
    )
    )
    );END EQ
    (T
    (setq layr(entget(tblobjname "layer" layr))
    layr(subst(cons 62 color)(assoc 62 layr)layr)
    layr(subst(cons 70 on_off)(assoc 70 layr)layr)
    layr(subst(cons 6 lttype)(assoc 6 layr)layr))
    (entmod layr)
    (entupd (cdr(assoc -1 layr)))
    );end t
    );end cond
    (princ)
    );end create_layer

    ;Layer list
    (defun RestoreLayers ()
    (create_layer "ALUM" 15 0 "CONTINUOUS")
    (create_layer "BORDER" 5 0 "CONTINUOUS")
    (create_layer "CENTER" 9 0 "CENTER")
    (create_layer "CLAD" 161 0 "CONTINUOUS")
    (create_layer "CONST" 2 0 "CONTINUOUS")
    (create_layer "CW" 7 0 "CONTINUOUS")
    (create_layer "DIMN" 7 0 "CONTINUOUS")
    (create_layer "ELEV" 220 0 "CONTINUOUS")
    (create_layer "FAST" 4 0 "CONTINUOUS")
    (create_layer "GLS" 1 0 "CONTINUOUS")
    (create_layer "GRID" 54 0 "CONTINUOUS")
    (create_layer "GSKT" 1 0 "CONTINUOUS")
    (create_layer "HATCH" 9 0 "CONTINUOUS")
    (create_layer "HIDDEN" 9 0 "HIDDEN")
    (create_layer "NOTES" 120 0 "CONTINUOUS")
    (create_layer "PARTNO" 3 0 "CONTINUOUS")
    (create_layer "PLAN" 230 0 "CONTINUOUS")
    (create_layer "SEAL" 20 0 "CONTINUOUS")
    (create_layer "SECT" 240 0 "CONTINUOUS")
    (create_layer "STEEL" 185 0 "CONTINUOUS")
    (create_layer "SYMBOL" 123 0 "CONTINUOUS")
    (create_layer "VIEWPORT" 7 0 "CONTINUOUS")
    (create_layer "WP" 1 0 "CONTINUOUS")
    (create_layer "WW" 4 0 "CONTINUOUS")
    );end defun RestoreLayers

    (RestoreLayers)

    ;set no plot layers
    (command "LAYER" "S" "VIEWPORT" "P" "NO" "VIEWPORT" "")

    (setvar "CMDECHO" savcmd)
    (setvar "CLAYER" savlay)
    (princ)
     
    Dave Jones, Dec 3, 2004
    #14
  15. andy drafter

    Tom Smith Guest

    Reducing file size is not the only reason to purge a drawing.

    We're kind of weaving around the original topic. I was replying to a post
    about "hard purging" when archiving a finished project. At that point in
    time, usability issues don't really matter, and file size would seem to me
    to be the only real issue.

    I also referred to in-progress purging issues we have had. Some of our
    users, working on very large drawings, had a tendency to copyclip and paste
    vast amounts of stuff, grossly inflating their file sizes with temporary
    blocks. When performance slowed to a crawl, they were prone to hit the purge
    "all" button, for simplicity, and this had some very undesirable side
    effects. Such as the file corruption bug I mentioned, and the elimination of
    standard layers that hadn't been used yet. Thus I advised them to restrict
    their purging to blocks only. This fixes the size/performance problem
    without causing fresh problems. The purge bug seems to have gone away in
    A2K4 but I haven't seen a reason to change my advice.
    when only 40 are used. Same with dimension styles, text styles etc.

    As I said in an earlier post, we don't have that issue. Our template
    "contains all of out standard layers (just over 40), a couple of text
    styles, the few linetypes we use, our two dimstyles, and so forth." In the
    final analysis, there are never more than 5 or 6 layers to purge anyway, if
    that. The other items are nearly always used, though once in a while there
    might be a single purgeable linetype. So sifting through stuff isn't a
    problem for us.

    Different folks have different needs. We're lucky in that our setup is
    blissfully simply. I understand that having too much unused clutter in a
    drawing makes it unworkable. But bear in mind, the original question came
    from someone who WANTS to preserve the layers he hasn't used yet. I'd assume
    that he also has a relatively simple layering system.

    I'd think that if you're routinely creating drawings in which 80% of the
    layers aren't needed, and the same is true of other table entry items, then
    maybe a different approach might be in order. That would seem pretty
    cumbersome to me too. But there's still the question, how do you know when
    you've used every layer you're going to need, so it's safe to purge all the
    others?

    There have been a number of threads on the same subject, and one person has
    repeatedly trumpeted an ObjectDBX system whereby you can import from a
    master file only the set of layers which you need in your present drawing.
    There's a demo in the CF group. It's all too complicated for me, since I
    have no need of such a thing, but sounds like it would be useful for those
    that do.
     
    Tom Smith, Dec 3, 2004
    #15
  16. andy drafter

    Cad Dept Guest

    I forgot were I learned about CDGpurge but I found the following at
    http://new.cadalyst.com/newsline/issue.cfm?issue=200241

    It works great and I highly recommend it.


    9. TOOL HELPS WITH DRAWING CLEANUP
    The August and September AutoCAD Clinic discussed how to purge unwanted
    layer filters. Joel Roderick wrote in with his solution, CDG Purge,
    which removes all layer filters, layer states, page setups, and
    unreferenced registered applications, using a dialog similar to the
    standard AutoCAD purge command. CDG Purge is free with no restrictions at:
    http://www.caddevelopmentgroup.com/downloads/CDGPurge11_Install.exe
     
    Cad Dept, Dec 3, 2004
    #16
  17. andy drafter

    spectrefish Guest

    Why not purge your drawings then just drag and drop the layers you need from the design center? Seems a lot easier to me.
     
    spectrefish, Dec 8, 2004
    #17
  18. andy drafter

    andy drafter Guest

    I was recently turned on to that. I had not been using design center. I suppose you mean to drag the layers from another file that has my standard layers already-or a template file?
     
    andy drafter, Dec 8, 2004
    #18
  19. andy drafter

    spectrefish Guest

    Yes that is exactly what I mean. I have a drawing set up that has all of my layers, dimstyles, tablestyles, linetypes, etc. and all I need to do is drag and drop. Takes but a split second to get what I need.
     
    spectrefish, Dec 8, 2004
    #19
  20. andy drafter

    Dave Jones Guest

    my layers, dimstyles, tablestyles, linetypes, etc. and all I need to do is
    open ADC
    assuming your template drawing is open
    click on Layers, select the ones you want...drag and drop
    click on Dimstyles, select the ones you want...drag and drop
    click on Tablestyles, select the ones you want...drag and drop
    click on Linetypes, select the ones you want...drag and drop
    etc...

    seems like much more than a split second to me. Here I type RA (restoreall)
    on the keyboard and hit enter to accomplish the above. Don't have to have a
    secondary drawing open. Now that's a split second. Toolbars, pallettes, and
    drop downs are for slow pokes :)
    Dave
    DDP
     
    Dave Jones, Dec 8, 2004
    #20
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.