broncos15 Posted May 4, 2016 Posted May 4, 2016 So I have a LISP routine that I wrote that will purge all the styles in a drawing, then purge everything else that I am able to, then will wblock out the drawing and save over the existing drawing. The last step that I am wanting to add is to get rid of the layers that are still left after the wblock but that don't have any objects on them. I now that if I use the laymrg command I can accomplish this easily by just having all the unused layers merged with layer 0. My issue is that I can't think of the most efficient way to find if a layer is "empty". I was going to just use ssget and iterate through every layer in the drawing, and if the selection set is null, then laymrg with layer 0. This seems like it is really inefficient though, so I was wondering if anyone has any other suggestions on how to do this. Quote
David Bethel Posted May 4, 2016 Posted May 4, 2016 Some layers can be very difficult to purge An empty layer that is refernced only in a viewport ( xdata ) VPLAYER settings An empty created with a SEQEND entity An empty layer in a referenced block Owen has written and maintained a robust routine over the years: https://www.manusoft.com/software/superpurge.html It may be useful. -David Quote
rkmcswain Posted May 4, 2016 Posted May 4, 2016 Although @David makes some good points, I don't think @broncos15 cares about those scenarios. LayMrg will handle those cases just fine. So back to [the most efficient way to find if a layer is "empty".]...... where "empty" means no normal geometry. Although this is for .NET code, the article and comments might give you some ideas: http://through-the-interface.typepad.com/through_the_interface/2008/05/finding-all-the.html Quote
BIGAL Posted May 5, 2016 Posted May 5, 2016 You have a problem with Civ3D styles that it will link to a layer even if its not used. Are you doing a PURGESTYLES before purge ? A better option 2019 ? would be define a layer to use but not exist till actually used in CIV3D. Quote
broncos15 Posted May 5, 2016 Author Posted May 5, 2016 rkmcswain, thank you for the article, that was very helpful! I am going to see how I can apply those concepts to LISP. BigAL, yes I am doing the purgestyles before the purge. How do you define a layer to use in a template file but not have it exist until it is actually used? I am running 2015, is it possible in this version? This seems like a much better practice to apply to the template file and it would definitely help negate the need to do such a "deep" purge. Quote
broncos15 Posted May 5, 2016 Author Posted May 5, 2016 I realized that another thing that I need to consider is whether the layer is in an xref or if it is in the drawing. This is getting a little more complicated than I first thought haha. Quote
marko_ribar Posted May 5, 2016 Posted May 5, 2016 (edited) Xref layers shouldn't have to have impact on normal layers in DWG... Just recently I wrote lisp for checking for nested layers in DWG... You can change routine to iterate through all (ai_table "LAYER" 4) list of layers and if modified routine as sub function returns nil, you can set that layer for LAYMRG with 0 Layer... Lisp can be found here : http://www.cadtutor.net/forum/showthread.php?96685-Nested-layer-located-in-which-block&p=#6 [EDIT : (ai_table "LAYER" 4) should give you correct list of Layers not including Xref Layers... Look here for more info : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ai-table-parameters/m-p/1547150/highlight/true#M203243 ] HTH, M.R. Edited May 5, 2016 by marko_ribar Quote
broncos15 Posted May 5, 2016 Author Posted May 5, 2016 Xref layers shouldn't have to have impact on normal layers in DWG... Just recently I wrote lisp for checking for nested layers in DWG... You can change routine to iterate through all (ai_table "LAYER" 4) list of layers and if modified routine as sub function returns nil, you can set that layer for LAYMRG with 0 Layer... Lisp can be found here :http://www.cadtutor.net/forum/showthread.php?96685-Nested-layer-located-in-which-block&p=#6 [EDIT : (ai_table "LAYER" 4) should give you correct list of Layers not including Xref Layers... Look here for more info : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ai-table-parameters/m-p/1547150/highlight/true#M203243 ] HTH, M.R. Thanks Marko, this is a great starting point! Also, thanks for the link, that was super useful to know what the parameters for ai_table all do. Quote
BIGAL Posted May 6, 2016 Posted May 6, 2016 Broncos15 we got round the layer exist by in one proprietry package but it used customisation so when you drew an object it went on a layer defined within a text file that was set for that type of object. As you drew layers were added. Quote
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.