Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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

Posted

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.

Posted

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.

Posted

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.

Posted (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 by marko_ribar
Posted
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.

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...