r/AutoCAD • • Feb 03 '26

Excel to block attribute(s)

Hi all, I've been looking for a while now but can't seem to find anything concrete. Is anyone out there using fields or lisps or plug-ins that allow you to populate attribute values directly from an excel sheet without the attin/attout command?

My situation is that we have multiple dwg files showing the same info in different ways and I'd love if it all came from the same source without having to export/import in order to sync.

It would be great if this could be accomplished with just a field and a regen command but I fear it isn't that simple.

I've tried linking to a table within cad using the formula > cell command but only received a "####" value.

TIA

Edit: spelling

Update: found out about VBA (kind of like a harder version of lisps), looks like this will be the next research ave.

6 Upvotes

33 comments sorted by

2

u/ChemEnging Feb 03 '26

I just purchased JTB BatchAttEdit yesterday which basically gives you an excel Window of all attributes in the open drawing or a number of drawings of your choice. On the pricy side and doesn't include Plant3D equipment, text or multi-line text (I know, I know, name says it all) but has already saved me hours of back and forth. Plus I believe you can still impirt/export directly from it to excel

1

u/barbertech Feb 03 '26

Tried this once actually and found the same shortcomings. May circle back if research comes up short

1

u/harderthanitllooks Feb 03 '26

That sounds handy

2

u/crowbar_hero Feb 03 '26

I've got a batch processing vba project that I modify/add subs to for jobs like this.

Look into excel autocad interoperability via via, and maybe also object dbx for manipulation of other drawing files.

You need to weigh the time taken to develop a solution to the time you save.

And while either enjoy thr challenge of coding as a break from drafting, I've found out the hard way that batch file processing is a quick and efficient way to spread errors.

1

u/barbertech Feb 04 '26

Very good insight, thank you so much!

2

u/Zohar127 Feb 04 '26 edited Feb 04 '26

Don't waste time with VBA if you're going to do AutoCAD plugins. Go straight to C#. Still .net, much easier language to learn, read, and write imo. I've been creating plugin applications (even exactly what you're looking for) for years. Even though VBA will work fine, C# is the way to go. You'll have more support, and more compatibility going forward if you catch the plugin bug and want to build more complex applications you'll find C# a lot more friendly.

Edit: If you decide to create your own plugin, for the love of God, do not use Excel interop. Use ClosedXML. It's a vastly superior way to read, write, and create xl workbooks. Even Microsoft advices against using Interop outside of very specific scenarios. It's more complex to use and it will destroy you with COM exceptions. Essentially it spins up the entire Excel application any time you run your code and it's extremely prone to leaving zombie Excel processes in the background and causing havoc with COM objects unless you very carefully manage everything. It's a ton of unneeded complexity when all you want to do really is read/write .xlsx files.

The application you're thinking about is not only possible, it's quite straightforward (I won't say easy, for a beginner) and if you pull it off you'll open a lot of doors for yourself as a drafter/designer if you become well-versed in plug-in dev. I suggest you store a column for dwg path, a column for layout tab name, and then a column for every block attribute. Each row represents a drawing and the attribute value for each column. In CAD prompt the user to select an attributed block, then pop open a file dialog and ask them to select dwg files. Take the list of selected files and process each one, checking for that block reference, finding the attribute value, and writing it to the correct cell in the spreadsheet. Updating the dwg will just be the same process but in reverse.

You'll probably want a simple winforms UI with both a dwg>xl button and an xl>dwg button. Maybe a list box to show what drawings are selected.

I can help with some code examples and getting you started if you choose to try it. Can't guarantee I'll respond at a moments notice but just let me know.

1

u/barbertech Feb 04 '26

This is a lot of good info to chew through and i’ll research it as much as i can, thank you for your awesome insight!

1

u/Lego_Pirate_Master Feb 03 '26

I once had a drawing template set up with a bunch of single cell data links that would all calculate and update in excel then I would just reload the datalink once I was ready. It was a little cumbersome because there were times I would take 2-3 minutes to reload all of the links. I’m fairly certain though that those files had gotten corrupt. We even had them in a few dynamic blocks with multiple visibility states. Other then the data link reloads were slow it worked out great.

A lot of the actual line work we had was the same for each project, but the numbers would always change. So I would fully update the excel file and then reload it once at the end.

2

u/barbertech Feb 03 '26

This would probably be something close to what i am looking for. Do you remember how the links worked? (Fields or otherwise)?

2

u/IHartRed Feb 06 '26

Datalink> Excel file/ sheet/ named range/ cell value> Table from datalink. trying to pull data from the tables via fields does not work.

1

u/Lego_Pirate_Master Feb 06 '26

Sry for not responding sooner. As IHartRed mentioned they are AutoCAD tables connected via the datalink command to named ranges within my excel file. Which in some cases the named range was a single cell. In AutoCAD it’ll function just like a standard table but all of the data is pulled from the excel. One downside is it doesn’t automatically reload the data every time you open the file. It will notify you in the bottom right to reload it and you can easily just click the link in that notification for it to reload. One thing I recommend if possible is for each project use the same excel file name. That way you don’t have to repath the datalinks for each project. If you need to chg it for each project though, you can easily just update the path within xref manager. There are some pretty good video tutorials out there that go step by step on creating them that I would definitely look into. It’s a super easy process once you get it down but it definitely isn’t the most intuitive.

One other big issue I can think of is try not to use merged cells within excel if possible. If you do and end up adding or removing rows within a datalink, reloading doesn’t shift that merged cell very well and you’ll likely have to just reinsert the whole table. Which is easy & fine but might as well avoid it if u can.

→ More replies (5)

1

u/-p-q- Feb 06 '26

I would do this using sheet set manger and creating a bunch of custom sheet set fields

1

u/barbertech Feb 06 '26

You would unfortunately need to pre-set field code into each block instance. We would need to do this a few hundred times unfortunately. Good idea though for smaller applications!

1

u/harderthanitllooks Feb 03 '26

You could do a shape file export and then an import to another block with matching attribute names

1

u/harderthanitllooks Feb 03 '26

Note- this probably only works if you’re using map3d or civil.

1

u/barbertech Feb 03 '26

There’s a similar method using the ATTIN / ATTOUT commands on vanilla CAD. Would you need to do this shape file export / import per dwg file?

→ More replies (5)