Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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++.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top