pyvista_cad.read_dxf#
- read_dxf(path, /, *, clean=True, keep_text=False, expand_blocks=True, layout='modelspace', **_)[source]#
Read a DXF file as a
pyvista.PolyData.- Parameters:
- pathstr or os.PathLike
Path to a
.dxffile (ASCII or binary, any AutoCAD version supported byezdxf).- cleanbool, default: True
Run
pyvista.PolyData.clean()on the result to merge coincident vertices and drop degenerate cells. DXF files almost always store coincident vertices per face, so cleaning is on by default.- keep_textbool, default: False
Include
TEXT/MTEXT/ATTRIBentities by tessellating their bounding rectangles into faces; the text content is stored in aTextcell-data string array.- expand_blocksbool, default: True
Recursively expand
INSERTblock references into real geometry.- layoutstr, default:
'modelspace' 'modelspace','paperspace', or a specific layout name.- **_Any
Additional keyword arguments are accepted for forward compatibility with
pyvista.read()and ignored here.
- Returns:
- pyvista.PolyData
Aggregated mesh containing every drawable entity. A
Layercell-data string array records the originating DXF layer; the same data is mirrored tocad.layerfor forward compat.
- Raises:
- FileNotFoundError
If
pathdoes not exist.- pyvista_cad.CadReadError
If the file cannot be parsed as a DXF.
- Parameters:
- Return type:
Examples
Read the bundled DXF plate fixture:
>>> import pyvista_cad >>> from pyvista_cad import read_dxf >>> mesh = read_dxf(pyvista_cad.examples.dxf_plate) >>> type(mesh).__name__ 'PolyData' >>> str(mesh.field_data['cad.source_format'][0]) 'dxf'