Importing CSV into AutoCAD 2018 as block and including Point ID on block

Importing CSV into AutoCAD 2018 as block and including Point ID on block

andrew.wheaton
Enthusiast Enthusiast
18,514 Views
23 Replies
Message 1 of 24

Importing CSV into AutoCAD 2018 as block and including Point ID on block

andrew.wheaton
Enthusiast
Enthusiast

Good afternoon.

 

I'm hoping someone can help me.

 

I've been asked to import a CSV file into AutoCAD. I have around 1000 points to plot. My idea is to import the points using the X and Y coordinates from the CSV, and adding a block to each point with an identifying ID as an attribute.

 

Can anyone help me?

 

0 Likes
Accepted solutions (3)
18,515 Views
23 Replies
Replies (23)
Message 2 of 24

john.vellek
Alumni
Alumni

Hi @andrew.wheaton

 

This should be fairly easy. Open your CSV in Excel and use the concatenate function to combine all the values and to insert commands such as _Insert and the block name.  If you would like to attach your CSV I can get you started on this process.

 

On e you have combined all this information, you can then copy the new data to a test file and run it in AutoCAD as a script.

 

 

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


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 3 of 24

leeminardi
Mentor
Mentor

Check out this post.  My post (#9) provides details for adding a block that may have space characters in its name.  It also shows how to specify an attribute with the script.

lee.minardi
Message 4 of 24

andrew.wheaton
Enthusiast
Enthusiast

John,

 

Please find attached file.

 

Andrew

0 Likes
Message 5 of 24

leeminardi
Mentor
Mentor
Accepted solution

Create a block with one attribute for the label (I named the block MyPtBlock) and you can use the attached Excel file.  Copy and paste column I into the AutoCAD command prompt and it will add the blocks with attribute labels.

al1.JPG

 

al2.JPG

 

lee.minardi
Message 6 of 24

andrew.wheaton
Enthusiast
Enthusiast

How do I insert these points in one go?

0 Likes
Message 7 of 24

leeminardi
Mentor
Mentor
Accepted solution

Select cells I2 thru I11 and copy them to the Windows clipboard (Ctrl-C) then go to AutoCAD and do a Paste into the command line (Ctrl-V).  This assumes you have defined a block with the name MyPtBlock which has one attribute.

lee.minardi
0 Likes
Message 8 of 24

john.vellek
Alumni
Alumni
Accepted solution

Hi @andrew.wheaton,

 

Lee did a great job (and faster than I got to it) on this solution.  Please reward him with marking his post(s) as a solution for your issue.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 9 of 24

Anonymous
Not applicable

Sorry for opening an old thread but I'm trying to implement this solution and am having trouble.

 

When I paste in one of the text strings to the command line, it doesnt fully work. When it comes to defining the Block attribute a dialog box opens which must be dealt with manually, rather than automatically taking the label from the text.

 

Am i doing something wrong? Have I defined the attribute incorrectly?

0 Likes
Message 10 of 24

leeminardi
Mentor
Mentor

I think I was able to paste the content of column I from my spreadsheet directly into the AutoCAD prompt.  That doesn't appear to work with 2019. It stops with the display of the attribute dialog box.

 

There is a simple fix.

Copy and save the contents of column I  in Notepad or some other ASCII text editor (I prefer Notepad ++) then save the file as a text file but with the file extension .scr (not .txt).  Just edit the file name so that it ends with .scr.  Back in AutoCAD give the script command and select the .scr file.

 

 

lee.minardi
Message 11 of 24

Anonymous
Not applicable

Script solution worked perfectly, thanks

0 Likes
Message 12 of 24

Anonymous
Not applicable

Hello, I follow most of this, however I am Running AutoCAD 2020 and the Script method is not working for me.

Any other thoughts on the matter? I was simply trying to plot the points in John's excel file w/o editing them to see if it worked and it only plots 1 point and then here is what the command prompt spits back at me:

 

Command: SCR
SCRIPT
Command: (command "-insert" "MyPtBlock" "511852.557,180065.876,0" 1 1 0 "SOP001")
-insert Enter block name or [?] : MyPtBlock
Units: Inches Conversion: 0'-0.0833"
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]: 511852.557,180065.876,0
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: 1 Enter Y scale factor : 1
Specify rotation angle <0>: 0
Command: SOP001 Unknown command "SOP001". Press F1 for help.
Command: nil

 

Thanks ahead of time.

0 Likes
Message 13 of 24

Anonymous
Not applicable

Hi @leeminardi, I followed you so far, and it's worked well. I would like to modify names in the xCel workbook to show up in my block. I have three attributes that read out (NEZ). I'd like one more that reads the "description" column. Do I need to add an attribute to the block that will accept the "description" that I also want to auto-fil when i copy past the fields into the command line?

0 Likes
Message 14 of 24

leeminardi
Mentor
Mentor

If I follow you I think you want to have the script add the contents of an Excel cell for the value for an additional attribute.  If so, then yes, you will need to add an another column that contains the value of the attribute and the cell of course needs another attribute.

 

After you make (edit) your new block try adding it to your drawing interactively and observe the order in which you are prompted to enter values for the attributes.  The AutoCAD command you build in Excel with the concatenate function should duplicate this order.  Note, when defining a block you can control the sequence order of prompts for attributes by selecting the attributes in the order you want them to be presented to the user. 

lee.minardi
0 Likes
Message 15 of 24

Anonymous
Not applicable
I got it working exactly the way i need it, i can't thank you enough. This is an issue that I've been trying to find a better solution for the last 3 years. Thank you!
0 Likes
Message 16 of 24

martin.phamVJ8N9
Observer
Observer

Hi,

I managed to insert att block from xcel to cad. When I try to copy and paste 100 lines/att block from xcel to cad, it seem like they're all in the wrong positions. I convert those line to .scr and try on cad and it doesn't work as well. Can you advice solution to this.

Thank you.

0 Likes
Message 17 of 24

leeminardi
Mentor
Mentor

Post a sample file with a few instances of the block and the Excel file you created to extract the block data.

lee.minardi
0 Likes
Message 18 of 24

matthew_fuller46E6T
Community Visitor
Community Visitor

I found this thread and am looking for an assist with a task at hand. I'm using 2022, and am trying to mark several gps'd locations using the x/y coordinate data.  

 

I followed the information above and made the spreadsheet that works with a single attribute block. That worked well, however, when the blocks insert, the x/y dats is ignored. All blocks insert at the same point on the drawing.

 

It sounded like someone else might have had the same issue, so I tried the script option as well. I had the same result there too. Any help would be greatly appreciated. 

 

0 Likes
Message 19 of 24

leeminardi
Mentor
Mentor

Please post a sample xlxs file and a "before" dwg file and I will  take a look at it.

lee.minardi
Message 20 of 24

matthew_fuller46E6T
Community Visitor
Community Visitor

Lee,

 

Thanks for the quick reply. The drawing has the start point marked. The attached excel file has the x/y data formatted to match the example above. 

0 Likes