I’m writing a basic import function for dxf files (please don’t tell me -.obj files are easier, I already implemented that but I also need dxf), but since the format is quite complex, I’m just filtering the interesting information. It is not yet ready, but I would like to know if I didn’t forget some important flags or else. I would appreciate a lot if someone who knows could correct (or answer) the following (I’m just interested in importing the faces):
I only need to parse BLOCKs and ENTITIES
In BLOCK I can find some shapes which could be referenced in ENTITIES with an INSERT.
3DFACE important group codes:
10,20,30, (point 1 location)
11,21,31, (point 2 location)
12,22,32, (point 3 location)
13,23,33 (point 4 location if not same as point 3)
INSERT important group codes:
2 (block name)
10,20,30 (insertion point)
41,42,43 (scale factor)
50 (rotation angle) (I’m not sure around which axis??)
POLYLINE important group codes:
70 (polyline flags (bit 6 is important))
VERTEX important group codes:
10,20,30 (location)
70 (vertex flags (bit 6 & 7 are important))
71,72,73,74 (index for faces)
Will a BLOCK base point’s coordinates be added to the vertices it contains?
Will an INSERT base point’s coordinates be added to the block it references?
Sometime in the distant past, I wrote a DXF importer. I believe that you only need to read the entities and the import blocks, however, my memory is hazy. As for the rest of your questions…
I have the DXF file format in an HTML help document. It describes all of the entities, blocks, flags, etc. It is a well organized, hyperlinked document that provides all of the basic info you need to interpret a DXF files. I can e-mail a copy to you if you are interested.
I also have a working (but unfinished) project that imports DXF files and displays them using OpenGL. It is a Borland project, but you should be able to compile the DXF classes (after minor mods) with any compiler. I can e-mail that to you as well.
The main problem I have had with DXF files concerns the extrusion vector that is sometimes defined for some entities. It actually defines a new OCS using the Arbitrary Axis Algorithm but it does not seem to work with Ellipses (or Arcs, can’t remember).
All in all, DXF is a pain and you can’t even get solids from it !
Originally posted by Coconut:
[b] I saw posts somewhere people were able to decode those encoded SAT data in the DXF file, although I never try that.
[/b]
I’ll have a look for that because it is really a feature I’d like to have in my programs… For the moment, when people want to import solids they have to convert the DXF say to ASE via 3DS Max…