Package: ezdxf
ezdxfAbstractThis Python package is designed to facilitate the creation and manipulation of DXF
documents, with compatibility across various DXF versions. It empowers users to
seamlessly load and edit DXF files while preserving all content, except for comments.Any unfamiliar DXF tags encountered in the document are gracefully ignored but retained
for future modifications. This feature enables the processing of DXF documents
containing data from third-party applications without any loss of valuable information.Quick-Infoezdxfis a Python package to create new DXF files and read/modify/write
existing DXF documentsMIT-Licensethe intended audience are programmersrequires at least Python 3.8OS independenttested with CPython and pypy3has type annotations and passesmypy --ignore-missing-imports -p ezdxfsuccessfuladditional required packages for the core package without add-onstyping_extensionspyparsingnumpyfontToolsread/write/new support for DXF versions: R12, R2000, R2004, R2007, R2010, R2013 and R2018additional read-only support for DXF versions R13/R14 (upgraded to R2000)additional read-only support for older DXF versions than R12 (upgraded to R12)read/write support for ASCII DXF and Binary DXFretains third-party DXF contentoptional C-extensions for CPython are included in the binary wheels, available
onPyPIfor Windows, Linux and macOScommand line scriptezdxfto display, convert and inspect DXF filesIncluded ExtensionsAdditional packages required for these add-ons are not automatically installed
during thebasicsetup, for more information about the setup & dependencies
visit thedocumentation.Thedrawingadd-on is a translation layer to send DXF data to a render backend,
interfaces tomatplotlib, which can export
images as PNG, PDF or SVG, andPyQt5are implemented.r12writeradd-on to write basic DXF entities direct and fast into a DXF R12
file or streamiterdxfadd-on to iterate over DXF entities from the modelspace of huge DXF
files (> 5GB) which do not fit into memoryImporteradd-on to import entities, blocks and table entries from another DXF documentdxf2codeadd-on to generate Python code for DXF structures loaded from DXF
documents as starting point for parametric DXF entity creationacadctbadd-on to read/write plot style files (CTB/STB)pycsgadd-on for basic Constructive Solid Geometry (CSG) modelingMTextExplodeadd-on for exploding MTEXT entities into single-line TEXT entitiestext2pathadd-on to convert text into outline pathsgeoadd-on to support the__geo_interface__meshexfor exchanging meshes with other tools as STL, OFF or OBJ filesopenscadadd-on, an interface toOpenSCADodafcadd-on, an interface to theODA File Converterto read and write DWG fileshpgl2add-on for converting HPGL/2 plot files to DXF, SVG and PDFA simple example:importezdxffromezdxfimportcolorsfromezdxf.enumsimportTextEntityAlignment# Create a new DXF document.doc=ezdxf.new(dxfversion="R2010")# Create new table entries (layers, linetypes, text styles, ...).doc.layers.add("TEXTLAYER",color=colors.RED)# DXF entities (LINE, TEXT, ...) reside in a layout (modelspace,# paperspace layout or block definition).msp=doc.modelspace()# Add entities to a layout by factory methods: layout.add_...()msp.add_line((0,0),(10,0),dxfattribs={"color":colors.YELLOW})msp.add_text("Test",dxfattribs={"layer":"TEXTLAYER"}).set_placement((0,0.2),align=TextEntityAlignment.CENTER)# Save the DXF document.doc.saveas("test.dxf")Example for ther12writer, which writes a simple DXF R12 file without
in-memory structures:fromrandomimportrandomfromezdxf.addonsimportr12writerMAX_X_COORD=1000MAX_Y_COORD=1000withr12writer("many_circles.dxf")asdoc:for_inrange(100000):doc.add_circle((MAX_X_COORD*random(),MAX_Y_COORD*random()),radius=2)The r12writer supports only the ENTITIES section of a DXF R12 drawing, no HEADER,
TABLES or BLOCKS section is present, except FIXED-TABLES are written, than some
additional predefined text styles and line types are available.InstallationBasic installation by pip including the optional C-extensions from PyPI as
binary wheels:pip install ezdxfFull installation with all dependencies (matplotlib, PySide6) for using the
drawing add-on:pip install ezdxf[draw]For more information about the setup & dependencies visit thedocumentation.Command LineUsepython -m ezdxf ...if your shell can't find theezdxfscript.Get additional help for a sub-command:ezdxf <cmd> -hPreview DXF files in a graphical window:ezdxf view <file.dxf>Export the modelspace of DXF files as PNG|SVG|PDF:ezdxf draw -o file.<png|svg|pdf> <file.dxf>Print basic information about DXF files:ezdxf info <file.dxf>Show detailed information and structures of DXF files:ezdxf browse <file.dxf>Audit DXF files:ezdxf audit <file.dxf>Preview and convert HPGL/2 plot files:ezdxf hpgl <file.plt>Websitehttps://ezdxf.mozman.at/DocumentationDocumentation of the development version athttps://ezdxf.mozman.at/docsDocumentation of the latest release athttps://ezdxf.readthedocs.io/Knowledge GraphThe knowledge graph contains additional information beyond the documentation and is
managed bylogseq.  The source data is included in the repository
in the folderezdxf/notes.  There is also aHTML exporton the website which gets regular updates.ContributionThe source code ofezdxfcan be found atGitHub, target your pull requests
to themasterbranch:https://github.com/mozman/ezdxf.gitFeedbackQuestions and feedback atGitHub Discussions:https://github.com/mozman/ezdxf/discussionsQuestions atStack Overflow:Post questions atstack overflowand use the tagdxforezdxf.Issue tracker atGitHub:http://github.com/mozman/ezdxf/issuesRelease NotesTherelease notesare included
in the knowledge graph.ChangelogThechangelogis included
in the knowledge graph.ContactPleasealwayspost questions at theforumorstack overflowto make answers
available to other users as well.ezdxf@mozman.atFeedback is greatly appreciated.Manfred