Exporting Layer Names

Exporting Layer Names

kieran.leadbetter
Advocate Advocate
1,064 Views
6 Replies
Message 1 of 7

Exporting Layer Names

kieran.leadbetter
Advocate
Advocate

Hello, last request and with this as well as the other lisps in progress, it should allow me to effectively tidy up hundreds of drawings, this request is does anyone know of a lisp which can export all the layer names within a drawing, into an excel sheet. If this doesn't work I think I shall give up with my goal to tidy up all these drawings and just tidy them along the way in future.

I intend to run this lisp through all the drawings, merge all the excel sheets together, and then write a command using excel to make the layer names merge to the preferred layer name. 

If its possible to also make the excel sheets all go to a specific folder, that would be immensely helpful as well, Kind Regards

0 Likes
1,065 Views
6 Replies
Replies (6)
Message 2 of 7

kieran.leadbetter
Advocate
Advocate

I do have this lisp by Jimmy Bergmark which works perfect as I can extract the layer names using excel, however this method means I have to manually save each .txt file, open each file and paste each text file into excel, instead of a massive single bulk excel pile which I can merge and tidy that way.

If its possible to automate Jimmy's lisp, I can work with this,

Kind Regards

0 Likes
Message 3 of 7

hak_vz
Advisor
Advisor

Why not change command open in writing to txt file from "w" to "a" and store all layer names to single txt file?

 

 w Open for writing. If filename does not exist, a new file is created and opened. If filename already exists, its existing data is overwritten. Data passed to an open file is not actually written until the file is closed with the close function.

a Open for appending. If filename does not exist, a new file is created and opened. If filename already exists, it is opened and the pointer is positioned at the end of the existing data, so new data you write to the file is appended to the existing data. 

 

 

I hope you know how to make changes and test if the code works correctly.

 

(defun layer-list-fprint (fn / f row col)
  (if (setq f (open fn "w"))..... change "w" to "a"

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 4 of 7

MrJSmith
Advocate
Advocate

Exporting all layer names to excel is quite simple. Do you want them all in the same excel file, same sheet? Same excel file, different sheet name for each drawing? Or a different excel file for every different drawing? 

 

They all would take about the same amount of effort to do while the first one would be the fastest speed wise and the last one slowest (since the PC would have to make hundreds of excel files).

 

Or as others are discussing, would you want them all just in a text file and then you copy paste them into excel? 

0 Likes
Message 5 of 7

Sea-Haven
Mentor
Mentor

Like others getting layer list big tick, write direct to Excel tick, add a new Excel sheet tick, a hundred Excel sheets in one file not sure what your really doing, if its some sort of clean up process better ways to do that. Maybe explain what end goal is.

 

Not sure if acoreconsole supports write to file, for processing a 100 dwg in one go.

0 Likes
Message 6 of 7

kieran.leadbetter
Advocate
Advocate

I've been on this project for several weeks now and slowly making progress, we have thousands and thousands of drawings which have went across different offices and had its drawing standards messed up, so we are needing layers tidied up a lot to match our drawing standards, however doing this manual would takes months of work.

Originally I created a large lisp containing a bunch of possible layer typo's which may occur in the layers, i.e. Layer 'A015 General Text' is merged to A015_GENERAL_TEXT. I got this lisp up to about 10000 possible variants for our 135 Layers, but this became way too long and frustrating to manage.

Secondly I continued to use this merge lisp to get rid of the variants I've already written down, but then I've attempted to remove specific characters such as - & and space to lower variant possibilities, but once again this only does so much.

So my next attempts are to extract all the layer names from all the selected autocad files, import this into excel, then filter the layers down and merge them to the correct layers. I'm efficient with excel so I am sure I would be able to do this just by spamming the formula:

(defun C:LPMERGE1 ()
(if (tblsearch "LAYER" "A016 AREA")(command "-laymrg" "n" "A016 AREA" "" "n" "A016_AREA" "yes"))
(if (tblsearch "LAYER" "A016 AREA_1")(command "-laymrg" "n" "A016 AREA_1" "" "n" "A016_AREA" "yes"))
(if (tblsearch "LAYER" "A016 AREA_2")(command "-laymrg" "n" "A016 AREA_4" "" "n" "A016_AREA" "yes"));etc....
(princ) ;clean exit 
)

 
Other methods I'm attempting with help of others from Autodesk forums is: Remove Suffix's and Prefix's and merge to existing layers if layer name already exists,, change specific characters and merge to existing layers if layer name already exists.

Hope this explains my current task, Kind Regards

0 Likes
Message 7 of 7

Sea-Haven
Mentor
Mentor

As you have double posted making solutions confusing, look at other post, LAYTRANS Multiple Drawings - Autodesk Community - AutoCAD look at write file and use "A" to append to a file that way if you have a lisp dumping layers for each dwg. Then just open in Excel sort etc. You will have your thousands of layers.

0 Likes