Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Layer manager 1

Status
Not open for further replies.

summajet

Technical User
Jan 5, 2005
33
0
0
US
I am using Autocad 2002 and was wondering if there is a way to delete all of the layer manager in that drawing at one time instead of picking them individually and then erasing them?

Thanks, G.
 
Found the following lisp routine at another forum. The typical request is for a way to delete all layer filters - this seems to cause a lot of large drawing file problems.



Re: Layer Manager - Deleting States
If you're looking to delete all the LMAN layer states, you should be able to
use the following LISP routine:

(defun c:killstates (/ lyr ent)
(while (setq lyr (tblnext "layer" (not lyr)))
(setq ent (entget (tblobjname "layer" (cdr (assoc 2 lyr))) '("RAK")))
(if (and ent (assoc -3 ent))
(progn
(setq ent (subst '(-3 ("RAK")) (assoc -3 ent) ent))
(entmod ent)
) ;progn
) ;if
);while
(princ)
) ;defun c:killstates
 
I appreciate the lisp routine. I am a newbie when it comes to creating lisp routines. Where do i place the lisp routine you posted on my question?

Also what size drawing file does it cause problems?

3 megabyte files and up or lower?

Thnaks, G
 
G,

To use the lisp routine, save it as a text file with a ".lsp" extension, so it will be recognized by AutoCAD as a lisp file. Give it any descriptive name. Save it in your support folder, or make a separate folder to keep routines together. When you load the routine you can browse to its location. To load use the menu, Tools>>Load Application (browse to and select file)>>Load. (You can also use Tools>>AutoLisp>Load). You'll get a message that it loaded sucessfully. Then type "killstates" (without quotes) to run the routine.

I was referring to a differnt routine & different problem regarding file sizes. Having a huge number of Named Layer Filters often makes what should be a small drawing into one that is a megabyte or more larger. Following is the routine for deleting all named layer filters:

(princ "\nType LFD to start")
(defun C:LFD ()
(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))
 
Hi Carl, I followed the instructions in your last post. I copied the lisp routing and placed it in a file w/ the .lsp extension on the end. I opened up autocad and loaded it and typed in killstates and it did nothing. I loaded the killstates routine and I got no results. I appreciate your patience w/ me on this.

G.
 
G.,

Oops, the routine I posted deleted Layer created by Express Tools layer manager. The following routine deletes AutoCAD's layer states:

;;; Purge/delete all layer states
(princ "\nType DSTATES to start")
(defun c:DStates ()
(vl-Catch-All-Apply
'(lambda ()
(vla-Remove (vla-GetExtensionDictionary
(vla-Get-Layers
(vla-Get-ActiveDocument
(vlax-Get-Acad-Object))))
"ACAD_LAYERSTATES")))
(princ)
)
 
I loaded it and i still cannot get it to work. It shows that it was loaded and when i type in the command line- dstates it does nothing.

thanks, G
 
Besides the message that it loaded properly, you should get prompted with;
"Type DSTATES to start"

In 2002 you may need to load a lisp extension(?) with the command:
(vl-load-com)

including parentheses. Hopefully the routine will now work. And add that line to the lisp routine, after the line:

(defun c:DStates ()

I hope this does it, if not we'll keep at it!
 
Hi Carl,
I tried to follow the instructions you offered and it still did not work. I was wondering if you might be able to poss the entire routine again here on tec-tips? If thta does not work maybe you could email it to me.

Thanks, G
 
OK I'll post the entire thing. You didn't say if you get the prompt "Type DSTATES to start"; if you do then it should be loaded fine. Upon running it shows nothing but check your layer States, they should be gone! It does for me anyway, on 2005. Post your email and I'll correspond with you to troubleshoot, if needed.

;;; Purge/delete all layer states
(princ "\nType DSTATES to start")
(defun c:DStates ()
(vl-load-com)
(vl-Catch-All-Apply
'(lambda ()
(vla-Remove (vla-GetExtensionDictionary
(vla-Get-Layers
(vla-Get-ActiveDocument
(vlax-Get-Acad-Object))))
"ACAD_LAYERSTATES")))
(princ)
)
 
I loaded it and opened up a dwg with multiple layers and i typed in dstates and then attempted to pull up the layer manager and it said internal eror and that autocad was aborting.

I am getting an error now. Got any ideas?

G.
 
You know I'm still not sure what you are trying to delete - in the first post you said you wanted to delete "layer manager" (which isn't possible) and in the last you said you have "multiple layers" ( a differnt thing altogether). The 2 routines I posted were for deleting "Express Tools" LMAN Layer States and AutoCAD Layer States. What type are you trying to delete and we'll focus on that.

No I don't know why you're getting an error. You said "loaded it and opened a drawing". You have to first open a drawing then load the routine - not sure what's going on here.....must sleep.....
 
Are you trying to delete empty layers? Have you tried PURGE?
 
I'm running ADT 3.3 with express tools, and was having the same problem with the layer filters. I ran both the "killstates" and the "lfd" routines, and was able to purge a lot of the crap that had accumulated in my drawings. took the file sizes down from 8 mb to 150 kb. Thanks to CarlAK for the help!
 
Hi Jessiem25,

carl gave me the lisp routine and i loaded it but then when i tried to look and see that all the layer manager names were deleted. It crashed autocad. What type of ADT3.3 w/ express tools do? Are they from Autocad or a third party? I work for an Engineering firm and we have had certain Govt. projects get so full og layer manager names that we needed to use parts of a section for new projects and being able to delete all of the layer managers names in the click of a button and loading of a lisp routine makes life easier instead of having to delete each layer manager name one bye one. some of the drawings have in excess of 20 layer manager names. so any input you can give or anyone else would be greatly appreciated.

Thanks,
 
Summajet,

we're using Architectural Desktop 3.3 (no mechanical or civil versions, just the standard ADT), with AutoCAD express tools 2000. If you're using AutoCAD 2002, then the routine should work fine. I got both the DSTATES and LFD routines to work, but the DSTATES one isn't as necessary as the LFD one, at least not in my case. The routine that works the best is the LFD routine below (I've put the instructions that I followed to load the routine, which do work):

(princ "\nType LFD to start")
(defun C:LFD ()
(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))

Copy it into a text file and save it as "LFD.lsp". Save it to the support folder of AutoCAD. When you start up AutoCAD, go to Tools-AutoLisp-Load. Click on the startup suite and add the LFD.lsp file. This will make sure the routine loads each time you open the program. When you open a big drawing, all you need to do is type LFD. I also like to do a "Purge All" afterwards. The LFD lisp unlocks some of the layers that came in with the random layer filters, so you can get rid of even more crap from the drawing. Save it, close it, and when you reopen it, it should be smaller.

20 layer manager filters isn't too bad. I've had upwards of 100, and colleagues of mine have had 4 times as many!

Good luck, and let us know if you get it to work!

p.s. you might want to delete the lisp routines that didn't work and start over with a new one. Make sure you go into the autolisp load menu and remove them from startup suite.
 
Hi Jessiem,
I followed the instreuctions you gave me and when i loaded the lfd lisp routine it said that all layer filters have been deleted. I might be confused as to what i'm trying to accomplish?

I am using the layer manager on the Express tools for Autocad 2002. I am trying to delete the layer manager names and to make it easier to block stuff from one dwg to another. So am i totally confused as to what i need and or is it not working properly?

I appreciate any tips you can offer me.
G
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top