woodman78 Posted July 5, 2011 Share Posted July 5, 2011 Is there a way in lisp to delete all layers except the current? Quote Link to comment Share on other sites More sharing options...
Tiger Posted July 5, 2011 Share Posted July 5, 2011 LAYDEL > Name > Highlight all but one with shift-button Sorry, don't know how to translate it to lisp-speek Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 5, 2011 Author Share Posted July 5, 2011 Thanks but not what I was looking for. Need it is lisp-speek!! Quote Link to comment Share on other sites More sharing options...
vnanhvu Posted July 5, 2011 Share Posted July 5, 2011 simple with my lisp + purge command (defun c:EAA () (command "erase" "all" "") (princ)) Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 5, 2011 Author Share Posted July 5, 2011 What lisp is that? Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 5, 2011 Author Share Posted July 5, 2011 I got it but that deletes the current layer too! Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 5, 2011 Author Share Posted July 5, 2011 I got it. I need to lock the layer I want to keep. Thanks. Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 5, 2011 Author Share Posted July 5, 2011 Great I got what I needed. One other thing. How do I invoke the saveas dialog box from Lisp? Quote Link to comment Share on other sites More sharing options...
irneb Posted July 5, 2011 Share Posted July 5, 2011 Call initdia just before sending the saveas command: (initdia) (command "._SAVEAS") Quote Link to comment Share on other sites More sharing options...
vnanhvu Posted July 5, 2011 Share Posted July 5, 2011 First you use command LAYLCK current your layer, and use my code (defun c:EAA () (command "erase" "all" "") (princ)) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 5, 2011 Share Posted July 5, 2011 Why not just use the wblock command, instead of deleting items from your main drawing??? This would also save you the step of saving your main drawing as, then deleting all but what you wanted. Just a thought. LISP: (command "._wblock") Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 5, 2011 Share Posted July 5, 2011 Why not , new Drawing and make layer as required Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 5, 2011 Share Posted July 5, 2011 Why not , new Drawing and make layer as required The OP already has data on the current (Active) Layer, and wants to isolate that data (by deleting all others), and Save As to another drawing (Hence my suggesting wblock). As I understand it, and perhaps I am mistaken, the OP does not want to open a new (emtpy) drawing and create a new layer. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 5, 2011 Share Posted July 5, 2011 The OP already has data on the current (Active) Layer, and wants to isolate that data (by deleting all others), and Save As to another drawing (Hence my suggesting wblock). As I understand it, and perhaps I am mistaken, the OP does not want to open a new (emtpy) drawing and create a new layer. As long as none of anything is clear , we could say everything is possible . ( could be right or wrong ). So Also since mr vnanvhu already given the routine and the OP agreed with it in post No 7 , it means that they have nothing to keep for the current layer while the given codes would erase everything without a permission from anyone . Regards. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 5, 2011 Share Posted July 5, 2011 Yes, there are multiple ways of accomplishing most tasks in AutoCAD, often times even multiple ways programmatically. If the OP's goal is for the current layer's contents be the only occupants within a separate drawing, Erasing everything (except locked layers) and doing a Save As will work. However the simplest solution is to wblock that layer's contents... Same result, less work. Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 6, 2011 Author Share Posted July 6, 2011 I prefer the method I have of delete and saveas. Thanks anyway. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 6, 2011 Share Posted July 6, 2011 I prefer the method I have of delete and saveas. Thanks anyway. No worries; some people prefer to do more work for the same result. Quote Link to comment Share on other sites More sharing options...
irneb Posted July 6, 2011 Share Posted July 6, 2011 Actually, I'd go with RenderMan's suggestion due to more than just less work: Even after the LayDel, you may still have block definitions, styles, registered apps, dictionaries, etc. contained in the drawing. Not all of which can easily be gotten rid of through multiple purges. The WBlock tends to only save the VERY needed data to the new DWG - all in one single command call. E.g.: (command "._wblock" "c:\\NewFileName.dwg" "" "_None" '(0.0 0.0 0.0) (ssget "_X" (list (cons 8 (getvar "CLAYER")))) "") One thing though, that will only export the entities selectable on the current tab. So if you need all the tabs and their contents as well, then you should rather go with the SaveAs method. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted July 6, 2011 Share Posted July 6, 2011 @Irneb - Perhaps I did a poor sales job for wblock; I appreciate your stepping in to clarify the benefits beyond simple efficiency, as I quickly tired of what turned out to be arguing the point. You can only lead a horse to water.... LoL Quote Link to comment Share on other sites More sharing options...
woodman78 Posted July 6, 2011 Author Share Posted July 6, 2011 I get your points about the wblock and I did consider it but I won't be saving the drawing to the same location each time. The user will choose the save location. And I know there are a few guys here who get freaked out by anything that isn't an open or save dialog box. If I was to do wblock could I invoke a dialog to choose the folder to save the drawing to and the drawing name. A bit like saveas? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.