views:

78

answers:

2

Hey,

I'm wondering if there is a way to extract the necessary data out of an autocad .dxf file, so I can visualize the structure in opengl?

I've found some old cold snippets for windows written in cpp but since the standard changes I assume 15 yr old code is a little outdated.

Also, there is a book about the .dxf file standard but it's also from the 90's and aside that, rarely available.

Another way might be to convert it to some other file format and then extract the data I need.

Trying to look into the .dxf files didn't give too much insight either since a simple cuboid contains a lot of data already!

Can anyone give me hint on how to approach this?

+1  A: 

Autodesk has references for the DXF formats used by recent revisions of AutoCAD. I'd probably take a second look at that 15 year-old code though. Even if you can't/don't use it as-is, it may provide a decent starting point. The DXF specification is sufficiently large and complex that having something to start from, and just add new bits and pieces where needed can be a big help. As an interchange format, DXF has to be pretty conservative anyway, only including elements that essentially all programs can interpret reasonably directly.

I'd probably be more concerned about the code itself than changes in the DXF format. A lot of code that old uses deep, monolithic class hierarchies that's quite a bit different from what you'd expect in modern C++.

Jerry Coffin
thanks all for the replies. @Knyphe: How did yu start converting the .dxf files, if I may ask. Because I was indeed wondering, whether I could extract all the data I need. After all, there's more than just vertex data in there
Icky
There is a lot of data in there, and it will require significant maths to get the info you need in the coordinate system you require. You should probably take a look at the spec, then post with specific questions. Even just post something along the lines of - Here is a 3DSOLID in DXF format, how do I convert it into a list of vertices.
Knyphe
+1  A: 

The references are a good place to start, but if you are doing heavy 3D work it may not be possible to accomplish what you are attempting..

We recently wrote a DXF converter in JAVA based entirely on the references. Although many of the entities are relatively straightfoward, many other entities (3DSOLID, BODY, REGION, SURFACE, Swept Surface) are not really possible to translate, since the reference states that the groups are primarily proprietary data. Other objects (Extruded Surface, Revolved Surface, Swept Surface (again)) have significant chunks of binary data which may hold important information you need.

These entities were not vital for our efforts, but if you are looking to convert to OpenGL, these may be the entities you were particularly concerned with.

Knyphe