Matthew Taylor
Matthew Taylor

Reputation: 13

Read Autocad Drawing with VB6

I need to open and read the contents of an Autocad file, containing information for a building- walls, windows and so on and read and categorize that information. Since these Autocad files vary, i need someone with experience to advise me how can i determine whether there is a window for instance. Furthermore it will be quite useful to be able to extract information for the wall- internal, external, and so on...

Upvotes: 0

Views: 1199

Answers (1)

Daniel Möller
Daniel Möller

Reputation: 86600

First you need to download the ObjectArx package from Autodesk. Install it and create a new Autocad Addin.

There are two ways of working I know:

Using the Arx or the Interop. I'm experienced only with the interop, but the Arx works quite the same way. (I've choosen Interop because it uses the same ActiveX libraries as the VBA for Autocad. So anything you can do with the Interop you can do with the VBA)

Find some Wizard to create a project template for Autocad Add-In.

Then reference the Autodesk.Autocad.Interop library.

In the addin, you can get the autocad application from Autodesk.AutoCAD.ApplicationServices.Application.

To use the Interop version of the application, get the Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as AcadApplication type.

From the Application, you can get the Documents collection, as well as the ActiveDocument.

From the document, you can get ModelSpace and PaperSpace.

From those you can get the Items, wich are of type AcadEntity.

AcadEntity is the base type for all Autocad objects that appear in the drawing. So all the walls and windows will be formed by a group of AcadEntity objects.

But AcadEntity can have derived types, such as AcadLine (lines), AcadLWPolyline (polylines 2d with elevation), AcadCircle and so on.

Now you will have to know how the windows and walls are made in the drawing in order to find them out. If they are blocks, it will be quite easy. Just select in the modelspace or paperspace (or any autocad Block, because the paperspace and modelspace are considered blocks) all AcadEntity objects that are AcadBlockReference.

Each AcadBlockReference represents the insertion of a block in the drawing and contains it's parameters.

But if walls and windows are hand made with lines, then you will have to stabilish some rules to search for them, such as comparing AcadLine objects each to each to test if they are parallel and with a distance lower than the maximum thickness a wall can have.

Those rules will be very specific for your case and how the drawings are made.

Upvotes: 2

Related Questions