ezdxf(1)

ezdxf Documentation

Section 1 python3-ezdxf bookworm source

Description

. .

.

\\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2]

. RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1

. RE

ezdxf - ezdxf Documentation [image]

Welcome! This is the documentation for ezdxf release 0.18.1, last updated Sep 14, 2022.

ezdxf is a Python package to create new DXF files and read/modify/write existing DXF files

MIT-License

the intended audience are programmers

requires at least Python 3.7

OS independent

tested with CPython and pypy3

has type annotations and passes mypy --ignore-missing-imports -p ezdxf successful

additional required packages for the core package without add-ons: \%typing_extensions, \%pyparsing

read/write/new support for DXF versions: R12, R2000, R2004, R2007, R2010, R2013 and R2018

read-only support for DXF versions R13/R14 (upgraded to R2000)

read-only support for older DXF versions than R12 (upgraded to R12)

read/write support for ASCII DXF and Binary DXF

retains third-party DXF content

optional C-extensions for CPython are included in the binary wheels, available on \%PyPI for Windows, Linux and macOS

Additional packages required for these add-ons are not automatically installed during the basic setup, for more information about the setup & dependencies visit the \%documentation.

\%drawing add-on to visualise and convert DXF files to images which can be saved to various formats such as png, pdf and svg

\%r12writer add-on to write basic DXF entities direct and fast into a DXF R12 file or stream

\%iterdxf add-on to iterate over DXF entities from the modelspace of huge DXF files (> 5GB) which do not fit into memory

\%importer add-on to import entities, blocks and table entries from another DXF document

\%dxf2code add-on to generate Python code for DXF structures loaded from DXF documents as starting point for parametric DXF entity creation

\%acadctb add-on to read/write \%Plot Style Files (CTB/STB)

\%pycsg add-on for Constructive Solid Geometry (CSG) modeling technique

\%MTextExplode add-on for exploding MTEXT entities into single-line TEXT entities

\%text2path add-on to convert text into linear paths

\%geo add-on to support the \%__geo_interface__

\%meshex add-on for exchanging meshes with other tools as STL, OFF or OBJ files

\%openscad add-on, an interface to \%OpenSCAD

\%odafc add-on, an interface to the \%ODA File Converter to read and write DWG files

\%https://ezdxf.mozman.at/

Documentation of development version at \%https://ezdxf.mozman.at/docs

Documentation of latest release at \%http://ezdxf.readthedocs.io/

Source Code: \%http://github.com/mozman/ezdxf.git

Issue Tracker: \%http://github.com/mozman/ezdxf/issues

Forum: \%https://github.com/mozman/ezdxf/discussions

Please post questions at the \%forum or \%stack overflow to make answers available to other users as well.

ezdxf is a \%Python interface to the \%DXF (drawing interchange file) format developed by \%Autodesk, ezdxf allows developers to read and modify existing DXF drawings or create new DXF drawings.

The main objective in the development of ezdxf was to hide complex DXF details from the programmer but still support most capabilities of the \%DXF format. Nevertheless, a basic understanding of the DXF format is required, also to understand which tasks and goals are possible to accomplish by using the DXF format.

Not all DXF features are supported yet, but additional features will be added in the future gradually.

ezdxf is also a replacement for my \%dxfwrite and my \%dxfgrabber packages but with different APIs, for more information see also: \%What is the Relationship between ezdxf, dxfwrite and dxfgrabber?

ezdxf is not a DXF converter: ezdxf can not convert between different DXF versions, if you are looking for an appropriate application, try the free \%ODAFileConverter from the \%Open Design Alliance, which converts between different DXF version and also between the DXF and the DWG file format.

ezdxf is not a CAD file format converter: ezdxf can not convert DXF files to other CAD formats such as DWG

ezdxf is not a CAD kernel and does not provide high level functionality for construction work, it is just an interface to the DXF file format. If you are looking for a CAD kernel with \%Python scripting support, look at \%FreeCAD.

ezdxf requires at least Python 3.7 and will be tested with the latest stable CPython version and the latest stable release of pypy3 during development.

ezdxf is written in pure Python with optional Cython implementations of some low level math classes and requires only pyparser and typing_extensions as additional library beside the Python Standard Library. pytest is required to run the unit and integration tests. Data to run the stress and audit test can not be provided, because I don’t have the rights for publishing this DXF files.

ezdxf is OS independent and runs on all platforms which provide an appropriate Python interpreter (>=3.7).

center; |l|l|. _ T{ Version T} T{ AutoCAD Release T} _ T{ AC1009 T} T{ AutoCAD R12 T} _ T{ AC1012 T} T{ AutoCAD R13 -> R2000 T} _ T{ AC1014 T} T{ AutoCAD R14 -> R2000 T} _ T{ AC1015 T} T{ AutoCAD R2000 T} _ T{ AC1018 T} T{ AutoCAD R2004 T} _ T{ AC1021 T} T{ AutoCAD R2007 T} _ T{ AC1024 T} T{ AutoCAD R2010 T} _ T{ AC1027 T} T{ AutoCAD R2013 T} _ T{ AC1032 T} T{ AutoCAD R2018 T} _

ezdxf also reads older DXF versions but saves it as DXF R12.

The DXF format allows third-party applications to embed application-specific information. ezdxf manages DXF data in a structure-preserving form, but for the price of large memory requirement. Because of this, processing of DXF information of third-party applications is possible and will retained on rewriting.

ezdxf is licensed under the very liberal \%MIT-License.

The primary goal is to keep the dependencies of the core package as small as possible. The add-ons are not part of the core package and can therefore use as many packages as needed. The only requirement for these packages is an easy way to install them on Windows, Linux and macOS, preferably as:

pip3 install ezdxf

The \%pyparsing package and the \%typing_extensions are the only hard dependency and will be installed automatically by pip3!

The minimal required Python version is determined by the latest stable version of \%pypy3 and the Python version deployed by the \%Raspberry Pi OS, which is currently Python 3.7 (2021).

The most common case is the installation by pip3 including the optional C-extensions from \%PyPI as binary wheels:

pip3 install ezdxf

To use all features of the drawing add-on, add the [draw] tag:

pip3 install ezdxf[draw]

center; |l|l|. _ T{ Tag T} T{ Additional Installed Packages T} _ T{ [draw] T} T{ \%Matplotlib, \%PySide6, \%Pillow T} _ T{ [draw5] T} T{ \%Matplotlib, \%PyQt5, \%Pillow (use only if PySide6 is not available) T} _ T{ [test] T} T{ geomdl, pytest T} _ T{ [dev] T} T{ setuptools, wheel, Cython + [test] T} _ T{ [all] T} T{ [draw] + [test] + [dev] T} _ T{ [all5] T} T{ [draw5] + [test] + [dev] (use only if PySide6 is not available) T} _

Ezdxf includes some C-extensions, which will be deployed automatically at each release to \%PyPI as binary wheels to PyPI:

Windows: only amd64 packages

Linux: manylinux and musllinux packages for x86_64 & aarch64

macOS: x86_64, arm64 and universal packages

The wheels are created by the continuous integration (CI) service provided by \%GitHub and the build container \%cibuildwheel provided by \%PyPA the Python Packaging Authority. The \%workflows are kept short and simple, so my future me will understand what’s going on and they are maybe also helpful for other developers which do not touch CI services every day.

The C-extensions are disabled for \%pypy3, because the JIT compiled code of pypy is much faster than the compiled C-extensions for pypy.

It is possible to disable the C-Extensions by setting the environment variable EZDXF_DISABLE_C_EXT to 1 or true:

set EZDXF_DISABLE_C_EXT=1

or on Linux:

export EZDXF_DISABLE_C_EXT=1

This is has to be done before anything from ezdxf is imported! If you are working in an interactive environment, you have to restart the interpreter.

Install the latest development version by pip3 from \%GitHub:

pip3 install git+https://github.com/mozman/ezdxf.git@master

This is only required if you want the compiled C-extensions, the ezdxf installation by pip from the source code package works without the C-extension but is slower. There are many binary wheels including the compiles C-extensions available on \%PyPi.

Make a build directory and a virtual environment:

mkdir build cd build py -m venv py310 py310/Scripts/activate.bat

A working C++ compiler setup is required to compile the C-extensions from source code. Windows users need the build tools from Microsoft: \%https://visualstudio.microsoft.com/de/downloads/

Download and install the required Visual Studio Installer of the community edition and choose the option: Visual Studio Build Tools 20..

Install required packages to build and install ezdxf with C-extensions:

pip3 install setuptools wheel cython

Clone the \%GitHub repository:

git clone https://github.com/mozman/ezdxf.git

Build and install ezdxf from source code:

cd ezdxf pip3 install .

Check if the installation was successful:

python3 -m ezdxf -V

The ezdxf command should run without a preceding python3 -m, but calling the launcher through the interpreter guarantees to call the version which was installed in the venv if there exist a global installation of ezdxf like in my case.

The output should look like this:

ezdxf 0.17.2b4 from D:\eSource\ebuild\epy310\elib\esite-packages\eezdxf Python version: 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] using C-extensions: yes using Matplotlib: no

To install optional packages go to section: \%Install Optional Packages

To run the included tests go to section: \%Run the Tests

I use sometimes the Windows Subsystem for Linux (\%WSL) with \%Ubuntu 20.04 LTS for some tests (how to install \%WSL).

By doing as fresh install on WSL & Ubuntu, I encountered an additional requirement, the build-essential package adds the required C++ support:

sudo apt install build-essential

The system Python 3 interpreter has the version 3.8, but I will show in a later section how to install an additional newer Python version from the source code: