View Full Version : 2011 Import Layers from Excel
gfreddog
2011-04-25, 03:02 PM
I saw a trick awhile back where you can copy the layers from Layer Manager into Excel...
Has anyone found a way to do it in the other direction?
Thx
rkmcswain
2011-04-25, 03:19 PM
We wrote a lisp routine to do this.
Wanderer
2011-04-25, 05:06 PM
I saw a trick awhile back where you can copy the layers from Layer Manager into Excel...
Has anyone found a way to do it in the other direction?
Thx
Maybe this thread could give you a point in the right direction?
http://forums.augi.com/showthread.php?t=114760
gfreddog
2011-04-25, 06:55 PM
We wrote a lisp routine to do this.
That's what I was thinking of. Then I could keep the XLS as our "standards" so as we change our standard layer compliment I'd only have to edit the XLS and import to the template.
rkmcswain
2011-04-25, 07:00 PM
That's what I was thinking of. Then I could keep the XLS as our "standards" so as we change our standard layer compliment I'd only have to edit the XLS and import to the template.
Yes, exactly. Our routine asks the user a couple of questions, and then the layer list is imported based on those answers, depending on the project type, etc. So we may have 300 layers in the Excel file, but only a portion of those are imported for any given project type. Also, we store the linetype and color in the Excel file, and optionally reset these in the drawing.
gfreddog
2011-04-25, 07:13 PM
Yes, exactly. Our routine asks the user a couple of questions, and then the layer list is imported based on those answers, depending on the project type, etc. So we may have 300 layers in the Excel file, but only a portion of those are imported for any given project type. Also, we store the linetype and color in the Excel file, and optionally reset these in the drawing.
Nice. Is there a generic version you'd mind sharing or can you send it off line?
gfreddog
2011-05-13, 01:16 PM
I tried a couple of ways but did not get the results I needed. I guess this will go to the back burner till I have time to "Play"
BlackBox
2011-05-14, 02:14 PM
I tried a couple of ways but did not get the results I needed. I guess this will go to the back burner till I have time to "Play"
Are you working with .XLS*, or .CSV?
If the former you might look into using (setq XL (vlax-get-or-create-object "Excel.Application")) to drill down to the specific worksheet, and tab, column, etc..
If the latter, a simple open + read-line combo would suffice (provided you implement a "," delineator sub function to extract the layer name, color, linetype, etc. from the line being read).
Without a sample excel file (for file, and data format etc.), and your "test" code, it would be hard to better help you.
gfreddog
2011-05-16, 04:57 PM
I really didn't get too far with a LISP routine yet. I know enough to be dangerous but I am still learning bit by bit.
I attempted a few ways of trying to manually import the attached XLS file.
BlackBox
2011-05-16, 08:26 PM
I really didn't get too far with a LISP routine yet. I know enough to be dangerous but I am still learning bit by bit.
I attempted a few ways of trying to manually import the attached XLS file.
This is the route I'd suggest for your situation:
If the latter, a simple open + read-line combo would suffice (provided you implement a "," delineator sub function to extract the layer name, color, linetype, etc. from the line being read).
Note that there are different variations available, meaning instead of .CSV, you could (for example) use a Tab-Delimited text file (.TXT)... just be sure to include a parse function for your delimiter character.
Also, consider adding in other layer components such as On, Freeze, Lock, Lineweight, and Plot for future customization. Be sure to include a CONDitional statement, or an IF statement to sort "Yes" = :vlax-true, and "No" = :vlax-false for your Layer Item's Property values.
If you have any problems writing this code, stop by the AutoLISP Forum for more help.
If all of this sounds overwhelming, then perhaps it's best that you instead simply include the layers you need into your Template (.DWT).
Good luck!
gfreddog
2011-05-16, 08:34 PM
snip...
If all of this sounds overwhelming, then perhaps it's best that you instead simply include the layers you need into your Template (.DWT).
Good luck!
Basically I have an existing template from the previous manager with 80 incorrect or badly named layers.
I have a new list I created as an Excel.xls file that I would love to be able to import into my Template without having to manually create all 75 layers we will be listing in our Template. To bring it more in compliance with NCS than the previous one.
I was hope to borrow or create a LISP that takes my new XLS into my Template and I can then edit the layers from there.
BlackBox
2011-05-16, 08:39 PM
Basically I have an existing template from the previous manager with 80 incorrect or badly named layers.
I have a new list I created as an Excel.xls file that I would love to be able to import into my Template without having to manually create all 75 layers we will be listing in our Template.
I was hope to borrow or create a LISP that takes my new XLS into my Template and I can then edit the layers from there.
Perhaps I'm overlooking something, but it sounds to me like you're making it a lot harder on yourself than it needs to be.
If you've already got a template, and only 13 additional / replacement layers (posted in your .XLS file) then edit the template manually (after you make a backup copy) and be done with it.
What am I missing?
BlackBox
2011-05-16, 08:45 PM
Layer Creator LISP Routine (http://www.cadtutor.net/forum/showthread.php?57570-Layer-Creater-Lisp-Routine-Issue)
gfreddog
2011-05-17, 02:29 PM
Perhaps I'm overlooking something, but it sounds to me like you're making it a lot harder on yourself than it needs to be.
If you've already got a template, and only 13 additional / replacement layers (posted in your .XLS file) then edit the template manually (after you make a backup copy) and be done with it.
What am I missing?
My Jersey comes out sometimes and may cause confusion LOL.
Yes I do have 80 already in a template but they all need to be renamed as well. During our meetings we came up with the new scheme we want to use so I need to correct the old and add the new. But since I have an XLS with all the new ones in it I figured I'd love to create a new template with all the correct layers and replace the old template.
gfreddog
2011-05-17, 02:55 PM
Layer Creator LISP Routine (http://www.cadtutor.net/forum/showthread.php?57570-Layer-Creater-Lisp-Routine-Issue)
That might be exactly what I need. I'll play around and let you know how it goes.
Thanks for all the help
BlackBox
2011-05-17, 03:02 PM
That might be exactly what I need. I'll play around and let you know how it goes.
Thanks for all the help
Good luck!
gfreddog
2011-06-21, 07:10 PM
Found a free VLX on Cad Forum called CADstudio CsvLayers (http://www.cadforum.cz/cadforum_en/how-to-create-dwg-layers-from-a-list-in-csv-excel-tip7193)
It takes what ever CSV file you have and makes layers out of it. Nice, neat, quick, and free.
Thank you everyone for your suggestions and help it is greatly appreciated.
cadtag
2011-06-21, 11:25 PM
as a suggestion -- if you are changing layer schemes, include the _old_ layer name at the beginning of the Description. that will make it a tad easier for people to change over.
gfreddog
2011-06-22, 03:56 PM
as a suggestion -- if you are changing layer schemes, include the _old_ layer name at the beginning of the Description. that will make it a tad easier for people to change over.
Great idea Thx
dpardine677842
2014-08-07, 05:41 PM
Great information on this thread but I am new to working with LISPs and Apps and could use some advice.
I am working on a 3d to 4d model (Autocad2014 to Navisworks2014) and need to map 300+ schedule activity ID's to autocad layers to control the file once in navisworks. In Autocad, I have loaded the above referenced CSVLayers application but what do I do from there to make it "go"!
Any insight is appreciated! I very much do not want to manually type these activity ID's :D
BlackBox
2014-08-13, 02:20 PM
Great information on this thread but I am new to working with LISPs and Apps and could use some advice.
I am working on a 3d to 4d model (Autocad2014 to Navisworks2014) and need to map 300+ schedule activity ID's to autocad layers to control the file once in navisworks. In Autocad, I have loaded the above referenced CSVLayers application but what do I do from there to make it "go"!
Any insight is appreciated! I very much do not want to manually type these activity ID's :D
Welcome to AUGI!
If you're using this routine (http://www.cadtutor.net/forum/showthread.php?57570-Layer-Creater-Lisp-Routine-Issue&p=390543&viewfull=1#post390543), then simply format your .CSV file in accordance to the sample attachment in the same post (ArchExist_revised.txt, just change the .txt to .csv)... Excerpt:
Layer Name,Layer Description,Layer Color,Layer Linetype,Layer Lineweight,Layer Plottable,Layer Freeze
A-ANNO,Architectural General Notes_ Key Notes,7,Continuous,ByLayer,Yes,No
...
... Where each layer is on its own line in the .CSV file, then you can import said layers by this from the Command line:
(BB:CSV->Layers "<YourFilePath>\\<YourFileName>.csv")
HTH
cadtag
2014-08-13, 02:48 PM
Also the LAYTRANS command built into Acad for translating layers.....:mrgreen:
BlackBox
2014-08-13, 02:54 PM
Also the LAYTRANS command built into Acad for translating layers.....:mrgreen:
What do you think about the built-in LAYTRANS Command, Dr. Mr. Horse?
https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQgLUxRnIcQuUM73NoEPLS2ktuOFxzp9UV0eypnOreF7Vyhg7xz
... And Dr. Mr. Horse (http://bit.ly/1p61Yfg) is never wrong. :beer:
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.