.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1 REPLY 1
Reply
Message 1 of 2
kcimos
1416 Views, 1 Reply

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

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?

1 REPLY 1
Message 2 of 2
_gile
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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost