TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: danny on October 13, 2004, 02:33:08 PM

Title: layer filters
Post by: danny on October 13, 2004, 02:33:08 PM
I received this code from a coworker of mine and it reduced my drawing from 893kb to 200kb.  I don't know much about layer filters or what this routine is doing to the drawing that reduces its size so much.  Can anyone explain..
appreciate the help
Code: [Select]
(defun C:LayerFiltersDelete ()
  (vl-Load-Com)
  (vl-Catch-All-Apply
    '(lambda ()
       (vla-Remove (vla-GetExtensionDictionary
                     (vla-Get-Layers
                       (vla-Get-ActiveDocument
                         (vlax-Get-Acad-Object))))
         "ACAD_LAYERFILTERS")))
  (princ "\nAll layer filters have been deleted.")
  (princ)
)
Title: layer filters
Post by: daron on October 13, 2004, 04:49:37 PM
Layer filters take up memory. You've run into some drawings that obviously take up a lot. I've seen this recently too. What this function is doing is removing all layer filters. To find them, go to the layer dialog and you should see a pull-down in the upper left corner. This is where they are stored.
Title: layer filters
Post by: danny on October 13, 2004, 05:57:51 PM
thanks Daron,
From looking at these filters, I see no purpose in having them.  Should running this routine become a standard of mine?  Would you see any purpose in keeping any of the filters.
Title: layer filters
Post by: daron on October 14, 2004, 08:35:46 AM
Only ones you create, should you keep. Also, any xref's create their own and can't be erased unless you remove the xref. I personally have it loaded and executed with every drawing that gets opened. Saves a big headache.
Title: layer filters
Post by: ronjonp on October 14, 2004, 09:53:40 AM
Quote
I personally have it loaded and executed with every drawing that gets opened.


Me too.  :D
Title: layer filters
Post by: V-Man on October 14, 2004, 01:43:29 PM
I do the same. We get drawings from other firms and who knows what is going on in their drawings. This is a must have and this saves server space. I also use the following to get rid of layer states in drawings. The following is what I have run everytime I open up any drawing.

Code: [Select]

(setvar 'isavebak 1) ;<- makes sure a .bak file is created
(setvar 'isavepercent 0) ;<- creates a full save every time
(setvar 'savetime 10) ;<- sets autosave to 10 minutes
(setvar 'savefilepath (getvar "dwgprefix")) ;<- sets savepath to opened current drawing location

 (vl-Load-Com)
 (vl-Catch-All-Apply '(lambda () ;;; Purge/delete all layer states
    (vla-Remove (vla-GetExtensionDictionary
                  (vla-Get-Layers
                   (vla-Get-ActiveDocument
                      (vlax-Get-Acad-Object)))) "ACAD_LAYERSTATES")))
(princ "\nAll Layer States have been deleted!!")

 (vl-Catch-All-Apply '(lambda () ;;; Purge/delete all layer filters
                       (vla-Remove (vla-GetExtensionDictionary
                         (vla-Get-Layers
                          (vla-Get-ActiveDocument
                           (vlax-Get-Acad-Object)))) "ACAD_LAYERFILTERS")))
 (princ "\nAll Layer Filters have been deleted!!")
Title: layer filters
Post by: SMadsen on October 14, 2004, 02:04:16 PM
This is what I have:
Code: [Select]
(setq dwgname (strcat (getvar "DWGPREFIX")(getvar "DWGNAME"))
(if (vl-file-delete dwgname)
  (princ "\nYour drawing has been deleted!!")
)

Clean slate. No more layer states or layer filters!

^..is a joke! Don't run it!
Title: layer filters
Post by: Mark on October 14, 2004, 02:22:12 PM
Quote from: SMadsen
This is what I have:
Code: [Select]
(setq dwgname (strcat (getvar "DWGPREFIX")(getvar "DWGNAME"))
(if (vl-file-delete dwgname)
  (princ "\nYour drawing has been deleted!!")
)

Clean slate. No more layer states or layer filters!


wow, that works like a charm.............. err ............... wait a minute......... dang, now where did that dwg go .....................
Title: layer filters
Post by: Andrea on December 01, 2004, 12:04:35 PM
WOW !!  all.

thanks for the quick response...
I appreciate.

it work fine !!!

from 2MB go to 24k !!   :D

I'm happy !!

you'r HOT !!
Title: Re: layer filters
Post by: megamike on February 02, 2005, 09:45:09 AM
Quote from: danny
I received this code from a coworker of mine and it reduced my drawing from 893kb to 200kb.  I don't know much about layer filters or what this routine is doing to the drawing that reduces its size so much.  Can anyone explain..
appreciate the help
Code: [Select]
(defun C:LayerFiltersDelete ()
  (vl-Load-Com)
  (vl-Catch-All-Apply
    '(lambda ()
       (vla-Remove (vla-GetExtensionDictionary
                     (vla-Get-Layers
                       (vla-Get-ActiveDocument
                         (vlax-Get-Acad-Object))))
         "ACAD_LAYERFILTERS")))
  (princ "\nAll layer filters have been deleted.")
  (princ)
)


A quick search on The Swamp just saved me a BUNCH of time!
Thanks Swamp!
Thanks danny!
Thanks to the author of this routine (whoever you are)
 :D It's gonna be a GOOD day!
Title: layer filters
Post by: whdjr on February 02, 2005, 10:34:09 AM
Danny, The problem with layerfilters arises because when you copyclip anything (be it a line, block, or half the dwg) from one dwg to another it copies all the layerfilters and layerstates.  It is not too bad with layerstates as most people don't use them that much, it is a different story with layerfilters.  We were routinely having dwgs with 20,000 to 30,000 layerfilters.  Well I loaded that piece of code into our office mnl file to run at dwg startup, and server storage usage went from 36GB to 25GB over about 30 projects.  WOW!


I'm only on A2K, but I think this is correct so others correct me if I'm wrong, isn't the problem resolved in 2004-5?
Title: layer filters
Post by: MikePerry on February 02, 2005, 12:18:57 PM
Quote from: whdjr
I'm only on A2K, but I think this is correct so others correct me if I'm wrong, isn't the problem resolved in 2004-5?

Hi

From AutoCAD 2004 Layer Filters stopped multiplying from dwg file to dwg file.

Have a good one, Mike
Title: layer filters
Post by: whdjr on February 02, 2005, 01:38:26 PM
Thanks for the clarification Mike.
Title: layer filters
Post by: sinc on February 04, 2005, 02:57:23 PM
Of course, at least in 2004, the layer filter delete button is buggy, so when someone sends you a drawing with 20,000 filters in it, you still need to run something to clean it up.  You can't just delete them all.  The delete button seems to work fine for small numbers of filters, but chokes if there are very many.
Title: layer filters
Post by: whdjr on February 04, 2005, 03:32:29 PM
I wrote a delete tool for A2k that included a dcl file with an option to select certain ones to delete or "Select All" to delete, but the "selection" button would not always return the proper amount of filters and the "Select All" button would return a buffer overrun error.  It had too many items for dcl.  I was told this was a limitation with dcl.
Title: layer filters
Post by: AfricaAD on February 04, 2005, 06:42:28 PM
Quote from: whdjr
I wrote a delete tool for A2k that included a dcl file with an option to select certain ones to delete or "Select All" to delete, but the "selection" button would not always return the proper amount of filters and the "Select All" button would return a buffer overrun error.  It had too many items for dcl.  I was told this was a limitation with dcl.


Sounds similar to CDGPurge.