Import form Excel layers to Autocad

Import form Excel layers to Autocad

ahmed.xeng
Advocate Advocate
18,433 Views
25 Replies
Message 1 of 26

Import form Excel layers to Autocad

ahmed.xeng
Advocate
Advocate

Hello Every one

 

Is it Possible to import form Excel layers to Autocad 2021

without using scripts or lisps ?

 

 

 

0 Likes
Accepted solutions (1)
18,434 Views
25 Replies
Replies (25)
Message 2 of 26

chriscowgill7373
Advisor
Advisor

There has been no new feature added to 2021 to accomplish such a task to my knowledge.   Is there a particular reason asl script or lisp is not desirable?


Christopher T. Cowgill, P.E.

AutoCAD Certified Professional
Civil 3D Certified Professional
Civil 3D 2024 on Windows 10

Please select the Accept as Solution button if my post solves your issue or answers your question.

0 Likes
Message 3 of 26

janu319
Advocate
Advocate

If you want to create the layer names in AutoCAD from a list in excel, you can try this, but you have to check the properties of the layers in AutoCAD afterwards.

 

First make the list of layers from excel with each layer separated by a comma(,) like: layer1,layer2,layer3,etc. Then use the command “-Layer”, select “New”, copy paste the list of layers in command line.

 

There are lot of ways to make a list from excel, you can try Concatenate or try Transpose option and then notepad. 

0 Likes
Message 4 of 26

ahmed.xeng
Advocate
Advocate

Thanks a lot  Chris and Janu for replying 

I would like to use concatenate formula in excel but how can I add layer description and Line type

 

I dont really understand the function of this formula i need to how to made this script

 

 

0 Likes
Message 5 of 26

leeminardi
Mentor
Mentor

The following shows how you can use the Excel concatenate command to create layers with a specified line weight and true color (amount of red, green, blue) from Excel data. 

image.png

Char(34) is used to create quote marks when needed in the vlisp command statement to distinguish them from quotes needed by the concatenate function to identify a text string. I found it tricky to find a way to terminate the layer function but found that two char(34)'s did the trick.

 

Here is the contents of cell G2. 

=CONCATENATE("(command ",CHAR(34),"-layer",CHAR(34)," ",CHAR(34),"m",CHAR(34)," ",CHAR(34),A2,CHAR(34)," ",CHAR(34),"LW",CHAR(34)," ",CHAR(34),B2,CHAR(34)," ",CHAR(34),CHAR(34)," ",CHAR(34),"c",CHAR(34)," ",CHAR(34),"t",CHAR(34)," ", CHAR(34),C2,",",D2,",",E2,CHAR(34)," ",CHAR(34),CHAR(34)," ",CHAR(34),CHAR(34),")")

It can be filled-down for the other layers.  Simply copy the content of cells G2 to G6 and paste into the command prompt of AutoCAD or use Notepad to create a script (.scr) file.

 

The statement is a little unwieldy but works!  There may be some simplification possible. 

 

An alternative approach would be to create an Excel/VBA macro to create a script file.

 

lee.minardi
Message 6 of 26

ahmed.xeng
Advocate
Advocate

Thanks a lot for replying

 

I need to add Layer description to this formula in excel how can I do it ?

 

 

 

0 Likes
Message 7 of 26

leeminardi
Mentor
Mentor
Accepted solution

Cjeck out the prompts you see when you give the -layer command.  You want to duplicate those with the concatenate command. Use CHAR(34) to create " marks where AtuoCAD needs them.  Use " " (quote space quote) to place a space between parameters.

 

The following will create a layer and give it a description.

image.png

The contents of cell C2 is:

=CONCATENATE("(command ",CHAR(34),"-layer",CHAR(34)," ",CHAR(34),"m",CHAR(34)," ",CHAR(34),A2,CHAR(34)," ",CHAR(34),"D",CHAR(34)," ",CHAR(34),B2,CHAR(34)," ",CHAR(34),A2,CHAR(34)," ",CHAR(34),CHAR(34)," ",CHAR(34),CHAR(34)," ",CHAR(34),CHAR(34),")")

Note that the "D" is used to pick the descriptor option and that: 

," ",CHAR(34),CHAR(34)

is repeated 3 times at the end.  This is to produce the 3 "Enters" needed to terminate the command. 

Copying cells C2 to C6 the clipboard and then pasting into Autocad will generate this result:

image.png

lee.minardi
Message 8 of 26

Anonymous
Not applicable

Can you please help me. I have attached my spreadsheet. I would like to import the red columns into AutoCAD 2021. Can you insert the Autocad formula into the column to the right and upload it thanks. I really appreciate it.

 

0 Likes
Message 9 of 26

Anonymous
Not applicable

Hi, can someone please check my formula? I cannot get the linetype, lineweight, and description into the formula. Can you help provide the formula?

 

kindly

0 Likes
Message 10 of 26

leeminardi
Mentor
Mentor

Rather than specify to use a default value for a layer parameter with a double quote (CHAR(34), CHAR(3)) explicitly state the value (e.g., the layer name).

 

For example, change char(34),char(34) to char(34),A2,char(34)

 

image.png

lee.minardi
0 Likes
Message 11 of 26

yoav-d
Explorer
Explorer

Hi, is there a way that in "color" command to choose "index color"?

 

yoavd_0-1673939474514.png

Thanks

0 Likes
Message 12 of 26

cadffm
Consultant
Consultant

Hi @yoav-d 

 

I don't understand. Your dialog is on tab "Index color" and you can use index colors (only) on this tab,

what is your problem?

 

If you like to use the dialog while in Script, you have to use Lisp:

_.-LAYER
_new
123
_color
(acad_colordlg 7 nil)
123

_circle
2000,800
50

 
 

 

 

Sebastian

0 Likes
Message 13 of 26

yoav-d
Explorer
Explorer

Sorry for not being clear.
I was asking about the relevant path to write in an xlsx file.
The definition for a new color in a new layer command, according to the command bar, are only "Truecolor" and "COlorbook", but no index color:

yoavd_0-1673949133211.png

The examples here show only "t" for truecolor.

 

I'm still quite new to AutoCAD and not familiar enough with lisps, so I don't understand your example and whether it is relevant to my issue.

 

Thanks @cadffm ,

 

0 Likes
Message 14 of 26

janu319
Advocate
Advocate

Hi, Default option is "index color". just type the index color you want. 

 

Message 15 of 26

yoav-d
Explorer
Explorer

OH, Thank you!

0 Likes
Message 16 of 26

milan_trnka
Contributor
Contributor

=CONCATENATE("(command ";CHAR(34);"-layer";CHAR(34);" ";CHAR(34);"m";CHAR(34);" ";CHAR(34);B34;CHAR(34);" ";CHAR(34);"LW";CHAR(34);" ";CHAR(34);I34;CHAR(34);" ";CHAR(34);CHAR(34);" ";CHAR(34);"c";CHAR(34);" ";CHAR(34);"t";CHAR(34);" ";CHAR(34);G34;CHAR(34);" ";CHAR(34);CHAR(34);" ";CHAR(34);"D";CHAR(34);" ";CHAR(34);L34;CHAR(34);" ";CHAR(34);CHAR(34);" ";CHAR(34);CHAR(34);" ";CHAR(34);CHAR(34);")")

This formula filled all empty descriprions in other layers. How to fill only one descriprion?

0 Likes
Message 17 of 26

leeminardi
Mentor
Mentor

Here's an updated version of the Excel file that enables the creation of layers that allows the specification of:

layer name

true color layer color

line type

line weight

transparency

unique description for each layer

 

Just copy and paste the contents of column I into the AutoCAD command prompt.

leeminardi_0-1677079824120.png

 

lee.minardi
0 Likes
Message 18 of 26

milan_trnka
Contributor
Contributor

Yes it wotks. Thank you.😁

milan_trnka_0-1677132069089.png

 

0 Likes
Message 19 of 26

dseshanZQS9M
Explorer
Explorer

Line type continuous only working, is that possible to change center or dashed Linetype?

Thanks.

0 Likes
Message 20 of 26

chriscowgill7373
Advisor
Advisor

@dseshanZQS9M wrote:

Line type continuous only working, is that possible to change center or dashed Linetype?

Thanks.


what do you currently have in your excel file?

Are center or dashed linetypes already defined in the drawing you are trying to use?


Christopher T. Cowgill, P.E.

AutoCAD Certified Professional
Civil 3D Certified Professional
Civil 3D 2024 on Windows 10

Please select the Accept as Solution button if my post solves your issue or answers your question.

0 Likes