extracting vertices_list and faces_list with 3DFACE

23 Views Asked by At

I am trying to extract vertices and faces from 3DFace dxftype. Below I just generated faces from len of vertices which will output constant of [[0,1,2]]. and I quickly learned this is will produce non-watertight mesh. Any idea on face generating?

doc = ezdxf.readfile(r"C:\Users\Baldan\Downloads\simplified_face.dxf")
msp = doc.modelspace()

vertices = []
faces = []

for shape_idx, entity in enumerate(doc.modelspace()):
    
    # Extract vertices of the 3D face
    vertices.extend([
        [float(entity.dxf.vtx0.x), float(entity.dxf.vtx0.y), float(entity.dxf.vtx0.z)],
        [float(entity.dxf.vtx1.x), float(entity.dxf.vtx1.y), float(entity.dxf.vtx1.z)],
        [float(entity.dxf.vtx2.x), float(entity.dxf.vtx2.y), float(entity.dxf.vtx2.z)]
    ])

    faces.append([len(vertices) - 3, len(vertices) - 2, len(vertices) - 1])
    # Append the vertices and face to the result
    vertices_row_data = entity.dxf.layer, shape_idx, vertices, faces
    rows.append(Row(*vertices_row_data))

    return rows
0

There are 0 best solutions below