.NET

.NET

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

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

662 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*
_gile
Posts: 2,084
Registered: ‎04-29-2006
Message 2 of 2 (650 Views)

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

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

Hi,

 

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
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.