Valued Contributor
Posts: 91
Registered: ‎02-18-2010
Message 1 of 2 (749 Views)

VB.NET - excel - most efficient ways of transferring data between autocad

749 Views, 1 Replies
10-18-2012 08:36 AM

anyone have ideas on what would be the most efficient way of transferring data between autocad, such as reading layer data from autocad & writing it into excel.


I'm working on a routine to do this, & it initially seemed that since i was iterating the layer records & viewport records to extract the layer data, I may as well populate each XL cell with the corresponding data. This actually takes a huge amount of time.


That is fine if that is the quickest way of doing it, but I was wondering if maybe reading all the data first & storing it in an array or two, or using a custom data structure (a class of strings and booleans etc for layer name, and on/off, etc), and then populating the cells from that might be quicker.


Also I've read a little about filling many cells at once from arrays & it seems this might be really quick. If this is the best way, & I'm using a custom data structure, should I try to create arrays from it (iterate through it to create an array of layernames, do it again for ON/OFF state, etc). If that is the case maybe I shouldn't bother with my custom class & just make a bunch of arrays to begin with. It just seems that my data class will help keep things organized & clean.


Any suggestions?

*Expert Elite*
Posts: 2,125
Registered: ‎04-29-2006
Message 2 of 2 (737 Views)

Re : VB.NET - excel - most efficient ways of transferring data between autocad

10-18-2012 09:46 AM in reply to: kcimos



One way: store the data in an object 2 dimensional array and, in a Range with a number of rows and columns equal to the array, set the array as Range.Value2 property.


Other way: store the data in a single string separated with tabulations and new lines, copy the string to the clipboard and paste it in an Excel cell.


You can also get the ExcelStreamLateBinding.dll assembly from here, containing ExcelReader and ExcelWriter classes which are helpers to read and write Excel workbooks. The ExcelWriter provides a WriteRange() and a PasteFromClipboard() methods.

Attached: ExcelStreamLateBinding help file

Gilles Chanteau
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.