Author Topic: layer filters  (Read 6560 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
layer filters
« 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)
)

daron

  • Guest
layer filters
« Reply #1 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.

danny

  • Guest
layer filters
« Reply #2 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.

daron

  • Guest
layer filters
« Reply #3 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.

ronjonp

  • Needs a day job
  • Posts: 7529
layer filters
« Reply #4 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

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
layer filters
« Reply #5 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!!")
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

SMadsen

  • Guest
layer filters
« Reply #6 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!

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
layer filters
« Reply #7 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 .....................
TheSwamp.org  (serving the CAD community since 2003)

Andrea

  • Water Moccasin
  • Posts: 2372
layer filters
« Reply #8 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 !!
Keep smile...

megamike

  • Guest
Re: layer filters
« Reply #9 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!

whdjr

  • Guest
layer filters
« Reply #10 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?

MikePerry

  • Guest
layer filters
« Reply #11 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

whdjr

  • Guest
layer filters
« Reply #12 on: February 02, 2005, 01:38:26 PM »
Thanks for the clarification Mike.

sinc

  • Guest
layer filters
« Reply #13 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.

whdjr

  • Guest
layer filters
« Reply #14 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.