I am looking to extract very specific information from AutoCAD and put it into Excel for manipulation, then write the updated information back to AutoCAD. At present, I am doing this with VBA, but it is HEINOUSLY slow, and it's unacceptable.
Background: My job is to manipulate and validate drawings for a litany of vendors for a whole host of things, but one consistent thing I need to do is titleblock / detail manipulation, and the "best" option I have been able to get operational is VBA inside Excel.
What my code does right now is use an array of data it needs, and where to get it (block names, the attribute names inside them, and what column of Excel to put them into). This works well enough, except almost everything I work with has ~100,000+ entities in each drawing, meaning they can take minutes each to process. The reason I am thinking .NET is considerably faster is because I have a tool that does some random stuff to these same drawings, and this tool is able to tear through many files / second; even if I made my tool do NOTHING except open and close the file, it's nowhere near as fast.
Here is some pseudocode for what my program does, for reference:
- Open file (using ObjectDBX)
-- iterate through all entites (since I can't just iterate through blocks apparently)
--- if block, see if it matches one of the blocks I want
--- if it does, but has no attributes, do something
--- if it does, but has attributes, do something else
-- next entity
- next file
Almost all of the time the program is running, it is looping through entities that are not blocks, and are therefore simply skipped. This entity search is gloriously slow, and I was curious if:
a) moving code to VB .NET is a big challenge (given my program is currently in Excel VBA, not in the AutoCAD VBA ... and I have programmed in a bunch of languages, but not VB .NET yet)
b) Simply changing my code to work in VB .NET, can expect notable speed increases (hoping in the order of a magnitude)
c) Would I be able to realise more speed increases with, say, C#
d) Does .NET offer me something like being able to iterate through just BLOCKS? Since 99.9% of my entities are just lines, this would be much quicker.
e) Does setting attributes via the .NET API have the same glitch with the shifting attributes bug of ObjectDBX? That alone almost would make this worth it.
In an ideal world, this would also become an "app", where I can open it, select the folder to process, select the desination Excel file, and go; this is basically how it is currently programmed, except Excel is the "program". However, I need it to be much faster first.