VB.Net - AutoCAD 2008

I'd like to read data from a .dwg file into my vb.net 2005 application.

I'm not up to speed on how to use AutoCAD, but when I open the dwg file, there is a datagrid type of control  in the drawing file that contains 4 columns and many rows.  I need to read each row in the datagrid and have the ability to specify which column also.

If anyone has sample code that can read from the current .dwg file open in AutoCAD 2008, that would be very helpful.

I have referenced acdbmgd.dll and acmgd.dll in my project.  I've been reading about ObjectARX, but I'm not sure this is available for AutoCAD 2008.

If it's better I read from the AutoCAD file itself or their database, I'd be open to that option also.

the project requires me to read part numbers, descriptions, and quantities from AutoCAD.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you post the file for us to upload and examine?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JMO9966Author Commented:

I have written a program that communicates with the current drawing file open in SolidWorks by using these objects. I was thinking of doing similar with AutoCAD if they have standard objects to use.

Dim swApp As sldworks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As sldworks.DrawingDoc
Dim swView As SldWorks.view
Dim swTable As sldworks.TableAnnotation

I then read data from the data table within the drawing file:

 swDraw = swModel
        swView = swDraw.GetFirstView
        swTable = swView.GetFirstTableAnnotation
        initial_load = False
        Do While Not swTable Is Nothing
            ProcessTable(swApp, swModel, swTable)
            swTable = swTable.GetNext

Is this possible with AutoCAD or would I be better off exploring a solution where I retreive data from their database instead ??

I have attached one AutoCAD drawing file.
JMO9966Author Commented:
Here the file is again if it didn't come through.

Come on guys, there has to be plenty of knowledge on how to read data from the drawing file or their db??
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Hi JM,

I don't see the DWG file attachment as part of your message. I will try again from another computer tomorrow that is running MS Explorer (I am currently on my Linux box w/ Firefox).

I can get your data from AutoCAD in several different ways other than ObjectARX. I wanted to see the file because I wanted to see the item you refer to as a "data grid". It may be an AutoCAD table which should have its entities and their values available from the AutoCAD programming interface, specifically AutoLisp or VisualLisp.

Some AutoCAD entities have built in extraction capabilities that can be exported to CSV type data streams.

Why don't you send me the file to this email address:
bd125@assi-cad.com and I will take a look at it?
Hi JM,

Got your file. This is a piece of cake! Each record is an AutoCAD block (block name BOM in your sample drawing) with attributes. You can use the command ATE (stands for Attribute Edit) to edit each attribute. Here are a few ways that you can extract the data to a file:

1. You can use the command EATTEXT. This stands for Extended Attribute Extract. You will be stepped through a number of screens to identify what blocks you want to extract, if you want to save your extraction method to a template for future use, the file name of that template, what attributes of the blocks you want to extract, what fields you want to extract, what order you want, and finally a file name that you want to extract to.

2. You can use the regular command ATTEXT. This stands for Attribute Extract. With this method you must create a template file that will tell what attributes are to be extracted.

For both of the above methods go to HELP in AutoCAD and search for EATTEXT and ATTEXT.

3. It would be an easy programming task to create an AutoLISP program that would find the blocks, extract the attributes and write them to a text file.

If the case is that the same blocks are on different drawings with the same format (consistent) , I would choose option #3, save the output to the same file name every time. That way you can set your software to pick up the export file in the same place every time. Also the user could basically "press a button" and everything would be automated.

If you want to have a go at the programming your self here is a good start:

JMO9966Author Commented:

I would be pursuing the AutoLISP option.  Would you say it's a fair assumption to expect that most AutoCAD users already have a data table like my example file in their drawing files or could easilly add on with the agreed upon block references?
I would NOT say that it is a fair assumption that most AutoCAD users already have a table like this in their drawing files. AutoCAD out of the box has nothing like this "built in" to the base product.

This table was probably created from a third party software like Architectural Desktop or Inventor. I have seen a number of DOOR SCHEDULES that use this technique of stacked blocks, each one a single record with multiple attributes.

Yes, it would be easy to add the block references if the blocks were supplied. If you wanted to supply the block you could easily create a drawing file (DWG) and the user would INSERT the file into his / her drawing as a block upon they would be prompted to input the fields. You could easily include this as part of your LISP routine.

Do you plan to do the LISP programming yourself or farm that out?
JMO9966Author Commented:
I would like to attempt the LISP programming, but in reading that article, I was lost.

Thanks guys, I'll be closing this request soon.
This is a pretty easy LISP programming task so it would not cost you much to have it written for you. You would have to clearly define the parameters that you wanted included.

I would suggest that you supply the AutoCAD block that would be used for the data extraction so that you would have control over the number of attributes, their order, their names and tags, etc..

I could suggest a couple of sources to get a quote for the programming if you would like....
JMO9966Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CAD/Architecture Software

From novice to tech pro — start learning today.