Getting Layer Names Out of DWGs (Batch, Fastest)

Getting Layer Names Out of DWGs (Batch, Fastest)

Anonymous
Not applicable
2,004 Views
7 Replies
Message 1 of 8

Getting Layer Names Out of DWGs (Batch, Fastest)

Anonymous
Not applicable

Please bear with me, I know a similar question has been asked hundreds of times.

 

I'm looking for the fastest way to get a list of layers from hundreds of DWGs.

 

We manage our layers and their properties via excel out of necessity. We have hundreds of sheets that contain on average 2600 layers (99% of which are coming from XREFs). These roughly 150 XREFs are being continually updated, almost daily; layers are added/removed/deleted etc. In total we are dealing with roughly 12,000 unique layers.

 

Currently we rely on custom LISP routines and VBA (Excel) to keep on top of this mess. My question is: Outside of .NET, is there any way to get a complete list of layers out of a DWG without having to open and close every file?

 

I keep going in circles trying to figure out if VBA can actually read an acaddatabase without physically opening the file, I know I can in .NET but that is not an option.

0 Likes
Accepted solutions (1)
2,005 Views
7 Replies
Replies (7)
Message 2 of 8

pbejse
Mentor
Mentor

@Anonymous wrote:

 

...We manage our layers and their properties via excel out of necessity. We have hundreds of sheets that contain on average 2600 layers (99% of which are coming from XREFs). These roughly 150 XREFs are being continually updated, almost daily; layers are added/removed/deleted etc. In total we are dealing with roughly 12,000 unique layers.

 

Currently we rely on custom LISP routines and VBA (Excel) to keep on top of this mess. My question is: Outside of .NET, is there any way to get a complete list of layers out of a DWG without having to open and close every file?

 


In what format do you want the layer list? And after retrieving the layers what are you intending to do with it? 

 

YES using ObjectDBX

Message 3 of 8

dbroad
Mentor
Mentor

"is there any way to get a complete list of layers out of a DWG without having to open and close every file?"

 

No. If you don't open the file in some fashion, you can't see what's in it.  You could roll your own program to open and read the database directly, but I would prefer to use Scriptpro with the Accoreconsole. That would still have to open every file but wouldn't need to alter its file modified date. Since Accoreconsole has no graphical interface, its much faster to process drawings than ObjectDBX.

 

If you include the drawing modified date with your data, you could just check that a drawing hasn't changed and skip over it.

 

Personally though, I think that 2600 layers per drawing is insane.  I would recommend rethinking your layer strategy.  When the process becomes more complex than its benefits, the process should be re-imagined.

Architect, Registered NC, VA, SC, & GA.
Message 4 of 8

pbejse
Mentor
Mentor

@Anonymous wrote:

"is there any way to get a complete list of layers out of a DWG without having to open and close every file?"

 

No. If you don't open the file in some fashion, you can't see what's in it. 


I guess you're right when you put it that way.


.Since Accoreconsole has no graphical interface, its much faster to process drawings than ObjectDBX.

 


Certainly worth looking into. My only experience with Accoreconsole was batch processing dwg to pdfs' running in command line (cmd).

 

 

 

0 Likes
Message 5 of 8

Anonymous
Not applicable

Thanks for the response.

 

I was looking for a solution for loading the database or DWG into memory. I know it's possible via .NET by utilizing 'side loading' or 'side database' workflows, and I know Autodesk's own tools like the reference editor can read into a file with opening it.

 

I did find Lee-Mac's layer extractor lisp routine, which does exactly what I want, I just tears through files, seemingly without opening them. I believe it's utilizing ObjectDBX but I haven't dug into the code yet. I hope to modify it to fire directly from Excel bypass the interface.

 


dbroad wrote: 

Personally though, I think that 2600 layers per drawing is insane.  I would recommend rethinking your layer strategy. 


 

Regarding the layers, I completely agree. Unfortunately our projects are big (think major civil infrastructure), and have hundreds of people working across a dozen disciplines from dozens of companies/entities/sub-contractors etc. We only have control over very small portions of the CAD work that ends up on our sheets.

0 Likes
Message 6 of 8

Anonymous
Not applicable

Thanks for your response.

 

Any text based format is fine, plain text, CSV, XML. I can read or parse through it later. After getting the layers I will plug them into my VBA layer manager to track/find/update everything so there are no surprises during my next bi-weekly plot.

 

As I mentioned in my response to dbroad, I found Lee-Mac's tool which has great promise. I just need to open the hood and look around.

0 Likes
Message 7 of 8

pbejse
Mentor
Mentor

@Anonymous wrote:

 

... As I mentioned in my response to dbroad, I found Lee-Mac's tool which has great promise. I just need to open the hood and look around.


Holler if you need assistance.

 

0 Likes
Message 8 of 8

Anonymous
Not applicable
Accepted solution

I have my solution, it's not perfect but it's a major improvement. Thanks pbejse and dbroad

 

I'm using ObjectDBX and controlling any Autocad instance from Excel, cutting out the middle man.

 

Set acad = CreateObject("AutoCAD.Application")
acad.Visible = False

Set doc = acad.getinterfaceobject("ObjectDBX.AxDbDocument.20")

doc.Open ("C:\....dwg")

For Each iLayer In doc.Layers
  Debug.Print iLayer.Name
Next iLayer

{etc.}

I'm getting thousands of layers from hundreds of files in seconds, straight into my Excel manager. I used to have to run it overnight.

 

Cheers!