How to read AutoCAD's dxf 3dface index array?

How to read AutoCAD's dxf 3dface index array?

Anonymous
Not applicable
588 Views
2 Replies
Message 1 of 3

How to read AutoCAD's dxf 3dface index array?

Anonymous
Not applicable

I am trying to read AutoCAD's dxf file and load it to THREE.js scene. I have all information except triangulation index array. Example, for 1 3dface object, say, I have points like [{x: 0, y: 0, z: 0}, {x: 0, y: 1, z: 1}, {x: 1, y: 1, z: 0}, {x: 1, y: 0, z: 0}] and for just this one I am giving to faces array values [0, 1, 3, 3, 1, 2](for creating triangulations). But this is only for one 3dface object. How about 10 thousands or millions of points. How I can create triangulation face index? Or is there any information about that in dxf file?
Thanks

0 Likes
589 Views
2 Replies
Replies (2)
Message 2 of 3

CodeDing
Advisor
Advisor

@Anonymous ,

 

Well I feel like there are more questions to be asked about your particular situation, but to get us started, here's some stuff you need to know..

 

Here's the DXF documentation about a 3DFace:

https://help.autodesk.com/view/OARX/2020/ENU/?guid=GUID-747865D5-51F0-45F2-BEFE-9572DBC5B151

 

A 3DFace can ONLY have 3 OR 4 sides.

 

If 3 sides, no triangulation necessary, a single plane is created. The DXF vertex values would look like so:

Vertex 1: {[DXF 10], [DXF 20], [DXF 30]}

Vertex 2: {[DXF 11], [DXF 21], [DXF 31]}

Vertex 3: {[DXF 12], [DXF 22], [DXF 32]}

 

If 4 sides, there are 2 triangles created, with the "crease" ALWAYS connecting, by default, between vertices 2 and 4.

Therefore, your vertex values would look like so:

Vertex 1: {[DXF 10], [DXF 20], [DXF 30]}

Vertex 2: {[DXF 11], [DXF 21], [DXF 31]}

Vertex 3: {[DXF 12], [DXF 22], [DXF 32]}

Vertex 4: {[DXF 13], [DXF 23], [DXF 33]}

...and your 2 triangles, like so:

Triangle 1: Vertex 1: {[DXF 10], [DXF 20], [DXF 30]}

Triangle 1: Vertex 2: {[DXF 11], [DXF 21], [DXF 31]}

Triangle 1: Vertex 4: {[DXF 13], [DXF 23], [DXF 33]}

Triangle 2: Vertex 2: {[DXF 11], [DXF 21], [DXF 31]}

Triangle 2: Vertex 3: {[DXF 12], [DXF 22], [DXF 32]}

Triangle 2: Vertex 4: {[DXF 13], [DXF 23], [DXF 33]}

 

Does that help?

 

EDIT:

Also, to be SUPER clear... a 3DFace ALWAYS saves 4 vertices (whether 3 or 4 sided).. If the 3rd and 4th vertex are the SAME coordinates, then the 3DFace is only 3 sided.. that's how you tell.

 

Best,

~DD

Message 3 of 3

Sea-Haven
Mentor
Mentor

Index 3dfaces yes based on what critreria if just a number 3dface1  ((entname1 1)(entname2 2)..(entnamelast3dface xxx)

0 Likes