This procedure will walk through the process of using Microsoft Excel to create script files to be read into AutoCAD. Tabular information is often present in the spreadsheet that needs to be transferred to CAD.
The example explained here is a table of layer names with colors and linetypes. It could quickly be adapted to use point coordinates to create inserts. This example provides Excel specific explanations, but users of other spreadsheets should be able to adapt the instructions to their particular product. The following instructions will reference the next example.
The goal is to populate column D with concatenated values appropriate to pass to the AutoCAD command line.
- Make cell D1 current.
- Enter this expression in cell D1.
=”N “&TRIM(A1)&” C “&TRIM(B1)&” “&TRIM(A1)&” LT “&TRIM(C1)&” “&TRIM(A1)
It is very important that the spaces be included. Note that just as in the command line layer command, we must pass the layer name after each designation such as color to tell AutoCAD to assign that color only to the current layer. This explains the multiple references to A1.
- Copy that expression down to all the valid lines.
- Highlight the entire column D and copy it to the clipboard.
- Choose File/New to create a new empty sheet.
- Choose Edit/Paste Special, choose Values.
- Insert a blank row at the top of the file and enter this:
- Choose File/Save As, choose Save As Type, then choose Text (OS/2 or MS-DOS)(*.TXT).
- Enter the script filename such as D:\PATH\FILENAME.SCR.
- When prompted that the selected format does not support multiple sheets, choose Ok.
- Excel has the file locked down in the operating system, and AutoCAD can’t even run it, so we must close it first. Choose File/Close, choose No to the next dialog. This was just a temporary workbook anyway.
- Back in AutoCAD, make any preliminary settings as necessary, such as loading linetypes.
- Issue the SCRIPT command, choose your script. When its done you will may have to press enter once.
- Check the layer table. It should be populated with the information from Excel.