.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$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] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "EZDXF" "1" "Nov 25, 2023" "1.1.3" "ezdxf" .SH NAME ezdxf \- ezdxf Documentation [image] .sp Welcome! This is the documentation for ezdxf release 1.1.3, last updated Nov 25, 2023\&. .INDENT 0.0 .IP \(bu 2 \fIezdxf\fP is a Python package to create new DXF documents and read/modify/write existing DXF documents .IP \(bu 2 MIT\-License .IP \(bu 2 the intended audience are programmers .IP \(bu 2 requires at least Python 3.8 .IP \(bu 2 OS independent .IP \(bu 2 tested with CPython and pypy3 .IP \(bu 2 has type annotations and passes \fBmypy \-\-ignore\-missing\-imports \-p ezdxf\fP successful .IP \(bu 2 additional required packages for the core package without add\-ons: \fI\%typing_extensions\fP, \fI\%pyparsing\fP, \fI\%numpy\fP, \fI\%fontTools\fP .IP \(bu 2 read/write/new support for DXF versions: R12, R2000, R2004, R2007, R2010, R2013 and R2018 .IP \(bu 2 additional read\-only support for DXF versions R13/R14 (upgraded to R2000) .IP \(bu 2 additional read\-only support for older DXF versions than R12 (upgraded to R12) .IP \(bu 2 read/write support for ASCII DXF and Binary DXF .IP \(bu 2 retains third\-party DXF content .IP \(bu 2 optional C\-extensions for CPython are included in the binary wheels, available on \fI\%PyPI\fP for Windows, Linux and macOS .UNINDENT .SH INCLUDED EXTENSIONS .sp Additional packages required for these add\-ons are not automatically installed during the \fIbasic\fP setup, for more information about the setup & dependencies visit the \fI\%documentation\fP\&. .INDENT 0.0 .IP \(bu 2 \fI\%drawing\fP add\-on to visualise and convert DXF files to images which can be saved as PNG, PDF or SVG files .IP \(bu 2 \fI\%r12writer\fP add\-on to write basic DXF entities direct and fast into a DXF R12 file or stream .IP \(bu 2 \fI\%iterdxf\fP add\-on to iterate over DXF entities from the modelspace of huge DXF files (> 5GB) which do not fit into memory .IP \(bu 2 \fI\%importer\fP add\-on to import entities, blocks and table entries from another DXF document .IP \(bu 2 \fI\%dxf2code\fP add\-on to generate Python code for DXF structures loaded from DXF documents as starting point for parametric DXF entity creation .IP \(bu 2 \fI\%acadctb\fP add\-on to read/write \fI\%Plot Style Files (CTB/STB)\fP .IP \(bu 2 \fI\%pycsg\fP add\-on for Constructive Solid Geometry (CSG) modeling technique .IP \(bu 2 \fI\%MTextExplode\fP add\-on for exploding MTEXT entities into single\-line TEXT entities .IP \(bu 2 \fI\%text2path\fP add\-on to convert text into outline paths .IP \(bu 2 \fI\%geo\fP add\-on to support the \fI\%__geo_interface__\fP .IP \(bu 2 \fI\%meshex\fP add\-on for exchanging meshes with other tools as STL, OFF or OBJ files .IP \(bu 2 \fI\%openscad\fP add\-on, an interface to \fI\%OpenSCAD\fP .IP \(bu 2 \fI\%odafc\fP add\-on, an interface to the \fI\%ODA File Converter\fP to read and write DWG files .IP \(bu 2 \fBhpgl2\fP add\-on for converting \fI\%HPGL/2\fP plot files to DXF, SVG and PDF .UNINDENT .SH WEBSITE .sp \fI\%https://ezdxf.mozman.at/\fP .SH DOCUMENTATION .sp Documentation of development version at \fI\%https://ezdxf.mozman.at/docs\fP .sp Documentation of latest release at \fI\%http://ezdxf.readthedocs.io/\fP .SH KNOWLEDGE GRAPH .sp The \fI\%Knowledge Graph\fP contains additional information beyond the documentation and is managed by \fI\%logseq\fP\&. The source data is included in the repository in the folder \fBezdxf/notes\fP\&. There is also a \fI\%HTML export\fP on the website which gets regular updates. .SH RELEASE NOTES .sp The \fI\%release notes\fP are included in the \fI\%Knowledge Graph\fP\&. .SH CHANGELOG .sp The \fI\%changelog\fP is included in the \fI\%Knowledge Graph\fP\&. .SH SOURCE CODE & FEEDBACK .sp Source Code: \fI\%http://github.com/mozman/ezdxf.git\fP .sp Issue Tracker: \fI\%http://github.com/mozman/ezdxf/issues\fP .sp Forum: \fI\%https://github.com/mozman/ezdxf/discussions\fP .SH QUESTIONS AND ANSWERS .sp Please post questions at the \fI\%forum\fP or \fI\%stack overflow\fP to make answers available to other users as well. .SH INTRODUCTION .SS What is ezdxf .sp \fIEzdxf\fP is a \fI\%Python\fP interface to the \fI\%DXF\fP (drawing interchange file) format developed by \fI\%Autodesk\fP, \fIezdxf\fP allows developers to read and modify existing DXF documents or create new DXF documents. .sp The main objective in the development of \fIezdxf\fP was to hide complex DXF details from the programmer but still support most capabilities of the \fI\%DXF\fP 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. .sp Not all DXF features are supported yet, but additional features will be added in the future gradually. .sp \fIEzdxf\fP is also a replacement for the outdated \fI\%dxfwrite\fP and \fI\%dxfgrabber\fP packages but with different APIs, for more information see also: \fI\%What is the Relationship between ezdxf, dxfwrite and dxfgrabber?\fP .SS What ezdxf can’t do .INDENT 0.0 .IP \(bu 2 \fIezdxf\fP is not a DXF converter: \fIezdxf\fP can not convert between different DXF versions, if you are looking for an appropriate application, try the free \fI\%ODAFileConverter\fP from the \fI\%Open Design Alliance\fP, which converts between different DXF version and also between the DXF and the DWG file format. .IP \(bu 2 \fIezdxf\fP is not a CAD file format converter: \fIezdxf\fP can not convert DXF files to other CAD formats such as DWG .IP \(bu 2 \fIezdxf\fP 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 \fI\%Python\fP scripting support, look at \fI\%FreeCAD\fP\&. .UNINDENT .SS Supported Python Versions .sp \fIEzdxf\fP requires at least Python 3.8 (determined by \fInumpy\fP) and will be tested with the latest stable CPython version and the latest stable release of pypy3 during development. .sp \fIEzdxf\fP is written in pure Python with optional Cython implementations of some low level math classes and requires \fIpyparsing\fP, \fInumpy\fP, \fIfontTools\fP and \fItyping_extensions\fP as additional library beside the Python Standard Library. \fIPytest\fP 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 these DXF files. .SS Supported Operating Systems .sp \fIEzdxf\fP is OS independent and runs on all platforms which provide an appropriate Python interpreter (>=3.8). .SS Supported DXF Versions .TS 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} _ .TE .sp \fIEzdxf\fP also reads older DXF versions but saves it as DXF R12. .SS Embedded DXF Information of 3rd Party Applications .sp The DXF format allows third\-party applications to embed application\-specific information. \fIEzdxf\fP 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. .SS License .sp \fIEzdxf\fP is licensed under the very liberal \fI\%MIT\-License\fP\&. .SH SETUP & DEPENDENCIES .sp The primary goal is to keep the dependencies of the \fIcore\fP 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 \fIWindows\fP, \fILinux\fP and \fImacOS\fP, preferably as: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install ezdxf .EE .UNINDENT .UNINDENT .sp The packages \fI\%pyparsing\fP, \fI\%numpy\fP, \fI\%fontTools\fP and \fI\%typing_extensions\fP are the hard dependency and will be installed automatically by \fIpip3\fP! .sp The minimal required Python version is determined by the latest release version of \fI\%numpy\fP\&. .SS Basic Installation .sp The most common case is the installation by \fIpip3\fP including the optional C\-extensions from \fI\%PyPI\fP as binary wheels: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install ezdxf .EE .UNINDENT .UNINDENT .SS Installation with Extras .sp To use all features of the drawing add\-on, add the [draw] tag: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install ezdxf[draw] .EE .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Tag T} T{ Additional Installed Packages T} _ T{ [draw] T} T{ \fI\%Matplotlib\fP, \fI\%PySide6\fP, \fI\%PyMuPDF\fP T} _ T{ [draw5] T} T{ \fI\%Matplotlib\fP, \fI\%PyQt5\fP, \fI\%PyMuPDF\fP (use only if PySide6 is not available) T} _ T{ [test] T} T{ 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} _ .TE .SS PySide6 Issue .sp Maybe \fI\%PySide6\fP won’t launch on debian based distributions and shows this error message: .INDENT 0.0 .INDENT 3.5 .sp .EX qt.qpa.plugin: Could not load the Qt platform plugin \(dqxcb\(dq in \(dq\(dq even though it was found. \&... .EE .UNINDENT .UNINDENT .sp This may fix the issue: .INDENT 0.0 .INDENT 3.5 .sp .EX sudo apt\-get install libxcb\-cursor0 .EE .UNINDENT .UNINDENT .SS Binary Wheels .sp Ezdxf includes some C\-extensions, which will be deployed automatically at each release to \fI\%PyPI\fP as binary wheels to \fIPyPI\fP: .INDENT 0.0 .IP \(bu 2 \fIWindows\fP: only amd64 packages .IP \(bu 2 \fILinux\fP: manylinux and musllinux packages for x86_64 & aarch64 .IP \(bu 2 \fImacOS\fP: x86_64, arm64 and universal packages .UNINDENT .sp The wheels are created by the continuous integration (CI) service provided by \fI\%GitHub\fP and the build container \fI\%cibuildwheel\fP provided by \fI\%PyPA\fP the Python Packaging Authority. The \fI\%workflows\fP 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. .sp The C\-extensions are disabled for \fI\%pypy3\fP, because the JIT compiled code of pypy is much faster than the compiled C\-extensions. .SS Disable C\-Extensions .sp It is possible to disable the C\-Extensions by setting the environment variable \fBEZDXF_DISABLE_C_EXT\fP to \fB1\fP or \fBtrue\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX set EZDXF_DISABLE_C_EXT=1 .EE .UNINDENT .UNINDENT .sp or on Linux: .INDENT 0.0 .INDENT 3.5 .sp .EX export EZDXF_DISABLE_C_EXT=1 .EE .UNINDENT .UNINDENT .sp This is has to be done \fBbefore\fP anything from \fIezdxf\fP is imported! If you are working in an interactive environment, you have to restart the interpreter. .SS Installation from GitHub .sp Install the latest development version by \fIpip3\fP from \fI\%GitHub\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install git+https://github.com/mozman/ezdxf.git@master .EE .UNINDENT .UNINDENT .SS Build and Install from Source .sp This is only required if you want the compiled C\-extensions, the \fIezdxf\fP installation by \fIpip\fP from the source code package works without the C\-extension but is slower. There are binary wheels available on \fI\%PyPi\fP which included the compiled C\-extensions. .SS Windows 10 .sp Make a build directory and a virtual environment: .INDENT 0.0 .INDENT 3.5 .sp .EX mkdir build cd build py \-m venv py310 py310/Scripts/activate.bat .EE .UNINDENT .UNINDENT .sp A working C++ compiler setup is required to compile the C\-extensions from source code. Windows users need the build tools from Microsoft: \fI\%https://visualstudio.microsoft.com/de/downloads/\fP .sp Download and install the required Visual Studio Installer of the community edition and choose the option: \fIVisual Studio Build Tools 20..\fP .sp Install required packages to build and install ezdxf with C\-extensions: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install setuptools wheel cython .EE .UNINDENT .UNINDENT .sp Clone the \fI\%GitHub\fP repository: .INDENT 0.0 .INDENT 3.5 .sp .EX git clone https://github.com/mozman/ezdxf.git .EE .UNINDENT .UNINDENT .sp Build and install ezdxf from source code: .INDENT 0.0 .INDENT 3.5 .sp .EX cd ezdxf pip3 install . .EE .UNINDENT .UNINDENT .sp Check if the installation was successful: .INDENT 0.0 .INDENT 3.5 .sp .EX python3 \-m ezdxf \-V .EE .UNINDENT .UNINDENT .sp The \fIezdxf\fP command should run without a preceding \fIpython3 \-m\fP, 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 \fIezdxf\fP like in my development environment. .sp The output should look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX 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 .EE .UNINDENT .UNINDENT .sp To install optional packages go to section: \fI\%Install Optional Packages\fP .sp To run the included tests go to section: \fI\%Run the Tests\fP .SS WSL & Ubuntu .sp I use sometimes the Windows Subsystem for Linux (\fI\%WSL\fP) with \fI\%Ubuntu\fP 20.04 LTS for some tests (how to install \fI\%WSL\fP). .sp By doing as fresh install on \fIWSL & Ubuntu\fP, I encountered an additional requirement, the \fIbuild\-essential\fP package adds the required C++ support and the \fIpython3.10\-dev\fP package the required headers, change \fI3.10\fP to the Python version you are using: .INDENT 0.0 .INDENT 3.5 .sp .EX sudo apt install build\-essential python3.10\-dev .EE .UNINDENT .UNINDENT .sp The system Python 3 interpreter has the version 3.8 (in 2021), but I will show in a later section how to install an additional newer Python version from the source code: .INDENT 0.0 .INDENT 3.5 .sp .EX cd ~ mkdir build cd build python3 \-m venv py38 source py38/bin/activate .EE .UNINDENT .UNINDENT .sp Install \fICython\fP and \fIwheel\fP in the venv to get the C\-extensions compiled: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install cython wheel .EE .UNINDENT .UNINDENT .sp Clone the \fI\%GitHub\fP repository: .INDENT 0.0 .INDENT 3.5 .sp .EX git clone https://github.com/mozman/ezdxf.git .EE .UNINDENT .UNINDENT .sp Build and install ezdxf from source code: .INDENT 0.0 .INDENT 3.5 .sp .EX cd ezdxf pip3 install . .EE .UNINDENT .UNINDENT .sp Check if the installation was successful: .INDENT 0.0 .INDENT 3.5 .sp .EX python3 \-m ezdxf \-V .EE .UNINDENT .UNINDENT .sp The output should look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX ezdxf 0.17.2b4 from /home/mozman/src/py38/lib/python3.8/site\-packages/ezdxf Python version: 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0] using C\-extensions: yes using Matplotlib: no .EE .UNINDENT .UNINDENT .sp To install optional packages go to section: \fI\%Install Optional Packages\fP .sp To run the included tests go to section: \fI\%Run the Tests\fP .SS Raspberry Pi OS .sp Testing platform is a \fI\%Raspberry Pi\fP 400 and the OS is the \fI\%Raspberry Pi\fP OS which runs on 64bit hardware but is a 32bit OS. The system Python 3 interpreter comes in version 3.7 (in 2021), but I will show in a later section how to install an additional newer Python version from the source code. .sp Install the build requirements, \fI\%Matplotlib\fP and the \fI\%PyQt5\fP bindings from the distribution repository: .INDENT 0.0 .INDENT 3.5 .sp .EX sudo apt install python3\-pip python3\-matplotlib python3\-pyqt5 .EE .UNINDENT .UNINDENT .sp Installing \fI\%Matplotlib\fP and the \fI\%PyQt5\fP bindings by \fIpip\fP from \fI\%piwheels\fP in the venv worked, but the packages showed errors at import, seems to be an packaging error in the required \fI\%numpy\fP package. \fI\%PySide6\fP is the preferred Qt binding but wasn’t available on \fI\%Raspberry Pi\fP OS at the time of writing this \- \fI\%PyQt5\fP is supported as fallback. .sp Create the venv with access to the system site\-packages for using \fI\%Matplotlib\fP and the Qt bindings from the system installation: .INDENT 0.0 .INDENT 3.5 .sp .EX cd ~ mkdir build cd build python3 \-m venv \-\-system\-site\-packages py37 source py37/bin/activate .EE .UNINDENT .UNINDENT .sp Install \fICython\fP and \fIwheel\fP in the venv to get the C\-extensions compiled: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install cython wheel .EE .UNINDENT .UNINDENT .sp Clone the \fI\%GitHub\fP repository: .INDENT 0.0 .INDENT 3.5 .sp .EX git clone https://github.com/mozman/ezdxf.git .EE .UNINDENT .UNINDENT .sp Build and install ezdxf from source code: .INDENT 0.0 .INDENT 3.5 .sp .EX cd ezdxf pip3 install . .EE .UNINDENT .UNINDENT .sp Check if the installation was successful: .INDENT 0.0 .INDENT 3.5 .sp .EX python3 \-m ezdxf \-V .EE .UNINDENT .UNINDENT .sp The output should look like this: .INDENT 0.0 .INDENT 3.5 .sp .EX ezdxf 0.17.2b4 from /home/pi/src/py37/lib/python3.7/site\-packages/ezdxf Python version: 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] using C\-extensions: yes using Matplotlib: yes .EE .UNINDENT .UNINDENT .sp To run the included tests go to section: \fI\%Run the Tests\fP .SS Manjaro on Raspberry Pi .sp Because the (very well working) \fI\%Raspberry Pi\fP OS is only a 32bit OS, I searched for a 64bit alternative like \fI\%Ubuntu\fP, which just switched to version 21.10 and always freezes at the installation process! So I tried \fI\%Manjaro\fP as rolling release, which I used prior in a virtual machine and wasn’t really happy, because there is always something to update. Anyway the distribution looks really nice and has Python 3.9.9 installed. .sp Install build requirements and optional packages by the system packager \fIpacman\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX sudo pacman \-S python\-pip python\-matplotlib python\-pyqt5 .EE .UNINDENT .UNINDENT .sp Create and activate the venv: .INDENT 0.0 .INDENT 3.5 .sp .EX cd ~ mkdir build cd build python3 \-m venv \-\-system\-site\-packages py39 source py39/bin/activate .EE .UNINDENT .UNINDENT .sp The rest is the same procedure as for the \fI\%Raspberry Pi OS\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install cython wheel git clone https://github.com/mozman/ezdxf.git cd ezdxf pip3 install . python3 \-m ezdxf \-V .EE .UNINDENT .UNINDENT .sp To run the included tests go to section: \fI\%Run the Tests\fP .SS Ubuntu Server 21.10 on Raspberry Pi .sp I gave the \fI\%Ubuntu\fP Server 21.10 a chance after the desktop version failed to install by a nasty bug and it worked well. The distribution comes with Python 3.9.4 and after installing some requirements: .INDENT 0.0 .INDENT 3.5 .sp .EX sudo apt install build\-essential python3\-pip python3.9\-venv .EE .UNINDENT .UNINDENT .sp The remaining process is like on \fI\%WSL & Ubuntu\fP except for the newer Python version. Installing \fI\%Matplotlib\fP by \fIpip\fP works as expected and is maybe useful even on a headless server OS to create SVG and PNG from DXF files. \fI\%PySide6\fP is not available by \fIpip\fP and the installation of \fI\%PyQt5\fP starts from the source code package which I stopped because this already didn’t finished on \fI\%Manjaro\fP, but the installation of the \fI\%PyQt5\fP bindings by \fIapt\fP works: .INDENT 0.0 .INDENT 3.5 .sp .EX sudo apt install python3\-pyqt5 .EE .UNINDENT .UNINDENT .sp Use the \fB\-\-system\-site\-packages\fP option for creating the venv to get access to the \fI\%PyQt5\fP package. .SS Install Optional Packages .sp Install the optional dependencies by \fIpip\fP only for \fI\%Windows 10\fP and \fI\%WSL & Ubuntu\fP, for \fI\%Raspberry Pi OS\fP and \fI\%Manjaro on Raspberry Pi\fP install these packages by the system packager: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install matplotlib PySide6 .EE .UNINDENT .UNINDENT .SS Run the Tests .sp This is the same procedure for all systems, assuming you are still in the build directory \fIbuild/ezdxf\fP and \fIezdxf\fP is now installed in the venv. .sp Install the test dependencies and run the tests: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install pytest python3 \-m pytest tests integration_tests .EE .UNINDENT .UNINDENT .SS Build Documentation .sp Assuming you are still in the build directory \fIbuild/ezdxf\fP of the previous section. .sp Install Sphinx: .INDENT 0.0 .INDENT 3.5 .sp .EX pip3 install Sphinx sphinx\-rtd\-theme .EE .UNINDENT .UNINDENT .sp Build the HTML documentation: .INDENT 0.0 .INDENT 3.5 .sp .EX cd docs make html .EE .UNINDENT .UNINDENT .sp The output is located in \fIbuild/ezdxf/docs/build/html\fP\&. .SS Python from Source .sp Debian based systems have often very outdated software installed and sometimes there is no easy way to install a newer Python version. This is a brief summery how I installed Python 3.9.9 on the \fI\%Raspberry Pi\fP OS, for more information go to the source of the recipe: \fI\%Real Python\fP .sp Install build requirements: .INDENT 0.0 .INDENT 3.5 .sp .EX sudo apt\-get update sudo apt\-get upgrade sudo apt\-get install \-y make build\-essential libssl\-dev zlib1g\-dev \e libbz2\-dev libreadline\-dev libsqlite3\-dev wget curl llvm \e libncurses5\-dev libncursesw5\-dev xz\-utils tk\-dev .EE .UNINDENT .UNINDENT .sp Make a build directory: .INDENT 0.0 .INDENT 3.5 .sp .EX cd ~ mkdir build cd build .EE .UNINDENT .UNINDENT .sp Download and unpack the source code from \fI\%Python.org\fP, replace 3.9.9 by your desired version: .INDENT 0.0 .INDENT 3.5 .sp .EX wget https://www.python.org/ftp/python/3.9.9/Python\-3.9.9.tgz tar \-xvzf Python\-3.9.9.tgz cd Python\-3.9.9/ .EE .UNINDENT .UNINDENT .sp Configure the build process, use a prefix to the directory where the interpreter should be installed: .INDENT 0.0 .INDENT 3.5 .sp .EX \&./configure \-\-prefix=/opt/python3.9.9 \-\-enable\-optimizations .EE .UNINDENT .UNINDENT .sp Build & install the Python interpreter. The \fI\-j\fP option simply tells \fImake\fP to split the building into parallel steps to speed up the compilation, my \fI\%Raspberry Pi\fP 400 has 4 cores so 4 seems to be a good choice: .INDENT 0.0 .INDENT 3.5 .sp .EX make \-j 4 sudo make install .EE .UNINDENT .UNINDENT .sp The building time was ~25min and the new Python 3.9.9 interpreter is now installed as \fI/opt/python3.9.9/bin/python3\fP\&. .sp At the time there were no system packages for \fI\%Matplotlib\fP and \fI\%PyQt5\fP for this new Python version available, so there is no benefit of using the option \fB\-\-system\-site\-packages\fP for building the venv: .INDENT 0.0 .INDENT 3.5 .sp .EX cd ~/build /opt/python3.9.9/bin/python3 \-m venv py39 source py39/bin/activate .EE .UNINDENT .UNINDENT .sp I have not tried to build \fI\%Matplotlib\fP and \fI\%PyQt5\fP by myself and the installation by \fIpip\fP from \fI\%piwheels\fP did not work, in this case you don’t get \fI\%Matplotlib\fP support for better font measuring and the \fIdrawing\fP add\-on will not work. .sp Proceed with the \fIezdxf\fP installation from source as shown for the \fI\%Raspberry Pi OS\fP\&. .SH USAGE FOR BEGINNERS .sp This section shows the intended usage of the \fIezdxf\fP package. This is just a brief overview for new \fIezdxf\fP users, follow the provided links for more detailed information. .sp First import the package: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf .EE .UNINDENT .UNINDENT .SS Loading DXF Files .sp \fIezdxf\fP supports loading ASCII and binary DXF documents from a file: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.readfile(filename) .EE .UNINDENT .UNINDENT .sp or from a zip\-file: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.readzip(zipfilename[, filename]) .EE .UNINDENT .UNINDENT .sp Which loads the DXF document \fIfilename\fP from the zip\-file \fIzipfilename\fP or the first DXF file in the zip\-file if \fIfilename\fP is absent. .sp It is also possible to read a DXF document from a stream by the \fI\%ezdxf.read()\fP function, but this is a more advanced feature, because this requires detection of the file encoding in advance. .sp This works well with DXF documents from trusted sources like AutoCAD or BricsCAD. For loading DXF documents with minor or major flaws use the \fI\%ezdxf.recover\fP module. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Documentation for \fI\%ezdxf.readfile()\fP, \fI\%ezdxf.readzip()\fP and \fI\%ezdxf.read()\fP, for more information about file management go to the \fI\%Document Management\fP section. For loading DXF documents with structural errors look at the \fI\%ezdxf.recover\fP module. .UNINDENT .UNINDENT .SS Layouts and Blocks .sp Layouts are containers for DXF entities like LINE or CIRCLE. The most important layout is the modelspace labeled as “Model” in CAD applications which represents the “world” work space. Paperspace layouts represents plottable sheets which contains often the framing and the tile block of a drawing and VIEWPORT entities as scaled and clipped “windows” into the modelspace. .sp The modelspace is always present and can not be deleted. The active paperspace is also always present in a new DXF document but can be deleted, in that case another paperspace layout gets the new active paperspace, but you can not delete the last paperspace layout. .sp Getting the modelspace of a DXF document: .INDENT 0.0 .INDENT 3.5 .sp .EX msp = doc.modelspace() .EE .UNINDENT .UNINDENT .sp Getting a paperspace layout by the name as shown in the tab of a CAD application: .INDENT 0.0 .INDENT 3.5 .sp .EX psp = doc.paperspace(\(dqLayout1\(dq) .EE .UNINDENT .UNINDENT .sp A block is just another kind of entity space, which can be inserted multiple times into other layouts and blocks by the INSERT entity also called block references, this is a very powerful and an important concept of the DXF format. .sp Getting a block layout by the block name: .INDENT 0.0 .INDENT 3.5 .sp .EX blk = doc.blocks.get(\(dqNAME\(dq) .EE .UNINDENT .UNINDENT .sp All these layouts have factory functions to create graphical DXF entities for their entity space, for more information about creating entities see section: \fI\%Create new DXF Entities\fP .SS Query DXF Entities .sp As said in the \fI\%Layouts and Blocks\fP section, all graphical DXF entities are stored in layouts, all these layouts can be iterated and do support the index operator e.g. \fBlayout[\-1]\fP returns the last entity. .sp The main difference between iteration and index access is, that iteration filters destroyed entities, but the index operator returns also destroyed entities until these entities are purged by \fBlayout.purge()\fP, more about this topic in section: \fI\%Delete Entities\fP\&. .sp There are two advanced query methods: \fI\%query()\fP and \fI\%groupby()\fP\&. .sp Get all lines of layer \fB\(dqMyLayer\(dq\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX lines = msp.query(\(aqLINE[layer==\(dqMyLayer\(dq]\(aq) .EE .UNINDENT .UNINDENT .sp This returns an \fI\%EntityQuery\fP container, which also provides the same \fBquery()\fP and \fBgroupby()\fP methods. .sp Get all lines categorized by a DXF attribute like color: .INDENT 0.0 .INDENT 3.5 .sp .EX all_lines_by_color = msp.query(\(dqLINE\(dq).groupby(\(dqcolor\(dq) lines_with_color_1 = all_lines_by_color.get(1, []) .EE .UNINDENT .UNINDENT .sp The \fBgroupby()\fP method returns a regular Python \fBdict\fP with colors as key and a regular Python \fBlist\fP of entities as values (not an \fI\%EntityQuery\fP container). .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For more information go to the \fI\%Tutorial for Getting Data from DXF Files\fP .UNINDENT .UNINDENT .SS Examine DXF Entities .sp Each DXF entity has a \fBdxf\fP namespace attribute, which stores the named DXF attributes, some entity attributes and assets are only available from Python properties or methods outside the \fBdxf\fP namespace like the vertices of the LWPOLYLINE entity. More information about the DXF attributes of each entity can found in the documentation of the \fI\%ezdxf.entities\fP module. .sp Get some basic DXF attributes: .INDENT 0.0 .INDENT 3.5 .sp .EX layer = entity.dxf.layer # default is \(dq0\(dq color = entity.dxf.color # default is 256 = BYLAYER .EE .UNINDENT .UNINDENT .sp Most DXF attributes have a default value, which will be returned if the DXF attribute is not present, for DXF attributes without a default value you can check if the attribute really exist: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.hasattr(\(dqtrue_color\(dq) .EE .UNINDENT .UNINDENT .sp or use the \fBget()\fP method and provide a default value: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.get(\(dqtrue_color\(dq, 0) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Common graphical DXF attributes\fP .IP \(bu 2 Helper class \fI\%ezdxf.gfxattribs.GfxAttribs\fP for building DXF attribute dictionaries. .UNINDENT .UNINDENT .UNINDENT .SS Create a New DXF File .sp Create new document for the latest supported DXF version: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new() .EE .UNINDENT .UNINDENT .sp Create a new DXF document for a specific DXF version, e.g. for DXF R12: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(dqR12\(dq) .EE .UNINDENT .UNINDENT .sp The \fI\%ezdxf.new()\fP function can create some standard resources, such as linetypes and text styles, by setting the argument \fIsetup\fP to \fBTrue\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(setup=True) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Creating DXF Drawings\fP .IP \(bu 2 Documentation for \fI\%ezdxf.new()\fP, for more information about file management go to the \fI\%Document Management\fP section. .UNINDENT .UNINDENT .UNINDENT .SS Create New DXF Entities .sp The factory methods for creating new graphical DXF entities are located in the \fI\%BaseLayout\fP class and these factory methods are available for all entity containers: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Modelspace\fP .IP \(bu 2 \fI\%Paperspace\fP .IP \(bu 2 \fI\%BlockLayout\fP .UNINDENT .UNINDENT .UNINDENT .sp The usage is simple: .INDENT 0.0 .INDENT 3.5 .sp .EX msp = doc.modelspace() msp.add_line((0, 0), (1, 0), dxfattribs={\(dqlayer\(dq: \(dqMyLayer\(dq}) .EE .UNINDENT .UNINDENT .sp A few important/required DXF attributes are explicit method arguments, most additional DXF attributes are gives as a regular Python \fBdict\fP object by the keyword only argument \fBdxfattribs\fP\&. The supported DXF attributes can be found in the documentation of the \fI\%ezdxf.entities\fP module. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate DXF entities by yourself and add them to layouts, always use the provided factory methods to create new graphical entities, this is the intended way to use \fIezdxf\fP\&. .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Thematic Index of Layout Factory Methods\fP .IP \(bu 2 \fI\%Tutorial for Creating DXF Drawings\fP .IP \(bu 2 \fI\%Tutorial for Simple DXF Entities\fP .IP \(bu 2 \fI\%Tutorial for LWPolyline\fP .IP \(bu 2 \fI\%Tutorial for Text\fP .IP \(bu 2 \fI\%Tutorial for MText and MTextEditor\fP .IP \(bu 2 \fI\%Tutorial for Hatch\fP .UNINDENT .UNINDENT .UNINDENT .SS Saving DXF Files .sp Save the DXF document with a new name: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.saveas(\(dqnew_name.dxf\(dq) .EE .UNINDENT .UNINDENT .sp or with the same name as loaded: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.save() .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Documentation for \fI\%ezdxf.document.Drawing.save()\fP and \fI\%ezdxf.document.Drawing.saveas()\fP, for more information about file management go to the \fI\%Document Management\fP section. .UNINDENT .UNINDENT .SS Create New Blocks .sp The block definitions of a DXF document are managed by the \fI\%BlocksSection\fP object: .INDENT 0.0 .INDENT 3.5 .sp .EX my_block = doc.blocks.new(\(dqMyBlock\(dq) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Blocks\fP .UNINDENT .UNINDENT .SS Create Block References .sp A block reference is just another DXF entity called INSERT. The \fI\%Insert\fP entity is created by the factory method: \fI\%add_blockref()\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_blockref(\(dqMyBlock\(dq, (0, 0)) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 See \fI\%Tutorial for Blocks\fP for more advanced features like using \fI\%Attrib\fP entities. .UNINDENT .UNINDENT .SS Create New Layers .sp A layer is not an entity container, a layer is just another DXF attribute stored in the entity and the entity can inherit some properties from this \fI\%Layer\fP object. Layer objects are stored in the layer table which is available as attribute \fBdoc.layers\fP\&. .sp You can create your own layers: .INDENT 0.0 .INDENT 3.5 .sp .EX my_layer = doc.layers.add(\(dqMyLayer\(dq) .EE .UNINDENT .UNINDENT .sp The layer object also controls the visibility of entities which references this layer, the on/off state of the layer is unfortunately stored as positive or negative color value which make the raw DXF attribute of layers useless, to change the color of a layer use the property \fBLayer.color\fP .INDENT 0.0 .INDENT 3.5 .sp .EX my_layer.color = 1 .EE .UNINDENT .UNINDENT .sp To change the state of a layer use the provided methods of the \fI\%Layer\fP object, like \fI\%on()\fP, \fI\%off()\fP, \fI\%freeze()\fP or \fI\%thaw()\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX my_layer.off() .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Layers\fP .UNINDENT .UNINDENT .SS Delete Entities .sp The safest way to delete entities is to delete the entity from the layout containing that entity: .INDENT 0.0 .INDENT 3.5 .sp .EX line = msp.add_line((0, 0), (1, 0)) msp.delete_entity(line) .EE .UNINDENT .UNINDENT .sp This removes the entity immediately from the layout and destroys the entity. The property \fI\%is_alive\fP returns \fBFalse\fP for a destroyed entity and all Python attributes are deleted, so \fBline.dxf.color\fP will raise an \fBAttributeError\fP exception, because \fBline\fP does not have a \fI\%dxf\fP attribute anymore. .sp \fIEzdxf\fP also supports manually destruction of entities by calling the method \fBdestroy()\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX line.destroy() .EE .UNINDENT .UNINDENT .sp Manually destroyed entities are not removed immediately from entities containers like \fBModelspace\fP or \fBEntityQuery\fP, but iterating such a container will filter destroyed entities automatically, so a \fBfor e in msp: ...\fP loop will never yield destroyed entities. The index operator and the \fBlen()\fP function do \fBnot\fP filter deleted entities, to avoid getting deleted entities call the \fBpurge()\fP method of the container manually to remove deleted entities. .SS Further Information .INDENT 0.0 .IP \(bu 2 \fI\%Reference\fP .UNINDENT .SH BASIC CONCEPTS .sp The Basic Concepts section teach the intended meaning of DXF attributes and structures without teaching the application of this information or the specific implementation by \fIezdxf\fP, if you are looking for more information about the \fIezdxf\fP internals look at the \fI\%Reference\fP section or if you want to learn how to use \fIezdxf\fP go to the \fI\%Tutorials\fP section and for the solution of specific problems go to the \fI\%Howto\fP section. .SS What is DXF? .sp The common assumption is also the cite of \fI\%Wikipedia\fP: .INDENT 0.0 .INDENT 3.5 AutoCAD DXF (Drawing eXchange Format) is a CAD data file format developed by Autodesk for enabling data interoperability between AutoCAD and \fBother\fP applications. .sp DXF was originally introduced in December 1982 as part of AutoCAD 1.0, and was intended to provide an exact representation of the data in the AutoCAD native file format, DWG (Drawing). For many years Autodesk did not publish specifications making correct imports of DXF files difficult. Autodesk now publishes the DXF specifications online. .UNINDENT .UNINDENT .sp The more precise cite from the \fI\%DXF reference\fP itself: .INDENT 0.0 .INDENT 3.5 The DXF™ format is a tagged data representation of all the information contained in an AutoCAD® drawing file. Tagged data means that each data element in the file is preceded by an integer number that is called a group code. A group code’s value indicates what type of data element follows. This value also indicates the meaning of a data element for a given object (or record) type. Virtually all user\-specified information in a drawing file can be represented in DXF format. .UNINDENT .UNINDENT .sp No mention of interoperability between AutoCAD and \fBother\fP applications. .sp In reality the DXF format was designed to ensure AutoCAD cross\-platform compatibility in the early days when different hardware platforms with different binary data formats were used. The name DXF (Drawing eXchange Format) may suggest an universal exchange format, but it is not. It is based on the infrastructure installed by Autodesk products (fonts) and the implementation details of AutoCAD (MTEXT) or on licensed third party technologies (embedded ACIS entities). .sp For more information about the AutoCAD history see the document: \fI\%The Autodesk File\fP \- Bits of History, Words of Experience by \fIJohn Walker\fP, founder of \fIAutodesk, Inc.\fP and co\-author of \fIAutoCAD\fP\&. .SS DXF Reference Quality .sp The \fI\%DXF reference\fP is by far no specification nor a standard like the W3C standard for \fI\%SVG\fP or the ISO standard for \fI\%PDF\fP\&. .sp The reference describes many but not all DXF entities and some basic concepts like the tag structure or the arbitrary axis algorithm. But the existing documentation (reference) is incomplete and partly misleading or wrong. Also missing from the reference are some important parts like the complex relationship between the entities to create higher order structures like block definitions, layouts (model space & paper space) or dynamic blocks to name a few. .SS Reliable CAD Applications .sp Because of the suboptimal quality of the DXF reference not all DXF viewers, creators or processors are of equal quality. I consider a CAD application as a \fI\%reliable CAD application\fP when the application creates valid DXF documents in the meaning and interpretation of \fI\%Autodesk\fP and a reliable DXF viewer when the result matches in most parts the result of the free \fI\%Trueview\fP viewer provided by \fI\%Autodesk\fP\&. .sp These are some applications which do fit the criteria of a reliable CAD application: .INDENT 0.0 .IP \(bu 2 \fI\%AutoCAD\fP and \fI\%Trueview\fP .IP \(bu 2 CAD applications based on the \fI\%OpenDesignAlliance\fP (ODA) SDK, see also \fI\%ODA on wikipedia\fP, even \fI\%Autodesk\fP is a corporate member, see their blog post from \fI\%22 Sep 2020\fP at \fI\%adsknews\fP but only to use the ODA IFC tools and not to improve the DWG/DXF compatibility .IP \(bu 2 \fI\%BricsCAD\fP (ODA based) .IP \(bu 2 \fI\%GstarCAD\fP (ODA based) .IP \(bu 2 \fI\%ZWCAD\fP (ODA based) .UNINDENT .sp Unfortunately, I cannot recommend any open source applications because everyone I know has serious shortcomings, at least as a DXF viewer, and I don’t trust them as a DXF creator either. To be clear, not even \fIezdxf\fP (which is not a CAD application) is a \fIreliable\fP library in this sense \- it just keeps getting better, but is far from \fIreliable\fP\&. .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 Please do not submit bug reports based on the use of \fI\%LibreCAD\fP or \fI\%QCAD\fP, these applications are in no way reliable regarding the DXF format and I will not waste my time on them. .UNINDENT .UNINDENT .SS DXF Entities and Objects .sp DXF entities are objects that make up the design data stored in a DXF file. .SS Graphical Entities .sp Graphical entities are visible objects stored in blocks, modelspace\- or paperspace layouts. They represent the various shapes, lines, and other elements that make up a 2D or 3D design. .sp Some common types of DXF entities include: .INDENT 0.0 .IP \(bu 2 LINE and POLYLINE: These are the basic building blocks of a DXF file. They represent straight and curved lines. .IP \(bu 2 CIRCLE and ARC: These entities represent circles and portions of circles, respectively. .IP \(bu 2 TEXT and MTEXT: DXF files can also contain text entities, which can be used to label parts of the design or provide other information. .IP \(bu 2 HATCH: DXF files can also include hatch patterns, which are used to fill in areas with a specific pattern or texture. .IP \(bu 2 DIMENSION: DXF files can also contain dimension entities, which provide precise measurements of the various elements in a design. .IP \(bu 2 INSERT: A block is a group of entities that can be inserted into a design multiple times by the INSERT entity, making it a useful way to reuse elements of a design. .UNINDENT .sp These entities are defined using specific codes and values in the DXF file format, and they can be created and manipulated by \fIezdxf\fP\&. .SS Objects .sp DXF objects are non\-graphical entities and have no visual representation, they store administrative data, paperspace layout definitions, style definitions for multiple entity types, custom data and objects. The OBJECTS section in DXF files serves as a container for these non\-graphical objects. .sp Some common DXF types of DXF objects include: .INDENT 0.0 .IP \(bu 2 DICTIONARY: A dictionary object consists of a series of name\-value pairs, where the name is a string that identifies a specific object within the dictionary, and the value is a reference to that object. The objects themselves can be any type of DXF entity or custom object defined in the DXF file. .IP \(bu 2 XRECORD entities are used to store custom application data in a DXF file. .IP \(bu 2 the LAYOUT entity is a DXF entity that represents a single paper space layout in a DXF file. Paper space is the area in a CAD drawing that represents the sheet of paper or other physical media on which the design will be plotted or printed. .IP \(bu 2 MATERIAL, MLINESTYLE, MLEADERSTYLE definitions stored in certain DICTIONARY objects. .IP \(bu 2 A GROUP entity contains a list of handles that refer to other DXF entities in the drawing. The entities in the group can be of any type, including entities from the model space or paper space layouts. .UNINDENT .SS TagStorage .sp The \fIezdxf\fP package supports many but not all entity types, all these unsupported types are stored as \fBTagStorage\fP instances to preserve their data when exporting the edited DXF content by \fIezdxf\fP\&. .SS Access Entity Attributes .sp All DXF attributes are stored in the entity namespace attribute \fBdxf\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX print(entity.dxf.layer) .EE .UNINDENT .UNINDENT .sp Some attributes are mandatory others are optional in most cases a reasonable values will be returned as default value if the attribute is missing. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Getting Data from DXF Files\fP .UNINDENT .UNINDENT .SS Where to Look for Entities .sp The DXF document has an entity database where all entities which have a handle are stored in a (key, value) storage. The \fBquery()\fP method is often the easiest way to request data: .INDENT 0.0 .INDENT 3.5 .sp .EX for text in doc.entitydb.query(\(dqTEXT\(dq): print(text.dxf.text) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.query\fP module .IP \(bu 2 \fI\%ezdxf.entitydb\fP module .UNINDENT .UNINDENT .UNINDENT .sp Graphical entities are stored in blocks, the modelspace or paperspace layouts. .INDENT 0.0 .IP \(bu 2 The \fBdoc.modelspace()\fP function returns the \fI\%Modelspace\fP instance .IP \(bu 2 The \fBdoc.paperspace()\fP returns a \fI\%Paperspace\fP instance .IP \(bu 2 The \fBdoc.blocks\fP attribute provides access to the \fI\%BlocksSection\fP .UNINDENT .sp The \fI\%query()\fP method of the \fI\%Drawing\fP class which represents the DXF document, runs the query on all layouts and block definitions. .sp Non\-graphical entities are stored in the OBJECTS section: .INDENT 0.0 .IP \(bu 2 The \fBdoc.objects\fP attribute provides access to the \fI\%ObjectsSection\fP\&. .UNINDENT .sp Resource definitions like \fI\%Layer\fP, \fI\%Linetype\fP or \fI\%Textstyle\fP are stored in resource tables: .INDENT 0.0 .IP \(bu 2 \fBdoc.layers\fP: the \fI\%LayerTable\fP .IP \(bu 2 \fBdoc.linetypes\fP: the \fI\%LinetypeTable\fP .IP \(bu 2 \fBdoc.styles\fP: the \fI\%TextstyleTable\fP .IP \(bu 2 \fBdoc.dimstyles\fP: the \fI\%DimStyleTable\fP .UNINDENT .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 A layer assignment is just an attribute of a DXF entity, it’s not an entity container! .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basic concept of the \fI\%Modelspace\fP .IP \(bu 2 Basic concept of \fI\%Paperspace\fP layouts .IP \(bu 2 Basic concept of \fI\%Blocks\fP .IP \(bu 2 \fI\%Tutorial for Getting Data from DXF Files\fP .UNINDENT .UNINDENT .UNINDENT .SS How to Create Entities .sp The recommended way to create new DXF entities is to use the factory methods of layouts and blocks to create entities and add them to the entity space automatically. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Thematic Index of Layout Factory Methods\fP .IP \(bu 2 Reference of the \fI\%BaseLayout\fP class .IP \(bu 2 \fI\%Tutorial for Simple DXF Entities\fP .UNINDENT .UNINDENT .UNINDENT .SS AutoCAD Color Index (ACI) .sp The \fI\%color\fP attribute represents an \fIACI\fP (AutoCAD Color Index). AutoCAD and many other \fI\%CAD\fP application provides a default color table, but pen table would be the more correct term. Each ACI entry defines the color value, the line weight and some other attributes to use for the pen. This pen table can be edited by the user or loaded from an \fI\%CTB\fP or \fI\%STB\fP file. \fIEzdxf\fP provides functions to create (\fBnew()\fP) or modify (\fBezdxf.acadctb.load()\fP) plot styles files. .sp DXF R12 and prior do not preserve the layout of a drawing very well, because of the lack of a standard color table and missing DXF structures to define these color tables in the DXF file. If a CAD user redefines an ACI color entry in a CAD application and does not provide this \fI\%CTB\fP or \fI\%STB\fP file, you can not know what color or lineweight was used intentionally. This got better in later DXF versions by supporting additional DXF attributes like \fI\%lineweight\fP and \fI\%true_color\fP which can define these attributes by distinct values. [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Plot Style Files (CTB/STB)\fP .IP \(bu 2 \fI\%ezdxf.colors\fP .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .IP \(bu 2 Autodesk Knowledge Network: \fI\%About Setting the Color of Objects\fP .IP \(bu 2 BricsCAD Help Center: \fI\%Entity Color\fP .UNINDENT .UNINDENT .UNINDENT .SS True Color .sp The support for true color was added to the DXF file format in revision R2004. The true color value has three components red, green and blue in the range from 0 to 255 and is stored as a 24\-bit value in the DXF namespace as \fBtrue_color\fP attribute and looks like this \fB0xRRGGBB\fP as hex value. For a more easy usage all graphical entities support the \fI\%rgb\fP property to get and set the true color as (r, g, b) tuples where the components must be in the range from 0 to 255. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new() msp = doc.modelspace() line = msp.add_line((0, 0), (10, 0)) line.rgb = (255, 128, 32) .EE .UNINDENT .UNINDENT .sp The true color value has higher precedence than the \fI\%AutoCAD Color Index (ACI)\fP value, if the attributes \fBcolor\fP and the \fBtrue_color\fP are present the entity will be rendered with the true color value. .sp The true color value has the advantage that it defines the color absolutely and unambiguously, no unexpected overwriting is possible. The representation of the color is fixed and only depends on the calibration of the output medium: [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.colors\fP .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .IP \(bu 2 Autodesk Knowledge Network: \fI\%About Setting the Color of Objects\fP .IP \(bu 2 BricsCAD Help Center: \fI\%Entity Color\fP .UNINDENT .UNINDENT .UNINDENT .SS Transparency .sp The support for transparency was added to the DXF file format in revision R2004. The raw transparency value stored as 32 bit value in the DXF namespace as \fBtransparency\fP attribute, has a range from 0 to 255 where 0 is fully transparent and 255 if opaque and has the top byte set to \fB0x02\fP\&. For a more easy usage all graphical entities support the \fI\%transparency\fP property to get and set the transparency as float value in the range frem 0.0 to 1.0 where 0.0 is opaque and 1.0 is fully transparent. The transparency value can be set explicit in the entity, by layer or by block. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new() msp = doc.modelspace() line = msp.add_line((0, 0), (10, 0)) line.transparency = 0.5 .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.colors\fP .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .IP \(bu 2 Autodesk Knowledge Network: \fI\%About Making Objects Transparent\fP .IP \(bu 2 BricsCAD Help Center: \fI\%Entity Transparency\fP .UNINDENT .UNINDENT .UNINDENT .SS Layers .sp Every object has a layer as one of its properties. You may be familiar with layers \- independent drawing spaces that stack on top of each other to create an overall image \- from using drawing programs. Most CAD programs use layers as the primary organizing principle for all the objects that you draw. You use layers to organize objects into logical groups of things that belong together; for example, walls, furniture, and text notes usually belong on three separate layers, for a couple of reasons: .INDENT 0.0 .IP \(bu 2 Layers give you a way to turn groups of objects on and off \- both on the screen and on the plot. .IP \(bu 2 Layers provide the most efficient way of controlling object color and linetype .UNINDENT .sp Create a layer table entry \fI\%Layer\fP by \fBDrawing.layers.add()\fP, assign the layer properties such as color and linetype. Then assign those layers to other DXF entities by setting the DXF attribute \fI\%layer\fP to the layer name as string. .sp The DXF format do not require a layer table entry for a layer. A layer without a layer table entry has the default linetype \fB\(aqContinuous\(aq\fP, a default color of \fB7\fP and a lineweight of \fB\-3\fP which represents the default lineweight of 0.25mm in most circumstances. .SS Layer Properties .sp The advantage of assigning properties to a layer is that entities can inherit this properties from the layer by using the string \fB\(aqBYLAYER\(aq\fP as linetype string, \fB256\fP as color or \fB\-1\fP as lineweight, all these values are the default values for new entities. DXF version R2004 and later also support inheriting \fItrue_color\fP and \fItransparency\fP attributes from a layer. .SS Layer Status .sp The layer status is important for the visibility and the ability to select and edit DXF entities on that layer in CAD applications. \fIEzdxf\fP does not care about the visual representation and works at the level of entity spaces and the entity database and therefore all the layer states documented below are ignored by \fIezdxf\fP\&. This means if you iterate an entity space like the modelspace or the entity database you will get all entities from that entity space regardless the layer status. .INDENT 0.0 .IP \(bu 2 ON: the layer is visible, entities on that layer are visible, selectable and editable .IP \(bu 2 OFF: the layer is not visible, entities on that layer are not visible, not selectable and not editable .IP \(bu 2 FROZEN: the layer is not visible, entities on that layer are not visible, not selectable and not editable, very similar to the OFF status but layers can be frozen individually in VIEWPORTS and freezing layers may speed up some commands in CAD applications like ZOOM, PAN or REGEN. .IP \(bu 2 LOCKED: the layer is visible, entities on that layer are visible but not selectable and not editable .UNINDENT .SS Deleting Layers .sp Deleting a layer is not as simple as it might seem, especially if you are used to use a CAD application like AutoCAD. There is no directory of locations where layers can be used and references to layers can occur even in third\-party data. Deleting the layer table entry removes only the default attributes of that layer and does not delete any layer references automatically. And because a layer can exist without a layer table entry, the layer exist as long as at least one layer reference to the layer exist. .SS Renaming Layers .sp Renaming a layer is also problematic because the DXF format stores the layer references in most cases as text strings, so renaming the layer table entry just creates a new layer and all entities which still have a reference to the old layer now inherit their attributes from an undefined layer table entry with default settings. .SS Viewport Overrides .sp Most of the layer properties can be overriden for each \fI\%Viewport\fP entity individually and this overrides are stored in layer table entry referenced by the handle of the VIEWPORT entity. In contrast the frozen status of layers is store in the VIEWPORT entity. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Layers\fP .IP \(bu 2 \fI\%Tutorial for Viewports in Paperspace\fP .IP \(bu 2 Autodesk Knowledge Network: \fI\%About Layers\fP .IP \(bu 2 BricsCAD Help Center: \fI\%Working with Layers\fP .UNINDENT .UNINDENT .UNINDENT .SS Linetypes .sp The \fI\%linetype\fP defines the rendering pattern of linear graphical entities like LINE, ARC, CIRCLE and so on. The linetype of an entity can be specified by the DXF attribute \fBlinetype\fP, this can be an explicit named linetype or the entity can inherit its linetype from the assigned layer by setting \fBlinetype\fP to \fB\(aqBYLAYER\(aq\fP, which is also the default value. \fBCONTINUOUS\fP is the default linetype for layers with an unspecified linetype. .sp \fIEzdxf\fP creates several standard linetypes, if the argument \fIsetup\fP is \fBTrue\fP when calling \fI\%new()\fP, this simple linetypes are supported by all DXF versions: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(aqR2007\(aq, setup=True) .EE .UNINDENT .UNINDENT [image] .sp In DXF R13 Autodesk introduced complex linetypes which can contain text or shapes. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .IP \(bu 2 \fI\%Tutorial for Creating Linetype Pattern\fP .IP \(bu 2 Autodesk Knowledge Network: \fI\%About Linetypes\fP .IP \(bu 2 BricsCAD Help Center: \fI\%Entity Linetype\fP .UNINDENT .UNINDENT .UNINDENT .SS Linetype Scaling .sp Global linetype scaling can be changed by setting the header variable \fBdoc.header[\(aq$LTSCALE\(aq] = 2\fP, which stretches the line pattern by factor 2. .sp The linetype scaling for a single entity can be set by the DXF attribute \fI\%ltscale\fP, which is supported since DXF R2000. .SS Lineweights .sp The \fI\%lineweight\fP attribute represents the lineweight as integer value in millimeters * 100, e.g. 0.25mm = 25, independently from the unit system used in the DXF document. The \fBlineweight\fP attribute is supported by DXF R2000 and newer. .sp Only certain values are valid, they are stored in \fBezdxf.lldxf.const.VALID_DXF_LINEWEIGHTS\fP: 0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200, 211. .sp Values < 0 have a special meaning and can be imported as constants from \fI\%ezdxf.lldxf.const\fP .TS center; |l|l|. _ T{ \-1 T} T{ LINEWEIGHT_BYLAYER T} _ T{ \-2 T} T{ LINEWEIGHT_BYBLOCK T} _ T{ \-3 T} T{ LINEWEIGHT_DEFAULT T} _ .TE .sp The validator function: \fBezdxf.lldxf.validator.is_valid_lineweight()\fP returns \fBTrue\fP for valid lineweight values otherwise \fBFalse\fP\&. .sp Sample script which shows all valid lineweights: \fI\%valid_lineweights.dxf\fP .sp You have to enable the option to show lineweights in your CAD application or viewer to see the effect on screen, which is disabled by default, the same has to be done in the page setup options for plotting lineweights. .sp Setting the HEADER variable \fB$LWDISPLAY\fP to 1, activates support for displaying lineweights on screen: .INDENT 0.0 .INDENT 3.5 .sp .EX # activate on screen lineweight display doc.header[\(dq$LWDISPLAY\(dq] = 1 .EE .UNINDENT .UNINDENT [image] .sp The lineweight value can be overridden by \fI\%CTB\fP or \fI\%STB\fP files. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Autodesk Knowledge Network: \fI\%About Lineweights\fP .IP \(bu 2 BricsCAD Help Center: \fI\%Entity Lineweight\fP .UNINDENT .UNINDENT .UNINDENT .SS Coordinate Systems .sp \fI\%AutoLISP Reference to Coordinate Systems\fP provided by Autodesk. .sp To brush up you knowledge about vectors, watch the YouTube tutorials of \fI\%3Blue1Brown\fP about \fI\%Linear Algebra\fP\&. .SS WCS .sp World coordinate system \- the reference coordinate system. All other coordinate systems are defined relative to the WCS, which never changes. Values measured relative to the WCS are stable across changes to other coordinate systems. .SS UCS .sp User coordinate system \- the working coordinate system defined by the user to make drawing tasks easier. All points passed to AutoCAD commands, including those returned from AutoLISP routines and external functions, are points in the current UCS. As far as I know, all coordinates stored in DXF files are always WCS or OCS never UCS. .sp User defined coordinate systems are not just helpful for interactive CAD, therefore \fIezdxf\fP provides a converter class \fI\%UCS\fP to translate coordinates from UCS into WCS and vice versa, but always remember: store only WCS or OCS coordinates in DXF files, because there is no method to determine which UCS was active or used to create UCS coordinates. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Table entry \fBUCS\fP .IP \(bu 2 \fI\%ezdxf.math.UCS\fP \- converter between WCS and UCS .UNINDENT .UNINDENT .UNINDENT .SS OCS .sp Object coordinate system are coordinates relative to the object itself. The main goal of OCS is to place 2D elements in 3D space and the OCS is defined by the extrusion vector of the entity. As long the extrusion vector is (0, 0, 1) (the WCS z\-axis) the OCS is coincident to the WCS, which means the OCS coordinates are equal to the WCS coordinates, most of the time this is true for 2D entities. .sp OCS entities: ARC, CIRCLE, TEXT, LWPOLYLINE, HATCH, SOLID, TRACE, INSERT, IMAGE .sp Because \fIezdxf\fP is just an interface to DXF, it does not automatically convert OCS into WCS, this is the domain of the user/application. These lines convert the center of a 3D circle from OCS to WCS: .INDENT 0.0 .INDENT 3.5 .sp .EX ocs = circle.ocs() wcs_center = ocs.to_wcs(circle.dxf.center) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Object Coordinate System (OCS)\fP \- deeper insights into OCS .IP \(bu 2 \fI\%ezdxf.math.OCS\fP \- converter between WCS and OCS .UNINDENT .UNINDENT .UNINDENT .SS DCS .sp Display coordinate system \- the coordinate system into which objects are transformed before they are displayed. The origin of the DCS is the point stored in the AutoCAD system variable TARGET, and its z\-axis is the viewing direction. In other words, a viewport is always a plan view of its DCS. These coordinates can be used to determine where something will be displayed to the AutoCAD user. \fIEzdxf\fP does not use or support DCS in any way. .SS Object Coordinate System (OCS) .INDENT 0.0 .IP \(bu 2 \fI\%DXF Reference for OCS\fP provided by Autodesk. .UNINDENT .sp The points associated with each entity are expressed in terms of the entity’s own object coordinate system (OCS). The OCS was referred to as ECS in previous releases of AutoCAD. .sp With OCS, the only additional information needed to describe the entity’s position in 3D space is the 3D vector describing the z\-axis of the OCS (often referenced as extrusion vector), and the elevation value, which is the distance of the entity xy\-plane to the WCS/OCS origin. .sp For a given z\-axis (extrusion) direction, there are an infinite number of coordinate systems, defined by translating the origin in 3D space and by rotating the x\- and y\-axis around the z\-axis. However, for the same z\-axis direction, there is only one OCS. It has the following properties: .INDENT 0.0 .IP \(bu 2 Its origin coincides with the WCS origin. .IP \(bu 2 The orientation of the x\- and y\-axis within the xy\-plane are calculated in an arbitrary but consistent manner. AutoCAD performs this calculation using the arbitrary axis algorithm (see below). .IP \(bu 2 Because of the \fI\%Arbitrary Axis Algorithm\fP the OCS can only represent a \fBright\-handed\fP coordinate system! .UNINDENT .sp The following entities do not lie in a particular plane. All points are expressed in world coordinates. Of these entities, only lines and points can be extruded. Their extrusion direction can differ from the world z\-axis. .INDENT 0.0 .IP \(bu 2 \fI\%Line\fP .IP \(bu 2 \fI\%Point\fP .IP \(bu 2 \fB3DFace\fP .IP \(bu 2 \fI\%Polyline\fP (3D) .IP \(bu 2 \fI\%Vertex\fP (3D) .IP \(bu 2 \fI\%Polymesh\fP .IP \(bu 2 \fI\%Polyface\fP .IP \(bu 2 \fI\%Viewport\fP .UNINDENT .sp These entities are planar in nature. All points are expressed in object coordinates. All of these entities can be extruded. Their extrusion direction can differ from the world z\-axis. .INDENT 0.0 .IP \(bu 2 \fI\%Circle\fP .IP \(bu 2 \fI\%Arc\fP .IP \(bu 2 \fI\%Solid\fP .IP \(bu 2 \fI\%Trace\fP .IP \(bu 2 \fI\%Text\fP .IP \(bu 2 \fI\%Attrib\fP .IP \(bu 2 \fBAttdef\fP .IP \(bu 2 \fI\%Shape\fP .IP \(bu 2 \fI\%Insert\fP .IP \(bu 2 \fI\%Polyline\fP (2D) .IP \(bu 2 \fI\%Vertex\fP (2D) .IP \(bu 2 \fI\%LWPolyline\fP .IP \(bu 2 \fI\%Hatch\fP .IP \(bu 2 \fI\%Image\fP .UNINDENT .sp Some of a \fI\%Dimension\fP’s points are expressed in WCS and some in OCS. .SS Elevation .sp Elevation group code 38: .sp Exists only in output from versions prior to R11. Otherwise, Z coordinates are supplied as part of each of the entity’s defining points. .SS Arbitrary Axis Algorithm .INDENT 0.0 .IP \(bu 2 \fI\%DXF Reference for Arbitrary Axis Algorithm\fP provided by Autodesk. .UNINDENT .sp The arbitrary axis algorithm is used by AutoCAD internally to implement the arbitrary but consistent generation of object coordinate systems for all entities that use object coordinates. .sp Given a unit\-length vector to be used as the z\-axis of a coordinate system, the arbitrary axis algorithm generates a corresponding x\-axis for the coordinate system. The y\-axis follows by application of the \fBright\-hand\fP rule. .sp We are looking for the arbitrary x\- and y\-axis to go with the normal Az (the arbitrary z\-axis). They will be called Ax and Ay (using \fI\%Vec3\fP): .INDENT 0.0 .INDENT 3.5 .sp .EX Az = Vec3(entity.dxf.extrusion).normalize() # normal (extrusion) vector if (abs(Az.x) < 1/64.) and (abs(Az.y) < 1/64.): Ax = Vec3(0, 1, 0).cross(Az).normalize() # the cross\-product operator else: Ax = Vec3(0, 0, 1).cross(Az).normalize() # the cross\-product operator Ay = Az.cross(Ax).normalize() .EE .UNINDENT .UNINDENT .SS WCS to OCS .INDENT 0.0 .INDENT 3.5 .sp .EX def wcs_to_ocs(point): px, py, pz = Vec3(point) # point in WCS x = px * Ax.x + py * Ax.y + pz * Ax.z y = px * Ay.x + py * Ay.y + pz * Ay.z z = px * Az.x + py * Az.y + pz * Az.z return Vec3(x, y, z) .EE .UNINDENT .UNINDENT .SS OCS to WCS .INDENT 0.0 .INDENT 3.5 .sp .EX Wx = wcs_to_ocs((1, 0, 0)) Wy = wcs_to_ocs((0, 1, 0)) Wz = wcs_to_ocs((0, 0, 1)) def ocs_to_wcs(point): px, py, pz = Vec3(point) # point in OCS x = px * Wx.x + py * Wx.y + pz * Wx.z y = px * Wy.x + py * Wy.y + pz * Wy.z z = px * Wz.x + py * Wz.y + pz * Wz.z return Vec3(x, y, z) .EE .UNINDENT .UNINDENT .SS DXF Units .sp The \fI\%DXF reference\fP has no explicit information how to handle units in DXF, any information in this section is based on experiments with BricsCAD and may differ in other CAD applications, BricsCAD tries to be as compatible with AutoCAD as possible. Therefore, this information should also apply to AutoCAD. .sp Please open an issue on \fI\%github\fP if you have any corrections or additional information about this topic. .SS Length Units .sp Any length or coordinate value in DXF is unitless in the first place, there is no unit information attached to the value. The unit information comes from the context where a DXF entity is used. The document/modelspace get the unit information from the header variable $INSUNITS, paperspace and block layouts get their unit information from the attribute \fI\%units\fP\&. The modelspace object has also a \fBunits\fP property, but this value do not represent the modelspace units, this value is always set to 0 “unitless”. .sp Get and set document/modelspace units as enum by the \fI\%Drawing\fP property \fBunits\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import units doc = ezdxf.new() # Set centimeter as document/modelspace units doc.units = units.CM # which is a shortcut (including validation) for doc.header[\(aq$INSUNITS\(aq] = units.CM .EE .UNINDENT .UNINDENT .SS Block Units .sp As said each block definition can have independent units, but there is no implicit unit conversion applied, not in CAD applications and not in \fIezdxf\fP\&. .sp When inserting a block reference (INSERT) into the modelspace or another block layout with different units, the scaling factor between these units \fBmust\fP be applied explicit as DXF attributes (\fBxscale\fP, …) of the \fI\%Insert\fP entity, e.g. modelspace in meters and block in centimeters, x\-, y\- and z\-scaling has to be 0.01: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.units = units.M my_block = doc.blocks.new(\(aqMYBLOCK\(aq) my_block.units = units.CM block_ref = msp.add_block_ref(\(aqMYBLOCK\(aq) # Set uniform scaling for x\-, y\- and z\-axis block_ref.set_scale(0.01) .EE .UNINDENT .UNINDENT .sp Use helper function \fI\%conversion_factor()\fP to calculate the scaling factor between units: .INDENT 0.0 .INDENT 3.5 .sp .EX factor = units.conversion_factor(doc.units, my_block.units) # factor = 100 for 1m is 100cm # scaling factor = 1 / factor block_ref.set_scale(1.0/factor) .EE .UNINDENT .UNINDENT .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 It is never a good idea to use different measurement system in one project, ask the NASA about their Mars Climate Orbiter from 1999. The same applies for units of the same measurement system, just use one unit like meters or inches. .UNINDENT .UNINDENT .SS Angle Units .sp Angles are always in degrees (360 deg = full circle) in counter\-clockwise orientation, unless stated explicit otherwise. .SS Display Format .sp How values are shown in the CAD GUI is controlled by the header variables $LUNITS and $AUNITS, but this has no meaning for values stored in DXF files. .SS $INSUNITS .sp The most important setting is the header variable $INSUNITS, this variable defines the drawing units for the modelspace and therefore for the DXF document if no further settings are applied. .sp The modelspace LAYOUT entity has a property \fI\%units\fP as any layout like object, but it seem to have no meaning for the modelspace, BricsCAD set this property always to 0, which means unitless. .sp The most common units are 6 for meters and 1 for inches. .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(aq$INSUNITS\(aq] = 6 .EE .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ 0 T} T{ Unitless T} _ T{ 1 T} T{ Inches, \fBunits.IN\fP T} _ T{ 2 T} T{ Feet, \fBunits.FT\fP T} _ T{ 3 T} T{ Miles, \fBunits.MI\fP T} _ T{ 4 T} T{ Millimeters, \fBunits.MM\fP T} _ T{ 5 T} T{ Centimeters, \fBunits.CM\fP T} _ T{ 6 T} T{ Meters, \fBunits.M\fP T} _ T{ 7 T} T{ Kilometers, \fBunits.KM\fP T} _ T{ 8 T} T{ Microinches T} _ T{ 9 T} T{ Mils T} _ T{ 10 T} T{ Yards, \fBunits.YD\fP T} _ T{ 11 T} T{ Angstroms T} _ T{ 12 T} T{ Nanometers T} _ T{ 13 T} T{ Microns T} _ T{ 14 T} T{ Decimeters, \fBunits.DM\fP T} _ T{ 15 T} T{ Decameters T} _ T{ 16 T} T{ Hectometers T} _ T{ 17 T} T{ Gigameters T} _ T{ 18 T} T{ Astronomical units T} _ T{ 19 T} T{ Light years T} _ T{ 20 T} T{ Parsecs T} _ T{ 21 T} T{ US Survey Feet T} _ T{ 22 T} T{ US Survey Inch T} _ T{ 23 T} T{ US Survey Yard T} _ T{ 24 T} T{ US Survey Mile T} _ .TE .sp See also enumeration \fI\%ezdxf.enums.InsertUnits\fP\&. .SS $MEASUREMENT .sp The header variable $MEASUREMENT controls whether the current drawing uses imperial or metric hatch pattern and linetype files: .sp This setting is independent from $INSUNITS, it is possible to set the drawing units to inch and use metric linetypes and hatch pattern. .sp In BricsCAD the base scaling of linetypes and hatch pattern is defined by the $MEASUREMENT value, the value of $INSUNITS is ignored. .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(aq$MEASUREMENT\(aq] = 1 .EE .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ 0 T} T{ English T} _ T{ 1 T} T{ Metric T} _ .TE .sp See also enumeration \fI\%ezdxf.enums.Measurement\fP .SS $LUNITS .sp The header variable $LUNITS defines how CAD applications display linear values in the GUI and has no meaning for \fIezdxf\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(aq$LUNITS\(aq] = 2 .EE .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ 1 T} T{ Scientific T} _ T{ 2 T} T{ Decimal (default) T} _ T{ 3 T} T{ Engineering T} _ T{ 4 T} T{ Architectural T} _ T{ 5 T} T{ Fractional T} _ .TE .sp See also enumeration \fI\%ezdxf.enums.LengthUnits\fP .SS $AUNITS .sp The header variable $AUNITS defines how CAD applications display angular values in the GUI and has no meaning for \fIezdxf\fP, DXF angles are always stored as degrees in counter\-clockwise orientation, unless stated explicit otherwise: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(aq$AUNITS\(aq] = 0 .EE .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ 0 T} T{ Decimal degrees T} _ T{ 1 T} T{ Degrees/minutes/seconds T} _ T{ 2 T} T{ Grad T} _ T{ 3 T} T{ Radians T} _ .TE .sp See also enumeration \fI\%ezdxf.enums.AngularUnits\fP .SS Helper Tools .INDENT 0.0 .TP .B ezdxf.units.conversion_factor(source_units: \fI\%InsertUnits\fP, target_units: \fI\%InsertUnits\fP) -> float Returns the conversion factor to represent \fIsource_units\fP in \fItarget_units\fP\&. .sp E.g. millimeter in centimeter \fBconversion_factor(MM, CM)\fP returns 0.1, because 1 mm = 0.1 cm .UNINDENT .INDENT 0.0 .TP .B ezdxf.units.unit_name(enum: int) -> str Returns the name of the unit enum. .UNINDENT .INDENT 0.0 .TP .B ezdxf.units.angle_unit_name(enum: int) -> str Returns the name of the angle unit enum. .UNINDENT .SS Modelspace .sp The modelspace contains the “real” world representation of the drawing subjects in real world units and is displayed in the tab called “Model” in CAD applications. The modelspace is always present and can’t be deleted. .sp The modelspace object is acquired by the method \fI\%modelspace()\fP of the \fI\%Drawing\fP class and new entities should be added to the modelspace by factory methods: \fI\%Thematic Index of Layout Factory Methods\fP\&. .sp This is a common idiom for creating a new document and acquiring the modelspace: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new() msp = doc.modelspace() .EE .UNINDENT .UNINDENT .sp The modelspace can have one or more rectangular areas called modelspace viewports. The modelspace viewports can be used for displaying different views of the modelspace from different locations of the modelspace or viewing directions. It is important to know that modelspace viewports (\fI\%VPort\fP) are not the same as paperspace viewport entities (\fI\%Viewport\fP). .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Reference of class \fI\%Modelspace\fP .IP \(bu 2 \fI\%Thematic Index of Layout Factory Methods\fP .IP \(bu 2 Example for usage of modelspace viewports: \fI\%tiled_window_setup.py\fP .UNINDENT .UNINDENT .UNINDENT .SS Paperspace .sp A paperspace layout is where the modelspace drawing content is assembled and organized for 2D output, such as printing on a sheet of paper, or as a digital document, such as a PDF file. .sp Each DXF document can have one or more paperspace layouts but the DXF version R12 supports only one paperspace layout and it is not recommended to rely on paperspace layouts in DXF version R12. .sp Graphical entities can be added to the paperspace by factory methods: \fI\%Thematic Index of Layout Factory Methods\fP\&. Views or “windows” to the modelspace are added as \fI\%Viewport\fP entities, each viewport displays a region of the modelspace and can have an individual scaling factor, rotation angle, clipping path, view direction or overridden layer attributes. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Reference of class \fI\%Paperspace\fP .IP \(bu 2 \fI\%Thematic Index of Layout Factory Methods\fP .IP \(bu 2 Example for usage of paperspace viewports: \fI\%viewports_in_paperspace.py\fP .UNINDENT .UNINDENT .UNINDENT .SS Blocks .sp Blocks are collections of DXF entities which can be placed multiple times as block references in different layouts and other block definitions. The block reference (\fI\%Insert\fP) can be rotated, scaled, placed in 3D space by \fI\%OCS\fP and arranged in a grid like manner, each \fI\%Insert\fP entity can have individual attributes (\fI\%Attrib\fP) attached. .SS Block Attributes .sp A block attribute (\fI\%Attrib\fP) is a text annotation attached to a block reference with an associated tag. Attributes are often used to add information to block references which can be evaluated and exported by CAD applications. .SS Extended Block Features .sp Autodesk added many new features to BLOCKS (dynamic blocks, constraints) as undocumented DXF entities, many of these features are not fully supported by other CAD application and \fIezdxf\fP also has no support or these features beyond the preservation of these undocumented DXF entities. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Blocks\fP Section .IP \(bu 2 \fI\%Tutorial for Blocks\fP .UNINDENT .UNINDENT .UNINDENT .SS Layout Extents and Limits .sp The \fIextents\fP and \fIlimits\fP of an layout represents borders which can be referenced by the ZOOM command or read from some header variables from the \fI\%HeaderSection\fP, if the creator application maintains these values – \fIezdxf\fP does this not automatically. .SS Extents .sp The \fIextents\fP of an layout are determined by the maximum extents of all DXF entities that are in this layout. The command: .INDENT 0.0 .INDENT 3.5 .sp .EX ZOOM extents .EE .UNINDENT .UNINDENT .sp sets the current viewport to the extents of the currently selected layout. .sp A paperspace layout in an arbitrary zoom state: [image] .sp The same layout after the \fBZOOM extents\fP command: [image] .SS Limits .sp Sets an invisible rectangular boundary in the drawing area that can limit the grid display and limit clicking or entering point locations. The default limits for paperspace layouts is defined by the paper size. .sp The layout from above after the \fBZOOM all\fP command: [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 The AutoCAD online reference for the \fI\%ZOOM\fP and the \fI\%LIMITS\fP command. .UNINDENT .UNINDENT .SS Read Stored Values .sp The extents of the modelspace (the tab called “Model”) are stored in the header variable \fB$EXTMIN\fP and \fB$EXTMAX\fP\&. The default values of \fB$EXTMIN\fP is (+1e20, +1e20, +1e20) and \fB$EXTMAX\fP is (\-1e20, \-1e20, \-1e20), which do not describe real borders. These values are copies of the extents attributes of the \fI\%Layout\fP object as \fBLayout.dxf.extmin\fP and \fBLayout.dxf.extmax\fP\&. .sp The limits of the modelspace are stored in the header variables \fB$LIMMIN\fP and \fB$LIMMAX\fP and have default values of (0, 0) and (420, 297), the default paper size of \fIezdxf\fP in drawing units. These are copies of the \fI\%Layout\fP attributes \fBLayout.dxf.extmin\fP and \fBLayout.dxf.extmax\fP\&. .sp The extents and the limits of the \fIactual\fP paperspace layout, which is the last activated paperspace layout tab, are stored in the header variable \fB$PEXTMIN\fP, \fB$PEXTMAX\fP, \fB$PLIMMIN\fP and \fB$PLIMMAX\fP\&. .sp Each paperspace layout has its own values stored in the \fI\%Layout\fP attributes \fBLayout.dxf.extmin\fP, \fBLayout.dxf.extmax\fP, \fBLayout.dxf.limmin\fP and \fBLayout.dxf.limmax\fP\&. .SS Setting Extents and Limits .sp Since v0.16 \fIezdxf\fP it is sufficient to define the attributes for \fIextents\fP and \fIlimits\fP (\fBLayout.dxf.extmax\fP, \fBLayout.dxf.limmin\fP and \fBLayout.dxf.limmax\fP) of \fI\%Layout\fP object. The header variables are synchronized when the document is saved. .sp The extents of a layout are not calculated automatically by \fIezdxf\fP, as this can take a long time for large documents and correct values are not required to create a valid DXF document. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 How to: \fI\%Calculate Extents for the Modelspace\fP .UNINDENT .UNINDENT .SS Font Resources .sp DXF relies on the infrastructure installed by AutoCAD like the included SHX files or True Type fonts. There is no simple way to store additional information about a used fonts beside the plain file system name like \fB\(dqarial.ttf\(dq\fP\&. The CAD application or viewer which opens the DXF file has to have access to the specified fonts used in your DXF document or it has to use an appropriate replacement font, which is not that easy in the age of unicode. Later DXF versions can store font family names in the XDATA of the STYLE entity but not all CAD application use this information. .SH TUTORIALS .SS Tutorial for Getting Data from DXF Files .sp This tutorial shows how to get data from an existing DXF document. If you are a new user of \fIezdxf\fP, read also the tutorial \fI\%Usage for Beginners\fP\&. .sp Loading the DXF file: .INDENT 0.0 .INDENT 3.5 .sp .EX import sys import ezdxf try: doc = ezdxf.readfile(\(dqyour_dxf_file.dxf\(dq) except IOError: print(f\(dqNot a DXF file or a generic I/O error.\(dq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(dqInvalid or corrupted DXF file.\(dq) sys.exit(2) .EE .UNINDENT .UNINDENT .sp This works well for DXF files from trusted sources like AutoCAD or BricsCAD, for loading DXF files with minor or major flaws look at the \fI\%ezdxf.recover\fP module. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Document Management\fP .IP \(bu 2 \fI\%Usage for Beginners\fP .UNINDENT .UNINDENT .UNINDENT .SS Layouts .sp The term layout is used as a synonym for an arbitrary entity space which can contain DXF entities like LINE, CIRCLE, TEXT and so on. Each DXF entity can only reside in exact one layout. .sp There are three different layout types: .INDENT 0.0 .IP \(bu 2 \fI\%Modelspace\fP: the common construction space .IP \(bu 2 \fI\%Paperspace\fP: used to to create print layouts .IP \(bu 2 \fI\%BlockLayout\fP: reusable elements, every block has its own entity space .UNINDENT .sp A DXF document consist of exact one modelspace and at least one paperspace. DXF R12 has only one unnamed paperspace the later DXF versions support more than one paperspace and each paperspace has a name. .SS Getting the modelspace layout .sp The modelspace contains the “real” world representation of the drawing subjects in real world units. The modelspace has the fixed name “Model” and the DXF document has a special getter method \fI\%modelspace()\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX msp = doc.modelspace() .EE .UNINDENT .UNINDENT .SS Iterate over DXF entities of a layout .sp This code shows how to iterate over all DXF entities in modelspace: .INDENT 0.0 .INDENT 3.5 .sp .EX # helper function def print_entity(e): print(\(dqLINE on layer: %s\en\(dq % e.dxf.layer) print(\(dqstart point: %s\en\(dq % e.dxf.start) print(\(dqend point: %s\en\(dq % e.dxf.end) # iterate over all entities in modelspace msp = doc.modelspace() for e in msp: if e.dxftype() == \(dqLINE\(dq: print_entity(e) # entity query for all LINE entities in modelspace for e in msp.query(\(dqLINE\(dq): print_entity(e) .EE .UNINDENT .UNINDENT .sp All layout objects supports the standard Python iterator protocol and the \fBin\fP operator. .SS Access DXF attributes of an entity .sp The \fBe.dxftype()\fP method returns the DXF type, the DXF type is always an uppercase string like \fB\(dqLINE\(dq\fP\&. All DXF attributes of an entity are grouped in the namespace attribute \fBdxf\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX e.dxf.layer # layer of the entity as string e.dxf.color # color of the entity as integer .EE .UNINDENT .UNINDENT .sp See \fI\%Common graphical DXF attributes\fP .sp If a DXF attribute is not set (the DXF attribute does not exist), a \fBDXFValueError\fP will be raised. The \fBget()\fP method returns a default value in this case or \fBNone\fP if no default value is specified: .INDENT 0.0 .INDENT 3.5 .sp .EX # If DXF attribute \(aqpaperspace\(aq does not exist, the entity defaults # to modelspace: p = e.dxf.get(\(dqpaperspace\(dq, 0) .EE .UNINDENT .UNINDENT .sp or check beforehand if the attribute exist: .INDENT 0.0 .INDENT 3.5 .sp .EX if e.dxf.hasattr(\(dqpaperspace\(dq): ... .EE .UNINDENT .UNINDENT .sp An unsupported DXF attribute raises a \fBDXFAttributeError\fP, to check if an attribute is supported by an entity use: .INDENT 0.0 .INDENT 3.5 .sp .EX if e.dxf.is_supported(\(dqpaperspace\(dq): ... .EE .UNINDENT .UNINDENT .SS Getting a paperspace layout .INDENT 0.0 .INDENT 3.5 .sp .EX paperspace = doc.paperspace(\(dqlayout0\(dq) .EE .UNINDENT .UNINDENT .sp The code above retrieves the paperspace named \fBlayout0\fP, the usage of the \fI\%Paperspace\fP object is the same as of the modelspace object. DXF R12 provides only one paperspace, therefore the paperspace name in the method call \fBdoc.paperspace(\(dqlayout0\(dq)\fP is ignored or can be left off. For newer DXF versions you can get a list of the available layout names by the methods \fI\%layout_names()\fP and \fI\%layout_names_in_taborder()\fP\&. .SS Retrieve entities by query language .sp \fIEzdxf\fP provides a flexible query language for DXF entities. All layout types have a \fI\%query()\fP method to start an entity query or use the \fI\%ezdxf.query.new()\fP function. .sp The query string is the combination of two queries, first the required entity query and second the optional attribute query, enclosed in square brackets: \fB\(dqEntityQuery[AttributeQuery]\(dq\fP .sp The entity query is a whitespace separated list of DXF entity names or the special name \fB*\fP\&. Where \fB*\fP means all DXF entities, all DXF names have to be uppercase. The \fB*\fP search can exclude entity types by adding the entity name with a preceding \fB!\fP (e.g. \fB* !LINE\fP, search all entities except lines). .sp The attribute query is used to select DXF entities by its DXF attributes. The attribute query is an addition to the entity query and matches only if the entity already match the entity query. The attribute query is a boolean expression, supported operators: \fBand\fP, \fBor\fP, \fB!\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Entity Query String\fP .UNINDENT .UNINDENT .sp Get all LINE entities from the modelspace: .INDENT 0.0 .INDENT 3.5 .sp .EX msp = doc.modelspace() lines = msp.query(\(dqLINE\(dq) .EE .UNINDENT .UNINDENT .sp The result container \fI\%EntityQuery\fP also provides the \fBquery()\fP method to further refine the query, such as retrieving all LINE entities at layer \fBconstruction\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX construction_lines = lines.query(\(aq*[layer==\(dqconstruction\(dq]\(aq) .EE .UNINDENT .UNINDENT .sp The \fB*\fP is a wildcard for all DXF types, in this case you could also use \fBLINE\fP instead of \fB*\fP, \fB*\fP works here because the source just contains LINE entities. .sp This could be executed as a single query: .INDENT 0.0 .INDENT 3.5 .sp .EX lines = msp.query(\(aqLINE[layer==\(dqconstruction\(dq]\(aq) .EE .UNINDENT .UNINDENT .sp An advanced query for getting all modelspace entities at layer \fBconstruction\fP, but excluding entities with linetype \fBDASHED\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX not_dashed_entities = msp.query(\(aq*[layer==\(dqconstruction\(dq and linetype!=\(dqDASHED\(dq]\(aq) .EE .UNINDENT .UNINDENT .SS Extended EntityQuery Features .sp The \fI\%EntityQuery\fP class has properties and overloaded operators to build extended queries by Python features instead of a query string. .sp Same task as in the previous section but using features of the \fI\%EntityQuery\fP container: .INDENT 0.0 .INDENT 3.5 .sp .EX # The overloaded rational operators return an EntityQuery object and not a bool value! lines = msp.query(\(dqLINES\(dq).layer == \(dqconstruction\(dq not_dashed_lines = lines.linetype != \(dqDASHED\(dq .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Extended EntityQuery Features\fP .UNINDENT .UNINDENT .SS Retrieve entities by groupby() function .sp The \fI\%groupby()\fP function searches and group entities by a user defined criteria. As an example let’s group all entities from modelspace by layer, the result will be a \fIdict\fP with layer names as dict\-key and a list of all entities from the modelspace matching this layer as dict\-value: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.groupby import groupby group = groupby(entities=msp, dxfattrib=\(dqlayer\(dq) .EE .UNINDENT .UNINDENT .sp The \fIentities\fP argument can be any container or generator which yields DXF entities: .INDENT 0.0 .INDENT 3.5 .sp .EX group = msp.groupby(dxfattrib=\(dqlayer\(dq) for layer, entities in group.items(): print(f\(aqLayer \(dq{layer}\(dq contains following entities:\(aq) for entity in entities: print(f\(dq {entity}\(dq) print(\(dq\-\(dq*40) .EE .UNINDENT .UNINDENT .sp The previous example shows how to group entities by a single DXF attribute. For a more advanced query create a custom key function, which accepts a DXF entity as argument and returns a hashable value as dict\-key or \fBNone\fP to exclude the entity. .sp The following example shows how to group entities by layer and color, the dict\-key is a \fB(layer, color)\fP tuple and the dict\-value is a list of entities with matching DXF attributes: .INDENT 0.0 .INDENT 3.5 .sp .EX def layer_and_color_key(entity): # return None to exclude entities from the result container if entity.dxf.layer == \(dq0\(dq: # exclude entities from default layer \(dq0\(dq return None else: return entity.dxf.layer, entity.dxf.color group = msp.groupby(key=layer_and_color_key) for key, entities in group.items(): print(f\(aqGrouping criteria \(dq{key}\(dq matches following entities:\(aq) for entity in entities: print(f\(dq {entity}\(dq) print(\(dq\-\(dq*40) .EE .UNINDENT .UNINDENT .sp The \fI\%groupby()\fP function catches \fBDXFAttributeError\fP exceptions while processing entities and excludes this entities from the result. There is no need to worry about DXF entities which do not support certain attributes, they will be excluded automatically. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%groupby()\fP documentation .UNINDENT .UNINDENT .SS Tutorial for Creating DXF Drawings .sp Create a new DXF document by the \fI\%ezdxf.new()\fP function: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # create a new DXF R2010 document doc = ezdxf.new(\(dqR2010\(dq) # add new entities to the modelspace msp = doc.modelspace() # add a LINE entity msp.add_line((0, 0), (10, 0)) # save the DXF document doc.saveas(\(dqline.dxf\(dq) .EE .UNINDENT .UNINDENT .sp New entities are always added to layouts, a layout can be the modelspace, a paperspace layout or a block layout. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Thematic Index of Layout Factory Methods\fP .UNINDENT .UNINDENT .SS Predefined Resources .sp \fIEzdxf\fP creates new DXF documents with as little content as possible, this means only the resources that are absolutely necessary are created. The \fI\%ezdxf.new()\fP function can create some standard resources, such as linetypes and text styles, by setting the argument \fIsetup\fP to \fBTrue\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(\(dqR2010\(dq, setup=True) msp = doc.modelspace() msp.add_line((0, 0), (10, 0), dxfattribs={\(dqlinetype\(dq: \(dqDASHED\(dq}) .EE .UNINDENT .UNINDENT .sp The defined standard linetypes are shown in the basic concept section for \fI\%Linetypes\fP and the available text styles are shown in the \fI\%Tutorial for Text\fP\&. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 To see the defined text styles in a DXF viewer or CAD application, the applications have to know where the referenced TTF fonts can be found. This configuration is not possible by \fIezdxf\fP and has to be done for each application as described in their documentation. .sp See also: \fI\%Font Resources\fP .UNINDENT .UNINDENT .SS Simple DXF R12 drawings .sp The \fI\%r12writer\fP add\-on creates simple DXF R12 drawings with a restricted set of DXF types: LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE and POLYLINE. .sp The advantage of the \fI\%r12writer\fP is the speed and the small memory footprint, all entities are written directly to a file or stream without creating a document structure in memory. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%r12writer\fP .UNINDENT .UNINDENT .SS Tutorial for Common Graphical Attributes .sp The graphical attributes \fBcolor\fP, \fBlinetype\fP, \fBlineweight\fP, \fBtrue_color\fP, \fBtransparency\fP, \fBltscale\fP and \fBinvisible\fP are available for all graphical DXF entities and are located in the DXF namespace attribute \fBdxf\fP of the DXF entities. All these attributes are optional and all except for \fBtrue_color\fP and \fBtransparency\fP have a default value. .sp Not all of these attributes are supported by all DXF versions. This table shows the minimum required DXF version for each attribute: .TS center; |l|l|. _ T{ R12 T} T{ \fBcolor\fP, \fBlinetype\fP T} _ T{ R2000 T} T{ \fBlineweight\fP, \fBltscale\fP, \fBinvisible\fP T} _ T{ R2004 T} T{ \fBtrue_color\fP, \fBtransparency\fP T} _ .TE .SS Color .sp Please read the section about the \fI\%AutoCAD Color Index (ACI)\fP to understand the basics. .sp The usage of the \fI\%color\fP attribute is very straight forward. Setting the value is: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.color = 1 .EE .UNINDENT .UNINDENT .sp and getting the value looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX value = entity.dxf.color .EE .UNINDENT .UNINDENT .sp The \fBcolor\fP attribute has a default value of 256, which means take the color defined by the layer associated to the entity. The \fI\%ezdxf.colors\fP module defines some constants for often used color values: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.color = ezdxf.colors.RED .EE .UNINDENT .UNINDENT .sp The \fI\%ezdxf.colors.aci2rgb()\fP function converts the ACI value to the RGB value of the default modelspace palette. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basics about \fI\%AutoCAD Color Index (ACI)\fP .IP \(bu 2 \fI\%ezdxf.colors\fP module .UNINDENT .UNINDENT .UNINDENT .SS True Color .sp Please read the section about \fI\%True Color\fP to understand the basics. .sp The easiest way is to use the \fBrgb\fP property to set and get the true color values as RGB tuples: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.rgb = (255, 128, 16) .EE .UNINDENT .UNINDENT .sp The \fBrgb\fP property return \fBNone\fP if the \fBtrue_color\fP attribute is not present: .INDENT 0.0 .INDENT 3.5 .sp .EX rgb = entity.rgb if rgb is not None: r, g, b = rgb .EE .UNINDENT .UNINDENT .sp Setting and getting the \fBtrue_color\fP DXF attribute directly is possible and the \fI\%ezdxf.colors\fP module has helper function to convert RGB tuples to 24\-bit value and back: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.true_color = ezdxf.colors.rgb2int(255, 128, 16) .EE .UNINDENT .UNINDENT .sp The \fBtrue_color\fP attribute is optional does not have a default value and therefore it is not safe to use the attribute directly, check if the attribute exists beforehand: .INDENT 0.0 .INDENT 3.5 .sp .EX if entity.dxf.hasattr(\(dqtrue_color\(dq): r, g, b = ezdxf.colors.int2rgb(entity.dxf.true_color) .EE .UNINDENT .UNINDENT .sp or use the \fBget()\fP method of the \fBdxf\fP namespace attribute to get a default value if the attribute does not exist: .INDENT 0.0 .INDENT 3.5 .sp .EX r, g, b = ezdxf.colors.int2rgb(entity.dxf.get(\(dqtrue_color\(dq, 0) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basics about \fI\%True Color\fP .IP \(bu 2 \fI\%ezdxf.colors\fP module .UNINDENT .UNINDENT .UNINDENT .SS Transparency .sp Please read the section about \fI\%Transparency\fP to understand the basics. .sp It’s recommended to use the \fI\%transparency\fP property of the \fI\%DXFGraphic\fP base class. The \fBtransparency\fP property is a float value in the range from 0.0 to 1.0 where 0.0 is opaque and 1.0 if fully transparent: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.transparency = 0.5 .EE .UNINDENT .UNINDENT .sp or set the values of the DXF attribute by constants defined in the \fI\%ezdxf.colors\fP module: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.transparency = ezdxf.colors.TRANSPARENCY_50 .EE .UNINDENT .UNINDENT .sp The default setting for \fBtransparency\fP in CAD applications is always transparency by layer, but the \fBtransparency\fP property in \fIezdxf\fP has a default value of 0.0 (opaque), so there are additional entity properties to check if the transparency value should be taken from the associated entity layer or from the parent block: .INDENT 0.0 .INDENT 3.5 .sp .EX if entity.is_transparency_by_layer: ... elif entity.is_transparency_by_block: ... else: ... .EE .UNINDENT .UNINDENT .sp The top level entity attribute \fBtransparency\fP does not support setting transparency by layer or block: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf import colors \&... # set transparency by layer by removing the DXF attribute \(dqtransparency\(dq: entity.dxf.discard(\(dqtransparency\(dq) # set transparency by block: entity.dxf.transparency = colors.TRANSPARENCY_BYBLOCK # there are also some handy constants in the colors module: # TRANSPARENCY_10 upto TRANSPARENCY_90 in steps of 10 entity.dxf.transparency = colors.TRANSPARENCY_30 # set 30% transparency entity.dxf.transparency = colors.OPAQUE .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basics about \fI\%Transparency\fP .IP \(bu 2 \fI\%ezdxf.colors\fP module .UNINDENT .UNINDENT .UNINDENT .SS Linetype .sp Please read the section about \fI\%Linetypes\fP to understand the basics. .sp The \fBlinetype\fP attribute contains the name of the linetype as string and can be set by the \fBdxf\fP namespace attribute directly: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.linetype = \(dqDASHED\(dq # linetype DASHED must exist! .EE .UNINDENT .UNINDENT .sp The \fBlinetype\fP attribute is optional and has a default value of “BYLAYER”, so the attribute can always be used without any concerns: .INDENT 0.0 .INDENT 3.5 .sp .EX name = entity.dxf.linetype .EE .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Make sure the linetype you assign to an entity is really defined in the linetype table otherwise AutoCAD will not open the DXF file. There are no implicit checks for that by \fIezdxf\fP but you can call the \fI\%audit()\fP method of the DXF document explicitly to validate the document before exporting. .UNINDENT .UNINDENT .sp \fIEzdxf\fP creates new DXF documents with as little content as possible, this means only the resources that are absolutely necessary are created. The \fI\%ezdxf.new()\fP function can create some standard linetypes by setting the argument \fIsetup\fP to \fBTrue\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(dqR2010\(dq, setup=True) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basics about \fI\%Linetypes\fP .IP \(bu 2 \fI\%Tutorial for Creating Linetype Pattern\fP .UNINDENT .UNINDENT .UNINDENT .SS Lineweight .sp Please read the section about \fI\%Lineweights\fP to understand the basics. .sp The \fBlineweight\fP attribute contains the lineweight as an integer value and can be set by the \fBdxf\fP namespace attribute directly: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.lineweight = 25 .EE .UNINDENT .UNINDENT .sp The \fBlineweight\fP value is the line width in millimeters times 100 e.g. 0.25mm = 25, but only certain values are valid for more information go to section: \fI\%Lineweights\fP\&. .sp Values < 0 have a special meaning and can be imported as constants from \fI\%ezdxf.lldxf.const\fP .TS center; |l|l|. _ T{ \-1 T} T{ LINEWEIGHT_BYLAYER T} _ T{ \-2 T} T{ LINEWEIGHT_BYBLOCK T} _ T{ \-3 T} T{ LINEWEIGHT_DEFAULT T} _ .TE .sp The \fBlineweight\fP attribute is optional and has a default value of \-1, so the attribute can always be used without any concerns: .INDENT 0.0 .INDENT 3.5 .sp .EX lineweight = entity.dxf.lineweight .EE .UNINDENT .UNINDENT .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 You have to enable the option to show lineweights in your CAD application or viewer to see the effect on screen, which is disabled by default, the same has to be done in the page setup options for plotting lineweights. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX # activate on screen lineweight display doc.header[\(dq$LWDISPLAY\(dq] = 1 .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basics about \fI\%Lineweights\fP .UNINDENT .UNINDENT .UNINDENT .SS Linetype Scale .sp The \fBltscale\fP attribute scales the linetype pattern by a float value and can be set by the \fBdxf\fP namespace attribute directly: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.ltscale = 2.0 .EE .UNINDENT .UNINDENT .sp The \fBltscale\fP attribute is optional and has a default value of 1.0, so the attribute can always be used without any concerns: .INDENT 0.0 .INDENT 3.5 .sp .EX scale = entity.dxf.ltscale .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basics about \fI\%Linetypes\fP .UNINDENT .UNINDENT .UNINDENT .SS Invisible .sp The \fBinvisible\fP attribute an boolean value (0/1) which defines if an entity is invisible or visible and can be set by the \fBdxf\fP namespace attribute directly: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.invisible = 1 .EE .UNINDENT .UNINDENT .sp The \fBinvisible\fP attribute is optional and has a default value of 0, so the attribute can always be used without any concerns: .INDENT 0.0 .INDENT 3.5 .sp .EX is_invisible = bool(entity.dxf.invisible) .EE .UNINDENT .UNINDENT .SS GfxAttribs .sp When adding new entities to an entity space like the modelspace or a block definition, the factory methods expect the graphical DXF attributes by the argument \fIdxfattribs\fP\&. This object can be a Python \fBdict\fP where the key is the DXF attribute name and the value is the attribute value, or better use the \fI\%GfxAttribs\fP object which has some additional validation checks and support for code completions by IDEs: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.gfxattribs import GfxAttribs doc = ezdxf.new() msp = doc.modelspace() line = msp.add_line( (0, 0), (10, 10), dxfattribs=GfxAttribs(layer=\(dq0\(dq, rgb=(25, 128, 16)) ) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.gfxattribs\fP module .UNINDENT .UNINDENT .UNINDENT .SS Tutorial for Layers .sp If you are not familiar with the concept of layers, please read this first: Concept of \fI\%Layers\fP .sp Reminder: a layer definition is not required for using a layer! .SS Create a Layer Definition .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(setup=True) # setup required line types msp = doc.modelspace() doc.layers.add(name=\(dqMyLines\(dq, color=7, linetype=\(dqDASHED\(dq) .EE .UNINDENT .UNINDENT .sp The advantage of assigning a linetype and a color to a layer is that entities on this layer can inherit this properties by using \fB\(dqBYLAYER\(dq\fP as linetype string and \fB256\fP as color, both values are default values for new entities so you can leave off these assignments: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_line((0, 0), (10, 0), dxfattribs={\(dqlayer\(dq: \(dqMyLines\(dq}) .EE .UNINDENT .UNINDENT .sp The new created line will be drawn with color \fB7\fP and linetype \fB\(dqDASHED\(dq\fP\&. .SS Moving an Entity to a Different Layer .sp Moving an entity to a different layer is a simple assignment of the new layer name to the \fBlayer\fP attribute of the entity. .INDENT 0.0 .INDENT 3.5 .sp .EX line = msp.add_line((0, 0), (10, 0), dxfattribs={\(dqlayer\(dq: \(dqMyLines\(dq}) # move the entity to layer \(dqOtherLayer\(dq line.dxf.layer = \(dqOtherLayer\(dq .EE .UNINDENT .UNINDENT .SS Changing Layer State .sp Get the layer definition object from the layer table: .INDENT 0.0 .INDENT 3.5 .sp .EX my_lines = doc.layers.get(\(aqMyLines\(aq) .EE .UNINDENT .UNINDENT .sp Check the state of the layer: .INDENT 0.0 .INDENT 3.5 .sp .EX my_lines.is_off() # True if layer is off my_lines.is_on() # True if layer is on my_lines.is_locked() # True if layer is locked layer_name = my_lines.dxf.name # get the layer name .EE .UNINDENT .UNINDENT .sp Change the state of the layer: .INDENT 0.0 .INDENT 3.5 .sp .EX # switch layer off, entities at this layer will not shown in CAD applications/viewers my_lines.off() # lock layer, entities at this layer are not editable in CAD applications my_lines.lock() .EE .UNINDENT .UNINDENT .sp Get/set the color of a layer by property \fBLayer.color\fP, because the DXF attribute \fBLayer.dxf.color\fP is misused for switching the layer on and off, the layer is off if the color value is negative. .sp Changing the layer properties: .INDENT 0.0 .INDENT 3.5 .sp .EX my_lines.dxf.linetype = \(dqDOTTED\(dq my_lines.color = 13 # preserves on/off state of layer .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For all methods and attributes see class \fI\%Layer\fP\&. .UNINDENT .UNINDENT .SS Check Available Layers .sp The \fI\%LayerTable\fP object supports some standard Python protocols: .INDENT 0.0 .INDENT 3.5 .sp .EX # iteration for layer in doc.layers: if layer.dxf.name != \(dq0\(dq: layer.off() # switch all layers off except layer \(dq0\(dq # check for existing layer definition if \(dqMyLines\(dq in doc.layers: layer = doc.layers.get(\(dqMyLines\(dq) layer_count = len(doc.layers) # total count of layer definitions .EE .UNINDENT .UNINDENT .SS Renaming a Layer .sp The \fI\%Layer\fP class has a method for renaming the layer, but has same limitations, not all places where layer references can occur are documented, third\-party entities are black\-boxes with unknown content and layer references could be stored in the extended data section of any DXF entity or in a XRECORD entity, so some references may reference a non\-existing layer definition after the renaming, at least these references are still valid, because a layer definition is not required for using a layer. .INDENT 0.0 .INDENT 3.5 .sp .EX my_lines = doc.layers.get(\(dqMyLines\(dq) my_lines.rename(\(dqYourLines\(dq) .EE .UNINDENT .UNINDENT .SS Deleting a Layer Definition .sp Delete a layer definition: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.layers.remove(\(dqMyLines\(dq) .EE .UNINDENT .UNINDENT .sp This just deletes the layer definition, all DXF entities referencing this layer still exist, if they inherit any properties from the deleted layer they will now get the default layer properties. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The behavior of entities referencing the layer by handle is unknown and may break the DXF document. .UNINDENT .UNINDENT .SS Deleting All Entities From a Layer .sp Because of all these uncertainties about layer references mentioned above, deleting all entities referencing a certain layer from a DXF document is not implemented as an API call! .sp Nonetheless deleting all graphical entities from the DXF document which do reference a certain layer by the \fBlayer\fP attribute is a safe procedure: .INDENT 0.0 .INDENT 3.5 .sp .EX key_func = doc.layers.key layer_key = key_func(\(dqMyLines\(dq) # The trashcan context\-manager is a safe way to delete entities from the # entities database while iterating. with doc.entitydb.trashcan() as trash: for entity in doc.entitydb.values(): if not entity.dxf.hasattr(\(dqlayer\(dq): continue if layer_key == key_func(entity.dxf.layer): # safe destruction while iterating trash.add(entity.dxf.handle) .EE .UNINDENT .UNINDENT .SS Tutorial for Creating Linetype Pattern .sp Simple line type example: [image] .sp You can define your own linetypes. A linetype definition has a name, a description and line pattern elements: .INDENT 0.0 .INDENT 3.5 .sp .EX elements = [total_pattern_length, elem1, elem2, ...] .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B total_pattern_length Sum of all linetype elements (absolute values) .TP .B elem if elem > 0 it is a line, if elem < 0 it is gap, if elem == 0.0 it is a dot .UNINDENT .sp Create a new linetype definition: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.tools.standards import linetypes # some predefined linetypes doc = ezdxf.new() msp = doc.modelspace() my_line_types = [ ( \(dqDOTTED\(dq, \(dqDotted . . . . . . . . . . . . . . . .\(dq, [0.2, 0.0, \-0.2], ), ( \(dqDOTTEDX2\(dq, \(dqDotted (2x) . . . . . . . . \(dq, [0.4, 0.0, \-0.4], ), ( \(dqDOTTED2\(dq, \(dqDotted (.5) . . . . . . . . . . . . . . . . . . . \(dq, [0.1, 0.0, \-0.1], ), ] for name, desc, pattern in my_line_types: if name not in doc.linetypes: doc.linetypes.add( name=name, pattern=pattern, description=desc, ) .EE .UNINDENT .UNINDENT .sp Setup some predefined linetypes: .INDENT 0.0 .INDENT 3.5 .sp .EX for name, desc, pattern in linetypes(): if name not in doc.linetypes: doc.linetypes.add( name=name, pattern= pattern, description=desc, ) .EE .UNINDENT .UNINDENT .SS Check Available Linetypes .sp The linetypes object supports some standard Python protocols: .INDENT 0.0 .INDENT 3.5 .sp .EX # iteration print(\(dqavailable linetypes:\(dq) for lt in doc.linetypes: print(f\(dq{lt.dxf.name}: {lt.dxf.description}\(dq) # check for existing linetype if \(dqDOTTED\(dq in doc.linetypes: pass count = len(doc.linetypes) # total count of linetypes .EE .UNINDENT .UNINDENT .SS Removing Linetypes .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Ezdxf does not check if a linetype is still in use and deleting a linetype which is still in use generates an \fBinvalid\fP DXF file. The audit process \fI\%audit()\fP of the DXF document removes \fBlinetype\fP attributes referencing non existing linetypes. .UNINDENT .UNINDENT .sp You can delete a linetype: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.layers.remove(\(dqDASHED\(dq) .EE .UNINDENT .UNINDENT .sp This just removes the linetype definition, the \fBlinetype\fP attribute of DXF entities may still refer the removed linetype definition “DASHED” and AutoCAD will not open DXF files including undefined linetypes. .SS Tutorial for Creating Complex Linetype Pattern .sp In DXF R13 Autodesk introduced complex linetypes, containing TEXT or SHAPES in line types. .sp Complex linetype example with text: [image] .sp Complex line type example with shapes: [image] .sp For easy usage the pattern string for complex line types is mostly the same string as the pattern definition strings in AutoCAD “.lin” files. .sp Example for complex line type TEXT: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(dqR2018\(dq) # DXF R13 or later is required doc.linetypes.add( name=\(dqGASLEITUNG2\(dq, # linetype definition string from acad.lin: pattern=\(aqA,.5,\-.2,[\(dqGAS\(dq,STANDARD,S=.1,U=0.0,X=\-0.1,Y=\-.05],\-.25\(aq, description= \(dqGasleitung2 \-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-\(dq, length=1, # required for complex line types }) .EE .UNINDENT .UNINDENT .sp The pattern always starts with an “A”, the following float values have the same meaning as for simple linetypes, a value > 0 is a line, a value < 0 is a gap, and a 0 is a point, the opening square bracket “[” starts the complex part of the linetype pattern. .sp The text after the “[” defines the complex linetype: .INDENT 0.0 .IP \(bu 2 A text in quotes (e.g. “GAS”) defines a \fIcomplex TEXT linetype\fP and represents the pattern text itself. .IP \(bu 2 A text without quotes is a SHAPE name (in “.lin” files) and defines a \fIcomplex SHAPE linetype. Ezdxf can not translate this SHAPE name from the “.lin” file into the required shape file index, so *YOU\fP have to translate this SHAPE name into the shape file index, e.g. saving the file with AutoCAD as DXF and searching for the DXF linetype definition, see example below and the DXF Internals: \fI\%LTYPE Table\fP\&. .UNINDENT .sp For \fIcomplex TEXT linetypes\fP the second parameter is the text style, for \fIcomplex SHAPE linetypes\fP the second parameter is the shape file name, the shape file has to be in the same directory as the DXF file or in one of the CAD application support paths. .sp The meaning of the following comple linetype parameters are shown in the table below: .TS center; |l|l|. _ T{ S T} T{ scaling factor, always > 0, if S=0 the TEXT or SHAPE is not visible T} _ T{ R or U T} T{ rotation relative to the line direction T} _ T{ X T} T{ x\-direction offset (along the line) T} _ T{ Y T} T{ y\-direction offset (perpendicular to the line) T} _ .TE .sp These parameters are case insensitive and the closing square bracket “]” ends the complex part of the linetype pattern. .sp The fine tuning of this parameters is a try an error process, for \fIcomplex TEXT linetypes\fP the scaling factor (e.g. the STANDARD text style) sets the text height (e.g. “S=0.1” sets the text height to 0.1 units), by shifting in y\-direction by half of the scaling factor, the text is vertically centered to the line. For the x\-direction it seems to be a good practice to place a gap in front of the text and after the text, find x shifting value and gap sizes by try and error. The overall length is at least the sum of all line and gap definitions (absolute values). .sp Example for complex line type SHAPE: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.linetypes.add(\(dqGRENZE2\(dq, # linetype definition in acad.lin: # A,.25,\-.1,[BOX,ltypeshp.shx,x=\-.1,s=.1],\-.1,1 # replacing BOX by shape index 132 (got index from an AutoCAD file), # ezdxf can\(aqt get shape index from ltypeshp.shx pattern=\(dqA,.25,\-.1,[132,ltypeshp.shx,x=\-.1,s=.1],\-.1,1\(dq, description=\(dqGrenze eckig \-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\-\(dq, length= 1.45, # required for complex line types }) .EE .UNINDENT .UNINDENT .sp Complex line types with shapes only work if the associated shape file (e. g. ltypeshp.shx) and the DXF file are in the same directory or the shape file is placed in one of the CAD application support folders. .SS Tutorial for Simple DXF Entities .sp These are basic graphical entities located in an entity space like the modelspace or a block definition and only support the common graphical attributes. .sp The entities in the following examples are always placed in the xy\-plane of the \fI\%WCS\fP aka the 2D drawing space. Some of these entities can only be placed outside the xy\-plane in 3D space by utilizing the \fI\%OCS\fP, but this feature is beyond the scope of this tutorial, for more information about that go to: \fI\%Tutorial for OCS/UCS Usage\fP\&. .sp Prelude to all following examples: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.gfxattribs import GfxAttribs doc = ezdxf.new() doc.layers.new(\(dqENTITY\(dq, color=1) msp = doc.modelspace() attribs = GfxAttribs(layer=\(dqENTITY\(dq) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Creating DXF Drawings\fP .IP \(bu 2 \fI\%Tutorial for Layers\fP .IP \(bu 2 \fI\%ezdxf.gfxattribs\fP module .UNINDENT .UNINDENT .UNINDENT .SS Point .sp The \fI\%Point\fP entity marks a 3D point in the \fI\%WCS\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX point = msp.add_point((10, 10), dxfattribs=attribs) .EE .UNINDENT .UNINDENT .sp All \fI\%Point\fP entities have the same styling stored in the header variable $PDMODE, for more information read the reference of class \fI\%Point\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Reference of class \fI\%Point\fP .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .UNINDENT .UNINDENT .UNINDENT .SS Line .sp The \fI\%Line\fP entity is a 3D line with a start\- and an end point in the \fI\%WCS\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX line = msp.add_line((0, 0), (10, 10), dxfattribs=attribs) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Reference of class \fI\%Line\fP .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionLine\fP .UNINDENT .UNINDENT .UNINDENT .SS Circle .sp The \fI\%Circle\fP entity is an \fI\%OCS\fP entity defined by a center point and a radius: .INDENT 0.0 .INDENT 3.5 .sp .EX circle = msp.add_circle((10, 10), radius=3, dxfattribs=attribs) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Reference of class \fI\%Circle\fP .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionCircle\fP .UNINDENT .UNINDENT .UNINDENT .SS Arc .sp The \fI\%Arc\fP entity is an \fI\%OCS\fP entity defined by a center point, a radius a start\- and an end angle in degrees: .INDENT 0.0 .INDENT 3.5 .sp .EX arc = msp.add_arc((10, 10), radius=3, start_angle=30, end_angle=120, dxfattribs=attribs) .EE .UNINDENT .UNINDENT .sp The arc goes always in counter\-clockwise orientation around the z\-axis more precisely the extrusion vector of \fI\%OCS\fP, but this is beyond the scope of this tutorial. .sp The helper class \fI\%ezdxf.math.ConstructionArc\fP provides constructors to create arcs from different scenarios: .INDENT 0.0 .IP \(bu 2 \fI\%from_2p_angle\fP: arc from 2 points and an angle .IP \(bu 2 \fI\%from_2p_radius\fP: arc from 2 points and a radius .IP \(bu 2 \fI\%from_3p\fP: arc from 3 points .UNINDENT .sp This example creates an arc from point (10, 0) to point (0, 0) passing the point (5, 3): .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.math import ConstructionArc # \-x\-x\-x\- snip \-x\-x\-x\- arc = ConstructionArc.from_3p( start_point=(10, 0), end_point=(0, 0), def_point=(5, 3) ) arc.add_to_layout(msp, dxfattribs=attribs) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Reference of class \fI\%Arc\fP .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionArc\fP .UNINDENT .UNINDENT .UNINDENT .SS Ellipse .sp The \fI\%Ellipse\fP entity requires DXF R2000 or newer and is a true \fI\%WCS\fP entity. The ellipse is defined by a center point, a vector for the major axis, the ratio between major\- and minor axis and the start\- and end parameter in radians: .INDENT 0.0 .INDENT 3.5 .sp .EX ellipse = msp.add_ellipse( (10, 10), major_axis=(5, 0), ratio=0.5, start_param=0, end_param=math.pi, dxfattribs=attribs ) .EE .UNINDENT .UNINDENT .sp When placed in 3D space the extrusion vector defines the normal vector of the ellipse plane and the minor axis is the extrusion vector \fBcross\fP the major axis. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Reference of class \fI\%Ellipse\fP .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionEllipse\fP .UNINDENT .UNINDENT .UNINDENT .SS Further Tutorials .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for LWPolyline\fP .IP \(bu 2 \fI\%Tutorial for Spline\fP .IP \(bu 2 \fI\%Tutorial for Text\fP .IP \(bu 2 \fI\%Tutorial for MText and MTextEditor\fP .IP \(bu 2 \fI\%Tutorial for Hatch\fP .IP \(bu 2 \fI\%Tutorial for MultiLeader\fP .IP \(bu 2 \fI\%Tutorial for Mesh\fP .UNINDENT .SS Tutorial for Blocks .sp If you are not familiar with the concept of blocks, please read this first: Concept of \fI\%Blocks\fP .SS Create a Block .sp Blocks are managed as \fI\%BlockLayout\fP objects by the \fI\%BlocksSection\fP object, every drawing has only one blocks section referenced by attribute \fBDrawing.blocks\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf import random # needed for random placing points def get_random_point(): \(dq\(dq\(dqReturns random x, y coordinates.\(dq\(dq\(dq x = random.randint(\-100, 100) y = random.randint(\-100, 100) return x, y # Create a new drawing in the DXF format of AutoCAD 2010 doc = ezdxf.new(\(aqR2010\(aq) # Create a block with the name \(aqFLAG\(aq flag = doc.blocks.new(name=\(aqFLAG\(aq) # Add DXF entities to the block \(aqFLAG\(aq. # The default base point (= insertion point) of the block is (0, 0). flag.add_lwpolyline([(0, 0), (0, 5), (4, 3), (0, 3)]) # the flag symbol as 2D polyline flag.add_circle((0, 0), .4, dxfattribs={\(aqcolor\(aq: 2}) # mark the base point with a circle .EE .UNINDENT .UNINDENT .SS Block References (Insert) .sp A block reference can be created by adding an \fI\%Insert\fP entity to any of these layout types: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Modelspace\fP .IP \(bu 2 \fI\%Paperspace\fP .IP \(bu 2 \fI\%BlockLayout\fP .UNINDENT .UNINDENT .UNINDENT .sp A block reference can be scaled and rotated individually. Lets add some random flags to the modelspace: .INDENT 0.0 .INDENT 3.5 .sp .EX # Get the modelspace of the drawing. msp = doc.modelspace() # Get 50 random placing points. placing_points = [get_random_point() for _ in range(50)] for point in placing_points: # Every flag has a different scaling and a rotation of \-15 deg. random_scale = 0.5 + random.random() * 2.0 # Add a block reference to the block named \(aqFLAG\(aq at the coordinates \(aqpoint\(aq. msp.add_blockref(\(aqFLAG\(aq, point, dxfattribs={ \(aqxscale\(aq: random_scale, \(aqyscale\(aq: random_scale, \(aqrotation\(aq: \-15 }) # Save the drawing. doc.saveas(\(dqblockref_tutorial.dxf\(dq) .EE .UNINDENT .UNINDENT .sp Query all block references of block \fBFLAG\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX for flag_ref in msp.query(\(aqINSERT[name==\(dqFLAG\(dq]\(aq): print(str(flag_ref)) .EE .UNINDENT .UNINDENT .sp When adding a block reference to a layout with different units, the scaling factor between these units should be applied as scaling attributes (\fBxscale\fP, …) e.g. modelspace in meters and block in centimeters, \fBxscale\fP has to be 0.01. .SS Block Attributes .sp A block attribute (\fI\%Attrib\fP) is a text annotation attached to a block reference with an associated tag. Attributes are often used to add information to blocks which can be evaluated and exported by CAD applications. An attribute can be added to a block reference by the \fBInsert.add_attrib()\fP method, the ATTRIB entity is geometrically not related to the block reference, so insertion point, rotation and scaling of the attribute have to be calculated by the user, but helper tools for that do exist. .SS Using Attribute Definitions .sp Another way to add attributes to block references is using attribute templates (\fI\%AttDef\fP). First create the attribute definition in the block definition, then add the block reference by \fBadd_blockref()\fP and attach and fill attributes automatically by the \fI\%add_auto_attribs()\fP method to the block reference. This method has the advantage that all attributes are placed relative to the block base point with the same rotation and scaling as the block reference, but non\-uniform scaling is not handled very well. .sp The \fI\%add_auto_blockref()\fP method handles non\-uniform scaling better by wrapping the block reference and its attributes into an anonymous block and let the CAD application do the transformation work. This method has the disadvantage of a more complex evaluation of attached attributes .sp Using attribute definitions (\fI\%AttDef\fP templates): .INDENT 0.0 .INDENT 3.5 .sp .EX # Define some attributes for the block \(aqFLAG\(aq, placed relative # to the base point, (0, 0) in this case. flag.add_attdef(\(aqNAME\(aq, (0.5, \-0.5), dxfattribs={\(aqheight\(aq: 0.5, \(aqcolor\(aq: 3}) flag.add_attdef(\(aqXPOS\(aq, (0.5, \-1.0), dxfattribs={\(aqheight\(aq: 0.25, \(aqcolor\(aq: 4}) flag.add_attdef(\(aqYPOS\(aq, (0.5, \-1.5), dxfattribs={\(aqheight\(aq: 0.25, \(aqcolor\(aq: 4}) # Get another 50 random placing points. placing_points = [get_random_point() for _ in range(50)] for number, point in enumerate(placing_points): # values is a dict with the attribute tag as item\-key and # the attribute text content as item\-value. values = { \(aqNAME\(aq: \(dqP(%d)\(dq % (number + 1), \(aqXPOS\(aq: \(dqx = %.3f\(dq % point[0], \(aqYPOS\(aq: \(dqy = %.3f\(dq % point[1] } # Every flag has a different scaling and a rotation of +15 deg. random_scale = 0.5 + random.random() * 2.0 blockref = msp.add_blockref(\(aqFLAG\(aq, point, dxfattribs={ \(aqrotation\(aq: 15 }).set_scale(random_scale) blockref.add_auto_attribs(values) # Save the drawing. doc.saveas(\(dqauto_blockref_tutorial.dxf\(dq) .EE .UNINDENT .UNINDENT .SS Get/Set Attributes of Existing Block References .sp See the howto: \fI\%Get/Set Block Reference Attributes\fP .SS Evaluate Wrapped Block References .sp As mentioned above the evaluation of block references wrapped into anonymous blocks is complex: .INDENT 0.0 .INDENT 3.5 .sp .EX # Collect all anonymous block references starting with \(aq*U\(aq anonymous_block_refs = modelspace.query(\(aqINSERT[name ? \(dq^\e*U.+\(dq]\(aq) # Collect the references of the \(aqFLAG\(aq block flag_refs = [] for block_ref in anonymous_block_refs: # Get the block layout of the anonymous block block = doc.blocks.get(block_ref.dxf.name) # Find all block references to \(aqFLAG\(aq in the anonymous block flag_refs.extend(block.query(\(aqINSERT[name==\(dqFLAG\(dq]\(aq)) # Evaluation example: collect all flag names. flag_numbers = [ flag.get_attrib_text(\(dqNAME\(dq) for flag in flag_refs if flag.has_attrib(\(dqNAME\(dq) ] print(flag_numbers) .EE .UNINDENT .UNINDENT .SS Exploding Block References .sp This is an advanced feature and the results may not be perfect. A \fBnon\-uniform scaling\fP lead to incorrect results for text entities (TEXT, MTEXT, ATTRIB) and some other entities like HATCH with circular\- or elliptic path segments. The “exploded” entities are added to the same layout as the block reference by default. .INDENT 0.0 .INDENT 3.5 .sp .EX for flag_ref in msp.query(\(aqINSERT[name==\(dqFLAG\(dq]\(aq): flag_ref.explode() .EE .UNINDENT .UNINDENT .SS Examine Entities of Block References .sp To just examine the content entities of a block reference use the \fI\%virtual_entities()\fP method. This methods yields “virtual” entities with properties identical to “exploded” entities but they are not stored in the entity database, have no handle and are not assigned to any layout. .INDENT 0.0 .INDENT 3.5 .sp .EX for flag_ref in msp.query(\(aqINSERT[name==\(dqFLAG\(dq]\(aq): for entity in flag_ref.virtual_entities(): if entity.dxftype() == \(dqLWPOLYLINE\(dq: print(f\(dqFound {str(entity)}.\(dq) .EE .UNINDENT .UNINDENT .SS Tutorial for LWPolyline .sp The \fI\%LWPolyline\fP (lightweight polyline) was introduced in DXF R13/14 and it is defined as a single graphic entity, which differs from the old\-style \fI\%Polyline\fP entity, which is defined as a group of sub\-entities. It is recommended to prefer the LWPOLYLINE over the 2D POLYLINE entity because it requires less space in memory and in DXF files and displays faster in AutoCAD. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The LWPOLYLINE is a planar element, therefore the (x, y) point coordinates are located in the \fI\%OCS\fP and the z\-axis is stored in the \fBLWPolyline.dxf.elevation\fP attribute. The method \fI\%vertices_in_wcs\fP returns the polyline vertices as WCS coordinates. .UNINDENT .UNINDENT .sp Create a simple polyline: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() points = [(0, 0), (3, 0), (6, 3), (6, 6)] msp.add_lwpolyline(points) doc.saveas(\(dqlwpolyline1.dxf\(dq) .EE .UNINDENT .UNINDENT .sp Append multiple points to a polyline: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.readfile(\(dqlwpolyline1.dxf\(dq) msp = doc.modelspace() line = msp.query(\(dqLWPOLYLINE\(dq).first if line is not None: line.append_points([(8, 7), (10, 7)]) doc.saveas(\(dqlwpolyline2.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The index operator \fB[]\fP always returns polyline points as 5\-tuple (x, y, start_width, end_width, bulge), the start_width, end_width and bulge values are 0 if not present: .INDENT 0.0 .INDENT 3.5 .sp .EX first_point = line[0] x, y, start_width, end_width, bulge = first_point .EE .UNINDENT .UNINDENT .sp The context manager \fI\%points()\fP can be used to edit polyline points, this method was introduced because accessing individual points was very slow in early versions of \fIezdxf\fP, in current versions of \fIezdxf\fP the direct access by the index operator \fB[]\fP is very fast and using the context manager is not required anymore, but the context manager still exist and has the advantage of supporting an user defined point format: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.readfile(\(dqlwpolyline2.dxf\(dq) msp = doc.modelspace() line = msp.query(\(dqLWPOLYLINE\(dq).first with line.points(\(dqxyseb\(dq) as points: # points is a standard Python list # existing points are 5\-tuples, but new points can be # set as (x, y, [start_width, [end_width, [bulge]]]) tuple # set start_width, end_width to 0 to be ignored (x, y, 0, 0, bulge). # delete last 2 points del points[\-2:] # adding two points points.extend([(4, 7), (0, 7)]) doc.saveas(\(dqlwpolyline3.dxf\(dq) .EE .UNINDENT .UNINDENT .sp Each line segment can have a different start\- and end width, if omitted start\- and end width is 0: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() # point format = (x, y, [start_width, [end_width, [bulge]]]) # set start_width, end_width to 0 to be ignored (x, y, 0, 0, bulge). points = [(0, 0, .1, .15), (3, 0, .2, .25), (6, 3, .3, .35), (6, 6)] msp.add_lwpolyline(points) doc.saveas(\(dqlwpolyline4.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The first point carries the start\- and end\-width of the first segment, the second point of the second segment and so on, the start\- and end width value of the last point is used for the closing segment if the polyline is closed else these values are ignored. Start\- and end width only works if the DXF attribute \fBdxf.const_width\fP is unset, delete it to be sure it’s unset: .INDENT 0.0 .INDENT 3.5 .sp .EX # no exception will be raised if const_width is already unset: del line.dxf.const_width .EE .UNINDENT .UNINDENT .sp \fBLWPolyline\fP can also have curved elements, they are defined by the \fI\%Bulge value\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() # point format = (x, y, [start_width, [end_width, [bulge]]]) # set start_width, end_width to 0 to be ignored (x, y, 0, 0, bulge). points = [(0, 0, 0, .05), (3, 0, .1, .2, \-.5), (6, 0, .1, .05), (9, 0)] msp.add_lwpolyline(points) doc.saveas(\(dqlwpolyline5.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp The curved segment is drawn from the point which defines the \fIbulge\fP value to the following point, the curved segment is always an arc. The bulge value defines the ratio of the arc sagitta (segment height \fIh\fP) to half line segment length (point distance), a bulge value of 1 defines a semicircle. The curve is on the right side of the line for a bulge value > 0, and on the left side of the line for a bulge value < 0. .sp Helper functions to handle bulge values: \fI\%Bulge Related Functions\fP .sp The user defined point format, default is \fBxyseb\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBx\fP = x coordinate .IP \(bu 2 \fBy\fP = y coordinate .IP \(bu 2 \fBs\fP = start width .IP \(bu 2 \fBe\fP = end width .IP \(bu 2 \fBb\fP = bulge value .IP \(bu 2 \fBv\fP = (x, y) as tuple .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_lwpolyline([(0, 0, 0), (10, 0, 1), (20, 0, 0)], format=\(dqxyb\(dq) msp.add_lwpolyline([(0, 10, 0), (10, 10, .5), (20, 10, 0)], format=\(dqxyb\(dq) .EE .UNINDENT .UNINDENT [image] .SS Tutorial for Text .sp Add a simple one line text entity by factory function \fI\%add_text()\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.enums import TextEntityAlignment # The TEXT entity is a DXF primitive and is supported in all DXF versions. # The argument setup=True creates standard linetypes and text styles in the # new DXF document. doc = ezdxf.new(\(dqR12\(dq, setup=True) msp = doc.modelspace() # Use method set_placement() to define the TEXT alignment, because the # relations between the DXF attributes \(aqhalign\(aq, \(aqvalign\(aq, \(aqinsert\(aq and # \(aqalign_point\(aq are tricky. msp.add_text(\(dqA Simple Text\(dq).set_placement( (2, 3), align=TextEntityAlignment.MIDDLE_RIGHT ) # Using a predefined text style: msp.add_text( \(dqText Style Example: Liberation Serif\(dq, height=0.35, dxfattribs={\(dqstyle\(dq: \(dqLiberationSerif\(dq} ).set_placement((2, 6), align=TextEntityAlignment.LEFT) doc.saveas(\(dqsimple_text.dxf\(dq) .EE .UNINDENT .UNINDENT .sp Alignments defined by the enum \fI\%TextEntityAlignment\fP: .TS center; |l|l|l|l|. _ T{ Vert/Horiz T} T{ Left T} T{ Center T} T{ Right T} _ T{ Top T} T{ \fBTOP_LEFT\fP T} T{ \fBTOP_CENTER\fP T} T{ \fBTOP_RIGHT\fP T} _ T{ Middle T} T{ \fBMIDDLE_LEFT\fP T} T{ \fBMIDDLE_CENTER\fP T} T{ \fBMIDDLE_RIGHT\fP T} _ T{ Bottom T} T{ \fBBOTTOM_LEFT\fP T} T{ \fBBOTTOM_CENTER\fP T} T{ \fBBOTTOM_RIGHT\fP T} _ T{ Baseline T} T{ \fBLEFT\fP T} T{ \fBCENTER\fP T} T{ \fBRIGHT\fP T} _ .TE .sp Special alignments are \fBALIGNED\fP and \fBFIT\fP, they require a second alignment point, the text is justified with the vertical alignment \fIBaseline\fP on the virtual line between these two points. .TS center; |l|l|. _ T{ Alignment T} T{ Description T} _ T{ \fBALIGNED\fP T} T{ Text is stretched or compressed to fit exactly between \fIp1\fP and \fIp2\fP and the text height is also adjusted to preserve height/width ratio. T} _ T{ \fBFIT\fP T} T{ Text is stretched or compressed to fit exactly between \fIp1\fP and \fIp2\fP but only the text width is adjusted, the text height is fixed by the \fIheight\fP attribute. T} _ T{ \fBMIDDLE\fP T} T{ also a \fIspecial\fP adjustment, but the result is the same as for \fBMIDDLE_CENTER\fP\&. T} _ .TE .SS Standard Text Styles .sp Setup some standard text styles and linetypes by argument \fBsetup=True\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(aqR12\(aq, setup=True) .EE .UNINDENT .UNINDENT .sp Replaced all proprietary font declarations in \fBsetup_styles()\fP (ARIAL, ARIAL_NARROW, ISOCPEUR and TIMES) by open source fonts, this is also the style name (e.g. \fB{\(aqstyle\(aq: \(aqOpenSans\-Italic\(aq}\fP): [image] .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 To see the defined text styles in a DXF viewer or CAD application, the applications have to know where the referenced TTF fonts can be found. This configuration is not possible by \fIezdxf\fP and has to be done for each application as described in their documentation. .sp See also: \fI\%Font Resources\fP .UNINDENT .UNINDENT .SS New Text Style .sp Creating a new text style is simple: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.styles.new(\(dqmyStandard\(dq, dxfattribs={\(dqfont\(dq : \(dqOpenSans\-Regular.ttf\(dq}) .EE .UNINDENT .UNINDENT .sp Getting the correct font name is often not that simple, especially on Windows. This shows the required steps to get the font name for \fIOpen Sans\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 open font folder \fIc:\ewindows\efonts\fP .IP \(bu 2 select and open the font\-family \fIOpen Sans\fP .IP \(bu 2 right\-click on \fIOpen Sans Standard\fP and select \fIProperties\fP .IP \(bu 2 on top of the first tab you see the font name: \fB\(aqOpenSans\-Regular.ttf\(aq\fP .UNINDENT .UNINDENT .UNINDENT .sp The style name has to be unique in the DXF document, otherwise \fIezdxf\fP will raise an \fBDXFTableEntryError\fP exception. To replace an existing entry, delete the existing entry by \fBdoc.styles.remove(name)\fP, and add the replacement entry. .SS 3D Text .sp It is possible to place the 2D \fI\%Text\fP entity into 3D space by using the \fI\%OCS\fP, for further information see: \fI\%Tutorial for OCS/UCS Usage\fP and \fI\%Tutorial for UCS Based Transformations\fP\&. .SS Tutorial for MText and MTextEditor .sp The \fI\%MText\fP entity is a multi line entity with extended formatting possibilities and requires at least DXF version R2000, to use all features (e.g. background fill) DXF R2007 is required. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The rendering result of the MTEXT entity depends on the DXF viewer or CAD application and can differ between different applications. These differences have the greatest impact on line wrapping, which can cause columns of text to have different heights in different applications! .sp In order for the text to look similar in different programs, the formatting should be as simple as possible or omitted altogether. .UNINDENT .UNINDENT .sp Prolog code: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(\(dqR2007\(dq, setup=True) msp = doc.modelspace() lorem_ipsum = \(dq\(dq\(dq Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \(dq\(dq\(dq .EE .UNINDENT .UNINDENT .SS Adding a MTEXT entity .sp The MTEXT entity can be added to any layout (modelspace, paperspace or block) by the \fI\%add_mtext()\fP function. .INDENT 0.0 .INDENT 3.5 .sp .EX # store MTEXT entity for additional manipulations mtext = msp.add_mtext(lorem_ipsum, dxfattribs={\(dqstyle\(dq: \(dqOpenSans\(dq}) .EE .UNINDENT .UNINDENT .sp This adds a MTEXT entity with text style “OpenSans”. The MTEXT content can be accessed by the \fBtext\fP attribute, this attribute can be edited like any Python string: .INDENT 0.0 .INDENT 3.5 .sp .EX mtext.text += \(dqAppend additional text to the MTEXT entity.\(dq # even shorter with __iadd__() support: mtext += \(dqAppend additional text to the MTEXT entity.\(dq .EE .UNINDENT .UNINDENT [image] .sp The \fBMText\fP entity has an alias \fBMText.dxf.text\fP for the \fBMText.text\fP attribute for compatibility to the \fBText\fP entity. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 Line endings “\en” will be replaced by the MTEXT line endings “\eP” at DXF export, but \fBnot\fP vice versa “\eP” by “\en” at DXF file loading. .UNINDENT .UNINDENT .SS Text placement .sp The location of the MTEXT entity is defined by the \fBMText.dxf.insert\fP and the \fBMText.dxf.attachment_point\fP attributes in \fI\%WCS\fP coordinates. The \fBattachment_point\fP defines the text alignment relative to the \fBinsert\fP location, default value is 1. .sp Attachment point constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|. _ T{ MText.dxf.attachment_point T} T{ Value T} _ T{ MTEXT_TOP_LEFT T} T{ 1 T} _ T{ MTEXT_TOP_CENTER T} T{ 2 T} _ T{ MTEXT_TOP_RIGHT T} T{ 3 T} _ T{ MTEXT_MIDDLE_LEFT T} T{ 4 T} _ T{ MTEXT_MIDDLE_CENTER T} T{ 5 T} _ T{ MTEXT_MIDDLE_RIGHT T} T{ 6 T} _ T{ MTEXT_BOTTOM_LEFT T} T{ 7 T} _ T{ MTEXT_BOTTOM_CENTER T} T{ 8 T} _ T{ MTEXT_BOTTOM_RIGHT T} T{ 9 T} _ .TE .sp The MTEXT entity has a method for setting \fBinsert\fP, \fBattachment_point\fP and \fBrotation\fP attributes by one call: \fI\%set_location()\fP .SS Character height .sp The character height is defined by the DXF attribute \fBMText.dxf.char_height\fP in drawing units, which has also consequences for the line spacing of the MTEXT entity: .INDENT 0.0 .INDENT 3.5 .sp .EX mtext.dxf.char_height = 0.5 .EE .UNINDENT .UNINDENT .sp The character height can be changed inline, see also \fI\%MTEXT formatting\fP and \fI\%MText Inline Codes\fP\&. .SS Text rotation (direction) .sp The \fBMText.dxf.rotation\fP attribute defines the text rotation as angle between the x\-axis and the horizontal direction of the text in degrees. The \fBMText.dxf.text_direction\fP attribute defines the horizontal direction of MTEXT as vector in WCS. Both attributes can be present at the same entity, in this case the \fBMText.dxf.text_direction\fP attribute has the higher priority. .sp The MTEXT entity has two methods to get/set rotation: \fI\%get_rotation()\fP returns the rotation angle in degrees independent from definition as angle or direction, and \fI\%set_rotation()\fP set the \fBrotation\fP attribute and removes the \fBtext_direction\fP attribute if present. .SS Defining a wrapping border .sp The wrapping border limits the text width and forces a line break for text beyond this border. Without attribute \fBdxf.width\fP (or setting 0) the lines are wrapped only at the regular line endings “ \eP” or “\en”, setting the reference column width forces additional line wrappings at the given width. The text height can not be limited, the text always occupies as much space as needed. .INDENT 0.0 .INDENT 3.5 .sp .EX mtext.dxf.width = 60 .EE .UNINDENT .UNINDENT [image] .SS MTEXT formatting .sp MTEXT supports inline formatting by special codes: \fI\%MText Inline Codes\fP .INDENT 0.0 .INDENT 3.5 .sp .EX mtext.text = \(dq{\e\eC1;red text} \- {\e\eC3;green text} \- {\e\eC5;blue text}\(dq .EE .UNINDENT .UNINDENT [image] .sp See also the support class \fI\%MTextEditor\fP\&. .SS Stacked text .sp MTEXT supports stacked text: .INDENT 0.0 .INDENT 3.5 .sp .EX # the space \(aq \(aq in front of \(aqLower\(aq and the \(aq;\(aq behind \(aqLower\(aq are necessary # combined with vertical center alignment mtext.text = \(dq\e\eA1;\e\eSUpper^ Lower; \- \e\eSUpper/ Lower;} \- \e\eSUpper# Lower;\(dq .EE .UNINDENT .UNINDENT [image] .sp See also the support class \fI\%MTextEditor\fP\&. .SS Background color (filling) .sp The MTEXT entity can have a background filling: .INDENT 0.0 .IP \(bu 2 \fI\%AutoCAD Color Index (ACI)\fP .IP \(bu 2 true color value as \fB(r, g, b)\fP tuple .IP \(bu 2 color name as string, use special name \fB\(aqcanvas\(aq\fP to use the canvas background color .UNINDENT .sp Because of the complex dependencies \fIezdxf\fP provides a method to set all required DXF attributes at once: .INDENT 0.0 .INDENT 3.5 .sp .EX mtext.set_bg_color(2, scale=1.5) .EE .UNINDENT .UNINDENT .sp The parameter \fIscale\fP determines how much border there is around the text, the value is based on the text height, and should be in the range of 1 \- 5, where 1 fits exact the MTEXT entity. [image] .SS MTextEditor .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The \fBMTextEditor\fP assembles just the inline code, which has to be parsed and rendered by the target CAD application, \fIezdxf\fP has no influence to that result. .sp Keep inline formatting as simple as possible, don’t test the limits of its capabilities, this will not work across different CAD applications and keep the formatting in a logic manner like, do not change paragraph properties in the middle of a paragraph. .sp \fBThere is no official documentation for the inline codes!\fP .UNINDENT .UNINDENT .sp The \fI\%MTextEditor\fP class provides a floating interface to build \fBMText\fP content in an easy way. .sp This example only shows the connection between \fBMText\fP and the \fBMTextEditor\fP, and shows no additional features to the first example of this tutorial: .SS Init Editor .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.tools.text import MTextEditor doc = ezdxf.new(\(dqR2007\(dq, setup=True) msp = doc.modelspace() lorem_ipsum = \(dq\(dq\(dq Lorem ipsum dolor sit amet, consectetur adipiscing elit, ... see prolog code \(dq\(dq\(dq # create a new editor object with an initial text: editor = MTextEditor(lorem_ipsum) # get the MTEXT content string from the editor by the str() function: mtext = msp.add_mtext(str(editor), dxfattribs={\(dqstyle\(dq: \(dqOpenSans\(dq}) .EE .UNINDENT .UNINDENT .sp Tutorial Prolog: .INDENT 0.0 .INDENT 3.5 .sp .EX # use constants defined in MTextEditor: NP = MTextEditor.NEW_PARAGRAPH ATTRIBS = { \(dqchar_height\(dq: 0.7, \(dqstyle\(dq: \(dqOpenSans\(dq, \(dqwidth\(dq: 10, } editor = MTextEditor(\(dqusing colors:\(dq + NP) .EE .UNINDENT .UNINDENT .SS Set Text Color .sp There are three ways to change the color inline: .INDENT 0.0 .IP \(bu 2 by color name “red”, “green”, “blue”, “yellow”, “cyan”, “magenta”, “white” .IP \(bu 2 by \fI\%AutoCAD Color Index (ACI)\fP .IP \(bu 2 by RGB values .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX # RED: set color by name \- red, green, blue, yellow, cyan, magenta, white editor.color(\(dqred\(dq).append(\(dqRED\(dq + NP) # RED: the color stays the same until the next change editor.append(\(dqalso RED\(dq + NP) # GREEN: change color by ACI (AutoCAD Color Index) editor.aci(3).append(\(dqGREEN\(dq + NP) # BLUE: change color by RGB tuples editor.rgb((0, 0, 255)).append(\(dqBLUE\(dq + NP) # add the MTEXT entity to the model space: msp.add_mtext(str(editor), attribs) .EE .UNINDENT .UNINDENT [image] .SS Changing Text Height .sp The \fBMtextEditor.height()\fP method set the text height as absolute value in drawing units (text height = cap height): .INDENT 0.0 .INDENT 3.5 .sp .EX attribs = dict(ATTRIBS) attribs[\(dqwidth\(dq] = 40.0 editor = MTextEditor(\(dqchanging text height absolute: default height is 0.7\(dq + NP) # doubling the default height = 1.4 editor.height(1.4) editor.append(\(dqtext height: 1.4\(dq + NP) editor.height(3.5).append(\(dqtext height: 3.5\(dq + NP) editor.height(0.7).append(\(dqback to default height: 0.7\(dq + NP) msp.add_mtext(str(editor), attribs) .EE .UNINDENT .UNINDENT [image] .sp The \fBMtextEditor.scale_height()\fP method set the text height by a relative factor, the \fBMtextEditor\fP object does not keep track of current text height, you have to do this by yourself. The initial text height is \fBMText.dxf.char_height\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX attribs = dict(ATTRIBS) attribs[\(dqwidth\(dq] = 40.0 editor = MTextEditor(\(dqchanging text height relative: default height is 0.7\(dq + NP) # this is the default text height in the beginning: current_height = attribs[\(dqchar_height\(dq] # The text height can only be changed by a factor: editor.scale_height(2) # scale by 2 = 1.4 # keep track of the actual height: current_height *= 2 editor.append(\(dqtext height: 1.4\(dq + NP) # to set an absolute height, calculate the required factor: desired_height = 3.5 factor = desired_height / current_height editor.scale_height(factor).append(\(dqtext height: 3.5\(dq + NP) current_height = desired_height # and back to 0.7 editor.scale_height(0.7 / current_height).append(\(dqback to default height: 0.7\(dq + NP) msp.add_mtext(str(editor), attribs).set_location(insert=location) .EE .UNINDENT .UNINDENT .SS Changing Font .sp The font name for changing \fBMText\fP fonts inline is the font family name! The font family name is the name shown in font selection widgets in desktop applications: “Arial”, “Times New Roman”, “Comic Sans MS”. The font has to be installed at the target system, else then CAD default font will be used, in AutoCAD/BricsCAD is this the font defined for the text style “Standard”. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The DXF/DWG format is not optimal for preserving text layouts across multiple systems, and it’s getting really bad across different CAD applications. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX attribs = dict(ATTRIBS) attribs[\(dqwidth\(dq] = 15.0 editor = MTextEditor(\(dqchanging fonts:\(dq + NP) editor.append(\(dqDefault: Hello World!\(dq + NP) editor.append(\(dqSimSun: \(dq) # change font in a group to revert back to the default font at the end: simsun_editor = MTextEditor().font(\(dqSimSun\(dq).append(\(dq你好,世界\(dq + NP) # reverts the font back at the end of the group: editor.group(str(simsun_editor)) # back to default font OpenSans: editor.append(\(dqTimes New Roman: \(dq) # change font outside of a group until next font change: editor.font(\(dqTimes New Roman\(dq).append(\(dqПривет мир!\(dq + NP) # If the font does not exist, a replacement font will be used: editor.font(\(dqDoes not exist\(dq).append(\(dqThis is the replacement font!\(dq) msp.add_mtext(str(editor), attribs) .EE .UNINDENT .UNINDENT [image] .SS Set Paragraph Properties .sp The paragraph properties are set by the \fI\%paragraph()\fP method and a \fI\%ParagraphProperties\fP object, which bundles all paragraph properties in a named tuple. .sp Each paragraph can have its own properties for: .INDENT 0.0 .IP \(bu 2 indentation arguments: .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBindent\fP is the left indentation of the first line .IP \(bu 2 \fBleft\fP is the left side indentation of the paragraph .IP \(bu 2 \fBright\fP is the right side indentation of the paragraph .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 text adjustment: \fBalign\fP, by enum \fBMTextParagraphAlignment\fP .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 MTextParagraphAlignment.LEFT .IP \(bu 2 MTextParagraphAlignment.RIGHT .IP \(bu 2 MTextParagraphAlignment.CENTER .IP \(bu 2 MTextParagraphAlignment.JUSTIFIED .IP \(bu 2 MTextParagraphAlignment.DISTRIBUTED .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 tabulator stops: \fBtab_stops\fP, a tuple of tabulator stops .UNINDENT .sp Indentation and tabulator stops are multiples of the default \fBMText\fP text height stored in \fBMText.dxf.char_height\fP\&. Calculate the drawing units for indentation and tabulator stops, by multiplying the indentation value by the \fBchar_height\fP value. .sp \fBMtext\fP paragraphs are separated by new paragraph “\eP” characters. .INDENT 0.0 .INDENT 3.5 .sp .EX # import support classes: from ezdxf.tools.text import ParagraphProperties, MTextParagraphAlignment attribs = dict(ATTRIBS) attribs[\(dqchar_height\(dq] = 0.25 attribs[\(dqwidth\(dq] = 7.5 editor = MTextEditor(\(dqIndent the first line:\(dq + NP) props = ParagraphProperties( indent=1, # indent first line = 1x0.25 drawing units align=MTextParagraphAlignment.JUSTIFIED ) editor.paragraph(props) editor.append(lorem_ipsum) msp.add_mtext(str(editor), attribs) .EE .UNINDENT .UNINDENT [image] .sp The first line indentation “indent” is relative to the “left” indentation. .INDENT 0.0 .INDENT 3.5 .sp .EX # import support classes: from ezdxf.tools.text import ParagraphProperties, MTextParagraphAlignment attribs = dict(ATTRIBS) attribs[\(dqchar_height\(dq] = 0.25 attribs[\(dqwidth\(dq] = 7.5 editor = MTextEditor(\(dqIndent left paragraph side:\(dq + NP) indent = 0.7 # 0.7 * 0.25 = 0.175 drawing units props = ParagraphProperties( # first line indentation is relative to \(dqleft\(dq, this reverses the # left indentation: indent=\-indent, # first line # indent left paragraph side: left=indent, align=MTextParagraphAlignment.JUSTIFIED ) editor.paragraph(props) editor.append(\(dq \(dq.join(lorem_ipsum(100))) msp.add_mtext(str(editor), attribs).set_location(insert=location) .EE .UNINDENT .UNINDENT [image] .SS Bullet List .sp There are no special commands to build bullet list, the list is build of indentation and a tabulator stop. Each list item needs a marker as an arbitrary string. For more information about paragraph indentation and tabulator stops see also chapter \fI\%Set Paragraph Properties\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX attribs = dict(ATTRIBS) attribs[\(dqchar_height\(dq] = 0.25 attribs[\(dqwidth\(dq] = 7.5 bullet = \(dq•\(dq # alt + numpad 7 editor = MTextEditor(\(dqBullet List:\(dq + NP) editor.bullet_list( indent=1, bullets=[bullet] * 3, # each list item needs a marker content=[ \(dqFirst item\(dq, \(dqSecond item\(dq, \(dq \(dq.join(lorem_ipsum(30)), ]) msp.add_mtext(str(editor), attribs) .EE .UNINDENT .UNINDENT [image] .SS Numbered List .sp There are no special commands to build numbered list, the list is build of indentation and a tabulator stop. There is no automatic numbering, but therefore the absolute freedom for using any string as list marker. For more information about paragraph indentation and tabulator stops see also chapter \fI\%Set Paragraph Properties\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX attribs = dict(ATTRIBS) attribs[\(dqchar_height\(dq] = 0.25 attribs[\(dqwidth\(dq] = 7.5 editor = MTextEditor(\(dqNumbered List:\(dq + NP) editor.bullet_list( indent=1, bullets=[\(dq1.\(dq, \(dq2.\(dq, \(dq3.\(dq], content=[ \(dqFirst item\(dq, \(dqSecond item\(dq, \(dq \(dq.join(lorem_ipsum(30)), ]) msp.add_mtext(str(editor), attribs) .EE .UNINDENT .UNINDENT [image] .SS Stacked Text .sp \fBMText\fP supports stacked text (fractions) as a single inline code, which means it is not possible to change any property inside the fraction. This example shows a fraction with scaled down text height, placed in a group to revert the text height afterwards: .INDENT 0.0 .INDENT 3.5 .sp .EX editor = MTextEditor(\(dqStacked text:\(dq + NP) stack = MTextEditor().scale_height(0.6).stack(\(dq1\(dq, \(dq2\(dq, \(dq^\(dq) editor.append(\(dqover: \(dq).group(str(stack)).append(NP) stack = MTextEditor().scale_height(0.6).stack(\(dq1\(dq, \(dq2\(dq, \(dq/\(dq) editor.append(\(dqfraction: \(dq).group(str(stack)).append(NP) stack = MTextEditor().scale_height(0.6).stack(\(dq1\(dq, \(dq2\(dq, \(dq#\(dq) editor.append(\(dqslanted: \(dq).group(str(stack)).append(NP) # Additional formatting in numerator and denominator is not supported # by AutoCAD or BricsCAD, switching the color inside the stacked text # to red does not work: numerator = MTextEditor().color(\(dqred\(dq).append(\(dq1\(dq) stack = MTextEditor().scale_height(0.6).stack(str(numerator), \(dq2\(dq, \(dq#\(dq) editor.append(\(dqcolor red: \(dq).group(str(stack)).append(NP) msp.add_mtext(str(editor), attribs) .EE .UNINDENT .UNINDENT [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%MTextEditor\fP example code on \fI\%github\fP\&. .IP \(bu 2 Documentation of \fI\%MTextEditor\fP .UNINDENT .UNINDENT .UNINDENT .SS Tutorial for Spline .sp Background information about \fI\%B\-spline\fP at Wikipedia. .SS Splines from fit points .sp Splines can be defined by fit points only, this means the curve passes all given fit points. AutoCAD and BricsCAD generates required control points and knot values by itself, if only fit points are present. .sp Create a simple spline: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(dqR2000\(dq) fit_points = [(0, 0, 0), (750, 500, 0), (1750, 500, 0), (2250, 1250, 0)] msp = doc.modelspace() spline = msp.add_spline(fit_points) .EE .UNINDENT .UNINDENT [image] .sp Append a fit point to a spline: .INDENT 0.0 .INDENT 3.5 .sp .EX # fit_points, control_points, knots and weights are list\-like containers: spline.fit_points.append((2250, 2500, 0)) .EE .UNINDENT .UNINDENT [image] .sp You can set additional \fIcontrol points\fP, but if they do not fit the auto\-generated AutoCAD values, they will be ignored and don’t mess around with \fI\%knot\fP values. .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.readfile(\(dqAutoCAD_generated.dxf\(dq) msp = doc.modelspace() spline = msp.query(\(dqSPLINE\(dq).first # fit_points, control_points, knots and weights are list\-like objects: spline.fit_points.append((2250, 2500, 0)) .EE .UNINDENT .UNINDENT .sp As far as I have tested, this approach works without complaints from AutoCAD, but for the case of problems remove invalid data from the SPLINE entity: .INDENT 0.0 .INDENT 3.5 .sp .EX # current control points do not match spline defined by fit points spline.control_points = [] # count of knots is not correct: # count of knots = count of control points + degree + 1 spline.knots = [] # same for weights, count of weights == count of control points spline.weights = [] .EE .UNINDENT .UNINDENT .SS Splines by control points .sp Creating splines from fit points is the easiest way, but this method is also the least accurate, because a spline is defined by control points and knot values, which are generated for the case of a definition by fit points, and the worst fact is that for every given set of fit points exist an infinite number of possible splines as solution. .sp AutoCAD (and BricsCAD) uses an unknown proprietary algorithm to generate control points and knot values from fit points. Therefore splines generated from fit points by \fIezdxf\fP do not match splines generated by AutoCAD (BricsCAD). .sp To ensure the same spline geometry for all CAD applications, the spline has to be defined by control points. The method \fI\%add_spline_control_frame()\fP adds a spline passing the given fit points by calculating the control points by the \fI\%Global Curve Interpolation\fP algorithm. There is also a low level function \fI\%ezdxf.math.global_bspline_interpolation()\fP which calculates the control points from fit points. .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_spline_control_frame(fit_points, method=\(aquniform\(aq, dxfattribs={\(aqcolor\(aq: 1}) msp.add_spline_control_frame(fit_points, method=\(aqchord\(aq, dxfattribs={\(aqcolor\(aq: 3}) msp.add_spline_control_frame(fit_points, method=\(aqcentripetal\(aq, dxfattribs={\(aqcolor\(aq: 5}) .EE .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 black curve: AutoCAD/BricsCAD spline generated from fit points .IP \(bu 2 red curve: spline curve interpolation, “uniform” method .IP \(bu 2 green curve: spline curve interpolation, “chord” method .IP \(bu 2 blue curve: spline curve interpolation, “centripetal” method .UNINDENT [image] .SS Open Spline .sp Add and open (clamped) spline defined by control points with the method \fI\%add_open_spline()\fP\&. If no \fI\%knot\fP values are given, an open uniform knot vector will be generated. A clamped B\-spline starts at the first control point and ends at the last control point. .INDENT 0.0 .INDENT 3.5 .sp .EX control_points = [(0, 0, 0), (1250, 1560, 0), (3130, 610, 0), (2250, 1250, 0)] msp.add_open_spline(control_points) .EE .UNINDENT .UNINDENT [image] .SS Rational Spline .sp \fI\%Rational B\-splines\fP have a weight for every control point, which can raise or lower the influence of the control point, default weight = \fB1\fP, to lower the influence set a weight < \fB1\fP to raise the influence set a weight > \fB1\fP\&. The count of weights has to be always equal to the count of control points. .sp Example to raise the influence of the first control point: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_closed_rational_spline(control_points, weights=[3, 1, 1, 1]) .EE .UNINDENT .UNINDENT [image] .SS Spline properties .sp Check if spline is a \fI\%closed curve\fP or close/open spline, for a closed spline the last point is connected to the first point: .INDENT 0.0 .INDENT 3.5 .sp .EX if spline.closed: # this spline is closed pass # close spline spline.closed = True # open spline spline.closed = False .EE .UNINDENT .UNINDENT .sp Set start\- and end tangent for splines defined by fit points: .INDENT 0.0 .INDENT 3.5 .sp .EX spline.dxf.start_tangent = (0, 1, 0) spline.dxf.end_tangent = (1, 0, 0) .EE .UNINDENT .UNINDENT .sp Get data count as stored in DXF attributes: .INDENT 0.0 .INDENT 3.5 .sp .EX count = spline.dxf.n_fit_points count = spline.dxf.n_control_points count = spline.dxf.n_knots .EE .UNINDENT .UNINDENT .sp Get data count from existing data: .INDENT 0.0 .INDENT 3.5 .sp .EX count = spline.fit_point_count count = spline.control_point_count count = spline.knot_count .EE .UNINDENT .UNINDENT .SS Tutorial for Polyface .sp The \fI\%Polyface\fP entity represents a 3D mesh build of vertices and faces and is just an extended POLYLINE entity with a complex VERTEX structure. The \fBPolyface\fP entity was used in DXF R12 and older DXF versions and is still supported by newer DXF versions. The new \fI\%Mesh\fP entity stores the same data much more efficient but requires DXF R2000 or newer. The \fBPolyface\fP entity supports only triangles and quadrilaterals as faces, the \fBMesh\fP entity supports also n\-gons. .sp Its recommended to use the \fI\%MeshBuilder\fP objects to create 3D meshes and render them as POLYFACE entities by the \fBrender_polymesh()\fP method into a layout: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import colors from ezdxf.gfxattribs import GfxAttribs from ezdxf.render import forms cube = forms.cube().scale_uniform(10).subdivide(2) red = GfxAttribs(color=colors.RED) green = GfxAttribs(color=colors.GREEN) blue = GfxAttribs(color=colors.BLUE) doc = ezdxf.new() msp = doc.modelspace() # render as MESH entity cube.render_mesh(msp, dxfattribs=red) cube.translate(20) # render as POLYFACE a.k.a. POLYLINE entity cube.render_polyface(msp, dxfattribs=green) cube.translate(20) # render as a bunch of 3DFACE entities cube.render_3dfaces(msp, dxfattribs=blue) doc.saveas(\(dqmeshes.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 If the mesh contains n\-gons the render methods for POLYFACE and 3DFACES subdivides the n\-gons into triangles, which does \fBnot\fP work for concave faces. .UNINDENT .UNINDENT .sp The usage of the \fI\%MeshBuilder\fP object is also recommended for inspecting \fBPolyface\fP entities: .INDENT 0.0 .IP \(bu 2 \fBMeshBuilder.vertices\fP is a sequence of 3D points as \fI\%ezdxf.math.Vec3\fP objects .IP \(bu 2 a face in \fBMeshBuilder.faces\fP is a sequence of indices into the \fBMeshBuilder.vertices\fP sequence .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.render import MeshBuilder def process(mesh): # vertices is a sequence of 3D points vertices = mses.vertices # a face is a sequence of indices into the vertices sequence faces = mesh.faces ... doc = ezdxf.readfile(\(dqmeshes.dxf\(dq) msp = doc.modelspace() for polyline in msp.query(\(dqPOLYLINE\(dq): if polyline.is_poly_face_mesh: mesh = MeshBuilder.from_polyface(polyline) process(mesh) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Mesh\fP .UNINDENT .UNINDENT .SS Tutorial for Mesh .sp The \fI\%Mesh\fP entity is a 3D object in \fI\%WCS\fP build up from vertices and faces. .sp Create a cube mesh by directly accessing the base data structures: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # 8 corner vertices cube_vertices = [ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0), (0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1), ] # 6 cube faces cube_faces = [ [0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 5, 4], [1, 2, 6, 5], [3, 2, 6, 7], [0, 3, 7, 4] ] # MESH requires DXF R2000 or later doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() mesh = msp.add_mesh() # do not subdivide cube, 0 is the default value mesh.dxf.subdivision_levels = 0 with mesh.edit_data() as mesh_data: mesh_data.vertices = cube_vertices mesh_data.faces = cube_faces doc.saveas(\(dqcube_mesh_1.dxf\(dq) .EE .UNINDENT .UNINDENT .sp Create a cube mesh by assembling single faces using the \fI\%edit_data()\fP context manager of the \fI\%Mesh\fP class and the helper class \fI\%MeshData\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # 8 corner vertices p = [ (0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0), (0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1), ] # MESH requires DXF R2000 or later doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() mesh = msp.add_mesh() with mesh.edit_data() as mesh_data: mesh_data.add_face([p[0], p[1], p[2], p[3]]) mesh_data.add_face([p[4], p[5], p[6], p[7]]) mesh_data.add_face([p[0], p[1], p[5], p[4]]) mesh_data.add_face([p[1], p[2], p[6], p[5]]) mesh_data.add_face([p[3], p[2], p[6], p[7]]) mesh_data.add_face([p[0], p[3], p[7], p[4]]) # optional call optimize(): minimizes the vertex count mesh_data.optimize() doc.saveas(\(dqcube_mesh_2.dxf\(dq) .EE .UNINDENT .UNINDENT .sp Its recommended to use the \fI\%MeshBuilder\fP objects to create 3D meshes and render them as MESH entities by the \fI\%render_mesh()\fP method into a layout: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import colors from ezdxf.gfxattribs import GfxAttribs from ezdxf.render import forms cube = forms.cube().scale_uniform(10).subdivide(2) red = GfxAttribs(color=colors.RED) green = GfxAttribs(color=colors.GREEN) blue = GfxAttribs(color=colors.BLUE) doc = ezdxf.new() msp = doc.modelspace() # render as MESH entity cube.render_mesh(msp, dxfattribs=red) cube.translate(20) # render as POLYFACE a.k.a. POLYLINE entity cube.render_polyface(msp, dxfattribs=green) cube.translate(20) # render as a bunch of 3DFACE entities cube.render_3dfaces(msp, dxfattribs=blue) doc.saveas(\(dqmeshes.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp There exist some tools to manage meshes: .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.render.MeshBuilder\fP: The \fI\%MeshBuilder\fP classes are helper tools to manage meshes buildup by vertices and faces. .IP \(bu 2 \fI\%ezdxf.render.MeshTransformer\fP: Same functionality as \fI\%MeshBuilder\fP but supports inplace transformation. .IP \(bu 2 \fI\%ezdxf.render.MeshDiagnose\fP: A diagnose tool which can be used to analyze and detect errors of \fI\%MeshBuilder\fP objects like topology errors for closed surfaces. .IP \(bu 2 \fI\%ezdxf.render.FaceOrientationDetector\fP: A helper class for face orientation and face normal vector detection .UNINDENT .sp The \fI\%ezdxf.render.forms\fP module provides function to create basic geometries like cube, cone, sphere and so on and functions to create meshes from profiles by extrusion, rotation or sweeping. .sp This example shows how to sweep a gear profile along a helix: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.render import forms doc = ezdxf.new() doc.layers.add(\(dqMESH\(dq, color=ezdxf.colors.YELLOW) msp = doc.modelspace() # sweeping a gear\-profile gear = forms.gear( 8, top_width=0.01, bottom_width=0.02, height=0.02, outside_radius=0.1 ) helix = path.helix(radius=2, pitch=1, turns=6) # along a helix spine sweeping_path = helix.flattening(0.1) mesh = forms.sweep(gear, sweeping_path, close=True, caps=True) # and render as MESH entity mesh.render_mesh(msp, dxfattribs={\(dqlayer\(dq: \(dqMESH\(dq}) doc.saveas(\(dqgear_along_helix.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .SS Tutorial for Hatch .SS Create hatches with one boundary path .sp The simplest form of the \fI\%Hatch\fP entity has one polyline path with only straight lines as boundary path: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # hatch requires DXF R2000 or later doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() # by default a solid fill hatch with fill color=7 (white/black) hatch = msp.add_hatch(color=2) # every boundary path is a 2D element # vertex format for the polyline path is: (x, y[, bulge]) # there are no bulge values in this example hatch.paths.add_polyline_path( [(0, 0), (10, 0), (10, 10), (0, 10)], is_closed=True ) doc.saveas(\(dqsolid_hatch_polyline_path.dxf\(dq) .EE .UNINDENT .UNINDENT .sp But like all polyline entities the polyline path can also have bulge values: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # hatch requires the DXF R2000 or later doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() # by default a solid fill hatch with fill color=7 (white/black) hatch = msp.add_hatch(color=2) # every boundary path is a 2D element # vertex format for the polyline path is: (x, y[, bulge]) # bulge value 1 = an arc with diameter=10 (= distance to next vertex * bulge value) # bulge value > 0 ... arc is right of line # bulge value < 0 ... arc is left of line hatch.paths.add_polyline_path( [(0, 0, 1), (10, 0), (10, 10, \-0.5), (0, 10)], is_closed=True ) doc.saveas(\(dqsolid_hatch_polyline_path_with_bulge.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The most flexible way to define a boundary path is the edge path. An edge path can have multiple edges and each edge can be one of the following elements: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 line \fBEdgePath.add_line()\fP .IP \(bu 2 arc \fBEdgePath.add_arc()\fP .IP \(bu 2 ellipse \fBEdgePath.add_ellipse()\fP .IP \(bu 2 spline \fBEdgePath.add_spline()\fP .UNINDENT .UNINDENT .UNINDENT .sp Create a solid hatch with an edge path (ellipse) as boundary path: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # hatch requires the DXF R2000 or later doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() # important: major axis >= minor axis (ratio <= 1.) # minor axis length = major axis length * ratio msp.add_ellipse((0, 0), major_axis=(0, 10), ratio=0.5) # by default a solid fill hatch with fill color=7 (white/black) hatch = msp.add_hatch(color=2) # every boundary path is a 2D element edge_path = hatch.paths.add_edge_path() # each edge path can contain line, arc, ellipse and spline elements # important: major axis >= minor axis (ratio <= 1.) edge_path.add_ellipse((0, 0), major_axis=(0, 10), ratio=0.5) doc.saveas(\(dqsolid_hatch_ellipse.dxf\(dq) .EE .UNINDENT .UNINDENT .SS Create hatches with multiple boundary paths (islands) .sp The DXF attribute \fBhatch_style\fP defines the island detection style: .TS center; |l|l|. _ T{ 0 T} T{ nested \- altering filled and unfilled areas T} _ T{ 1 T} T{ outer \- area between \fIexternal\fP and \fIoutermost\fP path is filled T} _ T{ 2 T} T{ ignore \- \fIexternal\fP path is filled T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX hatch = msp.add_hatch( color=1, dxfattribs={ \(dqhatch_style\(dq: ezdxf.const.HATCH_STYLE_NESTED, # 0 = nested: ezdxf.const.HATCH_STYLE_NESTED # 1 = outer: ezdxf.const.HATCH_STYLE_OUTERMOST # 2 = ignore: ezdxf.const.HATCH_STYLE_IGNORE }, ) # The first path has to set flag: 1 = external # flag const.BOUNDARY_PATH_POLYLINE is added (OR) automatically hatch.paths.add_polyline_path( [(0, 0), (10, 0), (10, 10), (0, 10)], is_closed=True, flags=ezdxf.const.BOUNDARY_PATH_EXTERNAL, ) .EE .UNINDENT .UNINDENT .sp This is also the result for all 4 paths and \fBhatch_style\fP set to \fB2\fP (ignore). [image] .INDENT 0.0 .INDENT 3.5 .sp .EX # The second path has to set flag: 16 = outermost hatch.paths.add_polyline_path( [(1, 1), (9, 1), (9, 9), (1, 9)], is_closed=True, flags=ezdxf.const.BOUNDARY_PATH_OUTERMOST, ) .EE .UNINDENT .UNINDENT .sp This is also the result for all 4 paths and \fBhatch_style\fP set to \fB1\fP (outer). [image] .INDENT 0.0 .INDENT 3.5 .sp .EX # The third path has to set flag: 0 = default hatch.paths.add_polyline_path( [(2, 2), (8, 2), (8, 8), (2, 8)], is_closed=True, flags=ezdxf.const.BOUNDARY_PATH_DEFAULT, ) .EE .UNINDENT .UNINDENT [image] .INDENT 0.0 .INDENT 3.5 .sp .EX # The forth path has to set flag: 0 = default, and so on hatch.paths.add_polyline_path( [(3, 3), (7, 3), (7, 7), (3, 7)], is_closed=True, flags=ezdxf.const.BOUNDARY_PATH_DEFAULT, ) doc.saveas(OUTDIR / \(dqsolid_hatch_islands_04.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp The expected result of combinations of various \fBhatch_style\fP values and paths \fIflags\fP, or the handling of overlapping paths is not documented by the DXF reference, so don’t ask me, ask Autodesk or just try it by yourself and post your experience in the forum. .SS Example for Edge Path Boundary .INDENT 0.0 .INDENT 3.5 .sp .EX hatch = msp.add_hatch(color=1) # 1. polyline path hatch.paths.add_polyline_path( [ (240, 210, 0), (0, 210, 0), (0, 0, 0.0), (240, 0, 0), ], is_closed=1, flags=ezdxf.const.BOUNDARY_PATH_EXTERNAL, ) # 2. edge path edge_path = hatch.paths.add_edge_path(flags=ezdxf.const.BOUNDARY_PATH_OUTERMOST) edge_path.add_spline( control_points=[ (126.658105895725, 177.0823706957212), (141.5497003747484, 187.8907860433995), (205.8997365206943, 154.7946313459515), (113.0168862297068, 117.8189380884978), (202.9816918983783, 63.17222935389572), (157.363511042264, 26.4621294342132), (144.8204003260554, 28.4383294369643), ], knot_values=[ 0.0, 0.0, 0.0, 0.0, 55.20174685732758, 98.33239645153571, 175.1126541251052, 213.2061566683142, 213.2061566683142, 213.2061566683142, 213.2061566683142, ], ) edge_path.add_arc( center=(152.6378550678883, 128.3209356351659), radius=100.1880612627354, start_angle=94.4752130054052, end_angle=177.1345242028005, ) edge_path.add_line( (52.57506282464041, 123.3124200796114), (126.658105895725, 177.0823706957212), ) .EE .UNINDENT .UNINDENT [image] .SS Associative Boundary Paths .sp A HATCH entity can be associative to a base geometry, which means if the base geometry is edited in a CAD application the HATCH get the same modification. Because \fIezdxf\fP is \fBnot\fP a CAD application, this association is \fBnot\fP maintained nor verified by \fIezdxf\fP, so if you modify the base geometry afterwards the geometry of the boundary path is not updated and no verification is done to check if the associated geometry matches the boundary path, this opens many possibilities to create invalid DXF files: USE WITH CARE. .sp This example associates a LWPOLYLINE entity to the hatch created from the LWPOLYLINE vertices: .INDENT 0.0 .INDENT 3.5 .sp .EX # Create base geometry lwpolyline = msp.add_lwpolyline( [(0, 0, 0), (10, 0, 0.5), (10, 10, 0), (0, 10, 0)], format=\(dqxyb\(dq, close=True, ) hatch = msp.add_hatch(color=1) path = hatch.paths.add_polyline_path( # get path vertices from associated LWPOLYLINE entity lwpolyline.get_points(format=\(dqxyb\(dq), # get closed state also from associated LWPOLYLINE entity is_closed=lwpolyline.closed, ) # Set association between boundary path and LWPOLYLINE hatch.associate(path, [lwpolyline]) .EE .UNINDENT .UNINDENT .sp An \fBEdgePath\fP needs associations to all geometry entities forming the boundary path. .SS Predefined Hatch Pattern .sp Use predefined hatch pattern by name: .INDENT 0.0 .INDENT 3.5 .sp .EX hatch.set_pattern_fill(\(dqANSI31\(dq, scale=0.5) .EE .UNINDENT .UNINDENT [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Hatch Pattern Definition\fP .UNINDENT .UNINDENT .SS Tutorial for Hatch Pattern Definition .sp A hatch pattern consist of one or more hatch lines. A hatch line defines a set of lines which have the same orientation an the same line pattern. All the lines defined by a hatch line are parallel and have a constant distance to each other. The \fIorigin\fP defines the start point of the hatch line and also the starting point of the line pattern. The \fIdirection\fP defines the angle between the \fI\%WCS\fP x\-axis and the hatch line. The \fIoffset\fP is a 2D vector which will be added consecutively the the origin for each new hatch line. The line pattern has the same format as as the simple linetype pattern (\fI\%Tutorial for Creating Linetype Pattern\fP). .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The hatch pattern must be defined for a hatch scaling factor of 1.0 and a hatch rotation angle of 0 degrees! .UNINDENT .UNINDENT .sp The first example creates a simple pattern of horizontal solid lines with a vertical distance of 0.5 drawing units. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(\(dqR2010\(dq) msp = doc.modelspace() hatch = msp.add_hatch() hatch.set_pattern_fill( \(dqMyPattern\(dq, color=7, angle=0, scale=1.0, style=0, # normal hatching style pattern_type=0, # user\-defined # pattern definition as list of: # [angle in degree, origin as 2d vector, offset as 2d vector, line pattern] # line pattern is a solid line definition=[[0, (0, 0), (0, 0.5), []]], ) points = [(0, 0), (10, 0), (10, 10), (0, 10)] hatch.paths.add_polyline_path(points) msp.add_lwpolyline(points, close=True, dxfattribs={\(dqcolor\(dq: 1}) doc.saveas(\(dquser_defined_hatch_pattern.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp The next example shows how the \fIoffset\fP value works: .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x\- snip \-x\-x\-x\- hatch = msp.add_hatch() hatch.set_pattern_fill( \(dqMyPattern\(dq, color=7, angle=0, scale=1.0, style=0, # normal hatching style pattern_type=0, # user\-defined # the line pattern is a dashed line: \- \- \- \- # the offset is 1 unit vertical and 0.3 units horizontal # [angle in degree, origin as 2d vector, offset as 2d vector, line pattern] definition=[[0, (0, 0), (0.3, 1), [1, \-1]]], ) # \-x\-x\-x\- snip \-x\-x\-x\- .EE .UNINDENT .UNINDENT [image] .sp The next example combines two parallel hatch lines, the origin defines how the hatch lines are offset from each other: .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x\- snip \-x\-x\-x\- hatch = msp.add_hatch() hatch.set_pattern_fill( \(dqMyPattern\(dq, color=7, angle=0, scale=1.0, style=0, # normal hatching style pattern_type=0, # user\-defined # [angle in degree, origin as 2d vector, offset as 2d vector, line pattern] definition=[ [0, (0, 0), (0.3, 1), [1, \-1]], # dashed line [0, (0, 0.5), (0, 1), []], # solid line ], ) # \-x\-x\-x\- snip \-x\-x\-x\- .EE .UNINDENT .UNINDENT [image] .sp The next example combines two hatch lines with different angles. The origins can be the same for this example. The \fBVec2\fP class is used to calculate the offset value for a normal distance of 0.7 drawing units between the slanted lines: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.math import Vec2 # \-x\-x\-x\- snip \-x\-x\-x\- hatch = msp.add_hatch() # offset vector for a normal distance of 0.7 for a 45 deg slanted hatch line offset = Vec2.from_deg_angle(45 + 90, length=0.7) hatch.set_pattern_fill( \(dqMyPattern\(dq, color=7, angle=0, scale=1.0, style=0, # normal hatching style pattern_type=0, # user\-defined # [angle in degree, origin as 2d vector, offset as 2d vector, line pattern] definition=[ [0, (0, 0), (0, 1), [1, \-1]], # horizontal dashed line [45, (0, 0), offset, []], # slanted solid line ], ) # \-x\-x\-x\- snip \-x\-x\-x\- .EE .UNINDENT .UNINDENT [image] .SS Tutorial for Image and ImageDef .sp This example shows how to use a raster image in a DXF document. Each IMAGE entity requires an associated IMAGEDEF entity in the objects section, which stores the filename of the linked image and the size in pixels. Multiple IMAGE entities can share the same IMAGEDEF entity. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The raster image is NOT embedded in the DXF file! .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # The IMAGE entity requires the DXF R2000 format or later. doc = ezdxf.new(\(dqR2000\(dq) # The IMAGEDEF entity is like a block definition, it just defines the image. my_image_def = doc.add_image_def( filename=\(dqmycat.jpg\(dq, size_in_pixel=(640, 360) ) msp = doc.modelspace() # The IMAGE entity is like the INSERT entity, it\(aqs just an image reference, # and there can be multiple references to the same picture in a DXF document. # 1st image reference msp.add_image( insert=(2, 1), size_in_units=(6.4, 3.6), image_def=my_image_def, rotation=0 ) # 2nd image reference msp.add_image( insert=(4, 5), size_in_units=(3.2, 1.8), image_def=my_image_def, rotation=30 ) # Get existing image definitions from the OBJECTS section: image_defs = doc.objects.query(\(dqIMAGEDEF\(dq) doc.saveas(\(dqdxf_with_cat.dxf\(dq) .EE .UNINDENT .UNINDENT .SS Tutorial for Underlay and UnderlayDefinition .sp This example shows hot to insert a a PDF, DWF, DWFx or DGN file as drawing underlay. Each UNDERLAY entity requires an associated UNDERLAYDEF entity in the objects section, which stores the filename of the linked document and the parameters of the underlay. Multiple UNDERLAY entities can share the same UNDERLAYDEF entity. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The underlay file is NOT embedded into the DXF file: .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(\(aqAC1015\(aq) # underlay requires the DXF R2000 format or later my_underlay_def = doc.add_underlay_def(filename=\(aqmy_underlay.pdf\(aq, name=\(aq1\(aq) # The (PDF)DEFINITION entity is like a block definition, it just defines the underlay # \(aqname\(aq is misleading, because it defines the page/sheet to be displayed # PDF: name is the page number to display # DGN: name=\(aqdefault\(aq ??? # DWF: ???? msp = doc.modelspace() # add first underlay msp.add_underlay(my_underlay_def, insert=(2, 1, 0), scale=0.05) # The (PDF)UNDERLAY entity is like the INSERT entity, it creates an underlay reference, # and there can be multiple references to the same underlay in a drawing. msp.add_underlay(my_underlay_def, insert=(4, 5, 0), scale=.5, rotation=30) # get existing underlay definitions, Important: UNDERLAYDEFs resides in the objects section pdf_defs = doc.objects.query(\(aqPDFDEFINITION\(aq) # get all pdf underlay defs in drawing doc.saveas(\(dqdxf_with_underlay.dxf\(dq) .EE .UNINDENT .UNINDENT .SS Tutorial for MultiLeader .sp A multileader object typically consists of an arrowhead, a horizontal landing (a.k.a. “dogleg”), a leader line or curve, and either a MTEXT object or a BLOCK. .sp Factory methods of the \fI\%BaseLayout\fP class to create new \fI\%MultiLeader\fP entities: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%add_multileader_mtext()\fP .IP \(bu 2 \fI\%add_multileader_block()\fP .UNINDENT .UNINDENT .UNINDENT .sp Because of the complexity of the MULTILEADER entity, the factory method \fI\%add_multileader_mtext()\fP returns a \fI\%MultiLeaderMTextBuilder\fP instance to build a new entity and the factory method \fI\%add_multileader_block()\fP returns a \fI\%MultiLeaderBlockBuilder\fP instance. .sp Due of the lack of good documentation it’s not possible to support all combinations of MULTILEADER properties with decent quality, so stick to recipes and hints shown in this tutorial to get usable results otherwise, you will enter uncharted territory. .sp The rendering result of the MULTILEADER entity is highly dependent on the CAD application. The MULTILEADER entity does not have a pre\-rendered anonymous block of DXF primitives like all DIMENSION entities, so results may vary from CAD application to CAD application. The general support for this entity is only good in Autodesk products other CAD applications often struggle when rendering MULTILEADERS, even my preferred testing application BricsCAD has rendering issues. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 MULTILEADER support has flaws in many CAD applications except Autodesk products! .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.render.MultiLeaderBuilder\fP classes .IP \(bu 2 \fI\%ezdxf.entities.MultiLeader\fP class .IP \(bu 2 \fI\%ezdxf.entities.MLeaderStyle\fP class .IP \(bu 2 \fI\%ezdxf.tools.text.MTextEditor\fP class .IP \(bu 2 \fI\%MULTILEADER Internals\fP .UNINDENT .UNINDENT .UNINDENT .SS MTEXT Quick Draw .sp Full Python script: \fI\%mtext_quick_leader.py\fP .sp The \fBquick_leader()\fP method of a MTEXT \- MULTILEADER entity constructs the geometry parameters in reverse manner, starting from a given target point: .sp DXF document setup: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(setup=True) # Create a new custom MLEADERSTYLE: mleaderstyle = doc.mleader_styles.duplicate_entry(\(dqStandard\(dq, \(dqEZDXF\(dq) # The required TEXT style \(dqOpenSans\(dq was created by ezdxf.new() because setup is True: mleaderstyle.set_mtext_style(\(dqOpenSans\(dq) msp = doc.modelspace() .EE .UNINDENT .UNINDENT .sp Draw a red circle to mark the target point: .INDENT 0.0 .INDENT 3.5 .sp .EX target_point = Vec2(40, 15) msp.add_circle( target_point, radius=0.5, dxfattribs=GfxAttribs(color=colors.RED) ) .EE .UNINDENT .UNINDENT .sp Create four horizontal placed MULTILEADER entities pointing at the target point, the first segment of the leader line is determined by an angle in this example pointing away from the target point: .INDENT 0.0 .INDENT 3.5 .sp .EX for angle in [45, 135, 225, \-45]: ml_builder = msp.add_multileader_mtext(\(dqEZDXF\(dq) ml_builder.quick_leader( f\(dqangle={angle}°\en2nd text line\(dq, target=target_point, segment1=Vec2.from_deg_angle(angle, 14), ) .EE .UNINDENT .UNINDENT [image] .sp The content is automatically aligned to the end of the leader line. The first segment is a relative vector to the target point and the optional second segment vector is relative to the end of the first segment. The default connection type is horizontal but can be changed to vertical: .sp A smaller text size is required: .INDENT 0.0 .INDENT 3.5 .sp .EX mleaderstyle = doc.mleader_styles.duplicate_entry(\(dqStandard\(dq, \(dqEZDXF\(dq) mleaderstyle.set_mtext_style(\(dqOpenSans\(dq) mleaderstyle.dxf.char_height = 2.0 # set the default char height of MTEXT .EE .UNINDENT .UNINDENT .sp Adding vertical placed MULTILEADER entities: .INDENT 0.0 .INDENT 3.5 .sp .EX for angle in [45, 135, 225, \-45]: ml_builder = msp.add_multileader_mtext(\(dqEZDXF\(dq) ml_builder.quick_leader( f\(dqangle={angle}°\en2nd text line\(dq, target=target_point, segment1=Vec2.from_deg_angle(angle, 14), connection_type=mleader.VerticalConnection.center_overline, ) .EE .UNINDENT .UNINDENT .sp This example already shows the limitation caused by different text renderings in various CAD applications. The \fIezdxf\fP text measurement by \fImatplotlib\fP is different to AutoCAD and BricsCAD and the result is a misalignment of the overline and the leader line. .sp The DXF file shown in BricsCAD: [image] .sp The same DXF file shown with the \fBezdxf view\fP command (drawing add\-on): [image] .sp My advice is to avoid vertical placed MULTILEADER entities at all and for horizontal placed MULTILEADER entities avoid styles including an “underline” or an “overline”. .sp The \fBquick_leader()\fP method is not very customizable for ease of use, but follows the settings of the associated \fI\%MLeaderStyle\fP\&. .sp The following sections show how to have more control when adding MULTILEADER entities. .SS Create MTEXT Content .sp Full Python script: \fI\%mtext_content.py\fP .sp This section shows how to create a MULTILEADER entity with MTEXT content the manual way with full control over all settings. .sp For good results the MTEXT alignment should match the leader connection side, e.g. if you attach leaders to the left side also align the MTEXT to the left side, for leaders attached at the right side, align the MTEXT to the right side and if you attach leaders at both sides one side will fit better than the other or maybe a center aligned MTEXT is a good solution, for further details see section \fI\%MTEXT Alignment\fP\&. .sp The first example uses the default connection type of the MLEADERSTYLE “Standard” which is “middle of the top line” for left and right attached leaders. The render UCS for this example is the WCS to keep things simple. .sp Create a new MULTILEADER entity. .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder = msp.add_multileader_mtext(\(dqStandard\(dq) .EE .UNINDENT .UNINDENT .sp Set MTEXT content, text style and alignment. .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.set_content( \(dqLine1\enLine2\(dq, style=\(dqOpenSans\(dq, alignment=mleader.TextAlignment.left, # set MTEXT alignment! ) .EE .UNINDENT .UNINDENT .sp Add the first leader on the left side. The leader points always to the first given vertex and all vertices are given in render UCS coordinates (= WCS in this example). .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.add_leader_line(mleader.ConnectionSide.left, [Vec2(\-20, \-15)]) .EE .UNINDENT .UNINDENT .sp More than one vertex per leader can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.add_leader_line( mleader.ConnectionSide.left, [Vec2(\-20, 15), Vec2(\-10, 15), Vec2(\-15, 11), Vec2(\-10, 7)], ) .EE .UNINDENT .UNINDENT .sp The insert point of the \fBbuild()\fP method is the alignment point for the MTEXT content. .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.build(insert=Vec2(5, 0)) .EE .UNINDENT .UNINDENT .sp The “dogleg” settings are defined by the MLEADERSTYLE “Standard”. [image] .sp This example shows a leader attached to the right side and the MTEXT aligned to the right side. .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder = msp.add_multileader_mtext(\(dqStandard\(dq) ml_builder.set_content( \(dqLine1\enLine2\(dq, style=\(dqOpenSans\(dq, alignment=mleader.TextAlignment.right, # set MTEXT alignment! ) ml_builder.add_leader_line(mleader.ConnectionSide.right, [Vec2(40, \-15)]) ml_builder.build(insert=Vec2(15, 0)) .EE .UNINDENT .UNINDENT [image] .sp This example shows two leaders attached to both sides and the MTEXT aligned to the left side, which shows that the right landing gap (space between text and start of vertex) is bigger than the gap on the left size. This is due to the different text size calculations from AutoCAD/BricsCAD and Matplotlib. The longer the text, the greater the error. .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder = msp.add_multileader_mtext(\(dqStandard\(dq) ml_builder.set_content( \(dqLine1\enLine1\(dq, style=\(dqOpenSans\(dq, alignment=mleader.TextAlignment.left, # set MTEXT alignment! ) ml_builder.add_leader_line(mleader.ConnectionSide.left, [Vec2(\-20, \-15)]) ml_builder.add_leader_line(mleader.ConnectionSide.right, [Vec2(40, \-15)]) ml_builder.build(insert=Vec2(5, 0)) .EE .UNINDENT .UNINDENT [image] .sp A centered MTEXT alignment gives a more even result. .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder = msp.add_multileader_mtext(\(dqStandard\(dq) ml_builder.set_content( \(dqFirst Line\en2. Line\(dq, style=\(dqOpenSans\(dq, alignment=mleader.TextAlignment.center, # set MTEXT alignment! ) ml_builder.add_leader_line(mleader.ConnectionSide.left, [Vec2(\-20, \-15)]) ml_builder.add_leader_line(mleader.ConnectionSide.right, [Vec2(40, \-15)]) ml_builder.build(insert=Vec2(10, 0)) .EE .UNINDENT .UNINDENT [image] .sp But even this has its disadvantages, the attachment calculation is always based on the bounding box of the MTEXT content. [image] .SS MTEXT Connection Types .sp There are four connection sides defined by the enum \fI\%ezdxf.render.ConnectionSide\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 left .IP \(bu 2 right .IP \(bu 2 top .IP \(bu 2 bottom .UNINDENT .UNINDENT .UNINDENT .sp The MultiLeader entity supports as the name says multiple leader lines, but all have to have a horizontal (left/right) connection side or a vertical (top/bottom) connection side, it’s not possible to mix left/right and top/bottom connection sides. This is determined by the DXF format. .sp There are different connection types available for the horizontal and the vertical connection sides. All leaders connecting to the same side have the same connection type. The horizontal connection sides support following connection types, defined by the enum \fI\%ezdxf.render.HorizontalConnection\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 by_style .IP \(bu 2 top_of_top_line .IP \(bu 2 middle_of_top_line .IP \(bu 2 middle_of_text .IP \(bu 2 middle_of_bottom_line .IP \(bu 2 bottom_of_bottom_line .IP \(bu 2 bottom_of_bottom_line_underline (not recommended) .IP \(bu 2 bottom_of_top_line_underline (not recommended) .IP \(bu 2 bottom_of_top_line .IP \(bu 2 bottom_of_top_line_underline_all (not recommended) .UNINDENT .UNINDENT .UNINDENT .sp The vertical connection sides support following connection types, defined by the enum \fI\%ezdxf.render.VerticalConnection\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 by_style .IP \(bu 2 center .IP \(bu 2 center_overline (not recommended) .UNINDENT .UNINDENT .UNINDENT .sp The connection type for each side can be set by the method \fI\%set_connection_types()\fP, the default for all sides is \fIby_style\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.set_connection_types( left=mleader.HorizontalConnection.middle_of_top_line, right=mleader.HorizontalConnection.middle_of_bottom_line, ) .EE .UNINDENT .UNINDENT [image] .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 As shown in the quick draw section using connection types including underlines or overlines do not render well in AutoCAD/BricsCAD because of the different text measurement of \fImatplotlib\fP, therefore it’s not recommended to use any of these connection types when creating MULTILEADERS by \fIezdxf\fP\&. .UNINDENT .UNINDENT .SS MTEXT Alignment .sp In contrast to the standalone MTEXT entity supports the MTEXT content entity only three text alignments defined by the enum \fI\%ezdxf.render.TextAlignment\fP\&. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 left .IP \(bu 2 center .IP \(bu 2 right .UNINDENT .UNINDENT .UNINDENT .sp The MTEXT alignment is set as argument \fIalignment\fP of the \fBset_content()\fP method and the alignment point is the insert point of the \fI\%build()\fP method. .SS Create BLOCK Content .sp Full Python script: \fI\%block_content.py\fP .sp This section shows how to create a MULTILEADER entity with BLOCK content the manual way with full control over all settings. .sp The BLOCK content consist of a BLOCK layout and optional ATTDEF entities which defines the location and DXF attributes of dynamically created ATTRIB entities. .sp Create the BLOCK content, the full \fBcreate_square_block()\fP function can be found in the \fI\%block_content.py\fP script. .INDENT 0.0 .INDENT 3.5 .sp .EX block = create_square_block( doc, size=8.0, margin=0.25, base_point=base_point ) .EE .UNINDENT .UNINDENT .sp Create the MULTILEADER and set the content: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder = msp.add_multileader_block(style=\(dqStandard\(dq) ml_builder.set_content( name=block.name, alignment=mleader.BlockAlignment.insertion_point ) .EE .UNINDENT .UNINDENT .sp Set the BLOCK attribute content as text: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.set_attribute(\(dqONE\(dq, \(dqData1\(dq) ml_builder.set_attribute(\(dqTWO\(dq, \(dqData2\(dq) .EE .UNINDENT .UNINDENT .sp Add some leader lines to the left and right side of the BLOCK: .sp Construction plane of the entity is defined by a render UCS. The leader lines vertices are expected in render UCS coordinates, which means relative to the UCS origin and this example shows the simple case where the UCS is the WCS which is also the default setting. .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.add_leader_line(mleader.ConnectionSide.right, [Vec2(x2, y1)]) ml_builder.add_leader_line(mleader.ConnectionSide.right, [Vec2(x2, y2)]) ml_builder.add_leader_line(mleader.ConnectionSide.left, [Vec2(x1, y1)]) ml_builder.add_leader_line(mleader.ConnectionSide.left, [Vec2(x1, y2)]) .EE .UNINDENT .UNINDENT .sp Last step is to build the final MULTILEADER entity. This example uses the alignment type \fIinsertion_point\fP where the insert point of the \fBbuild()\fP method is the base point of the BLOCK: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.build(insert=Vec2(5, 2), rotation=30) .EE .UNINDENT .UNINDENT [image] .sp The result is shown in BricsCAD as expected, although BricsCAD shows “Center extents” as attachment type in the properties dialog instead of the correct attachment type “Insertion point”. .SS BLOCK Connection Types .sp There are four connection sides defined by the enum \fI\%ezdxf.render.ConnectionSide\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 left .IP \(bu 2 right .IP \(bu 2 top .IP \(bu 2 bottom .UNINDENT .UNINDENT .UNINDENT .sp The connection point for leader lines is always the center of the side of the block bounding box the leader is connected to and has the same limitation as for the MTEXT content, it’s not possible to mix the connection sides left/right and top/bottom. .sp The connection side is set when adding the leader line by the \fI\%add_leader_line()\fP method. .sp Unfortunately BricsCAD has an error in version 22.2.03 and renders all connection types as left/right, this is top/bottom connection shown in Autodesk TrueView 2022: [image] .sp The top/bottom connection type does not support the “dogleg” feature. .SS BLOCK Alignment .sp There are two alignments types, defined by the enum \fI\%ezdxf.render.BlockAlignment\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 center_extents .IP \(bu 2 insertion_point .UNINDENT .UNINDENT .UNINDENT .sp The alignment is set by the \fI\%set_content()\fP method. .sp The alignment type \fIcenter_extent\fP inserts the BLOCK with the center of the bounding box at the insert point of the \fI\%build()\fP method. The insert point is (5, 2) in this example: [image] .sp The same MULTILEADER with alignment type \fIinsert_point\fP: [image] .SS BLOCK Scaling .sp The BLOCK content can be scaled independently from the overall scaling of the MULTILEADER entity: .sp The block scaling factor is set by the \fI\%set_content()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.set_content( name=block.name, scale=2.0, alignment=mleader.BlockAlignment.center_extents ) .EE .UNINDENT .UNINDENT .sp This is the first example with a block scaling factor of 2. The BLOCK and the attached ATTRIB entities are scaled but not the arrows. [image] .SS BLOCK Rotation .sp The rotation around the render UCS z\-axis in degrees is applied by the \fI\%build()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.build(insert=Vec2(5, 2), rotation=30) .EE .UNINDENT .UNINDENT .sp This is the first example with a rotation of 30 degrees. The BLOCK, the attached ATTRIB entities and the last connection lines (“dogleg”) are rotated. [image] .SS BLOCK Attributes .sp BLOCK attributes are defined as ATTDEF entities in the BLOCK layout. This ATTDEF entities will be replaced by ATTRIB entities at the rendering process of the CAD application. Only the text content and the text width factor can be changed for each MULTILEADER entity individually by the \fI\%set_attribute()\fP method. The ATTDEF is addressed by it’s DXF \fItag\fP attribute: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.set_attribute(\(dqONE\(dq, \(dqData1\(dq) ml_builder.set_attribute(\(dqTWO\(dq, \(dqData2\(dq) .EE .UNINDENT .UNINDENT .SS Leader Properties .SS “Dogleg” Properties .sp The “dogleg” is the last line segment from the last leader vertex to the MULTILEADER content for polyline leaders. [image] .sp The length of the dogleg and the landing gap size is set by the \fI\%set_connection_properties()\fP\&. .SS Polyline Leader .sp A polygon leader line has only straight line segments and is added by the \fI\%add_leader_line()\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.add_leader_line( mleader.ConnectionSide.left, [Vec2(\-20, 15), Vec2(\-10, 15), Vec2(\-15, 11), Vec2(\-10, 7)], ) .EE .UNINDENT .UNINDENT [image] .sp All leader line vertices have render UCS coordinates and the start\- and end\-vertex of the “dogleg” is calculated automatically. .SS Spline Leader .sp A spline leader line has a single curved line as leader line and is also added by the \fI\%add_leader_line()\fP\&. This is spline leader has the same vertices as the previous created polyline leader: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.set_leader_properties(leader_type=mleader.LeaderType.splines) ml_builder.add_leader_line( mleader.ConnectionSide.left, [Vec2(\-20, 15), Vec2(\-10, 15), Vec2(\-15, 11), Vec2(\-10, 7)], ) .EE .UNINDENT .UNINDENT [image] .sp The spline leader has no “dogleg” and spline leaders and polyline leaders can not be mixed in a single MULTILEADER entity. .sp The leader type is set by the \fI\%set_leader_properties()\fP method. .sp The \fI\%LeaderType\fP enum: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 none .IP \(bu 2 straight_lines .IP \(bu 2 splines .UNINDENT .UNINDENT .UNINDENT .SS Line Styling .sp The leader color, linetype and lineweight is set by the \fI\%set_leader_properties()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX ml_builder.set_leader_properties( color=colors.MAGENTA, linetype=\(dqDASHEDX2\(dq, lineweight=70, ) .EE .UNINDENT .UNINDENT [image] .sp All leader lines have the same properties. .SS Arrowheads .sp The arrow head is set by the \fI\%set_arrow_properties()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.render import ARROWS ml_builder.set_arrow_properties(name=ARROWS.closed_blank, size=8.0) .EE .UNINDENT .UNINDENT [image] .sp All leader lines have the same arrow head and size. The available arrow heads are defined in the \fI\%ARROWS\fP object. .SS Overall Scaling .sp The overall scaling has to be applied by the \fI\%set_overall_scaling()\fP method and scales the MTEXT or BLOCK content \fBand\fP the arrows. .SS Setup MLEADERSTYLE .sp The \fI\%MLeaderStyle\fP stores many of the MULTILEADER settings but most of them are copied to the MULTILINE entity at initialization. So changing the MLEADERSTYLE style afterwards has little to no effect for existing MULTILEADER entities. .sp Create a new MLEADERSTYLE called “MY_STYLE” and set the MTEXT style to “OpenSans”: .INDENT 0.0 .INDENT 3.5 .sp .EX my_style = doc.mleader_styles.duplicate_entry(\(dqStandard\(dq, \(dqMY_STYLE\(dq) my_style.set_mtext_style(\(dqOpenSans\(dq) .EE .UNINDENT .UNINDENT .sp The style for a MULTILEADER is set at the \fI\%add_multileader_mtext()\fP and \fI\%add_multileader_block()\fP factory methods. .SS Tutorial for Viewports in Paperspace .sp This tutorial is based on the example script \fIviewports_in_paperspace.py\fP\&. The script creates DXF files for the version R12 and for R2000+, but the export for DXF R12 has a wrong papersize in BricsCAD and wrong margins in Autodesk DWG Trueview. I don’t know why this happens and I don’t waste my time to fix this. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 If you need paperspace layouts use DXF version R2000 or newer because the export of the page dimensions does not work for DXF R12! .UNINDENT .UNINDENT .sp The scripts creates three flat geometries in the xy\-plane of the \fI\%WCS\fP and a 3D mesh as content of the modelspace: [image] .SS Page Setup .sp The paperspace layout feature lacks documentation in the DXF reference, there is no information in practice on \fBhow\fP it is used, so most of the information here is assumptions gathered through trail and error. .sp The \fI\%page_setup()\fP method defines the properties of the paper sheet itself. The units of the modelspace and the paperspace are not related and can even have different unit systems (imperial, meters), but to keep things simple it’s recommended to use the same unit system for both spaces. .INDENT 0.0 .INDENT 3.5 .sp .EX layout.page_setup(size=(24, 18), margins=(1, 1, 1, 1), units=\(dqinch\(dq) .EE .UNINDENT .UNINDENT .sp The \fIsize\fP argument defines the overall paper size in rotation mode 0, it seems to be the best practice to define the paper extents in landscape mode and rotate the paper by the \fIrotate\fP argument afterwards. .sp Choices for the \fIrotation\fP argument: .INDENT 0.0 .INDENT 3.5 .TS center; |l|l|. _ T{ 0 T} T{ no rotation T} _ T{ 1 T} T{ 90 degrees counter\-clockwise T} _ T{ 2 T} T{ upside\-down T} _ T{ 3 T} T{ 90 degrees clockwise T} _ .TE .UNINDENT .UNINDENT .sp The \fIscale\fP argument reflects the relationship between paper unit and drawing unit in paperspace. It’s recommended to let this scale at the default value of 1:1 and draw lines and text in paperspace with the same units as you defined the paper size. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 AutoCAD: \fI\%About Plotting\fP and \fI\%About Setting the Plot Scale\fP .IP \(bu 2 BricsCAD: \fI\%General Procedure for Printing\fP .UNINDENT .UNINDENT .UNINDENT .SS Drawing in Paperspace .sp You can add DXF entities to the paperspace like to any other layout space. The coordinate origin (0, 0) is in the left bottom corner of the canvas which is the paper size minus the margins. You can draw beyond this limits but CAD applications may not print that content. .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 By writing this tutorial I noticed that changing the printer/plotter and the paper size does shift the layout content, because all paper sizes are defined without margins. Maybe it’s preferable to set all margins to zero. .sp I added the helper method \fI\%page_setup()\fP to the \fI\%Drawing\fP class and an example \fI\%simple_page_setup.py\fP how to use it. .UNINDENT .UNINDENT .SS Adding Viewports .sp The \fI\%Viewport\fP entity is a window to the modelspace to display the content of the modelspace in paperspace with an arbitrary scaling and rotation. The VIEWPORT entity will be added by the factory method \fI\%add_viewport()\fP, the \fIcenter\fP argument defines the center and the \fIsize\fP argument defines the width and height of the of the VIEWPORT in paperspace. The source of the modelspace to display is defined by the arguments \fIview_center_point\fP and \fIview_height\fP\&. [image] .SS Scaling Factor .sp The scaling factor of the VIEWPORT is not an explicit value, the factor is defined by the relation of the VIEWPORT height of the \fIsize\fP argument and the \fIview_height\fP argument. .sp If both values are equal the scaling is 1:1 .INDENT 0.0 .INDENT 3.5 .sp .EX paperspace.add_viewport( center=(14.5, 2.5), size=(5, 5), view_center_point=(12.5, 7.5), view_height=5, ) .EE .UNINDENT .UNINDENT .sp If the \fIview_height\fP is 5x larger than the VIEWPORT height the scaling is 1:5 .INDENT 0.0 .INDENT 3.5 .sp .EX paperspace.add_viewport( center=(8.5, 2.5), size=(5, 5), view_center_point=(10, 5), view_height=25, ) .EE .UNINDENT .UNINDENT .SS View Direction .sp The default view direction is the top down view, but can be changed to any view by the attributes \fIview_target_point\fP and \fIview_direction_vector\fP of the \fBdxf\fP namespace. .INDENT 0.0 .INDENT 3.5 .sp .EX vp = paperspace.add_viewport( center=(16, 10), size=(4, 4), view_center_point=(0, 0), view_height=30 ) vp.dxf.view_target_point = (40, 40, 0) vp.dxf.view_direction_vector = (\-1, \-1, 1) .EE .UNINDENT .UNINDENT .SS Viewport Frame .sp The VIEWPORT frame (borderlines) are shown in paperspace by default. The VIEWPORT entity does not have an attribute to change this. The visibility of the VIEWPORT frame is controlled by the layer assigned to the VIEWPORT entity which is the layer “VIEWPORTS” by default in \fIezdxf\fP\&. Turning off this layer hides the frames of the VIEWPORT entities on this layer, to do that the layer “VIEWPORTS” have to be created by the library user: .INDENT 0.0 .INDENT 3.5 .sp .EX vp_layer = doc.layers.add(\(dqVIEWPORTS\(dq) vp_layer.off() .EE .UNINDENT .UNINDENT .SS Freeze Layers .sp Each VIEWPORT can have individual frozen layers, which means the layers are not visible in this VIEWPORT. To freeze layers in a VIEWPORT assign the names of the frozen layers as a list\-like object to the \fBfrozen_layers\fP attribute of the VIEWPORT entity: .INDENT 0.0 .INDENT 3.5 .sp .EX vp.frozen_layers = [\(dqLayer0\(dq, \(dqLayer1\(dq] .EE .UNINDENT .UNINDENT .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 AutoCAD and BricsCAD \fBdo not crash\fP if the layer names do not have layer table entries and the layer names are case insensitive as all table names. .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basic concept of \fI\%Layers\fP .IP \(bu 2 \fI\%Layer\fP .UNINDENT .UNINDENT .UNINDENT .SS Override Layer Properties .sp Each VIEWPORT can override layer properties individually. These overrides are stored in the \fI\%Layer\fP entity and referenced by the handle of the VIEWPORT. This procedure is a bit more complex and shown in the example file \fI\%viewports_override_layer_attributes.py\fP\&. .INDENT 0.0 .IP 1. 3 get the \fI\%Layer\fP object .IP 2. 3 get the \fI\%LayerOverrides\fP object from the layer .IP 3. 3 override the properties of the VIEWPORT .IP 4. 3 commit changes .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX layer = doc.layers.get(\(dqLayer0\(dq) override = layer.get_vp_overrides() override.set_linetype(vp.dxf.handle, \(dqDASHED\(dq) override.commit() .EE .UNINDENT .UNINDENT .sp Supported property overrides: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 ACI color .IP \(bu 2 true color .IP \(bu 2 transparency .IP \(bu 2 linetype .IP \(bu 2 lineweight .UNINDENT .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Basic concept of \fI\%Layers\fP .IP \(bu 2 Basic concept of \fI\%AutoCAD Color Index (ACI)\fP .IP \(bu 2 Basic concept of \fI\%True Color\fP .IP \(bu 2 Basic concept of \fI\%Transparency\fP .IP \(bu 2 Basic concept of \fI\%Linetypes\fP .IP \(bu 2 Basic concept of \fI\%Lineweights\fP .IP \(bu 2 \fI\%Layer\fP .IP \(bu 2 \fI\%LayerOverrides\fP .UNINDENT .UNINDENT .UNINDENT .SS Tutorial for OCS/UCS Usage .sp For OCS/UCS usage is a basic understanding of vector math required, for a brush up, watch the YouTube tutorials of \fI\%3Blue1Brown\fP about \fI\%Linear Algebra\fP\&. .sp Second read the \fI\%Coordinate Systems\fP introduction please. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 The free online book \fI\%3D Math Primer for Graphics and Game Development\fP is a very good resource for learning vector math and other graphic related topics, it is easy to read for beginners and especially targeted to programmers. .UNINDENT .UNINDENT .sp For \fI\%WCS\fP there is not much to say as, it is what it is: the main world coordinate system, and a drawing unit can have any real world unit you want. Autodesk added some mechanism to define a scale for dimension and text entities, but because I am not an AutoCAD user, I am not familiar with it, and further more I think this is more an AutoCAD topic than a DXF topic. .SS Object Coordinate System (OCS) .sp The \fI\%OCS\fP is used to place planar 2D entities in 3D space. \fBALL\fP points of a planar entity lay in the same plane, this is also true if the plane is located in 3D space by an OCS. There are three basic DXF attributes that gives a 2D entity its spatial form. .SS Extrusion .sp The extrusion vector defines the OCS, it is a normal vector to the base plane of a planar entity. This \fIbase plane\fP is always located in the origin of the \fI\%WCS\fP\&. But there are some entities like \fI\%Ellipse\fP, which have an extrusion vector, but do not establish an OCS. For this entities the extrusion vector defines only the extrusion direction and thickness defines the extrusion distance, but all other points and directions in WCS. .SS Elevation .sp The elevation value defines the z\-axis value for all points of a planar entity, this is an OCS value, and defines the distance of the entity plane from the \fIbase plane\fP\&. .sp This value exists only in output from DXF versions prior to R11 as separated DXF attribute (group code 38). In DXF R12 and later, the elevation value is supplied as z\-axis value of each point. But as always in DXF, this simple rule does not apply to all entities: \fI\%LWPolyline\fP and \fI\%Hatch\fP have an DXF attribute \fBelevation\fP as a 3D point, where the z\-values of this point is the elevation height and the x\-value and the y\-value are 0. .SS Thickness .sp Defines the extrusion distance for an entity. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 There is a new edition of this tutorial using UCS based transformation, which are available in \fIezdxf\fP v0.11 and later: \fI\%Tutorial for UCS Based Transformations\fP .sp This edition shows the \fBhard way\fP to accomplish the transformations by low level operations. .UNINDENT .UNINDENT .SS Placing 2D Circle in 3D Space .sp The colors of the system axis follow the AutoCAD standard: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 red is x\-axis .IP \(bu 2 green is y\-axis .IP \(bu 2 blue is z\-axis .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.math import OCS doc = ezdxf.new(\(aqR2010\(aq) msp = doc.modelspace() # For this example the OCS is rotated around x\-axis about 45 degree # OCS z\-axis: x=0, y=1, z=1 # extrusion vector must not normalized here ocs = OCS((0, 1, 1)) msp.add_circle( # You can place the 2D circle in 3D space # but you have to convert WCS into OCS center=ocs.from_wcs((0, 2, 2)), # center in OCS: (0.0, 0.0, 2.82842712474619) radius=1, dxfattribs={ # here the extrusion vector should be normalized, # which is granted by using the ocs.uz \(aqextrusion\(aq: ocs.uz, \(aqcolor\(aq: 1, }) # mark center point of circle in WCS msp.add_point((0, 2, 2), dxfattribs={\(aqcolor\(aq: 1}) .EE .UNINDENT .UNINDENT .sp The following image shows the 2D circle in 3D space in AutoCAD \fILeft\fP and \fIFront\fP view. The blue line shows the OCS z\-axis (extrusion direction), elevation is the distance from the origin to the center of the circle in this case 2.828, and you see that the x\- and y\-axis of the OCS and the WCS are not aligned. [image: circle in ocs as side view] [image] [image: circle in ocs as front view] [image] .SS Placing LWPolyline in 3D Space .sp For simplicity of calculation I use the \fI\%UCS\fP class in this example to place a 2D pentagon in 3D space. .INDENT 0.0 .INDENT 3.5 .sp .EX # The center of the pentagon should be (0, 2, 2), and the shape is # rotated around x\-axis about 45 degree, to accomplish this I use an # UCS with z\-axis (0, 1, 1) and an x\-axis parallel to WCS x\-axis. ucs = UCS( origin=(0, 2, 2), # center of pentagon ux=(1, 0, 0), # x\-axis parallel to WCS x\-axis uz=(0, 1, 1), # z\-axis ) # calculating corner points in local (UCS) coordinates points = [Vec3.from_deg_angle((360 / 5) * n) for n in range(5)] # converting UCS into OCS coordinates ocs_points = list(ucs.points_to_ocs(points)) # LWPOLYLINE accepts only 2D points and has an separated DXF attribute elevation. # All points have the same z\-axis (elevation) in OCS! elevation = ocs_points[0].z msp.add_lwpolyline( points=ocs_points, format=\(aqxy\(aq, # ignore z\-axis close=True, dxfattribs={ \(aqelevation\(aq: elevation, \(aqextrusion\(aq: ucs.uz, \(aqcolor\(aq: 1, }) .EE .UNINDENT .UNINDENT .sp The following image shows the 2D pentagon in 3D space in AutoCAD \fILeft\fP, \fIFront\fP and \fITop\fP view. The three lines from the center of the pentagon show the UCS, the three colored lines in the origin show the OCS, the white lines in the origin show the WCS. .sp The z\-axis of the UCS and the OCS pointing in the same direction (extrusion direction), and the x\-axis of the UCS and the WCS pointing also in the same direction. The elevation is the distance from the origin to the center of the pentagon and all points of the pentagon have the same elevation, and you see that the y\-axis of the UCS, the OCS and the WCS are not aligned. [image: pentagon in ucs as side view] [image] [image: pentagon in ucs as front view] [image] .SS Using UCS to Place 3D Polyline .sp It is much simpler to use a 3D \fI\%Polyline\fP to create the 3D pentagon. The \fI\%UCS\fP class is handy for this example and all kind of 3D operations. .INDENT 0.0 .INDENT 3.5 .sp .EX # Using an UCS simplifies 3D operations, but UCS definition can happen later # calculating corner points in local (UCS) coordinates without Vec3 class angle = math.radians(360 / 5) corners_ucs = [(math.cos(angle * n), math.sin(angle * n), 0) for n in range(5)] # let\(aqs do some transformations tmatrix = Matrix44.chain( # creating a transformation matrix Matrix44.z_rotate(math.radians(15)), # 1. rotation around z\-axis Matrix44.translate(0, .333, .333), # 2. translation ) transformed_corners_ucs = tmatrix.transform_vertices(corners_ucs) # transform UCS into WCS ucs = UCS( origin=(0, 2, 2), # center of pentagon ux=(1, 0, 0), # x\-axis parallel to WCS x\-axis uz=(0, 1, 1), # z\-axis ) corners_wcs = list(ucs.points_to_wcs(transformed_corners_ucs)) msp.add_polyline3d( points=corners_wcs, close=True, ) # add lines from center to corners center_wcs = ucs.to_wcs((0, .333, .333)) for corner in corners_wcs: msp.add_line(center_wcs, corner, dxfattribs={\(aqcolor\(aq: 1}) ucs.render_axis(msp) .EE .UNINDENT .UNINDENT [image: 3d poyline with UCS] [image] .SS Placing 2D Text in 3D Space .sp The problem of placing text in 3D space is the text rotation, which is always counter clockwise around the OCS z\-axis, and \fB0\fP degree is the direction of the positive OCS x\-axis, and the OCS x\-axis is calculated by the \fI\%Arbitrary Axis Algorithm\fP\&. .sp Calculate the OCS rotation angle by converting the TEXT rotation angle (in UCS or WCS) into a vector or begin with text direction as vector, transform this direction vector into OCS and convert the OCS vector back into an angle in the OCS xy\-plane (see example), this procedure is available as \fI\%UCS.to_ocs_angle_deg()\fP or \fBUCS.to_ocs_angle_rad()\fP\&. .sp AutoCAD supports thickness for the TEXT entity only for \fI\&.shx\fP fonts and not for true type fonts. .INDENT 0.0 .INDENT 3.5 .sp .EX # Thickness for text works only with shx fonts not with true type fonts doc.styles.new(\(aqTXT\(aq, dxfattribs={\(aqfont\(aq: \(aqromans.shx\(aq}) ucs = UCS(origin=(0, 2, 2), ux=(1, 0, 0), uz=(0, 1, 1)) # calculation of text direction as angle in OCS: # convert text rotation in degree into a vector in UCS text_direction = Vec3.from_deg_angle(\-45) # transform vector into OCS and get angle of vector in xy\-plane rotation = ucs.to_ocs(text_direction).angle_deg text = msp.add_text( text=\(dqTEXT\(dq, dxfattribs={ # text rotation angle in degrees in OCS \(aqrotation\(aq: rotation, \(aqextrusion\(aq: ucs.uz, \(aqthickness\(aq: .333, \(aqcolor\(aq: 1, \(aqstyle\(aq: \(aqTXT\(aq, }) # set text position in OCS text.set_pos(ucs.to_ocs((0, 0, 0)), align=\(aqMIDDLE_CENTER\(aq) .EE .UNINDENT .UNINDENT [image: text in ucs as top view] [image] [image: text in ucs as front view] [image] .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 For calculating OCS angles from an UCS, be aware that 2D entities, like TEXT or ARC, are placed parallel to the xy\-plane of the UCS. .UNINDENT .UNINDENT .SS Placing 2D Arc in 3D Space .sp Here we have the same problem as for placing text, you need the start\- and end angle of the arc in degrees in the OCS, and this example also shows a shortcut for calculating the OCS angles. .INDENT 0.0 .INDENT 3.5 .sp .EX ucs = UCS(origin=(0, 2, 2), ux=(1, 0, 0), uz=(0, 1, 1)) msp.add_arc( center=ucs.to_ocs((0, 0)), radius=1, start_angle=ucs.to_ocs_angle_deg(45), end_angle=ucs.to_ocs_angle_deg(270), dxfattribs={ \(aqextrusion\(aq: ucs.uz, \(aqcolor\(aq: 1, }) center = ucs.to_wcs((0, 0)) msp.add_line( start=center, end=ucs.to_wcs(Vec3.from_deg_angle(45)), dxfattribs={\(aqcolor\(aq: 1}, ) msp.add_line( start=center, end=ucs.to_wcs(Vec3.from_deg_angle(270)), dxfattribs={\(aqcolor\(aq: 1}, ) .EE .UNINDENT .UNINDENT [image: arc in ucs as top view] [image] [image: arc in ucs as front view] [image] .SS Placing Block References in 3D Space .sp Despite the fact that block references (\fI\%Insert\fP) can contain true 3D entities like \fI\%Line\fP or \fI\%Mesh\fP, the \fI\%Insert\fP entity uses the same placing principe as \fI\%Text\fP or \fI\%Arc\fP shown in the previous chapters. .sp Placement by OCS coordinates and rotation about the OCS z\-axis, can be achieved the same way as for generic 2D entities. The DXF attribute \fBInsert.dxf.rotation\fP rotates a block reference around the block z\-axis, which is located in the \fBBlock.dxf.base_point\fP\&. To rotate the block reference around the WCS x\-axis, a transformation of the block z\-axis into the WCS x\-axis is required by rotating the block z\-axis 90 degree counter\-clockwise around y\-axis by using an UCS: .sp This is just an excerpt of the important parts, see the whole code of \fI\%insert.py\fP at github. .INDENT 0.0 .INDENT 3.5 .sp .EX # rotate UCS around an arbitrary axis: def ucs_rotation(ucs: UCS, axis: Vec3, angle: float): # new in ezdxf v0.11: UCS.rotate(axis, angle) t = Matrix44.axis_rotate(axis, math.radians(angle)) ux, uy, uz = t.transform_vertices([ucs.ux, ucs.uy, ucs.uz]) return UCS(origin=ucs.origin, ux=ux, uy=uy, uz=uz) doc = ezdxf.new(\(aqR2010\(aq, setup=True) blk = doc.blocks.new(\(aqCSYS\(aq) setup_csys(blk) msp = doc.modelspace() ucs = ucs_rotation(UCS(), axis=Y_AXIS, angle=90) # transform insert location to OCS insert = ucs.to_ocs((0, 0, 0)) # rotation angle about the z\-axis (= WCS x\-axis) rotation = ucs.to_ocs_angle_deg(15) msp.add_blockref(\(aqCSYS\(aq, insert, dxfattribs={ \(aqextrusion\(aq: ucs.uz, \(aqrotation\(aq: rotation, }) .EE .UNINDENT .UNINDENT [image] [image] .sp To rotate a block reference around another axis than the block z\-axis, you have to find the rotated z\-axis (extrusion vector) of the rotated block reference, following example rotates the block reference around the block x\-axis by 15 degrees: .INDENT 0.0 .INDENT 3.5 .sp .EX # t is a transformation matrix to rotate 15 degree around the x\-axis t = Matrix44.axis_rotate(axis=X_AXIS, angle=math.radians(15)) # transform block z\-axis into new UCS z\-axis (= extrusion vector) uz = Vec3(t.transform(Z_AXIS)) # create new UCS at the insertion point, because we are rotating around the x\-axis, # ux is the same as the WCS x\-axis and uz is the rotated z\-axis. ucs = UCS(origin=(1, 2, 0), ux=X_AXIS, uz=uz) # transform insert location to OCS, block base_point=(0, 0, 0) insert = ucs.to_ocs((0, 0, 0)) # for this case a rotation around the z\-axis is not required rotation = 0 blockref = msp.add_blockref(\(aqCSYS\(aq, insert, dxfattribs={ \(aqextrusion\(aq: ucs.uz, \(aqrotation\(aq: rotation, }) .EE .UNINDENT .UNINDENT [image] [image] .sp The next example shows how to translate a block references with an already established OCS: .INDENT 0.0 .INDENT 3.5 .sp .EX # translate a block references with an established OCS translation = Vec3(\-3, \-1, 1) # get established OCS ocs = blockref.ocs() # get insert location in WCS actual_wcs_location = ocs.to_wcs(blockref.dxf.insert) # translate location new_wcs_location = actual_wcs_location + translation # convert WCS location to OCS location blockref.dxf.insert = ocs.from_wcs(new_wcs_location) .EE .UNINDENT .UNINDENT .sp Setting a new insert location is the same procedure without adding a translation vector, just transform the new insert location into the OCS. [image] [image] .sp The next operation is to rotate a block reference with an established OCS, rotation axis is the block y\-axis, rotation angle is \-90 degrees. First transform block y\-axis (rotation axis) and block z\-axis (extrusion vector) from OCS into WCS: .INDENT 0.0 .INDENT 3.5 .sp .EX # rotate a block references with an established OCS around the block y\-axis about 90 degree ocs = blockref.ocs() # convert block y\-axis (= rotation axis) into WCS vector rotation_axis = ocs.to_wcs((0, 1, 0)) # convert local z\-axis (=extrusion vector) into WCS vector local_z_axis = ocs.to_wcs((0, 0, 1)) .EE .UNINDENT .UNINDENT .sp Build transformation matrix and transform extrusion vector and build new UCS: .INDENT 0.0 .INDENT 3.5 .sp .EX # build transformation matrix t = Matrix44.axis_rotate(axis=rotation_axis, angle=math.radians(\-90)) uz = t.transform(local_z_axis) uy = rotation_axis # the block reference origin stays at the same location, no rotation needed wcs_insert = ocs.to_wcs(blockref.dxf.insert) # build new UCS to convert WCS locations and angles into OCS ucs = UCS(origin=wcs_insert, uy=uy, uz=uz) .EE .UNINDENT .UNINDENT .sp Set new OCS attributes, we also have to set the rotation attribute even though we do not rotate the block reference around the local z\-axis, the new block x\-axis (0 deg) differs from OCS x\-axis and has to be adjusted: .INDENT 0.0 .INDENT 3.5 .sp .EX # set new OCS blockref.dxf.extrusion = ucs.uz # set new insert blockref.dxf.insert = ucs.to_ocs((0, 0, 0)) # set new rotation: we do not rotate the block reference around the local z\-axis, # but the new block x\-axis (0 deg) differs from OCS x\-axis and has to be adjusted blockref.dxf.rotation = ucs.to_ocs_angle_deg(0) .EE .UNINDENT .UNINDENT [image] [image] .sp And here is the point, where my math knowledge ends, for more advanced CAD operation you have to look elsewhere. .SS Tutorial for UCS Based Transformations .sp The \fIezdxf\fP version v0.13 introduced a transformation interface for DXF primitives, which makes working with OCS/UCS much easier. This is a new edition of the \fI\%Tutorial for OCS/UCS Usage\fP\&. Please read the old tutorial for the basics about the OCS. .sp For this tutorial we don’t have to worry about the OCS and the extrusion vector, this is done automatically by the \fBtransform()\fP method of each DXF entity. .SS Placing 2D Circle in 3D Space .sp To recreate the situation of the old tutorial instantiate a new UCS and rotate it around the local x\-axis. Use UCS coordinates to place the 2D CIRCLE in 3D space and transform the UCS coordinates to the WCS. .INDENT 0.0 .INDENT 3.5 .sp .EX import math import ezdxf from ezdxf.math import UCS doc = ezdxf.new(\(aqR2010\(aq) msp = doc.modelspace() ucs = UCS() # New default UCS # All rotation angles in radians, and rotation # methods always return a new UCS. ucs = ucs.rotate_local_x(math.radians(\-45)) circle = msp.add_circle( # Use UCS coordinates to place the 2d circle in 3d space center=(0, 0, 2), radius=1, dxfattribs={\(aqcolor\(aq: 1} ) circle.transform(ucs.matrix) # mark center point of circle in WCS msp.add_point((0, 0, 2), dxfattribs={\(aqcolor\(aq: 1}).transform(ucs.matrix) .EE .UNINDENT .UNINDENT [image: circle in ucs as side view] [image] [image: circle in ucs as front view] [image] .SS Placing LWPolyline in 3D Space .sp Simplified LWPOLYLINE example: .INDENT 0.0 .INDENT 3.5 .sp .EX # The center of the pentagon should be (0, 2, 2), and the shape is # rotated around x\-axis about \-45 degree ucs = UCS(origin=(0, 2, 2)).rotate_local_x(math.radians(\-45)) msp.add_lwpolyline( # calculating corner points in UCS coordinates points=(Vec3.from_deg_angle((360 / 5) * n) for n in range(5)), format=\(aqxy\(aq, # ignore z\-axis close=True, dxfattribs={ \(aqcolor\(aq: 1, } ).transform(ucs.matrix) .EE .UNINDENT .UNINDENT .sp The 2D pentagon in 3D space in BricsCAD \fILeft\fP and \fIFront\fP view. [image: pentagon in ucs as side view] [image] [image: pentagon in ucs as front view] [image] .SS Using UCS to Place 3D Polyline .sp Simplified POLYLINE example: Using a first UCS to transform the POLYLINE and a second UCS to place the POLYLINE in 3D space. .INDENT 0.0 .INDENT 3.5 .sp .EX # using an UCS simplifies 3D operations, but UCS definition can happen later # calculating corner points in local (UCS) coordinates without Vec3 class angle = math.radians(360 / 5) corners_ucs = [(math.cos(angle * n), math.sin(angle * n), 0) for n in range(5)] # let\(aqs do some transformations by UCS transformation_ucs = UCS().rotate_local_z(math.radians(15)) # 1. rotation around z\-axis transformation_ucs.shift((0, .333, .333)) # 2. translation (inplace) corners_ucs = list(transformation_ucs.points_to_wcs(corners_ucs)) location_ucs = UCS(origin=(0, 2, 2)).rotate_local_x(math.radians(\-45)) msp.add_polyline3d( points=corners_ucs, close=True, dxfattribs={ \(aqcolor\(aq: 1, } ).transform(location_ucs.matrix) # Add lines from the center of the POLYLINE to the corners center_ucs = transformation_ucs.to_wcs((0, 0, 0)) for corner in corners_ucs: msp.add_line( center_ucs, corner, dxfattribs={\(aqcolor\(aq: 1} ).transform(location_ucs.matrix) .EE .UNINDENT .UNINDENT [image: 3d poyline with UCS] [image] .SS Placing 2D Text in 3D Space .sp The problem with the text rotation in the old tutorial disappears with the new UCS based transformation method: .sp AutoCAD supports thickness for the TEXT entity only for \fI\&.shx\fP fonts and not for true type fonts. .INDENT 0.0 .INDENT 3.5 .sp .EX # thickness for text works only with shx fonts not with true type fonts doc.styles.new(\(aqTXT\(aq, dxfattribs={\(aqfont\(aq: \(aqromans.shx\(aq}) ucs = UCS(origin=(0, 2, 2)).rotate_local_x(math.radians(\-45)) text = msp.add_text( text=\(dqTEXT\(dq, dxfattribs={ # text rotation angle in degrees in UCS \(aqrotation\(aq: \-45, \(aqthickness\(aq: .333, \(aqcolor\(aq: 1, \(aqstyle\(aq: \(aqTXT\(aq, } ) # set text position in UCS text.set_pos((0, 0, 0), align=\(aqMIDDLE_CENTER\(aq) text.transform(ucs.matrix) .EE .UNINDENT .UNINDENT [image: text in ucs as top view] [image] [image: text in ucs as front view] [image] .SS Placing 2D Arc in 3D Space .sp Same as for the text example, OCS angle transformation can be ignored: .INDENT 0.0 .INDENT 3.5 .sp .EX ucs = UCS(origin=(0, 2, 2)).rotate_local_x(math.radians(\-45)) CENTER = (0, 0) START_ANGLE = 45 END_ANGLE = 270 msp.add_arc( center=CENTER, radius=1, start_angle=START_ANGLE, end_angle=END_ANGLE, dxfattribs={\(aqcolor\(aq: 6}, ).transform(ucs.matrix) msp.add_line( start=CENTER, end=Vec3.from_deg_angle(START_ANGLE), dxfattribs={\(aqcolor\(aq: 6}, ).transform(ucs.matrix) msp.add_line( start=CENTER, end=Vec3.from_deg_angle(END_ANGLE), dxfattribs={\(aqcolor\(aq: 6}, ).transform(ucs.matrix) .EE .UNINDENT .UNINDENT [image: arc in ucs as top view] [image] [image: arc in ucs as front view] [image] .SS Placing Block References in 3D Space .sp Despite the fact that block references (INSERT) can contain true 3D entities like LINE or MESH, the INSERT entity uses the same placing principe as TEXT or ARC shown in the previous sections. .sp To rotate the block reference 15 degrees around the WCS x\-axis, we place the block reference in the origin of the UCS, and rotate the UCS 90 degrees around its local y\-axis, to align the UCS z\-axis with the WCS x\-axis: .sp This is just an excerpt of the important parts, see the whole code of \fI\%insert.py\fP at github. .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new(\(aqR2010\(aq, setup=True) blk = doc.blocks.new(\(aqCSYS\(aq) setup_csys(blk) msp = doc.modelspace() ucs = UCS().rotate_local_y(angle=math.radians(90)) msp.add_blockref( \(aqCSYS\(aq, insert=(0, 0), # rotation around the block z\-axis (= WCS x\-axis) dxfattribs={\(aqrotation\(aq: 15}, ).transform(ucs.matrix) .EE .UNINDENT .UNINDENT [image] [image] .sp A more simple approach is to ignore the \fBrotate\fP attribute at all and just rotate the UCS. To rotate a block reference around any axis rather than the block z\-axis, rotate the UCS into the desired position. The following example rotates the block reference around the block x\-axis by 15 degrees: .INDENT 0.0 .INDENT 3.5 .sp .EX ucs = UCS(origin=(1, 2, 0)).rotate_local_x(math.radians(15)) blockref = msp.add_blockref(\(aqCSYS\(aq, insert=(0, 0, 0)) blockref.transform(ucs.matrix) .EE .UNINDENT .UNINDENT [image] [image] .sp The next example shows how to translate a block references with an already established OCS: .INDENT 0.0 .INDENT 3.5 .sp .EX # New UCS at the translated location, axis aligned to the WCS ucs = UCS((\-3, \-1, 1)) # Transform an already placed block reference, including # the transformation of the established OCS. blockref.transform(ucs.matrix) .EE .UNINDENT .UNINDENT [image] [image] .sp The next operation is to rotate a block reference with an established OCS, rotation axis is the block y\-axis, rotation angle is \-90 degrees. The idea is to create an UCS in the origin of the already placed block reference, UCS axis aligned to the block axis and resetting the block reference parameters for a new WCS transformation. .INDENT 0.0 .INDENT 3.5 .sp .EX # Get UCS at the block reference insert location, UCS axis aligned # to the block axis. ucs = blockref.ucs() # Rotate UCS around the local y\-axis. ucs = ucs.rotate_local_y(math.radians(\-90)) .EE .UNINDENT .UNINDENT .sp Reset block reference parameters, this places the block reference in the UCS origin and aligns the block axis to the UCS axis, now we do a new transformation from UCS to WCS: .INDENT 0.0 .INDENT 3.5 .sp .EX # Reset block reference parameters to place block reference in # UCS origin, without any rotation and OCS. blockref.reset_transformation() # Transform block reference from UCS to WCS blockref.transform(ucs.matrix) .EE .UNINDENT .UNINDENT [image] [image] .SS Tutorial for Linear Dimensions .sp The \fI\%Dimension\fP entity is the generic entity for all dimension types, but unfortunately AutoCAD is \fBnot willing\fP to show a dimension line defined only by this dimension entity, it also needs an anonymous block which contains the dimension line shape constructed by DXF primitives like LINE and TEXT entities, this representation is called the dimension line \fIrendering\fP in this documentation, beside the fact that this is not a real graphical rendering. BricsCAD is a much more friendly CAD application, which do show the dimension entity without the graphical rendering as block, which was very useful for testing, because there is no documentation how to apply all the dimension style variables (more than 80). This seems to be the reason why dimension lines are rendered so differently by many CAD application. .sp Don’t expect to get the same rendering results by \fIezdxf\fP as you get from AutoCAD. \fIEzdxf\fP tries to be as close to the results rendered by BricsCAD, but it is not possible to implement all the various combinations of dimension style parameters, which often affect one another. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .sp Text rendering is another problem, because \fIezdxf\fP has no real rendering engine. Some font properties, like the real text width, which is only available to \fIezdxf\fP if the \fIMatplotlib\fP package is installed and this value may also vary slightly for different CAD applications. Without access to the \fIMatplotlib\fP package the text properties in \fIezdxf\fP are based on an abstract monospaced font and are bigger than required by true type fonts. .sp Not all DIMENSION and DIMSTYLE features are supported by all DXF versions, especially DXF R12 does not support many features, but in this case the required rendering of dimension lines is an advantage, because if the application just shows the rendered block, all features which can be used in DXF R12 will be displayed, but these features will disappear if the dimension line will be edited in the CAD application. \fIEzdxf\fP writes only the supported DIMVARS of the used DXF version to avoid invalid DXF files. So it is not that critical to know all the supported features of a DXF version, except for limits and tolerances, \fIezdxf\fP uses the advanced features of the MTEXT entity to create limits and tolerances and therefore they are not supported (displayed) in DXF R12 files. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Graphical reference of many DIMVARS and some advanced information: \fI\%DIMSTYLE Table\fP .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 The Script \fI\%dimension_linear.py\fP shows examples for linear dimensions. .UNINDENT .UNINDENT .UNINDENT .SS Horizontal Dimension .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # Create a DXF R2010 document: # Use argument setup=True to setup the default dimension styles. doc = ezdxf.new(\(dqR2010\(dq, setup=True) # Add new dimension entities to the modelspace: msp = doc.modelspace() # Add a LINE entity for visualization, not required to create the DIMENSION # entity: msp.add_line((0, 0), (3, 0)) # Add a horizontal linear DIMENSION entity: dim = msp.add_linear_dim( base=(3, 2), # location of the dimension line p1=(0, 0), # 1st measurement point p2=(3, 0), # 2nd measurement point dimstyle=\(dqEZDXF\(dq, # default dimension style ) # Necessary second step to create the BLOCK entity with the dimension geometry. # Additional processing of the DIMENSION entity could happen between adding # the entity and the rendering call. dim.render() doc.saveas(\(dqdim_linear_horiz.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp The example above creates a horizontal \fI\%Dimension\fP entity. The default dimension style “EZDXF” is defined as: .INDENT 0.0 .IP \(bu 2 1 drawing unit = 1m .IP \(bu 2 measurement text height = 0.25 (drawing scale = 1:100) .IP \(bu 2 the length factor \fBdimlfac\fP = 100, which creates a measurement text in cm. .IP \(bu 2 arrow is “ARCHTICK”, arrow size \fBdimasz\fP = 0.175 .UNINDENT .sp Every dimension style which does not exist will be replaced by the dimension style “Standard” at DXF export by \fBsave()\fP or \fBsaveas()\fP (e.g. dimension style setup was not initiated). .sp The \fIbase\fP point defines the location of the dimension line, \fIezdxf\fP accepts any point on the dimension line, the point \fIp1\fP defines the start point of the first extension line, which also defines the first measurement point and the point \fIp2\fP defines the start point of the second extension line, which also defines the second measurement point. .sp The return value \fIdim\fP is \fBnot\fP a dimension entity, instead a \fI\%DimStyleOverride\fP object is returned, the dimension entity is stored as attribute \fBdim.dimension\fP\&. .SS Vertical and Rotated Dimension .sp Argument \fIangle\fP defines the angle of the dimension line in relation to the x\-axis of the WCS or UCS, measurement is the distance between first and second measurement point in direction of \fIangle\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX # assignment to dim is not necessary, if no additional processing happens msp.add_linear_dim(base=(3, 2), p1=(0, 0), p2=(3, 0), angle=\-30).render() doc.saveas(\(dqdim_linear_rotated.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp For a vertical dimension set argument \fIangle\fP to 90 degree, but in this example the vertical distance would be 0. .SS Aligned Dimension .sp An aligned dimension line is parallel to the line defined by the definition points \fIp1\fP and \fIp2\fP\&. The placement of the dimension line is defined by the argument \fIdistance\fP, which is the distance between the definition line and the dimension line. The \fIdistance\fP of the dimension line is orthogonal to the base line in counter clockwise orientation. .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_line((0, 2), (3, 0)) dim = msp.add_aligned_dim(p1=(0, 2), p2=(3, 0), distance=1) doc.saveas(\(dqdim_linear_aligned.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .SS Dimension Style Override .sp Many dimension styling options are defined by the associated \fI\%DimStyle\fP entity. But often you wanna change just a few settings without creating a new dimension style, therefore the DXF format has a protocol to store this changed settings in the dimension entity itself. This protocol is supported by \fIezdxf\fP and every factory function which creates dimension entities supports the \fIoverride\fP argument. This \fIoverride\fP argument is a simple Python dictionary (e.g. \fBoverride = {\(dqdimtad\(dq: 4}\fP, place measurement text below dimension line). .sp The overriding protocol is managed by the \fI\%DimStyleOverride\fP object, which is returned by the most dimension factory functions. .SS Placing Measurement Text .sp The default location of the measurement text depends on various \fI\%DimStyle\fP parameters and is applied if no user defined text location is defined. .SS Default Text Locations .sp “Horizontal direction” means in direction of the dimension line and “vertical direction” means perpendicular to the dimension line direction. .sp The \fB“horizontal”\fP location of the measurement text is defined by \fI\%dimjust\fP: .TS center; |l|l|. _ T{ 0 T} T{ Center of dimension line T} _ T{ 1 T} T{ Left side of the dimension line, near first extension line T} _ T{ 2 T} T{ Right side of the dimension line, near second extension line T} _ T{ 3 T} T{ Over first extension line T} _ T{ 4 T} T{ Over second extension line T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(0, 0), p2=(3, 0), override={\(dqdimjust\(dq: 1} ).render() .EE .UNINDENT .UNINDENT [image] .sp The \fB“vertical”\fP location of the measurement text relative to the dimension line is defined by \fI\%dimtad\fP: .TS center; |l|l|. _ T{ 0 T} T{ Center, it is possible to adjust the vertical location by \fI\%dimtvp\fP T} _ T{ 1 T} T{ Above T} _ T{ 2 T} T{ Outside, handled like \fIAbove\fP by \fIezdxf\fP T} _ T{ 3 T} T{ JIS, handled like \fIAbove\fP by \fIezdxf\fP T} _ T{ 4 T} T{ Below T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(0, 0), p2=(3, 0), override={\(dqdimtad\(dq: 4} ).render() .EE .UNINDENT .UNINDENT [image] .sp The distance between text and dimension line is defined by \fI\%dimgap\fP\&. .sp The \fI\%DimStyleOverride\fP object has a method \fI\%set_text_align()\fP to set the default text location in an easy way, this is also the reason for the 2 step creation process of dimension entities: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(0, 0), p2=(3, 0)) dim.set_text_align(halign=\(dqleft\(dq, valign=\(dqcenter\(dq) dim.render() .EE .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ halign T} T{ “left”, “right”, “center”, “above1”, “above2” T} _ T{ valign T} T{ “above”, “center”, “below” T} _ .TE .sp Run function \fBexample_for_all_text_placings_R2007()\fP in the example script \fI\%dimension_linear.py\fP to create a DXF file with all text placings supported by \fIezdxf\fP\&. .SS User Defined Text Locations .sp Beside the default location, it is possible to locate the measurement text freely. .SS Location Relative to Origin .sp The user defined text location can be set by the argument \fIlocation\fP in most dimension factory functions and always references the midpoint of the measurement text: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), location=(4, 4) ).render() .EE .UNINDENT .UNINDENT [image] .sp The \fIlocation\fP is relative to the origin of the active coordinate system or WCS if no UCS is defined in the \fI\%render()\fP method, the user defined \fIlocation\fP can also be set by \fI\%user_location_override()\fP\&. .SS Location Relative to Center of Dimension Line .sp The method \fI\%set_location()\fP has additional features for linear dimensions. Argument \fIleader\fP = \fBTrue\fP adds a simple leader from the measurement text to the center of the dimension line and argument \fIrelative\fP = \fBTrue\fP places the measurement text relative to the center of the dimension line. .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_location(location=(\-1, 1), leader=True, relative=True) dim.render() .EE .UNINDENT .UNINDENT [image] .SS Location Relative to Default Location .sp The method \fI\%shift_text()\fP shifts the measurement text away from the default text location. The shifting directions are aligned to the text direction, which is the direction of the dimension line in most cases, \fIdh\fP (for delta horizontal) shifts the text parallel to the text direction, \fIdv\fP (for delta vertical) shifts the text perpendicular to the text direction. This method does not support leaders. .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.shift_text(dh=1, dv=1) dim.render() .EE .UNINDENT .UNINDENT [image] .SS Overriding Text Rotation .sp All factory methods supporting the argument \fItext_rotation\fP can override the measurement text rotation. The user defined rotation is relative to the render UCS x\-axis (default is WCS). .SS Measurement Text Formatting and Styling .SS Text Properties .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimtxsty\fP T} T{ Specifies the text style of the dimension as \fI\%Textstyle\fP name. T} _ T{ \fBdimtxt\fP T} T{ Text height in drawing units. T} _ T{ \fBdimclrt\fP T} T{ Measurement text color as \fI\%AutoCAD Color Index (ACI)\fP\&. T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(dqdimtxsty\(dq: \(dqStandard\(dq, \(dqdimtxt\(dq: 0.35, \(dqdimclrt\(dq: 1, } ).render() .EE .UNINDENT .UNINDENT [image] .SS Background Filling .sp Background fillings are supported since DXF R2007, and \fIezdxf\fP uses the MTEXT entity to implement this feature, so setting background filling in DXF R12 has no effect. The DIMVAR \fI\%dimtfill\fP defines the kind of background filling and the DIMVAR \fI\%dimtfillclr\fP defines the fill color. .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimtfill\fP T} T{ Enables background filling if bigger than 0 T} _ T{ \fBdimtfillclr\fP T} T{ Fill color as \fI\%AutoCAD Color Index (ACI)\fP, if \fBdimtfill\fP is 2 T} _ .TE .TS center; |l|l|. _ T{ \fBdimtfill\fP T} T{ Description T} _ T{ 0 T} T{ disabled T} _ T{ 1 T} T{ canvas color T} _ T{ 2 T} T{ color defined by \fBdimtfillclr\fP T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(dqdimtfill\(dq: 2, \(dqdimtfillclr\(dq: 1, } ).render() .EE .UNINDENT .UNINDENT [image] .SS Text Formatting .INDENT 0.0 .IP \(bu 2 \fBdecimal places\fP: \fI\%dimdec\fP defines the number of decimal places displayed for the primary units of a dimension. (DXF R2000) .IP \(bu 2 \fBdecimal point character\fP: \fI\%dimdsep\fP defines the decimal point as ASCII code, get the ASCII code by \fBord(\(aq.\(aq)\fP .IP \(bu 2 \fBrounding\fP: \fI\%dimrnd\fP, rounds all dimensioning distances to the specified value, for instance, if \fBdimrnd\fP is set to 0.25, all distances round to the nearest 0.25 unit. If \fBdimrnd\fP is set to 1.0, all distances round to the nearest integer. For more information look at the documentation of the \fI\%ezdxf.math.xround()\fP function. .IP \(bu 2 \fBzero trimming\fP: \fI\%dimzin\fP, \fIezdxf\fP supports only a subset of values: .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 4 to suppress leading zeros .IP \(bu 2 8 to suppress trailing zeros .IP \(bu 2 12 as the combination of both .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 \fBmeasurement factor\fP: scale measurement by factor \fI\%dimlfac\fP, e.g. to get the dimensioning text in cm for a DXF file where 1 drawing unit represents 1m, set \fBdimlfac\fP to 100. .IP \(bu 2 \fBtext template\fP: \fI\%dimpost\fP, “<>” represents the measurement text, e.g. “~<>cm” produces “~300cm” for measurement in previous example. .UNINDENT .sp To set this values the \fI\%ezdxf.entities.DimStyle.set_text_format()\fP and \fI\%ezdxf.entities.DimStyleOverride.set_text_format()\fP methods are very recommended. .SS Overriding Measurement Text .sp This feature allows overriding the real measurement text by a custom measurement text, the text is stored as string in the \fI\%Dimension\fP entity as attribute \fI\%text\fP\&. Special values of the \fBtext\fP attribute are: one space “ “ to suppress the measurement text at all, an empty string “” or “<>” to display the real measurement. .sp All factory functions have an explicit \fItext\fP argument, which always replaces the \fItext\fP value in the \fIdxfattribs\fP dict. .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0), text=\(dq>1m\(dq).render() .EE .UNINDENT .UNINDENT [image] .SS Dimension Line Properties .sp The \fIdimension line color\fP is defined by the DIMVAR \fBdimclrd\fP as \fI\%AutoCAD Color Index (ACI)\fP, \fBdimclrd\fP and also defines the color of the arrows. The \fIlinetype\fP is defined by \fBdimltype\fP and requires DXF R2007. The \fIlineweight\fP is defined by \fBdimlwd\fP and requires DXF R2000, see also the \fI\%lineweight\fP reference for valid values. The \fBdimdle\fP is the extension of the dimension line beyond the extension lines, this dimension line extension is not supported for all arrows. .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimclrd\fP T} T{ dimension line and arrows color as \fI\%AutoCAD Color Index (ACI)\fP T} _ T{ \fBdimltype\fP T} T{ linetype of dimension line T} _ T{ \fBdimlwd\fP T} T{ line weight of dimension line T} _ T{ \fBdimdle\fP T} T{ extension of dimension line in drawing units T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(dqdimclrd\(dq: 1, # red \(dqdimdle\(dq: 0.25, \(dqdimltype\(dq: \(dqDASHED2\(dq, \(dqdimlwd\(dq: 35, # 0.35mm line weight } ).render() .EE .UNINDENT .UNINDENT [image] .sp \fI\%DimStyleOverride()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_dimline_format( color=1, linetype=\(dqDASHED2\(dq, lineweight=35, extension=0.25 ) dim.render() .EE .UNINDENT .UNINDENT .SS Extension Line Properties .sp The \fIextension line color\fP is defined by the DIMVAR \fBdimclre\fP as \fI\%AutoCAD Color Index (ACI)\fP\&. The \fIlinetype\fP for the first and the second extension line is defined by \fBdimltex1\fP and \fBdimltex2\fP and requires DXF R2007. The \fIlineweight\fP is defined by \fBdimlwe\fP and required DXF R2000, see also the \fI\%lineweight\fP reference for valid values. .sp The \fBdimexe\fP is the extension of the extension line beyond the dimension line, and \fBdimexo\fP defines the offset of the extension line from the measurement point. .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimclre\fP T} T{ extension line color as \fI\%AutoCAD Color Index (ACI)\fP T} _ T{ \fBdimltex1\fP T} T{ linetype of first extension line T} _ T{ \fBdimltex2\fP T} T{ linetype of second extension line T} _ T{ \fBdimlwe\fP T} T{ line weight of extension line T} _ T{ \fBdimexe\fP T} T{ extension beyond dimension line in drawing units T} _ T{ \fBdimexo\fP T} T{ offset of extension line from measurement point T} _ T{ \fBdimfxlon\fP T} T{ set to 1 to enable fixed length extension line T} _ T{ \fBdimfxl\fP T} T{ length of fixed length extension line in drawing units T} _ T{ \fBdimse1\fP T} T{ suppress first extension line if 1 T} _ T{ \fBdimse2\fP T} T{ suppress second extension line if 1 T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(dqdimclre\(dq: 1, # red \(dqdimltex1\(dq: \(dqDASHED2\(dq, \(dqdimltex2\(dq: \(dqCENTER2\(dq, \(dqdimlwe\(dq: 35, # 0.35mm line weight \(dqdimexe\(dq: 0.3, # length above dimension line \(dqdimexo\(dq: 0.1, # offset from measurement point } ).render() .EE .UNINDENT .UNINDENT [image] .sp \fI\%DimStyleOverride()\fP methods: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_extline_format(color=1, lineweight=35, extension=0.3, offset=0.1) dim.set_extline1(linetype=\(dqDASHED2\(dq) dim.set_extline2(linetype=\(dqCENTER2\(dq) dim.render() .EE .UNINDENT .UNINDENT .sp Fixed length extension lines are supported in DXF R2007, set \fBdimfxlon\fP to 1 and \fBdimfxl\fP defines the length of the extension line starting at the dimension line. .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(dqdimfxlon\(dq: 1, # fixed length extension lines \(dqdimexe\(dq: 0.2, # length above dimension line \(dqdimfxl\(dq: 0.4, # length below dimension line } ).render() .EE .UNINDENT .UNINDENT [image] .sp \fI\%DimStyleOverride()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_extline_format(extension=0.2, fixed_length=0.4) dim.render() .EE .UNINDENT .UNINDENT .sp To suppress extension lines set \fBdimse1\fP to 1 to suppress the first extension line and \fBdimse2\fP to 1 to suppress the second extension line. .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(dqdimse1\(dq: 1, # suppress first extension line \(dqdimse2\(dq: 1, # suppress second extension line \(dqdimblk\(dq: ezdxf.ARROWS.closed_filled, # arrows just looks better } ).render() .EE .UNINDENT .UNINDENT [image] .sp \fI\%DimStyleOverride()\fP methods: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_arrows(blk=ezdxf.ARROWS.closed_filled) dim.set_extline1(disable=True) dim.set_extline2(disable=True) dim.render() .EE .UNINDENT .UNINDENT .SS Arrows .sp “Arrows” mark then beginning and the end of a dimension line, and most of them do not look like arrows. .sp DXF distinguish between the simple tick (a slanted line) and arrows as blocks. .sp To use a simple tick as “arrow” set \fI\%dimtsz\fP to a value greater than 0, this also disables arrow blocks as side effect: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_tick(size=0.25) dim.render() .EE .UNINDENT .UNINDENT .sp \fIEzdxf\fP uses the “ARCHTICK” block at double size to render the tick (AutoCAD and BricsCad just draw a simple line), so there is no advantage of using the tick instead of an arrow. .sp Using arrows: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_arrow(blk=\(dqOPEN_30\(dq, size=0.25) dim.render() .EE .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimtsz\fP T} T{ tick size in drawing units, set to 0 to use arrows T} _ T{ \fBdimblk\fP T} T{ set both arrow block names at once T} _ T{ \fBdimblk1\fP T} T{ first arrow block name T} _ T{ \fBdimblk2\fP T} T{ second arrow block name T} _ T{ \fBdimasz\fP T} T{ arrow size in drawing units T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(dqdimtsz\(dq: 0, # set tick size to 0 to enable arrow usage \(dqdimasz\(dq: 0.25, # arrow size in drawing units \(dqdimblk\(dq: \(dqOPEN_30\(dq, # arrow block name } ).render() .EE .UNINDENT .UNINDENT .sp The dimension line extension (\fBdimdle\fP) works only for a few arrow blocks and the simple tick: .INDENT 0.0 .IP \(bu 2 “ARCHTICK” .IP \(bu 2 “OBLIQUE” .IP \(bu 2 “NONE” .IP \(bu 2 “SMALL” .IP \(bu 2 “DOTSMALL” .IP \(bu 2 “INTEGRAL” .UNINDENT .SS Arrow Shapes [image] .SS Arrow Names .sp The arrow names are stored as attributes in the \fBezdxf.ARROWS\fP object. .TS center; |l|l|. _ T{ closed_filled T} T{ “” (empty string) T} _ T{ dot T} T{ “DOT” T} _ T{ dot_small T} T{ “DOTSMALL” T} _ T{ dot_blank T} T{ “DOTBLANK” T} _ T{ origin_indicator T} T{ “ORIGIN” T} _ T{ origin_indicator_2 T} T{ “ORIGIN2” T} _ T{ open T} T{ “OPEN” T} _ T{ right_angle T} T{ “OPEN90” T} _ T{ open_30 T} T{ “OPEN30” T} _ T{ closed T} T{ “CLOSED” T} _ T{ dot_smallblank T} T{ “SMALL” T} _ T{ none T} T{ “NONE” T} _ T{ oblique T} T{ “OBLIQUE” T} _ T{ box_filled T} T{ “BOXFILLED” T} _ T{ box T} T{ “BOXBLANK” T} _ T{ closed_blank T} T{ “CLOSEDBLANK” T} _ T{ datum_triangle_filled T} T{ “DATUMFILLED” T} _ T{ datum_triangle T} T{ “DATUMBLANK” T} _ T{ integral T} T{ “INTEGRAL” T} _ T{ architectural_tick T} T{ “ARCHTICK” T} _ T{ ez_arrow T} T{ “EZ_ARROW” T} _ T{ ez_arrow_blank T} T{ “EZ_ARROW_BLANK” T} _ T{ ez_arrow_filled T} T{ “EZ_ARROW_FILLED” T} _ .TE .SS Tolerances and Limits .sp The tolerances and limits features are implemented by using inline codes for the \fI\%MText\fP entity, therefore DXF R2000 is required. It is not possible to use both tolerances and limits at the same time. .SS Tolerances .sp Geometrical tolerances are shown as additional text appended to the measurement text. It is recommend to use \fI\%set_tolerance()\fP method in \fI\%DimStyleOverride\fP or \fI\%DimStyle\fP\&. .sp The attribute \fBdimtp\fP defines the upper tolerance value, \fBdimtm\fP defines the lower tolerance value if present, else the lower tolerance value is the same as the upper tolerance value. Tolerance values are shown as given! .sp Same upper and lower tolerance value: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(0, 3), p1=(3, 0), p2=(6.5, 0)) dim.set_tolerance(.1, hfactor=.4, align=\(dqtop\(dq, dec=2) dim.render() .EE .UNINDENT .UNINDENT [image] .sp Different upper and lower tolerance values: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(0, 3), p1=(3, 0), p2=(6.5, 0)) dim.set_tolerance(upper=.1, lower=.15, hfactor=.4, align=\(dqmiddle\(dq, dec=2) dim.render() .EE .UNINDENT .UNINDENT [image] .sp The attribute \fBdimtfac\fP specifies a scale factor for the text height of limits and tolerance values relative to the dimension text height, as set by \fBdimtxt\fP\&. For example, if \fBdimtfac\fP is set to 1.0, the text height of fractions and tolerances is the same height as the dimension text. If \fBdimtxt\fP is set to 0.75, the text height of limits and tolerances is three\-quarters the size of dimension text. .sp Vertical justification for tolerances is specified by \fBdimtolj\fP: .TS center; |l|l|. _ T{ \fBdimtolj\fP T} T{ Description T} _ T{ 0 T} T{ Align with bottom line of dimension text T} _ T{ 1 T} T{ Align vertical centered to dimension text T} _ T{ 2 T} T{ Align with top line of dimension text T} _ .TE .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimtol\fP T} T{ set to 1 to enable tolerances T} _ T{ \fBdimtp\fP T} T{ set the maximum (or upper) tolerance limit for dimension text T} _ T{ \fBdimtm\fP T} T{ set the minimum (or lower) tolerance limit for dimension text T} _ T{ \fBdimtfac\fP T} T{ specifies a scale factor for the text height of limits and tolerance values relative to the dimension text height, as set by \fBdimtxt\fP\&. T} _ T{ \fBdimtzin\fP T} T{ 4 to suppress leading zeros, 8 to suppress trailing zeros or 12 to suppress both, like \fBdimzin\fP for dimension text, see also \fI\%Text Formatting\fP T} _ T{ \fBdimtolj\fP T} T{ set the vertical justification for tolerance values relative to the nominal dimension text. T} _ T{ \fBdimtdec\fP T} T{ set the number of decimal places to display in tolerance values T} _ .TE .SS Limits .sp The geometrical limits are shown as upper and lower measurement limit and replaces the usual measurement text. It is recommend to use \fI\%set_limits()\fP method in \fI\%DimStyleOverride\fP or \fI\%DimStyle\fP\&. .sp For limits the tolerance values are drawing units scaled by measurement factor \fBdimlfac\fP, the upper limit is scaled measurement value + \fBdimtp\fP and the lower limit is scaled measurement value \- \fBdimtm\fP\&. .sp The attributes \fBdimtfac\fP, \fBdimtzin\fP and \fBdimtdec\fP have the same meaning for limits as for tolerances. .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_linear_dim(base=(0, 3), p1=(3, 0), p2=(6.5, 0)) dim.set_limits(upper=.1, lower=.15, hfactor=.4, dec=2) dim.render() .EE .UNINDENT .UNINDENT [image] .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimlim\fP T} T{ set to 1 to enable limits T} _ .TE .SS Alternative Units .sp Alternative units are not supported. .SS Tutorial for Radius Dimensions .sp Please read the \fI\%Tutorial for Linear Dimensions\fP before, if you haven’t. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # DXF R2010 drawing, official DXF version name: \(aqAC1024\(aq, # setup=True setups the default dimension styles doc = ezdxf.new(\(dqR2010\(dq, setup=True) msp = doc.modelspace() # add new dimension entities to the modelspace msp.add_circle((0, 0), radius=3) # add a CIRCLE entity, not required # add default radius dimension, measurement text is located outside dim = msp.add_radius_dim( center=(0, 0), radius=3, angle=45, dimstyle=\(dqEZ_RADIUS\(dq ) # necessary second step, to create the BLOCK entity with the dimension geometry. dim.render() doc.saveas(\(dqradius_dimension.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The example above creates a 45 degrees slanted radius \fI\%Dimension\fP entity, the default dimension style “EZ_RADIUS” is defined as 1 drawing unit = 1m, drawing scale = 1:100 and the length factor = 100, which creates a measurement text in cm, the default location for the measurement text is outside of the circle. .sp The \fIcenter\fP point defines the center of the circle but there doesn’t have to exist a circle entity, \fIradius\fP defines the circle radius, which is also the measurement, and angle defines the slope of the dimension line, it is also possible to define the circle by a measurement point \fImpoint\fP on the circle. .sp The return value \fIdim\fP is \fBnot\fP a dimension entity, instead a \fI\%DimStyleOverride\fP object is returned, the dimension entity is stored as \fBdim.dimension\fP\&. .SS Placing Measurement Text .sp There are different predefined DIMSTYLES to achieve various text placing locations. .sp The basic DIMSTYLE “EZ_RADIUS” settings are: .INDENT 0.0 .IP \(bu 2 1 drawing unit = 1m .IP \(bu 2 scale 1:100 .IP \(bu 2 the length factor \fBdimlfac\fP = 100, which creates a measurement text in cm. .IP \(bu 2 uses a closed filled arrow, arrow size \fBdimasz\fP = 0.25 .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Not all possibles features of DIMSTYLE are supported by the \fIezdxf\fP rendering procedure and especially for the radial dimension there are less features implemented than for the linear dimension because of the lack of good documentation. .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Graphical reference of many DIMVARS and some advanced information: \fI\%DIMSTYLE Table\fP .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 The Script \fI\%dimension_radius.py\fP shows examples for radius dimensions. .UNINDENT .UNINDENT .UNINDENT .SS Default Text Locations Outside .sp Advanced “EZ_RADIUS” settings for placing the text outside of the circle: .TS center; |l|l|. _ T{ tmove T} T{ 1 = add a leader when dimension text is moved, this is the best setting for text outside to preserve the appearance of the DIMENSION entity, if editing afterwards in a CAD application. T} _ T{ dimtad T} T{ 1 = place the text vertical above the dimension line T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS\(dq ) dim.render() # always required, but not shown in the following examples .EE .UNINDENT .UNINDENT [image] .sp To force text outside horizontal set \fI\%dimtoh\fP to 1: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS\(dq, override={\(dqdimtoh\(dq: 1} ) .EE .UNINDENT .UNINDENT [image] .SS Default Text Locations Inside .sp DIMSTYLE “EZ_RADIUS_INSIDE” can be used to place the dimension text inside the circle at a default location. .sp The basic DIMSTYLE “EZ_RADIUS_INSIDE” settings are: .INDENT 0.0 .IP \(bu 2 1 drawing unit = 1m .IP \(bu 2 scale 1:100, length_factor is 100 which creates .IP \(bu 2 the length factor \fBdimlfac\fP = 100, which creates a measurement text in cm. .IP \(bu 2 uses a closed filled arrow, arrow size \fBdimasz\fP = 0.25 .UNINDENT .sp Advanced “EZ_RADIUS_INSIDE” settings to place (force) the text inside of the circle: .TS center; |l|l|. _ T{ tmove T} T{ 0 = moves the dimension line with dimension text, this is the best setting for text inside to preserve the appearance of the DIMENSION entity, if editing afterwards in a CAD application. T} _ T{ dimtix T} T{ 1 = force text inside T} _ T{ dimatfit T} T{ 0 = force text inside, required by BricsCAD and AutoCAD T} _ T{ dimtad T} T{ 0 = center text vertical, BricsCAD and AutoCAD always create a vertical centered text, \fIezdxf\fP let you choose the vertical placement (above, below, center), but editing the DIMENSION in BricsCAD or AutoCAD will reset text to center placement. T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS_INSIDE\(dq ) .EE .UNINDENT .UNINDENT [image] [image] .sp To force text inside horizontal set \fI\%dimtih\fP to 1: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS_INSIDE\(dq, override={\(dqdimtih\(dq: 1} ) .EE .UNINDENT .UNINDENT [image] .SS User Defined Text Locations .sp Beside the default location it is always possible to override the text location by a user defined location. This location also determines the angle of the dimension line and overrides the argument \fIangle\fP\&. For user defined locations it is not necessary to force text inside (\fBdimtix=1\fP), because the location of the text is explicit given, therefore the DIMSTYLE “EZ_RADIUS” can be used for all this examples. .sp User defined location outside of the circle: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, location=(4, 4), dimstyle=\(dqEZ_RADIUS\(dq ) .EE .UNINDENT .UNINDENT [image] .sp User defined location outside of the circle and forced horizontal text: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, location=(4, 4), dimstyle=\(dqEZ_RADIUS\(dq, override={\(dqdimtoh\(dq: 1} ) .EE .UNINDENT .UNINDENT [image] .sp User defined location inside of the circle: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, location=(1, 1), dimstyle=\(dqEZ_RADIUS\(dq ) .EE .UNINDENT .UNINDENT [image] [image] .sp User defined location inside of the circle and forced horizontal text: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, location=(1, 1), dimstyle=\(dqEZ_RADIUS\(dq, override={\(dqdimtih\(dq: 1}, ) .EE .UNINDENT .UNINDENT [image] .SS Center Mark/Lines .sp Center mark/lines are controlled by \fI\%dimcen\fP, default value is 0 for predefined dimstyles “EZ_RADIUS” and “EZ_RADIUS_INSIDE”: .TS center; |l|l|. _ T{ 0 T} T{ Center mark is off T} _ T{ >0 T} T{ Create center mark of given size T} _ T{ <0 T} T{ Create center lines T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_radius_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS\(dq, override={\(dqdimcen\(dq: 0.25}, ) .EE .UNINDENT .UNINDENT [image] .SS Overriding Measurement Text .sp See Linear Dimension Tutorial: \fI\%Overriding Measurement Text\fP .SS Measurement Text Formatting and Styling .sp See Linear Dimension Tutorial: \fI\%Measurement Text Formatting and Styling\fP .SS Tutorial for Diameter Dimensions .sp Please read the \fI\%Tutorial for Radius Dimensions\fP before, if you haven’t. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .sp This is a repetition of the radius tutorial, just with diameter dimensions. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # setup=True setups the default dimension styles doc = ezdxf.new(\(dqR2010\(dq, setup=True) msp = doc.modelspace() # add new dimension entities to the modelspace msp.add_circle((0, 0), radius=3) # add a CIRCLE entity, not required # add default diameter dimension, measurement text is located outside dim = msp.add_diameter_dim( center=(0, 0), radius=3, angle=45, dimstyle=\(dqEZ_RADIUS\(dq ) dim.render() doc.saveas(\(dqdiameter_dimension.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The example above creates a 45 degrees slanted diameter \fI\%Dimension\fP entity, the default dimension style “EZ_RADIUS” (same as for radius dimensions) is defined as 1 drawing unit = 1m, drawing scale = 1:100 and the length factor = 100, which creates a measurement text in cm, the default location for the measurement text is outside of the circle. .sp The \fIcenter\fP point defines the center of the circle but there doesn’t have to exist a circle entity, \fIradius\fP defines the circle radius and \fIangle\fP defines the slope of the dimension line, it is also possible to define the circle by a measurement point \fImpoint\fP on the circle. .sp The return value \fIdim\fP is \fBnot\fP a dimension entity, instead a \fI\%DimStyleOverride\fP object is returned, the dimension entity is stored as \fIdim.dimension\fP\&. .SS Placing Measurement Text .sp There are different predefined DIMSTYLES to achieve various text placing locations. .sp The basic DIMSTYLE “EZ_RADIUS” settings are: .INDENT 0.0 .IP \(bu 2 1 drawing unit = 1m .IP \(bu 2 scale 1:100 .IP \(bu 2 the length factor \fBdimlfac\fP = 100, which creates a measurement text in cm. .IP \(bu 2 uses a closed filled arrow, arrow size \fBdimasz\fP = 0.25 .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Not all possibles features of DIMSTYLE are supported by the \fIezdxf\fP rendering procedure and especially for the diameter dimension there are less features implemented than for the linear dimension because of the lack of good documentation. .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Graphical reference of many DIMVARS and some advanced information: \fI\%DIMSTYLE Table\fP .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 The Script \fI\%dimension_diameter.py\fP shows examples for radius dimensions. .UNINDENT .UNINDENT .UNINDENT .SS Default Text Locations Outside .sp “EZ_RADIUS” default settings for to place text outside: .TS center; |l|l|. _ T{ tmove T} T{ 1 = add a leader when dimension text is moved, this is the best setting for text outside to preserve the appearance of the DIMENSION entity, if editing afterwards in a CAD application. T} _ T{ dimtad T} T{ 1 = place the text vertical above the dimension line T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_diameter_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS\(dq ) dim.render() # always required, but not shown in the following examples .EE .UNINDENT .UNINDENT [image] .sp To force text outside horizontal set \fI\%dimtoh\fP to 1: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_diameter_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS\(dq, override={\(dqdimtoh\(dq: 1} ) .EE .UNINDENT .UNINDENT [image] .SS Default Text Locations Inside .sp DIMSTYLE “EZ_RADIUS_INSIDE” can be used to place the dimension text inside the circle at a default location. .sp The basic DIMSTYLE settings are: .INDENT 0.0 .IP \(bu 2 1 drawing unit = 1m .IP \(bu 2 scale 1:100, length_factor is 100 which creates .IP \(bu 2 the length factor \fBdimlfac\fP = 100, which creates a measurement text in cm. .IP \(bu 2 uses a closed filled arrow, arrow size \fBdimasz\fP = 0.25 .UNINDENT .sp Advanced “EZ_RADIUS_INSIDE” settings to place (force) the text inside of the circle: .TS center; |l|l|. _ T{ tmove T} T{ 0 = moves the dimension line with dimension text, this is the best setting for text inside to preserve the appearance of the DIMENSION entity, if editing afterwards in a CAD application. T} _ T{ dimtix T} T{ 1 = force text inside T} _ T{ dimatfit T} T{ 0 = force text inside, required by BricsCAD and AutoCAD T} _ T{ dimtad T} T{ 0 = center text vertical, BricsCAD and AutoCAD always create a vertical centered text, \fIezdxf\fP let you choose the vertical placement (above, below, center), but editing the DIMENSION in BricsCAD or AutoCAD will reset text to center placement. T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_diameter_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS_INSIDE\(dq ) .EE .UNINDENT .UNINDENT [image] .sp To force text inside horizontal set \fI\%dimtih\fP to 1: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_diameter_dim( center=(0, 0), radius=2.5, angle=45, dimstyle=\(dqEZ_RADIUS_INSIDE\(dq, override={\(dqdimtih\(dq: 1} ) .EE .UNINDENT .UNINDENT [image] .SS User Defined Text Locations .sp Beside the default location it is always possible to override the text location by a user defined location. This location also determines the angle of the dimension line and overrides the argument \fIangle\fP\&. For user defined locations it is not necessary to force text inside (\fBdimtix=1\fP), because the location of the text is explicit given, therefore the DIMSTYLE “EZ_RADIUS” can be used for all this examples. .sp User defined location outside of the circle: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_diameter_dim( center=(0, 0), radius=2.5, location=(4, 4), dimstyle=\(dqEZ_RADIUS\(dq ) .EE .UNINDENT .UNINDENT [image] .sp User defined location outside of the circle and forced horizontal text: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_diameter_dim( center=(0, 0), radius=2.5, location=(4, 4), dimstyle=\(dqEZ_RADIUS\(dq, override={\(dqdimtoh\(dq: 1} ) .EE .UNINDENT .UNINDENT [image] .sp User defined location inside of the circle: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_diameter_dim( center=(0, 0), radius=2.5, location=(1, 1), dimstyle=\(dqEZ_RADIUS\(dq ) .EE .UNINDENT .UNINDENT [image] .sp User defined location inside of the circle and forced horizontal text: .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_diameter_dim( center=(0, 0), radius=2.5, location=(1, 1), dimstyle=\(dqEZ_RADIUS\(dq, override={\(dqdimtih\(dq: 1}, ) .EE .UNINDENT .UNINDENT [image] .SS Center Mark/Lines .sp See Radius Dimension Tutorial: \fI\%Center Mark/Lines\fP .SS Overriding Measurement Text .sp See Linear Dimension Tutorial: \fI\%Overriding Measurement Text\fP .SS Measurement Text Formatting and Styling .sp See Linear Dimension Tutorial: \fI\%Measurement Text Formatting and Styling\fP .SS Tutorial for Angular Dimensions .sp Please read the \fI\%Tutorial for Linear Dimensions\fP before, if you haven’t. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .SS Dimension Style “EZ_CURVED” .sp All factory methods to create angular dimensions uses the dimension style “EZ_CURVED” for curved dimension lines which is defined as: .INDENT 0.0 .IP \(bu 2 angle unit is decimal degrees, \fBdimaunit\fP = 0 .IP \(bu 2 measurement text height = 0.25 (drawing scale = 1:100) .IP \(bu 2 measurement text location is above the dimension line .IP \(bu 2 closed filled arrow and arrow size \fBdimasz\fP = 0.25 .IP \(bu 2 \fBdimazin\fP = 2, suppresses trailing zeros (e.g. 12.5000 becomes 12.5) .UNINDENT .sp This DIMENSION style only exist if the argument \fIsetup\fP is \fBTrue\fP for creating a new DXF document by \fI\%ezdxf.new()\fP\&. Every dimension style which does not exist will be replaced by the dimension style “Standard” at DXF export by \fBsave()\fP or \fBsaveas()\fP (e.g. dimension style setup was not initiated). .sp Add all \fIezdxf\fP specific resources (line types, text\- and dimension styles) to an existing DXF document: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.tools.standards import setup_drawing doc = ezdxf.readfile(\(dqyour.dxf\(dq) setup_drawing(doc, topics=\(dqall\(dq) .EE .UNINDENT .UNINDENT .SS Factory Methods to Create Angular Dimensions .SS Defined by Center, Radius and Angles .sp The first example shows an angular dimension defined by the center point, radius, start\- and end angles: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # Create a DXF R2010 document: # Use argument setup=True to setup the default dimension styles. doc = ezdxf.new(\(dqR2010\(dq, setup=True) # Add new entities to the modelspace: msp = doc.modelspace() # Add an angular DIMENSION defined by the center point, start\- and end angles, # the measurement text is placed at the default location above the dimension # line: dim = msp.add_angular_dim_cra( center=(5, 5), # center point of the angle radius= 7, # distance from center point to the start of the extension lines start_angle=60, # start angle in degrees end_angle=120, # end angle in degrees distance=3, # distance from start of the extension lines to the dimension line dimstyle=\(dqEZ_CURVED\(dq, # default angular dimension style ) # Necessary second step to create the BLOCK entity with the dimension geometry. # Additional processing of the DIMENSION entity could happen between adding # the entity and the rendering call. dim.render() doc.saveas(\(dqangular_dimension_cra.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The return value \fIdim\fP is \fBnot\fP a dimension entity, instead a \fI\%DimStyleOverride\fP object is returned, the dimension entity is stored as \fBdim.dimension\fP\&. [image] .SS Angle by 2 Lines .sp The next example shows an angular dimension for an angle defined by two lines: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(setup=True) msp = doc.modelspace() # Setup the geometric parameters for the DIMENSION entity: base = (5.8833, \-6.3408) # location of the dimension line p1 = (2.0101, \-7.5156) # start point of 1st leg p2 = (2.7865, \-10.4133) # end point of 1st leg p3 = (6.7054, \-7.5156) # start point of 2nd leg p4 = (5.9289, \-10.4133) # end point of 2nd leg # Draw the lines for visualization, not required to create the # DIMENSION entity: msp.add_line(p1, p2) msp.add_line(p3, p4) # Add an angular DIMENSION defined by two lines, the measurement text is # placed at the default location above the dimension line: dim = msp.add_angular_dim_2l( base=base, # defines the location of the dimension line line1=(p1, p2), # start leg of the angle line2=(p3, p4), # end leg of the angle dimstyle=\(dqEZ_CURVED\(dq, # default angular dimension style ) # Necessary second step to create the dimension line geometry: dim.render() doc.saveas(\(dqangular_dimension_2l.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The example above creates an angular \fI\%Dimension\fP entity to measures the angle between two lines (\fIline1\fP and \fIline2\fP). .sp The \fIbase\fP point defines the location of the dimension line (arc), any point on the dimension line is valid. The points \fIp1\fP and \fIp2\fP define the first leg of the angle, \fIp1\fP also defines the start point of the first extension line. The points \fIp3\fP and \fIp4\fP define the second leg of the angle and point \fIp3\fP also defines the start point of the second extension line. .sp The measurement of the DIMENSION entity is the angle enclosed by the first and the second leg and where the dimension line passes the \fIbase\fP point. [image] .SS Angle by 3 Points .sp The next example shows an angular dimension defined by three points, a center point and the two end points of the angle legs: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(setup=True) msp = doc.modelspace() msp.add_angular_dim_3p( base=(0, 7), # location of the dimension line center=(0, 0), # center point p1=(\-3, 5), # end point of 1st leg = start angle p2=(3, 5), # end point of 2nd leg = end angle ).render() .EE .UNINDENT .UNINDENT [image] .SS Angle from ConstructionArc .sp The \fI\%ezdxf.math.ConstructionArc\fP provides various class methods for creating arcs and the construction tool can be created from an ARC entity. .sp Add an angular dimension to an ARC entity: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(setup=True) msp = doc.modelspace() arc = msp.add_arc( center=(0, 0), radius=5, start_angle = 60, end_angle = 120, ) msp.add_angular_dim_arc( arc.construction_tool(), distance=2, ).render() .EE .UNINDENT .UNINDENT [image] .SS Placing Measurement Text .sp The default location of the measurement text depends on various \fI\%DimStyle\fP parameters and is applied if no user defined text location is defined. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Not all possibles features of DIMSTYLE are supported by the \fIezdxf\fP rendering procedure and especially for the angular dimension there are less features implemented than for the linear dimension because of the lack of good documentation. .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Graphical reference of many DIMVARS and some advanced information: \fI\%DIMSTYLE Table\fP .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 The Script \fI\%dimension_angular.py\fP shows examples for angular dimensions. .UNINDENT .UNINDENT .UNINDENT .SS Default Text Locations .sp The DIMSTYLE “EZ_CURVED” places the measurement text in the center of the angle above the dimension line. The first examples above show the measurement text at the default text location. .sp The text direction angle is always perpendicular to the line from the text center to the center point of the angle unless this angle is manually overridden. .sp The \fB“vertical”\fP location of the measurement text relative to the dimension line is defined by \fI\%dimtad\fP: .TS center; |l|l|. _ T{ 0 T} T{ Center, it is possible to adjust the vertical location by \fI\%dimtvp\fP T} _ T{ 1 T} T{ Above T} _ T{ 2 T} T{ Outside, handled like \fIAbove\fP by \fIezdxf\fP T} _ T{ 3 T} T{ JIS, handled like \fIAbove\fP by \fIezdxf\fP T} _ T{ 4 T} T{ Below T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_angular_dim_cra( center=(3, 3), radius=3, distance=1, start_angle=60, end_angle=120, override={ \(dqdimtad\(dq: 1, # 0=center; 1=above; 4=below; }, ).render() .EE .UNINDENT .UNINDENT [image] .sp Arrows and measurement text are placed “outside” automatically if the available space between the extension lines isn’t sufficient. This overrides the \fBdimtad\fP value by 1 (“above”). \fIEzdxf\fP follows its own rules, ignores the \fI\%dimatfit\fP attribute and works similar to \fBdimatfit\fP = 1, move arrows first, then text: [image] .SS Shift Text From Default Location .sp The method \fBshift_text()\fP shifts the measurement text away from the default location. The shifting direction is aligned to the text rotation of the default measurement text. .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_angular_dim_cra( center=(3, 3), radius=3, distance=1, start_angle=60, end_angle=120, ) # shift text from default text location: dim.shift_text(0.5, 1.0) dim.render() .EE .UNINDENT .UNINDENT [image] .sp This is just a rendering effect, editing the dimension line in a CAD application resets the text to the default location. .SS User Defined Text Locations .sp Beside the default location it is always possible to override the text location by a user defined location. .sp The coordinates of user locations are located in the rendering UCS and the default rendering UCS is the \fI\%WCS\fP\&. .SS Absolute User Location .sp Absolute placing of the measurement text means relative to the origin of the render UCS. The user location is stored in the DIMENSION entity, which means editing the dimension line in a CAD application does not alter the text location. This location also determines the rotation of the measurement text. .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_angular_dim_cra( center=(3, 3), radius=3, distance=1, start_angle=60, end_angle=120, location=(5, 8), # user defined measurement text location ) dim.render() .EE .UNINDENT .UNINDENT [image] .SS Relative User Location .sp Relative placing of the measurement text means relative to the middle of the dimension line. This is only possible by calling the \fBset_location()\fP method, and the argument \fIrelative\fP has to be \fBTrue\fP\&. The user location is stored in the DIMENSION entity, which means editing the dimension line in a CAD application does not alter the text location. This location also determines the rotation of the measurement text. .INDENT 0.0 .INDENT 3.5 .sp .EX dim = msp.add_angular_dim_cra( center=(3, 3), radius=3, distance=1, start_angle=60, end_angle=120, ) dim.set_location((1, 2), relative=True) dim.render() .EE .UNINDENT .UNINDENT [image] .SS Adding a Leader .sp The method \fBset_location()\fP has the option to add a leader line to the measurement text. This also aligns the text rotation to the render UCS x\-axis, this means in the default case the measurement text is horizontal. The leader line can be “below” the text or start at the “left” or “right” center of the text, this location is defined by the \fI\%dimtad\fP attribute, 0 means “center” and any value != 0 means “below”. .INDENT 0.0 .INDENT 3.5 .sp .EX for dimtad, x in [(0, 0), (4, 6)]: dim = msp.add_angular_dim_cra( center=(3 + x, 3), radius=3, distance=1, start_angle=60, end_angle=120, override={\(dqdimtad\(dq: dimtad} # \(dqcenter\(dq == 0; \(dqbelow\(dq != 0; ) dim.set_location((1, 2), relative=True, leader=True) dim.render() .EE .UNINDENT .UNINDENT [image] .sp Advanced version which calculates the relative text location: The user location vector has a length 2 and the orientation is defined by \fIcenter_angle\fP pointing away from the center of the angle. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.math import Vec3 doc = ezdxf.new(setup=True) msp = doc.modelspace() for dimtad, y, leader in [ [0, 0, False], [0, 7, True], [4, 14, True], ]: for x, center_angle in [ (0, 0), (7, 45), (14, 90), (21, 135), (26, 225), (29, 270) ]: dim = msp.add_angular_dim_cra( center=(x, y), radius=3.0, distance=1.0, start_angle=center_angle \- 15.0, end_angle=center_angle + 15.0, override={\(dqdimtad\(dq: dimtad}, ) # The user location is relative to the center of the dimension line: usr_location = Vec3.from_deg_angle(angle=center_angle, length=2.0) dim.set_location(usr_location, leader=leader, relative=True) dim.render() .EE .UNINDENT .UNINDENT [image] .SS Overriding Text Rotation .sp All factory methods supporting the argument \fItext_rotation\fP can override the measurement text rotation. The user defined rotation is relative to the render UCS x\-axis (default is WCS). .sp This example uses a relative text location without a leader and forces the text rotation to 90 degrees: .INDENT 0.0 .INDENT 3.5 .sp .EX for x, center_angle in [(7, 45), (14, 90), (21, 135)]: dim = msp.add_angular_dim_cra( center=(x, 0), radius=3.0, distance=1.0, start_angle=center_angle \- 15.0, end_angle=center_angle + 15.0, text_rotation=90, # vertical text ) usr_location = Vec3.from_deg_angle(angle=center_angle, length=1.0) dim.set_location(usr_location, leader=False, relative=True) dim.render() .EE .UNINDENT .UNINDENT [image] .SS Angular Units .sp Angular units are set by \fI\%dimaunit\fP: .TS center; |l|l|. _ T{ 0 T} T{ Decimal degrees T} _ T{ 1 T} T{ Degrees/Minutes/Seconds, \fBdimadec\fP controls the shown precision .INDENT 0.0 .IP \(bu 2 dimadec=0: 30° .IP \(bu 2 dimadec=2: 30°35’ .IP \(bu 2 dimadec=4: 30°35’25” .IP \(bu 2 dimadec=7: 30°35’25.15” .UNINDENT T} _ T{ 2 T} T{ Grad T} _ T{ 3 T} T{ Radians T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .EX d1 = 15 d2 = 15.59031944 for x, (dimaunit, dimadec) in enumerate( [ (0, 4), (1, 7), (2, 4), (3, 4), ] ): dim = msp.add_angular_dim_cra( center=(x * 4.0, 0.0), radius=3.0, distance=1.0, start_angle=90.0 \- d1, end_angle=90.0 + d2, override={ \(dqdimaunit\(dq: dimaunit, \(dqdimadec\(dq: dimadec, }, ) dim.render() .EE .UNINDENT .UNINDENT [image] [image] .SS Overriding Measurement Text .sp See Linear Dimension Tutorial: \fI\%Overriding Measurement Text\fP .SS Measurement Text Formatting and Styling .sp See Linear Dimension Tutorial: \fI\%Measurement Text Formatting and Styling\fP .SS Tolerances and Limits .sp See Linear Dimension Tutorial: \fI\%Tolerances and Limits\fP .SS Tutorial for Arc Dimensions .sp Please read the \fI\%Tutorial for Linear Dimensions\fP before, if you haven’t. This is a repetition of the \fI\%Tutorial for Angular Dimensions\fP, because \fIezdxf\fP reuses the angular dimension to render arc dimensions. This approach is very different to CAD applications, but also much less work. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP does not render the arc dimension like CAD applications and does not consider all DIMSTYLE variables, so the rendering results are \fBvery\fP different from CAD applications. .UNINDENT .UNINDENT .SS Dimension Style “EZ_CURVED” .sp All factory methods to create arc dimensions uses the dimension style “EZ_CURVED” for curved dimension lines which is defined as: .INDENT 0.0 .IP \(bu 2 angle unit is decimal degrees, \fBdimaunit\fP = 0 .IP \(bu 2 measurement text height = 0.25 (drawing scale = 1:100) .IP \(bu 2 measurement text location is above the dimension line .IP \(bu 2 closed filled arrow and arrow size \fBdimasz\fP = 0.25 .IP \(bu 2 \fBdimzin\fP = 2, suppresses trailing zeros (e.g. 12.5000 becomes 12.5) .IP \(bu 2 \fBdimarcsym\fP = 2, disables the arc symbol, 0 renders only an open round bracket “(” in front of the text and 1 for arc symbol above the text is not supported, renders like disabled .UNINDENT .sp For more information go to: \fI\%Dimension Style “EZ_CURVED”\fP .SS Factory Methods to Create Arc Dimensions .SS Defined by Center, Radius and Angles .sp The first example shows an arc dimension defined by the center point, radius, start\- and end angles: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf # Use argument setup=True to setup the default dimension styles. doc = ezdxf.new(setup=True) # Add new entities to the modelspace: msp = doc.modelspace() # Add an arc DIMENSION defined by the center point, start\- and end angles, # the measurement text is placed at the default location above the dimension # line: dim = msp.add_arc_dim_cra( center=(5, 5), # center point of the angle radius=5, # distance from center point to the start of the extension lines start_angle=60, # start angle in degrees end_angle=120, # end angle in degrees distance=2, # distance from start of the extension lines to the dimension line dimstyle=\(dqEZ_CURVED\(dq, # default angular dimension style ) # Necessary second step to create the BLOCK entity with the dimension geometry. # Additional processing of the DIMENSION entity could happen between adding # the entity and the rendering call. dim.render() doc.saveas(\(dqarc_dimension_cra.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The return value \fIdim\fP is \fBnot\fP a dimension entity, instead a \fI\%DimStyleOverride\fP object is returned, the dimension entity is stored as \fBdim.dimension\fP\&. [image] .SS Arc by 3 Points .sp The next example shows an angular dimension defined by three points, a center point and the two end points of the angle legs, the first point defines the radius, the second point defines only the end angle, the distance from the center point is not relevant: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(setup=True) msp = doc.modelspace() msp.add_arc_dim_3p( base=(0, 7), # location of the dimension line center=(0, 0), # center point p1=(2.5, 4.330127018922193), # 1st point of arc defines start angle and radius p2=(\-2.5, 4.330127018922194), # 2nd point defines the end angle ).render() .EE .UNINDENT .UNINDENT [image] .SS Angle from ConstructionArc .sp The \fI\%ezdxf.math.ConstructionArc\fP provides various class methods for creating arcs and the construction tool can be created from an ARC entity. .sp Add an angular dimension to an ARC entity: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new(setup=True) msp = doc.modelspace() arc = msp.add_arc( center=(0, 0), radius=5, start_angle = 60, end_angle = 120, ) msp.add_arc_dim_arc( arc.construction_tool(), distance=2, ).render() .EE .UNINDENT .UNINDENT .SS Placing Measurement Text .sp The default location of the measurement text depends on various \fI\%DimStyle\fP parameters and is applied if no user defined text location is defined. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Not all possibles features of DIMSTYLE are supported by the \fIezdxf\fP rendering procedure and especially for the arc dimension there are less features implemented than for the linear dimension because of the lack of good documentation. If the arc symbol is enabled (\fBdimarcsym\fP = 0) only an open round bracket “(” is rendered in front of the measurement text! .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Graphical reference of many DIMVARS and some advanced information: \fI\%DIMSTYLE Table\fP .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 The Script \fI\%dimension_arc.py\fP shows examples for angular dimensions. .UNINDENT .UNINDENT .UNINDENT .SS Default Text Locations .sp The DIMSTYLE “EZ_CURVED” places the measurement text in the center of the angle above the dimension line. The first examples above show the measurement text at the default text location. .sp The text direction angle is always perpendicular to the line from the text center to the center point of the angle unless this angle is manually overridden. .sp Arrows and measurement text are placed “outside” automatically if the available space between the extension lines isn’t sufficient. .sp For more information go to: \fI\%Default Text Locations\fP .SS Shift Text From Default Location .sp The method \fBshift_text()\fP shifts the measurement text away from the default location. The shifting direction is aligned to the text rotation of the default measurement text. .sp For more information go to: \fI\%Shift Text From Default Location\fP .SS User Defined Text Locations .sp Beside the default location it is always possible to override the text location by a user defined location. .sp The coordinates of user locations are located in the rendering UCS and the default rendering UCS is the \fI\%WCS\fP\&. .sp For more information go to: \fI\%User Defined Text Locations\fP .SS Absolute User Location .sp Absolute placing of the measurement text means relative to the origin of the render UCS. .sp For more information go to: \fI\%User Defined Text Locations\fP .SS Relative User Location .sp Relative placing of the measurement text means relative to the middle of the dimension line. .sp For more information go to: \fI\%User Defined Text Locations\fP .SS Adding a Leader .sp Add a leader line to the measurement text and set the text rotation to “horizontal”. .sp For more information go to: \fI\%User Defined Text Locations\fP .SS Overriding Text Rotation .sp All factory methods supporting the argument \fItext_rotation\fP can override the measurement text rotation. The user defined rotation is relative to the render UCS x\-axis (default is WCS). .sp For more information go to: \fI\%User Defined Text Locations\fP .SS Overriding Measurement Text .sp See Linear Dimension Tutorial: \fI\%Overriding Text Rotation\fP .SS Measurement Text Formatting and Styling .sp See Linear Dimension Tutorial: \fI\%Measurement Text Formatting and Styling\fP .SS Tolerances and Limits .sp See Linear Dimension Tutorial: \fI\%Tolerances and Limits\fP .SS Tutorial for Ordinate Dimensions .sp Please read the \fI\%Tutorial for Linear Dimensions\fP before, if you haven’t. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .SS Local Coordinate System .sp Ordinate dimensioning is used when the x\- and the y\-coordinates from a location (feature), are the only dimensions necessary. The dimensions to each feature, originate from one datum location, called “origin” in this tutorial. .sp The local coordinate system (LCS) in which the measurement is done, is defined by the \fIorigin\fP and the \fIrotation\fP angle around the z\-axis in the rendering UCS, which is the \fI\%WCS\fP by default. .SS Factory Methods to Create Ordinate Dimensions .sp All factory methods for creating ordinate dimensions expect global coordinates to define the feature location. .SS Global Feature Location .sp The first example shows ordinate dimensions defined in the render UCS, in this example the \fI\%WCS\fP, this is how the DIMENSION entity expects the coordinates of the feature location: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.math import Vec3 from ezdxf.render import forms # Use argument setup=True to setup the default dimension styles. doc = ezdxf.new(setup=True) # Add new entities to the modelspace: msp = doc.modelspace() # Add a rectangle: width=4, height = 2.5, lower left corner is WCS(x=2, y=3) origin = Vec3(2, 3) msp.add_lwpolyline( forms.translate(forms.box(4, 2.5), origin), close=True ) # Add an x\-type ordinate DIMENSION with global feature locations: msp.add_ordinate_x_dim( # lower left corner feature_location=origin + (0, 0), # feature location in the WCS offset=(0, \-2), # end of leader, relative to the feature location origin=origin, ).render() msp.add_ordinate_x_dim( # lower right corner feature_location=origin + (4, 0), # feature location in the WCS offset=(0, \-2), origin=origin, ).render() # Add an y\-type ordinate DIMENSION with global feature locations: msp.add_ordinate_y_dim( # lower right corner feature_location=origin + (4, 0), # feature location in the WCS offset=(2, 0), origin=origin, ).render() msp.add_ordinate_y_dim( # upper right corner feature_location=origin + (4, 2.5), # feature location in the WCS offset=(2, 0), origin=origin, ).render() # Necessary second step to create the BLOCK entity with the dimension geometry. # Additional processing of the DIMENSION entity could happen between adding # the entity and the rendering call. doc.saveas(\(dqord_global_features.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The return value \fIdim\fP is \fBnot\fP a dimension entity, instead a \fI\%DimStyleOverride\fP object is returned, the dimension entity is stored as \fBdim.dimension\fP\&. [image] .SS Local Feature Location .sp The previous examples shows that the calculation of the global feature location is cumbersome and it gets even more complicated for a rotated LCS. .sp This example shows how to use a render \fI\%UCS\fP for using locale coordinates to define the feature locations: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.math import Vec3, UCS from ezdxf.render import forms doc = ezdxf.new(setup=True) msp = doc.modelspace() # Create a special DIMSTYLE for \(dqvertical\(dq centered measurement text: dimstyle = doc.dimstyles.duplicate_entry(\(dqEZDXF\(dq, \(dqORD_CENTER\(dq) dimstyle.dxf.dimtad = 0 # \(dqvertical\(dq centered measurement text # Add a rectangle: width=4, height = 2.5, lower left corner is WCS(x=2, y=3), # rotated about 30 degrees: origin = Vec3(2, 3) msp.add_lwpolyline( forms.translate(forms.rotate(forms.box(4, 2.5), 30), origin), close=True ) # Define the rotated local render UCS. # The origin is the lower\-left corner of the rectangle and the axis are # aligned to the rectangle edges: # The y\-axis \(dquy\(dq is calculated automatically by the right\-hand rule. ucs = UCS(origin, ux=Vec3.from_deg_angle(30), uz=(0, 0, 1)) # Add a x\-type ordinate DIMENSION with local feature locations: # the origin is now the origin of the UCS, which is (0, 0) the default value of # \(dqorigin\(dq and the feature coordinates are located in the UCS: msp.add_ordinate_x_dim( # lower left corner feature_location=(0, 0), # feature location in the UCS offset=(0.25, \-2), # # leader with a \(dqknee\(dq dimstyle=\(dqORD_CENTER\(dq, ).render(ucs=ucs) # Important when using a render UCS! msp.add_ordinate_x_dim( # lower right corner feature_location=(4, 0), # feature location in the UCS offset=(0.25, \-2), # leader with a \(dqknee\(dq dimstyle=\(dqORD_CENTER\(dq, ).render(ucs=ucs) # Important when using a render UCS! # Add a y\-type ordinate DIMENSION with local feature coordinates: msp.add_ordinate_y_dim( # lower right corner feature_location=(4, 0), # feature location in the UCS offset=(2, 0.25), # leader with a \(dqknee\(dq dimstyle=\(dqORD_CENTER\(dq, ).render(ucs=ucs) # Important when using a render UCS! msp.add_ordinate_y_dim( # upper right corner feature_location=(4, 2.5), # feature location in the UCS offset=(2, 0.25), # leader with a \(dqknee\(dq dimstyle=\(dqORD_CENTER\(dq, ).render(ucs=ucs) # Important when using a render UCS! doc.saveas(\(dqord_local_features.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .SS Placing Measurement Text .sp The \fIezdxf\fP ordinate DIMENSION renderer places the measurement text always at the default location, because the location of the leader end point is given by the argument \fIoffset\fP in the factory methods, which provides a flexible way to place the measurement text, overriding the text location by an explicit user location is not supported, also the user text rotation is not supported, the text is always aligned to the local coordinate system x\- and y\-axis. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Graphical reference of many DIMVARS and some advanced information: \fI\%DIMSTYLE Table\fP .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 The Script \fI\%dimension_ordinate.py\fP shows examples for angular dimensions. .UNINDENT .UNINDENT .UNINDENT .SS Overriding Measurement Text .sp See Linear Dimension Tutorial: \fI\%Overriding Text Rotation\fP .SS Measurement Text Formatting and Styling .sp See Linear Dimension Tutorial: \fI\%Measurement Text Formatting and Styling\fP .SS Tolerances and Limits .sp See Linear Dimension Tutorial: \fI\%Tolerances and Limits\fP .SS Tutorial for the Geo Add\-on .sp This tutorial shows how to load a GPS track into a geo located DXF file and also the inverse operation, exporting geo located DXF entities as GeoJSON files. .sp Please read the section \fI\%Intended Usage\fP in the documentation of the \fI\%ezdxf.addons.geo\fP module first. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 TO ALL BEGINNERS! .sp If you are just learning to work with geospatial data, using DXF files is not the way to go! DXF is not the first choice for storing data for spatial data analysts. If you run into problems I cannot help you as I am just learning myself. .UNINDENT .UNINDENT .sp The complete source code and test data for this tutorial are available in the github repository: .sp \fI\%https://github.com/mozman/ezdxf/tree/master/docs/source/tutorials/src/geo\fP .SS Setup Geo Location Reference .sp The first step is setting up the geo location reference, which is \fBnot\fP doable with ezdxf yet \- this feature may come in the future \- but for now you have to use a CAD application to do this. If the DXF file has no geo location reference the projected 2D coordinates are most likely far away from the WCS origin (0, 0), use the CAD command “ZOOM EXTENDS” to find the data. .SS Load GPX Data .sp The GPX format stores GPS data in a XML format, use the \fBElementTree\fP class to load the data: .INDENT 0.0 .INDENT 3.5 .sp .EX def load_gpx_track(p: Path) \-> Iterable[Tuple[float, float]]: \(dq\(dq\(dqLoad all track points from all track segments at once.\(dq\(dq\(dq gpx = ET.parse(p) root = gpx.getroot() for track_point in root.findall(\(dq.//gpx:trkpt\(dq, GPX_NS): data = track_point.attrib # Elevation is not supported by the geo add\-on. yield float(data[\(dqlon\(dq]), float(data[\(dqlat\(dq]) .EE .UNINDENT .UNINDENT .sp The loaded GPS data has a WSG84 EPSG:4326 projection as longitude and latitude in decimal degrees. The next step is to create a \fBGeoProxy\fP object from this data, the \fBGeoProxy.parse()\fP method accepts a \fB__geo_interface__\fP mapping or a Python object with a \fB__geo_interface__\fP attribute/property. In this case as simple “LineString” object for all GPS points is sufficient: .INDENT 0.0 .INDENT 3.5 .sp .EX def add_gpx_track(msp, track_data, layer: str): geo_mapping = { \(dqtype\(dq: \(dqLineString\(dq, \(dqcoordinates\(dq: track_data, } geo_track = geo.GeoProxy.parse(geo_mapping) .EE .UNINDENT .UNINDENT .sp Transform the data from the polar representation EPSG:4326 into a 2D cartesian map representation EPSG:3395 called “World Mercator”, this is the only projection supported by the add\-on, without the need to write a custom transformation function: .INDENT 0.0 .INDENT 3.5 .sp .EX geo_track.globe_to_map() .EE .UNINDENT .UNINDENT .sp The data is now transformed into 2D cartesian coordinates in meters and most likely far away from origin (0, 0), the data stored in the GEODATA entity helps to transform the data into the DXF WCS in modelspace units, if the DXF file has no geo location reference you have to stick with the large coordinates: .INDENT 0.0 .INDENT 3.5 .sp .EX # Load geo data information from the DXF file: geo_data = msp.get_geodata() if geo_data: # Get the transformation matrix and epsg code: m, epsg = geo_data.get_crs_transformation() else: # Identity matrix for DXF files without a geo location reference: m = Matrix44() epsg = 3395 # Check for compatible projection: if epsg == 3395: # Transform CRS coordinates into DXF WCS: geo_track.crs_to_wcs(m) # Create DXF entities (LWPOLYLINE) for entity in geo_track.to_dxf_entities(dxfattribs={\(dqlayer\(dq: layer}): # Add entity to the modelspace: msp.add_entity(entity) else: print(f\(dqIncompatible CRS EPSG:{epsg}\(dq) .EE .UNINDENT .UNINDENT .sp We are ready to save the final DXF file: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.saveas(str(out_path)) .EE .UNINDENT .UNINDENT .sp In BricsCAD the result looks like this, the underlying images were added by the BricsCAD command MAPCONNECT and such a feature is \fBnot\fP planned for the add\-on: [image] .SS Export DXF Entities as GeoJSON .sp This will only work with a proper geo location reference, the code shown accepts also WCS data from DXF files without a GEODATA object, but the result is just unusable \- but in valid GeoJSON notation. .sp First get epsg code and the CRS transformation matrix: .INDENT 0.0 .INDENT 3.5 .sp .EX # Get the geo location information from the DXF file: geo_data = msp.get_geodata() if geo_data: # Get transformation matrix and epsg code: m, epsg = geo_data.get_crs_transformation() else: # Identity matrix for DXF files without geo reference data: m = Matrix44() .EE .UNINDENT .UNINDENT .sp Query the DXF entities to export: .INDENT 0.0 .INDENT 3.5 .sp .EX for track in msp.query(\(dqLWPOLYLINE\(dq): export_geojson(track, m) .EE .UNINDENT .UNINDENT .sp Create a \fBGeoProxy\fP object from the DXF entity: .INDENT 0.0 .INDENT 3.5 .sp .EX def export_geojson(entity, m): # Convert DXF entity into a GeoProxy object: geo_proxy = geo.proxy(entity) .EE .UNINDENT .UNINDENT .sp Transform DXF WCS coordinates in modelspace units into the CRS coordinate system by the transformation matrix \fIm\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX # Transform DXF WCS coordinates into CRS coordinates: geo_proxy.wcs_to_crs(m) .EE .UNINDENT .UNINDENT .sp The next step assumes a EPSG:3395 projection, everything else needs a custom transformation function: .INDENT 0.0 .INDENT 3.5 .sp .EX # Transform 2D map projection EPSG:3395 into globe (polar) # representation EPSG:4326 geo_proxy.map_to_globe() .EE .UNINDENT .UNINDENT .sp Use the \fBjson\fP module from the Python standard library to write the GeoJSON data, provided by the \fBGeoProxy.__geo_interface__\fP property: .INDENT 0.0 .INDENT 3.5 .sp .EX # Export GeoJSON data: name = entity.dxf.layer + \(dq.geojson\(dq with open(TRACK_DATA / name, \(dqwt\(dq, encoding=\(dqutf8\(dq) as fp: json.dump(geo_proxy.__geo_interface__, fp, indent=2) .EE .UNINDENT .UNINDENT .sp The content of the GeoJSON file looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqtype\(dq: \(dqLineString\(dq, \(dqcoordinates\(dq: [ [ 15.430999, 47.06503 ], [ 15.431039, 47.064797 ], [ 15.431206, 47.064582 ], [ 15.431283, 47.064342 ], ... } .EE .UNINDENT .UNINDENT .SS Custom Transformation Function .sp This sections shows how to use the GDAL package to write a custom transformation function. The example reimplements the builtin transformation from unprojected WGS84 coordinates to 2D map coordinates EPSG:3395 “World Mercator”: .INDENT 0.0 .INDENT 3.5 .sp .EX from osgeo import osr from ezdxf.math import Vec3 # GPS track in WGS84, load_gpx_track() code see above gpx_points = list(load_gpx_track(\(aqtrack1.gpx\(aq)) # Create source coordinate system: src_datum = osr.SpatialReference() src_datum.SetWellKnownGeoCS(\(aqWGS84\(aq) # Create target coordinate system: target_datum = osr.SpatialReference() target_datum.SetWellKnownGeoCS(\(aqEPSG:3395\(aq) # Create transformation object: ct = osr.CoordinateTransform(src_datum, target_datum) # Create GeoProxy() object: geo_proxy = GeoProxy.parse({ \(aqtype\(aq: \(aqLineString\(aq, \(aqcoordinates\(aq: gpx_points }) # Apply a custom transformation function to all coordinates: geo_proxy.apply(lambda v: Vec3(ct.TransformPoint(v.x, v.y))) .EE .UNINDENT .UNINDENT .sp The same example with the pyproj package: .INDENT 0.0 .INDENT 3.5 .sp .EX from pyproj import Transformer from ezdxf.math import Vec3 # GPS track in WGS84, load_gpx_track() code see above gpx_points = list(load_gpx_track(\(aqtrack1.gpx\(aq)) # Create transformation object: ct = Transformer.from_crs(\(aqEPSG:4326\(aq, \(aqEPSG:3395\(aq) # Create GeoProxy() object: geo_proxy = GeoProxy.parse({ \(aqtype\(aq: \(aqLineString\(aq, \(aqcoordinates\(aq: gpx_points }) # Apply a custom transformation function to all coordinates: geo_proxy.apply(lambda v: Vec3(ct.transform(v.x, v.y))) .EE .UNINDENT .UNINDENT .SS Polygon Validation by Shapely .sp Ezdxf tries to avoid to create invalid polygons from HATCH entities like a hole in another hole, but not all problems are detected by ezdxf, especially overlapping polygons. For a reliable and robust result use the Shapely package to check for valid polygons: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons import geo from shapely.geometry import shape # Load DXF document including HATCH entities. doc = ezdxf.readfile(\(aqhatch.dxf\(aq) msp = doc.modelspace() # Test a single entity # Get the first DXF hatch entity: hatch_entity = msp.query(\(aqHATCH\(aq).first # Create GeoProxy() object: hatch_proxy = geo.proxy(hatch_entity) # Shapely supports the __geo_interface__ shapely_polygon = shape(hatch_proxy) if shapely_polygon.is_valid: ... else: print(f\(aqInvalid Polygon from {str(hatch_entity)}.\(aq) # Remove invalid entities by a filter function def validate(geo_proxy: geo.GeoProxy) \-> bool: # Multi\-entities are divided into single entities: # e.g. MultiPolygon is verified as multiple single Polygon entities. if geo_proxy.geotype == \(aqPolygon\(aq: return shape(geo_proxy).is_valid return True # The gfilter() function let only pass compatible DXF entities msp_proxy = geo.GeoProxy.from_dxf_entities(geo.gfilter(msp)) # remove all mappings for which validate() returns False msp_proxy.filter(validate) .EE .UNINDENT .UNINDENT .SS Interface to GDAL/OGR .sp The GDAL/OGR package has no direct support for the \fB__geo_interface__\fP, but has builtin support for the GeoJSON format: .INDENT 0.0 .INDENT 3.5 .sp .EX from osgeo import ogr from ezdxf.addons import geo from ezdxf.render import random_2d_path import json p = geo.GeoProxy({\(aqtype\(aq: \(aqLineString\(aq, \(aqcoordinates\(aq: list(random_2d_path(20))}) # Create a GeoJSON string from the __geo_interface__ object by the json # module and feed the result into ogr: line_string = ogr.CreateGeometryFromJson(json.dumps(p.__geo_interface__)) # Parse the GeoJSON string from ogr by the json module and feed the result # into a GeoProxy() object: p2 = geo.GeoProxy.parse(json.loads(line_string.ExportToJson())) .EE .UNINDENT .UNINDENT .SS Storing Custom Data in DXF Files .sp This tutorial describes how to store custom data in DXF files using standard DXF features. .sp Saving data in comments is not covered in this section, because comments are not a reliable way to store information in DXF files and \fIezdxf\fP does not support adding comments to DXF files. Comments are also ignored by \fIezdxf\fP and many other DXF libraries when loading DXF files, but there is a \fI\%ezdxf.comments\fP module to load comments from DXF files. .sp The DXF data format is a very versatile and flexible data format and supports various ways to store custom data. This starts by setting special header variables, storing XData, AppData and extension dictionaries in DXF entities and objects, storing XRecords in the OBJECTS section and ends by using proxy entities or even extending the DXF format by user defined entities and objects. .sp This is the common prolog for all Python code examples shown in this tutorial: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new() msp = doc.modelspace() .EE .UNINDENT .UNINDENT .SS Retrieving User Data .sp Retrieving the is a simple task by \fIezdxf\fP, but often not possible in CAD applications without using the scripting features (AutoLISP) or even the SDK. .SS AutoLISP Resources .INDENT 0.0 .IP \(bu 2 \fI\%Autodesk Developer Documentation\fP .IP \(bu 2 \fI\%AfraLISP\fP .IP \(bu 2 \fI\%Lee Mac Programming\fP .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 I have no experience with AutoLISP so far and I created this scripts for AutoLISP while writing this tutorial. There may be better ways to accomplish these tasks, and feedback on this is very welcome. Everything is tested with BricsCAD and should also work with the full version of AutoCAD. .UNINDENT .UNINDENT .SS Header Section .sp The HEADER section has tow ways to store custom data. .SS Predefined User Variables .sp There are ten predefined user variables, five 16\-bit integer variables called \fB$USERI1\fP up to \fB$USERI5\fP and five floating point variables (reals) called \fB$USERR1\fP up to \fB$USERR5\fP\&. This is very limited and the data maybe will be overwritten by the next application which opens and saves the DXF file. Advantage of this methods is, it works for all supported DXF versions starting at R12. .sp Settings the data: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(dq$USERI1\(dq] = 4711 doc.header[\(dq$USERR1\(dq] = 3.141592 .EE .UNINDENT .UNINDENT .sp Getting the data by \fIezdxf\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX i1 = doc.header[\(dq$USERI1\(dq] r1 = doc.header[\(dq$USERR1\(dq] .EE .UNINDENT .UNINDENT .sp Getting the data in \fIBricsCAD\fP at the command line: .INDENT 0.0 .INDENT 3.5 .sp .EX : USERI1 New current value for USERI1 (\-32768 to 32767) <4711>: .EE .UNINDENT .UNINDENT .sp Getting the data by AutoLISP: .INDENT 0.0 .INDENT 3.5 .sp .EX : (getvar \(aqUSERI1) 4711 .EE .UNINDENT .UNINDENT .sp Setting the value by AutoLISP: .INDENT 0.0 .INDENT 3.5 .sp .EX : (setvar \(aqUSERI1 1234) 1234 .EE .UNINDENT .UNINDENT .SS Custom Document Properties .sp This method defines custom document properties, but requires at least DXF R2004. The custom document properties are stored in a \fI\%CustomVars\fP instance in the \fI\%custom_vars\fP attribute of the \fI\%HeaderSection\fP object and supports only string values. .sp Settings the data: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header.custom_vars.append(\(dqMyFirstVar\(dq, \(dqFirst Value\(dq) .EE .UNINDENT .UNINDENT .sp Getting the data by \fIezdxf\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX my_first_var = doc.header.custom_vars.get(\(dqMyFirstVar\(dq, \(dqDefault Value\(dq) .EE .UNINDENT .UNINDENT .sp The document property \fBMyFirstVar\fP is available in \fIBricsCAD\fP as FIELD variable: [image] .sp AutoLISP script for getting the custom document properties: .INDENT 0.0 .INDENT 3.5 .sp .EX (defun C:CUSTOMDOCPROPS (/ Info Num Index Custom) (vl\-load\-com) (setq acadObject (vlax\-get\-acad\-object)) (setq acadDocument (vla\-get\-ActiveDocument acadObject)) ;;Get the SummaryInfo (setq Info (vlax\-get\-Property acadDocument \(aqSummaryInfo)) (setq Num (vla\-NumCustomInfo Info)) (setq Index 0) (repeat Num (vla\-getCustomByIndex Info Index \(aqID \(aqValue) (setq Custom (cons (cons ID Value) Custom)) (setq Index (1+ Index)) ) ;repeat (if Custom (reverse Custom)) ) .EE .UNINDENT .UNINDENT .sp Running the script in BricsCAD: .INDENT 0.0 .INDENT 3.5 .sp .EX : (load \(dqcustomdocprops.lsp\(dq) C:CUSTOMDOCPROPS : CUSTOMDOCPROPS ((\(dqMyFirstVar\(dq . \(dqFirst Value\(dq)) .EE .UNINDENT .UNINDENT .SS Meta Data .sp Starting with version v0.16.4 \fIezdxf\fP stores some meta data in the DXF file and the AppID \fBEZDXF\fP will be created. Two entries will be added to the \fI\%MetaData\fP instance, the \fBCREATED_BY_EZDXF\fP for DXF documents created by \fIezdxf\fP and the entry \fBWRITTEN_BY_EZDXF\fP if the DXF document will be saved by \fIezdxf\fP\&. The marker string looks like this \fB\(dq0.17b0 @ 2021\-09\-18T05:14:37.921826+00:00\(dq\fP and contains the \fIezdxf\fP version and an UTC timestamp in ISO format. .sp You can add your own data to the \fI\%MetaData\fP instance as a string with a maximum of 254 characters and choose a good name which may never be used by \fIezdxf\fP in the future. .INDENT 0.0 .INDENT 3.5 .sp .EX metadata = doc.ezdxf_metadata() metadata[\(dqMY_UNIQUE_KEY\(dq] = \(dqmy additional meta data\(dq print(metadata.get(\(dqCREATED_BY_EZDXF\(dq)) print(metadata.get(\(dqMY_UNIQUE_KEY\(dq)) .EE .UNINDENT .UNINDENT .sp The data is stored as XDATA in then BLOCK entity of the model space for DXF R12 and for DXF R2000 and later as a DXF \fI\%Dictionary\fP in the root dictionary by the key \fBEZDXF_META\fP\&. See following chapters for accessing such data by AutoLISP. .SS XDATA .sp \fI\%Extended Data (XDATA)\fP is a way to attach arbitrary data to DXF entities. Each application needs a unique AppID registered in the AppID table to add XDATA to an entity. The AppID \fBACAD\fP is reserved and by using \fIezdxf\fP the AppID \fBEZDXF\fP is also registered automatically. The total size of XDATA for a single DXF entity is limited to 16kB for AutoCAD. XDATA is supported by all DXF versions and is accessible by AutoLISP. .sp The valid group codes for extended data are limited to the following values, see also the internals of \fI\%Extended Data\fP: .TS center; |l|l|. _ T{ Group Code T} T{ Description T} _ T{ 1000 T} T{ Strings up to 255 bytes long T} _ T{ 1001 T} T{ (fixed) Registered application name up to 31 bytes long T} _ T{ 1002 T} T{ (fixed) An extended data control string \fB\(aq{\(aq\fP or \fB\(aq}\(aq\fP T} _ T{ 1004 T} T{ Binary data T} _ T{ 1005 T} T{ Database Handle of entities in the drawing database T} _ T{ 1010 T} T{ 3D point, in the order X, Y, Z that will not be modified at any transformation of the entity T} _ T{ 1011 T} T{ A WCS point that is moved, scaled, rotated and mirrored along with the entity T} _ T{ 1012 T} T{ A WCS displacement that is scaled, rotated and mirrored along with the entity, but not moved T} _ T{ 1013 T} T{ A WCS direction that is rotated and mirrored along with the entity but not moved and scaled. T} _ T{ 1040 T} T{ A real value T} _ T{ 1041 T} T{ Distance, a real value that is scaled along with the entity T} _ T{ 1042 T} T{ Scale Factor, a real value that is scaled along with the entity T} _ T{ 1070 T} T{ A 16\-bit integer (signed or unsigned) T} _ T{ 1071 T} T{ A 32\-bit signed (long) integer T} _ .TE .sp Group codes are not unique in the XDATA section and can be repeated, therefore tag order matters. .INDENT 0.0 .INDENT 3.5 .sp .EX # register your appid APPID = \(dqYOUR_UNIQUE_ID\(dq doc.appids.add(APPID) # create a DXF entity line = msp.add_line((0, 0), (1, 0)) # setting the data line.set_xdata(APPID, [ # basic types (1000, \(dqcustom text\(dq), (1040, 3.141592), (1070, 4711), # 16bit (1071, 1_048_576), # 32bit # points and vectors (1010, (10, 20, 30)), (1011, (11, 21, 31)), (1012, (12, 22, 32)), (1013, (13, 23, 33)), # scaled distances and factors (1041, 10), (1042, 10), ]) # getting the data if line.has_xdata(APPID): tags = line.get_xdata(APPID) print(f\(dq{str(line)} has {len(tags)} tags of XDATA for AppID {APPID!r}\(dq) for tag in tags: print(tag) .EE .UNINDENT .UNINDENT .sp AutoLISP script for getting XDATA for AppID \fBYOUR_UNIQUE_ID\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX (defun C:SHOWXDATA (/ entity_list xdata_list) (setq entity_list (entget (car (entsel)) \(aq(\(dqYOUR_UNIQUE_ID\(dq))) (setq xdata_list (assoc \-3 entity_list)) (car (cdr xdata_list)) ) .EE .UNINDENT .UNINDENT .sp Script output: .INDENT 0.0 .INDENT 3.5 .sp .EX : SHOWXDATA Select entity: (\(dqYOUR_UNIQUE_ID\(dq (1000 . \(dqcustom text\(dq) (1040 . 3.141592) ... .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%AfraLISP XDATA tutorial\fP .IP \(bu 2 \fI\%Extended Data (XDATA)\fP Reference .UNINDENT .UNINDENT .UNINDENT .SS XDATA Helper Classes .sp The \fI\%XDataUserList\fP and \fI\%XDataUserDict\fP are helper classes to manage XDATA content in a simple way. .sp Both classes store the Python types \fBint\fP, \fBfloat\fP and \fBstr\fP and the \fIezdxf\fP type \fI\%Vec3\fP\&. As the names suggests has the \fBXDataUserList\fP a list\-like interface and the \fBXDataUserDict\fP a dict\-like interface. This classes can not contain additional container types, but multiple lists and/or dicts can be stored in the same XDATA section for the same AppID. .sp These helper classes uses a fixed group code for each data type: .TS center; |l|l|. _ T{ 1001 T} T{ strings (max. 255 chars) T} _ T{ 1040 T} T{ floats T} _ T{ 1071 T} T{ 32\-bit ints T} _ T{ 1010 T} T{ Vec3 T} _ .TE .sp Additional required imports for these examples: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.math import Vec3 from ezdxf.entities.xdata import XDataUserDict, XDataUserList .EE .UNINDENT .UNINDENT .sp Example for \fI\%XDataUserDict\fP: .sp Each \fBXDataUserDict\fP has a unique name, the default name is “DefaultDict” and the default AppID is \fBEZDXF\fP\&. If you use your own AppID, don’t forget to create the requited AppID table entry like \fBdoc.appids.new(\(dqMyAppID\(dq)\fP, otherwise AutoCAD will not open the DXF file. .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.new() msp = doc.modelspace() line = msp.add_line((0, 0), (1, 0)) with XDataUserDict.entity(line) as user_dict: user_dict[\(dqCreatedBy\(dq] = \(dqmozman\(dq user_dict[\(dqFloat\(dq] = 3.1415 user_dict[\(dqInt\(dq] = 4711 user_dict[\(dqPoint\(dq] = Vec3(1, 2, 3) .EE .UNINDENT .UNINDENT .sp If you modify the content of without using the context manager \fI\%entity()\fP, you have to call \fI\%commit()\fP by yourself, to transfer the modified data back into the XDATA section. .sp Getting the data back from an entity: .INDENT 0.0 .INDENT 3.5 .sp .EX with XDataUserDict.entity(line) as user_dict: print(user_dict) # acts like any other dict() storage = dict(user_dict) .EE .UNINDENT .UNINDENT .sp Example for \fI\%XDataUserList\fP: .sp This example stores the data in a \fBXDataUserList\fP named “AppendedPoints”, the default name is “DefaultList” and the default AppID is \fBEZDXF\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX with XDataUserList.entity(line, name=\(dqAppendedPoints\(dq) as user_list: user_list.append(Vec3(1, 0, 0)) user_list.append(Vec3(0, 1, 0)) user_list.append(Vec3(0, 0, 1)) .EE .UNINDENT .UNINDENT .sp Now the content of both classes are stored in the same XDATA section for AppID \fBEZDXF\fP\&. The \fBXDataUserDict\fP is stored by the name “DefaultDict” and the \fBXDataUserList\fP is stored by the name “AppendedPoints”. .sp Getting the data back from an entity: .INDENT 0.0 .INDENT 3.5 .sp .EX with XDataUserList.entity(line, name=\(dqAppendedPoints\(dq) as user_list: print(user_list) storage = list(user_list) print(f\(dqCopy of XDataUserList: {storage}\(dq) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%XDataUserList\fP class .IP \(bu 2 \fI\%XDataUserDict\fP class .UNINDENT .UNINDENT .UNINDENT .SS Extension Dictionaries .sp Extension dictionaries are another way to attach custom data to any DXF entity. This method requires DXF R13/14 or later. I will use the short term XDICT for extension dictionaries in this tutorial. .sp The \fI\%Extension Dictionary\fP is a regular DXF \fI\%Dictionary\fP which can store (key, value) pairs where the key is a string and the value is a DXF object from the OBJECTS section. The usual objects to store custom data are \fI\%DictionaryVar\fP to store simple strings and \fI\%XRecord\fP to store complex data. .sp Unlike XDATA, custom data attached by extension dictionary will not be transformed along with the DXF entity! .sp This example shows how to manage the XDICT and to store simple strings as \fI\%DictionaryVar\fP objects in the XDICT, to store more complex data go to the next section \fI\%XRecord\fP\&. .INDENT 0.0 .IP 1. 3 Get or create the XDICT for an entity: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX # create a DXF entity line = msp.add_line((0, 0), (1, 0)) if line.has_extension_dict: # get the extension dictionary xdict = line.get_extension_dict() else: # create a new extension dictionary xdict = line.new_extension_dict() .EE .UNINDENT .UNINDENT .sp 2. Add strings as \fI\%DictionaryVar\fP objects to the XDICT. No AppIDs required, but existing keys will be overridden, so be careful by choosing your keys: .INDENT 0.0 .INDENT 3.5 .sp .EX xdict.add_dictionary_var(\(dqDATA1\(dq, \(dqYour custom data string 1\(dq) xdict.add_dictionary_var(\(dqDATA2\(dq, \(dqYour custom data string 2\(dq) .EE .UNINDENT .UNINDENT .sp 3. Retrieve the strings from the XDICT as \fI\%DictionaryVar\fP objects: .INDENT 0.0 .INDENT 3.5 .sp .EX print(f\(dqDATA1 is \(aq{xdict[\(aqDATA1\(aq].value}\(aq\(dq) print(f\(dqDATA2 is \(aq{xdict[\(aqDATA2\(aq].value}\(aq\(dq) .EE .UNINDENT .UNINDENT .sp The AutoLISP access to DICTIONARIES is possible, but it gets complex and I’m only referring to the \fI\%AfraLISP Dictionaries and XRecords\fP tutorial. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%AfraLISP Dictionaries and XRecords\fP Tutorial .IP \(bu 2 \fI\%Extension Dictionary\fP Reference .IP \(bu 2 DXF \fI\%Dictionary\fP Reference .IP \(bu 2 \fI\%DictionaryVar\fP Reference .UNINDENT .UNINDENT .UNINDENT .SS XRecord .sp The \fI\%XRecord\fP object can store arbitrary data like the XDATA section, but is not limited by size and can use all group codes in the range from 1 to 369 for \fI\%DXF Tags\fP\&. The \fI\%XRecord\fP can be referenced by any DXF \fI\%Dictionary\fP, other \fBXRecord\fP objects (tricky ownership!), the XDATA section (store handle by group code 1005) or any other DXF object by adding the \fBXRecord\fP object to the \fI\%Extension Dictionary\fP of the DXF entity. .sp It is recommend to follow the DXF reference to assign appropriate group codes to \fI\%DXF Tags\fP\&. My recommendation is shown in the table below, but all group codes from 1 to 369 are valid. I advice against using the group codes 100 and 102 (structure tags) to avoid confusing generic tag loaders. Unfortunately, Autodesk doesn’t like general rules and uses DXF format exceptions everywhere. .TS center; |l|l|. _ T{ 1 T} T{ strings (max. 2049 chars) T} _ T{ 2 T} T{ structure tags as strings like \fB\(dq{\(dq\fP and \fB\(dq}\(dq\fP T} _ T{ 10 T} T{ points and vectors T} _ T{ 40 T} T{ floats T} _ T{ 90 T} T{ integers T} _ T{ 330 T} T{ handles T} _ .TE .sp Group codes are not unique in \fBXRecord\fP and can be repeated, therefore tag order matters. .sp This example shows how to attach a \fI\%XRecord\fP object to a LINE entity by \fI\%Extension Dictionary\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX line = msp.add_line((0, 0), (1, 0)) line2 = msp.add_line((0, 2), (1, 2)) if line.has_extension_dict: xdict = line.get_extension_dict() else: xdict = line.new_extension_dict() xrecord = xdict.add_xrecord(\(dqDATA1\(dq) xrecord.reset([ (1, \(dqtext1\(dq), # string (40, 3.141592), # float (90, 256), # 32\-bit int (10, (1, 2, 0)), # points and vectors (330, line2.dxf.handle) # handles ]) print(xrecord.tags) .EE .UNINDENT .UNINDENT .sp Script output: .INDENT 0.0 .INDENT 3.5 .sp .EX [DXFTag(1, \(aqtext1\(aq), DXFTag(40, 3.141592), DXFTag(90, 256), DXFVertex(10, (1.0, 2.0, 0.0)), DXFTag(330, \(aq30\(aq)] .EE .UNINDENT .UNINDENT .sp Unlike XDATA, custom data attached by extension dictionary will not be transformed along with the DXF entity! To react to entity modifications by a CAD applications it is possible to write event handlers by AutoLISP, see the \fI\%AfraLISP Reactors Tutorial\fP for more information. This is very advanced stuff! .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%AfraLISP Dictionaries and XRecords\fP Tutorial .IP \(bu 2 \fI\%AfraLISP Reactors Tutorial\fP .IP \(bu 2 \fI\%XRecord\fP Reference .IP \(bu 2 helper functions: \fI\%ezdxf.lldxf.types.dxftag()\fP and \fI\%ezdxf.lldxf.types.tuples_to_tags()\fP .UNINDENT .UNINDENT .UNINDENT .SS XRecord Helper Classes .sp The \fI\%UserRecord\fP and \fI\%BinaryRecord\fP are helper classes to manage XRECORD content in a simple way. The \fI\%UserRecord\fP manages the data as plain Python types: \fBdict\fP, \fBlist\fP, \fBint\fP, \fBfloat\fP, \fBstr\fP and the \fIezdxf\fP types \fI\%Vec2\fP and \fI\%Vec3\fP\&. The top level type for the \fBUserRecord.data\fP attribute has to be a \fBlist\fP\&. The \fI\%BinaryRecord\fP stores arbitrary binary data as \fI\%BLOB\fP\&. These helper classes uses fixed group codes to manage the data in XRECORD, you have no choice to change them. .sp Additional required imports for these examples: .INDENT 0.0 .INDENT 3.5 .sp .EX from pprint import pprint import ezdxf from ezdxf.math import Vec3 from ezdxf.urecord import UserRecord, BinaryRecord from ezdxf.entities import XRecord import zlib .EE .UNINDENT .UNINDENT .sp Example 1: Store entity specific data in the \fI\%Extension Dictionary\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX line = msp.add_line((0, 0), (1, 0)) xdict = line.new_extension_dict() xrecord = xdict.add_xrecord(\(dqMyData\(dq) with UserRecord(xrecord) as user_record: user_record.data = [ # top level has to be a list! \(dqMyString\(dq, 4711, 3.1415, Vec3(1, 2, 3), { \(dqMyIntList\(dq: [1, 2, 3], \(dqMyFloatList\(dq: [4.5, 5.6, 7.8], }, ] .EE .UNINDENT .UNINDENT .sp Example 1: Get entity specific data back from the \fI\%Extension Dictionary\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX if line.has_extension_dict: xdict = line.get_extension_dict() xrecord = xdict.get(\(dqMyData\(dq) if isinstance(xrecord, XRecord): user_record = UserRecord(xrecord) pprint(user_record.data) .EE .UNINDENT .UNINDENT .sp If you modify the content of \fBUserRecord.data\fP without using the context manager, you have to call \fI\%commit()\fP by yourself, to store the modified data back into the XRECORD. .sp Example 2: Store arbitrary data in DICTIONARY objects. The XRECORD is stored in the named DICTIONARY, called \fBrootdict\fP in \fIezdxf\fP\&. This DICTIONARY is the root entity for the tree\-like data structure stored in the OBJECTS section, see also the documentation of the \fI\%ezdxf.sections.objects\fP module. .INDENT 0.0 .INDENT 3.5 .sp .EX # Get the existing DICTIONARY object or create a new DICTIONARY object: my_dict = doc.objects.rootdict.get_required_dict(\(dqMyDict\(dq) # Create a new XRECORD object, the DICTIONARY object is the owner of this # new XRECORD: xrecord = my_dict.add_xrecord(\(dqMyData\(dq) # This example creates the user record without the context manager. user_record = UserRecord(xrecord) # Store user data: user_record.data = [ \(dqJust another user record\(dq, 4711, 3.1415, ] # Store user data in associated XRECORD: user_record.commit() .EE .UNINDENT .UNINDENT .sp Example 2: Get user data back from the DICTIONARY object .INDENT 0.0 .INDENT 3.5 .sp .EX my_dict = doc.rootdict.get_required_dict(\(dqMyDict\(dq) entity = my_dict[\(dqMyData\(dq] if isinstance(entity, XRecord): user_record = UserRecord(entity) pprint(user_record.data) .EE .UNINDENT .UNINDENT .sp Example 3: Store arbitrary binary data .INDENT 0.0 .INDENT 3.5 .sp .EX my_dict = doc.rootdict.get_required_dict(\(dqMyDict\(dq) xrecord = my_dict.add_xrecord(\(dqMyBinaryData\(dq) with BinaryRecord(xrecord) as binary_record: # The content is stored as hex strings (e.g. ABBAFEFE...) in one or more # group code 310 tags. # A preceding group code 160 tag stores the data size in bytes. data = b\(dqStore any binary data, even line breaks\er\en\(dq * 20 # compress data if required binary_record.data = zlib.compress(data, level=9) .EE .UNINDENT .UNINDENT .sp Example 3: Get binary data back from the DICTIONARY object .INDENT 0.0 .INDENT 3.5 .sp .EX entity = my_dict[\(dqMyBinaryData\(dq] if isinstance(entity, XRecord): binary_record = BinaryRecord(entity) print(\(dq\encompressed data:\(dq) pprint(binary_record.data) print(\(dq\enuncompressed data:\(dq) pprint(zlib.decompress(binary_record.data)) .EE .UNINDENT .UNINDENT .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 Don’t be fooled, the ability to save any binary data such as images, office documents, etc. in the DXF file doesn’t impress AutoCAD, it simply ignores this data, this data only has a meaning for your application! .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%urecord\fP module .IP \(bu 2 \fI\%UserRecord\fP class .IP \(bu 2 \fI\%BinaryRecord\fP class .UNINDENT .UNINDENT .UNINDENT .SS AppData .sp \fI\%Application\-Defined Data (AppData)\fP was introduced in DXF R13/14 and is used by AutoCAD internally to store the handle to the \fI\%Extension Dictionary\fP and the \fI\%Reactors\fP in DXF entities. \fIEzdxf\fP supports these kind of data storage for any AppID and the data is preserved by AutoCAD and BricsCAD, but I haven’t found a way to access this data by AutoLISP or even the SDK. So I don’t recommend this feature to store application defined data, because \fI\%Extended Data (XDATA)\fP and the \fI\%Extension Dictionary\fP are well documented and safe ways to attach custom data to entities. .INDENT 0.0 .INDENT 3.5 .sp .EX # register your appid APPID = \(dqYOUR_UNIQUE_ID\(dq doc.appids.add(APPID) # create a DXF entity line = msp.add_line((0, 0), (1, 0)) # setting the data line.set_app_data(APPID, [(300, \(dqcustom text\(dq), (370, 4711), (460, 3.141592)]) # getting the data if line.has_app_data(APPID): tags = line.get_app_data(APPID) print(f\(dq{str(line)} has {len(tags)} tags of AppData for AppID {APPID!r}\(dq) for tag in tags: print(tag) .EE .UNINDENT .UNINDENT .sp Printed output: .INDENT 0.0 .INDENT 3.5 .sp .EX LINE(#30) has 3 tags of AppData for AppID \(aqYOUR_UNIQUE_ID\(aq (300, \(aqcustom text\(aq) (370, 4711) (460, 3.141592) .EE .UNINDENT .UNINDENT .SS Tutorial for External References .INDENT 0.0 .IP \(bu 2 \fI\%Introduction\fP .IP \(bu 2 \fI\%Supported Entities\fP .IP \(bu 2 \fI\%Environment Setup\fP .IP \(bu 2 \fI\%Attach a DXF File\fP .IP \(bu 2 \fI\%Attach a DWG File\fP .IP \(bu 2 \fI\%Detach an XREF\fP .IP \(bu 2 \fI\%Embed an XREF\fP .IP \(bu 2 \fI\%Load Modelspace\fP .IP \(bu 2 \fI\%Load Paperspace\fP .IP \(bu 2 \fI\%Write Block\fP .IP \(bu 2 \fI\%Conflict Policies\fP .INDENT 2.0 .IP \(bu 2 \fI\%ConflictPolicy.KEEP\fP .IP \(bu 2 \fI\%ConflictPolicy.XREF_PREFIX\fP .IP \(bu 2 \fI\%ConflictPolicy.NUM_PREFIX\fP .UNINDENT .IP \(bu 2 \fI\%Load Table Resources\fP .UNINDENT .SS Introduction .sp This tutorial uses the \fI\%ezdxf.xref\fP module to work with external references (XREF). .sp Attached XREFs are links to the modelspace of a specified drawing file. Changes made to the referenced drawing are automatically reflected in the current drawing when it’s opened or if the XREF is reloaded. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 \fBAutoCAD can only display DWG files as attached XREFs.\fP Any DXF file attached as an XREF to a DXF document must be converted to DWG in order to be viewed in AutoCAD. Fortunately, other CAD applications are more cooperative, BricsCAD has no problem displaying DXF files as XREFs. .sp The \fI\%drawing\fP add\-on included in \fIezdxf\fP \fBdoes not display external references at all!\fP .UNINDENT .UNINDENT .sp There are some example files included in the \fI\%examples/xref\fP folder of the repository: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 attach_dxf_dwg_xref.py .IP \(bu 2 detach_block_as_xref.py .IP \(bu 2 embed_dxf_dwg_xref.py .IP \(bu 2 load_table_resources.py .UNINDENT .UNINDENT .UNINDENT .SS Supported Entities .sp All operations which move entities between layouts and XREFs copy these entities, therefore only entities which are copyable can be transferred. The following entities are not copyable: .INDENT 0.0 .IP \(bu 2 All entities which are not documented by the DXF reference. .IP \(bu 2 ACAD_TABLE .IP \(bu 2 ACAD_PROXY_ENTITY .IP \(bu 2 OLE2FRAME .IP \(bu 2 ACIS based entities: BODY, 3DSOLID, REGION, … .IP \(bu 2 Custom entities from applications on top of AutoCAD like Map 3D, Civil 3D or Architecture. The vertical integration stack is not documented by the DXF reference. .UNINDENT .sp Unsupported entities are ignored and do not raise exceptions. .SS Environment Setup .sp Required imports to follow this tutorial: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons import odafc from ezdxf.document import Drawing from ezdxf import xref, units, colors from ezdxf.render import forms DXFVERSION = \(dqR2013\(dq .EE .UNINDENT .UNINDENT .sp Function to create a simple DXF file as XREF, the insertion point of the XREF is set to (5, 5): .INDENT 0.0 .INDENT 3.5 .sp .EX def make_dxf_xref_document(name: str) \-> Drawing: ref_doc = ezdxf.new(DXFVERSION, units=units.M) ref_doc.layers.add(\(dqGEAR\(dq, color=colors.YELLOW) msp = ref_doc.modelspace() gear = forms.gear( 16, top_width=0.25, bottom_width=0.75, height=0.5, outside_radius=2.5 ) msp.add_lwpolyline( forms.translate(gear, (5, 5)), close=True, dxfattribs={\(dqlayer\(dq: \(dqGEAR\(dq} ) ref_doc.header[\(dq$INSBASE\(dq] = (5, 5, 0) ref_doc.saveas(name) return ref_doc .EE .UNINDENT .UNINDENT .sp Create the DXF file: .INDENT 0.0 .INDENT 3.5 .sp .EX make_dxf_xref_document(\(dqxref.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The XREF looks like this: [image] .SS Attach a DXF File .sp Create a host document to which the XREF will be attached: .INDENT 0.0 .INDENT 3.5 .sp .EX host_doc = ezdxf.new(DXFVERSION, units=units.M) .EE .UNINDENT .UNINDENT .sp Attach the XREF by the \fI\%ezdxf.xref.attach()\fP function and save the host DXF file: .INDENT 0.0 .INDENT 3.5 .sp .EX xref.attach(host_doc, block_name=\(dqdxf_xref\(dq, insert=(0, 0), filename=\(dqattached_xref.dxf\(dq) host_doc.set_modelspace_vport(height=10, center=(0, 0)) host_doc.saveas(\(dqattach_host_dxf.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The \fBattach()\fP function is meant to simply attach an XREF once without any overhead, therefore the \fBattach()\fP function creates the required block definition automatically and raises an \fBXrefDefinitionError\fP exception if the block definition already exist. To attach additional XREF references use the method \fI\%add_blockref()\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_blockref(\(dqdxf_xref\(dq, insert=another_location) .EE .UNINDENT .UNINDENT .sp The attached DXF file in BricsCAD: [image] .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 AutoCAD can not display DXF files as attached XREFs. .UNINDENT .UNINDENT .SS Attach a DWG File .sp Export the DXF file as DWG by the \fI\%odafc\fP add\-on: .INDENT 0.0 .INDENT 3.5 .sp .EX # It\(aqs not required to save the DXF file! doc = make_dxf_xref_document(\(dqattached_xref.dxf\(dq) try: odafc.export_dwg(doc, \(dqattached_xref.dwg\(dq, replace=True) except odafc.ODAFCError as e: print(str(e)) .EE .UNINDENT .UNINDENT .sp Attach the DWG file by the \fI\%ezdxf.xref.attach()\fP function and save the host DXF file: .INDENT 0.0 .INDENT 3.5 .sp .EX host_doc = ezdxf.new(DXFVERSION, units=units.M) xref.attach(host_doc, block_name=\(dqdwg_xref\(dq, filename=\(dqattached_xref.dwg\(dq, insert=(0, 0)) host_doc.set_modelspace_vport(height=10, center=(0, 0)) host_doc.saveas(\(dqattached_dwg.dxf\(dq) .EE .UNINDENT .UNINDENT .sp Attached DWG file in Autodesk DWG TrueView 2023: [image] .SS Detach an XREF .sp The \fI\%detach()\fP function writes the content of a block definition into the modelspace of a new DXF document and convert the block to an external reference (XREF). The new DXF document has to be written/exported by the caller. The function does not create any block references. These references should already exist and do not need to be changed since references to blocks and XREFs are the same. .INDENT 0.0 .INDENT 3.5 .sp .EX host_doc = ezdxf.new() make_block(host_doc, \(dqGEAR\(dq) block_layout = host_doc.blocks.get(\(dqGEAR\(dq) detached_block_doc = xref.detach(block_layout, xref_filename=\(dqdetached_gear.dxf\(dq) detached_block_doc.saveas(\(dqdetached_gear.dxf\(dq) host_doc.set_modelspace_vport(height=10, center=(0, 0)) host_doc.saveas(\(dqdetach_host_dxf_xref.dxf\(dq) .EE .UNINDENT .UNINDENT .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 Save the host document after detaching the block! Detaching a block definition modifies the host document. .UNINDENT .UNINDENT .sp The \fBdetach()\fP function returns a \fBDrawing\fP instance, so it’s possible to convert the DXF document to DWG by the \fI\%odafc\fP add\-on if necessary (e.g. for Autodesk products). It’s important that the argument \fBxref_filename\fP match the filename of the exported DWG file: .INDENT 0.0 .INDENT 3.5 .sp .EX host_doc = ezdxf.new() make_block(host_doc, \(dqGEAR\(dq) block_layout = host_doc.blocks.get(\(dqGEAR\(dq) detached_block_doc = xref.detach(block_layout, xref_filename=\(dqdetached_gear.dwg\(dq) try: odafc.export_dwg(detached_block_doc, \(dqdetached_gear.dwg\(dq, replace=True) except odafc.ODAFCError as e: print(str(e)) host_doc.set_modelspace_vport(height=10, center=(0, 0)) host_doc.saveas(\(dqdetach_host_dwg_xref.dxf\(dq) .EE .UNINDENT .UNINDENT .sp It’s recommended to clean up the entity database of the host document afterwards: .INDENT 0.0 .INDENT 3.5 .sp .EX host_doc.entitydb.purge() .EE .UNINDENT .UNINDENT .sp For understanding, this is the \fBmake_block()\fP function: .INDENT 0.0 .INDENT 3.5 .sp .EX def make_block(doc: Drawing, name: str) \-> None: blk = doc.blocks.new(name, base_point=(5, 5, 0)) doc.layers.add(\(dqGEAR\(dq, color=colors.YELLOW) gear = forms.gear( 16, top_width=0.25, bottom_width=0.75, height=0.5, outside_radius=2.5 ) blk.add_lwpolyline( forms.translate(gear, (5, 5)), close=True, dxfattribs={\(dqlayer\(dq: \(dqGEAR\(dq} ) doc.modelspace().add_blockref(name, (0, 0)) .EE .UNINDENT .UNINDENT .SS Embed an XREF .sp The \fBembed()\fP function loads the content of the XREF into the block definition, this is the reverse operation of detaching an XREF. .sp For loading the content of DWG files is a loading function required, which loads the DWG file as \fBDrawing\fP document. The \fI\%odafc\fP add\-on module provides such a function: \fI\%readfile()\fP\&. .sp This example embeds the XREF “attached_xref.dwg” of the first example as content of the block definition “GEAR”, the “attach_host_dwg.dxf” file is the host DXF document: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons import odafc doc = ezdxf.readfile(\(dqattach_host_dwg.dxf\(dq) gear_xref = doc.blocks.get(\(dqGEAR\(dq) try: xref.embed(gear_xref, load_fn=odafc.readfile) except FileNotFoundError as e: print(str(e)) .EE .UNINDENT .UNINDENT .sp The default loading function for DXF files is the \fI\%ezdxf.readfile()\fP function and doesn’t have to be specified. For the loading function from the \fI\%recover\fP module use a lambda function: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import recover doc = ezdxf.readfile(\(dqattach_host_dxf.dxf\(dq) gear_xref = doc.blocks.get(\(dqGEAR\(dq) try: xref.embed(gear_xref, load_fn=lambda f: recover.readfile(f)[0]) except FileNotFoundError as e: print(str(e)) .EE .UNINDENT .UNINDENT .SS Load Modelspace .sp The \fI\%ezdxf.xref.load_modelspace()\fP function loads the content of the modelspace of the source document into a layout of the target document, the modelspace of the target document is the default target layout. .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 Use this function to combine multiple existing DXF files. If the goal is just to add new entities to an existing document, rather load the source document as a template by \fI\%ezdxf.readfile()\fP, add your content and save the document as a new DXF file with the \fBsaveas()\fP method. .UNINDENT .UNINDENT .sp Merge multiple DXF files: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import colors, transform, xref from ezdxf.math import Matrix44 from ezdxf.render import forms def make_gear(name: str) \-> None: doc = ezdxf.new() doc.layers.add(\(dqGEAR\(dq, color=colors.YELLOW) msp = doc.modelspace() gear = forms.gear( 16, top_width=0.25, bottom_width=0.75, height=0.5, outside_radius=2.5 ) msp.add_lwpolyline(gear, close=True, dxfattribs={\(dqlayer\(dq: \(dqGEAR\(dq}) doc.saveas(name) make_gear(\(dqgear.dxf\(dq) merged_doc = ezdxf.new() for index in range(3): sdoc = ezdxf.readfile(\(dqgear.dxf\(dq) # this could be different DXF files transform.inplace(sdoc.modelspace(), Matrix44.translate(index * 10, 0, 0)) xref.load_modelspace(sdoc, merged_doc) merged_doc.saveas(\(dqmerged.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .SS Load Paperspace .sp The function \fI\%ezdxf.xref.load_paperspace()\fP loads a paperspace layout as a new paperspace layout into the target document. To be clear this function loads \fBonly\fP the content of the paperspace layout, the content of the modelspace isn’t loaded, therefore the loaded VIEWPORT entities show the content of the target modelspace. .SS Write Block .sp The function \fI\%ezdxf.xref.write_block()\fP writes the given entities into the modelspace of a new DXF document, this document can be, but doesn’t have to be used as an external referenced block. .SS Conflict Policies .sp Resources are definitions of layers, linetypes, text\-, dimension\-, mline\- and mleader styles, materials and blocks. .sp A resource conflict occurs when the source and target documents contain elements such as layers, linetypes, text styles and so on that share the same name. .sp Many of the functions shown above support an argument to define the \fI\%ezdxf.xref.ConflictPolicy\fP, that gives you the choice how to handle resource name conflicts. .SS ConflictPolicy.KEEP .sp Keeps the existing resource name of the target document and ignore the resource from the source document. The loaded entities from the source document use the resources defined in the target document and may alter their visual appearance, when the resources are different. .SS ConflictPolicy.XREF_PREFIX .sp This policy handles the resource import like CAD applications by \fBalways\fP renaming the loaded resources to \fI$0$\fP, where \fIxref\fP is the name of source document, the \fI$0$\fP part is a number to create a unique resource name and \fI\fP is the name of the resource itself. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 This policy ALWAYS renames the resource, even if the loaded resource doesn’t have a conflict in the target document. .UNINDENT .UNINDENT .SS ConflictPolicy.NUM_PREFIX .sp This policy renames the loaded resources to \fI$0$\fP only if the resource \fI\fP already exists. The \fI$0$\fP prefix is a number to create a unique resource name and \fI\fP is the name of the resource itself. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 This policy renames the resource ONLY when the loaded resource has a conflict in the target document. .UNINDENT .UNINDENT .SS Load Table Resources .sp Resources are definitions of layers, linetypes, text\-, dimension\-, mline\- and mleader styles, materials and blocks. .sp The \fBLoader\fP class is the low level tool to build a loading operation from simple loading commands. Study the \fI\%source code\fP of the \fBxref\fP module, most of loading commands used above are build upon the \fBLoader\fP class. This example shows how to import layer, linetype, text\- and dimension style definitions: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import xref sdoc = ezdxf.new(setup=True) tdoc = ezdxf.new() # The default conflict policy is ConflictPolicy.KEEP loader = xref.Loader(sdoc, tdoc) # Load all layers: loader.load_layers([layer.dxf.name for layer in sdoc.layers]) # Load specific linetypes: loader.load_linetypes([\(dqCENTER\(dq, \(dqDASHED\(dq, \(dqDASHDOT\(dq]) # Load specific text style: loader.load_text_styles([\(dqOpenSans\(dq, \(dqLiberationMono\(dq]) # Load all DIMENSION styles, this command loads also the dependent text styles: loader.load_dim_styles([dimstyle.dxf.name for dimstyle in sdoc.dimstyles]) # execute all loading commands: loader.execute() tdoc.saveas(\(dqtarget.dxf\(dq) .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Loading a layer does not load the entities which do reference this layer, a layer is not an entity container, it’s just an DXF attribute, see also Basic Concepts: \fI\%Layers\fP\&. .UNINDENT .UNINDENT .SS Tutorial for Image Export .INDENT 0.0 .IP \(bu 2 \fI\%Introduction\fP .IP \(bu 2 \fI\%Common Basics\fP .INDENT 2.0 .IP \(bu 2 \fI\%Frontend Configuration\fP .IP \(bu 2 \fI\%Page Layout\fP .IP \(bu 2 \fI\%Autodetect Page Size\fP .IP \(bu 2 \fI\%Scaling Content\fP .IP \(bu 2 \fI\%Limit Page Size\fP .UNINDENT .IP \(bu 2 \fI\%SVG Export\fP .IP \(bu 2 \fI\%PDF Export\fP .IP \(bu 2 \fI\%PNG Export\fP .IP \(bu 2 \fI\%PLT/HPGL2 Export\fP .IP \(bu 2 \fI\%DXF Export\fP .IP \(bu 2 \fI\%Recorder Backend\fP .UNINDENT .SS Introduction .sp This tutorial shows how to export DXF content of the modelspace or a paperspace as images by the \fI\%drawing\fP add\-on. .sp The tutorial covers the new added backends in \fIezdxf\fP version 1.1: .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.addons.drawing.svg.SVGBackend\fP class for SVG export .IP \(bu 2 \fI\%ezdxf.addons.drawing.pymupdf.PyMuPdfBackend\fP class for PDF and PNG export .IP \(bu 2 \fI\%ezdxf.addons.drawing.hpgl2.PlotterBackend\fP class for PLT/HPGL2 export .IP \(bu 2 \fI\%ezdxf.addons.drawing.dxf.DXFBackend\fP class for flattened DXF export .UNINDENT .sp The tutorial \fBdoes not cover\fP the \fBMatplotlibBackend\fP and \fI\%PyQtBackend\fP, for information about these backends see: .INDENT 0.0 .IP \(bu 2 Howtos for the \fI\%Drawing Add\-on\fP .IP \(bu 2 FAQs at github: \fI\%https://github.com/mozman/ezdxf/discussions/550\fP .UNINDENT .SS Common Basics .sp The rendering process is divided into multiple steps. The frontend resolves the DXF properties and breaks down complex DXF entities into simple drawing primitives which are send to the backend that renders the output format. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons.drawing import Frontend, RenderContext, svg, layout def example_doc(): doc = ezdxf.new() msp = doc.modelspace() x0, y0, x1, y1 = 0, 0, 10, 10 start = (x0, y0) end = (x0 + 1, y0) for color in range(1, 6): msp.add_lwpolyline( [start, (x0, y1), (x1, y1), (x1, y0), end], dxfattribs={\(dqcolor\(dq: color} ) x0 += 1 x1 \-= 1 y0 += 1 y1 \-= 1 start = end end = (x0 + 1, y0) return doc def export(doc): msp = doc.modelspace() # 1. create the render context context = RenderContext(doc) # 2. create the backend backend = svg.SVGBackend() # 3. create the frontend frontend = Frontend(context, backend) # 4. draw the modelspace frontend.draw_layout(msp) # 5. create an A4 page layout, not required for all backends page = layout.Page(210, 297, layout.Units.mm, margins=layout.Margins.all(20)) # 6. get the SVG rendering as string \- this step is backend dependent svg_string = backend.get_string(page) with open(\(dqoutput.svg\(dq, \(dqwt\(dq, encoding=\(dqutf8\(dq) as fp: fp.write(svg_string) if __name__ == \(dq__main__\(dq: export(example_doc()) .EE .UNINDENT .UNINDENT .sp The exported SVG shows a spiral centered on an A4 page with a margin of 20mm, notice the background has a dark color like the usual background of the modelspace: [image] .SS Frontend Configuration .sp The \fI\%Configuration\fP object configures the rendering process. This example changes the background color from dark grey to white and renders all lines black. .sp Add the \fBconfig\fP module to imports: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons.drawing import Frontend, RenderContext, svg, layout, config .EE .UNINDENT .UNINDENT .sp Create a new configuration and override the background and color policy between the 2nd and the 3rd step: .INDENT 0.0 .INDENT 3.5 .sp .EX # 2. create the backend backend = svg.SVGBackend() # create a new configuration for a white background and and a black foreground color cfg = config.Configuration( background_policy=config.BackgroundPolicy.WHITE, color_policy=config.ColorPolicy.BLACK, ) # 3. create the frontend frontend = Frontend(context, backend, config=cfg) .EE .UNINDENT .UNINDENT .sp The new exported SVG has a white background and all lines are black: [image] .sp There are many configuration options: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%LineweightPolicy\fP \- relative, absolute or relative fixed lineweight .IP \(bu 2 \fI\%LinePolicy\fP \- solid or accurate linetypes .IP \(bu 2 \fI\%HatchPolicy\fP \- normal, ignore, only outlines or always solid fill .IP \(bu 2 \fI\%ColorPolicy\fP \- color, black, white, monochrome, … .IP \(bu 2 \fI\%BackgroundPolicy\fP \- default, black, white, off (transparent) and custom .IP \(bu 2 \fI\%TextPolicy\fP \- filling, outline, ignore, … .IP \(bu 2 \fI\%ProxyGraphicPolicy\fP \- ignore, show, prefer .IP \(bu 2 lineweight scaling factor .IP \(bu 2 minimal lineweight .IP \(bu 2 \fImax_flattening_distance\fP for curve approximation .IP \(bu 2 and more … .UNINDENT .UNINDENT .UNINDENT .sp All configuration options are documented here: \fI\%Configuration\fP\&. .SS Page Layout .sp The \fI\%Page\fP object defines the output page for some backends (SVG, PDF, PNG, PLT). .sp A page is defined by width and height in a given length unit. The supported length units are millimeters (mm), inch (in), point (1 pt is 1/72 in) and pixels (1 px is 1/96 in). .sp It’s possible to autodetect the page size from the content or fit the content onto the page. In both cases the margin values are used to create space between the content and the page borders. The content is centered in the remaining space without margins. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 None of the backends crop the content automatically, the margin values are just calculation values! .UNINDENT .UNINDENT .SS Autodetect Page Size .sp The required page size is auto\-detected by setting the width and/or height to 0. By default the scaling factor is 1, so 1 drawing unit is 1 page unit. The content is fit to page by default and the outcome is shown in the previous examples. .sp This example shows the output when the scale should be 1:1, 1 drawing unit is 1 page unit (mm): .INDENT 0.0 .INDENT 3.5 .sp .EX # auto\-detect page size and 2mm margins on all sides page = layout.Page(0, 0, layout.Units.mm, margins=layout.Margins.all(2)) # scale content by 1, do not fit content to page svg_string = backend.get_string( page, settings=layout.Settings(scale=1, fit_page=False) ) .EE .UNINDENT .UNINDENT .sp The page has a size of 14x14mm, a content size of 10x10mm and 2mm margins on all sides. [image] .SS Scaling Content .sp Scaling the content by factor 10 means, 10 page units represent 1 drawing unit, which is a scale of 10:1 and only uniform scaling is supported. .INDENT 0.0 .INDENT 3.5 .sp .EX def export_2(doc): backend = make_backend(doc) # auto\-detect page size and 2mm margins on all sides page = layout.Page(0, 0, layout.Units.mm, margins=layout.Margins.all(2)) # scale content by 10, do not fit content to page svg_string = backend.get_string( .EE .UNINDENT .UNINDENT .sp The page has a size of 104x104mm, a content size of 100x100mm and 2mm margins on all sides. [image] .SS Limit Page Size .sp The page arguments \fImax_width\fP and \fImax_height\fP can limit the page size in auto\-detection mode, e.g. most plotter devices can only print upto a width of 900mm. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Page\fP class .IP \(bu 2 \fI\%Margins\fP class .IP \(bu 2 \fI\%Settings\fP class .UNINDENT .UNINDENT .UNINDENT .SS SVG Export .sp The steps to export a SVG by the \fI\%SVGBackend\fP are show in the first example, the configuration of the frontend and the page setup are shown in the previous sections. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP 1. 3 Create the render context .IP 2. 3 Create the backend .IP 3. 3 Create and configure the frontend .IP 4. 3 Draw the content .IP 5. 3 Setup the page layout .IP 6. 3 Create the SVG output string .UNINDENT .UNINDENT .UNINDENT .sp This is the same code as for the first example: .INDENT 0.0 .INDENT 3.5 .sp .EX def export(doc): msp = doc.modelspace() # 1. create the render context context = RenderContext(doc) # 2. create the backend backend = svg.SVGBackend() # 3. create the frontend frontend = Frontend(context, backend) # 4. draw the modelspace frontend.draw_layout(msp) # 5. create an A4 page layout, not required for all backends page = layout.Page(210, 297, layout.Units.mm, margins=layout.Margins.all(20)) # 6. get the SVG rendering as string \- this step is backend dependent svg_string = backend.get_string(page) with open(\(dqoutput.svg\(dq, \(dqwt\(dq, encoding=\(dqutf8\(dq) as fp: fp.write(svg_string) .EE .UNINDENT .UNINDENT .sp The SVG backend flips the coordinates along the y\-axis and transforms the content into a compact integer coordinate space and produces therefore a small file size but therefore the output coordinates are different to the DXF coordinates. .SS PDF Export .sp The PDF export requires the the \fI\%PyMuPdf\fP package to be installed. .sp The steps to export a PDF are very similar to SVG, except for the \fI\%PyMuPdfBackend\fP class and the backend returns bytes and not a string: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP 1. 3 Create the render context .IP 2. 3 Create the backend .IP 3. 3 Create and configure the frontend .IP 4. 3 Draw the content .IP 5. 3 Setup the page layout .IP 6. 3 Create the SVG output string .UNINDENT .UNINDENT .UNINDENT .sp Import the \fBpymupdf\fP backend module: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons.drawing import Frontend, RenderContext, pymupdf, layout, config .EE .UNINDENT .UNINDENT .sp The export function: .INDENT 0.0 .INDENT 3.5 .sp .EX def export_dark_bg(doc): msp = doc.modelspace() # 1. create the render context context = RenderContext(doc) # 2. create the backend backend = pymupdf.PyMuPdfBackend() # 3. create the frontend frontend = Frontend(context, backend) # 4. draw the modelspace frontend.draw_layout(msp) # 5. create an A4 page layout page = layout.Page(210, 297, layout.Units.mm, margins=layout.Margins.all(20)) # 6. get the PDF rendering as bytes pdf_bytes = backend.get_pdf_bytes(page) with open(\(dqpdf_dark_bg.pdf\(dq, \(dqwb\(dq) as fp: fp.write(pdf_bytes) .EE .UNINDENT .UNINDENT [image] .sp The PDF has is dark background for the modelspace by default and color index 7 is white. Create a frontend configuration and override the \fBBackgroundPolicy\fP to get a white background: .INDENT 0.0 .INDENT 3.5 .sp .EX # 3. create and configure the frontend cfg = config.Configuration(background_policy=config.BackgroundPolicy.WHITE) frontend = Frontend(context, backend, config=cfg) .EE .UNINDENT .UNINDENT .sp Now the exported PDF has a white background and color index 7 is black: [image] .SS PNG Export .sp The PNG export is done by the \fI\%PyMuPdfBackend\fP class and differs only in the method to get the PNG data bytes: .INDENT 0.0 .INDENT 3.5 .sp .EX # 6. get the PNG rendering as bytes png_bytes = backend.get_pixmap_bytes(page, fmt=\(dqpng\(dq, dpi=96) with open(\(dqpng_white_bg.png\(dq, \(dqwb\(dq) as fp: fp.write(png_bytes) .EE .UNINDENT .UNINDENT .sp The \fBpymupdf\fP backend supports multiple image formats: .TS center; |l|l|. _ T{ png T} T{ Portable Network Graphics T} _ T{ ppm T} T{ Portable Pixmap (no alpha channel) T} _ T{ pbm T} T{ Portable Bitmap (no alpha channel) T} _ .TE .SS PLT/HPGL2 Export .sp The \fI\%PlotterBackend\fP creates HPGL/2 plot files for output on raster plotters. The \fBPlotterBackend\fP is designed to print on white paper, so the background color is always white and color index 7 is black by default. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The plot files are only tested by the plot file viewer \fI\%ViewCompanion Standard\fP but not on real hardware \- please use with care and give feedback. .UNINDENT .UNINDENT .sp The PLT/HPGL2 export is very similar to the SVG export: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons.drawing import Frontend, RenderContext, hpgl2, layout def export(doc): msp = doc.modelspace() # 1. create the render context context = RenderContext(doc) # 2. create the backend backend = hpgl2.PlotterBackend() # 3. create the frontend frontend = Frontend(context, backend) # 4. draw the modelspace frontend.draw_layout(msp) # 5. create an A4 page layout page = layout.Page(210, 297, layout.Units.mm, margins=layout.Margins.all(20)) # 6. get the HPGL2 rendering as bytes plt_bytes = backend.get_bytes(page) with open(\(dqoutput_01.plt\(dq, \(dqwb\(dq) as fp: fp.write(plt_bytes) .EE .UNINDENT .UNINDENT [image] .sp The HPGL/2 viewer does not show the margins around the content, but most construction drawings draw the page borders around the content. .sp The \fBPlotterBackend\fP has some quality preset methods to get the HPGL/2 data: .INDENT 0.0 .IP \(bu 2 \fI\%compatible()\fP .IP \(bu 2 \fI\%low_quality()\fP .IP \(bu 2 \fI\%normal_quality()\fP (default) .IP \(bu 2 \fI\%high_quality()\fP .UNINDENT .sp The difference are mostly the floating point precision and the usage of Bézier curves, but the Bézier curves are approximated by plotter drivers (even by HP drivers), so there is no real quality improvement, but curves need less space than approximated polylines so the file size is smaller. .sp Very old plotter may not support Bézier curves and floating point coordinates, for these plotters the \fBcompatible()\fP method exports only polylines and integer coordinates. .sp Usage: .INDENT 0.0 .INDENT 3.5 .sp .EX # 6. get the HPGL2 rendering as bytes plt_bytes = backend.high_quality(page) .EE .UNINDENT .UNINDENT .SS DXF Export .sp The \fI\%DXFBackend\fP exports the content as DXF primitives: POINT, LINE, LWPOLYLINE, SPLINE and HATCH. All blocks are exploded, text is rendered as filled polygons represented by the HATCH entity and arcs are represented by SPLINE entities (internal Bèzier curve representation). .sp This backend was added to convert HPGL/2 files to DXF files, because the \fBhpgl2\fP add\-on reuses the backends of the \fBdrawing\fP add\-on for export. Maybe it is useful for other tasks too. .sp This backend works different than the previous. There is no page setup and everything is rendered into a given layout of a DXF document: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons.drawing import Frontend, RenderContext, dxf def export(doc): export_doc = ezdxf.new() msp = doc.modelspace() # 1. create the render context context = RenderContext(doc) # 2. create the backend backend = dxf.DXFBackend(export_doc.modelspace()) # 3. create the frontend frontend = Frontend(context, backend) # 4. draw the modelspace frontend.draw_layout(msp) # 5. save or return DXF document export_doc.saveas(\(dqoutput_01.dxf\(dq) .EE .UNINDENT .UNINDENT .SS Recorder Backend .sp The \fI\%Recorder\fP backend is an intermediate layer to record the drawing commands of the \fI\%Frontend\fP class. The \fI\%Player\fP object can replay this records on any other backend class but also provides some additional features like bounding box detection, content transformation and cropping. .sp The SVG/PDF/PLT backends use this intermediate layer internally to transform and place the content. .SH EXTERNAL REFERENCES (XREF) .sp New in version 1.1. .sp Attached XREFs are links to the modelspace of a specified drawing file. Changes made to the referenced drawing are automatically reflected in the current drawing when it’s opened or if the XREF is reloaded. .sp XREFs can be nested within other XREFs: that is, you can attach an XREF that contains another XREF. You can attach as many copies of an XREF as you want, and each copy can have a different position, scale, and rotation. .sp You can also overlay an XREF on your drawing. Unlike an attached XREF, an overlaid XREF is not included when the drawing is itself attached or overlaid as an XREF to another drawing. .SS DXF Files as Attached XREFs .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 AutoCAD can only display DWG files as attached XREFs but \fIezdxf\fP can only create DXF files. Consequently, any DXF file attached as an XREF to a DXF document must be converted to DWG in order to be viewed in AutoCAD. Fortunately, other CAD applications are more cooperative, BricsCAD has no problem displaying DXF files as XREFs, although it is not possible to attach a DXF file as an XREF in the BricsCAD application itself. .UNINDENT .UNINDENT .sp The \fI\%ezdxf.xref\fP module provides an interface for working with XREFs. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%attach()\fP \- attach a DXF/DWG file as XREF .IP \(bu 2 \fI\%detach()\fP \- detach a BLOCK definition as XREF .IP \(bu 2 \fI\%embed()\fP \- embed an XREF as a BLOCK definition .IP \(bu 2 \fI\%dxf_info()\fP \- scans a DXF file for basic settings and properties .UNINDENT .UNINDENT .UNINDENT .sp For loading the content of DWG files is a loading function required, which loads the DWG file as \fBDrawing\fP document. The \fI\%odafc\fP add\-on module provides such a function: \fI\%readfile()\fP .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for External References\fP .UNINDENT .UNINDENT .UNINDENT .SS XREF Structures .sp An XREF is a normal block definition located in the BLOCKS section with special flags set and a filename to the referenced DXF/DWG file and without any content, the block content is the modelspace of the referenced file. An XREF can be referenced (inserted) by one or multiple INSERT entities. .sp Find block definitions in the BLOCKS section: .INDENT 0.0 .INDENT 3.5 .sp .EX for block_layout in doc.blocks: block = block_layout.block # the BLOCK entity if block.is_xref: handle_xref(block_layout) elif block.is_xref_overlay: handle_xref_overlay(block_layout) .EE .UNINDENT .UNINDENT .sp Find XREF references in modelspace: .INDENT 0.0 .INDENT 3.5 .sp .EX for insert in msp.query(\(dqINSERT\(dq): if insert.is_xref: handle_xref_reference(insert) # ... or get the XREF definition block_layout = insert.block() if block_layout is not None: handle_xref_definition(block_layout) .EE .UNINDENT .UNINDENT .sp Use the helper function \fI\%define()\fP to create your own XREF definition, the \fI\%attach()\fP creates this definition automatically and raises an exception if the block already exists. .SS Supported Entities .sp The current implementation supports only copyable and transformable DXF entities, these are all basic entity types as LINE, CIRCLE, … and block references and their associated required table entries and objects from the OBJECTS section. .sp Unsupported are all ACIS based entities, the ACAD_TABLE entity, preserved unknown entities wrapped in a \fBDXFTagStorage\fP class, proxy entities and objects. Support for these entities may be added in a later version of \fIezdxf\fP\&. Unsupported entities are ignored and do not raise exceptions. .sp Most document features stored in the HEADER and OBJECTS sections are not supported by this module like GROUPS, LAYER_FILTER, GEODATA, SUN. .SS Importing Data and Resources .sp The \fI\%ezdxf.xref\fP module replaces the \fI\%Importer\fP add\-on. .sp The basic functionality of the \fI\%ezdxf.xref\fP module is loading data from external files including their required resources, which is an often requested feature by users for importing data from other DXF files into the current document. .sp The \fBImporter\fP add\-on was very limited and removed many resources, where the \fI\%ezdxf.xref\fP module tries to preserve as much information as possible. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%load_modelspace()\fP \- loads the modelspace content from another DXF document .IP \(bu 2 \fI\%load_paperspace()\fP \- loads a paperspace layout from another DXF document .IP \(bu 2 \fI\%write_block()\fP \- writes entities into the modelspace of a new DXF document .IP \(bu 2 \fI\%Loader\fP \- low level loading interface .UNINDENT .UNINDENT .UNINDENT .SS High Level Functions .INDENT 0.0 .TP .B ezdxf.xref.attach(doc: \fI\%Drawing\fP, *, block_name: str, filename: str, insert: \fI\%UVec\fP = (0, 0, 0), scale: float = 1.0, rotation: float = 0.0, overlay=False) -> Insert Attach the file \fIfilename\fP to the host document as external reference (XREF) and creates a default block reference for the XREF in the modelspace of the document. The function raises an \fBXrefDefinitionError\fP exception if the block definition already exist, but an XREF can be inserted multiple times by adding additional block references: .INDENT 7.0 .INDENT 3.5 .sp .EX msp.add_blockref(block_name, insert=another_location) .EE .UNINDENT .UNINDENT .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 If the XREF has different drawing units than the host document, the scale factor between these units must be applied as a uniform scale factor to the block reference! Unfortunately the XREF drawing units can only be detected by scanning the HEADER section of a document by the function \fI\%dxf_info()\fP and is therefore not done automatically by this function. Advice: always use the same units for all drawings of a project! .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdoc\fP – host DXF document .IP \(bu 2 \fBblock_name\fP – name of the XREF definition block .IP \(bu 2 \fBfilename\fP – file name of the XREF .IP \(bu 2 \fBinsert\fP – location of the default block reference .IP \(bu 2 \fBscale\fP – uniform scaling factor .IP \(bu 2 \fBrotation\fP – rotation angle in degrees .IP \(bu 2 \fBoverlay\fP – creates an XREF overlay if \fBTrue\fP and an XREF attachment otherwise .UNINDENT .TP .B Returns default block reference for the XREF .TP .B Return type \fI\%Insert\fP .TP .B Raises \fBXrefDefinitionError\fP – block with same name exist .UNINDENT .sp New in version 1.1. .UNINDENT .INDENT 0.0 .TP .B ezdxf.xref.define(doc: \fI\%Drawing\fP, block_name: str, filename: str, overlay=False) -> None Add an external reference (xref) definition to a document. .sp XREF attachment types: .INDENT 7.0 .IP \(bu 2 attached: the XREF that’s inserted into this drawing is also present in a document to which this document is inserted as an XREF. .IP \(bu 2 overlay: the XREF that’s inserted into this document is \fBnot\fP present in a document to which this document is inserted as an XREF. .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdoc\fP – host document .IP \(bu 2 \fBblock_name\fP – name of the xref block .IP \(bu 2 \fBfilename\fP – external reference filename .IP \(bu 2 \fBoverlay\fP – creates an XREF overlay if \fBTrue\fP and an XREF attachment otherwise .UNINDENT .TP .B Raises \fBXrefDefinitionError\fP – block with same name exist .UNINDENT .sp New in version 1.1. .UNINDENT .INDENT 0.0 .TP .B ezdxf.xref.detach(block: BlockLayout, *, xref_filename: str | PathLike, overlay=False) -> \fI\%Drawing\fP Write the content of \fIblock\fP into the modelspace of a new DXF document and convert \fIblock\fP to an external reference (XREF). The new DXF document has to be written by the caller: \fBxref_doc.saveas(xref_filename)\fP\&. This way it is possible to convert the DXF document to DWG by the \fI\%odafc\fP add\-on if necessary: .INDENT 7.0 .INDENT 3.5 .sp .EX xref_doc = xref.detach(my_block, \(dqmy_block.dwg\(dq) odafc.export_dwg(xref_doc, \(dqmy_block.dwg\(dq) .EE .UNINDENT .UNINDENT .sp It’s recommended to clean up the entity database of the host document afterwards: .INDENT 7.0 .INDENT 3.5 .sp .EX doc.entitydb.purge() .EE .UNINDENT .UNINDENT .sp The function does not create any block references. These references should already exist and do not need to be changed since references to blocks and XREFs are the same. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBblock\fP – block definition to detach .IP \(bu 2 \fBxref_filename\fP – name of the external referenced file .IP \(bu 2 \fBoverlay\fP – creates an XREF overlay if \fBTrue\fP and an XREF attachment otherwise .UNINDENT .UNINDENT .sp New in version 1.1. .UNINDENT .INDENT 0.0 .TP .B ezdxf.xref.dxf_info(filename: str | PathLike) -> DXFInfo Scans the HEADER section of a DXF document and returns a \fBDXFInfo\fP object, which contains information about the DXF version, text encoding, drawing units and insertion base point. .INDENT 7.0 .TP .B Raises \fBIOError\fP – not a DXF file or a generic IO error .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.xref.embed(xref: BlockLayout, *, load_fn: Callable[[str], \fI\%Drawing\fP] | None = None, search_paths: Iterable[Path | str] = tuple(), conflict_policy=ConflictPolicy.XREF_PREFIX) -> None Loads the modelspace of the XREF as content into a block layout. .sp The loader function loads the XREF as \fIDrawing\fP object, by default the function \fI\%ezdxf.readfile()\fP is used to load DXF files. To load DWG files use the \fI\%readfile()\fP function from the \fI\%ezdxf.addons.odafc\fP add\-on. The \fI\%ezdxf.recover.readfile()\fP function is very robust for reading DXF files with errors. .sp If the XREF path isn’t absolute the XREF is searched in the folder of the host DXF document and in the \fIsearch_path\fP folders. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBxref\fP – \fBBlockLayout\fP of the XREF document .IP \(bu 2 \fBload_fn\fP – function to load the content of the XREF as \fIDrawing\fP object .IP \(bu 2 \fBsearch_paths\fP – list of folders to search for XREFS, default is the folder of the host document or the current directory if no filepath is set .IP \(bu 2 \fBconflict_policy\fP – how to resolve name conflicts .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBXrefDefinitionError\fP – argument \fIxref\fP is not a XREF definition .IP \(bu 2 \fBFileNotFoundError\fP – XREF file not found .IP \(bu 2 \fI\%DXFVersionError\fP – cannot load a XREF with a newer DXF version than the host document, try the \fI\%odafc\fP add\-on to downgrade the XREF document or upgrade the host document .UNINDENT .UNINDENT .sp New in version 1.1. .UNINDENT .INDENT 0.0 .TP .B ezdxf.xref.load_modelspace(sdoc: \fI\%Drawing\fP, tdoc: \fI\%Drawing\fP, filter_fn: Callable[[DXFEntity], bool] | None = None, conflict_policy=ConflictPolicy.KEEP) -> None Loads the modelspace content of the source document into the modelspace of the target document. The filter function \fIfilter_fn\fP gets every source entity as input and returns \fBTrue\fP to load the entity or \fBFalse\fP otherwise. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsdoc\fP – source document .IP \(bu 2 \fBtdoc\fP – target document .IP \(bu 2 \fBfilter_fn\fP – optional function to filter entities from the source modelspace .IP \(bu 2 \fBconflict_policy\fP – how to resolve name conflicts .UNINDENT .UNINDENT .sp New in version 1.1. .UNINDENT .INDENT 0.0 .TP .B ezdxf.xref.load_paperspace(psp: Paperspace, tdoc: \fI\%Drawing\fP, filter_fn: Callable[[DXFEntity], bool] | None = None, conflict_policy=ConflictPolicy.KEEP) -> None Loads the paperspace layout \fIpsp\fP into the target document. The filter function \fIfilter_fn\fP gets every source entity as input and returns \fBTrue\fP to load the entity or \fBFalse\fP otherwise. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpsp\fP – paperspace layout to load .IP \(bu 2 \fBtdoc\fP – target document .IP \(bu 2 \fBfilter_fn\fP – optional function to filter entities from the source paperspace layout .IP \(bu 2 \fBconflict_policy\fP – how to resolve name conflicts .UNINDENT .UNINDENT .sp New in version 1.1. .UNINDENT .INDENT 0.0 .TP .B ezdxf.xref.write_block(entities: Sequence[DXFEntity], *, origin: \fI\%UVec\fP = (0, 0, 0)) -> \fI\%Drawing\fP Write \fIentities\fP into the modelspace of a new DXF document. .sp This function is called “write_block” because the new DXF document can be used as an external referenced block. This function is similar to the WBLOCK command in CAD applications. .sp Virtual entities are not supported, because each entity needs a real database\- and owner handle. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentities\fP – DXF entities to write .IP \(bu 2 \fBorigin\fP – block origin, defines the point in the modelspace which will be inserted at the insert location of the block reference .UNINDENT .TP .B Raises \fBEntityError\fP – virtual entities are not supported .UNINDENT .sp New in version 1.1. .UNINDENT .SS Conflict Policy .INDENT 0.0 .TP .B class ezdxf.xref.ConflictPolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) These conflict policies define how to handle resource name conflicts. .sp New in version 1.1. .INDENT 7.0 .TP .B KEEP Keeps the existing resource name of the target document and ignore the resource from the source document. .UNINDENT .INDENT 7.0 .TP .B XREF_PREFIX This policy handles the resource import like CAD applications by \fBalways\fP renaming the loaded resources to \fI$0$\fP, where \fIxref\fP is the name of source document, the \fI$0$\fP part is a number to create a unique resource name and \fI\fP is the name of the resource itself. .UNINDENT .INDENT 7.0 .TP .B NUM_PREFIX This policy renames the loaded resources to \fI$0$\fP only if the resource \fI\fP already exists. The \fI$0$\fP prefix is a number to create a unique resource name and \fI\fP is the name of the resource itself. .UNINDENT .UNINDENT .SS Low Level Loading Interface .sp The \fI\%Loader\fP class is the basic building block for loading entities and resources. The class manages a list of loading commands which is executed at once by calling the \fI\%Loader.execute()\fP method. It is important to execute the commands at once to get a consistent renaming of resources when using resource name prefixes otherwise the loaded resources would get a new unique name at each loading process even when the resources are loaded from the same document. .INDENT 0.0 .TP .B class ezdxf.xref.Loader(sdoc: \fI\%Drawing\fP, tdoc: \fI\%Drawing\fP, conflict_policy=ConflictPolicy.KEEP) Load entities and resources from the source DXF document \fIsdoc\fP into the target DXF document. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsdoc\fP – source DXF document .IP \(bu 2 \fBtdoc\fP – target DXF document .IP \(bu 2 \fBconflict_policy\fP – \fI\%ConflictPolicy\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B load_modelspace(target_layout: BaseLayout | None = None, filter_fn: Callable[[DXFEntity], bool] | None = None) -> None Loads the content of the modelspace of the source document into a layout of the target document, the modelspace of the target document is the default target layout. The filter function \fIfilter_fn\fP is used to skip source entities, the function should return \fBFalse\fP for entities to ignore and \fBTrue\fP otherwise. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtarget_layout\fP – target layout can be any layout: modelspace, paperspace layout or block layout. .IP \(bu 2 \fBfilter_fn\fP – function to filter source entities .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B load_paperspace_layout(psp: Paperspace, filter_fn: Callable[[DXFEntity], bool] | None = None) -> None Loads a paperspace layout as a new paperspace layout into the target document. If a paperspace layout with same name already exists the layout will be renamed to “ (2)” or “ (3)” and so on. The filter function \fIfilter_fn\fP is used to skip source entities, the function should return \fBFalse\fP for entities to ignore and \fBTrue\fP otherwise. .sp The content of the modelspace which may be displayed through a VIEWPORT entity will \fBnot\fP be loaded! .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpsp\fP – the source paperspace layout .IP \(bu 2 \fBfilter_fn\fP – function to filter source entities .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B load_paperspace_layout_into(psp: Paperspace, target_layout: BaseLayout, filter_fn: Callable[[DXFEntity], bool] | None = None) -> None Loads the content of a paperspace layout into an existing layout of the target document. The filter function \fIfilter_fn\fP is used to skip source entities, the function should return \fBFalse\fP for entities to ignore and \fBTrue\fP otherwise. .sp The content of the modelspace which may be displayed through a VIEWPORT entity will \fBnot\fP be loaded! .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpsp\fP – the source paperspace layout .IP \(bu 2 \fBtarget_layout\fP – target layout can be any layout: modelspace, paperspace layout or block layout. .IP \(bu 2 \fBfilter_fn\fP – function to filter source entities .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B load_block_layout(block_layout: BlockLayout) -> None Loads a block layout (block definition) as a new block layout into the target document. If a block layout with the same name exists the conflict policy will be applied. This method cannot load modelspace or paperspace layouts. .INDENT 7.0 .TP .B Parameters \fBblock_layout\fP – the source block layout .UNINDENT .UNINDENT .INDENT 7.0 .TP .B load_block_layout_into(block_layout: BlockLayout, target_layout: BaseLayout) -> None Loads the content of a block layout (block definition) into an existing layout of the target document. This method cannot load the content of modelspace or paperspace layouts. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBblock_layout\fP – the source block layout .IP \(bu 2 \fBtarget_layout\fP – target layout can be any layout: modelspace, paperspace layout or block layout. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B load_layers(names: Sequence[str]) -> None Loads the layers defined by the argument \fInames\fP into the target document. In the case of a name conflict the conflict policy will be applied. .UNINDENT .INDENT 7.0 .TP .B load_linetypes(names: Sequence[str]) -> None Loads the linetypes defined by the argument \fInames\fP into the target document. In the case of a name conflict the conflict policy will be applied. .UNINDENT .INDENT 7.0 .TP .B load_text_styles(names: Sequence[str]) -> None Loads the TEXT styles defined by the argument \fInames\fP into the target document. In the case of a name conflict the conflict policy will be applied. .UNINDENT .INDENT 7.0 .TP .B load_dim_styles(names: Sequence[str]) -> None Loads the DIMENSION styles defined by the argument \fInames\fP into the target document. In the case of a name conflict the conflict policy will be applied. .UNINDENT .INDENT 7.0 .TP .B load_mline_styles(names: Sequence[str]) -> None Loads the MLINE styles defined by the argument \fInames\fP into the target document. In the case of a name conflict the conflict policy will be applied. .UNINDENT .INDENT 7.0 .TP .B load_mleader_styles(names: Sequence[str]) -> None Loads the MULTILEADER styles defined by the argument \fInames\fP into the target document. In the case of a name conflict the conflict policy will be applied. .UNINDENT .INDENT 7.0 .TP .B load_materials(names: Sequence[str]) -> None Loads the MATERIALS defined by the argument \fInames\fP into the target document. In the case of a name conflict the conflict policy will be applied. .UNINDENT .INDENT 7.0 .TP .B execute(xref_prefix: str = \(aq\(aq) -> None Execute all loading commands. The \fIxref_prefix\fP string is used as XREF name when the conflict policy \fI\%ConflictPolicy.XREF_PREFIX\fP is applied. .UNINDENT .UNINDENT .SH HOWTO .sp The Howto section show how to accomplish specific tasks with \fIezdxf\fP in a straight forward way without teaching basics or internals, if you are looking for more information about the ezdxf internals look at the \fI\%Reference\fP section or if you want to learn how to use \fIezdxf\fP go to the \fI\%Tutorials\fP section or to the \fI\%Basic Concepts\fP section. .SS General Document .sp General preconditions: .INDENT 0.0 .INDENT 3.5 .sp .EX import sys import ezdxf try: doc = ezdxf.readfile(\(dqyour_dxf_file.dxf\(dq) except IOError: print(f\(dqNot a DXF file or a generic I/O error.\(dq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(dqInvalid or corrupted DXF file.\(dq) sys.exit(2) msp = doc.modelspace() .EE .UNINDENT .UNINDENT .sp This works well with DXF files from trusted sources like AutoCAD or BricsCAD, for loading DXF files with minor or major flaws look at the \fI\%ezdxf.recover\fP module. .SS Load DXF Files with Structure Errors .sp If you know the files you will process have most likely minor or major flaws, use the \fI\%ezdxf.recover\fP module: .INDENT 0.0 .INDENT 3.5 .sp .EX import sys from ezdxf import recover try: # low level structure repair: doc, auditor = recover.readfile(name) except IOError: print(f\(dqNot a DXF file or a generic I/O error.\(dq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(dqInvalid or corrupted DXF file: {name}.\(dq) sys.exit(2) # DXF file can still have unrecoverable errors, but this is maybe # just a problem when saving the recovered DXF file. if auditor.has_errors: print(f\(dqFound unrecoverable errors in DXF file: {name}.\(dq) auditor.print_error_report() .EE .UNINDENT .UNINDENT .sp For more loading scenarios follow the link: \fI\%ezdxf.recover\fP .SS Set/Get Header Variables .sp \fIezdxf\fP has an interface to get and set HEADER variables: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(dqVarName\(dq] = value value = doc.header[\(dqVarName\(dq] .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%HeaderSection\fP and online documentation from Autodesk for available \fI\%header variables\fP\&. .UNINDENT .UNINDENT .SS Set DXF Drawing Units .sp The header variable $INSUNITS defines the drawing units for the modelspace and therefore for the DXF document if no further settings are applied. The most common units are 6 for meters and 1 for inches. .sp Use this HEADER variables to setup the default units for CAD applications opening the DXF file. This setting is not relevant for \fIezdxf\fP API calls, which are unitless for length values and coordinates and decimal degrees for angles (in most cases). .sp Sets drawing units: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(dq$INSUNITS\(dq] = 6 .EE .UNINDENT .UNINDENT .sp For more information see section \fI\%DXF Units\fP\&. .SS Create More Readable DXF Files (DXF Pretty Printer) .sp DXF files are plain text files, you can open this files with every text editor which handles bigger files. But it is not really easy to get quick the information you want. .sp Create a more readable HTML file (DXF Pretty Printer): .INDENT 0.0 .INDENT 3.5 .sp .EX # Call as executable script from the command line: ezdxf pp FILE [FILE ...] # Call as module on Windows: py \-m ezdxf pp FILE [FILE ...] # Call as module on Linux/Mac python3 \-m ezdxf pp FILE [FILE ...] .EE .UNINDENT .UNINDENT .sp This creates a HTML file with a nicer layout than a plain text file, and handles are links between DXF entities, this simplifies the navigation between the DXF entities. .INDENT 0.0 .INDENT 3.5 .sp .EX usage: ezdxf pp [\-h] [\-o] [\-r] [\-x] [\-l] FILE [FILE ...] positional arguments: FILE DXF files pretty print optional arguments: \-h, \-\-help show this help message and exit \-o, \-\-open open generated HTML file with the default web browser \-r, \-\-raw raw mode \- just print tags, no DXF structure interpretation \-x, \-\-nocompile don\(aqt compile points coordinates into single tags (only in raw mode) \-l, \-\-legacy legacy mode \- reorders DXF point coordinates .EE .UNINDENT .UNINDENT .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 This does not render the graphical content of the DXF file to a HTML canvas element. .UNINDENT .UNINDENT .SS Calculate Extents for the Modelspace .sp Since \fIezdxf\fP v0.16 exist a \fI\%ezdxf.bbox\fP module to calculate bounding boxes for DXF entities. This module makes the extents calculation very easy, but read the documentation for the \fI\%bbox\fP module to understand its limitations. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import bbox doc = ezdxf.readfile(\(dqyour.dxf\(dq) msp = doc.modelspace() extents = bbox.extents(msp) .EE .UNINDENT .UNINDENT .sp The returned \fIextents\fP is a \fI\%ezdxf.math.BoundingBox\fP object. .SS Set Initial View/Zoom for the Modelspace .sp To show an arbitrary location of the modelspace centered in the CAD application window, set the \fB\(aq*Active\(aq\fP VPORT to this location. The DXF attribute \fBdxf.center\fP defines the location in the modelspace, and the \fBdxf.height\fP specifies the area of the modelspace to view. Shortcut function: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.set_modelspace_vport(height=10, center=(10, 10)) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%ezdxf.zoom\fP module is another way to set the initial modelspace view. .UNINDENT .UNINDENT .sp Setting the initial view to the extents of all entities in the modelspace: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import zoom doc = ezdxf.readfile(\(dqyour.dxf\(dq) msp = doc.modelspace() zoom.extents(msp) .EE .UNINDENT .UNINDENT .sp Setting the initial view to the extents of just some entities: .INDENT 0.0 .INDENT 3.5 .sp .EX lines = msp.query(\(dqLINES\(dq) zoom.objects(lines) .EE .UNINDENT .UNINDENT .sp The \fI\%zoom\fP module also works for paperspace layouts. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%zoom\fP module uses the \fI\%bbox\fP module to calculate the bounding boxes for DXF entities. Read the documentation for the \fI\%bbox\fP module to understand its limitations and the bounding box calculation for large documents can take a while! .UNINDENT .UNINDENT .SS Hide the UCS Icon .sp The visibility of the UCS icon is controlled by the DXF \fI\%ucs_icon\fP attribute of the \fI\%VPort\fP entity: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 bit 0: 0=hide, 1=show .IP \(bu 2 bit 1: 0=display in lower left corner, 1=display at origin .UNINDENT .UNINDENT .UNINDENT .sp The state of the UCS icon can be set in conjunction with the initial \fI\%VPort\fP of the model space, this code turns off the UCS icon: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.set_modelspace_vport(10, center=(10, 10), dxfattribs={\(dqucs_icon\(dq: 0}) .EE .UNINDENT .UNINDENT .sp Alternative: turn off UCS icons for all \fBVPort\fP entries in the active viewport configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX for vport in doc.viewports.get_config(\(dq*Active\(dq): vport.dxf.ucs_icon = 0 .EE .UNINDENT .UNINDENT .SS Show Lineweights in DXF Viewers .sp By default lines and curves are shown without lineweights in DXF viewers. By setting the header variable $LWDISPLAY to 1 the DXF viewer should display lineweights, if supported by the viewer. .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(dq$LWDISPLAY\(dq] = 1 .EE .UNINDENT .UNINDENT .SS Add \fIezdxf\fP Resources to Existing DXF Document .sp Add all \fIezdxf\fP specific resources (line types, text\- and dimension styles) to an existing DXF document: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.tools.standards import setup_drawing doc = ezdxf.readfile(\(dqyour.dxf\(dq) setup_drawing(doc, topics=\(dqall\(dq) .EE .UNINDENT .UNINDENT .SS Set Logging Level of \fIezdxf\fP .sp Set the logging level of the \fIezdxf\fP package to a higher level to minimize logging messages from ezdxf. At level \fBERROR\fP only severe errors will be logged and \fBWARNING\fP, \fBINFO\fP and \fBDEBUG\fP messages will be suppressed: .INDENT 0.0 .INDENT 3.5 .sp .EX import logging logging.getLogger(\(dqezdxf\(dq).setLevel(logging.ERROR) .EE .UNINDENT .UNINDENT .SS DXF Viewer .SS A360 Viewer Problems .sp AutoDesk web service \fI\%A360\fP seems to be more picky than the AutoCAD desktop applications, may be it helps to use the latest DXF version supported by ezdxf, which is DXF R2018 (AC1032) in the year of writing this lines (2018). .SS DXF Entities Are Not Displayed in the Viewer .sp \fIezdxf\fP does not automatically locate the main viewport of the modelspace at the entities, you have to perform the “Zoom to Extends” command, here in TrueView 2020: [image] .sp And here in the Autodesk Online Viewer: [image] .sp Add this line to your code to relocate the main viewport, adjust the \fIcenter\fP (in modelspace coordinates) and the \fIheight\fP (in drawing units) arguments to your needs: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.set_modelspace_vport(height=10, center=(0, 0)) .EE .UNINDENT .UNINDENT .SS Show IMAGES/XREFS on Loading in AutoCAD .sp If you are adding XREFS and IMAGES with relative paths to existing drawings and they do not show up in AutoCAD immediately, change the HEADER variable \fB$PROJECTNAME=\(aq\(aq\fP to \fI(not really)\fP solve this problem. The ezdxf templates for DXF R2004 and later have \fB$PROJECTNAME=\(aq\(aq\fP as default value. .sp Thanks to \fI\%David Booth\fP: .INDENT 0.0 .INDENT 3.5 If the filename in the IMAGEDEF contains the full path (absolute in AutoCAD) then it shows on loading, otherwise it won’t display (reports as unreadable) until you manually reload using XREF manager. .sp A workaround (to show IMAGES on loading) appears to be to save the full file path in the DXF or save it as a DWG. .UNINDENT .UNINDENT .sp Thanks to \fI\%Zac Luzader\fP: .INDENT 0.0 .INDENT 3.5 Has anyone else noticed that very short simple image file names seem to avoid this problem? Once I ensured that the image file’s name was short and had no special characters (letters, numbers and underscores only) the problem seemed to go away. I didn’t rigorously analyze the behavior as its very time consuming. .sp Also: You can safely put the image in a subdirectory and use a relative path. The name of the subdirectory does not seem to trigger this problem, provided that the image file name itself is very short and simple. .sp Also pro tip: The XRef manager exists in DWG TrueView 2023, but access to it is only possible if you have a completely broken reference. Create a DXF with a reference to a non\-existent file, then the error dialog will let you open the XRef Manager. Once it is open you can pin it and it will be open next time, even if you have no broken references. .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Discussion on github: \fI\%Images don’t show in AutoCAD until …\fP .UNINDENT .UNINDENT .SS Set Initial View/Zoom for the Modelspace .sp See section “General Document”: \fI\%Set Initial View/Zoom for the Modelspace\fP .SS Show Lineweights in DXF Viewers .sp By default lines and curves are shown without lineweights in DXF viewers. By setting the header variable $LWDISPLAY to 1 the DXF viewer should display lineweights, if supported by the viewer. .INDENT 0.0 .INDENT 3.5 .sp .EX doc.header[\(dq$LWDISPLAY\(dq] = 1 .EE .UNINDENT .UNINDENT .SS DXF Content .sp General preconditions: .INDENT 0.0 .INDENT 3.5 .sp .EX import sys import ezdxf try: doc = ezdxf.readfile(\(dqyour_dxf_file.dxf\(dq) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file.\(aq) sys.exit(2) msp = doc.modelspace() .EE .UNINDENT .UNINDENT .SS Get/Set Entity Color .sp The entity color is stored as \fI\%ACI\fP (AutoCAD Color Index): .INDENT 0.0 .INDENT 3.5 .sp .EX aci = entity.dxf.color .EE .UNINDENT .UNINDENT .sp Default value is 256 which means BYLAYER: .INDENT 0.0 .INDENT 3.5 .sp .EX layer = doc.layers.get(entity.dxf.layer) aci = layer.get_color() .EE .UNINDENT .UNINDENT .sp The special \fI\%get_color()\fP method is required, because the color attribute \fBLayer.dxf.color\fP is misused as layer on/off flag, a negative color value means the layer is off. .sp ACI value 0 means BYBLOCK, which means the color from the block reference (INSERT entity). .sp Set color as ACI value as int in range [0, 256]: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.dxf.color = 1 .EE .UNINDENT .UNINDENT .sp The ACI value 7 has a special meaning, it is white on dark backgrounds and white on light backgrounds. .SS Get/Set Entity RGB Color .sp RGB true color values are supported since DXF R13 (AC1012), the 24\-bit RGB value is stored as integer in the DXF attribute \fI\%true_color\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX # 24 bit binary value: 0bRRRRRRRRGGGGGGGGBBBBBBBB or hex value: 0xRRGGBB # set true color value to red entity.dxf.true_color = 0xFF0000 .EE .UNINDENT .UNINDENT .sp Use the helper functions from the \fI\%ezdxf.colors\fP module for RGB integer value handling: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf import colors entity.dxf.true_color = colors.rgb2int((0xFF, 0, 0)) r, g, b = colors.int2rgb(entity.dxf.true_color) .EE .UNINDENT .UNINDENT .sp The RGB values of the AutoCAD default colors are not officially documented, but an accurate translation table is included in \fIezdxf\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX # Warning: ACI value 256 (BYLAYER) raises an IndexError! rgb24 = colors.DXF_DEFAULT_COLORS[aci] print(f\(dqRGB Hex Value: #{rgb24:06X}\(dq) r, g, b = colors.int2rgb(rgb24) print(f\(dqRGB Channel Values: R={r:02X} G={g:02X} b={b:02X}\(dq) .EE .UNINDENT .UNINDENT .sp If \fBcolor\fP and \fBtrue_color\fP values are set, BricsCAD and AutoCAD use the \fBtrue_color\fP value as display color for the entity. .SS Get/Set True Color as RGB\-Tuple .sp Get/Set the true color value as (r, g, b)\-tuple by the \fI\%rgb\fP property of the \fI\%DXFGraphic\fP entity: .INDENT 0.0 .INDENT 3.5 .sp .EX # set true color value to red entity.rgb = (0xFF, 0, 0) # get true color values r, g, b = entity.rgb .EE .UNINDENT .UNINDENT .SS Get/Set Block Reference Attributes .sp Block references (\fI\%Insert\fP) can have attached attributes (\fI\%Attrib\fP), these are simple text annotations with an associated tag appended to the block reference. .sp Iterate over all appended attributes: .INDENT 0.0 .INDENT 3.5 .sp .EX # get all INSERT entities with entity.dxf.name == \(dqPart12\(dq blockrefs = msp.query(\(aqINSERT[name==\(dqPart12\(dq]\(aq) if len(blockrefs): entity = blockrefs[0] # process first entity found for attrib in entity.attribs: if attrib.dxf.tag == \(dqdiameter\(dq: # identify attribute by tag attrib.dxf.text = \(dq17mm\(dq # change attribute content .EE .UNINDENT .UNINDENT .sp Get attribute by tag: .INDENT 0.0 .INDENT 3.5 .sp .EX diameter = entity.get_attrib(\(aqdiameter\(aq) if diameter is not None: diameter.dxf.text = \(dq17mm\(dq .EE .UNINDENT .UNINDENT .SS Adding XDATA to Entities .sp Adding XDATA as list of tuples (group code, value) by \fI\%set_xdata()\fP, overwrites data if already present: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.appids.new(\(aqYOUR_APPID\(aq) # IMPORTANT: create an APP ID entry circle = msp.add_circle((10, 10), 100) circle.set_xdata( \(aqYOUR_APPID\(aq, [ (1000, \(aqyour_web_link.org\(aq), (1002, \(aq{\(aq), (1000, \(aqsome text\(aq), (1002, \(aq{\(aq), (1071, 1), (1002, \(aq}\(aq), (1002, \(aq}\(aq) ]) .EE .UNINDENT .UNINDENT .sp For group code meaning see DXF reference section \fI\%DXF Group Codes in Numerical Order Reference\fP, valid group codes are in the range 1000 \- 1071. .sp Method \fI\%get_xdata()\fP returns the extended data for an entity as \fI\%Tags\fP object. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Tutorial: \fI\%Storing Custom Data in DXF Files\fP .UNINDENT .UNINDENT .SS Get Overridden DIMSTYLE Values from DIMENSION .sp In general the \fI\%Dimension\fP styling and config attributes are stored in the \fBDimstyle\fP entity, but every attribute can be overridden for each DIMENSION entity individually, get overwritten values by the \fBDimstyleOverride\fP object as shown in the following example: .INDENT 0.0 .INDENT 3.5 .sp .EX for dimension in msp.query(\(aqDIMENSION\(aq): dimstyle_override = dimension.override() # requires v0.12 dimtol = dimstyle_override[\(aqdimtol\(aq] if dimtol: print(f\(aq{str(dimension)} has tolerance values:\(aq) dimtp = dimstyle_override[\(aqdimtp\(aq] dimtm = dimstyle_override[\(aqdimtm\(aq] print(f\(aqUpper tolerance: {dimtp}\(aq) print(f\(aqLower tolerance: {dimtm}\(aq) .EE .UNINDENT .UNINDENT .sp The \fBDimstyleOverride\fP object returns the value of the underlying DIMSTYLE objects if the value in DIMENSION was not overwritten, or \fBNone\fP if the value was neither defined in DIMSTYLE nor in DIMENSION. .SS Override DIMSTYLE Values for DIMENSION .sp Same as above, the \fBDimstyleOverride\fP object supports also overriding DIMSTYLE values. But just overriding this values have no effect on the graphical representation of the DIMENSION entity, because CAD applications just show the associated anonymous block which contains the graphical representation on the DIMENSION entity as simple DXF entities. Call the \fBrender\fP method of the \fBDimstyleOverride\fP object to recreate this graphical representation by \fIezdxf\fP, but \fIezdxf\fP \fBdoes not\fP support all DIMENSION types and DIMVARS yet, and results \fBwill differ\fP from AutoCAD or BricsCAD renderings. .INDENT 0.0 .INDENT 3.5 .sp .EX dimstyle_override = dimension.override() dimstyle_override.set_tolerance(0.1) # delete associated geometry block del doc.blocks[dimension.dxf.geometry] # recreate geometry block dimstyle_override.render() .EE .UNINDENT .UNINDENT .SS How to Change the HATCH Pattern Origin Point .sp This code sets the origin of the first pattern line to the given \fIorigin\fP and the origins of all remaining pattern lines relative to the first pattern line origin. .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.entities import Hatch, Pattern from ezdxf.math import Vec2 def shift_pattern_origin(hatch: Hatch, offset: Vec2): if isinstance(hatch.pattern, Pattern): for pattern_line in hatch.pattern.lines: pattern_line.base_point += offset def reset_pattern_origin_of_first_pattern_line(hatch: Hatch, origin: Vec2): if isinstance(hatch.pattern, Pattern) and len(hatch.pattern.lines): first_pattern_line = hatch.pattern.lines[0] offset = origin \- first_pattern_line.base_point shift_pattern_origin(hatch, offset) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Discussion \fI\%#769\fP .UNINDENT .UNINDENT .UNINDENT .SS How to Get the Length of a Spline or Polyline .sp There exist no analytical function to calculate the length of a \fI\%B\-spline\fP, you have to approximate the curve and calculate the length of the polyline. The construction tool \fI\%ezdxf.math.ConstructionPolyline\fP is may be useful for that. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.math import ConstructionPolyline doc = ezdxf.new() msp = doc.modelspace() fit_points = [(0, 0, 0), (750, 500, 0), (1750, 500, 0), (2250, 1250, 0)] spline = msp.add_spline(fit_points) # Adjust the max. sagitta distance to your needs or run the calculation in a loop # reducing the distance until the difference to the previous run is smaller # than your expected precision: polyline = ConstructionPolyline(spline.flattening(distance=0.1)) print(f\(dqapproximated length = {polyline.length:.2f}\(dq) .EE .UNINDENT .UNINDENT .SS How to Resolve DXF Properties .sp Graphical properties of DXF entities (color, lineweight, …) are sometimes hard to resolve because of the complex possibilities to inherit properties from layers or blocks, or overriding them by \fI\%ctb\fP files. .sp The \fI\%drawing\fP add\-on provides the \fI\%RenderContext\fP class that can be used to resolve properties of entities in the context of their use: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons.drawing.properties import RenderContext doc = ezdxf.new() doc.layers.add(\(dqLINE\(dq, color=ezdxf.colors.RED) msp = doc.modelspace() line = msp.add_line((0, 0), (1, 0), dxfattribs={\(dqlayer\(dq: \(dqLINE\(dq}) ctx = RenderContext(doc) ctx.set_current_layout(msp) print(f\(dqresolved RGB value: {ctx.resolve_color(line)}\(dq) .EE .UNINDENT .UNINDENT .sp Output: .INDENT 0.0 .INDENT 3.5 .sp .EX resolved RGB value: #ff0000 .EE .UNINDENT .UNINDENT .sp This works in most simple cases, resolving properties of objects in viewports or nested blocks requires additional information that is beyond the scope of a simple guide. .SS How to Find XREF Definitions .sp XREFs are normal block definitions and can be found in the BLOCKS section: .INDENT 0.0 .INDENT 3.5 .sp .EX for block_layout in doc.blocks: block = block_layout.block # the BLOCK entity if block.is_xref: handle_xref(block_layout) elif block.is_xref_overlay: handle_xref_overlay(block_layout) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 documentation of the \fI\%ezdxf.xref\fP module .IP \(bu 2 \fI\%ezdxf.layouts.BlockLayout\fP .UNINDENT .UNINDENT .UNINDENT .SS How to Find XREF References .sp An XREF reference is a block reference (INSERT entity) to the block definition of the XREF: .INDENT 0.0 .INDENT 3.5 .sp .EX for insert in msp.query(\(dqINSERT\(dq): if insert.is_xref: handle_xref_reference(insert) # ... or get the XREF definition block_layout = insert.block() if block_layout is not None: block = block_layout.block if block.is_xref: handle_xref(block_layout) elif block.is_xref_overlay: handle_xref_overlay(block_layout) .EE .UNINDENT .UNINDENT .sp Like any normal block, an XREF can be inserted multiple times. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 documentation of the \fI\%ezdxf.xref\fP module .IP \(bu 2 \fI\%ezdxf.layouts.BlockLayout\fP .UNINDENT .UNINDENT .UNINDENT .SS Fonts .SS Rendering SHX Fonts .sp The SHX font format is not documented nor supported by many libraries/packages like \fIMatplotlib\fP and \fIQt\fP, therefore only SHX fonts which have corresponding TTF\-fonts can be rendered by these backends. The mapping from/to SHX/TTF fonts is hard coded in the source code file: \fI\%fonts.py\fP .sp Since \fIezdxf\fP v1.1 is the rendering of SHX fonts supported if the path to these fonts is added to the \fBsupport_dirs\fP in the \fI\%Config Files\fP\&. .SS Rebuild Font Manager Cache .sp If you wanna use new installed fonts which are not included in the current cache file of \fIezdxf\fP you have to rebuild the cache file: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.fonts import fonts fonts.build_system_font_cache() .EE .UNINDENT .UNINDENT .sp or call the \fIezdxf\fP launcher to do that: .INDENT 0.0 .INDENT 3.5 .sp .EX ezdxf \-\-fonts .EE .UNINDENT .UNINDENT .SS Drawing Add\-on .sp This section consolidates the \fI\%FAQ\fP about the drawing add\-on from the github forum. .SS All Backends .SS How to Set Background and Foreground Colors .sp Override the default background and foreground colors. The foreground color is the \fI\%AutoCAD Color Index (ACI)\fP 7, which is white/black depending on the background color. If the foreground color is not specified, the foreground color is white for dark backgrounds and black for light backgrounds. The required color format is a hex string “#RRGGBBAA”. .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons.drawing.properties import LayoutProperties # \-x\-x\-x snip \-x\-x\-x\- fig: plt.Figure = plt.figure() ax: plt.Axes = fig.add_axes((0, 0, 1, 1)) ctx = RenderContext(doc) # get the modelspace properties msp_properties = LayoutProperties.from_layout(msp) # set light gray background color and black foreground color msp_properties.set_colors(\(dq#eaeaea\(dq) out = MatplotlibBackend(ax) # override the layout properties and render the modelspace Frontend(ctx, out).draw_layout( msp, finalize=True, layout_properties=msp_properties, ) fig.savefig(\(dqimage.png\(dq) .EE .UNINDENT .UNINDENT .sp A light background “#eaeaea” has a black foreground color by default: [image] .sp A dark background “#0a0a0a” has a white foreground color by default: .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x snip \-x\-x\-x\- msp_properties.set_colors(\(dq#0a0a0a\(dq) # \-x\-x\-x snip \-x\-x\-x\- .EE .UNINDENT .UNINDENT [image] .SS How to Set a Transparent Background Color .sp The override color include an alpha transparency “#RRGGBBAA” value. An alpha value of “00” is opaque and “ff” is fully transparent. A transparent background color still defines the foreground color! .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 The \fBsavefig()\fP function of the matplotlib backend requires the \fItransparent\fP argument to be set to \fBTrue\fP to support transparency. .UNINDENT .UNINDENT .sp A light and fully transparent background “#eaeaeaff” has a black foreground color by default: .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x snip \-x\-x\-x\- msp_properties.set_colors(\(dq#eaeaeaff\(dq) # \-x\-x\-x snip \-x\-x\-x\- fig.savefig(\(dqimage.png\(dq, transparent=True) .EE .UNINDENT .UNINDENT [image] .sp A dark and fully transparent background “#0a0a0aff” has a \fBwhite\fP foreground color by default: .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x snip \-x\-x\-x\- msp_properties.set_colors(\(dq#0a0a0aff\(dq) # \-x\-x\-x snip \-x\-x\-x\- fig.savefig(\(dqimage.png\(dq, transparent=True) .EE .UNINDENT .UNINDENT [image] .SS How to Exclude DXF Entities from Rendering .INDENT 0.0 .IP \(bu 2 If all unwanted entities are on the same layer switch off the layer. .IP \(bu 2 If the document is not saved later, you can delete the entities or set them invisible. .IP \(bu 2 Filter the unwanted entities by a filter function. .UNINDENT .sp The argument \fIfilter_func\fP of the \fBFrontend.draw_layout()\fP method expects a function which takes a graphical DXF entity as input and returns \fBTrue\fP if the entity should be rendered or \fBFalse\fP to exclude the entity from rendering. .sp This filter function excludes all DXF entities with an ACI color value of 2: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.entities import DXFGraphic def my_filter(e: DXFGraphic) \-> bool: return e.dxf.color != 2 # \-x\-x\-x snip \-x\-x\-x\- Frontend(ctx, out).draw_layout(msp, finalize=True, filter_func=my_filter) .EE .UNINDENT .UNINDENT .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 Not all attributes have a default value if the attribute does not exist. If you are not sure about this, use the \fBget()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX def my_filter(e: DXFGraphic) \-> bool: return e.dxf.get(\(dqcolor\(dq, 7) != 2 .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS How to Override Properties of DXF Entities .sp Create a custom \fBFrontend\fP class and override the the \fBoverride_properties()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX class MyFrontend(Frontend): def override_properties(self, entity: DXFGraphic, properties: Properties) \-> None: # remove alpha channel from all entities, \(dq#RRGGBBAA\(dq properties.color = properties.color[:7] # \-x\-x\-x snip \-x\-x\-x\- MyFrontend(ctx, out).draw_layout(msp, finalize=True) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.addons.drawing.properties.Properties\fP .UNINDENT .UNINDENT .UNINDENT .SS Matplotlib Backend .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Matplotlib package: \fI\%https://matplotlib.org/stable/api/matplotlib_configuration_api.html\fP .IP \(bu 2 \fBFigure\fP API: \fI\%https://matplotlib.org/stable/api/figure_api.html\fP .IP \(bu 2 \fBAxes\fP API: \fI\%https://matplotlib.org/stable/api/axis_api.html\fP .UNINDENT .UNINDENT .UNINDENT .SS How to Get the Pixel Coordinates of DXF Entities .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Source: \fI\%https://github.com/mozman/ezdxf/discussions/219\fP .UNINDENT .UNINDENT .UNINDENT .sp Transformation from modelspace coordinates to image coordinates: .INDENT 0.0 .INDENT 3.5 .sp .EX import matplotlib.pyplot as plt from PIL import Image, ImageDraw import ezdxf from ezdxf.math import Matrix44 from ezdxf.addons.drawing import RenderContext, Frontend from ezdxf.addons.drawing.matplotlib import MatplotlibBackend def get_wcs_to_image_transform( ax: plt.Axes, image_size: tuple[int, int] ) \-> Matrix44: \(dq\(dq\(dqReturns the transformation matrix from modelspace coordinates to image coordinates. \(dq\(dq\(dq x1, x2 = ax.get_xlim() y1, y2 = ax.get_ylim() data_width, data_height = x2 \- x1, y2 \- y1 image_width, image_height = image_size return ( Matrix44.translate(\-x1, \-y1, 0) @ Matrix44.scale( image_width / data_width, \-image_height / data_height, 1.0 ) # +1 to counteract the effect of the pixels being flipped in y @ Matrix44.translate(0, image_height + 1, 0) ) # create the DXF document doc = ezdxf.new() msp = doc.modelspace() msp.add_lwpolyline([(0, 0), (1, 0), (1, 1), (0, 1)], close=True) msp.add_line((0, 0), (1, 1)) # export the pixel image fig: plt.Figure = plt.figure() ax: plt.Axes = fig.add_axes([0, 0, 1, 1]) ctx = RenderContext(doc) out = MatplotlibBackend(ax) Frontend(ctx, out).draw_layout(msp, finalize=True) fig.savefig(\(dqcad.png\(dq) plt.close(fig) # reload the pixel image by Pillow (PIL) img = Image.open(\(dqcad.png\(dq) draw = ImageDraw.Draw(img) # add some annotations to the pixel image by using modelspace coordinates m = get_wcs_to_image_transform(ax, img.size) a, b, c = ( (v.x, v.y) # draw.line() expects tuple[float, float] as coordinates # transform modelspace coordinates to image coordinates for v in m.transform_vertices([(0.25, 0.75), (0.75, 0.25), (1, 1)]) ) draw.line([a, b, c, a], fill=(255, 0, 0)) # show the image by the default image viewer img.show() .EE .UNINDENT .UNINDENT .SS How to Get Modelspace Coordinates from Pixel Coordinates .sp This is the reverse operation of the previous how\-to: \fI\%How to Get the Pixel Coordinates of DXF Entities\fP .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Full example script: \fI\%wcs_to_image_coordinates.py\fP .IP \(bu 2 Source: \fI\%https://github.com/mozman/ezdxf/discussions/269\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX def get_image_to_wcs_transform( ax: plt.Axes, image_size: tuple[int, int] ) \-> Matrix44: m = get_wcs_to_image_transform(ax, image_size) m.inverse() return m # \-x\-x\-x snip \-x\-x\-x\- img2wcs = get_image_to_wcs_transform(ax, img.size) print(f\(dq0.25, 0.75 == {img2wcs.transform(a).round(2)}\(dq) print(f\(dq0.75, 0.25 == {img2wcs.transform(b).round(2)}\(dq) print(f\(dq1.00, 1.00 == {img2wcs.transform(c).round(2)}\(dq) .EE .UNINDENT .UNINDENT .SS How to Export a Specific Area of the Modelspace .sp This code exports the specified modelspace area from (5, 3) to (7, 8) as a 2x5 inch PNG image to maintain the aspect ratio of the source area. .sp Use case: render only a specific area of the modelspace. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Full example script: \fI\%export_specific_area.py\fP .IP \(bu 2 Source: \fI\%https://github.com/mozman/ezdxf/discussions/451\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x snip \-x\-x\-x\- # export the pixel image fig: plt.Figure = plt.figure() ax: plt.Axes = fig.add_axes([0, 0, 1, 1]) ctx = RenderContext(doc) out = MatplotlibBackend(ax) Frontend(ctx, out).draw_layout(msp, finalize=True) # setting the export area: xmin, xmax = 5, 7 ymin, ymax = 3, 8 ax.set_xlim(xmin, xmax) ax.set_ylim(ymin, ymax) # set the output size to get the expected aspect ratio: fig.set_size_inches(xmax \- xmin, ymax \- ymin) fig.savefig(\(dqx5y3_to_x7y8.png\(dq) plt.close(fig) .EE .UNINDENT .UNINDENT .SS How to Render Without Margins .sp To remove the empty space at the image borders set the margins of the \fBAxes\fP object to zero: .INDENT 0.0 .INDENT 3.5 .sp .EX ax.margins(0) fig.savefig(\(dqimage_without_margins.png\(dq) plt.close(fig) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Matplotlib docs about \fI\%margins\fP .UNINDENT .UNINDENT .UNINDENT .SS How to Set the Pixel Count per Drawing Unit .sp This code exports the modelspace with an extent of 5 x 3 drawing units with 100 pixels per drawing unit as a 500 x 300 pixel image. .sp Use case: render the content with a fixed number of pixels for a drawing unit, e.g. a drawing unit of 1 inch should be rendered by 100 pixels. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Full example script: \fI\%export_image_pixel_size.py\fP .IP \(bu 2 Source: \fI\%https://github.com/mozman/ezdxf/discussions/357\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x snip \-x\-x\-x\- def set_pixel_density(fig: plt.Figure, ax: plt.Axes, ppu: int): \(dq\(dq\(dqArgument \(gappu\(ga is pixels per drawing unit.\(dq\(dq\(dq xmin, xmax = ax.get_xlim() width = xmax \- xmin ymin, ymax = ax.get_ylim() height = ymax \- ymin dpi = fig.dpi width_inch = width * ppu / dpi height_inch = height * ppu / dpi fig.set_size_inches(width_inch, height_inch) # \-x\-x\-x snip \-x\-x\-x\- # export image with 100 pixels per drawing unit = 500x300 pixels set_pixel_density(fig, ax, 100) fig.savefig(\(dqbox_500x300.png\(dq) plt.close(fig) .EE .UNINDENT .UNINDENT .SS How to Export a Specific Image Size in Pixels .sp This code exports the modelspace with an extent of 5 x 3 drawing units as a 1000 x 600 pixel Image. .sp Use case: render the content with a fixed image size in pixels. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Full example script: \fI\%export_image_pixel_size.py\fP .IP \(bu 2 Source: \fI\%https://github.com/mozman/ezdxf/discussions/357\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x snip \-x\-x\-x\- def set_pixel_size(fig: plt.Figure, size: tuple[int, int]): x, y = size fig.set_size_inches(x / fig.dpi, y / fig.dpi) # \-x\-x\-x snip \-x\-x\-x\- # export image with a size of 1000x600 pixels set_pixel_size(fig, (1000, 600)) fig.savefig(\(dqbox_1000x600.png\(dq) plt.close(fig) .EE .UNINDENT .UNINDENT .SS How to Set the Page Size in Inches .sp The page\- or image size in inches is set by the \fBset_size_inches()\fP method of the \fBFigure\fP class. The content within the \fBAxes\fP limits will be scaled to fill the page. .sp Use case: render the whole content to a PDF document with a specific paper size without worrying about scale. .INDENT 0.0 .INDENT 3.5 .sp .EX fig.set_size_inches(8, 11) .EE .UNINDENT .UNINDENT .SS How to Render at a Specific Scale .sp This code exports the modelspace at a specific scale and paper size. .sp Use case: render the content to a PDF document with a specific paper size and scale, but not all content may be rendered. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Full example script: \fI\%render_to_scale.py\fP .IP \(bu 2 Source: \fI\%https://github.com/mozman/ezdxf/discussions/665\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX # \-x\-x\-x snip \-x\-x\-x\- def render_limits( origin: tuple[float, float], size_in_inches: tuple[float, float], scale: float, ) \-> tuple[float, float, float, float]: \(dq\(dq\(dqReturns the final render limits in drawing units. Args: origin: lower left corner of the modelspace area to render size_in_inches: paper size in inches scale: render scale, e.g. scale=100 means 1:100, 1m is rendered as 0.01m or 1cm on paper \(dq\(dq\(dq min_x, min_y = origin max_x = min_x + size_in_inches[0] * scale max_y = min_y + size_in_inches[1] * scale return min_x, min_y, max_x, max_y def export_to_scale( paper_size: tuple[float, float] = (8.5, 11), origin: tuple[float, float] = (0, 0), scale: float = 1, dpi: int = 300, ): \(dq\(dq\(dqRender the modelspace content with to a specific paper size and scale. Args: paper_size: paper size in inches origin: lower left corner of the modelspace area to render scale: render scale, e.g. scale=100 means 1:100, 1m is rendered as 0.01m or 1cm on paper dpi: pixel density on paper as dots per inch \(dq\(dq\(dq # \-x\-x\-x snip \-x\-x\-x\- ctx = RenderContext(doc) fig: plt.Figure = plt.figure(dpi=dpi) ax: plt.Axes = fig.add_axes([0, 0, 1, 1]) # disable all margins ax.margins(0) # get the final render limits in drawing units: min_x, min_y, max_x, max_y = render_limits( origin, paper_size, scale ) ax.set_xlim(min_x, max_x) ax.set_ylim(min_y, max_y) out = MatplotlibBackend(ax) # finalizing invokes auto\-scaling by default! Frontend(ctx, out).draw_layout(msp, finalize=False) # set output size in inches: fig.set_size_inches(paper_size[0], paper_size[1], forward=True) fig.savefig(f\(dqimage_scale_1_{scale}.pdf\(dq, dpi=dpi) plt.close(fig) .EE .UNINDENT .UNINDENT .SS How to Control the Line Width .sp The DXF \fBlineweight\fP attribute defines the line width as absolute width on the output medium (e.g. 25 = 0.25mm) and therefore depends only on the DPI (dots per inch) setting of the \fBFigure\fP class and the \fBsavefig()\fP method. .sp There are two additional settings in the \fI\%Configuration\fP class which influences the line width: .INDENT 0.0 .IP \(bu 2 \fI\%min_lineweight\fP sets the minimum line width in 1/300 inch \- a value of 300 is a line width of 1 inch .IP \(bu 2 \fI\%lineweight_scaling\fP, multiply the line width by a this factor .UNINDENT .sp The following table shows the line width in pixels for all valid DXF lineweights for a resolution of 72, 100, 200 and 300 dpi: [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Discussion: \fI\%https://github.com/mozman/ezdxf/discussions/797\fP .UNINDENT .UNINDENT .SH FAQ .sp These are the old FAQ until late 2023, new FAQs will only be added to the \fI\%Knowledge Graph\fP\&. .SS What is the Relationship between ezdxf, dxfwrite and dxfgrabber? .sp In 2010 I started my first Python package for creating DXF documents called \fIdxfwrite\fP, this package can’t read DXF files and writes only the DXF R12 (AC1009) version. While \fIdxfwrite\fP works fine, I wanted a more versatile package, that can read and write DXF files and maybe also supports newer DXF formats than DXF R12. .sp This was the start of the \fIezdxf\fP package in 2011, but the progress was so slow, that I created a spin off in 2012 called \fIdxfgrabber\fP, which implements only the reading part of \fIezdxf\fP, which I needed for my work and I wasn’t sure if \fIezdxf\fP will ever be usable. Luckily in 2014 the first usable version of \fIezdxf\fP could be released. The \fIezdxf\fP package has all the features of \fIdxfwrite\fP and \fIdxfgrabber\fP and much more, but with a different API. So \fIezdxf\fP is not a drop\-in replacement for \fIdxfgrabber\fP or \fIdxfwrite\fP\&. .sp Since \fIezdxf\fP can do all the things that \fIdxfwrite\fP and \fIdxfgrabber\fP can do, I focused on the development of \fIezdxf\fP, \fIdxfwrite\fP and \fIdxfgrabber\fP are in maintenance\-only mode and will not get any new features, just bugfixes. .sp There are no advantages of \fIdxfwrite\fP over \fIezdxf\fP, \fIdxfwrite\fP has a smaller memory footprint, but the \fBr12writer\fP add\-on does the same job as \fIdxfwrite\fP without any in\-memory structures by writing direct to a stream or file and there is also no advantage of \fIdxfgrabber\fP over \fIezdxf\fP for ordinary DXF files, the smaller memory footprint of \fIdxfgrabber\fP is not noticeable and for really big files the \fBiterdxf\fP add\-on does a better job. .SS Imported ezdxf package has no content. (readfile, new) .INDENT 0.0 .IP 1. 3 AttributeError: partially initialized module ‘ezdxf’ has no attribute ‘readfile’ (most likely due to a circular import) .sp Did you name your file/script “ezdxf.py”? This causes problems with circular imports. Renaming your file/script should solve this issue. .IP 2. 3 AttributeError: module ‘ezdxf’ has no attribute ‘readfile’ .sp This could be a hidden permission error, for more information about this issue read Petr Zemeks article: \fI\%https://blog.petrzemek.net/2020/11/17/when\-you\-import\-a\-python\-package\-and\-it\-is\-empty/\fP .UNINDENT .SS How to add/edit ACIS based entities like 3DSOLID, REGION or SURFACE? .sp The BODY, 3DSOLID, SURFACE, REGION and so on, are stored as ACIS data embedded in the DXF file. The ACIS data is stored as SAT (text) format in the entity itself for DXF R2000\-R2010 and as SAB (binary) format in the ACDSDATA section for DXF R2013+. \fIEzdxf\fP can read SAT and SAB data, but only write SAT data. .sp The ACIS data is a proprietary format from \fI\%Spatial Inc.\fP, and there exist no free available documentation or open source libraries to create or edit SAT or SAB data, and also \fIezdxf\fP provides no functionality for creating or editing ACIS data. .sp The ACIS support provided by \fIezdxf\fP is only useful for users which have access to the ACIS SDK from \fI\%Spatial Inc.\fP\&. .SS Are OLE/OLE2 entities supported? .sp TLDR; NO! .sp The Wikipedia definition of \fI\%OLE\fP: Object Linking & Embedding (OLE) is a proprietary technology developed by Microsoft that allows embedding and linking to documents and other objects. For developers, it brought OLE Control Extension (OCX), a way to develop and use custom user interface elements. On a technical level, an OLE object is any object that implements the \fBIOleObject\fP interface, possibly along with a wide range of other interfaces, depending on the object’s needs. .sp Therefore \fIezdxf\fP does not support this entities in any way, this only work on Windows and with the required editing application installed. The binary data stored in the OLE objects cannot be used without the editing application. .sp In my opinion, using OLE objects in a CAD drawing is a very bad design decision that can and will cause problems opening these files in the future, even in AutoCAD on Windows when the required editing application is no longer available or the underlying technology is no longer supported. .sp All of this is unacceptable for a data storage format that should be accessed for many years or decades (e.g. construction drawings for buildings or bridges). .SS Rendering SHX fonts .sp The SHX font format is not documented nor supported by many libraries/packages like \fIMatplotlib\fP and \fIQt\fP, therefore only SHX fonts which have corresponding TTF\-fonts can be rendered by these backends. See also how\-tos about \fI\%Fonts\fP .SS Drawing Add\-on .sp There is a dedicated how\-to section for the \fI\%Drawing Add\-on\fP\&. .SS Is the AutoCAD command XYZ available? .sp TLDR; Would you expect Photoshop features from a JPG library? .sp The package is designed as an interface to the DXF format and therefore does not offer any advanced features of interactive CAD applications. First, some tasks are difficult to perform without human guidance, and second, in complex situations, it’s not that easy to tell a “headless” system what exactly to do, so it’s very likely that not many users would ever use these features, despite the fact that a lot of time and effort would have to be spent on development, testing and long\-term support. .SH REFERENCE .sp The \fI\%DXF Reference\fP is online available at \fI\%Autodesk\fP\&. .sp Quoted from the original DXF 12 Reference which is not available on the web: .INDENT 0.0 .INDENT 3.5 Since the AutoCAD drawing database (.dwg file) is written in a compact format that changes significantly as new features are added to AutoCAD, we do not document its format and do not recommend that you attempt to write programs to read it directly. To assist in interchanging drawings between AutoCAD and other programs, a Drawing Interchange file format (DXF) has been defined. All implementations of AutoCAD accept this format and are able to convert it to and from their internal drawing file representation. .UNINDENT .UNINDENT .SS DXF Document .SS Document Management .SS Create New Drawings .INDENT 0.0 .TP .B ezdxf.new(dxfversion=\(aqAC1027\(aq, setup=False, units=6) -> \fI\%Drawing\fP Create a new \fBDrawing\fP from scratch, \fIdxfversion\fP can be either “AC1009” the official DXF version name or “R12” the AutoCAD release name. .sp \fI\%new()\fP can create drawings for following DXF versions: .TS center; |l|l|. _ T{ Version T} T{ AutoCAD Release T} _ T{ AC1009 T} T{ AutoCAD R12 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} _ .TE .sp The \fIunits\fP argument defines th document and modelspace units. The header variable $MEASUREMENT will be set according to the given \fIunits\fP, 0 for inch, feet, miles, … and 1 for metric units. For more information go to module \fI\%ezdxf.units\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdxfversion\fP – DXF version specifier as string, default is “AC1027” respectively “R2013” .IP \(bu 2 \fBsetup\fP – .sp setup default styles, \fBFalse\fP for no setup, \fBTrue\fP to setup everything or a list of topics as strings, e.g. [“linetypes”, “styles”] to setup only some topics: .TS center; |l|l|. _ T{ Topic T} T{ Description T} _ T{ linetypes T} T{ setup line types T} _ T{ styles T} T{ setup text styles T} _ T{ dimstyles T} T{ setup default \fIezdxf\fP dimension styles T} _ T{ visualstyles T} T{ setup 25 standard visual styles T} _ .TE .IP \(bu 2 \fBunits\fP – document and modelspace units, default is 6 for meters .UNINDENT .UNINDENT .UNINDENT .SS Open Drawings .sp Open DXF drawings from file system or text stream, byte stream usage is not supported. .sp DXF files prior to R2007 requires file encoding defined by header variable $DWGCODEPAGE, DXF R2007 and later requires an UTF\-8 encoding. .sp \fIezdxf\fP supports reading of files for following DXF versions: .TS center; |l|l|l|l|. _ T{ Version T} T{ Release T} T{ Encoding T} T{ Remarks T} _ T{ < AC1009 T} T{ T} T{ $DWGCODEPAGE T} T{ pre AutoCAD R12 upgraded to AC1009 T} _ T{ AC1009 T} T{ R12 T} T{ $DWGCODEPAGE T} T{ AutoCAD R12 T} _ T{ AC1012 T} T{ R13 T} T{ $DWGCODEPAGE T} T{ AutoCAD R13 upgraded to AC1015 T} _ T{ AC1014 T} T{ R14 T} T{ $DWGCODEPAGE T} T{ AutoCAD R14 upgraded to AC1015 T} _ T{ AC1015 T} T{ R2000 T} T{ $DWGCODEPAGE T} T{ AutoCAD R2000 T} _ T{ AC1018 T} T{ R2004 T} T{ $DWGCODEPAGE T} T{ AutoCAD R2004 T} _ T{ AC1021 T} T{ R2007 T} T{ UTF\-8 T} T{ AutoCAD R2007 T} _ T{ AC1024 T} T{ R2010 T} T{ UTF\-8 T} T{ AutoCAD R2010 T} _ T{ AC1027 T} T{ R2013 T} T{ UTF\-8 T} T{ AutoCAD R2013 T} _ T{ AC1032 T} T{ R2018 T} T{ UTF\-8 T} T{ AutoCAD R2018 T} _ .TE .INDENT 0.0 .TP .B ezdxf.readfile(filename: str | PathLike, encoding: str | None = None, errors: str = \(aqsurrogateescape\(aq) -> \fI\%Drawing\fP Read the DXF document \fIfilename\fP from the file\-system. .sp This is the preferred method to load existing ASCII or Binary DXF files, the required text encoding will be detected automatically and decoding errors will be ignored. .sp Override encoding detection by setting argument \fIencoding\fP to the estimated encoding. (use Python encoding names like in the \fBopen()\fP function). .sp If this function struggles to load the DXF document and raises a \fBDXFStructureError\fP exception, try the \fI\%ezdxf.recover.readfile()\fP function to load this corrupt DXF document. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – filename of the ASCII\- or Binary DXF document .IP \(bu 2 \fBencoding\fP – use \fBNone\fP for auto detect (default), or set a specific encoding like “utf\-8”, argument is ignored for Binary DXF files .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBIOError\fP – not a DXF file or file does not exist .IP \(bu 2 \fI\%DXFStructureError\fP – for invalid or corrupted DXF structures .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.read(stream: TextIO) -> \fI\%Drawing\fP Read a DXF document from a text\-stream. Open stream in text mode (\fBmode=\(aqrt\(aq\fP) and set correct text encoding, the stream requires at least a \fBreadline()\fP method. .sp Since DXF version R2007 (AC1021) file encoding is always “utf\-8”, use the helper function \fBdxf_stream_info()\fP to detect the required text encoding for prior DXF versions. To preserve possible binary data in use \fBerrors=\(aqsurrogateescape\(aq\fP as error handler for the import stream. .sp If this function struggles to load the DXF document and raises a \fBDXFStructureError\fP exception, try the \fI\%ezdxf.recover.read()\fP function to load this corrupt DXF document. .INDENT 7.0 .TP .B Parameters \fBstream\fP – input text stream opened with correct encoding .TP .B Raises \fI\%DXFStructureError\fP – for invalid or corrupted DXF structures .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.readzip(zipfile: str | PathLike, filename: str | None = None, errors: str = \(aqsurrogateescape\(aq) -> \fI\%Drawing\fP Load a DXF document specified by \fIfilename\fP from a zip archive, or if \fIfilename\fP is \fBNone\fP the first DXF document in the zip archive. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBzipfile\fP – name of the zip archive .IP \(bu 2 \fBfilename\fP – filename of DXF file, or \fBNone\fP to load the first DXF document from the zip archive. .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBIOError\fP – not a DXF file or file does not exist or if \fIfilename\fP is \fBNone\fP \- no DXF file found .IP \(bu 2 \fI\%DXFStructureError\fP – for invalid or corrupted DXF structures .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.decode_base64(data: bytes, errors: str = \(aqsurrogateescape\(aq) -> \fI\%Drawing\fP Load a DXF document from base64 encoded binary data, like uploaded data to web applications. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdata\fP – DXF document base64 encoded binary data .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFStructureError\fP – for invalid or corrupted DXF structures .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 This works well with DXF files from trusted sources like AutoCAD or BricsCAD, for loading DXF files with minor or major flaws look at the \fI\%ezdxf.recover\fP module. .UNINDENT .UNINDENT .SS Save Drawings .sp Save the DXF document to the file system by \fI\%Drawing\fP methods \fI\%save()\fP or \fI\%saveas()\fP\&. Write the DXF document to a text stream with \fI\%write()\fP, the text stream requires at least a \fBwrite()\fP method. Get required output encoding for text streams by property \fBDrawing.output_encoding\fP .SS Drawing Settings .sp The \fI\%HeaderSection\fP stores meta data like modelspace extensions, user name or saving time and current application settings, like actual layer, text style or dimension style settings. These settings are not necessary to process DXF data and therefore many of this settings are not maintained by \fIezdxf\fP automatically. .SS Header variables set at new .TS center; |l|l|. _ T{ $ACADVER T} T{ DXF version T} _ T{ $TDCREATE T} T{ date/time at creating the drawing T} _ T{ $FINGERPRINTGUID T} T{ every drawing gets a GUID T} _ .TE .SS Header variables updated at saving .TS center; |l|l|. _ T{ $TDUPDATE T} T{ actual date/time at saving T} _ T{ $HANDSEED T} T{ next available handle as hex string T} _ T{ $DWGCODEPAGE T} T{ encoding setting T} _ T{ $VERSIONGUID T} T{ every saved version gets a new GUID T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Howto: \fI\%Set/Get Header Variables\fP .IP \(bu 2 Howto: \fI\%Set DXF Drawing Units\fP .UNINDENT .UNINDENT .UNINDENT .SS Ezdxf Metadata .sp Store internal metadata like \fIezdxf\fP version and creation time for a new created document as metadata in the DXF file. Only standard DXF features are used to store meta data and this meta data is preserved by Autodesk products, BricsCAD and of course \fIezdxf\fP\&. Other 3rd party DXF libraries may remove this meta data. .sp For DXF R12 the meta data is stored as XDATA by AppID \fBEZDXF\fP in the model space BLOCK entity in the BLOCKS section. .sp For DXF R2000+ the meta data is stored in the “root” DICTIONARY in the OBJECTS section as a DICTIONARY object by the key \fBEZDXF_META\fP\&. .sp The \fBMetaData\fP object has a dict\-like interface and can also store custom metadata: .INDENT 0.0 .INDENT 3.5 .sp .EX metadata = doc.ezdxf_metadata() # set data metadata[\(dqMY_CUSTOM_META_DATA\(dq] = \(dqa string with max. length of 254\(dq # get data, raises a KeyError() if key not exist value = metadata[\(dqMY_CUSTOM_META_DATA\(dq] # get data, returns an empty string if key not exist value = metadata.get(\(dqMY_CUSTOM_META_DATA\(dq) # delete entry, raises a KeyError() if key not exist del metadata[\(dqMY_CUSTOM_META_DATA\(dq] # discard entry, does not raise a KeyError() if key not exist metadata.discard(\(dqMY_CUSTOM_META_DATA\(dq) .EE .UNINDENT .UNINDENT .sp Keys and values are limited to strings with a max. length of 254 characters and line ending \fB\en\fP will be replaced by \fB\eP\fP\&. .sp Keys used by \fIezdxf\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBWRITTEN_BY_EZDXF\fP: \fIezdxf\fP version and UTC time in ISO format .IP \(bu 2 \fBCREATED_BY_EZDXF\fP: \fIezdxf\fP version and UTC time in ISO format .UNINDENT .UNINDENT .UNINDENT .sp Example of the ezdxf marker string: \fB0.16.4b1 @ 2021\-06\-12T07:35:34.898808+00:00\fP .INDENT 0.0 .TP .B class ezdxf.document.MetaData .INDENT 7.0 .TP .B abstract MetaData.__contains__(key: str) -> bool Returns \fIkey\fP \fBin\fP self. .UNINDENT .INDENT 7.0 .TP .B abstract MetaData.__getitem__(key: str) -> str Returns the value for self[\fIkey\fP]. .INDENT 7.0 .TP .B Raises \fBKeyError\fP – \fIkey\fP does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B MetaData.get(key: str, default: str = \(aq\(aq) -> str Returns the value for \fIkey\fP\&. Returns \fIdefault\fP if \fIkey\fP not exist. .UNINDENT .INDENT 7.0 .TP .B abstract MetaData.__setitem__(key: str, value: str) -> None Set self[\fIkey\fP] to \fIvalue\fP\&. .UNINDENT .INDENT 7.0 .TP .B abstract MetaData.__delitem__(key: str) -> None Delete self[\fIkey\fP]. .INDENT 7.0 .TP .B Raises \fBKeyError\fP – \fIkey\fP does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B MetaData.discard(key: str) -> None Remove \fIkey\fP, does \fBnot\fP raise an exception if \fIkey\fP not exist. .UNINDENT .UNINDENT .SS Drawing Class .sp The \fI\%Drawing\fP class is the central management structure of a DXF document. .SS Access Layouts .INDENT 0.0 .IP \(bu 2 \fI\%Drawing.modelspace()\fP .IP \(bu 2 \fI\%Drawing.paperspace()\fP .UNINDENT .SS Access Resources .INDENT 0.0 .IP \(bu 2 Application ID Table: \fI\%Drawing.appids\fP .IP \(bu 2 Block Definition Table: \fI\%Drawing.blocks\fP .IP \(bu 2 Dimension Style Table: \fI\%Drawing.dimstyles\fP .IP \(bu 2 Layer Table: \fI\%Drawing.layers\fP .IP \(bu 2 Linetype Table: \fI\%Drawing.linetypes\fP .IP \(bu 2 MLeader Style Table: \fI\%Drawing.mleader_styles\fP .IP \(bu 2 MLine Style Table: \fI\%Drawing.mline_styles\fP .IP \(bu 2 Material Table: \fI\%Drawing.materials\fP .IP \(bu 2 Text Style Table: \fI\%Drawing.styles\fP .IP \(bu 2 UCS Table: \fI\%Drawing.ucs\fP .IP \(bu 2 VPort Table: \fI\%Drawing.viewports\fP .IP \(bu 2 View Table: \fI\%Drawing.views\fP .IP \(bu 2 Classes Section: \fI\%Drawing.classes\fP .IP \(bu 2 Object Section: \fI\%Drawing.objects\fP .IP \(bu 2 Entity Database: \fBDrawing.entitydb\fP .IP \(bu 2 Entity Groups: \fI\%Drawing.groups\fP .IP \(bu 2 Header Variables: \fI\%Drawing.header\fP .UNINDENT .SS Drawing Class .INDENT 0.0 .TP .B class ezdxf.document.Drawing The \fI\%Drawing\fP class is the central management structure of a DXF document. .INDENT 7.0 .TP .B dxfversion Actual DXF version like \fB\(aqAC1009\(aq\fP, set by \fI\%ezdxf.new()\fP or \fI\%ezdxf.readfile()\fP\&. .sp For supported DXF versions see \fI\%Document Management\fP .UNINDENT .INDENT 7.0 .TP .B acad_release The AutoCAD release name like \fB\(aqR12\(aq\fP or \fB\(aqR2000\(aq\fP for actual \fI\%dxfversion\fP\&. .UNINDENT .INDENT 7.0 .TP .B encoding Text encoding of \fI\%Drawing\fP, the default encoding for new drawings is \fB\(aqcp1252\(aq\fP\&. Starting with DXF R2007 (AC1021), DXF files are written as UTF\-8 encoded text files, regardless of the attribute \fI\%encoding\fP\&. The text encoding can be changed to encodings listed below. .sp see also: \fI\%DXF File Encoding\fP .TS center; |l|l|. _ T{ supported T} T{ encodings T} _ T{ \fB\(aqcp874\(aq\fP T} T{ Thai T} _ T{ \fB\(aqcp932\(aq\fP T} T{ Japanese T} _ T{ \fB\(aqgbk\(aq\fP T} T{ UnifiedChinese T} _ T{ \fB\(aqcp949\(aq\fP T} T{ Korean T} _ T{ \fB\(aqcp950\(aq\fP T} T{ TradChinese T} _ T{ \fB\(aqcp1250\(aq\fP T} T{ CentralEurope T} _ T{ \fB\(aqcp1251\(aq\fP T} T{ Cyrillic T} _ T{ \fB\(aqcp1252\(aq\fP T} T{ WesternEurope T} _ T{ \fB\(aqcp1253\(aq\fP T} T{ Greek T} _ T{ \fB\(aqcp1254\(aq\fP T} T{ Turkish T} _ T{ \fB\(aqcp1255\(aq\fP T} T{ Hebrew T} _ T{ \fB\(aqcp1256\(aq\fP T} T{ Arabic T} _ T{ \fB\(aqcp1257\(aq\fP T} T{ Baltic T} _ T{ \fB\(aqcp1258\(aq\fP T} T{ Vietnam T} _ .TE .UNINDENT .INDENT 7.0 .TP .B output_encoding Returns required output encoding for saving to filesystem or encoding to binary data. .UNINDENT .INDENT 7.0 .TP .B filename \fI\%Drawing\fP filename, if loaded by \fI\%ezdxf.readfile()\fP else \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B rootdict Reference to the root dictionary of the OBJECTS section. .UNINDENT .INDENT 7.0 .TP .B header Reference to the \fI\%HeaderSection\fP, get/set drawing settings as header variables. .UNINDENT .INDENT 7.0 .TP .B entities Reference to the \fBEntitySection\fP of the drawing, where all graphical entities are stored, but only from modelspace and the \fIactive\fP paperspace layout. Just for your information: Entities of other paperspace layouts are stored as \fI\%BlockLayout\fP in the \fI\%BlocksSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B objects Reference to the objects section, see also \fI\%ObjectsSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B blocks Reference to the blocks section, see also \fI\%BlocksSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B tables Reference to the tables section, see also \fI\%TablesSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B classes Reference to the classes section, see also \fI\%ClassesSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B layouts Reference to the layout manager, see also \fI\%Layouts\fP\&. .UNINDENT .INDENT 7.0 .TP .B groups Collection of all groups, see also \fI\%GroupCollection\fP\&. .sp requires DXF R13 or later .UNINDENT .INDENT 7.0 .TP .B layers Shortcut for \fBDrawing.tables.layers\fP .sp Reference to the layers table, where you can create, get and remove layers, see also \fI\%Table\fP and \fI\%Layer\fP .UNINDENT .INDENT 7.0 .TP .B styles Shortcut for \fBDrawing.tables.styles\fP .sp Reference to the styles table, see also \fI\%Textstyle\fP\&. .UNINDENT .INDENT 7.0 .TP .B dimstyles Shortcut for \fBDrawing.tables.dimstyles\fP .sp Reference to the dimstyles table, see also \fI\%DimStyle\fP\&. .UNINDENT .INDENT 7.0 .TP .B linetypes Shortcut for \fBDrawing.tables.linetypes\fP .sp Reference to the linetypes table, see also \fI\%Linetype\fP\&. .UNINDENT .INDENT 7.0 .TP .B views Shortcut for \fBDrawing.tables.views\fP .sp Reference to the views table, see also \fI\%View\fP\&. .UNINDENT .INDENT 7.0 .TP .B viewports Shortcut for \fBDrawing.tables.viewports\fP .sp Reference to the viewports table, see also \fI\%VPort\fP\&. .UNINDENT .INDENT 7.0 .TP .B ucs Shortcut for \fBDrawing.tables.ucs\fP .sp Reference to the ucs table, see also \fI\%UCSTableEntry\fP\&. .UNINDENT .INDENT 7.0 .TP .B appids Shortcut for \fBDrawing.tables.appids\fP .sp Reference to the appids table, see also \fI\%AppID\fP\&. .UNINDENT .INDENT 7.0 .TP .B materials \fBMaterialCollection\fP of all \fBMaterial\fP objects. .UNINDENT .INDENT 7.0 .TP .B mline_styles \fBMLineStyleCollection\fP of all \fI\%MLineStyle\fP objects. .UNINDENT .INDENT 7.0 .TP .B mleader_styles \fBMLeaderStyleCollection\fP of all \fI\%MLeaderStyle\fP objects. .UNINDENT .INDENT 7.0 .TP .B units Get and set the document/modelspace base units as enum, for more information read this: \fI\%DXF Units\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_abs_filepath = .UNINDENT .INDENT 7.0 .TP .B save(encoding: str | None = None, fmt: str = \(aqasc\(aq) -> None Write drawing to file\-system by using the \fI\%filename\fP attribute as filename. Override file encoding by argument \fIencoding\fP, handle with care, but this option allows you to create DXF files for applications that handle file encoding different from AutoCAD. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBencoding\fP – override default encoding as Python encoding string like \fB\(aqutf\-8\(aq\fP .IP \(bu 2 \fBfmt\fP – \fB\(aqasc\(aq\fP for ASCII DXF (default) or \fB\(aqbin\(aq\fP for Binary DXF .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B saveas(filename: PathLike | str, encoding: str | None = None, fmt: str = \(aqasc\(aq) -> None Set \fI\%Drawing\fP attribute \fI\%filename\fP to \fIfilename\fP and write drawing to the file system. Override file encoding by argument \fIencoding\fP, handle with care, but this option allows you to create DXF files for applications that handles file encoding different than AutoCAD. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – file name as string .IP \(bu 2 \fBencoding\fP – override default encoding as Python encoding string like \fB\(aqutf\-8\(aq\fP .IP \(bu 2 \fBfmt\fP – \fB\(aqasc\(aq\fP for ASCII DXF (default) or \fB\(aqbin\(aq\fP for Binary DXF .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B write(stream: TextIO | BinaryIO, fmt: str = \(aqasc\(aq) -> None Write drawing as ASCII DXF to a text stream or as Binary DXF to a binary stream. For DXF R2004 (AC1018) and prior open stream with drawing \fI\%encoding\fP and \fBmode=\(aqwt\(aq\fP\&. For DXF R2007 (AC1021) and later use \fBencoding=\(aqutf\-8\(aq\fP, or better use the later added \fI\%Drawing\fP property \fI\%output_encoding\fP which returns the correct encoding automatically. The correct and required error handler is \fBerrors=\(aqdxfreplace\(aq\fP! .sp If writing to a \fBStringIO\fP stream, use \fI\%Drawing.encode()\fP to encode the result string from \fBStringIO.get_value()\fP: .INDENT 7.0 .INDENT 3.5 .sp .EX binary = doc.encode(stream.get_value()) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstream\fP – output text stream or binary stream .IP \(bu 2 \fBfmt\fP – “asc” for ASCII DXF (default) or “bin” for binary DXF .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B encode_base64() -> bytes Returns DXF document as base64 encoded binary data. .UNINDENT .INDENT 7.0 .TP .B encode(s: str) -> bytes Encode string \fIs\fP with correct encoding and error handler. .UNINDENT .INDENT 7.0 .TP .B query(query: str = \(aq*\(aq) -> \fI\%EntityQuery\fP Entity query over all layouts and blocks, excluding the OBJECTS section and the resource tables of the TABLES section. .INDENT 7.0 .TP .B Parameters \fBquery\fP – query string .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 \fI\%Entity Query String\fP and \fI\%Retrieve entities by query language\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B groupby(dxfattrib=\(aq\(aq, key=None) -> dict Groups DXF entities of all layouts and blocks (excluding the OBJECTS section) by a DXF attribute or a key function. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdxfattrib\fP – grouping DXF attribute like “layer” .IP \(bu 2 \fBkey\fP – key function, which accepts a \fBDXFEntity\fP as argument and returns a hashable grouping key or \fBNone\fP to ignore this entity. .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 \fI\%groupby()\fP documentation .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B modelspace() -> Modelspace Returns the modelspace layout, displayed as “Model” tab in CAD applications, defined by block record named “*Model_Space”. .UNINDENT .INDENT 7.0 .TP .B paperspace(name: str = \(aq\(aq) -> Paperspace Returns paperspace layout \fIname\fP or the active paperspace if no name is given. .INDENT 7.0 .TP .B Parameters \fBname\fP – paperspace name or empty string for the active paperspace .TP .B Raises \fBKeyError\fP – if the modelspace was acquired or layout \fIname\fP does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B layout(name: str = \(aq\(aq) -> \fI\%Layout\fP Returns paperspace layout \fIname\fP or the first layout in tab\-order if no name is given. .INDENT 7.0 .TP .B Parameters \fBname\fP – paperspace name or empty string for the first paperspace in tab\-order .TP .B Raises \fBKeyError\fP – layout \fIname\fP does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B active_layout() -> Paperspace Returns the active paperspace layout, defined by block record name “*Paper_Space”. .UNINDENT .INDENT 7.0 .TP .B layout_names() -> Iterable[str] Returns all layout names in arbitrary order. .UNINDENT .INDENT 7.0 .TP .B layout_names_in_taborder() -> Iterable[str] Returns all layout names in tab\-order, “Model” is always the first name. .UNINDENT .INDENT 7.0 .TP .B new_layout(name, dxfattribs=None) -> Paperspace Create a new paperspace layout \fIname\fP\&. Returns a \fI\%Paperspace\fP object. DXF R12 (AC1009) supports only one paperspace layout, only the active paperspace layout is saved, other layouts are dismissed. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – unique layout name .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the \fBDXFLayout\fP entity .UNINDENT .TP .B Raises \fI\%DXFValueError\fP – paperspace layout \fIname\fP already exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B page_setup(name: str = \(aqLayout1\(aq, fmt: str = \(aqISO A3\(aq, landscape=True) -> Paperspace Creates a new paperspace layout if \fIname\fP does not exist or reset the existing layout. This method requires DXF R2000 or newer. The paper format name \fIfmt\fP defines one of the following paper sizes, measures in landscape orientation: .TS center; |l|l|l|l|. _ T{ Name T} T{ Units T} T{ Width T} T{ Height T} _ T{ ISO A0 T} T{ mm T} T{ 1189 T} T{ 841 T} _ T{ ISO A1 T} T{ mm T} T{ 841 T} T{ 594 T} _ T{ ISO A2 T} T{ mm T} T{ 594 T} T{ 420 T} _ T{ ISO A3 T} T{ mm T} T{ 420 T} T{ 297 T} _ T{ ISO A4 T} T{ mm T} T{ 297 T} T{ 210 T} _ T{ ANSI A T} T{ inch T} T{ 11 T} T{ 8.5 T} _ T{ ANSI B T} T{ inch T} T{ 17 T} T{ 11 T} _ T{ ANSI C T} T{ inch T} T{ 22 T} T{ 17 T} _ T{ ANSI D T} T{ inch T} T{ 34 T} T{ 22 T} _ T{ ANSI E T} T{ inch T} T{ 44 T} T{ 34 T} _ T{ ARCH C T} T{ inch T} T{ 24 T} T{ 18 T} _ T{ ARCH D T} T{ inch T} T{ 36 T} T{ 24 T} _ T{ ARCH E T} T{ inch T} T{ 48 T} T{ 36 T} _ T{ ARCH E1 T} T{ inch T} T{ 42 T} T{ 30 T} _ T{ Letter T} T{ inch T} T{ 11 T} T{ 8.5 T} _ T{ Legal T} T{ inch T} T{ 14 T} T{ 8.5 T} _ .TE .sp The layout uses the associated units of the paper format as drawing units, has no margins or offset defined and the scale of the paperspace layout is 1:1. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – paperspace layout name .IP \(bu 2 \fBfmt\fP – paper format .IP \(bu 2 \fBlandscape\fP – \fBTrue\fP for landscape orientation, \fBFalse\fP for portrait orientation .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete_layout(name: str) -> None Delete paper space layout \fIname\fP and all entities owned by this layout. Available only for DXF R2000 or later, DXF R12 supports only one paperspace, and it can’t be deleted. .UNINDENT .INDENT 7.0 .TP .B add_image_def(filename: str, size_in_pixel: tuple[int, int], name=None) Add an image definition to the objects section. .sp Add an \fBImageDef\fP entity to the drawing (objects section). \fIfilename\fP is the image file name as relative or absolute path and \fIsize_in_pixel\fP is the image size in pixel as (x, y) tuple. To avoid dependencies to external packages, \fIezdxf\fP can not determine the image size by itself. Returns a \fBImageDef\fP entity which is needed to create an image reference. \fIname\fP is the internal image name, if set to \fBNone\fP, name is auto\-generated. .sp Absolute image paths works best for AutoCAD but not perfect, you have to update external references manually in AutoCAD, which is not possible in TrueView. If the drawing units differ from 1 meter, you also have to use: \fI\%set_raster_variables()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – image file name (absolute path works best for AutoCAD) .IP \(bu 2 \fBsize_in_pixel\fP – image size in pixel as (x, y) tuple .IP \(bu 2 \fBname\fP – image name for internal use, None for using filename as name (best for AutoCAD) .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 \fI\%Tutorial for Image and ImageDef\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_raster_variables(frame: int = 0, quality: int = 1, units: str = \(aqm\(aq) Set raster variables. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBframe\fP – 0 = do not show image frame; 1 = show image frame .IP \(bu 2 \fBquality\fP – 0 = draft; 1 = high .IP \(bu 2 \fBunits\fP – .sp units for inserting images. This defines the real world unit for one drawing unit for the purpose of inserting and scaling images with an associated resolution. .TS center; |l|l|. _ T{ mm T} T{ Millimeter T} _ T{ cm T} T{ Centimeter T} _ T{ m T} T{ Meter (ezdxf default) T} _ T{ km T} T{ Kilometer T} _ T{ in T} T{ Inch T} _ T{ ft T} T{ Foot T} _ T{ yd T} T{ Yard T} _ T{ mi T} T{ Mile T} _ .TE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_wipeout_variables(frame=0) Set wipeout variables. .INDENT 7.0 .TP .B Parameters \fBframe\fP – 0 = do not show image frame; 1 = show image frame .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_underlay_def(filename: str, fmt: str = \(aqext\(aq, name: str | None = None) Add an \fBUnderlayDef\fP entity to the drawing (OBJECTS section). The \fIfilename\fP is the underlay file name as relative or absolute path and \fIfmt\fP as string (pdf, dwf, dgn). The underlay definition is required to create an underlay reference. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – underlay file name .IP \(bu 2 \fBfmt\fP – file format as string “pdf”|”dwf”|”dgn” or “ext” for getting file format from filename extension .IP \(bu 2 \fBname\fP – pdf format = page number to display; dgn format = “default”; dwf: ???? .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 \fI\%Tutorial for Underlay and UnderlayDefinition\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_xref_def(filename: str, name: str, flags: int = BLK_XREF | BLK_EXTERNAL) Add an external reference (xref) definition to the blocks section. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – external reference filename .IP \(bu 2 \fBname\fP – name of the xref block .IP \(bu 2 \fBflags\fP – block flags .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B layouts_and_blocks() -> Iterator[GenericLayoutType] Iterate over all layouts (modelspace and paperspace) and all block definitions. .UNINDENT .INDENT 7.0 .TP .B chain_layouts_and_blocks() -> Iterator[\fI\%DXFEntity\fP] Chain entity spaces of all layouts and blocks. Yields an iterator for all entities in all layouts and blocks. .UNINDENT .INDENT 7.0 .TP .B reset_fingerprint_guid() Reset fingerprint GUID. .UNINDENT .INDENT 7.0 .TP .B reset_version_guid() Reset version GUID. .UNINDENT .INDENT 7.0 .TP .B set_modelspace_vport(height, center=(0, 0), *, dxfattribs=None) -> \fI\%VPort\fP Set initial view/zoom location for the modelspace, this replaces the current “*Active” viewport configuration (\fI\%VPort\fP) and reset the coordinate system to the \fI\%WCS\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBheight\fP – modelspace area to view .IP \(bu 2 \fBcenter\fP – modelspace location to view in the center of the CAD application window. .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the VPORT entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B audit() -> Auditor Checks document integrity and fixes all fixable problems, not fixable problems are stored in \fBAuditor.errors\fP\&. .sp If you are messing around with internal structures, call this method before saving to be sure to export valid DXF documents, but be aware this is a long\-running task. .UNINDENT .INDENT 7.0 .TP .B validate(print_report=True) -> bool Simple way to run an audit process. Fixes all fixable problems, return \fBFalse\fP if not fixable errors occurs. Prints a report of resolved and unrecoverable errors, if requested. .INDENT 7.0 .TP .B Parameters \fBprint_report\fP – print report to stdout .UNINDENT .sp Returns: \fBFalse\fP if unrecoverable errors exist .UNINDENT .INDENT 7.0 .TP .B ezdxf_metadata() -> \fI\%MetaData\fP Returns the \fIezdxf\fP \fI\%ezdxf.document.MetaData\fP object, which manages \fIezdxf\fP and custom metadata in DXF files. For more information see: \fI\%Ezdxf Metadata\fP\&. .UNINDENT .UNINDENT .SS Recover .sp This module provides functions to “recover” ASCII DXF documents with structural flaws, which prevents the regular \fI\%ezdxf.read()\fP and \fI\%ezdxf.readfile()\fP functions to load the document. .sp The \fI\%read()\fP and \fI\%readfile()\fP functions will repair as much flaws as possible and run the required audit process automatically afterwards and return the result of this audit process: .INDENT 0.0 .INDENT 3.5 .sp .EX import sys import ezdxf from ezdxf import recover try: doc, auditor = recover.readfile(\(dqmessy.dxf\(dq) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file.\(aq) sys.exit(2) # DXF file can still have unrecoverable errors, but this is maybe just # a problem when saving the recovered DXF file. if auditor.has_errors: auditor.print_error_report() .EE .UNINDENT .UNINDENT .sp The loading functions also decode DXF\-Unicode encoding automatically e.g. “\eU+00FC” \-> “ü”. All these efforts cost some time, loading the DXF document with \fI\%ezdxf.read()\fP or \fI\%ezdxf.readfile()\fP is faster. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 This module will load DXF files which have decoding errors, most likely binary data stored in XRECORD entities, these errors are logged as unrecoverable \fBAuditError.DECODE_ERRORS\fP in the \fBAuditor.errors\fP attribute, but no \fBDXFStructureError\fP exception will be raised, because for many use cases this errors can be ignored. .sp Writing such files back with \fIezdxf\fP may create \fBinvalid\fP DXF files, or at least some \fBinformation will be lost\fP \- handle with care! .sp To avoid this problem use \fBrecover.readfile(filename, errors=\(aqstrict\(aq)\fP which raises an \fBUnicodeDecodeError\fP exception for such binary data. Catch the exception and handle this DXF files as unrecoverable. .UNINDENT .UNINDENT .SS Loading Scenarios .SS 1. It will work .sp Mostly DXF files from AutoCAD or BricsCAD (e.g. for In\-house solutions): .INDENT 0.0 .INDENT 3.5 .sp .EX try: doc = ezdxf.readfile(name) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file: {name}.\(aq) sys.exit(2) .EE .UNINDENT .UNINDENT .SS 2. DXF file with minor flaws .sp DXF files have only minor flaws, like undefined resources: .INDENT 0.0 .INDENT 3.5 .sp .EX try: doc = ezdxf.readfile(name) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file: {name}.\(aq) sys.exit(2) auditor = doc.audit() if auditor.has_errors: auditor.print_error_report() .EE .UNINDENT .UNINDENT .SS 3. Try Hard .sp From trusted and untrusted sources but with good hopes, the worst case works like a cache miss, you pay for the first try and pay the extra fee for the recover mode: .INDENT 0.0 .INDENT 3.5 .sp .EX try: # Fast path: doc = ezdxf.readfile(name) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) # Catch all DXF errors: except ezdxf.DXFError: try: # Slow path including fixing low level structures: doc, auditor = recover.readfile(name) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file: {name}.\(aq) sys.exit(2) # DXF file can still have unrecoverable errors, but this is maybe # just a problem when saving the recovered DXF file. if auditor.has_errors: print(f\(aqFound unrecoverable errors in DXF file: {name}.\(aq) auditor.print_error_report() .EE .UNINDENT .UNINDENT .SS 4. Just use the slow recover module .sp Untrusted sources and expecting many invalid or corrupted DXF files, you always pay an extra fee for the recover mode: .INDENT 0.0 .INDENT 3.5 .sp .EX try: # Slow path including fixing low level structures: doc, auditor = recover.readfile(name) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file: {name}.\(aq) sys.exit(2) # DXF file can still have unrecoverable errors, but this is maybe # just a problem when saving the recovered DXF file. if auditor.has_errors: print(f\(aqFound unrecoverable errors in DXF file: {name}.\(aq) auditor.print_error_report() .EE .UNINDENT .UNINDENT .SS 5. Unrecoverable Decoding Errors .sp If files contain binary data which can not be decoded by the document encoding, it is maybe the best to ignore these files, this works in normal and recover mode: .INDENT 0.0 .INDENT 3.5 .sp .EX try: doc, auditor = recover.readfile(name, errors=\(aqstrict\(aq) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file: {name}.\(aq) sys.exit(2) except UnicodeDecodeError: print(f\(aqDecoding error in DXF file: {name}.\(aq) sys.exit(3) .EE .UNINDENT .UNINDENT .SS 6. Ignore/Locate Decoding Errors .sp Sometimes ignoring decoding errors can recover DXF files or at least you can detect where the decoding errors occur: .INDENT 0.0 .INDENT 3.5 .sp .EX try: doc, auditor = recover.readfile(name, errors=\(aqignore\(aq) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file: {name}.\(aq) sys.exit(2) if auditor.has_errors: auditor.print_report() .EE .UNINDENT .UNINDENT .sp The error messages with code \fBAuditError.DECODING_ERROR\fP shows the approximate line number of the decoding error: “Fixed unicode decoding error near line: xxx.” .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 This functions can handle only ASCII DXF files! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.recover.readfile(filename: str | \fI\%Path\fP, errors: str = \(aqsurrogateescape\(aq) -> tuple[\fI\%Drawing\fP, Auditor] Read a DXF document from file system similar to \fI\%ezdxf.readfile()\fP, but this function will repair as many flaws as possible, runs the required audit process automatically the DXF document and the \fBAuditor\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – file\-system name of the DXF document to load .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFStructureError\fP – for invalid or corrupted DXF structures .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.recover.read(stream: BinaryIO, errors: str = \(aqsurrogateescape\(aq) -> tuple[\fI\%Drawing\fP, Auditor] Read a DXF document from a binary\-stream similar to \fI\%ezdxf.read()\fP, but this function will detect the text encoding automatically and repair as many flaws as possible, runs the required audit process afterwards and returns the DXF document and the \fBAuditor\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstream\fP – data stream to load in binary read mode .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFStructureError\fP – for invalid or corrupted DXF structures .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.recover.explore(filename: str | \fI\%Path\fP, errors: str = \(aqignore\(aq) -> tuple[\fI\%Drawing\fP, Auditor] Read a DXF document from file system similar to \fI\%readfile()\fP, but this function will use a special tag loader, which tries to recover the tag stream if invalid tags occur. This function is intended to load corrupted DXF files and should only be used to explore such files, data loss is very likely. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – file\-system name of the DXF document to load .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFStructureError\fP – for invalid or corrupted DXF structures .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .SS r12strict .sp New in version 1.1. .sp Due to ACAD release 14 the resource names, such as layer\-, linetype, text style\-, dimstyle\- and block names, were limited to 31 characters in length and all names were uppercase. .sp Names can include the letters A to Z, the numerals 0 to 9, and the special characters, dollar sign \fB\(dq$\(dq\fP, underscore \fB\(dq_\(dq\fP, hyphen \fB\(dq\-\(dq\fP and the asterix \fB\(dq*\(dq\fP as first character for special names like anonymous blocks. Most applications do not care about that and work fine with longer names and any characters used in names for some exceptions, but of course Autodesk applications are very picky about that. .sp The function \fI\%make_acad_compatible()\fP makes DXF R12 drawings to 100% compatible to Autodesk products and does everything at once, but the different processing steps can be called manually. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 This module can only process DXF R12 file and will throw a \fBDXFVersionError\fP otherwise. For exporting any DXF document as DXF R12 use the \fI\%ezdxf.addons.r12export\fP add\-on. .UNINDENT .UNINDENT .SS Usage .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import r12strict doc = ezdxf.readfile(\(dqr12sloppy.dxf\(dq) r12strict.make_acad_compatible(doc) doc.saveas(\(dqr12strict.dxf\(dq) .EE .UNINDENT .UNINDENT .SS Functions .TS center; |l|l|. _ T{ \fI\%make_acad_compatible\fP T} T{ Apply all DXF R12 requirements, so Autodesk products will load the document. T} _ T{ \fI\%translate_names\fP T} T{ Translate table and block names into strict DXF R12 names. T} _ T{ \fI\%clean\fP T} T{ Removes all features that are not supported for DXF R12 by Autodesk products. T} _ .TE .INDENT 0.0 .TP .B ezdxf.r12strict.make_acad_compatible(doc: \fI\%Drawing\fP) -> None Apply all DXF R12 requirements, so Autodesk products will load the document. .UNINDENT .INDENT 0.0 .TP .B ezdxf.r12strict.translate_names(doc: \fI\%Drawing\fP) -> None Translate table and block names into strict DXF R12 names. .sp ACAD Releases upto 14 limit names to 31 characters in length and all names are uppercase. Names can include the letters A to Z, the numerals 0 to 9, and the special characters, dollar sign ($), underscore (_), hyphen (\-) and the asterix (*) as first character for special names like anonymous blocks. .sp Most applications do not care about that and work fine with longer names and any characters used in names for some exceptions, but of course Autodesk applications are very picky about that. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 This is a destructive process and modifies the internals of the DXF document. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.r12strict.clean(doc: \fI\%Drawing\fP) -> None Removes all features that are not supported for DXF R12 by Autodesk products. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.r12strict.R12NameTranslator Translate table and block names into strict DXF R12 names. .sp ACAD Releases upto 14 limit names to 31 characters in length and all names are uppercase. Names can include the letters A to Z, the numerals 0 to 9, and the special characters, dollar sign ($), underscore (_), hyphen (\-) and the asterix (*) as first character for special names like anonymous blocks. .INDENT 7.0 .TP .B reset() -> None .UNINDENT .INDENT 7.0 .TP .B translate(name: str) -> str .UNINDENT .UNINDENT .SS Application Settings .sp This is a high\-level module for working with CAD application settings and behaviors. None of these settings have any influence on the behavior of \fIezdxf\fP, since \fIezdxf\fP only takes care of the content of the DXF file and not of the way it is presented to the user. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 You need to understand that these settings work at the application level, \fIezdxf\fP cannot force an application to do something in a certain way! The functionality of this module has been tested with Autodesk TrueView and BricsCAD, other applications may show different results or ignore the settings. .UNINDENT .UNINDENT .SS Set Current Properties .sp The current properties are used by the CAD application to create new entities, these settings do not affect how \fIezdxf\fP creates new entities. .sp The module \fI\%ezdxf.gfxattribs\fP provides the class \fI\%GfxAttribs()\fP, which can load the current graphical entity settings from the HEADER section for creating new entities by \fIezdxf\fP: \fI\%load_from_header()\fP .INDENT 0.0 .TP .B ezdxf.appsettings.set_current_layer(doc: \fI\%Drawing\fP, name: str) Set current layer. .UNINDENT .INDENT 0.0 .TP .B ezdxf.appsettings.set_current_color(doc: \fI\%Drawing\fP, color: int) Set current \fI\%AutoCAD Color Index (ACI)\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.appsettings.set_current_linetype(doc: \fI\%Drawing\fP, name: str) Set current linetype. .UNINDENT .INDENT 0.0 .TP .B ezdxf.appsettings.set_current_lineweight(doc: \fI\%Drawing\fP, lineweight: int) Set current lineweight, see \fI\%Lineweights\fP reference for valid values. .UNINDENT .INDENT 0.0 .TP .B ezdxf.appsettings.set_current_linetype_scale(doc: \fI\%Drawing\fP, scale: float) Set current linetype scale. .UNINDENT .INDENT 0.0 .TP .B ezdxf.appsettings.set_current_textstyle(doc: \fI\%Drawing\fP, name: str) Set current text style. .UNINDENT .INDENT 0.0 .TP .B ezdxf.appsettings.set_current_dimstyle(doc: \fI\%Drawing\fP, name: str) Set current dimstyle. .UNINDENT .INDENT 0.0 .TP .B ezdxf.appsettings.set_current_dimstyle_attribs(doc: \fI\%Drawing\fP, name: str) Set current dimstyle and copy all dimstyle attributes to the HEADER section. .UNINDENT .INDENT 0.0 .TP .B ezdxf.appsettings.set_lineweight_display_style(doc: \fI\%Drawing\fP, end_caps: \fI\%EndCaps\fP, join_style: \fI\%JoinStyle\fP) -> None Set the style of end caps and joints for linear entities when displaying line weights. These settings only affect objects created afterwards. .UNINDENT .SS Restore the WCS .INDENT 0.0 .TP .B ezdxf.appsettings.restore_wcs(doc: \fI\%Drawing\fP) Restore the UCS settings in the HEADER section to the \fI\%WCS\fP and reset all active viewports to the WCS. .UNINDENT .SS Update Extents .INDENT 0.0 .TP .B ezdxf.appsettings.update_extents(doc: \fI\%Drawing\fP) -> \fI\%BoundingBox\fP Calculate the extents of the model space, update the HEADER variables $EXTMIN and $EXTMAX and returns the result as \fI\%ezdxf.math.BoundingBox\fP\&. Note that this function uses the \fI\%ezdxf.bbox\fP module to calculate the extent of the model space. This module is not very fast and not very accurate for text and ignores all \fI\%ACIS\fP based entities. .sp The function updates only the values in the HEADER section, to zoom the active viewport to this extents, use this recipe: .INDENT 7.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import zoom, appsettings doc = ezdxf.readfile(\(dqyour.dxf\(dq) extents = appsettings.update_extents(doc) zoom.center(doc.modelspace(), extents.center, extents.size) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 the \fI\%ezdxf.bbox\fP module to understand the limitations of the extent calculation .IP \(bu 2 the \fI\%ezdxf.zoom\fP module .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Show Lineweight .INDENT 0.0 .TP .B ezdxf.appsettings.show_lineweight(doc: \fI\%Drawing\fP, state=True) -> None The CAD application or DXF viewer should show lines and curves with “thickness” (lineweight) if \fIstate\fP is \fBTrue\fP\&. .UNINDENT .SS DXF Structures .SS Sections .SS Header Section .sp The drawing settings are stored in the HEADER section, which is accessible by the \fI\%header\fP attribute of the \fI\%Drawing\fP object. See the online documentation from Autodesk for available \fI\%header variables\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: \fI\%HEADER Section\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.header.HeaderSection .INDENT 7.0 .TP .B custom_vars Stores the custom drawing properties in a \fI\%CustomVars\fP object. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of header variables. .UNINDENT .INDENT 7.0 .TP .B __contains__(key) -> bool Returns \fBTrue\fP if header variable \fIkey\fP exist. .UNINDENT .INDENT 7.0 .TP .B varnames() -> KeysView Returns an iterable of all header variable names. .UNINDENT .INDENT 7.0 .TP .B get(key: str, default: Any = None) -> Any Returns value of header variable \fIkey\fP if exist, else the \fIdefault\fP value. .UNINDENT .INDENT 7.0 .TP .B __getitem__(key: str) -> Any Get header variable \fIkey\fP by index operator like: \fBdrawing.header[\(aq$ACADVER\(aq]\fP .UNINDENT .INDENT 7.0 .TP .B __setitem__(key: str, value: Any) -> None Set header variable \fIkey\fP to \fIvalue\fP by index operator like: \fBdrawing.header[\(aq$ANGDIR\(aq] = 1\fP .UNINDENT .INDENT 7.0 .TP .B __delitem__(key: str) -> None Delete header variable \fIkey\fP by index operator like: \fBdel drawing.header[\(aq$ANGDIR\(aq]\fP .UNINDENT .INDENT 7.0 .TP .B reset_wcs() Reset the current UCS settings to the \fI\%WCS\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.header.CustomVars The \fI\%CustomVars\fP class stores custom properties in the DXF header as $CUSTOMPROPERTYTAG and $CUSTOMPROPERTY values. Custom properties require DXF R2004 or later, \fIezdxf\fP can create custom properties for older DXF versions as well, but AutoCAD will not show that properties. .INDENT 7.0 .TP .B properties A list of custom header properties, stored as string tuples \fB(tag, value)\fP\&. Multiple occurrence of the same custom tag is allowed, but not well supported by the interface. This is a standard Python list and it’s safe to modify this list as long as you just use tuples of strings. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Count of custom properties. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[tuple[str, str]] Iterate over all custom properties as \fB(tag, value)\fP tuples. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Remove all custom properties. .UNINDENT .INDENT 7.0 .TP .B get(tag: str, default: str | None = None) Returns the value of the first custom property \fItag\fP\&. .UNINDENT .INDENT 7.0 .TP .B has_tag(tag: str) -> bool Returns \fBTrue\fP if custom property \fItag\fP exist. .UNINDENT .INDENT 7.0 .TP .B append(tag: str, value: str) -> None Add custom property as \fB(tag, value)\fP tuple. .UNINDENT .INDENT 7.0 .TP .B replace(tag: str, value: str) -> None Replaces the value of the first custom property \fItag\fP by a new \fIvalue\fP\&. .sp Raises \fBDXFValueError\fP if \fItag\fP does not exist. .UNINDENT .INDENT 7.0 .TP .B remove(tag: str, all: bool = False) -> None Removes the first occurrence of custom property \fItag\fP, removes all occurrences if \fIall\fP is \fBTrue\fP\&. .sp Raises \fI:class:\(gaDXFValueError\fP if \fItag\fP does not exist. .UNINDENT .UNINDENT .SS Classes Section .sp The CLASSES section in DXF files holds the information for application\-defined classes whose instances appear in \fI\%Layout\fP objects. As usual package user there is no need to bother about CLASSES. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: \fI\%CLASSES Section\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.classes.ClassesSection .INDENT 7.0 .TP .B classes Storage of all \fI\%DXFClass\fP objects, they are not stored in the entities database, because CLASS instances do not have a handle attribute. .UNINDENT .INDENT 7.0 .TP .B register() .UNINDENT .INDENT 7.0 .TP .B add_class(name: str) Register a known class by \fIname\fP\&. .UNINDENT .INDENT 7.0 .TP .B get(name: str) -> DXFClass Returns the first class matching \fIname\fP\&. .sp Storage key is the \fB(name, cpp_class_name)\fP tuple, because there are some classes with the same \fBname\fP but different \fBcpp_class_names\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_required_classes(dxfversion: str) -> None Add all required CLASS definitions for the specified DXF version. .UNINDENT .INDENT 7.0 .TP .B update_instance_counters() -> None Update CLASS instance counter for all registered classes, requires DXF R2004+. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.DXFClass Information about application\-defined classes. .INDENT 7.0 .TP .B dxf.name Class DXF record name. .UNINDENT .INDENT 7.0 .TP .B dxf.cpp_class_name C++ class name. Used to bind with software that defines object class behavior. .UNINDENT .INDENT 7.0 .TP .B dxf.app_name Application name. Posted in Alert box when a class definition listed in this section is not currently loaded. .UNINDENT .INDENT 7.0 .TP .B dxf.flags Proxy capabilities flag .TS center; |l|l|. _ T{ 0 T} T{ No operations allowed (0) T} _ T{ 1 T} T{ Erase allowed (0x1) T} _ T{ 2 T} T{ Transform allowed (0x2) T} _ T{ 4 T} T{ Color change allowed (0x4) T} _ T{ 8 T} T{ Layer change allowed (0x8) T} _ T{ 16 T} T{ Linetype change allowed (0x10) T} _ T{ 32 T} T{ Linetype scale change allowed (0x20) T} _ T{ 64 T} T{ Visibility change allowed (0x40) T} _ T{ 128 T} T{ Cloning allowed (0x80) T} _ T{ 256 T} T{ Lineweight change allowed (0x100) T} _ T{ 512 T} T{ Plot Style Name change allowed (0x200) T} _ T{ 895 T} T{ All operations except cloning allowed (0x37F) T} _ T{ 1023 T} T{ All operations allowed (0x3FF) T} _ T{ 1024 T} T{ Disables proxy warning dialog (0x400) T} _ T{ 32768 T} T{ R13 format proxy (0x8000) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.instance_count Instance count for a custom class. .UNINDENT .INDENT 7.0 .TP .B dxf.was_a_proxy Set to \fB1\fP if class was not loaded when this DXF file was created, and \fB0\fP otherwise. .UNINDENT .INDENT 7.0 .TP .B dxf.is_an_entity Set to \fB1\fP if class was derived from the \fI\%DXFGraphic\fP class and can reside in layouts. If \fB0\fP, instances may appear only in the OBJECTS section. .UNINDENT .INDENT 7.0 .TP .B key Unique name as \fB(name, cpp_class_name)\fP tuple. .UNINDENT .UNINDENT .SS Tables Section .sp The TABLES section is the home of all TABLE objects of a DXF document. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: \fI\%TABLES Section\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.tables.TablesSection .INDENT 7.0 .TP .B layers \fI\%LayerTable\fP maintaining the \fI\%Layer\fP objects .UNINDENT .INDENT 7.0 .TP .B linetypes \fI\%LinetypeTable\fP maintaining the \fI\%Linetype\fP objects .UNINDENT .INDENT 7.0 .TP .B styles \fI\%TextstyleTable\fP maintaining the \fI\%Textstyle\fP objects .UNINDENT .INDENT 7.0 .TP .B dimstyles \fI\%DimStyleTable\fP maintaining the \fI\%DimStyle\fP objects .UNINDENT .INDENT 7.0 .TP .B appids \fI\%AppIDTable\fP maintaining the \fI\%AppID\fP objects .UNINDENT .INDENT 7.0 .TP .B ucs \fI\%UCSTable\fP maintaining the \fBUCSTable\fP objects .UNINDENT .INDENT 7.0 .TP .B views \fI\%ViewTable\fP maintaining the \fI\%View\fP objects .UNINDENT .INDENT 7.0 .TP .B viewports \fI\%ViewportTable\fP maintaining the \fI\%VPort\fP objects .UNINDENT .INDENT 7.0 .TP .B block_records \fI\%BlockRecordTable\fP maintaining the \fI\%BlockRecord\fP objects .UNINDENT .UNINDENT .SS Blocks Section .sp The BLOCKS section is the home all block definitions (\fI\%BlockLayout\fP) of a DXF document. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Blocks are an essential building block of the DXF format. Most blocks are referenced are by name, and renaming or deleting a block is not as easy as it seems, since there is no overall index where all block references appear, and such block references can also reside in custom data or even custom entities, therefore renaming or deleting block definitions can damage a DXF file! .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: \fI\%BLOCKS Section\fP and \fI\%Block Management Structures\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.blocks.BlocksSection .INDENT 7.0 .TP .B __iter__() -> Iterator[BlockLayout] Iterable of all \fI\%BlockLayout\fP objects. .UNINDENT .INDENT 7.0 .TP .B __contains__(name: str) -> bool Returns \fBTrue\fP if \fI\%BlockLayout\fP \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B __getitem__(name: str) -> BlockLayout Returns \fI\%BlockLayout\fP \fIname\fP, raises \fBDXFKeyError\fP if \fIname\fP not exist. .UNINDENT .INDENT 7.0 .TP .B __delitem__(name: str) -> None Deletes \fI\%BlockLayout\fP \fIname\fP and all of its content, raises \fBDXFKeyError\fP if \fIname\fP not exist. .UNINDENT .INDENT 7.0 .TP .B get(name: str, default=None) -> BlockLayout Returns \fI\%BlockLayout\fP \fIname\fP, returns \fIdefault\fP if \fIname\fP not exist. .UNINDENT .INDENT 7.0 .TP .B new(name: str, base_point: \fI\%UVec\fP = NULLVEC, dxfattribs=None) -> BlockLayout Create and add a new \fI\%BlockLayout\fP, \fIname\fP is the BLOCK name, \fIbase_point\fP is the insertion point of the BLOCK. .UNINDENT .INDENT 7.0 .TP .B new_anonymous_block(type_char: str = \(aqU\(aq, base_point: \fI\%UVec\fP = NULLVEC) -> BlockLayout Create and add a new anonymous \fI\%BlockLayout\fP, \fItype_char\fP is the BLOCK type, \fIbase_point\fP is the insertion point of the BLOCK. .INDENT 7.0 .INDENT 3.5 .TS center; |l|l|. _ T{ type_char T} T{ Anonymous Block Type T} _ T{ \fB\(aqU\(aq\fP T} T{ \fB\(aq*U###\(aq\fP anonymous BLOCK T} _ T{ \fB\(aqE\(aq\fP T} T{ \fB\(aq*E###\(aq\fP anonymous non\-uniformly scaled BLOCK T} _ T{ \fB\(aqX\(aq\fP T} T{ \fB\(aq*X###\(aq\fP anonymous HATCH graphic T} _ T{ \fB\(aqD\(aq\fP T} T{ \fB\(aq*D###\(aq\fP anonymous DIMENSION graphic T} _ T{ \fB\(aqA\(aq\fP T} T{ \fB\(aq*A###\(aq\fP anonymous GROUP T} _ T{ \fB\(aqT\(aq\fP T} T{ \fB\(aq*T###\(aq\fP anonymous block for ACAD_TABLE content T} _ .TE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rename_block(old_name: str, new_name: str) -> None Rename \fI\%BlockLayout\fP \fIold_name\fP to \fInew_name\fP .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 This is a low\-level tool and does not rename the block references, so all block references to \fIold_name\fP are pointing to a non\-existing block definition! .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete_block(name: str, safe: bool = True) -> None Delete block. Checks if the block is still referenced if \fIsafe\fP is \fBTrue\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – block name (case insensitive) .IP \(bu 2 \fBsafe\fP – check if the block is still referenced or a special block without explicit references .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFKeyError\fP – if block not exists .IP \(bu 2 \fI\%DXFBlockInUseError\fP – if block is still referenced, and safe is \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete_all_blocks() -> None Delete all blocks without references except modelspace\- or paperspace layout blocks, special arrow\- and anonymous blocks (DIMENSION, ACAD_TABLE). .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 There could exist references to blocks which are not documented in the DXF reference, hidden in extended data sections or application defined data, which could invalidate a DXF document if these blocks will be deleted. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Entities Section .sp The ENTITIES section is the home of all entities of the \fI\%Modelspace\fP and the active \fI\%Paperspace\fP layout. This is a real section in the DXF file but in \fIezdxf\fP the \fI\%EntitySection\fP is just a linked entity space of these two layouts. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: \fI\%ENTITIES Section\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.entities.EntitySection .INDENT 7.0 .TP .B __iter__() -> Iterator[\fI\%DXFEntity\fP] Returns an iterator for all entities of the modelspace and the active paperspace. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns the count of all entities in the modelspace and the active paperspace. .UNINDENT .UNINDENT .SS Objects Section .sp The OBJECTS section is the home of all none graphical objects of a DXF document. The OBJECTS section is accessible by the \fBDrawing.objects\fP attribute. .sp Convenience methods of the \fI\%Drawing\fP object to create essential structures in the OBJECTS section: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 IMAGEDEF: \fI\%add_image_def()\fP .IP \(bu 2 UNDERLAYDEF: \fI\%add_underlay_def()\fP .IP \(bu 2 RASTERVARIABLES: \fI\%set_raster_variables()\fP .IP \(bu 2 WIPEOUTVARIABLES: \fI\%set_wipeout_variables()\fP .UNINDENT .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: \fI\%OBJECTS Section\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.objects.ObjectsSection .INDENT 7.0 .TP .B rootdict Returns the root DICTIONARY, or as AutoCAD calls it: the named DICTIONARY. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns the count of all DXF objects in the OBJECTS section. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[\fI\%DXFObject\fP] Returns an iterator of all DXF objects in the OBJECTS section. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index) -> \fI\%DXFObject\fP Get entity at \fIindex\fP\&. .sp The underlying data structure for storing DXF objects is organized like a standard Python list, therefore \fIindex\fP can be any valid list indexing or slicing term, like a single index \fBobjects[\-1]\fP to get the last entity, or an index slice \fBobjects[:10]\fP to get the first 10 or fewer objects as \fBlist[DXFObject]\fP\&. .UNINDENT .INDENT 7.0 .TP .B __contains__(entity) Returns \fBTrue\fP if \fIentity\fP stored in OBJECTS section. .INDENT 7.0 .TP .B Parameters \fBentity\fP – \fBDXFObject\fP or handle as hex string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B query(query: str = \(aq*\(aq) -> \fI\%EntityQuery\fP Get all DXF objects matching the \fI\%Entity Query String\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_dictionary(owner: str = \(aq0\(aq, hard_owned: bool = True) -> Dictionary Add new \fI\%Dictionary\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBowner\fP – handle to owner as hex string. .IP \(bu 2 \fBhard_owned\fP – \fBTrue\fP to treat entries as hard owned. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_dictionary_with_default(owner=\(aq0\(aq, default=\(aq0\(aq, hard_owned: bool = True) -> \fI\%DictionaryWithDefault\fP Add new \fI\%DictionaryWithDefault\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBowner\fP – handle to owner as hex string. .IP \(bu 2 \fBdefault\fP – handle to default entry. .IP \(bu 2 \fBhard_owned\fP – \fBTrue\fP to treat entries as hard owned. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_dictionary_var(owner: str = \(aq0\(aq, value: str = \(aq\(aq) -> \fI\%DictionaryVar\fP Add a new \fI\%DictionaryVar\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBowner\fP – handle to owner as hex string. .IP \(bu 2 \fBvalue\fP – value as string .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_geodata(owner: str = \(aq0\(aq, dxfattribs=None) -> \fI\%GeoData\fP Creates a new \fBGeoData\fP entity and replaces existing ones. The GEODATA entity resides in the OBJECTS section and NOT in the layout entity space, and it is linked to the layout by an extension dictionary located in BLOCK_RECORD of the layout. .sp The GEODATA entity requires DXF version R2010+. The DXF Reference does not document if other layouts than model space supports geo referencing, so getting/setting geo data may only make sense for the model space layout, but it is also available in paper space layouts. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBowner\fP – handle to owner as hex string .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%GeoData\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_image_def(filename: str, size_in_pixel: tuple[int, int], name: str | None = None) -> \fI\%ImageDef\fP Add an image definition to the objects section. .sp Add an \fBImageDef\fP entity to the drawing (objects section). \fIfilename\fP is the image file name as relative or absolute path and \fIsize_in_pixel\fP is the image size in pixel as (x, y) tuple. To avoid dependencies to external packages, \fIezdxf\fP can not determine the image size by itself. Returns a \fBImageDef\fP entity which is needed to create an image reference. \fIname\fP is the internal image name, if set to \fBNone\fP, name is auto\-generated. .sp Absolute image paths works best for AutoCAD but not really good, you have to update external references manually in AutoCAD, which is not possible in TrueView. If the drawing units differ from 1 meter, you also have to use: \fI\%set_raster_variables()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – image file name (absolute path works best for AutoCAD) .IP \(bu 2 \fBsize_in_pixel\fP – image size in pixel as (x, y) tuple .IP \(bu 2 \fBname\fP – image name for internal use, None for using filename as name (best for AutoCAD) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_placeholder(owner: str = \(aq0\(aq) -> \fI\%Placeholder\fP Add a new \fI\%Placeholder\fP object. .INDENT 7.0 .TP .B Parameters \fBowner\fP – handle to owner as hex string. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_underlay_def(filename: str, fmt: str = \(aqpdf\(aq, name: str | None = None) -> \fI\%UnderlayDefinition\fP Add an \fBUnderlayDefinition\fP entity to the drawing (OBJECTS section). \fIfilename\fP is the underlay file name as relative or absolute path and \fIfmt\fP as string (pdf, dwf, dgn). The underlay definition is required to create an underlay reference. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – underlay file name .IP \(bu 2 \fBfmt\fP – file format as string \fB\(aqpdf\(aq|\(aqdwf\(aq|\(aqdgn\(aq\fP .IP \(bu 2 \fBname\fP – pdf format = page number to display; dgn format = \fB\(aqdefault\(aq\fP; dwf: ???? .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_xrecord(owner: str = \(aq0\(aq) -> \fI\%XRecord\fP Add a new \fI\%XRecord\fP object. .INDENT 7.0 .TP .B Parameters \fBowner\fP – handle to owner as hex string. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_raster_variables(frame: int = 0, quality: int = 1, units: str = \(aqm\(aq) -> None Set raster variables. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBframe\fP – \fB0\fP = do not show image frame; \fB1\fP = show image frame .IP \(bu 2 \fBquality\fP – \fB0\fP = draft; \fB1\fP = high .IP \(bu 2 \fBunits\fP – .sp units for inserting images. This defines the real world unit for one drawing unit for the purpose of inserting and scaling images with an associated resolution. .INDENT 2.0 .INDENT 3.5 .TS center; |l|l|. _ T{ mm T} T{ Millimeter T} _ T{ cm T} T{ Centimeter T} _ T{ m T} T{ Meter (ezdxf default) T} _ T{ km T} T{ Kilometer T} _ T{ in T} T{ Inch T} _ T{ ft T} T{ Foot T} _ T{ yd T} T{ Yard T} _ T{ mi T} T{ Mile T} _ T{ none T} T{ None T} _ .TE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp (internal API), public interface \fBset_raster_variables()\fP .UNINDENT .INDENT 7.0 .TP .B set_wipeout_variables(frame: int = 0) -> None Set wipeout variables. .INDENT 7.0 .TP .B Parameters \fBframe\fP – \fB0\fP = do not show image frame; \fB1\fP = show image frame .UNINDENT .sp (internal API) .UNINDENT .UNINDENT .SS Tables .SS Table Classes .SS Generic Table Class .INDENT 0.0 .TP .B class ezdxf.sections.table.Table Generic collection of table entries. Table entry names are case insensitive: “Test” == “TEST”. .INDENT 7.0 .TP .B static key(name: str) -> str Unified table entry key. .UNINDENT .INDENT 7.0 .TP .B has_entry(name: str) -> bool Returns \fBTrue\fP if a table entry \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B __contains__(name: str) -> bool Returns \fBTrue\fP if a table entry \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Count of table entries. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[T] Iterable of all table entries. .UNINDENT .INDENT 7.0 .TP .B new(name: str, dxfattribs=None) -> T Create a new table entry \fIname\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – name of table entry .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for table entry .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get(name: str) -> T Returns table entry \fIname\fP\&. .INDENT 7.0 .TP .B Parameters \fBname\fP – name of table entry, case\-insensitive .TP .B Raises \fI\%DXFTableEntryError\fP – table entry does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B remove(name: str) -> None Removes table entry \fIname\fP\&. .INDENT 7.0 .TP .B Parameters \fBname\fP – name of table entry, case\-insensitive .TP .B Raises \fI\%DXFTableEntryError\fP – table entry does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B duplicate_entry(name: str, new_name: str) -> T Returns a new table entry \fInew_name\fP as copy of \fIname\fP, replaces entry \fInew_name\fP if already exist. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – name of table entry, case\-insensitive .IP \(bu 2 \fBnew_name\fP – name of duplicated table entry .UNINDENT .TP .B Raises \fI\%DXFTableEntryError\fP – table entry does not exist .UNINDENT .UNINDENT .UNINDENT .SS Layer Table .INDENT 0.0 .TP .B class ezdxf.sections.table.LayerTable Subclass of \fI\%Table\fP\&. .sp Collection of \fI\%Layer\fP objects. .INDENT 7.0 .TP .B add(name: str, *, color: int = const.BYLAYER, true_color: int | None = None, linetype: str = \(aqContinuous\(aq, lineweight: int = const.LINEWEIGHT_BYLAYER, plot: bool = True, transparency: float | None = None, dxfattribs=None) -> Layer Add a new \fI\%Layer\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – layer name .IP \(bu 2 \fBcolor\fP (\fIint\fP) – \fI\%AutoCAD Color Index (ACI)\fP value, default is BYLAYER .IP \(bu 2 \fBtrue_color\fP (\fIint\fP) – true color value, use \fBezdxf.rgb2int()\fP to create \fBint\fP values from RGB values .IP \(bu 2 \fBlinetype\fP (\fIstr\fP) – line type name, default is “Continuous” .IP \(bu 2 \fBlineweight\fP (\fIint\fP) – line weight, default is BYLAYER .IP \(bu 2 \fBplot\fP (\fIbool\fP) – plot layer as bool, default is \fBTrue\fP .IP \(bu 2 \fBtransparency\fP – transparency value in the range [0, 1], where 1 is 100% transparent and 0 is opaque .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Linetype Table .INDENT 0.0 .TP .B class ezdxf.sections.table.LinetypeTable Subclass of \fI\%Table\fP\&. .sp Collection of \fI\%Linetype\fP objects. .INDENT 7.0 .TP .B add(name: str, pattern: Sequence[float] | str, *, description: str = \(aq\(aq, length: float = 0.0, dxfattribs=None) -> Linetype Add a new line type entry. The simple line type pattern is a list of floats \fB[total_pattern_length, elem1, elem2, ...]\fP where an element > 0 is a line, an element < 0 is a gap and an element == 0.0 is a dot. The definition for complex line types are strings, like: \fB\(aqA,.5,\-.2,[\(dqGAS\(dq,STANDARD,S=.1,U=0.0,X=\-0.1,Y=\-.05],\-.25\(aq\fP similar to the line type definitions stored in the line definition \fI\&.lin\fP files, for more information see the tutorial about complex line types. Be aware that not many CAD applications and DXF viewers support complex linetypes. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for simple line types\fP .IP \(bu 2 \fI\%Tutorial for complex line types\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – line type name .IP \(bu 2 \fBpattern\fP – line type pattern as list of floats or as a string .IP \(bu 2 \fBdescription\fP (\fIstr\fP) – line type description, optional .IP \(bu 2 \fBlength\fP (\fIfloat\fP) – total pattern length, only for complex line types required .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Style Table .INDENT 0.0 .TP .B class ezdxf.sections.table.TextstyleTable Subclass of \fI\%Table\fP\&. .sp Collection of \fI\%Textstyle\fP objects. .INDENT 7.0 .TP .B add(name: str, *, font: str, dxfattribs=None) -> Textstyle Add a new text style entry for TTF fonts. The entry must not yet exist, otherwise an \fBDXFTableEntryError\fP exception will be raised. .sp Finding the TTF font files is the task of the DXF viewer and each viewer is different (hint: support files). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – text style name .IP \(bu 2 \fBfont\fP (\fIstr\fP) – TTF font file name like “Arial.ttf”, the real font file name from the file system is required and only the Windows filesystem is case\-insensitive. .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_shx(shx_file_name: str, *, dxfattribs=None) -> Textstyle Add a new shape font (SHX file) entry. These are special text style entries and have no name. The entry must not yet exist, otherwise an \fBDXFTableEntryError\fP exception will be raised. .sp Locating the SHX files in the filesystem is the task of the DXF viewer and each viewer is different (hint: support files). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBshx_file_name\fP (\fIstr\fP) – shape file name like “gdt.shx” .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_shx(shx_file_name: str) -> Textstyle Get existing entry for a shape file (SHX file), or create a new entry. .sp Locating the SHX files in the filesystem is the task of the DXF viewer and each viewer is different (hint: support files). .INDENT 7.0 .TP .B Parameters \fBshx_file_name\fP (\fIstr\fP) – shape file name like “gdt.shx” .UNINDENT .UNINDENT .INDENT 7.0 .TP .B find_shx(shx_file_name: str) -> Textstyle | None Find the shape file (SHX file) text style table entry, by a case\-insensitive search. .sp A shape file table entry has no name, so you have to search by the font attribute. .INDENT 7.0 .TP .B Parameters \fBshx_file_name\fP (\fIstr\fP) – shape file name like “gdt.shx” .UNINDENT .UNINDENT .INDENT 7.0 .TP .B discard_shx(shx_file_name: str) -> None Discard the shape file (SHX file) text style table entry. Does not raise an exception if the entry does not exist. .INDENT 7.0 .TP .B Parameters \fBshx_file_name\fP (\fIstr\fP) – shape file name like “gdt.shx” .UNINDENT .UNINDENT .UNINDENT .SS DimStyle Table .INDENT 0.0 .TP .B class ezdxf.sections.table.DimStyleTable Subclass of \fI\%Table\fP\&. .sp Collection of \fI\%DimStyle\fP objects. .INDENT 7.0 .TP .B add(name: str, *, dxfattribs=None) -> DimStyle Add a new dimension style table entry. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – dimension style name .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – DXF attributes .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS AppID Table .INDENT 0.0 .TP .B class ezdxf.sections.table.AppIDTable Subclass of \fI\%Table\fP\&. .sp Collection of \fI\%AppID\fP objects. .INDENT 7.0 .TP .B add(name: str, *, dxfattribs=None) -> AppID Add a new appid table entry. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – appid name .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – DXF attributes .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS UCS Table .INDENT 0.0 .TP .B class ezdxf.sections.table.UCSTable Subclass of \fI\%Table\fP\&. .sp Collection of \fI\%UCSTableEntry\fP objects. .INDENT 7.0 .TP .B add(name: str, *, dxfattribs=None) -> UCSTableEntry Add a new UCS table entry. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – UCS name .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – DXF attributes .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS View Table .INDENT 0.0 .TP .B class ezdxf.sections.table.ViewTable Subclass of \fI\%Table\fP\&. .sp Collection of \fI\%View\fP objects. .INDENT 7.0 .TP .B add(name: str, *, dxfattribs=None) -> View Add a new view table entry. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – view name .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – DXF attributes .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Viewport Table .INDENT 0.0 .TP .B class ezdxf.sections.table.ViewportTable The viewport table stores the modelspace viewport configurations. A viewport configuration is a tiled view of multiple viewports or just one viewport. In contrast to other tables the viewport table can have multiple entries with the same name, because all viewport entries of a multi\-viewport configuration are having the same name \- the viewport configuration name. .sp The name of the actual displayed viewport configuration is “*ACTIVE”. .sp Duplication of table entries is not supported: \fBduplicate_entry()\fP raises \fBNotImplementedError\fP .INDENT 7.0 .TP .B add(name: str, *, dxfattribs=None) -> VPort Add a new modelspace viewport entry. A modelspace viewport configuration can consist of multiple viewport entries with the same name. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – viewport name, multiple entries possible .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_config(self, name: str) -> List[\fI\%VPort\fP] Returns a list of \fI\%VPort\fP objects, for the multi\-viewport configuration \fIname\fP\&. .UNINDENT .INDENT 7.0 .TP .B delete_config(name: str) -> None Delete all \fI\%VPort\fP objects of the multi\-viewport configuration \fIname\fP\&. .UNINDENT .UNINDENT .SS Block Record Table .INDENT 0.0 .TP .B class ezdxf.sections.table.BlockRecordTable Subclass of \fI\%Table\fP\&. .sp Collection of \fI\%BlockRecord\fP objects. .INDENT 7.0 .TP .B add(name: str, *, dxfattribs=None) -> BlockRecord Add a new block record table entry. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstr\fP) – block record name .IP \(bu 2 \fBdxfattribs\fP (\fIdict\fP) – DXF attributes .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Layer .sp LAYER (\fI\%DXF Reference\fP) definition, defines attribute values for entities on this layer for their attributes set to \fBBYLAYER\fP\&. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 A layer assignment is just an attribute of a DXF entity, it’s not an entity container, the entities are stored in layouts and blocks and the assigned layer is not important for that. .sp Deleting a layer entry does not delete the entities which reference this layer! .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqLAYER\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.layers.new()\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Basic concepts of \fI\%Layers\fP and \fI\%Tutorial for Layers\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Layer .INDENT 7.0 .TP .B dxf.handle DXF handle (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%LayerTable\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name Layer name, case insensitive and can not contain any of this characters: \fB<>/\e\(dq:;?*|=\(ga\fP (str) .UNINDENT .INDENT 7.0 .TP .B dxf.flags Layer flags (bit\-coded values, feature for experts) .TS center; |l|l|. _ T{ 1 T} T{ Layer is frozen; otherwise layer is thawed; use \fBis_frozen()\fP, \fBfreeze()\fP and \fBthaw()\fP T} _ T{ 2 T} T{ Layer is frozen by default in new viewports T} _ T{ 4 T} T{ Layer is locked; use \fBis_locked()\fP, \fBlock()\fP, \fBunlock()\fP T} _ T{ 16 T} T{ If set, table entry is externally dependent on an xref T} _ T{ 32 T} T{ If both this bit and bit 16 are set, the externally dependent xref has been successfully resolved T} _ T{ 64 T} T{ If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited. (This flag is for the benefit of AutoCAD commands. It can be ignored by most programs that read DXF files and need not be set by programs that write DXF files) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.color Layer color, but use property \fI\%Layer.color\fP to get/set color value, because color is negative for layer status \fIoff\fP (int) .UNINDENT .INDENT 7.0 .TP .B dxf.true_color Layer true color value as int, use property \fI\%Layer.rgb\fP to set/get true color value as (r, g, b) tuple. .sp (requires DXF R2004) .UNINDENT .INDENT 7.0 .TP .B dxf.linetype Name of line type (str) .UNINDENT .INDENT 7.0 .TP .B dxf.plot Plot flag (int). Whether entities belonging to this layer should be drawn when the document is exported (plotted) to pdf. Does not affect visibility inside the CAD application itself. .TS center; |l|l|. _ T{ 1 T} T{ plot layer (default value) T} _ T{ 0 T} T{ don’t plot layer T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.lineweight Line weight in mm times 100 (e.g. 0.13mm = 13). Smallest line weight is 13 and biggest line weight is 200, values outside this range prevents AutoCAD from loading the file. .sp \fBezdxf.lldxf.const.LINEWEIGHT_DEFAULT\fP for using global default line weight. .sp (requires DXF R13) .UNINDENT .INDENT 7.0 .TP .B dxf.plotstyle_handle Handle to plot style name? .sp (requires DXF R13) .UNINDENT .INDENT 7.0 .TP .B dxf.material_handle Handle to default \fBMaterial\fP\&. .sp (requires DXF R13) .UNINDENT .INDENT 7.0 .TP .B rgb Get/set DXF attribute \fI\%dxf.true_color\fP as (r, g, b) tuple, returns \fBNone\fP if attribute \fI\%dxf.true_color\fP is not set. .INDENT 7.0 .INDENT 3.5 .sp .EX layer.rgb = (30, 40, 50) r, g, b = layer.rgb .EE .UNINDENT .UNINDENT .sp This is the recommend method to get/set RGB values, when ever possible do not use the DXF low level attribute \fI\%dxf.true_color\fP\&. .UNINDENT .INDENT 7.0 .TP .B color Get/set layer color, preferred method for getting the layer color, because \fI\%dxf.color\fP is negative for layer status \fIoff\fP\&. .UNINDENT .INDENT 7.0 .TP .B description Get/set layer description as string .UNINDENT .INDENT 7.0 .TP .B transparency Get/set layer transparency as float value in the range from 0 to 1. 0 for no transparency (opaque) and 1 for 100% transparency. .UNINDENT .INDENT 7.0 .TP .B is_frozen() -> bool Returns \fBTrue\fP if layer is frozen. .UNINDENT .INDENT 7.0 .TP .B freeze() -> None Freeze layer. .UNINDENT .INDENT 7.0 .TP .B thaw() -> None Thaw layer. .UNINDENT .INDENT 7.0 .TP .B is_locked() -> bool Returns \fBTrue\fP if layer is locked. .UNINDENT .INDENT 7.0 .TP .B lock() -> None Lock layer, entities on this layer are not editable \- just important in CAD applications. .UNINDENT .INDENT 7.0 .TP .B unlock() -> None Unlock layer, entities on this layer are editable \- just important in CAD applications. .UNINDENT .INDENT 7.0 .TP .B is_off() -> bool Returns \fBTrue\fP if layer is off. .UNINDENT .INDENT 7.0 .TP .B is_on() -> bool Returns \fBTrue\fP if layer is on. .UNINDENT .INDENT 7.0 .TP .B on() -> None Switch layer \fIon\fP (visible). .UNINDENT .INDENT 7.0 .TP .B off() -> None Switch layer \fIoff\fP (invisible). .UNINDENT .INDENT 7.0 .TP .B get_color() -> int Use property \fI\%Layer.color\fP instead. .UNINDENT .INDENT 7.0 .TP .B set_color(value: int) -> None Use property \fI\%Layer.color\fP instead. .UNINDENT .INDENT 7.0 .TP .B rename(name: str) -> None Rename layer and all known (documented) references to this layer. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 The DXF format is not consistent in storing layer references, the layers are mostly referenced by their case\-insensitive name, some later introduced entities do reference layers by handle, which is the safer way in the context of renaming layers. .sp There is no complete overview of where layer references are stored, third\-party entities are black\-boxes with unknown content and layer names could be stored in the extended data section of any DXF entity or in XRECORD entities. Which means that in some rare cases references to the old layer name can persist, at least this does not invalidate the DXF document. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters \fBname\fP – new layer name .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBValueError\fP – \fIname\fP contains invalid characters: <>/\(dq:;?*|=\(ga .IP \(bu 2 \fBValueError\fP – layer \fIname\fP already exist .IP \(bu 2 \fBValueError\fP – renaming of layers \fB\(aq0\(aq\fP and \fB\(aqDEFPOINTS\(aq\fP not possible .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_vp_overrides() -> \fI\%LayerOverrides\fP Returns the \fI\%LayerOverrides\fP object for this layer. .UNINDENT .UNINDENT .SS LayerOverrides .INDENT 0.0 .TP .B class ezdxf.entities.LayerOverrides This object stores the layer attribute overridden in \fI\%Viewport\fP entities, where each \fI\%Viewport\fP can have individual layer attribute overrides. .sp Layer attributes which can be overridden: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 ACI color .IP \(bu 2 true color (rgb) .IP \(bu 2 linetype .IP \(bu 2 lineweight .IP \(bu 2 transparency .UNINDENT .UNINDENT .UNINDENT .sp Get the override object for a certain layer by the \fI\%Layer.get_vp_overrides()\fP method. .sp It is important to write changes back by calling \fI\%commit()\fP, otherwise the changes are lost. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 The implementation of this feature as DXF structures is not documented by the DXF reference, so if you encounter problems or errors, \fBALWAYS\fP provide the DXF files, otherwise it is not possible to help. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_overrides(vp_handle: str | None = None) -> bool Returns \fBTrue\fP if attribute overrides exist for the given \fI\%Viewport\fP handle. Returns \fBTrue\fP if \fIany\fP attribute overrides exist if the given handle is \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B commit() -> None Write \fI\%Viewport\fP overrides back into the \fI\%Layer\fP entity. Without a commit() all changes are lost! .UNINDENT .INDENT 7.0 .TP .B get_color(vp_handle: str) -> int Returns the \fI\%AutoCAD Color Index (ACI)\fP override or the original layer value if no override exist. .UNINDENT .INDENT 7.0 .TP .B set_color(vp_handle: str, value: int) -> None Override the \fI\%AutoCAD Color Index (ACI)\fP\&. .INDENT 7.0 .TP .B Raises \fBValueError\fP – invalid color value .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_rgb(vp_handle: str) -> \fI\%RGB\fP | None Returns the RGB override or the original layer value if no override exist. Returns \fBNone\fP if no true color value is set. .UNINDENT .INDENT 7.0 .TP .B set_rgb(vp_handle: str, value: \fI\%RGB\fP | None) Set the RGB override as (red, gree, blue) tuple or \fBNone\fP to remove the true color setting. .INDENT 7.0 .TP .B Raises \fBValueError\fP – invalid RGB value .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_transparency(vp_handle: str) -> float Returns the transparency override or the original layer value if no override exist. Returns 0.0 for opaque and 1.0 for fully transparent. .UNINDENT .INDENT 7.0 .TP .B set_transparency(vp_handle: str, value: float) -> None Set the transparency override. A transparency of 0.0 is opaque and 1.0 is fully transparent. .INDENT 7.0 .TP .B Raises \fBValueError\fP – invalid transparency value .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_linetype(vp_handle: str) -> str Returns the linetype override or the original layer value if no override exist. .UNINDENT .INDENT 7.0 .TP .B set_linetype(vp_handle: str, value: str) -> None Set the linetype override. .INDENT 7.0 .TP .B Raises \fBValueError\fP – linetype without a LTYPE table entry .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_lineweight(vp_handle: str) -> int Returns the lineweight override or the original layer value if no override exist. .UNINDENT .INDENT 7.0 .TP .B set_lineweight(vp_handle: str, value: int) -> None Set the lineweight override. .INDENT 7.0 .TP .B Raises \fBValueError\fP – invalid lineweight value .UNINDENT .UNINDENT .INDENT 7.0 .TP .B discard(vp_handle: str | None = None) -> None Discard all attribute overrides for the given \fI\%Viewport\fP handle or for all \fI\%Viewport\fP entities if the handle is \fBNone\fP\&. .UNINDENT .UNINDENT .SS Style .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 DXF is not a layout preserving data format like PDF. It is more similar to the MS Word format. Many applications can open MS Word documents, but the displayed or printed document does not look perfect like the result of MS Word. .sp The final rendering of DXF files is highly dependent on the interpretation of DXF entities by the rendering engine, and the DXF reference does not provide any guidelines for rendering entities. The biggest visual differences of CAD applications are the text renderings, therefore the only way to get the exact same result is to use the same CAD application. .sp The DXF format does not and \fBcan not\fP embed TTF fonts like the PDF format! .UNINDENT .UNINDENT .sp The \fI\%Textstyle\fP entity defines a text style (\fI\%DXF Reference\fP), and can be used by the entities: \fI\%Text\fP, \fI\%Attrib\fP, \fBAttdef\fP, \fI\%MText\fP, \fI\%Dimension\fP, \fI\%Leader\fP and \fI\%MultiLeader\fP\&. .sp Example to create a new text style “Arial” and to apply this text style: .INDENT 0.0 .INDENT 3.5 .sp .EX doc.styles.add(\(dqArial\(dq, font=\(dqArial.ttf\(dq) msp = doc.modelspace() msp.add_text(\(dqmy text\(dq, dxfattribs={\(dqstyle\(dq: \(dqArial\(dq}) .EE .UNINDENT .UNINDENT .sp The settings stored in the \fI\%Textstyle\fP entity are the default text style values used by CAD applications if the text settings are not stored in the text entity itself. But not all setting are substituted by the default value. The \fBheight\fP or \fBwidth\fP attribute must be stored in the text entities itself in order to influence the appearance of the text. It is \fIrecommended\fP that you do not rely on the default settings in the \fI\%Textstyle\fP entity, set all attributes in the text entity itself if supported. .SS Font Settings .sp Just a few settings are available exclusive by the \fI\%Textstyle\fP entity: .sp The most important setting is the \fBfont\fP attribute, this attribute defines the rendering font as raw TTF file name, e.g. “Arial.ttf” or “OpenSansCondensed\-Light.ttf”, this file name is often \fBnot\fP the name displayed in GUI application and you have to digg down into the fonts folder e.g. (“C:\eWindows\eFonts”) to get the real file name for the TTF font. Do not include the path! [image] .sp AutoCAD supports beyond the legacy SHX fonts \fBonly\fP TTF fonts. The SHX font format is not documented and only available in some CAD applications. The \fIezdxf\fP \fI\%drawing\fP add\-on replaces the SHX fonts by TTF fonts, which look similar to the SHX fonts, unfortunately the license of these fonts is unclear, therefore they can not be packaged with \fIezdxf\fP\&. They are installed automatically if you use an Autodesk product like \fI\%TrueView\fP, or search the internet at you own risk for these TTF fonts. .sp The extended font data can provide extra information for the font, it is stored in the XDATA section, not well documented and not widely supported. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The DXF format does not and \fBcan not\fP embed TTF fonts like the PDF format! .sp You need to make sure that the CAD application is properly configured to have access to the system fonts. The DXF format has no setting where the CAD application should search for fonts, and does not guarantee that the text rendering on other computers or operating systems looks the same as on your current system on which you created the DXF. .UNINDENT .UNINDENT .sp The second exclusive setting is the vertical text flag in \fBTextstyle.flags\fP\&. The vertical text style is enabled for \fIall\fP entities using the text style. Vertical text works only for SHX fonts and is not supported for TTF fonts (in AutoCAD) and is works only for the single line entities \fI\%Text\fP and \fI\%Attrib\fP\&. Most CAD applications beside AutoCAD and BricsCAD do not support vertical text rendering and even AutoCAD and BricsCAD have problems with vertical text rendering in some circumstances. Using the vertical text feature is not recommended. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqSTYLE\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.styles.new()\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Text\fP and DXF internals for \fI\%DIMSTYLE Table\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Textstyle .INDENT 7.0 .TP .B property is_backward: bool Get/set text generation flag BACKWARDS, for mirrored text along the x\-axis. .UNINDENT .INDENT 7.0 .TP .B property is_upside_down: bool Get/set text generation flag UPSIDE_DOWN, for mirrored text along the y\-axis. .UNINDENT .INDENT 7.0 .TP .B property is_vertical_stacked: bool Get/set style flag VERTICAL_STACKED, for vertical stacked text. .UNINDENT .INDENT 7.0 .TP .B property is_shape_file: bool \fBTrue\fP if entry describes a shape. .UNINDENT .INDENT 7.0 .TP .B dxf.handle DXF handle (feature for experts). .UNINDENT .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%TextstyleTable\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name Style name (str) .UNINDENT .INDENT 7.0 .TP .B dxf.flags Style flags (feature for experts). .TS center; |l|l|. _ T{ 1 T} T{ If set, this entry describes a shape T} _ T{ 4 T} T{ Vertical text T} _ T{ 16 T} T{ If set, table entry is externally dependent on an xref T} _ T{ 32 T} T{ If both this bit and bit 16 are set, the externally dependent xref has been successfully resolved T} _ T{ 64 T} T{ If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited. (This flag is only for the benefit of AutoCAD)commands. It can be ignored by most programs that read DXF files and need not be set by programs that write DXF files) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.height Fixed height in drawing units as float value, 0 for not fixed. .UNINDENT .INDENT 7.0 .TP .B dxf.width Width factor as float value, default value is 1. .UNINDENT .INDENT 7.0 .TP .B dxf.oblique Oblique (slanting) angle in degrees as float value, default value is 0 for no slanting. .UNINDENT .INDENT 7.0 .TP .B dxf.generation_flags Text generations flags as int value. .TS center; |l|l|. _ T{ 2 T} T{ text is backward (mirrored along the x\-axis) T} _ T{ 4 T} T{ text is upside down (mirrored about the base line) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.last_height Last height used in drawing units as float value. .UNINDENT .INDENT 7.0 .TP .B dxf.font Raw font file name as string without leading path, e.g. “Arial.ttf” for TTF fonts or the SHX font name like “TXT” or “TXT.SHX”. .UNINDENT .INDENT 7.0 .TP .B dxf.bigfont Big font name as string, blank if none. No documentation how to use this feature, maybe just a legacy artifact. .UNINDENT .INDENT 7.0 .TP .B property has_extended_font_data: bool Returns \fBTrue\fP if extended font data is present. .UNINDENT .INDENT 7.0 .TP .B get_extended_font_data() -> tuple[str, bool, bool] Returns extended font data as tuple (font\-family, italic\-flag, bold\-flag). .sp The extended font data is optional and not reliable! Returns (“”, \fBFalse\fP, \fBFalse\fP) if extended font data is not present. .UNINDENT .INDENT 7.0 .TP .B set_extended_font_data(family: str = \(aq\(aq, *, italic=False, bold=False) -> None Set extended font data, the font\-family name \fIfamily\fP is not validated by \fIezdxf\fP\&. Overwrites existing data. .UNINDENT .INDENT 7.0 .TP .B discard_extended_font_data() Discard extended font data. .UNINDENT .INDENT 7.0 .TP .B make_font(cap_height: float | None = None, width_factor: float | None = None) -> \fI\%fonts.AbstractFont\fP Returns a font abstraction \fBAbstractFont\fP for this text style. Returns a font for a cap height of 1, if the text style has auto height (\fI\%Textstyle.dxf.height\fP is 0) and the given \fIcap_height\fP is \fBNone\fP or 0. Uses the \fI\%Textstyle.dxf.width\fP attribute if the given \fIwidth_factor\fP is \fBNone\fP or 0, the default value is 1. The attribute \fBTextstyle.dxf.big_font\fP is ignored. .UNINDENT .UNINDENT .SS Linetype .sp Defines a linetype (\fI\%DXF Reference\fP). .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqLTYPE\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.linetypes.new()\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Creating Linetype Pattern\fP .sp DXF Internals: \fI\%LTYPE Table\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Linetype .INDENT 7.0 .TP .B dxf.name Linetype name (str). .UNINDENT .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%Table\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.description Linetype description (str). .UNINDENT .INDENT 7.0 .TP .B dxf.length Total pattern length in drawing units (float). .UNINDENT .INDENT 7.0 .TP .B dxf.items Number of linetype elements (int). .UNINDENT .UNINDENT .SS DimStyle [image] [image] .sp DIMSTYLE (\fI\%DXF Reference\fP) defines the appearance of \fI\%Dimension\fP entities. Each of this dimension variables starting with \fB\(dqdim...\(dq\fP can be overridden for any \fI\%Dimension\fP entity individually. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqDIMSTYLE\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.dimstyles.new()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.DimStyle .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%Table\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name Dimension style name. .UNINDENT .INDENT 7.0 .TP .B dxf.flags Standard flag values (bit\-coded values): .TS center; |l|l|. _ T{ 16 T} T{ If set, table entry is externally dependent on an xref T} _ T{ 32 T} T{ If both this bit and bit 16 are set, the externally dependent XREF has been successfully resolved T} _ T{ 64 T} T{ If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited. (This flag is only for the benefit of AutoCAD) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.dimpost Prefix/suffix for primary units dimension values. .UNINDENT .INDENT 7.0 .TP .B dxf.dimapost Prefix/suffix for alternate units dimensions. .UNINDENT .INDENT 7.0 .TP .B dxf.dimblk Block type to use for both arrowheads as name string. .UNINDENT .INDENT 7.0 .TP .B dxf.dimblk1 Block type to use for first arrowhead as name string. .UNINDENT .INDENT 7.0 .TP .B dxf.dimblk2 Block type to use for second arrowhead as name string. .UNINDENT .INDENT 7.0 .TP .B dxf.dimscale Global dimension feature scale factor. (default=1) .UNINDENT .INDENT 7.0 .TP .B dxf.dimasz Dimension line and arrowhead size. (default=0.25) .UNINDENT .INDENT 7.0 .TP .B dxf.dimexo Distance from origin points to extension lines. (default imperial=0.0625, default metric=0.625) .UNINDENT .INDENT 7.0 .TP .B dxf.dimdli Incremental spacing between baseline dimensions. (default imperial=0.38, default metric=3.75) .UNINDENT .INDENT 7.0 .TP .B dxf.dimexe Extension line distance beyond dimension line. (default imperial=0.28, default metric=2.25) .UNINDENT .INDENT 7.0 .TP .B dxf.dimrnd Rounding value for decimal dimensions. (default=0) .sp Rounds all dimensioning distances to the specified value, for instance, if DIMRND is set to 0.25, all distances round to the nearest 0.25 unit. If you set DIMRND to 1.0, all distances round to the nearest integer. .UNINDENT .INDENT 7.0 .TP .B dxf.dimdle Dimension line extension beyond extension lines. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtp Upper tolerance value for tolerance dimensions. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtm Lower tolerance value for tolerance dimensions. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtxt Size of dimension text. (default imperial=0.28, default metric=2.5) .UNINDENT .INDENT 7.0 .TP .B dxf.dimcen Controls placement of center marks or centerlines. (default imperial=0.09, default metric=2.5) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtsz Controls size of dimension line tick marks drawn instead of arrowheads. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimaltf Alternate units dimension scale factor. (default=25.4) .UNINDENT .INDENT 7.0 .TP .B dxf.dimlfac Scale factor for linear dimension values. (default=1) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtvp Vertical position of text above or below dimension line if \fI\%dimtad\fP is 0. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtfac Scale factor for fractional or tolerance text size. (default=1) .UNINDENT .INDENT 7.0 .TP .B dxf.dimgap Gap size between dimension line and dimension text. (default imperial=0.09, default metric=0.625) .UNINDENT .INDENT 7.0 .TP .B dxf.dimaltrnd Rounding value for alternate dimension units. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtol Toggles creation of appended tolerance dimensions. (default imperial=1, default metric=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimlim Toggles creation of limits\-style dimension text. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtih Orientation of text inside extension lines. (default imperial=1, default metric=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtoh Orientation of text outside extension lines. (default imperial=1, default metric=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimse1 Toggles suppression of first extension line. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimse2 Toggles suppression of second extension line. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtad Sets vertical text placement relative to dimension line. (default imperial=0, default metric=1) .TS center; |l|l|. _ T{ 0 T} T{ center T} _ T{ 1 T} T{ above T} _ T{ 2 T} T{ outside, handled like above by \fIezdxf\fP T} _ T{ 3 T} T{ JIS, handled like above by \fIezdxf\fP T} _ T{ 4 T} T{ below T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.dimzin Zero suppression for primary units dimensions. (default imperial=0, default metric=8) .sp Values 0\-3 affect feet\-and\-inch dimensions only. .TS center; |l|l|. _ T{ 0 T} T{ Suppresses zero feet and precisely zero inches T} _ T{ 1 T} T{ Includes zero feet and precisely zero inches T} _ T{ 2 T} T{ Includes zero feet and suppresses zero inches T} _ T{ 3 T} T{ Includes zero inches and suppresses zero feet T} _ T{ 4 T} T{ Suppresses leading zeros in decimal dimensions (for example, 0.5000 becomes .5000) T} _ T{ 8 T} T{ Suppresses trailing zeros in decimal dimensions (for example, 12.5000 becomes 12.5) T} _ T{ 12 T} T{ Suppresses both leading and trailing zeros (for example, 0.5000 becomes .5) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.dimazin Controls zero suppression for angular dimensions. (default=0) .TS center; |l|l|. _ T{ 0 T} T{ Displays all leading and trailing zeros T} _ T{ 1 T} T{ Suppresses leading zeros in decimal dimensions (for example, 0.5000 becomes .5000) T} _ T{ 2 T} T{ Suppresses trailing zeros in decimal dimensions (for example, 12.5000 becomes 12.5) T} _ T{ 3 T} T{ Suppresses leading and trailing zeros (for example, 0.5000 becomes .5) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.dimalt Enables or disables alternate units dimensioning. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimaltd Controls decimal places for alternate units dimensions. (default imperial=2, default metric=3) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtofl Toggles forced dimension line creation. (default imperial=0, default metric=1) .UNINDENT .INDENT 7.0 .TP .B dxf.dimsah Toggles appearance of arrowhead blocks. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtix Toggles forced placement of text between extension lines. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimsoxd Suppresses dimension lines outside extension lines. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimclrd Dimension line, arrowhead, and leader line color. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimclre Dimension extension line color. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimclrt Dimension text color. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimadec Controls the number of decimal places for angular dimensions. .UNINDENT .INDENT 7.0 .TP .B dxf.dimunit Obsolete, now use DIMLUNIT AND DIMFRAC .UNINDENT .INDENT 7.0 .TP .B dxf.dimdec Decimal places for dimension values. (default imperial=4, default metric=2) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtdec Decimal places for primary units tolerance values. (default imperial=4, default metric=2) .UNINDENT .INDENT 7.0 .TP .B dxf.dimaltu Units format for alternate units dimensions. (default=2) .UNINDENT .INDENT 7.0 .TP .B dxf.dimalttd Decimal places for alternate units tolerance values. (default imperial=4, default metric=2) .UNINDENT .INDENT 7.0 .TP .B dxf.dimaunit Unit format for angular dimension values. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimfrac Controls the fraction format used for architectural and fractional dimensions. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimlunit Specifies units for all nonangular dimensions. (default=2) .UNINDENT .INDENT 7.0 .TP .B dxf.dimdsep Specifies a single character to use as a decimal separator. (default imperial = “.”, default metric = “,”) This is an integer value, use \fBord(\(dq.\(dq)\fP to write value. .UNINDENT .INDENT 7.0 .TP .B dxf.dimtmove Controls the format of dimension text when it is moved. (default=0) .TS center; |l|l|. _ T{ 0 T} T{ Moves the dimension line with dimension text T} _ T{ 1 T} T{ Adds a leader when dimension text is moved T} _ T{ 2 T} T{ Allows text to be moved freely without a leader T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.dimjust Horizontal justification of dimension text. (default=0) .TS center; |l|l|. _ T{ 0 T} T{ Center of dimension line T} _ T{ 1 T} T{ Left side of the dimension line, near first extension line T} _ T{ 2 T} T{ Right side of the dimension line, near second extension line T} _ T{ 3 T} T{ Over first extension line T} _ T{ 4 T} T{ Over second extension line T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.dimsd1 Toggles suppression of first dimension line. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimsd2 Toggles suppression of second dimension line. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtolj Vertical justification for dimension tolerance text. (default=1) .TS center; |l|l|. _ T{ 0 T} T{ Align with bottom line of dimension text T} _ T{ 1 T} T{ Align vertical centered to dimension text T} _ T{ 2 T} T{ Align with top line of dimension text T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.dimtzin Zero suppression for tolerances values, see \fI\%DimStyle.dxf.dimzin\fP .UNINDENT .INDENT 7.0 .TP .B dxf.dimaltz Zero suppression for alternate units dimension values. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimalttz Zero suppression for alternate units tolerance values. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimfit Obsolete, now use DIMATFIT and DIMTMOVE .UNINDENT .INDENT 7.0 .TP .B dxf.dimupt Controls user placement of dimension line and text. (default=0) .UNINDENT .INDENT 7.0 .TP .B dxf.dimatfit Controls placement of text and arrowheads when there is insufficient space between the extension lines. (default=3) .UNINDENT .INDENT 7.0 .TP .B dxf.dimtxsty Text style used for dimension text by name. .UNINDENT .INDENT 7.0 .TP .B dxf.dimtxsty_handle Text style used for dimension text by handle of STYLE entry. (use \fI\%DimStyle.dxf.dimtxsty\fP to get/set text style by name) .UNINDENT .INDENT 7.0 .TP .B dxf.dimldrblk Specify arrowhead used for leaders by name. .UNINDENT .INDENT 7.0 .TP .B dxf.dimldrblk_handle Specify arrowhead used for leaders by handle of referenced block. (use \fI\%DimStyle.dxf.dimldrblk\fP to get/set arrowhead by name) .UNINDENT .INDENT 7.0 .TP .B dxf.dimblk_handle Block type to use for both arrowheads, handle of referenced block. (use \fI\%DimStyle.dxf.dimblk\fP to get/set arrowheads by name) .UNINDENT .INDENT 7.0 .TP .B dxf.dimblk1_handle Block type to use for first arrowhead, handle of referenced block. (use \fI\%DimStyle.dxf.dimblk1\fP to get/set arrowhead by name) .UNINDENT .INDENT 7.0 .TP .B dxf.dimblk2_handle Block type to use for second arrowhead, handle of referenced block. (use \fI\%DimStyle.dxf.dimblk2\fP to get/set arrowhead by name) .UNINDENT .INDENT 7.0 .TP .B dxf.dimlwd Lineweight value for dimension lines. (default=\-2, BYBLOCK) .UNINDENT .INDENT 7.0 .TP .B dxf.dimlwe Lineweight value for extension lines. (default=\-2, BYBLOCK) .UNINDENT .INDENT 7.0 .TP .B dxf.dimltype Specifies the linetype used for the dimension line as linetype name, requires DXF R2007+ .UNINDENT .INDENT 7.0 .TP .B dxf.dimltype_handle Specifies the linetype used for the dimension line as handle to LTYPE entry, requires DXF R2007+ (use \fI\%DimStyle.dxf.dimltype\fP to get/set linetype by name) .UNINDENT .INDENT 7.0 .TP .B dxf.dimltex1 Specifies the linetype used for the extension line 1 as linetype name, requires DXF R2007+ .UNINDENT .INDENT 7.0 .TP .B dxf.dimlex1_handle Specifies the linetype used for the extension line 1 as handle to LTYPE entry, requires DXF R2007+ (use \fI\%DimStyle.dxf.dimltex1\fP to get/set linetype by name) .UNINDENT .INDENT 7.0 .TP .B dxf.dimltex2 Specifies the linetype used for the extension line 2 as linetype name, requires DXF R2007+ .UNINDENT .INDENT 7.0 .TP .B dxf.dimlex2_handle Specifies the linetype used for the extension line 2 as handle to LTYPE entry, requires DXF R2007+ (use \fI\%DimStyle.dxf.dimltex2\fP to get/set linetype by name) .UNINDENT .INDENT 7.0 .TP .B dxf.dimfxlon Extension line has fixed length if set to 1, requires DXF R2007+ .UNINDENT .INDENT 7.0 .TP .B dxf.dimfxl Length of extension line below dimension line if fixed (\fBDimStyle.dxf.dimtfxlon\fP == 1), \fBDimStyle.dxf.dimexen\fP defines the length above the dimension line, requires DXF R2007+ .UNINDENT .INDENT 7.0 .TP .B dxf.dimtfill Text fill 0=off; 1=background color; 2=custom color (see \fI\%DimStyle.dxf.dimtfillclr\fP), requires DXF R2007+ .UNINDENT .INDENT 7.0 .TP .B dxf.dimtfillclr Text fill custom color as color index (1\-255), requires DXF R2007+ .UNINDENT .INDENT 7.0 .TP .B dxf.dimarcsym Display arc symbol, supported only by \fI\%ArcDimension\fP: .TS center; |l|l|. _ T{ 0 T} T{ arc symbol preceding the measurement text T} _ T{ 1 T} T{ arc symbol above the measurement text T} _ T{ 2 T} T{ disable arc symbol T} _ .TE .UNINDENT .INDENT 7.0 .TP .B copy_to_header(doc: \fI\%Drawing\fP) Copy all dimension style variables to HEADER section of \fIdoc\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_arrows(blk: str = \(aq\(aq, blk1: str = \(aq\(aq, blk2: str = \(aq\(aq, ldrblk: str = \(aq\(aq) -> None Set arrows by block names or AutoCAD standard arrow names, set DIMTSZ to \fB0\fP which disables tick. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBblk\fP – block/arrow name for both arrows, if DIMSAH is 0 .IP \(bu 2 \fBblk1\fP – block/arrow name for first arrow, if DIMSAH is 1 .IP \(bu 2 \fBblk2\fP – block/arrow name for second arrow, if DIMSAH is 1 .IP \(bu 2 \fBldrblk\fP – block/arrow name for leader .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_tick(size: float = 1) -> None Set tick \fIsize\fP, which also disables arrows, a tick is just an oblique stroke as marker. .INDENT 7.0 .TP .B Parameters \fBsize\fP – arrow size in drawing units .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_text_align(halign: str | None = None, valign: str | None = None, vshift: float | None = None) -> None Set measurement text alignment, \fIhalign\fP defines the horizontal alignment (requires DXF R2000+), \fIvalign\fP defines the vertical alignment, \fIabove1\fP and \fIabove2\fP means above extension line 1 or 2 and aligned with extension line. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBhalign\fP – “left”, “right”, “center”, “above1”, “above2”, requires DXF R2000+ .IP \(bu 2 \fBvalign\fP – “above”, “center”, “below” .IP \(bu 2 \fBvshift\fP – vertical text shift, if \fIvalign\fP is “center”; >0 shift upward, <0 shift downwards .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_text_format(prefix: str = \(aq\(aq, postfix: str = \(aq\(aq, rnd: float | None = None, dec: int | None = None, sep: str | None = None, leading_zeros: bool = True, trailing_zeros: bool = True) Set dimension text format, like prefix and postfix string, rounding rule and number of decimal places. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBprefix\fP – Dimension text prefix text as string .IP \(bu 2 \fBpostfix\fP – Dimension text postfix text as string .IP \(bu 2 \fBrnd\fP – Rounds all dimensioning distances to the specified value, for instance, if DIMRND is set to 0.25, all distances round to the nearest 0.25 unit. If you set DIMRND to 1.0, all distances round to the nearest integer. .IP \(bu 2 \fBdec\fP – Sets the number of decimal places displayed for the primary units of a dimension, requires DXF R2000+ .IP \(bu 2 \fBsep\fP – “.” or “,” as decimal separator, requires DXF R2000+ .IP \(bu 2 \fBleading_zeros\fP – Suppress leading zeros for decimal dimensions if \fBFalse\fP .IP \(bu 2 \fBtrailing_zeros\fP – Suppress trailing zeros for decimal dimensions if \fBFalse\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_dimline_format(color: int | None = None, linetype: str | None = None, lineweight: int | None = None, extension: float | None = None, disable1: bool | None = None, disable2: bool | None = None) Set dimension line properties .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – color index .IP \(bu 2 \fBlinetype\fP – linetype as string, requires DXF R2007+ .IP \(bu 2 \fBlineweight\fP – line weight as int, 13 = 0.13mm, 200 = 2.00mm, requires DXF R2000+ .IP \(bu 2 \fBextension\fP – extension length .IP \(bu 2 \fBdisable1\fP – \fBTrue\fP to suppress first part of dimension line, requires DXF R2000+ .IP \(bu 2 \fBdisable2\fP – \fBTrue\fP to suppress second part of dimension line, requires DXF R2000+ .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_extline_format(color: int | None = None, lineweight: int | None = None, extension: float | None = None, offset: float | None = None, fixed_length: float | None = None) Set common extension line attributes. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – color index .IP \(bu 2 \fBlineweight\fP – line weight as int, 13 = 0.13mm, 200 = 2.00mm .IP \(bu 2 \fBextension\fP – extension length above dimension line .IP \(bu 2 \fBoffset\fP – offset from measurement point .IP \(bu 2 \fBfixed_length\fP – set fixed length extension line, length below the dimension line .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_extline1(linetype: str | None = None, disable=False) Set extension line 1 attributes. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlinetype\fP – linetype for extension line 1, requires DXF R2007+ .IP \(bu 2 \fBdisable\fP – disable extension line 1 if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_extline2(linetype: str | None = None, disable=False) Set extension line 2 attributes. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlinetype\fP – linetype for extension line 2, requires DXF R2007+ .IP \(bu 2 \fBdisable\fP – disable extension line 2 if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_tolerance(upper: float, lower: float | None = None, hfactor: float = 1.0, align: \fI\%MTextLineAlignment\fP | None = None, dec: int | None = None, leading_zeros: bool | None = None, trailing_zeros: bool | None = None) -> None Set tolerance text format, upper and lower value, text height factor, number of decimal places or leading and trailing zero suppression. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBupper\fP – upper tolerance value .IP \(bu 2 \fBlower\fP – lower tolerance value, if \fBNone\fP same as upper .IP \(bu 2 \fBhfactor\fP – tolerance text height factor in relation to the dimension text height .IP \(bu 2 \fBalign\fP – tolerance text alignment enum \fI\%ezdxf.enums.MTextLineAlignment\fP requires DXF R2000+ .IP \(bu 2 \fBdec\fP – Sets the number of decimal places displayed, requires DXF R2000+ .IP \(bu 2 \fBleading_zeros\fP – suppress leading zeros for decimal dimensions if \fBFalse\fP, requires DXF R2000+ .IP \(bu 2 \fBtrailing_zeros\fP – suppress trailing zeros for decimal dimensions if \fBFalse\fP, requires DXF R2000+ .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_limits(upper: float, lower: float, hfactor: float = 1.0, dec: int | None = None, leading_zeros: bool | None = None, trailing_zeros: bool | None = None) -> None Set limits text format, upper and lower limit values, text height factor, number of decimal places or leading and trailing zero suppression. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBupper\fP – upper limit value added to measurement value .IP \(bu 2 \fBlower\fP – lower limit value subtracted from measurement value .IP \(bu 2 \fBhfactor\fP – limit text height factor in relation to the dimension text height .IP \(bu 2 \fBdec\fP – Sets the number of decimal places displayed, requires DXF R2000+ .IP \(bu 2 \fBleading_zeros\fP – suppress leading zeros for decimal dimensions if \fBFalse\fP, requires DXF R2000+ .IP \(bu 2 \fBtrailing_zeros\fP – suppress trailing zeros for decimal dimensions if \fBFalse\fP, requires DXF R2000+ .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS VPort .sp The viewport table (\fI\%DXF Reference\fP) stores the modelspace viewport configurations. So this entries just modelspace viewports, not paperspace viewports, for paperspace viewports see the \fI\%Viewport\fP entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqVPORT\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.viewports.new()\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: \fI\%VPORT Configuration Table\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.VPort Subclass of \fI\%DXFEntity\fP .sp Defines a viewport configurations for the modelspace. .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%ViewportTable\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name Viewport name .UNINDENT .INDENT 7.0 .TP .B dxf.flags Standard flag values (bit\-coded values): .TS center; |l|l|. _ T{ 16 T} T{ If set, table entry is externally dependent on an xref T} _ T{ 32 T} T{ If both this bit and bit 16 are set, the externally dependent xref has been successfully resolved T} _ T{ 64 T} T{ If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited. (This flag is only for the benefit of AutoCAD) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.lower_left Lower\-left corner of viewport .UNINDENT .INDENT 7.0 .TP .B dxf.upper_right Upper\-right corner of viewport .UNINDENT .INDENT 7.0 .TP .B dxf.center View center point (in \fI\%DCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.snap_base Snap base point (in \fI\%DCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.snap_spacing Snap spacing X and Y .UNINDENT .INDENT 7.0 .TP .B dxf.grid_spacing Grid spacing X and Y .UNINDENT .INDENT 7.0 .TP .B dxf.direction_point View direction from target point (in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.target_point View target point (in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.height View height .UNINDENT .INDENT 7.0 .TP .B dxf.aspect_ratio .UNINDENT .INDENT 7.0 .TP .B dxf.lens_length Lens focal length in mm .UNINDENT .INDENT 7.0 .TP .B dxf.front_clipping Front clipping plane (offset from target point) .UNINDENT .INDENT 7.0 .TP .B dxf.back_clipping Back clipping plane (offset from target point) .UNINDENT .INDENT 7.0 .TP .B dxf.snap_rotation Snap rotation angle in degrees .UNINDENT .INDENT 7.0 .TP .B dxf.view_twist View twist angle in degrees .UNINDENT .INDENT 7.0 .TP .B dxf.status .UNINDENT .INDENT 7.0 .TP .B dxf.view_mode .UNINDENT .INDENT 7.0 .TP .B dxf.circle_zoom .UNINDENT .INDENT 7.0 .TP .B dxf.fast_zoom .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_icon .INDENT 7.0 .IP \(bu 2 bit 0: 0=hide, 1=show .IP \(bu 2 bit 1: 0=display in lower left corner, 1=display at origin .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxf.snap_on .UNINDENT .INDENT 7.0 .TP .B dxf.grid_on .UNINDENT .INDENT 7.0 .TP .B dxf.snap_style .UNINDENT .INDENT 7.0 .TP .B dxf.snap_isopair .UNINDENT .INDENT 7.0 .TP .B reset_wcs() -> None Reset coordinate system to the \fI\%WCS\fP\&. .UNINDENT .UNINDENT .SS View .sp The View table (\fI\%DXF Reference\fP) stores named views of the model or paperspace layouts. This stored views makes parts of the drawing or some view points of the model in a CAD applications more accessible. This views have no influence to the drawing content or to the generated output by exporting PDFs or plotting on paper sheets, they are just for the convenience of CAD application users. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqVIEW\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.views.new()\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: \fI\%VIEW Table\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.View .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%Table\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name Name of view. .UNINDENT .INDENT 7.0 .TP .B dxf.flags Standard flag values (bit\-coded values): .TS center; |l|l|. _ T{ 1 T} T{ If set, this is a paper space view T} _ T{ 16 T} T{ If set, table entry is externally dependent on an xref T} _ T{ 32 T} T{ If both this bit and bit 16 are set, the externally dependent xref has been successfully resolved T} _ T{ 64 T} T{ If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited. (This flag is only for the benefit of AutoCAD) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.height View height (in DCS) .UNINDENT .INDENT 7.0 .TP .B dxf.width View width (in DCS) .UNINDENT .INDENT 7.0 .TP .B dxf.center_point View center point (in DCS) .UNINDENT .INDENT 7.0 .TP .B dxf.direction_point View direction from target (in WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.target_point Target point (in WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.lens_length Lens length .UNINDENT .INDENT 7.0 .TP .B dxf.front_clipping Front clipping plane (offset from target point) .UNINDENT .INDENT 7.0 .TP .B dxf.back_clipping Back clipping plane (offset from target point) .UNINDENT .INDENT 7.0 .TP .B dxf.view_twist Twist angle in degrees. .UNINDENT .INDENT 7.0 .TP .B dxf.view_mode View mode (see VIEWMODE system variable) .UNINDENT .INDENT 7.0 .TP .B dxf.render_mode .TS center; |l|l|. _ T{ 0 T} T{ 2D Optimized (classic 2D) T} _ T{ 1 T} T{ Wireframe T} _ T{ 2 T} T{ Hidden line T} _ T{ 3 T} T{ Flat shaded T} _ T{ 4 T} T{ Gouraud shaded T} _ T{ 5 T} T{ Flat shaded with wireframe T} _ T{ 6 T} T{ Gouraud shaded with wireframe T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.ucs 1 if there is a UCS associated to this view; 0 otherwise .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_origin UCS origin as (x, y, z) tuple (appears only if \fBucs\fP is set to 1) .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_xaxis UCS x\-axis as (x, y, z) tuple (appears only if \fBucs\fP is set to 1) .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_yaxis UCS y\-axis as (x, y, z) tuple (appears only if \fBucs\fP is set to 1) .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_ortho_type Orthographic type of UCS (appears only if \fBucs\fP is set to 1) .TS center; |l|l|. _ T{ 0 T} T{ UCS is not orthographic T} _ T{ 1 T} T{ Top T} _ T{ 2 T} T{ Bottom T} _ T{ 3 T} T{ Front T} _ T{ 4 T} T{ Back T} _ T{ 5 T} T{ Left T} _ T{ 6 T} T{ Right T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.elevation UCS elevation .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_handle Handle of \fBUCSTable\fP if UCS is a named UCS. If not present, then UCS is unnamed (appears only if \fBucs\fP is set to 1) .UNINDENT .INDENT 7.0 .TP .B dxf.base_ucs_handle Handle of \fBUCSTable\fP of base UCS if UCS is orthographic. If not present and \fBucs_ortho_type\fP is non\-zero, then base UCS is taken to be WORLD (appears only if \fBucs\fP is set to 1) .UNINDENT .INDENT 7.0 .TP .B dxf.camera_plottable 1 if the camera is plottable .UNINDENT .INDENT 7.0 .TP .B dxf.background_handle Handle to background object (optional) .UNINDENT .INDENT 7.0 .TP .B dxf.live_selection_handle Handle to live section object (optional) .UNINDENT .INDENT 7.0 .TP .B dxf.visual_style_handle Handle to visual style object (optional) .UNINDENT .INDENT 7.0 .TP .B dxf.sun_handle Sun hard ownership handle. .UNINDENT .UNINDENT .SS AppID .sp Defines an APPID (\fI\%DXF Reference\fP). These table entries maintain a set of names for all registered applications. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqAPPID\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.appids.new()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.AppID .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%Table\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name User\-supplied (or application\-supplied) application name (for extended data). .UNINDENT .INDENT 7.0 .TP .B dxf.flags Standard flag values (bit\-coded values): .TS center; |l|l|. _ T{ 16 T} T{ If set, table entry is externally dependent on an xref T} _ T{ 32 T} T{ If both this bit and bit 16 are set, the externally dependent xref has been successfully resolved T} _ T{ 64 T} T{ If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited. (This flag is only for the benefit of AutoCAD) T} _ .TE .UNINDENT .UNINDENT .SS UCS .sp Defines an named or unnamed user coordinate system (\fI\%DXF Reference\fP) for usage in CAD applications. This UCS table entry does not interact with \fIezdxf\fP in any way, to do coordinate transformations by \fIezdxf\fP use the \fI\%ezdxf.math.UCS\fP class. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqUCS\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.ucs.new()\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%UCS\fP and \fI\%OCS\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.UCSTableEntry .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%Table\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name UCS name (str). .UNINDENT .INDENT 7.0 .TP .B dxf.flags Standard flags (bit\-coded values): .TS center; |l|l|. _ T{ 16 T} T{ If set, table entry is externally dependent on an xref T} _ T{ 32 T} T{ If both this bit and bit 16 are set, the externally dependent xref has been successfully resolved T} _ T{ 64 T} T{ If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited. (This flag is only for the benefit of AutoCAD) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.origin Origin as (x, y, z) tuple .UNINDENT .INDENT 7.0 .TP .B dxf.xaxis X\-axis direction as (x, y, z) tuple .UNINDENT .INDENT 7.0 .TP .B dxf.yaxis Y\-axis direction as (x, y, z) tuple .UNINDENT .INDENT 7.0 .TP .B ucs() -> \fI\%UCS\fP Returns an \fI\%ezdxf.math.UCS\fP object for this UCS table entry. .UNINDENT .UNINDENT .SS BlockRecord .sp BLOCK_RECORD (\fI\%DXF Reference\fP) is the core management structure for \fI\%BlockLayout\fP and \fI\%Layout\fP\&. This is an internal DXF structure managed by \fIezdxf\fP, package users don’t have to care about it. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqBLOCK_RECORD\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.block_records.new()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.BlockRecord .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fI\%Table\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name Name of associated BLOCK. .UNINDENT .INDENT 7.0 .TP .B dxf.layout Handle to associated \fBDXFLayout\fP, if paperspace layout or modelspace else “0” .UNINDENT .INDENT 7.0 .TP .B dxf.explode 1 for BLOCK references can be exploded else 0 .UNINDENT .INDENT 7.0 .TP .B dxf.scale 1 for BLOCK references can be scaled else 0 .UNINDENT .INDENT 7.0 .TP .B dxf.units BLOCK insert units .TS center; |l|l|. _ T{ 0 T} T{ Unitless T} _ T{ 1 T} T{ Inches T} _ T{ 2 T} T{ Feet T} _ T{ 3 T} T{ Miles T} _ T{ 4 T} T{ Millimeters T} _ T{ 5 T} T{ Centimeters T} _ T{ 6 T} T{ Meters T} _ T{ 7 T} T{ Kilometers T} _ T{ 8 T} T{ Microinches T} _ T{ 9 T} T{ Mils T} _ T{ 10 T} T{ Yards T} _ T{ 11 T} T{ Angstroms T} _ T{ 12 T} T{ Nanometers T} _ T{ 13 T} T{ Microns T} _ T{ 14 T} T{ Decimeters T} _ T{ 15 T} T{ Decameters T} _ T{ 16 T} T{ Hectometers T} _ T{ 17 T} T{ Gigameters T} _ T{ 18 T} T{ Astronomical units T} _ T{ 19 T} T{ Light years T} _ T{ 20 T} T{ Parsecs T} _ T{ 21 T} T{ US Survey Feet T} _ T{ 22 T} T{ US Survey Inch T} _ T{ 23 T} T{ US Survey Yard T} _ T{ 24 T} T{ US Survey Mile T} _ .TE .UNINDENT .INDENT 7.0 .TP .B property is_active_paperspace: bool \fBTrue\fP if is “active” paperspace layout. .UNINDENT .INDENT 7.0 .TP .B property is_any_paperspace: bool \fBTrue\fP if is any kind of paperspace layout. .UNINDENT .INDENT 7.0 .TP .B property is_any_layout: bool \fBTrue\fP if is any kind of modelspace or paperspace layout. .UNINDENT .INDENT 7.0 .TP .B property is_block_layout: bool \fBTrue\fP if not any kind of modelspace or paperspace layout, just a regular block definition. .UNINDENT .INDENT 7.0 .TP .B property is_modelspace: bool \fBTrue\fP if is the modelspace layout. .UNINDENT .INDENT 7.0 .TP .B property is_xref: bool \fBTrue\fP if represents an XREF (external reference) or XREF_OVERLAY. .UNINDENT .UNINDENT .SS Internal Structure .sp Do not change this structures, this is just an information for experienced developers! .sp The BLOCK_RECORD is the owner of all the entities in a layout and stores them in an \fI\%EntitySpace\fP object (\fBBlockRecord.entity_space\fP). For each layout exist a BLOCK definition in the BLOCKS section, a reference to the \fI\%Block\fP entity is stored in \fBBlockRecord.block\fP\&. .sp \fI\%Modelspace\fP and \fI\%Paperspace\fP layouts require an additional \fI\%DXFLayout\fP object in the OBJECTS section. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 More information about \fI\%Block Management Structures\fP and \fI\%Layout Management Structures\fP\&. .UNINDENT .UNINDENT .SS Blocks .sp A block definition (\fI\%BlockLayout\fP) is a collection of DXF entities, which can be placed multiply times at different layouts or other blocks as references to the block definition. Block layouts are located in the BLOCKS sections and are accessible by the \fI\%blocks\fP attribute of the \fI\%Drawing\fP class. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Blocks\fP and DXF Internals: \fI\%Block Management Structures\fP .UNINDENT .UNINDENT .SS Block .sp BLOCK (\fI\%DXF Reference\fP) entity is embedded into the \fI\%BlockLayout\fP object. The BLOCK entity is accessible by the \fBBlockLayout.block\fP attribute. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqBLOCK\(aq\fP T} _ T{ Factory function T} T{ \fBDrawing.blocks.new()\fP (returns a \fI\%BlockLayout\fP) T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Blocks\fP and DXF Internals: \fI\%Block Management Structures\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Block .INDENT 7.0 .TP .B dxf.handle BLOCK handle as plain hex string. (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.owner Handle to owner as plain hex string. (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.layer Layer name as string; default value is \fB\(aq0\(aq\fP .UNINDENT .INDENT 7.0 .TP .B dxf.name BLOCK name as string. (case insensitive) .UNINDENT .INDENT 7.0 .TP .B dxf.base_point BLOCK base point as \fB(x, y, z)\fP tuple, default value is \fB(0, 0, 0)\fP .sp Insertion location referenced by the \fI\%Insert\fP entity to place the block reference and also the center of rotation and scaling. .UNINDENT .INDENT 7.0 .TP .B dxf.flags BLOCK flags (bit\-coded) .TS center; |l|l|. _ T{ 1 T} T{ Anonymous block generated by hatching, associative dimensioning, other internal operations, or an application T} _ T{ 2 T} T{ Block has non\-constant attribute definitions (this bit is not set if the block has any attribute definitions that are constant, or has no attribute definitions at all) T} _ T{ 4 T} T{ Block is an external reference (xref) T} _ T{ 8 T} T{ Block is an xref overlay T} _ T{ 16 T} T{ Block is externally dependent T} _ T{ 32 T} T{ This is a resolved external reference, or dependent of an external reference (ignored on input) T} _ T{ 64 T} T{ This definition is a referenced external reference (ignored on input) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.xref_path File system path as string, if this block defines an external reference (XREF). .UNINDENT .INDENT 7.0 .TP .B is_layout_block Returns \fBTrue\fP if this is a \fI\%Modelspace\fP or \fI\%Paperspace\fP block definition. .UNINDENT .INDENT 7.0 .TP .B is_anonymous Returns \fBTrue\fP if this is an anonymous block generated by hatching, associative dimensioning, other internal operations, or an application. .UNINDENT .INDENT 7.0 .TP .B is_xref Returns \fBTrue\fP if bock is an external referenced file. .UNINDENT .INDENT 7.0 .TP .B is_xref_overlay Returns \fBTrue\fP if bock is an external referenced overlay file. .UNINDENT .UNINDENT .SS EndBlk .sp ENDBLK entity is embedded into the \fI\%BlockLayout\fP object. The ENDBLK entity is accessible by the \fBBlockLayout.endblk\fP attribute. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ T{ DXF type T} T{ \fB\(aqENDBLK\(aq\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.EndBlk .INDENT 7.0 .TP .B dxf.handle BLOCK handle as plain hex string. (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.owner Handle to owner as plain hex string. (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.layer Layer name as string; should always be the same as \fI\%Block.dxf.layer\fP .UNINDENT .UNINDENT .SS Insert .sp The INSERT entity (\fI\%DXF Reference\fP) represents a block reference with optional attached attributes as (\fI\%Attrib\fP) entities. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqINSERT\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_blockref()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Blocks\fP .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Insert .INDENT 7.0 .TP .B dxf.name BLOCK name (str) .UNINDENT .INDENT 7.0 .TP .B dxf.insert Insertion location of the BLOCK base point as (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.xscale Scale factor for x direction (float) .UNINDENT .INDENT 7.0 .TP .B dxf.yscale Scale factor for y direction (float) .sp Not all CAD applications support non\-uniform scaling (e.g. LibreCAD). .UNINDENT .INDENT 7.0 .TP .B dxf.zscale Scale factor for z direction (float) .sp Not all CAD applications support non\-uniform scaling (e.g. LibreCAD). .UNINDENT .INDENT 7.0 .TP .B dxf.rotation Rotation angle in degrees (float) .UNINDENT .INDENT 7.0 .TP .B dxf.row_count Count of repeated insertions in row direction, MINSERT entity if > 1 (int) .UNINDENT .INDENT 7.0 .TP .B dxf.row_spacing Distance between two insert points (MINSERT) in row direction (float) .UNINDENT .INDENT 7.0 .TP .B dxf.column_count Count of repeated insertions in column direction, MINSERT entity if > 1 (int) .UNINDENT .INDENT 7.0 .TP .B dxf.column_spacing Distance between two insert points (MINSERT) in column direction (float) .UNINDENT .INDENT 7.0 .TP .B attribs A list of all attached \fI\%Attrib\fP entities. .UNINDENT .INDENT 7.0 .TP .B has_scaling Returns \fBTrue\fP if scaling is applied to any axis. .UNINDENT .INDENT 7.0 .TP .B has_uniform_scaling Returns \fBTrue\fP if the scale factor is uniform for x\-, y\- and z\-axis, ignoring reflections e.g. (1, 1, \-1) is uniform scaling. .UNINDENT .INDENT 7.0 .TP .B mcount Returns the multi\-insert count, MINSERT (multi\-insert) processing is required if \fI\%mcount\fP > 1. .UNINDENT .INDENT 7.0 .TP .B set_scale(factor: float) Set a uniform scale factor. .UNINDENT .INDENT 7.0 .TP .B block() -> \fI\%BlockLayout\fP | None Returns the associated \fI\%BlockLayout\fP\&. .UNINDENT .INDENT 7.0 .TP .B place(insert: \fI\%UVec\fP | None = None, scale: tuple[float, float, float] | None = None, rotation: float | None = None) -> Insert Set the location, scaling and rotation attributes. Arguments which are \fBNone\fP will be ignored. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinsert\fP – insert location as (x, y [,z]) tuple .IP \(bu 2 \fBscale\fP – (x\-scale, y\-scale, z\-scale) tuple .IP \(bu 2 \fBrotation\fP – rotation angle in degrees .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B grid(size: tuple[int, int] = (1, 1), spacing: tuple[float, float] = (1, 1)) -> Insert Place block reference in a grid layout, grid \fIsize\fP defines the row\- and column count, \fIspacing\fP defines the distance between two block references. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsize\fP – grid size as (row_count, column_count) tuple .IP \(bu 2 \fBspacing\fP – distance between placing as (row_spacing, column_spacing) tuple .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_attrib(tag: str, search_const: bool = False) -> bool Returns \fBTrue\fP if the INSERT entity has an attached ATTRIB entity with the given \fItag\fP\&. Some applications do not attach constant ATTRIB entities, set \fIsearch_const\fP to \fBTrue\fP, to check for an associated \fI\%AttDef\fP entity with constant content. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name fo the ATTRIB entity .IP \(bu 2 \fBsearch_const\fP – search also const ATTDEF entities .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_attrib(tag: str, search_const: bool = False) -> \fI\%Attrib\fP | \fI\%AttDef\fP | None Get an attached \fI\%Attrib\fP entity with the given \fItag\fP, returns \fBNone\fP if not found. Some applications do not attach constant ATTRIB entities, set \fIsearch_const\fP to \fBTrue\fP, to get at least the associated \fI\%AttDef\fP entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name of the ATTRIB entity .IP \(bu 2 \fBsearch_const\fP – search also const ATTDEF entities .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_attrib_text(tag: str, default: str = \(aq\(aq, search_const: bool = False) -> str Get content text of an attached \fI\%Attrib\fP entity with the given \fItag\fP, returns the \fIdefault\fP value if not found. Some applications do not attach constant ATTRIB entities, set \fIsearch_const\fP to \fBTrue\fP, to get content text of the associated \fI\%AttDef\fP entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name of the ATTRIB entity .IP \(bu 2 \fBdefault\fP – default value if ATTRIB \fItag\fP is absent .IP \(bu 2 \fBsearch_const\fP – search also const ATTDEF entities .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_attrib(tag: str, text: str, insert: \fI\%UVec\fP = (0, 0), dxfattribs=None) -> Attrib Attach an \fI\%Attrib\fP entity to the block reference. .sp Example for appending an attribute to an INSERT entity: .INDENT 7.0 .INDENT 3.5 .sp .EX e.add_attrib(\(aqEXAMPLETAG\(aq, \(aqexample text\(aq).set_placement( (3, 7), align=TextEntityAlignment.MIDDLE_CENTER ) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name of the ATTRIB entity .IP \(bu 2 \fBtext\fP – content text as string .IP \(bu 2 \fBinsert\fP – insert location as (x, y[, z]) tuple in \fI\%OCS\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the ATTRIB entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_auto_attribs(values: dict[str, str]) -> Insert Attach for each \fBAttdef\fP entity, defined in the block definition, automatically an \fI\%Attrib\fP entity to the block reference and set \fBtag/value\fP DXF attributes of the ATTRIB entities by the \fBkey/value\fP pairs (both as strings) of the \fIvalues\fP dict. The ATTRIB entities are placed relative to the insert location of the block reference, which is identical to the block base point. .sp This method avoids the wrapper block of the \fI\%add_auto_blockref()\fP method, but the visual results may not match the results of CAD applications, especially for non\-uniform scaling. If the visual result is very important to you, use the \fBadd_auto_blockref()\fP method. .INDENT 7.0 .TP .B Parameters \fBvalues\fP – \fI\%Attrib\fP tag values as \fBtag/value\fP pairs .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete_attrib(tag: str, ignore=False) -> None Delete an attached \fI\%Attrib\fP entity from INSERT. Raises an \fBDXFKeyError\fP exception, if no ATTRIB for the given \fItag\fP exist if \fIignore\fP is \fBFalse\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name of the ATTRIB entity .IP \(bu 2 \fBignore\fP – \fBFalse\fP for raising \fBDXFKeyError\fP if ATTRIB \fItag\fP does not exist. .UNINDENT .TP .B Raises \fI\%DXFKeyError\fP – no ATTRIB for the given \fItag\fP exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete_all_attribs() -> None Delete all \fI\%Attrib\fP entities attached to the INSERT entity. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Insert Transform INSERT entity by transformation matrix \fIm\fP inplace. .sp Unlike the transformation matrix \fIm\fP, the INSERT entity can not represent a non\-orthogonal target coordinate system and an \fBInsertTransformationError\fP will be raised in that case. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> Insert Optimized INSERT translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(*, skipped_entity_callback: Callable[[DXFGraphic, str], None] | None = None, redraw_order=False) -> Iterator[DXFGraphic] Yields the transformed referenced block content as virtual entities. .sp This method is meant to examine the block reference entities at the target location without exploding the block reference. These entities are not stored in the entity database, have no handle and are not assigned to any layout. It is possible to convert these entities into regular drawing entities by adding the entities to the entities database and a layout of the same DXF document as the block reference: .INDENT 7.0 .INDENT 3.5 .sp .EX doc.entitydb.add(entity) msp = doc.modelspace() msp.add_entity(entity) .EE .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 \fBNon\-uniform scale factors\fP may return incorrect results for some entities (TEXT, MTEXT, ATTRIB). .UNINDENT .UNINDENT .sp This method does not resolve the MINSERT attributes, only the sub\-entities of the first INSERT will be returned. To resolve MINSERT entities check if multi insert processing is required, that’s the case if the property \fI\%Insert.mcount\fP > 1, use the \fI\%Insert.multi_insert()\fP method to resolve the MINSERT entity into multiple INSERT entities. .sp The \fIskipped_entity_callback()\fP will be called for all entities which are not processed, signature: \fBskipped_entity_callback(entity: DXFEntity, reason: str)\fP, \fIentity\fP is the original (untransformed) DXF entity of the block definition, the \fIreason\fP string is an explanation why the entity was skipped. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBskipped_entity_callback\fP – called whenever the transformation of an entity is not supported and so was skipped .IP \(bu 2 \fBredraw_order\fP – yield entities in ascending redraw order if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B multi_insert() -> Iterator[Insert] Yields a virtual INSERT entity for each grid element of a MINSERT entity (multi\-insert). .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: \fI\%BaseLayout\fP | None = None, *, redraw_order=False) -> \fI\%EntityQuery\fP Explodes the block reference entities into the target layout, if target layout is \fBNone\fP, the layout of the block reference will be used. This method destroys the source block reference entity. .sp Transforms the block entities into the required \fI\%WCS\fP location by applying the block reference attributes \fIinsert\fP, \fIextrusion\fP, \fIrotation\fP and the scale factors \fIxscale\fP, \fIyscale\fP and \fIzscale\fP\&. .sp Attached ATTRIB entities are converted to TEXT entities, this is the behavior of the BURST command of the AutoCAD Express Tools. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 \fBNon\-uniform scale factors\fP may lead to incorrect results some entities (TEXT, MTEXT, ATTRIB). .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtarget_layout\fP – target layout for exploded entities, \fBNone\fP for same layout as source entity. .IP \(bu 2 \fBredraw_order\fP – create entities in ascending redraw order if \fBTrue\fP .UNINDENT .TP .B Returns \fI\%EntityQuery\fP container referencing all exploded DXF entities. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B ucs() Returns the block reference coordinate system as \fI\%ezdxf.math.UCS\fP object. .UNINDENT .INDENT 7.0 .TP .B matrix44() -> \fI\%Matrix44\fP Returns a transformation matrix to transform the block entities from the block reference coordinate system into the \fI\%WCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B reset_transformation() -> None Reset block reference attributes location, rotation angle and the extrusion vector but preserves the scale factors. .UNINDENT .UNINDENT .SS Attrib .sp The ATTRIB (\fI\%DXF Reference\fP) entity represents a text value associated with a tag. In most cases an ATTRIB is appended to an \fI\%Insert\fP entity, but it can also be used as a standalone entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Text\fP T} _ T{ DXF type T} T{ \fB\(aqATTRIB\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_attrib()\fP (stand alone entity) T} _ T{ Factory function T} T{ \fI\%Insert.add_attrib()\fP (attached to \fI\%Insert\fP) T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Blocks\fP .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Attrib ATTRIB supports all DXF attributes and methods of parent class \fI\%Text\fP\&. .INDENT 7.0 .TP .B dxf.tag Tag to identify the attribute (str) .UNINDENT .INDENT 7.0 .TP .B dxf.text Attribute content as text (str) .UNINDENT .INDENT 7.0 .TP .B property is_invisible: bool Attribute is invisible if \fBTrue\fP\&. .UNINDENT .INDENT 7.0 .TP .B property is_const: bool This is a constant attribute if \fBTrue\fP\&. .UNINDENT .INDENT 7.0 .TP .B property is_verify: bool Verification is required on input of this attribute. (interactive CAD application feature) .UNINDENT .INDENT 7.0 .TP .B property is_preset: bool No prompt during insertion. (interactive CAD application feature) .UNINDENT .INDENT 7.0 .TP .B property has_embedded_mtext_entity: bool Returns \fBTrue\fP if the entity has an embedded MTEXT entity for multi\-line support. .UNINDENT .INDENT 7.0 .TP .B virtual_mtext_entity() -> MText Returns the embedded MTEXT entity as a regular but virtual \fI\%MText\fP entity with the same graphical properties as the host entity. .UNINDENT .INDENT 7.0 .TP .B plain_mtext(fast=True) -> str Returns the embedded MTEXT content without formatting codes. Returns an empty string if no embedded MTEXT entity exist. .sp The \fIfast\fP mode is accurate if the DXF content was created by reliable (and newer) CAD applications like AutoCAD or BricsCAD. The \fIaccurate\fP mode is for some rare cases where the content was created by older CAD applications or unreliable DXF libraries and CAD applications. .sp The \fIaccurate\fP mode is \fBmuch\fP slower than the \fIfast\fP mode. .INDENT 7.0 .TP .B Parameters \fBfast\fP – uses the \fIfast\fP mode to extract the plain MTEXT content if \fBTrue\fP or the \fIaccurate\fP mode if set to \fBFalse\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_mtext(mtext: MText, graphic_properties=True) -> None Set multi\-line properties from a \fI\%MText\fP entity. .sp The multi\-line ATTRIB/ATTDEF entity requires DXF R2018, otherwise an ordinary single line ATTRIB/ATTDEF entity will be exported. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmtext\fP – source \fI\%MText\fP entity .IP \(bu 2 \fBgraphic_properties\fP – copy graphic properties (color, layer, …) from source MTEXT if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B embed_mtext(mtext: MText, graphic_properties=True) -> None Set multi\-line properties from a \fI\%MText\fP entity and destroy the source entity afterwards. .sp The multi\-line ATTRIB/ATTDEF entity requires DXF R2018, otherwise an ordinary single line ATTRIB/ATTDEF entity will be exported. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmtext\fP – source \fI\%MText\fP entity .IP \(bu 2 \fBgraphic_properties\fP – copy graphic properties (color, layer, …) from source MTEXT if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS AttDef .sp The ATTDEF (\fI\%DXF Reference\fP) entity is a template in a \fI\%BlockLayout\fP, which will be used to create an attached \fI\%Attrib\fP entity for an \fI\%Insert\fP entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Text\fP T} _ T{ DXF type T} T{ \fB\(aqATTDEF\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_attdef()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Blocks\fP .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.AttDef ATTDEF supports all DXF attributes and methods of parent class \fI\%Text\fP\&. .INDENT 7.0 .TP .B dxf.tag Tag to identify the attribute (str) .UNINDENT .INDENT 7.0 .TP .B dxf.text Attribute content as text (str) .UNINDENT .INDENT 7.0 .TP .B dxf.prompt Attribute prompt string. (CAD application feature) .UNINDENT .INDENT 7.0 .TP .B dxf.field_length Just relevant to CAD programs for validating user input .UNINDENT .INDENT 7.0 .TP .B property is_invisible: bool Attribute is invisible if \fBTrue\fP\&. .UNINDENT .INDENT 7.0 .TP .B property is_const: bool This is a constant attribute if \fBTrue\fP\&. .UNINDENT .INDENT 7.0 .TP .B property is_verify: bool Verification is required on input of this attribute. (interactive CAD application feature) .UNINDENT .INDENT 7.0 .TP .B property is_preset: bool No prompt during insertion. (interactive CAD application feature) .UNINDENT .INDENT 7.0 .TP .B property has_embedded_mtext_entity: bool Returns \fBTrue\fP if the entity has an embedded MTEXT entity for multi\-line support. .UNINDENT .INDENT 7.0 .TP .B virtual_mtext_entity() -> MText Returns the embedded MTEXT entity as a regular but virtual \fI\%MText\fP entity with the same graphical properties as the host entity. .UNINDENT .INDENT 7.0 .TP .B plain_mtext(fast=True) -> str Returns the embedded MTEXT content without formatting codes. Returns an empty string if no embedded MTEXT entity exist. .sp The \fIfast\fP mode is accurate if the DXF content was created by reliable (and newer) CAD applications like AutoCAD or BricsCAD. The \fIaccurate\fP mode is for some rare cases where the content was created by older CAD applications or unreliable DXF libraries and CAD applications. .sp The \fIaccurate\fP mode is \fBmuch\fP slower than the \fIfast\fP mode. .INDENT 7.0 .TP .B Parameters \fBfast\fP – uses the \fIfast\fP mode to extract the plain MTEXT content if \fBTrue\fP or the \fIaccurate\fP mode if set to \fBFalse\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_mtext(mtext: MText, graphic_properties=True) -> None Set multi\-line properties from a \fI\%MText\fP entity. .sp The multi\-line ATTRIB/ATTDEF entity requires DXF R2018, otherwise an ordinary single line ATTRIB/ATTDEF entity will be exported. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmtext\fP – source \fI\%MText\fP entity .IP \(bu 2 \fBgraphic_properties\fP – copy graphic properties (color, layer, …) from source MTEXT if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B embed_mtext(mtext: MText, graphic_properties=True) -> None Set multi\-line properties from a \fI\%MText\fP entity and destroy the source entity afterwards. .sp The multi\-line ATTRIB/ATTDEF entity requires DXF R2018, otherwise an ordinary single line ATTRIB/ATTDEF entity will be exported. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmtext\fP – source \fI\%MText\fP entity .IP \(bu 2 \fBgraphic_properties\fP – copy graphic properties (color, layer, …) from source MTEXT if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Layouts .SS Layout Manager .sp The layout manager is unique to each DXF drawing, access the layout manager as \fI\%layouts\fP attribute of the \fI\%Drawing\fP object (e.g. \fBdoc.layouts.rename(\(dqLayout1\(dq, \(dqPlanView\(dq)\fP). .INDENT 0.0 .TP .B class ezdxf.layouts.Layouts The \fI\%Layouts\fP class manages \fI\%Paperspace\fP layouts and the \fI\%Modelspace\fP\&. .INDENT 7.0 .TP .B __len__() -> int Returns count of existing layouts, including the modelspace layout. .UNINDENT .INDENT 7.0 .TP .B __contains__(name: str) -> bool Returns \fBTrue\fP if layout \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[Layout] Returns iterable of all layouts as \fI\%Layout\fP objects, including the modelspace layout. .UNINDENT .INDENT 7.0 .TP .B names() -> list[str] Returns a list of all layout names, all names in original case sensitive form. .UNINDENT .INDENT 7.0 .TP .B names_in_taborder() -> list[str] Returns all layout names in tab order as shown in \fI\%CAD\fP applications. .UNINDENT .INDENT 7.0 .TP .B modelspace() -> Modelspace Returns the \fI\%Modelspace\fP layout. .UNINDENT .INDENT 7.0 .TP .B get(name: str | None) -> Layout Returns \fI\%Layout\fP by \fIname\fP, case insensitive “Model” == “MODEL”. .INDENT 7.0 .TP .B Parameters \fBname\fP – layout name as shown in tab, e.g. \fB\(aqModel\(aq\fP for modelspace .UNINDENT .UNINDENT .INDENT 7.0 .TP .B new(name: str, dxfattribs=None) -> Paperspace Returns a new \fI\%Paperspace\fP layout. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – layout name as shown in tabs in \fI\%CAD\fP applications .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the \fBDXFLayout\fP entity .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFValueError\fP – Invalid characters in layout name. .IP \(bu 2 \fI\%DXFValueError\fP – Layout \fIname\fP already exist. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rename(old_name: str, new_name: str) -> None Rename a layout from \fIold_name\fP to \fInew_name\fP\&. Can not rename layout \fB\(aqModel\(aq\fP and the new name of a layout must not exist. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBold_name\fP – actual layout name, case insensitive .IP \(bu 2 \fBnew_name\fP – new layout name, case insensitive .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFValueError\fP – try to rename \fB\(aqModel\(aq\fP .IP \(bu 2 \fI\%DXFValueError\fP – Layout \fInew_name\fP already exist. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete(name: str) -> None Delete layout \fIname\fP and destroy all entities in that layout. .INDENT 7.0 .TP .B Parameters \fBname\fP (\fIstr\fP) – layout name as shown in tabs .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFKeyError\fP – if layout \fIname\fP do not exists .IP \(bu 2 \fI\%DXFValueError\fP – deleting modelspace layout is not possible .IP \(bu 2 \fI\%DXFValueError\fP – deleting last paperspace layout is not possible .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B active_layout() -> Paperspace Returns the active paperspace layout. .UNINDENT .INDENT 7.0 .TP .B set_active_layout(name: str) -> None Set layout \fIname\fP as active paperspace layout. .UNINDENT .INDENT 7.0 .TP .B get_layout_for_entity(entity: DXFEntity) -> Layout Returns the owner layout for a DXF \fIentity\fP\&. .UNINDENT .UNINDENT .SS Layout Types .sp A Layout represents and manages DXF entities, there are three different layout objects: .INDENT 0.0 .IP \(bu 2 \fI\%Modelspace\fP is the common working space, containing basic drawing entities. .IP \(bu 2 \fI\%Paperspace\fP is the arrangement of objects for printing and plotting, this layout contains basic drawing entities and viewports to the \fI\%Modelspace\fP\&. .IP \(bu 2 \fI\%BlockLayout\fP works on an associated \fBBlock\fP, Blocks are collections of DXF entities for reusing by block references. .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate layout classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .SS Entity Ownership .sp A layout owns all entities residing in their entity space, therefore the \fBdxf.owner\fP attribute of any \fI\%DXFGraphic\fP entity in this layout is the \fBdxf.handle\fP of the layout, and deleting an entity from a layout is the end of life of this entity, because it is also deleted from the \fI\%EntityDB\fP\&. It’s possible to just unlink an entity from a layout to assign the entity to another layout, use the \fI\%move_to_layout()\fP method to move entities between layouts. .SS BaseLayout .INDENT 0.0 .TP .B class ezdxf.layouts.BaseLayout \fI\%BaseLayout\fP is the common base class for \fI\%Layout\fP and \fI\%BlockLayout\fP\&. .INDENT 7.0 .TP .B is_alive \fBFalse\fP if layout is deleted. .UNINDENT .INDENT 7.0 .TP .B is_active_paperspace \fBTrue\fP if is active layout. .UNINDENT .INDENT 7.0 .TP .B is_any_paperspace \fBTrue\fP if is any kind of paperspace layout. .UNINDENT .INDENT 7.0 .TP .B is_modelspace \fBTrue\fP if is modelspace layout. .UNINDENT .INDENT 7.0 .TP .B is_any_layout \fBTrue\fP if is any kind of modelspace or paperspace layout. .UNINDENT .INDENT 7.0 .TP .B is_block_layout \fBTrue\fP if not any kind of modelspace or paperspace layout, just a regular block definition. .UNINDENT .INDENT 7.0 .TP .B units \fIset drawing units\fP\&. .INDENT 7.0 .TP .B Type Get/Set layout/block drawing units as enum, see also .TP .B Type ref .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of entities owned by the layout. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[\fI\%DXFGraphic\fP] Returns iterable of all drawing entities in this layout. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index) Get entity at \fIindex\fP\&. .sp The underlying data structure for storing entities is organized like a standard Python list, therefore \fIindex\fP can be any valid list indexing or slicing term, like a single index \fBlayout[\-1]\fP to get the last entity, or an index slice \fBlayout[:10]\fP to get the first 10 or less entities as \fBlist[DXFGraphic]\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_extension_dict() -> \fI\%ExtensionDict\fP Returns the associated extension dictionary, creates a new one if necessary. .UNINDENT .INDENT 7.0 .TP .B delete_entity(entity: \fI\%DXFGraphic\fP) -> None Delete \fIentity\fP from layout entity space and the entity database, this destroys the \fIentity\fP\&. .UNINDENT .INDENT 7.0 .TP .B delete_all_entities() -> None Delete all entities from this layout and from entity database, this destroys all entities in this layout. .UNINDENT .INDENT 7.0 .TP .B unlink_entity(entity: \fI\%DXFGraphic\fP) -> None Unlink \fIentity\fP from layout but does not delete entity from the entity database, this removes \fIentity\fP just from the layout entity space. .UNINDENT .INDENT 7.0 .TP .B purge() Remove all destroyed entities from the layout entity space. .UNINDENT .INDENT 7.0 .TP .B query(query: str = \(aq*\(aq) -> \fI\%EntityQuery\fP Get all DXF entities matching the \fI\%Entity Query String\fP\&. .UNINDENT .INDENT 7.0 .TP .B groupby(dxfattrib: str = \(aq\(aq, key: KeyFunc | None = None) -> dict Returns a \fBdict\fP of entity lists, where entities are grouped by a \fIdxfattrib\fP or a \fIkey\fP function. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdxfattrib\fP – grouping by DXF attribute like \fB\(aqlayer\(aq\fP .IP \(bu 2 \fBkey\fP – key function, which accepts a \fBDXFGraphic\fP entity as argument and returns the grouping key of an entity or \fBNone\fP to ignore the entity. Reason for ignoring: a queried DXF attribute is not supported by entity. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B move_to_layout(entity: \fI\%DXFGraphic\fP, layout: \fI\%BaseLayout\fP) -> None Move entity to another layout. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP – DXF entity to move .IP \(bu 2 \fBlayout\fP – any layout (modelspace, paperspace, block) from \fBsame\fP drawing .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_redraw_order(handles: dict | Iterable[tuple[str, str]]) -> None If the header variable $SORTENTS \fIRegen\fP flag (bit\-code value 16) is set, AutoCAD regenerates entities in ascending handles order. .sp To change redraw order associate a different sort\-handle to entities, this redefines the order in which the entities are regenerated. The \fIhandles\fP argument can be a dict of entity_handle and sort_handle as (k, v) pairs, or an iterable of (entity_handle, sort_handle) tuples. .sp The sort\-handle doesn’t have to be unique, some or all entities can share the same sort\-handle and a sort\-handle can be an existing handle. .sp The “0” handle can be used, but this sort\-handle will be drawn as latest (on top of all other entities) and not as first as expected. .INDENT 7.0 .TP .B Parameters \fBhandles\fP – iterable or dict of handle associations; an iterable of 2\-tuples (entity_handle, sort_handle) or a dict (k, v) association as (entity_handle, sort_handle) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_redraw_order() -> Iterable[tuple[str, str]] Returns iterable for all existing table entries as (entity_handle, sort_handle) pairs, see also \fI\%set_redraw_order()\fP\&. .UNINDENT .INDENT 7.0 .TP .B entities_in_redraw_order(reverse=False) -> Iterable[\fI\%DXFGraphic\fP] Yields all entities from layout in ascending redraw order or descending redraw order if \fIreverse\fP is \fBTrue\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_entity(entity: \fI\%DXFGraphic\fP) -> None Add an existing \fBDXFGraphic\fP entity to a layout, but be sure to unlink (\fI\%unlink_entity()\fP) entity from the previous owner layout. Adding entities from a different DXF drawing is not supported. .UNINDENT .INDENT 7.0 .TP .B add_foreign_entity(entity: \fI\%DXFGraphic\fP, copy=True) -> None Add a foreign DXF entity to a layout, this foreign entity could be from another DXF document or an entity without an assigned DXF document. The intention of this method is to add \fBsimple\fP entities from another DXF document or from a DXF iterator, for more complex operations use the \fI\%importer\fP add\-on. Especially objects with BLOCK section (INSERT, DIMENSION, MLEADER) or OBJECTS section dependencies (IMAGE, UNDERLAY) can not be supported by this simple method. .sp Not all DXF types are supported and every dependency or resource reference from another DXF document will be removed except attribute layer will be preserved but only with default attributes like color \fB7\fP and linetype \fBCONTINUOUS\fP because the layer attribute doesn’t need a layer table entry. .sp If the entity is part of another DXF document, it will be unlinked from this document and its entity database if argument \fIcopy\fP is \fBFalse\fP, else the entity will be copied. Unassigned entities like from DXF iterators will just be added. .sp Supported DXF types: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 POINT .IP \(bu 2 LINE .IP \(bu 2 CIRCLE .IP \(bu 2 ARC .IP \(bu 2 ELLIPSE .IP \(bu 2 LWPOLYLINE .IP \(bu 2 SPLINE .IP \(bu 2 POLYLINE .IP \(bu 2 3DFACE .IP \(bu 2 SOLID .IP \(bu 2 TRACE .IP \(bu 2 SHAPE .IP \(bu 2 MESH .IP \(bu 2 ATTRIB .IP \(bu 2 ATTDEF .IP \(bu 2 TEXT .IP \(bu 2 MTEXT .IP \(bu 2 HATCH .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP – DXF entity to copy or move .IP \(bu 2 \fBcopy\fP – if \fBTrue\fP copy entity from other document else unlink from other document .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_point(location: \fI\%UVec\fP, dxfattribs=None) -> Point Add a \fI\%Point\fP entity at \fIlocation\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlocation\fP – 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_line(start: \fI\%UVec\fP, end: \fI\%UVec\fP, dxfattribs=None) -> Line Add a \fI\%Line\fP entity from \fIstart\fP to \fIend\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart\fP – 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBend\fP – 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_circle(center: \fI\%UVec\fP, radius: float, dxfattribs=None) -> \fI\%Circle\fP Add a \fI\%Circle\fP entity. This is an 2D element, which can be placed in space by using \fI\%OCS\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBradius\fP – circle radius .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_ellipse(center: \fI\%UVec\fP, major_axis: \fI\%UVec\fP = (1, 0, 0), ratio: float = 1, start_param: float = 0, end_param: float = math.tau, dxfattribs=None) -> \fI\%Ellipse\fP Add an \fI\%Ellipse\fP entity, \fIratio\fP is the ratio of minor axis to major axis, \fIstart_param\fP and \fIend_param\fP defines start and end point of the ellipse, a full ellipse goes from 0 to 2π. The ellipse goes from start to end param in \fIcounter\-clockwise\fP direction. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center of ellipse as 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBmajor_axis\fP – major axis as vector (x, y, z) .IP \(bu 2 \fBratio\fP – ratio of minor axis to major axis in range +/\-[1e\-6, 1.0] .IP \(bu 2 \fBstart_param\fP – start of ellipse curve .IP \(bu 2 \fBend_param\fP – end param of ellipse curve .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_arc(center: \fI\%UVec\fP, radius: float, start_angle: float, end_angle: float, is_counter_clockwise: bool = True, dxfattribs=None) -> \fI\%Arc\fP Add an \fI\%Arc\fP entity. The arc goes from \fIstart_angle\fP to \fIend_angle\fP in counter\-clockwise direction by default, set parameter \fIis_counter_clockwise\fP to \fBFalse\fP for clockwise orientation. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center of arc as 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBradius\fP – arc radius .IP \(bu 2 \fBstart_angle\fP – start angle in degrees .IP \(bu 2 \fBend_angle\fP – end angle in degrees .IP \(bu 2 \fBis_counter_clockwise\fP – \fBFalse\fP for clockwise orientation .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_solid(points: Iterable[\fI\%UVec\fP], dxfattribs=None) -> \fI\%Solid\fP Add a \fI\%Solid\fP entity, \fIpoints\fP is an iterable of 3 or 4 points. .sp \fBHINT:\fP .INDENT 7.0 .INDENT 3.5 The last two vertices are in reversed order: a square has the vertex order 0\-1\-3\-2 .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 3 or 4 2D/3D points in \fI\%WCS\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_trace(points: Iterable[\fI\%UVec\fP], dxfattribs=None) -> \fI\%Trace\fP Add a \fI\%Trace\fP entity, \fIpoints\fP is an iterable of 3 or 4 points. .sp \fBHINT:\fP .INDENT 7.0 .INDENT 3.5 The last two vertices are in reversed order: a square has the vertex order 0\-1\-3\-2 .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 3 or 4 2D/3D points in \fI\%WCS\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_3dface(points: Iterable[\fI\%UVec\fP], dxfattribs=None) -> \fI\%Face3d\fP Add a \fB3DFace\fP entity, \fIpoints\fP is an iterable 3 or 4 2D/3D points. .sp \fBHINT:\fP .INDENT 7.0 .INDENT 3.5 In contrast to SOLID and TRACE, the last two vertices are in regular order: a square has the vertex order 0\-1\-2\-3 .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 3 or 4 2D/3D points in \fI\%WCS\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_text(text: str, *, height: float | None = None, rotation: float | None = None, dxfattribs=None) -> \fI\%Text\fP Add a \fI\%Text\fP entity, see also \fI\%Textstyle\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – content string .IP \(bu 2 \fBheight\fP – text height in drawing units .IP \(bu 2 \fBrotation\fP – text rotation in degrees .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_blockref(name: str, insert: \fI\%UVec\fP, dxfattribs=None) -> \fI\%Insert\fP Add an \fI\%Insert\fP entity. .sp When inserting a block reference into the modelspace or another block layout with different units, the scaling factor between these units should be applied as scaling attributes (\fBxscale\fP, …) e.g. modelspace in meters and block in centimeters, \fBxscale\fP has to be 0.01. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – block name as str .IP \(bu 2 \fBinsert\fP – insert location as 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_auto_blockref(name: str, insert: \fI\%UVec\fP, values: dict[str, str], dxfattribs=None) -> \fI\%Insert\fP Add an \fI\%Insert\fP entity. This method adds for each \fBAttdef\fP entity, defined in the block definition, automatically an \fBAttrib\fP entity to the block reference and set (tag, value) DXF attributes of the ATTRIB entities by the (key, value) pairs (both as strings) of the \fIvalues\fP dict. .sp The Attrib entities are placed relative to the insert point, which is equal to the block base point. .sp This method wraps the INSERT and all the ATTRIB entities into an anonymous block, which produces the best visual results, especially for non\-uniform scaled block references, because the transformation and scaling is done by the CAD application. But this makes evaluation of block references with attributes more complicated, if you prefer INSERT and ATTRIB entities without a wrapper block use the \fBadd_blockref_with_attribs()\fP method. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – block name .IP \(bu 2 \fBinsert\fP – insert location as 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBvalues\fP – \fI\%Attrib\fP tag values as (tag, value) pairs .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_attdef(tag: str, insert: \fI\%UVec\fP = (0, 0), text: str = \(aq\(aq, *, height: float | None = None, rotation: float | None = None, dxfattribs=None) -> \fI\%AttDef\fP Add an \fI\%AttDef\fP as stand alone DXF entity. .sp Set position and alignment by the idiom: .INDENT 7.0 .INDENT 3.5 .sp .EX layout.add_attdef(\(dqNAME\(dq).set_placement( (2, 3), align=TextEntityAlignment.MIDDLE_CENTER ) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name as string .IP \(bu 2 \fBinsert\fP – insert location as 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBtext\fP – tag value as string .IP \(bu 2 \fBheight\fP – text height in drawing units .IP \(bu 2 \fBrotation\fP – text rotation in degrees .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polyline2d(points: Iterable[\fI\%UVec\fP], format: str | None = None, *, close: bool = False, dxfattribs=None) -> \fI\%Polyline\fP Add a 2D \fI\%Polyline\fP entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 2D points in \fI\%WCS\fP .IP \(bu 2 \fBclose\fP – \fBTrue\fP for a closed polyline .IP \(bu 2 \fBformat\fP – user defined point format like \fI\%add_lwpolyline()\fP, default is \fBNone\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polyline3d(points: Iterable[\fI\%UVec\fP], *, close: bool = False, dxfattribs=None) -> \fI\%Polyline\fP Add a 3D \fI\%Polyline\fP entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 3D points in \fI\%WCS\fP .IP \(bu 2 \fBclose\fP – \fBTrue\fP for a closed polyline .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polymesh(size: tuple[int, int] = (3, 3), dxfattribs=None) -> \fI\%Polymesh\fP Add a \fI\%Polymesh\fP entity, which is a wrapper class for the POLYLINE entity. A polymesh is a grid of \fImcount\fP x \fIncount\fP vertices and every vertex has its own (x, y, z)\-coordinates. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsize\fP – 2\-tuple (\fImcount\fP, \fIncount\fP) .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polyface(dxfattribs=None) -> \fI\%Polyface\fP Add a \fI\%Polyface\fP entity, which is a wrapper class for the POLYLINE entity. .INDENT 7.0 .TP .B Parameters \fBdxfattribs\fP – additional DXF attributes for \fI\%Polyline\fP entity .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_shape(name: str, insert: \fI\%UVec\fP = (0, 0), size: float = 1.0, dxfattribs=None) -> \fI\%Shape\fP Add a \fI\%Shape\fP reference to an external stored shape. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – shape name as string .IP \(bu 2 \fBinsert\fP – insert location as 2D/3D point in \fI\%WCS\fP .IP \(bu 2 \fBsize\fP – size factor .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_lwpolyline(points: Iterable[\fI\%UVec\fP], format: str = \(aqxyseb\(aq, *, close: bool = False, dxfattribs=None) -> \fI\%LWPolyline\fP Add a 2D polyline as \fI\%LWPolyline\fP entity. A points are defined as (x, y, [start_width, [end_width, [bulge]]]) tuples, but order can be redefined by the \fIformat\fP argument. Set \fIstart_width\fP, \fIend_width\fP to 0 to be ignored like (x, y, 0, 0, bulge). .sp The \fI\%LWPolyline\fP is defined as a single DXF entity and needs less disk space than a \fI\%Polyline\fP entity. (requires DXF R2000) .sp Format codes: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBx\fP = x\-coordinate .IP \(bu 2 \fBy\fP = y\-coordinate .IP \(bu 2 \fBs\fP = start width .IP \(bu 2 \fBe\fP = end width .IP \(bu 2 \fBb\fP = bulge value .IP \(bu 2 \fBv\fP = (x, y [,z]) tuple (z\-axis is ignored) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of (x, y, [start_width, [end_width, [bulge]]]) tuples .IP \(bu 2 \fBformat\fP – user defined point format, default is “xyseb” .IP \(bu 2 \fBclose\fP – \fBTrue\fP for a closed polyline .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mtext(text: str, dxfattribs=None) -> \fI\%MText\fP Add a multiline text entity with automatic text wrapping at boundaries as \fI\%MText\fP entity. (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – content string .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mtext_static_columns(content: Iterable[str], width: float, gutter_width: float, height: float, dxfattribs=None) -> \fI\%MText\fP Add a multiline text entity with static columns as \fI\%MText\fP entity. The content is spread across the columns, the count of content strings determine the count of columns. .sp This factory method adds automatically a column break \fB\(dq\eN\(dq\fP at the end of each column text to force a new column. The \fIheight\fP attribute should be big enough to reserve enough space for the tallest column. Too small values produce valid DXF files, but the visual result will not be as expected. The \fIheight\fP attribute also defines the total height of the MTEXT entity. .sp (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontent\fP – iterable of column content .IP \(bu 2 \fBwidth\fP – column width .IP \(bu 2 \fBgutter_width\fP – distance between columns .IP \(bu 2 \fBheight\fP – max. column height .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mtext_dynamic_manual_height_columns(content: str, width: float, gutter_width: float, heights: Sequence[float], dxfattribs=None) -> \fI\%MText\fP Add a multiline text entity with dynamic columns as \fI\%MText\fP entity. The content is spread across the columns automatically by the CAD application. The \fIheights\fP sequence determine the height of the columns, except for the last column, which always takes the remaining content. The height value for the last column is required but can be 0, because the value is ignored. The count of \fIheights\fP also determines the count of columns, and \fBmax(heights)\fP defines the total height of the MTEXT entity, which may be wrong if the last column requires more space. .sp This current implementation works best for DXF R2018, because the content is stored as a continuous text in a single MTEXT entity. For DXF versions prior to R2018 the content should be distributed across multiple MTEXT entities (one entity per column), which is not done by \fIezdxf\fP, but the result is correct for advanced DXF viewers and CAD application, which do the MTEXT content distribution completely by itself. .sp (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontent\fP – column content as a single string .IP \(bu 2 \fBwidth\fP – column width .IP \(bu 2 \fBgutter_width\fP – distance between columns .IP \(bu 2 \fBheights\fP – column height for each column .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mtext_dynamic_auto_height_columns(content: str, width: float, gutter_width: float, height: float, count: int, dxfattribs=None) -> \fI\%MText\fP Add a multiline text entity with as many columns as needed for the given common fixed \fIheight\fP\&. The content is spread across the columns automatically by the CAD application. The \fIheight\fP argument also defines the total height of the MTEXT entity. To get the correct column \fIcount\fP requires an \fBexact\fP MTEXT rendering like AutoCAD, which is not done by \fIezdxf\fP, therefore passing the expected column \fIcount\fP is required to calculate the correct total width. .sp This current implementation works best for DXF R2018, because the content is stored as a continuous text in a single MTEXT entity. For DXF versions prior to R2018 the content should be distributed across multiple MTEXT entities (one entity per column), which is not done by \fIezdxf\fP, but the result is correct for advanced DXF viewers and CAD application, which do the MTEXT content distribution completely by itself. .sp Because of the current limitations the use of this method is not recommend. This situation may improve in future releases, but the exact rendering of the content will also slow down the processing speed dramatically. .sp (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontent\fP – column content as a single string .IP \(bu 2 \fBwidth\fP – column width .IP \(bu 2 \fBgutter_width\fP – distance between columns .IP \(bu 2 \fBheight\fP – max. column height .IP \(bu 2 \fBcount\fP – expected column count .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_ray(start: \fI\%UVec\fP, unit_vector: \fI\%UVec\fP, dxfattribs=None) -> \fI\%Ray\fP Add a \fI\%Ray\fP that begins at \fIstart\fP point and continues to infinity (construction line). (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart\fP – location 3D point in \fI\%WCS\fP .IP \(bu 2 \fBunit_vector\fP – 3D vector (x, y, z) .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_xline(start: \fI\%UVec\fP, unit_vector: \fI\%UVec\fP, dxfattribs=None) -> \fI\%XLine\fP Add an infinity \fI\%XLine\fP (construction line). (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart\fP – location 3D point in \fI\%WCS\fP .IP \(bu 2 \fBunit_vector\fP – 3D vector (x, y, z) .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mline(vertices: Iterable[\fI\%UVec\fP] | None = None, *, close: bool = False, dxfattribs=None) -> \fI\%MLine\fP Add a \fI\%MLine\fP entity .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – MLINE vertices (in \fI\%WCS\fP) .IP \(bu 2 \fBclose\fP – \fBTrue\fP to add a closed MLINE .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_spline(fit_points: Iterable[\fI\%UVec\fP] | None = None, degree: int = 3, dxfattribs=None) -> Spline Add a B\-spline (\fI\%Spline\fP entity) defined by the given \fIfit_points\fP \- the control points and knot values are created by the CAD application, therefore it is not predictable how the rendered spline will look like, because for every set of fit points exists an infinite set of B\-splines. .sp If \fIfit_points\fP is \fBNone\fP, an “empty” spline will be created, all data has to be set by the user. .sp The SPLINE entity requires DXF R2000. .sp AutoCAD creates a spline through fit points by a global curve interpolation and an unknown method to estimate the direction of the start\- and end tangent. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Spline\fP .IP \(bu 2 \fI\%ezdxf.math.fit_points_to_cad_cv()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – iterable of fit points as \fB(x, y[, z])\fP in \fI\%WCS\fP, creates an empty \fI\%Spline\fP if \fBNone\fP .IP \(bu 2 \fBdegree\fP – degree of B\-spline, max. degree supported by AutoCAD is 11 .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_cad_spline_control_frame(fit_points: Iterable[\fI\%UVec\fP], tangents: Iterable[\fI\%UVec\fP] | None = None, dxfattribs=None) -> Spline Add a \fI\%Spline\fP entity passing through the given fit points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – iterable of fit points as (x, y[, z]) in \fI\%WCS\fP .IP \(bu 2 \fBtangents\fP – start\- and end tangent, default is autodetect .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_spline_control_frame(fit_points: Iterable[\fI\%UVec\fP], degree: int = 3, method: str = \(aqchord\(aq, dxfattribs=None) -> Spline Add a \fI\%Spline\fP entity passing through the given \fIfit_points\fP, the control points are calculated by a global curve interpolation without start\- and end tangent constrains. The new SPLINE entity is defined by control points and not by the fit points, therefore the SPLINE looks always the same, no matter which CAD application renders the SPLINE. .INDENT 7.0 .IP \(bu 2 “uniform”: creates a uniform t vector, from 0 to 1 evenly spaced, see \fI\%uniform\fP method .IP \(bu 2 “distance”, “chord”: creates a t vector with values proportional to the fit point distances, see \fI\%chord length\fP method .IP \(bu 2 “centripetal”, “sqrt_chord”: creates a t vector with values proportional to the fit point sqrt(distances), see \fI\%centripetal\fP method .IP \(bu 2 “arc”: creates a t vector with values proportional to the arc length between fit points. .UNINDENT .sp Use function \fI\%add_cad_spline_control_frame()\fP to create SPLINE entities from fit points similar to CAD application including start\- and end tangent constraints. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – iterable of fit points as (x, y[, z]) in \fI\%WCS\fP .IP \(bu 2 \fBdegree\fP – degree of B\-spline, max. degree supported by AutoCAD is 11 .IP \(bu 2 \fBmethod\fP – calculation method for parameter vector t .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_open_spline(control_points: Iterable[\fI\%UVec\fP], degree: int = 3, knots: Iterable[float] | None = None, dxfattribs=None) -> Spline Add an open uniform \fI\%Spline\fP defined by \fIcontrol_points\fP\&. (requires DXF R2000) .sp Open uniform B\-splines start and end at your first and last control point. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – iterable of 3D points in \fI\%WCS\fP .IP \(bu 2 \fBdegree\fP – degree of B\-spline, max. degree supported by AutoCAD is 11 .IP \(bu 2 \fBknots\fP – knot values as iterable of floats .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_rational_spline(control_points: Iterable[\fI\%UVec\fP], weights: Sequence[float], degree: int = 3, knots: Iterable[float] | None = None, dxfattribs=None) -> Spline Add an open rational uniform \fI\%Spline\fP defined by \fIcontrol_points\fP\&. (requires DXF R2000) .sp \fIweights\fP has to be an iterable of floats, which defines the influence of the associated control point to the shape of the B\-spline, therefore for each control point is one weight value required. .sp Open rational uniform B\-splines start and end at the first and last control point. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – iterable of 3D points in \fI\%WCS\fP .IP \(bu 2 \fBweights\fP – weight values as iterable of floats .IP \(bu 2 \fBdegree\fP – degree of B\-spline, max. degree supported by AutoCAD is 11 .IP \(bu 2 \fBknots\fP – knot values as iterable of floats .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_hatch(color: int = 7, dxfattribs=None) -> \fI\%Hatch\fP Add a \fI\%Hatch\fP entity. (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – fill color as :ref\(gaACI\(ga, default is 7 (black/white). .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_helix(radius: float, pitch: float, turns: float, ccw=True, dxfattribs=None) -> \fI\%Helix\fP Add a \fI\%Helix\fP entity. .sp The center of the helix is always (0, 0, 0) and the helix axis direction is the +z\-axis. .sp Transform the new HELIX by the \fI\%transform()\fP method to your needs. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP – helix radius .IP \(bu 2 \fBpitch\fP – the height of one complete helix turn .IP \(bu 2 \fBturns\fP – count of turns .IP \(bu 2 \fBccw\fP – creates a counter\-clockwise turning (right\-handed) helix if \fBTrue\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mpolygon(color: int = const.BYLAYER, fill_color: int | None = None, dxfattribs=None) -> \fI\%MPolygon\fP Add a \fI\%MPolygon\fP entity. (requires DXF R2000) .sp The MPOLYGON entity is not a core DXF entity and is not supported by every CAD application or DXF library. .sp DXF version R2004+ is required to use a fill color different from BYLAYER. For R2000 the fill color is always BYLAYER, set any ACI value to create a filled MPOLYGON entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – boundary color as \fI\%AutoCAD Color Index (ACI)\fP, default is BYLAYER. .IP \(bu 2 \fBfill_color\fP – fill color as \fI\%AutoCAD Color Index (ACI)\fP, default is \fBNone\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mesh(dxfattribs=None) -> \fI\%Mesh\fP Add a \fI\%Mesh\fP entity. (requires DXF R2007) .INDENT 7.0 .TP .B Parameters \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_image(image_def: \fI\%ImageDef\fP, insert: \fI\%UVec\fP, size_in_units: tuple[float, float], rotation: float = 0.0, dxfattribs=None) -> \fI\%Image\fP Add an \fI\%Image\fP entity, requires a \fI\%ImageDef\fP entity, see \fI\%Tutorial for Image and ImageDef\fP\&. (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBimage_def\fP – required image definition as \fI\%ImageDef\fP .IP \(bu 2 \fBinsert\fP – insertion point as 3D point in \fI\%WCS\fP .IP \(bu 2 \fBsize_in_units\fP – size as (x, y) tuple in drawing units .IP \(bu 2 \fBrotation\fP – rotation angle around the extrusion axis, default is the z\-axis, in degrees .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_wipeout(vertices: Iterable[\fI\%UVec\fP], dxfattribs=None) -> \fI\%Wipeout\fP Add a \fI\%ezdxf.entities.Wipeout\fP entity, the masking area is defined by WCS \fIvertices\fP\&. .sp This method creates only a 2D entity in the xy\-plane of the layout, the z\-axis of the input vertices are ignored. .UNINDENT .INDENT 7.0 .TP .B add_underlay(underlay_def: \fI\%UnderlayDefinition\fP, insert: \fI\%UVec\fP = (0, 0, 0), scale=(1, 1, 1), rotation: float = 0.0, dxfattribs=None) -> \fI\%Underlay\fP Add an \fI\%Underlay\fP entity, requires a \fI\%UnderlayDefinition\fP entity, see \fI\%Tutorial for Underlay and UnderlayDefinition\fP\&. (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBunderlay_def\fP – required underlay definition as \fI\%UnderlayDefinition\fP .IP \(bu 2 \fBinsert\fP – insertion point as 3D point in \fI\%WCS\fP .IP \(bu 2 \fBscale\fP – underlay scaling factor as (x, y, z) tuple or as single value for uniform scaling for x, y and z .IP \(bu 2 \fBrotation\fP – rotation angle around the extrusion axis, default is the z\-axis, in degrees .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_linear_dim(base: \fI\%UVec\fP, p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, angle: float = 0, text_rotation: float | None = None, dimstyle: str = \(aqEZDXF\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Add horizontal, vertical and rotated \fI\%Dimension\fP line. If an \fI\%UCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. See also: \fI\%Tutorial for Linear Dimensions\fP .sp This method returns a \fI\%DimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fI\%render()\fP manually, this two\-step process allows additional processing steps on the \fI\%Dimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbase\fP – location of dimension line, any point on the dimension line or its extension will do (in UCS) .IP \(bu 2 \fBp1\fP – measurement point 1 and start point of extension line 1 (in UCS) .IP \(bu 2 \fBp2\fP – measurement point 2 and start point of extension line 2 (in UCS) .IP \(bu 2 \fBlocation\fP – user defined location for the text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZDXF” .IP \(bu 2 \fBangle\fP – angle from ucs/wcs x\-axis to dimension line in degrees .IP \(bu 2 \fBtext_rotation\fP – rotation angle of the dimension text as absolute angle (x\-axis=0, y\-axis=90) in degrees .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_multi_point_linear_dim(base: \fI\%UVec\fP, points: Iterable[\fI\%UVec\fP], angle: float = 0, ucs: \fI\%UCS\fP | None = None, avoid_double_rendering: bool = True, dimstyle: str = \(aqEZDXF\(aq, override: dict | None = None, dxfattribs=None, discard=False) -> None Add multiple linear dimensions for iterable \fIpoints\fP\&. If an \fI\%UCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. See also: \fI\%Tutorial for Linear Dimensions\fP .sp This method sets many design decisions by itself, the necessary geometry will be generated automatically, no required nor possible \fI\%render()\fP call. This method is easy to use, but you get what you get. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbase\fP – location of dimension line, any point on the dimension line or its extension will do (in UCS) .IP \(bu 2 \fBpoints\fP – iterable of measurement points (in UCS) .IP \(bu 2 \fBangle\fP – angle from ucs/wcs x\-axis to dimension line in degrees (0 = horizontal, 90 = vertical) .IP \(bu 2 \fBucs\fP – user defined coordinate system .IP \(bu 2 \fBavoid_double_rendering\fP – suppresses the first extension line and the first arrow if possible for continued dimension entities .IP \(bu 2 \fBdimstyle\fP – dimension style name (DimStyle table entry), default is “EZDXF” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .IP \(bu 2 \fBdiscard\fP – discard rendering result for friendly CAD applications like BricsCAD to get a native and likely better rendering result. (does not work with AutoCAD) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_aligned_dim(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, distance: float, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZDXF\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Add linear dimension aligned with measurement points \fIp1\fP and \fIp2\fP\&. If an \fI\%UCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. See also: \fI\%Tutorial for Linear Dimensions\fP .sp This method returns a \fI\%DimStyleOverride\fP object, to create the necessary dimension geometry, you have to call \fBDimStyleOverride.render()\fP manually, this two\-step process allows additional processing steps on the \fI\%Dimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – measurement point 1 and start point of extension line 1 (in UCS) .IP \(bu 2 \fBp2\fP – measurement point 2 and start point of extension line 2 (in UCS) .IP \(bu 2 \fBdistance\fP – distance of dimension line from measurement points .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZDXF” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_radius_dim(center: \fI\%UVec\fP, mpoint: \fI\%UVec\fP | None = None, radius: float | None = None, angle: float | None = None, *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Add a radius \fI\%Dimension\fP line. The radius dimension line requires a \fIcenter\fP point and a point \fImpoint\fP on the circle or as an alternative a \fIradius\fP and a dimension line \fIangle\fP in degrees. See also: \fI\%Tutorial for Radius Dimensions\fP .sp If a \fI\%UCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. .sp This method returns a \fI\%DimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fI\%render()\fP manually, this two\-step process allows additional processing steps on the \fI\%Dimension\fP entity between creation and rendering. .sp Following render types are supported: .INDENT 7.0 .IP \(bu 2 Default text location outside: text aligned with dimension line; dimension style: “EZ_RADIUS” .IP \(bu 2 Default text location outside horizontal: “EZ_RADIUS” + dimtoh=1 .IP \(bu 2 Default text location inside: text aligned with dimension line; dimension style: “EZ_RADIUS_INSIDE” .IP \(bu 2 Default text location inside horizontal: “EZ_RADIUS_INSIDE” + dimtih=1 .IP \(bu 2 User defined text location: argument \fIlocation\fP != \fBNone\fP, text aligned with dimension line; dimension style: “EZ_RADIUS” .IP \(bu 2 User defined text location horizontal: argument \fIlocation\fP != \fBNone\fP, “EZ_RADIUS” + dimtoh=1 for text outside horizontal, “EZ_RADIUS” + dimtih=1 for text inside horizontal .UNINDENT .sp Placing the dimension text at a user defined \fIlocation\fP, overrides the \fImpoint\fP and the \fIangle\fP argument, but requires a given \fIradius\fP argument. The \fIlocation\fP argument does not define the exact text location, instead it defines the dimension line starting at \fIcenter\fP and the measurement text midpoint projected on this dimension line going through \fIlocation\fP, if text is aligned to the dimension line. If text is horizontal, \fIlocation\fP is the kink point of the dimension line from radial to horizontal direction. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of the circle (in UCS) .IP \(bu 2 \fBmpoint\fP – measurement point on the circle, overrides \fIangle\fP and \fIradius\fP (in UCS) .IP \(bu 2 \fBradius\fP – radius in drawing units, requires argument \fIangle\fP .IP \(bu 2 \fBangle\fP – specify angle of dimension line in degrees, requires argument \fIradius\fP .IP \(bu 2 \fBlocation\fP – user defined dimension text location, overrides \fImpoint\fP and \fIangle\fP, but requires \fIradius\fP (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_RADIUS” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_radius_dim_2p(center: \fI\%UVec\fP, mpoint: \fI\%UVec\fP, *, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut method to create a radius dimension by center point, measurement point on the circle and the measurement text at the default location defined by the associated \fIdimstyle\fP, for further information see general method \fI\%add_radius_dim()\fP\&. .INDENT 7.0 .IP \(bu 2 dimstyle “EZ_RADIUS”: places the dimension text outside .IP \(bu 2 dimstyle “EZ_RADIUS_INSIDE”: places the dimension text inside .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of the circle (in UCS) .IP \(bu 2 \fBmpoint\fP – measurement point on the circle (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_RADIUS” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_radius_dim_cra(center: \fI\%UVec\fP, radius: float, angle: float, *, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut method to create a radius dimension by (c)enter point, (r)adius and (a)ngle, the measurement text is placed at the default location defined by the associated \fIdimstyle\fP, for further information see general method \fI\%add_radius_dim()\fP\&. .INDENT 7.0 .IP \(bu 2 dimstyle “EZ_RADIUS”: places the dimension text outside .IP \(bu 2 dimstyle “EZ_RADIUS_INSIDE”: places the dimension text inside .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of the circle (in UCS) .IP \(bu 2 \fBradius\fP – radius in drawing units .IP \(bu 2 \fBangle\fP – angle of dimension line in degrees .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_RADIUS” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_diameter_dim(center: \fI\%UVec\fP, mpoint: \fI\%UVec\fP | None = None, radius: float | None = None, angle: float | None = None, *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Add a diameter \fI\%Dimension\fP line. The diameter dimension line requires a \fIcenter\fP point and a point \fImpoint\fP on the circle or as an alternative a \fIradius\fP and a dimension line \fIangle\fP in degrees. .sp If an \fI\%UCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. .sp This method returns a \fI\%DimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fI\%render()\fP manually, this two\-step process allows additional processing steps on the \fI\%Dimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – specifies the center of the circle (in UCS) .IP \(bu 2 \fBmpoint\fP – specifies the measurement point on the circle (in UCS) .IP \(bu 2 \fBradius\fP – specify radius, requires argument \fIangle\fP, overrides \fIp1\fP argument .IP \(bu 2 \fBangle\fP – specify angle of dimension line in degrees, requires argument \fIradius\fP, overrides \fIp1\fP argument .IP \(bu 2 \fBlocation\fP – user defined location for the text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or \fB\(dq<>\(dq\fP the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_RADIUS” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_diameter_dim_2p(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut method to create a diameter dimension by two points on the circle and the measurement text at the default location defined by the associated \fIdimstyle\fP, for further information see general method \fI\%add_diameter_dim()\fP\&. Center point of the virtual circle is the midpoint between \fIp1\fP and \fIp2\fP\&. .INDENT 7.0 .IP \(bu 2 dimstyle “EZ_RADIUS”: places the dimension text outside .IP \(bu 2 dimstyle “EZ_RADIUS_INSIDE”: places the dimension text inside .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – first point of the circle (in UCS) .IP \(bu 2 \fBp2\fP – second point on the opposite side of the center point of the circle (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_RADIUS” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_angular_dim_2l(base: \fI\%UVec\fP, line1: tuple[\fI\%UVec\fP, \fI\%UVec\fP], line2: tuple[\fI\%UVec\fP, \fI\%UVec\fP], *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, text_rotation: float | None = None, dimstyle: str = \(aqEZ_CURVED\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Add angular \fI\%Dimension\fP from two lines. The measurement is always done from \fIline1\fP to \fIline2\fP in counter\-clockwise orientation. This does not always match the result in CAD applications! .sp If an \fI\%UCS\fP is used for angular dimension rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. .sp This method returns a \fI\%DimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fI\%render()\fP manually, this two\-step process allows additional processing steps on the \fI\%Dimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbase\fP – location of dimension line, any point on the dimension line or its extension is valid (in UCS) .IP \(bu 2 \fBline1\fP – specifies start leg of the angle (start point, end point) and determines extension line 1 (in UCS) .IP \(bu 2 \fBline2\fP – specifies end leg of the angle (start point, end point) and determines extension line 2 (in UCS) .IP \(bu 2 \fBlocation\fP – user defined location for the text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBtext_rotation\fP – rotation angle of the dimension text as absolute angle (x\-axis=0, y\-axis=90) in degrees .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_CURVED” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_angular_dim_3p(base: \fI\%UVec\fP, center: \fI\%UVec\fP, p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, text_rotation: float | None = None, dimstyle: str = \(aqEZ_CURVED\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Add angular \fI\%Dimension\fP from three points (center, p1, p2). The measurement is always done from \fIp1\fP to \fIp2\fP in counter\-clockwise orientation. This does not always match the result in CAD applications! .sp If an \fI\%UCS\fP is used for angular dimension rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. .sp This method returns a \fI\%DimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fI\%render()\fP manually, this two\-step process allows additional processing steps on the \fI\%Dimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbase\fP – location of dimension line, any point on the dimension line or its extension is valid (in UCS) .IP \(bu 2 \fBcenter\fP – specifies the vertex of the angle .IP \(bu 2 \fBp1\fP – specifies start leg of the angle (center \-> p1) and end\-point of extension line 1 (in UCS) .IP \(bu 2 \fBp2\fP – specifies end leg of the angle (center \-> p2) and end\-point of extension line 2 (in UCS) .IP \(bu 2 \fBlocation\fP – user defined location for the text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBtext_rotation\fP – rotation angle of the dimension text as absolute angle (x\-axis=0, y\-axis=90) in degrees .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_CURVED” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_angular_dim_cra(center: \fI\%UVec\fP, radius: float, start_angle: float, end_angle: float, distance: float, *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, text_rotation: float | None = None, dimstyle: str = \(aqEZ_CURVED\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut method to create an angular dimension by (c)enter point, (r)adius and start\- and end (a)ngles, the measurement text is placed at the default location defined by the associated \fIdimstyle\fP\&. The measurement is always done from \fIstart_angle\fP to \fIend_angle\fP in counter\-clockwise orientation. This does not always match the result in CAD applications! For further information see the more generic factory method \fI\%add_angular_dim_3p()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of the angle (in UCS) .IP \(bu 2 \fBradius\fP – the distance from \fIcenter\fP to the start of the extension lines in drawing units .IP \(bu 2 \fBstart_angle\fP – start angle in degrees (in UCS) .IP \(bu 2 \fBend_angle\fP – end angle in degrees (in UCS) .IP \(bu 2 \fBdistance\fP – distance from start of the extension lines to the dimension line in drawing units .IP \(bu 2 \fBlocation\fP – user defined location for the text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBtext_rotation\fP – rotation angle of the dimension text as absolute angle (x\-axis=0, y\-axis=90) in degrees .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_CURVED” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_angular_dim_arc(arc: \fI\%ConstructionArc\fP, distance: float, *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, text_rotation: float | None = None, dimstyle: str = \(aqEZ_CURVED\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut method to create an angular dimension from a \fI\%ConstructionArc\fP\&. This construction tool can be created from ARC entities and the tool itself provides various construction class methods. The measurement text is placed at the default location defined by the associated \fIdimstyle\fP\&. The measurement is always done from \fIstart_angle\fP to \fIend_angle\fP of the arc in counter\-clockwise orientation. This does not always match the result in CAD applications! For further information see the more generic factory method \fI\%add_angular_dim_3p()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBarc\fP – \fI\%ConstructionArc\fP .IP \(bu 2 \fBdistance\fP – distance from start of the extension lines to the dimension line in drawing units .IP \(bu 2 \fBlocation\fP – user defined location for the text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBtext_rotation\fP – rotation angle of the dimension text as absolute angle (x\-axis=0, y\-axis=90) in degrees .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_CURVED” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_arc_dim_3p(base: \fI\%UVec\fP, center: \fI\%UVec\fP, p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, text_rotation: float | None = None, dimstyle: str = \(aqEZ_CURVED\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Add \fI\%ArcDimension\fP from three points (center, p1, p2). Point \fIp1\fP defines the radius and the start\-angle of the arc, point \fIp2\fP only defines the end\-angle of the arc. .sp If an \fI\%UCS\fP is used for arc dimension rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. .sp This method returns a \fI\%DimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fI\%render()\fP manually, this two\-step process allows additional processing steps on the \fI\%ArcDimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not render the arc dimension like CAD applications and does not consider all DIMSTYLE variables, so the rendering results are \fBvery\fP different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbase\fP – location of dimension line, any point on the dimension line or its extension is valid (in UCS) .IP \(bu 2 \fBcenter\fP – specifies the vertex of the angle .IP \(bu 2 \fBp1\fP – specifies the radius (center \-> p1) and the star angle of the arc, this is also the start point for the 1st extension line (in UCS) .IP \(bu 2 \fBp2\fP – specifies the end angle of the arc. The start 2nd extension line is defined by this angle and the radius defined by p1 (in UCS) .IP \(bu 2 \fBlocation\fP – user defined location for the text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBtext_rotation\fP – rotation angle of the dimension text as absolute angle (x\-axis=0, y\-axis=90) in degrees .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_CURVED” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_arc_dim_cra(center: \fI\%UVec\fP, radius: float, start_angle: float, end_angle: float, distance: float, *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, text_rotation: float | None = None, dimstyle: str = \(aqEZ_CURVED\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut method to create an arc dimension by (c)enter point, (r)adius and start\- and end (a)ngles, the measurement text is placed at the default location defined by the associated \fIdimstyle\fP\&. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not render the arc dimension like CAD applications and does not consider all DIMSTYLE variables, so the rendering results are \fBvery\fP different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of the angle (in UCS) .IP \(bu 2 \fBradius\fP – the distance from \fIcenter\fP to the start of the extension lines in drawing units .IP \(bu 2 \fBstart_angle\fP – start\-angle in degrees (in UCS) .IP \(bu 2 \fBend_angle\fP – end\-angle in degrees (in UCS) .IP \(bu 2 \fBdistance\fP – distance from start of the extension lines to the dimension line in drawing units .IP \(bu 2 \fBlocation\fP – user defined location for text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBtext_rotation\fP – rotation angle of the dimension text as absolute angle (x\-axis=0, y\-axis=90) in degrees .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_CURVED” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_arc_dim_arc(arc: \fI\%ConstructionArc\fP, distance: float, *, location: \fI\%UVec\fP | None = None, text: str = \(aq<>\(aq, text_rotation: float | None = None, dimstyle: str = \(aqEZ_CURVED\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut method to create an arc dimension from a \fI\%ConstructionArc\fP\&. This construction tool can be created from ARC entities and the tool itself provides various construction class methods. The measurement text is placed at the default location defined by the associated \fIdimstyle\fP\&. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not render the arc dimension like CAD applications and does not consider all DIMSTYLE variables, so the rendering results are \fBvery\fP different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBarc\fP – \fI\%ConstructionArc\fP .IP \(bu 2 \fBdistance\fP – distance from start of the extension lines to the dimension line in drawing units .IP \(bu 2 \fBlocation\fP – user defined location for the text midpoint (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBtext_rotation\fP – rotation angle of the dimension text as absolute angle (x\-axis=0, y\-axis=90) in degrees .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZ_CURVED” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_ordinate_dim(feature_location: \fI\%UVec\fP, offset: \fI\%UVec\fP, dtype: int, *, origin: \fI\%UVec\fP = NULLVEC, rotation: float = 0.0, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZDXF\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Add an ordinate type \fI\%Dimension\fP line. The feature location is defined in the global coordinate system, which is set as render UCS, which is the \fI\%WCS\fP by default. .sp If an \fI\%UCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into \fI\%WCS\fP and \fI\%OCS\fP is done by the rendering function. Extrusion vector is defined by UCS or (0, 0, 1) by default. .sp This method returns a \fI\%DimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fI\%render()\fP manually, this two\-step process allows additional processing steps on the \fI\%Dimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIEzdxf\fP does not consider all DIMSTYLE variables, so the rendering results are different from CAD applications. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfeature_location\fP – feature location in the global coordinate system (UCS) .IP \(bu 2 \fBoffset\fP – offset vector of leader end point from the feature location in the local coordinate system .IP \(bu 2 \fBdtype\fP – 1 = x\-type, 0 = y\-type .IP \(bu 2 \fBorigin\fP – specifies the origin (0, 0) of the local coordinate system in UCS .IP \(bu 2 \fBrotation\fP – rotation angle of the local coordinate system in degrees .IP \(bu 2 \fBtext\fP – \fBNone\fP or “<>” the measurement is drawn as text, “ “ (a single space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZDXF” .IP \(bu 2 \fBoverride\fP – \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the DIMENSION entity .UNINDENT .UNINDENT .sp Returns: \fI\%DimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_ordinate_x_dim(feature_location: \fI\%UVec\fP, offset: \fI\%UVec\fP, *, origin: \fI\%UVec\fP = NULLVEC, rotation: float = 0.0, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZDXF\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut to add an x\-type feature ordinate DIMENSION, for more information see \fI\%add_ordinate_dim()\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_ordinate_y_dim(feature_location: \fI\%UVec\fP, offset: \fI\%UVec\fP, *, origin: \fI\%UVec\fP = NULLVEC, rotation: float = 0.0, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZDXF\(aq, override: dict | None = None, dxfattribs=None) -> DimStyleOverride Shortcut to add a y\-type feature ordinate DIMENSION, for more information see \fI\%add_ordinate_dim()\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_leader(vertices: Iterable[\fI\%UVec\fP], dimstyle: str = \(aqEZDXF\(aq, override: dict | None = None, dxfattribs=None) -> \fI\%Leader\fP The \fI\%Leader\fP entity represents an arrow, made up of one or more vertices (or spline fit points) and an arrowhead. The label or other content to which the \fI\%Leader\fP is attached is stored as a separate entity, and is not part of the \fI\%Leader\fP itself. (requires DXF R2000) .sp \fI\%Leader\fP shares its styling infrastructure with \fI\%Dimension\fP\&. .sp By default a \fI\%Leader\fP without any annotation is created. For creating more fancy leaders and annotations see documentation provided by Autodesk or \fI\%Demystifying DXF: LEADER and MULTILEADER implementation notes\fP . .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – leader vertices (in \fI\%WCS\fP) .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fI\%DimStyle\fP table entry), default is “EZDXF” .IP \(bu 2 \fBoverride\fP – override \fI\%DimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_multileader_mtext(style: str = \(aqStandard\(aq, dxfattribs=None) -> \fI\%MultiLeaderMTextBuilder\fP Add a \fI\%MultiLeader\fP entity but returns a \fI\%MultiLeaderMTextBuilder\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_multileader_block(style: str = \(aqStandard\(aq, dxfattribs=None) -> \fI\%MultiLeaderBlockBuilder\fP Add a \fI\%MultiLeader\fP entity but returns a \fI\%MultiLeaderBlockBuilder\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_body(dxfattribs=None) -> Body Add a \fI\%Body\fP entity. (requires DXF R2000 or later) .sp The ACIS data has to be set as \fI\%SAT\fP or \fI\%SAB\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_region(dxfattribs=None) -> \fI\%Region\fP Add a \fI\%Region\fP entity. (requires DXF R2000 or later) .sp The ACIS data has to be set as \fI\%SAT\fP or \fI\%SAB\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_3dsolid(dxfattribs=None) -> \fI\%Solid3d\fP Add a 3DSOLID entity (\fI\%Solid3d\fP). (requires DXF R2000 or later) .sp The ACIS data has to be set as \fI\%SAT\fP or \fI\%SAB\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_surface(dxfattribs=None) -> Surface Add a \fI\%Surface\fP entity. (requires DXF R2007 or later) .sp The ACIS data has to be set as \fI\%SAT\fP or \fI\%SAB\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_extruded_surface(dxfattribs=None) -> \fI\%ExtrudedSurface\fP Add a \fI\%ExtrudedSurface\fP entity. (requires DXF R2007 or later) .sp The ACIS data has to be set as \fI\%SAT\fP or \fI\%SAB\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_lofted_surface(dxfattribs=None) -> \fI\%LoftedSurface\fP Add a \fI\%LoftedSurface\fP entity. (requires DXF R2007 or later) .sp The ACIS data has to be set as \fI\%SAT\fP or \fI\%SAB\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_revolved_surface(dxfattribs=None) -> \fI\%RevolvedSurface\fP Add a \fI\%RevolvedSurface\fP entity. (requires DXF R2007 or later) .sp The ACIS data has to be set as \fI\%SAT\fP or \fI\%SAB\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_swept_surface(dxfattribs=None) -> \fI\%SweptSurface\fP Add a \fI\%SweptSurface\fP entity. (requires DXF R2007 or later) .sp The ACIS data has to be set as \fI\%SAT\fP or \fI\%SAB\fP\&. .UNINDENT .UNINDENT .SS Layout .INDENT 0.0 .TP .B class ezdxf.layouts.Layout \fI\%Layout\fP is a subclass of \fI\%BaseLayout\fP and common base class of \fI\%Modelspace\fP and \fI\%Paperspace\fP\&. .INDENT 7.0 .TP .B name Layout name as shown in tabs of \fI\%CAD\fP applications. .UNINDENT .INDENT 7.0 .TP .B dxf Returns the DXF name space attribute of the associated \fI\%DXFLayout\fP object. .sp This enables direct access to the underlying LAYOUT entity, e.g. \fBLayout.dxf.layout_flags\fP .UNINDENT .INDENT 7.0 .TP .B __contains__(entity: \fI\%DXFGraphic\fP | str) -> bool Returns \fBTrue\fP if \fIentity\fP is stored in this layout. .INDENT 7.0 .TP .B Parameters \fBentity\fP – \fBDXFGraphic\fP object or handle as hex string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B reset_extents(extmin=(+1e20, +1e20, +1e20), extmax=(\-1e20, \-1e20, \-1e20)) -> None Reset \fI\%extents\fP to given values or the AutoCAD default values. .sp “Drawing extents are the bounds of the area occupied by objects.” (Quote Autodesk Knowledge Network) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBextmin\fP – minimum extents or (+1e20, +1e20, +1e20) as default value .IP \(bu 2 \fBextmax\fP – maximum extents or (\-1e20, \-1e20, \-1e20) as default value .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B reset_limits(limmin=None, limmax=None) -> None Reset \fI\%limits\fP to given values or the AutoCAD default values. .sp “Sets an invisible rectangular boundary in the drawing area that can limit the grid display and limit clicking or entering point locations.” (Quote Autodesk Knowledge Network) .sp The \fI\%Paperspace\fP class has an additional method \fI\%reset_paper_limits()\fP to deduce the default limits from the paper size settings. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlimmin\fP – minimum limits or (0, 0) as default .IP \(bu 2 \fBlimmax\fP – maximum limits or (paper width, paper height) as default value .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_plot_type(value: int = 5) -> None .TS center; |l|l|. _ T{ 0 T} T{ last screen display T} _ T{ 1 T} T{ drawing extents T} _ T{ 2 T} T{ drawing limits T} _ T{ 3 T} T{ view specific (defined by \fBLayout.dxf.plot_view_name\fP) T} _ T{ 4 T} T{ window specific (defined by \fBLayout.set_plot_window_limits()\fP) T} _ T{ 5 T} T{ layout information (default) T} _ .TE .INDENT 7.0 .TP .B Parameters \fBvalue\fP – plot type .TP .B Raises \fI\%DXFValueError\fP – for \fIvalue\fP out of range .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_plot_style(name: str = \(aqezdxf.ctb\(aq, show: bool = False) -> None Set plot style file of type \fI\&.ctb\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – plot style filename .IP \(bu 2 \fBshow\fP – show plot style effect in preview? (AutoCAD specific attribute) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_plot_window(lower_left: tuple[float, float] = (0, 0), upper_right: tuple[float, float] = (0, 0)) -> None Set plot window size in (scaled) paper space units. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlower_left\fP – lower left corner as 2D point .IP \(bu 2 \fBupper_right\fP – upper right corner as 2D point .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B plot_viewport_borders(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B show_plot_styles(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B plot_centered(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B plot_hidden(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B use_standard_scale(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B use_plot_styles(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B scale_lineweights(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B print_lineweights(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B draw_viewports_first(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B model_type(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B update_paper(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B zoom_to_paper_on_update(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B plot_flags_initializing(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B prev_plot_init(state: bool = True) -> None .UNINDENT .INDENT 7.0 .TP .B set_plot_flags(flag, state: bool = True) -> None .UNINDENT .UNINDENT .SS Modelspace .INDENT 0.0 .TP .B class ezdxf.layouts.Modelspace \fI\%Modelspace\fP is a subclass of \fI\%Layout\fP\&. .sp The modelspace contains the “real” world representation of the drawing subjects in real world units. .INDENT 7.0 .TP .B name Name of modelspace is fixed as “Model”. .UNINDENT .INDENT 7.0 .TP .B new_geodata(dxfattribs=None) -> \fI\%GeoData\fP Creates a new \fBGeoData\fP entity and replaces existing ones. The GEODATA entity resides in the OBJECTS section and not in the modelspace, it is linked to the modelspace by an \fBExtensionDict\fP located in BLOCK_RECORD of the modelspace. .sp The GEODATA entity requires DXF R2010. The DXF reference does not document if other layouts than the modelspace supports geo referencing, so I assume getting/setting geo data may only make sense for the modelspace. .INDENT 7.0 .TP .B Parameters \fBdxfattribs\fP – DXF attributes for \fI\%GeoData\fP entity .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_geodata() -> \fI\%GeoData\fP | None Returns the \fI\%GeoData\fP entity associated to the modelspace or \fBNone\fP\&. .UNINDENT .UNINDENT .SS Paperspace .INDENT 0.0 .TP .B class ezdxf.layouts.Paperspace \fI\%Paperspace\fP is a subclass of \fI\%Layout\fP\&. .sp Paperspace layouts are used to create different drawing sheets of the modelspace subjects for printing or PDF export. .INDENT 7.0 .TP .B name Layout name as shown in tabs of \fI\%CAD\fP applications. .UNINDENT .INDENT 7.0 .TP .B page_setup(size=(297, 210), margins=(10, 15, 10, 15), units=\(aqmm\(aq, offset=(0, 0), rotation=0, scale=16, name=\(aqezdxf\(aq, device=\(aqDWG to PDF.pc3\(aq) Setup plot settings and paper size and reset viewports. All parameters in given \fIunits\fP (mm or inch). .sp Reset paper limits, extents and viewports. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsize\fP – paper size as (width, height) tuple .IP \(bu 2 \fBmargins\fP – (top, right, bottom, left) hint: clockwise .IP \(bu 2 \fBunits\fP – “mm” or “inch” .IP \(bu 2 \fBoffset\fP – plot origin offset is 2D point .IP \(bu 2 \fBrotation\fP – see table Rotation .IP \(bu 2 \fBscale\fP – integer in range [0, 32] defines a standard scale type or as tuple(numerator, denominator) e.g. (1, 50) for scale 1:50 .IP \(bu 2 \fBname\fP – paper name prefix “{name}_({width}_x_{height}_{unit})” .IP \(bu 2 \fBdevice\fP – device .pc3 configuration file or system printer name .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ int T} T{ Rotation T} _ T{ 0 T} T{ no rotation T} _ T{ 1 T} T{ 90 degrees counter\-clockwise T} _ T{ 2 T} T{ upside\-down T} _ T{ 3 T} T{ 90 degrees clockwise T} _ .TE .UNINDENT .INDENT 7.0 .TP .B viewports() -> list[\fI\%Viewport\fP] Get all VIEWPORT entities defined in this paperspace layout. .UNINDENT .INDENT 7.0 .TP .B main_viewport() -> \fI\%Viewport\fP | None Returns the main viewport of this paper space layout, or \fBNone\fP if no main viewport exist. .UNINDENT .INDENT 7.0 .TP .B add_viewport(center: \fI\%UVec\fP, size: tuple[float, float], view_center_point: \fI\%UVec\fP, view_height: float, status: int = 2, dxfattribs=None) -> \fI\%Viewport\fP Add a new \fI\%Viewport\fP entity. .sp Viewport \fBstatus\fP: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \-1 is on, but is fully off\-screen, or is one of the viewports that is not active because the $MAXACTVP count is currently being exceeded. .IP \(bu 2 0 is off .IP \(bu 2 any value>0 is on and active. The value indicates the order of stacking for the viewports, where 1 is the “active viewport”, 2 is the next, … .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B reset_viewports() -> None Delete all existing viewports, and create a new main viewport. .UNINDENT .INDENT 7.0 .TP .B reset_main_viewport(center: \fI\%UVec\fP = None, size: \fI\%UVec\fP = None) -> \fI\%Viewport\fP Reset the main viewport of this paper space layout to the given values, or reset them to the default values, deduced from the paper settings. Creates a new main viewport if none exist. .sp Ezdxf does not create a main viewport by default, because CAD applications don’t require one. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center of the viewport in paper space units .IP \(bu 2 \fBsize\fP – viewport size as (width, height) tuple in paper space units .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B reset_paper_limits() -> None Set paper limits to default values, all values in paperspace units but without plot scale (?). .UNINDENT .INDENT 7.0 .TP .B get_paper_limits() -> tuple[\fI\%Vec2\fP, \fI\%Vec2\fP] Returns paper limits in plot paper units, relative to the plot origin. .sp plot origin = lower left corner of printable area + plot origin offset .INDENT 7.0 .TP .B Returns tuple (Vec2(x1, y1), Vec2(x2, y2)), lower left corner is (x1, y1), upper right corner is (x2, y2). .UNINDENT .UNINDENT .UNINDENT .SS BlockLayout .INDENT 0.0 .TP .B class ezdxf.layouts.BlockLayout \fI\%BlockLayout\fP is a subclass of \fI\%BaseLayout\fP\&. .sp Block layouts are reusable sets of graphical entities, which can be referenced by multiple \fI\%Insert\fP entities. Each reference can be placed, scaled and rotated individually and can have it’s own set of DXF \fI\%Attrib\fP entities attached. .INDENT 7.0 .TP .B property name: str Get/set the BLOCK name .UNINDENT .INDENT 7.0 .TP .B property block: Block | None the associated \fI\%Block\fP entity. .UNINDENT .INDENT 7.0 .TP .B property endblk: EndBlk | None the associated \fI\%EndBlk\fP entity. .UNINDENT .INDENT 7.0 .TP .B property dxf DXF name space of associated \fI\%BlockRecord\fP table entry. .UNINDENT .INDENT 7.0 .TP .B property can_explode: bool Set property to \fBTrue\fP to allow exploding block references of this block. .UNINDENT .INDENT 7.0 .TP .B property scale_uniformly: bool Set property to \fBTrue\fP to allow block references of this block only scale uniformly. .UNINDENT .INDENT 7.0 .TP .B property base_point: \fI\%Vec3\fP Get/Set the base point of the block. .UNINDENT .INDENT 7.0 .TP .B __contains__(entity) -> bool Returns \fBTrue\fP if block contains \fIentity\fP\&. .INDENT 7.0 .TP .B Parameters \fBentity\fP – \fBDXFGraphic\fP object or handle as hex string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B attdefs() -> Iterable[AttDef] Returns iterable of all \fBAttdef\fP entities. .UNINDENT .INDENT 7.0 .TP .B has_attdef(tag: str) -> bool Returns \fBTrue\fP if an \fBAttdef\fP for \fItag\fP exist. .UNINDENT .INDENT 7.0 .TP .B get_attdef(tag: str) -> DXFGraphic | None Returns attached \fBAttdef\fP entity by \fItag\fP name. .UNINDENT .INDENT 7.0 .TP .B get_attdef_text(tag: str, default: str = \(aq\(aq) -> str Returns text content for \fBAttdef\fP \fItag\fP as string or returns \fIdefault\fP if no \fBAttdef\fP for \fItag\fP exist. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – name of tag .IP \(bu 2 \fBdefault\fP – default value if \fItag\fP not exist .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Groups .sp A group is just a bunch of DXF entities tied together. All entities of a group has to be in the same layout (modelspace or any paperspace layout but not block). Groups can be named or unnamed, but in reality an unnamed groups has just a special name like “*Annnn”. The name of a group has to be unique in the drawing. Groups are organized in the group table, which is stored as attribute \fI\%groups\fP in the \fI\%Drawing\fP object. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 Group entities have to reside in the modelspace or an paperspace layout but not in a block definition! .UNINDENT .UNINDENT .SS DXFGroup .INDENT 0.0 .TP .B class ezdxf.entities.dxfgroups.DXFGroup The group name is not stored in the GROUP entity, it is stored in the \fI\%GroupCollection\fP object. .INDENT 7.0 .TP .B dxf.description group description (string) .UNINDENT .INDENT 7.0 .TP .B dxf.unnamed 1 for unnamed, 0 for named group (int) .UNINDENT .INDENT 7.0 .TP .B dxf.selectable 1 for selectable, 0 for not selectable group (int) .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[DXFEntity] Iterate over all DXF entities in \fI\%DXFGroup\fP as instances of \fBDXFGraphic\fP or inherited (LINE, CIRCLE, …). .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns the count of DXF entities in \fI\%DXFGroup\fP\&. .UNINDENT .INDENT 7.0 .TP .B __getitem__(item) Returns entities by standard Python indexing and slicing. .UNINDENT .INDENT 7.0 .TP .B __contains__(item: str | DXFEntity) -> bool Returns \fBTrue\fP if item is in \fI\%DXFGroup\fP\&. \fIitem\fP has to be a handle string or an object of type \fBDXFEntity\fP or inherited. .UNINDENT .INDENT 7.0 .TP .B handles() -> Iterable[str] Iterable of handles of all DXF entities in \fI\%DXFGroup\fP\&. .UNINDENT .INDENT 7.0 .TP .B edit_data() -> list[DXFEntity] Context manager which yields all the group entities as standard Python list: .INDENT 7.0 .INDENT 3.5 .sp .EX with group.edit_data() as data: # add new entities to a group data.append(modelspace.add_line((0, 0), (3, 0))) # remove last entity from a group data.pop() .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_data(entities: Iterable[DXFEntity]) -> None Set \fIentities\fP as new group content, entities should be an iterable \fBDXFGraphic\fP or inherited (LINE, CIRCLE, …). Raises \fBDXFValueError\fP if not all entities be on the same layout (modelspace or any paperspace layout but not block) .UNINDENT .INDENT 7.0 .TP .B extend(entities: Iterable[DXFEntity]) -> None Add \fIentities\fP to \fI\%DXFGroup\fP without immediate verification! .sp Validation at DXF export may raise a \fBDXFStructureError\fP! .UNINDENT .INDENT 7.0 .TP .B clear() -> None Remove all entities from \fI\%DXFGroup\fP, does not delete any drawing entities referenced by this group. .UNINDENT .INDENT 7.0 .TP .B audit(auditor: Auditor) -> None Remove invalid entities from \fI\%DXFGroup\fP\&. .sp Invalid entities are: .INDENT 7.0 .IP \(bu 2 deleted entities .IP \(bu 2 all entities which do not reside in model\- or paper space .IP \(bu 2 all entities if they do not reside in the same layout .UNINDENT .UNINDENT .UNINDENT .SS GroupCollection .sp Each \fI\%Drawing\fP has one group table, which is accessible by the attribute \fI\%groups\fP\&. .INDENT 0.0 .TP .B class ezdxf.entities.dxfgroups.GroupCollection Manages all \fI\%DXFGroup\fP objects of a \fI\%Drawing\fP\&. .INDENT 7.0 .TP .B __len__() Returns the count of DXF groups. .UNINDENT .INDENT 7.0 .TP .B __iter__() Iterate over all existing groups as (\fIname\fP, \fIgroup\fP) tuples. \fIname\fP is the name of the group as string and \fIgroup\fP is an \fI\%DXFGroup\fP object. .UNINDENT .INDENT 7.0 .TP .B __contains__() Returns \fBTrue\fP if a group \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B get(name: str) -> \fI\%DXFGroup\fP Returns the group \fIname\fP\&. Raises \fBDXFKeyError\fP if group \fIname\fP does not exist. .UNINDENT .INDENT 7.0 .TP .B groups() -> Iterator[\fI\%DXFGroup\fP] Iterable of all existing groups. .UNINDENT .INDENT 7.0 .TP .B new(name: str | None = None, description: str = \(aq\(aq, selectable: bool = True) -> \fI\%DXFGroup\fP Creates a new group. If \fIname\fP is \fBNone\fP an unnamed group is created, which has an automatically generated name like “*Annnn”. Group names are case\-insensitive. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – group name as string .IP \(bu 2 \fBdescription\fP – group description as string .IP \(bu 2 \fBselectable\fP – group is selectable if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete(group: \fI\%DXFGroup\fP | str) -> None Delete \fIgroup\fP, \fIgroup\fP can be an object of type \fI\%DXFGroup\fP or a group name as string. .UNINDENT .INDENT 7.0 .TP .B clear() Delete all groups. .UNINDENT .INDENT 7.0 .TP .B audit(auditor: Auditor) -> None Removes empty groups and invalid handles from all groups. .UNINDENT .UNINDENT .SS DXF Entities .sp All DXF entities can only reside in the \fI\%BaseLayout\fP and inherited classes like \fI\%Modelspace\fP, \fI\%Paperspace\fP and \fI\%BlockLayout\fP\&. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .SS DXF Entity Base Class .sp Common base class for all DXF entities and objects. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.DXFEntity .INDENT 7.0 .TP .B dxf The DXF attributes namespace: .INDENT 7.0 .INDENT 3.5 .sp .EX # set attribute value entity.dxf.layer = \(aqMyLayer\(aq # get attribute value linetype = entity.dxf.linetype # delete attribute del entity.dxf.linetype .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxf.handle DXF \fIhandle\fP is a unique identifier as plain hex string like \fBF000\fP\&. (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.owner Handle to \fIowner\fP as plain hex string like \fBF000\fP\&. (feature for experts) .UNINDENT .INDENT 7.0 .TP .B doc Get the associated \fI\%Drawing\fP instance. .UNINDENT .INDENT 7.0 .TP .B property is_alive: bool Is \fBFalse\fP if entity has been deleted. .UNINDENT .INDENT 7.0 .TP .B property is_virtual: bool Is \fBTrue\fP if entity is a virtual entity. .UNINDENT .INDENT 7.0 .TP .B property is_bound: bool Is \fBTrue\fP if entity is bound to DXF document. .UNINDENT .INDENT 7.0 .TP .B property is_copy: bool Is \fBTrue\fP if the entity is a copy. .UNINDENT .INDENT 7.0 .TP .B property uuid: UUID Returns a UUID, which allows to distinguish even virtual entities without a handle. .sp Dynamic attribute: this UUID will be created at the first request. .UNINDENT .INDENT 7.0 .TP .B property source_of_copy: DXFEntity | None The immediate source entity if this entity is a copy else \fBNone\fP\&. Never references a destroyed entity. .UNINDENT .INDENT 7.0 .TP .B property origin_of_copy: DXFEntity | None The origin source entity if this entity is a copy else \fBNone\fP\&. References the first non\-virtual source entity and never references a destroyed entity. .UNINDENT .INDENT 7.0 .TP .B property has_source_block_reference: bool Is \fBTrue\fP if this virtual entity was created by a block reference. .UNINDENT .INDENT 7.0 .TP .B property source_block_reference: \fI\%Insert\fP | None The source block reference (INSERT) which created this virtual entity. The property is \fBNone\fP if this entity was not created by a block reference. .UNINDENT .INDENT 7.0 .TP .B dxftype() -> str Get DXF type as string, like \fBLINE\fP for the line entity. .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Returns a simple string representation. .UNINDENT .INDENT 7.0 .TP .B __repr__() -> str Returns a simple string representation including the class. .UNINDENT .INDENT 7.0 .TP .B has_dxf_attrib(key: str) -> bool Returns \fBTrue\fP if DXF attribute \fIkey\fP really exist. .sp Raises \fBDXFAttributeError\fP if \fIkey\fP is not an supported DXF attribute. .UNINDENT .INDENT 7.0 .TP .B is_supported_dxf_attrib(key: str) -> bool Returns \fBTrue\fP if DXF attrib \fIkey\fP is supported by this entity. Does not grant that attribute \fIkey\fP really exist. .UNINDENT .INDENT 7.0 .TP .B get_dxf_attrib(key: str, default: Any = None) -> Any Get DXF attribute \fIkey\fP, returns \fIdefault\fP if key doesn’t exist, or raise \fBDXFValueError\fP if \fIdefault\fP is \fBDXFValueError\fP and no DXF default value is defined: .INDENT 7.0 .INDENT 3.5 .sp .EX layer = entity.get_dxf_attrib(\(dqlayer\(dq) # same as layer = entity.dxf.layer .EE .UNINDENT .UNINDENT .sp Raises \fBDXFAttributeError\fP if \fIkey\fP is not an supported DXF attribute. .UNINDENT .INDENT 7.0 .TP .B set_dxf_attrib(key: str, value: Any) -> None Set new \fIvalue\fP for DXF attribute \fIkey\fP: .INDENT 7.0 .INDENT 3.5 .sp .EX entity.set_dxf_attrib(\(dqlayer\(dq, \(dqMyLayer\(dq) # same as entity.dxf.layer = \(dqMyLayer\(dq .EE .UNINDENT .UNINDENT .sp Raises \fBDXFAttributeError\fP if \fIkey\fP is not an supported DXF attribute. .UNINDENT .INDENT 7.0 .TP .B del_dxf_attrib(key: str) -> None Delete DXF attribute \fIkey\fP, does not raise an error if attribute is supported but not present. .sp Raises \fBDXFAttributeError\fP if \fIkey\fP is not an supported DXF attribute. .UNINDENT .INDENT 7.0 .TP .B dxfattribs(drop: set[str] | None = None) -> dict Returns a \fBdict\fP with all existing DXF attributes and their values and exclude all DXF attributes listed in set \fIdrop\fP\&. .UNINDENT .INDENT 7.0 .TP .B update_dxf_attribs(dxfattribs: dict) -> None Set DXF attributes by a \fBdict\fP like \fB{\(aqlayer\(aq: \(aqtest\(aq, \(aqcolor\(aq: 4}\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_flag_state(flag: int, state: bool = True, name: str = \(aqflags\(aq) -> None Set binary coded \fIflag\fP of DXF attribute \fIname\fP to 1 (on) if \fIstate\fP is \fBTrue\fP, set \fIflag\fP to 0 (off) if \fIstate\fP is \fBFalse\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_flag_state(flag: int, name: str = \(aqflags\(aq) -> bool Returns \fBTrue\fP if any \fIflag\fP of DXF attribute is 1 (on), else \fBFalse\fP\&. Always check only one flag state at the time. .UNINDENT .INDENT 7.0 .TP .B has_extension_dict Returns \fBTrue\fP if entity has an attached \fI\%ExtensionDict\fP instance. .UNINDENT .INDENT 7.0 .TP .B get_extension_dict() -> \fI\%ExtensionDict\fP Returns the existing \fI\%ExtensionDict\fP instance. .INDENT 7.0 .TP .B Raises \fBAttributeError\fP – extension dict does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B new_extension_dict() -> \fI\%ExtensionDict\fP Create a new \fI\%ExtensionDict\fP instance . .UNINDENT .INDENT 7.0 .TP .B discard_extension_dict() -> None Delete \fI\%ExtensionDict\fP instance . .UNINDENT .INDENT 7.0 .TP .B has_app_data(appid: str) -> bool Returns \fBTrue\fP if application defined data for \fIappid\fP exist. .UNINDENT .INDENT 7.0 .TP .B get_app_data(appid: str) -> \fI\%Tags\fP Returns application defined data for \fIappid\fP\&. .INDENT 7.0 .TP .B Parameters \fBappid\fP – application name as defined in the APPID table. .TP .B Raises \fI\%DXFValueError\fP – no data for \fIappid\fP found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_app_data(appid: str, tags: Iterable) -> None Set application defined data for \fIappid\fP as iterable of tags. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – application name as defined in the APPID table. .IP \(bu 2 \fBtags\fP – iterable of (code, value) tuples or \fI\%DXFTag\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B discard_app_data(appid: str) Discard application defined data for \fIappid\fP\&. Does not raise an exception if no data for \fIappid\fP exist. .UNINDENT .INDENT 7.0 .TP .B has_xdata(appid: str) -> bool Returns \fBTrue\fP if extended data for \fIappid\fP exist. .UNINDENT .INDENT 7.0 .TP .B get_xdata(appid: str) -> \fI\%Tags\fP Returns extended data for \fIappid\fP\&. .INDENT 7.0 .TP .B Parameters \fBappid\fP – application name as defined in the APPID table. .TP .B Raises \fI\%DXFValueError\fP – no extended data for \fIappid\fP found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_xdata(appid: str, tags: Iterable) -> None Set extended data for \fIappid\fP as iterable of tags. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – application name as defined in the APPID table. .IP \(bu 2 \fBtags\fP – iterable of (code, value) tuples or \fI\%DXFTag\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B discard_xdata(appid: str) -> None Discard extended data for \fIappid\fP\&. Does not raise an exception if no extended data for \fIappid\fP exist. .UNINDENT .INDENT 7.0 .TP .B has_xdata_list(appid: str, name: str) -> bool Returns \fBTrue\fP if a tag list \fIname\fP for extended data \fIappid\fP exist. .UNINDENT .INDENT 7.0 .TP .B get_xdata_list(appid: str, name: str) -> \fI\%Tags\fP Returns tag list \fIname\fP for extended data \fIappid\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – application name as defined in the APPID table. .IP \(bu 2 \fBname\fP – extended data list name .UNINDENT .TP .B Raises \fI\%DXFValueError\fP – no extended data for \fIappid\fP found or no data list \fIname\fP not found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_xdata_list(appid: str, name: str, tags: Iterable) -> None Set tag list \fIname\fP for extended data \fIappid\fP as iterable of tags. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – application name as defined in the APPID table. .IP \(bu 2 \fBname\fP – extended data list name .IP \(bu 2 \fBtags\fP – iterable of (code, value) tuples or \fI\%DXFTag\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B discard_xdata_list(appid: str, name: str) -> None Discard tag list \fIname\fP for extended data \fIappid\fP\&. Does not raise an exception if no extended data for \fIappid\fP or no tag list \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B replace_xdata_list(appid: str, name: str, tags: Iterable) -> None Replaces tag list \fIname\fP for existing extended data \fIappid\fP by \fItags\fP\&. Appends new list if tag list \fIname\fP do not exist, but raises \fBDXFValueError\fP if extended data \fIappid\fP do not exist. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – application name as defined in the APPID table. .IP \(bu 2 \fBname\fP – extended data list name .IP \(bu 2 \fBtags\fP – iterable of (code, value) tuples or \fI\%DXFTag\fP .UNINDENT .TP .B Raises \fI\%DXFValueError\fP – no extended data for \fIappid\fP found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_reactors() -> bool Returns \fBTrue\fP if entity has reactors. .UNINDENT .INDENT 7.0 .TP .B get_reactors() -> list[str] Returns associated reactors as list of handles. .UNINDENT .INDENT 7.0 .TP .B set_reactors(handles: Iterable[str]) -> None Set reactors as list of handles. .UNINDENT .INDENT 7.0 .TP .B append_reactor_handle(handle: str) -> None Append \fIhandle\fP to reactors. .UNINDENT .INDENT 7.0 .TP .B discard_reactor_handle(handle: str) -> None Discard \fIhandle\fP from reactors. Does not raise an exception if \fIhandle\fP does not exist. .UNINDENT .UNINDENT .SS DXF Graphic Entity Base Class .sp Common base class for all graphical DXF entities. .sp All graphical entities reside in an entity space like \fI\%Modelspace\fP, any \fI\%Paperspace\fP or \fI\%BlockLayout\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.gfxattribs\fP module, helper tools to set graphical attributes of DXF entities .IP \(bu 2 \fI\%ezdxf.colors\fP module .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFEntity\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.DXFGraphic .INDENT 7.0 .TP .B rgb Get/set DXF attribute \fI\%dxf.true_color\fP as (r, g, b) tuple, returns \fBNone\fP if attribute \fI\%dxf.true_color\fP is not set. .INDENT 7.0 .INDENT 3.5 .sp .EX entity.rgb = (30, 40, 50) r, g, b = entity.rgb .EE .UNINDENT .UNINDENT .sp This is the recommend method to get/set RGB values, when ever possible do not use the DXF low level attribute \fI\%dxf.true_color\fP\&. .UNINDENT .INDENT 7.0 .TP .B transparency Get/set the transparency value as float. The transparency value is in the range from 0 to 1, where 0 means the entity is opaque and 1 means the entity is 100% transparent (invisible). This is the recommend method to get/set the transparency value, when ever possible do not use the DXF low level attribute \fI\%DXFGraphic.dxf.transparency\fP\&. .sp This attribute requires DXF R2004 or later, returns 0 for older DXF versions and raises \fBDXFAttributeError\fP for setting transparency in older DXF versions. .UNINDENT .INDENT 7.0 .TP .B property is_transparency_by_layer: bool Returns \fBTrue\fP if entity inherits transparency from layer. .UNINDENT .INDENT 7.0 .TP .B property is_transparency_by_block: bool Returns \fBTrue\fP if entity inherits transparency from block. .UNINDENT .INDENT 7.0 .TP .B ocs() -> \fI\%OCS\fP Returns object coordinate system (\fI\%OCS\fP) for 2D entities like \fI\%Text\fP or \fI\%Circle\fP, returns a pass\-through OCS for entities without OCS support. .UNINDENT .INDENT 7.0 .TP .B get_layout() -> \fI\%BaseLayout\fP | None Returns the owner layout or returns \fBNone\fP if entity is not assigned to any layout. .UNINDENT .INDENT 7.0 .TP .B unlink_from_layout() -> None Unlink entity from associated layout. Does nothing if entity is already unlinked. .sp It is more efficient to call the \fI\%unlink_entity()\fP method of the associated layout, especially if you have to unlink more than one entity. .UNINDENT .INDENT 7.0 .TP .B copy_to_layout(layout: \fI\%BaseLayout\fP) -> \fI\%DXFEntity\fP Copy entity to another \fIlayout\fP, returns new created entity as \fI\%DXFEntity\fP object. Copying between different DXF drawings is not supported. .INDENT 7.0 .TP .B Parameters \fBlayout\fP – any layout (model space, paper space, block) .TP .B Raises \fI\%DXFStructureError\fP – for copying between different DXF drawings .UNINDENT .UNINDENT .INDENT 7.0 .TP .B move_to_layout(layout: \fI\%BaseLayout\fP, source: \fI\%BaseLayout\fP | None = None) -> None Move entity from model space or a paper space layout to another layout. For block layout as source, the block layout has to be specified. Moving between different DXF drawings is not supported. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – any layout (model space, paper space, block) .IP \(bu 2 \fBsource\fP – provide source layout, faster for DXF R12, if entity is in a block layout .UNINDENT .TP .B Raises \fI\%DXFStructureError\fP – for moving between different DXF drawings .UNINDENT .UNINDENT .INDENT 7.0 .TP .B graphic_properties() -> dict Returns the important common properties layer, color, linetype, lineweight, ltscale, true_color and color_name as \fIdxfattribs\fP dict. .UNINDENT .INDENT 7.0 .TP .B has_hyperlink() -> bool Returns \fBTrue\fP if entity has an attached hyperlink. .UNINDENT .INDENT 7.0 .TP .B get_hyperlink() -> tuple[str, str, str] Returns hyperlink, description and location. .UNINDENT .INDENT 7.0 .TP .B set_hyperlink(link: str, description: str | None = None, location: str | None = None) Set hyperlink of an entity. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> DXFGraphic Inplace transformation interface, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters \fBm\fP – 4x4 transformation matrix (\fI\%ezdxf.math.Matrix44\fP) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> DXFGraphic Translate entity inplace about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis, returns \fIself\fP (floating interface). .sp Basic implementation uses the \fI\%transform()\fP interface, subclasses may have faster implementations. .UNINDENT .INDENT 7.0 .TP .B scale(sx: float, sy: float, sz: float) -> DXFGraphic Scale entity inplace about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis, returns \fIself\fP (floating interface). .UNINDENT .INDENT 7.0 .TP .B scale_uniform(s: float) -> DXFGraphic Scale entity inplace uniform about \fIs\fP in x\-axis, y\-axis and z\-axis, returns \fIself\fP (floating interface). .UNINDENT .INDENT 7.0 .TP .B rotate_x(angle: float) -> DXFGraphic Rotate entity inplace about x\-axis, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_y(angle: float) -> DXFGraphic Rotate entity inplace about y\-axis, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_z(angle: float) -> DXFGraphic Rotate entity inplace about z\-axis, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_axis(axis: \fI\%UVec\fP, angle: float) -> DXFGraphic Rotate entity inplace about vector \fIaxis\fP, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBaxis\fP – rotation axis as tuple or \fBVec3\fP .IP \(bu 2 \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Common graphical DXF attributes .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .TP .B DXFGraphic.dxf.layer Layer name as string; default = “0” .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.linetype Linetype as string, special names “BYLAYER”, “BYBLOCK”; default value is “BYLAYER” .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.color \fI\%AutoCAD Color Index (ACI)\fP, default value is 256 .sp Constants defined in \fI\%ezdxf.lldxf.const\fP or use the \fI\%ezdxf.colors\fP module .TS center; |l|l|. _ T{ 0 T} T{ BYBLOCK T} _ T{ 256 T} T{ BYLAYER T} _ T{ 257 T} T{ BYOBJECT T} _ .TE .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.lineweight Line weight in mm times 100 (e.g. 0.13mm = 13). There are fixed valid lineweights which are accepted by AutoCAD, other values prevents AutoCAD from loading the DXF document, BricsCAD isn’t that picky. (requires DXF R2000) .sp Constants defined in \fI\%ezdxf.lldxf.const\fP .TS center; |l|l|. _ T{ \-1 T} T{ LINEWEIGHT_BYLAYER T} _ T{ \-2 T} T{ LINEWEIGHT_BYBLOCK T} _ T{ \-3 T} T{ LINEWEIGHT_DEFAULT T} _ .TE .sp Valid DXF lineweights stored in \fBVALID_DXF_LINEWEIGHTS\fP: 0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200, 211 .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.ltscale Line type scale as float; default value is 1.0; (requires DXF R2000) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.invisible 1 for invisible, 0 for visible; default value is 0; (requires DXF R2000) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.paperspace 0 for entity resides in modelspace or a block, 1 for paperspace, this attribute is set automatically by adding an entity to a layout (feature for experts); default value is 0 .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.extrusion Extrusion direction as 3D vector; default value is (0, 0, 1) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.thickness Entity thickness as float; default value is 0.0; (requires DXF R2000) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.true_color True color value as int 0x00RRGGBB, use \fI\%DXFGraphic.rgb\fP to get/set true color values as (r, g, b) tuples. (requires DXF R2004) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.color_name Color name as string. (requires DXF R2004) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.transparency Transparency value as int, 0x020000TT, 0x00 = 100% transparent / 0xFF = opaque, special value 0x01000000 means transparency by block. An unset transparency value means transparency by layer. Use \fI\%DXFGraphic.transparency\fP to get/set transparency as float value, and the properties \fI\%DXFGraphic.is_transparency_by_block\fP and \fI\%DXFGraphic.is_transparency_by_layer\fP to check special cases. .sp (requires DXF R2004) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.shadow_mode .TS center; |l|l|. _ T{ 0 T} T{ casts and receives shadows T} _ T{ 1 T} T{ casts shadows T} _ T{ 2 T} T{ receives shadows T} _ T{ 3 T} T{ ignores shadows T} _ .TE .sp (requires DXF R2007) .UNINDENT .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.gfxattribs\fP module, helper tools to set graphical attributes of DXF entities .IP \(bu 2 \fI\%ezdxf.colors\fP module .IP \(bu 2 \fI\%Tutorial for Common Graphical Attributes\fP .UNINDENT .UNINDENT .UNINDENT .SS Face3d .sp The 3DFACE entity (\fI\%DXF Reference\fP) is real 3D solid filled triangle or quadrilateral. Access vertices by name (\fBentity.dxf.vtx0 = (1.7, 2.3)\fP) or by index (\fBentity[0] = (1.7, 2.3)\fP). .sp Unlike the entities \fI\%Solid\fP and \fI\%Trace\fP, the vertices of \fI\%Face3d\fP have the expected vertex order: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_3dface([(0, 0), (10, 0), (10, 10), (0, 10)]) .EE .UNINDENT .UNINDENT [image] .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aq3DFACE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_3dface()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Face3d The class name is \fI\%Face3d\fP because \fB3dface\fP is not a valid Python class name. .INDENT 7.0 .TP .B dxf.vtx0 Location of 1. vertex (3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx1 Location of 2. vertex (3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx2 Location of 3. vertex (3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx3 Location of 4. vertex (3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.invisible_edge invisible edge flag (int, default=0) .TS center; |l|l|. _ T{ 1 T} T{ first edge is invisible T} _ T{ 2 T} T{ second edge is invisible T} _ T{ 4 T} T{ third edge is invisible T} _ T{ 8 T} T{ fourth edge is invisible T} _ .TE .sp Combine values by adding them, e.g. 1+4 = first and third edge is invisible. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Face3d Transform the 3DFACE entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B wcs_vertices(close: bool = False) -> list[\fI\%Vec3\fP] Returns WCS vertices, if argument \fIclose\fP is \fBTrue\fP, the first vertex is also returned as closing last vertex. .sp Returns 4 vertices when \fIclose\fP is \fBFalse\fP and 5 vertices when \fIclose\fP is \fBTrue\fP\&. Some edges may have zero\-length. This is a compatibility interface to SOLID and TRACE. The 3DFACE entity is already defined by WCS vertices. .UNINDENT .UNINDENT .SS Solid3d .sp 3DSOLID entity (\fI\%DXF Reference\fP) created by an ACIS geometry kernel provided by the \fI\%Spatial Corp.\fP .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP has only very limited support for ACIS based entities, for more information see the FAQ: \fI\%How to add/edit ACIS based entities like 3DSOLID, REGION or SURFACE?\fP .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Body\fP T} _ T{ DXF type T} T{ \fB\(aq3DSOLID\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_3dsolid()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Solid3d Same attributes and methods as parent class \fI\%Body\fP\&. .INDENT 7.0 .TP .B dxf.history_handle Handle to history object. .UNINDENT .UNINDENT .SS ACADProxyEntity .sp An ACAD_PROXY_ENTITY (\fI\%DXF Reference\fP) is a proxy entity that represents an entity created by an Autodesk or 3rd party application. It stores the graphics and data of the original entity. .sp The internals of this entity are unknown, so the entity cannot be copied or transformed. However, \fIezdxf\fP can extract the proxy graphic from these entities as virtual entities or replace (explode) the entire entity with its proxy graphic. The meaning and data of this entity is lost when the entity is exploded. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqACAD_PROXY_ENTITY\(aq\fP T} _ T{ Factory function T} T{ not supported T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.ACADProxyEntity .INDENT 7.0 .TP .B virtual_entities() -> Iterator[DXFGraphic] Yields proxy graphic as “virtual” entities. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: \fI\%BaseLayout\fP | None = None) -> \fI\%EntityQuery\fP Explodes the proxy graphic for the ACAD_PROXY_ENTITY into the target layout, if target layout is \fBNone\fP, the layout of the ACAD_PROXY_ENTITY will be used. This method destroys the source ACAD_PROXY_ENTITY entity. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for exploded entities, \fBNone\fP for same layout as the source ACAD_PROXY_ENTITY. .TP .B Returns \fI\%EntityQuery\fP container referencing all exploded DXF entities. .UNINDENT .UNINDENT .UNINDENT .SS Arc .sp The ARC entity (\fI\%DXF Reference\fP) represents a circular arc, which is defined by the DXF attributes \fBdxf.center\fP, \fBdxf.radius\fP, \fBdxf.start_angle\fP and \fBdxf.end_angle\fP\&. The arc\-curve goes always from \fBdxf.start_angle\fP to \fBdxf.end_angle\fP in counter\-clockwise orientation around the \fBdxf.extrusion\fP vector, which is (0, 0, 1) by default and the usual case for 2D arcs. The ARC entity has \fI\%OCS\fP coordinates. .sp The helper tool \fI\%ezdxf.math.ConstructionArc\fP supports creating arcs from various scenarios, like from 3 points or 2 points and an angle or 2 points and a radius and the \fI\%upright\fP module can convert inverted extrusion vectors from (0, 0, \-1) to (0, 0, 1) without changing the curve. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Simple DXF Entities\fP, section \fI\%Arc\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionArc\fP .IP \(bu 2 \fI\%Object Coordinate System (OCS)\fP .IP \(bu 2 \fI\%ezdxf.upright\fP module .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Circle\fP T} _ T{ DXF type T} T{ \fB\(aqARC\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_arc()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Arc .INDENT 7.0 .TP .B dxf.center Center point of arc (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.radius Radius of arc (float) .UNINDENT .INDENT 7.0 .TP .B dxf.start_angle Start angle in degrees (float) .UNINDENT .INDENT 7.0 .TP .B dxf.end_angle End angle in degrees (float) .UNINDENT .INDENT 7.0 .TP .B start_point Returns the start point of the arc in \fI\%WCS\fP, takes the \fI\%OCS\fP into account. .UNINDENT .INDENT 7.0 .TP .B end_point Returns the end point of the arc in \fI\%WCS\fP, takes the \fI\%OCS\fP into account. .UNINDENT .INDENT 7.0 .TP .B angles(num: int) -> Iterator[float] Yields \fInum\fP angles from start\- to end angle in degrees in counter\-clockwise orientation. All angles are normalized in the range from [0, 360). .UNINDENT .INDENT 7.0 .TP .B flattening(sagitta: float) -> Iterator[\fI\%Vec3\fP] Approximate the arc by vertices in \fI\%WCS\fP, the argument \fI\%sagitta\fP defines the maximum distance from the center of an arc segment to the center of its chord. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Arc Transform ARC entity by transformation matrix \fIm\fP inplace. Raises \fBNonUniformScalingError()\fP for non\-uniform scaling. .UNINDENT .INDENT 7.0 .TP .B to_ellipse(replace=True) -> \fI\%Ellipse\fP Convert the CIRCLE/ARC entity to an \fI\%Ellipse\fP entity. .sp Adds the new ELLIPSE entity to the entity database and to the same layout as the source entity. .INDENT 7.0 .TP .B Parameters \fBreplace\fP – replace (delete) source entity by ELLIPSE entity if \fBTrue\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_spline(replace=True) -> \fI\%Spline\fP Convert the CIRCLE/ARC entity to a \fI\%Spline\fP entity. .sp Adds the new SPLINE entity to the entity database and to the same layout as the source entity. .INDENT 7.0 .TP .B Parameters \fBreplace\fP – replace (delete) source entity by SPLINE entity if \fBTrue\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B construction_tool() -> \fI\%ConstructionArc\fP Returns the 2D construction tool \fI\%ezdxf.math.ConstructionArc\fP but the extrusion vector is ignored. .UNINDENT .INDENT 7.0 .TP .B apply_construction_tool(arc: \fI\%ConstructionArc\fP) -> Arc Set ARC data from the construction tool \fI\%ezdxf.math.ConstructionArc\fP but the extrusion vector is ignored. .UNINDENT .UNINDENT .SS Body .sp BODY entity (\fI\%DXF Reference\fP) created by an ACIS geometry kernel provided by the \fI\%Spatial Corp.\fP .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP has only very limited support for ACIS based entities, for more information see the FAQ: \fI\%How to add/edit ACIS based entities like 3DSOLID, REGION or SURFACE?\fP .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqBODY\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_body()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Body .INDENT 7.0 .TP .B dxf.version Modeler format version number, default value is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.flags Require DXF R2013. .UNINDENT .INDENT 7.0 .TP .B dxf.uid Require DXF R2013. .UNINDENT .INDENT 7.0 .TP .B property acis_data: bytes | Sequence[str] Returns \fI\%SAT\fP data for DXF R2000 up to R2010 and \fI\%SAB\fP data for DXF R2013 and later .UNINDENT .INDENT 7.0 .TP .B property sat: Sequence[str] Get/Set \fI\%SAT\fP data as sequence of strings. .UNINDENT .INDENT 7.0 .TP .B property sab: bytes Get/Set \fI\%SAB\fP data as bytes. .UNINDENT .INDENT 7.0 .TP .B property has_binary_data Returns \fBTrue\fP if the entity contains \fI\%SAB\fP data and \fBFalse\fP if the entity contains \fI\%SAT\fP data. .UNINDENT .INDENT 7.0 .TP .B tostring() -> str Returns ACIS \fI\%SAT\fP data as a single string if the entity has SAT data. .UNINDENT .UNINDENT .SS Circle .sp The CIRCLE entity (\fI\%DXF Reference\fP) defined by the DXF attributes \fBdxf.center\fP and \fBdxf.radius\fP\&. The CIRCLE entity has \fI\%OCS\fP coordinates. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Simple DXF Entities\fP, section \fI\%Circle\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionCircle\fP .IP \(bu 2 \fI\%Object Coordinate System (OCS)\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqCIRCLE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_circle()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Circle .INDENT 7.0 .TP .B dxf.center Center point of circle (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.radius Radius of circle (float) .UNINDENT .INDENT 7.0 .TP .B vertices(angles: Iterable[float]) -> Iterator[\fI\%Vec3\fP] Yields the vertices of the circle of all given \fIangles\fP as \fI\%Vec3\fP instances in \fI\%WCS\fP\&. .INDENT 7.0 .TP .B Parameters \fBangles\fP – iterable of angles in \fI\%OCS\fP as degrees, angle goes counter\-clockwise around the extrusion vector, and the OCS x\-axis defines 0\-degree. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flattening(sagitta: float) -> Iterator[\fI\%Vec3\fP] Approximate the circle by vertices in \fI\%WCS\fP as \fI\%Vec3\fP instances. The argument \fI\%sagitta\fP is the maximum distance from the center of an arc segment to the center of its chord. Yields a closed polygon where the start vertex is equal to the end vertex! .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Circle Transform the CIRCLE entity by transformation matrix \fIm\fP inplace. Raises \fBNonUniformScalingError()\fP for non\-uniform scaling. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> Circle Optimized CIRCLE/ARC translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis, returns \fIself\fP (floating interface). .UNINDENT .INDENT 7.0 .TP .B to_ellipse(replace=True) -> \fI\%Ellipse\fP Convert the CIRCLE/ARC entity to an \fI\%Ellipse\fP entity. .sp Adds the new ELLIPSE entity to the entity database and to the same layout as the source entity. .INDENT 7.0 .TP .B Parameters \fBreplace\fP – replace (delete) source entity by ELLIPSE entity if \fBTrue\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_spline(replace=True) -> \fI\%Spline\fP Convert the CIRCLE/ARC entity to a \fI\%Spline\fP entity. .sp Adds the new SPLINE entity to the entity database and to the same layout as the source entity. .INDENT 7.0 .TP .B Parameters \fBreplace\fP – replace (delete) source entity by SPLINE entity if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .SS Dimension .sp The DIMENSION entity (\fI\%DXF Reference\fP) represents several types of dimensions in many orientations and alignments. The basic types of dimensioning are linear, radial, angular, ordinate, and arc length. .sp For more information about dimensions see the online help from AutoDesk: \fI\%About the Types of Dimensions\fP .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The DIMENSION entity is reused to create dimensional constraints, such entities do not have an associated geometrical block nor a dimension type group code (2) and reside on layer \fB*ADSK_CONSTRAINTS\fP\&. Use property \fI\%Dimension.is_dimensional_constraint\fP to check for this objects. Dimensional constraints are not documented in the DXF reference and not supported by \fIezdxf\fP\&. .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Linear Dimensions\fP .IP \(bu 2 \fI\%Tutorial for Radius Dimensions\fP .IP \(bu 2 \fI\%Tutorial for Diameter Dimensions\fP .IP \(bu 2 \fI\%Tutorial for Angular Dimensions\fP .IP \(bu 2 \fI\%Tutorial for Ordinate Dimensions\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqDIMENSION\(aq\fP T} _ T{ factory function T} T{ see table below T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .SS Factory Functions .TS center; |l|l|. _ T{ \fI\%Linear and Rotated Dimension (DXF)\fP T} T{ \fI\%add_linear_dim()\fP T} _ T{ \fI\%Aligned Dimension (DXF)\fP T} T{ \fI\%add_aligned_dim()\fP T} _ T{ \fI\%Angular Dimension (DXF)\fP T} T{ \fI\%add_angular_dim_2l()\fP T} _ T{ \fI\%Angular 3P Dimension (DXF)\fP T} T{ \fI\%add_angular_dim_3p()\fP T} _ T{ Angular Dimension by center, radius, angles T} T{ \fI\%add_angular_dim_cra()\fP T} _ T{ Angular Dimension by ConstructionArc T} T{ \fI\%add_angular_dim_arc()\fP T} _ T{ \fI\%Diameter Dimension (DXF)\fP T} T{ \fI\%add_diameter_dim()\fP T} _ T{ \fI\%Radius Dimension (DXF)\fP T} T{ \fI\%add_radius_dim()\fP T} _ T{ \fI\%Ordinate Dimension (DXF)\fP T} T{ \fI\%add_ordinate_dim()\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Dimension There is only one \fI\%Dimension\fP class to represent all different dimension types. .INDENT 7.0 .TP .B dxf.version Version number: \fB0\fP = R2010. (int, DXF R2010) .UNINDENT .INDENT 7.0 .TP .B dxf.geometry Name of the BLOCK that contains the entities that make up the dimension picture. .sp For AutoCAD this graphical representation is mandatory, otherwise AutoCAD will not open the DXF document. BricsCAD will render the DIMENSION entity by itself, if the graphical representation is not present, but displays the BLOCK content if present. .UNINDENT .INDENT 7.0 .TP .B dxf.dimstyle Dimension style (\fI\%DimStyle\fP) name as string. .UNINDENT .INDENT 7.0 .TP .B dxf.dimtype Values 0\-6 are integer values that represent the dimension type. Values 32, 64, and 128 are bit values, which are added to the integer values. .TS center; |l|l|. _ T{ 0 T} T{ \fI\%Linear and Rotated Dimension (DXF)\fP T} _ T{ 1 T} T{ \fI\%Aligned Dimension (DXF)\fP T} _ T{ 2 T} T{ \fI\%Angular Dimension (DXF)\fP T} _ T{ 3 T} T{ \fI\%Diameter Dimension (DXF)\fP T} _ T{ 4 T} T{ \fI\%Radius Dimension (DXF)\fP T} _ T{ 5 T} T{ \fI\%Angular 3P Dimension (DXF)\fP T} _ T{ 6 T} T{ \fI\%Ordinate Dimension (DXF)\fP T} _ T{ 8 T} T{ subclass \fI\%ezdxf.entities.ArcDimension\fP introduced in DXF R2004 T} _ T{ 32 T} T{ Indicates that graphical representation \fBgeometry\fP is referenced by this dimension only. (always set in DXF R13 and later) T} _ T{ 64 T} T{ Ordinate type. This is a bit value (bit 7) used only with integer value 6. If set, ordinate is \fIX\-type\fP; if not set, ordinate is \fIY\-type\fP T} _ T{ 128 T} T{ This is a bit value (bit 8) added to the other \fBdimtype\fP values if the dimension text has been positioned at a user\-defined location rather than at the default location T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint Definition point for all dimension types. (3D Point in \fI\%WCS\fP) .INDENT 7.0 .IP \(bu 2 Linear\- and rotated dimension: \fBdxf.defpoint\fP specifies the dimension line location. .IP \(bu 2 Arc\- and angular dimension: \fBdxf.defpoint\fP and \fBdxfdefpoint4\fP specify the endpoints of the line used to determine the second extension line. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint2 Definition point for linear\- and angular dimensions. (3D Point in \fI\%WCS\fP) .INDENT 7.0 .IP \(bu 2 Linear\- and rotated dimension: The \fBdxf.defpoint2\fP specifies the start point of the first extension line. .IP \(bu 2 Arc\- and angular dimension: The \fBdxf.defpoint2\fP and \fBdxf.defpoint3\fP specify the endpoints of the line used to determine the first extension line. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint3 Definition point for linear\- and angular dimensions. (3D Point in \fI\%WCS\fP) .INDENT 7.0 .IP \(bu 2 Linear\- and rotated dimension: The \fBdxf.defpoint3\fP specifies the start point of the second extension line. .IP \(bu 2 Arc\- and angular dimension: The \fBdxf.defpoint2\fP and \fBdxf.defpoint3\fP specify the endpoints of the line used to determine the first extension line. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint4 Definition point for diameter\-, radius\-, and angular dimensions. (3D Point in \fI\%WCS\fP) .sp The \fBdxf.defpoint\fP and \fBdxf.defpoint4\fP specify the endpoints of the line used to determine the second extension line for arc\- and angular dimension: .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint5 This point defines the location of the arc for angular dimensions. (3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.angle Rotation angle of linear and rotated dimensions in degrees. (float) .UNINDENT .INDENT 7.0 .TP .B dxf.leader_length Leader length for radius and diameter dimensions. (float) .UNINDENT .INDENT 7.0 .TP .B dxf.text_midpoint Middle point of dimension text. (3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.insert Insertion point for clones of a linear dimensions. (3D Point in \fI\%OCS\fP) .sp This value translates the content of the associated anonymous block for cloned linear dimensions, similar to the \fBinsert\fP attribute of the \fI\%Insert\fP entity. .UNINDENT .INDENT 7.0 .TP .B dxf.attachment_point Text attachment point (int, DXF R2000), default value is 5. .TS center; |l|l|. _ T{ 1 T} T{ Top left T} _ T{ 2 T} T{ Top center T} _ T{ 3 T} T{ Top right T} _ T{ 4 T} T{ Middle left T} _ T{ 5 T} T{ Middle center T} _ T{ 6 T} T{ Middle right T} _ T{ 7 T} T{ Bottom left T} _ T{ 8 T} T{ Bottom center T} _ T{ 9 T} T{ Bottom right T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.line_spacing_style Dimension text line\-spacing style (int, DXF R2000), default value is 1. .TS center; |l|l|. _ T{ 1 T} T{ At least (taller characters will override) T} _ T{ 2 T} T{ Exact (taller characters will not override) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.line_spacing_factor Dimension text\-line spacing factor. (float, DXF R2000) .sp Percentage of default (3\-on\-5) line spacing to be applied. Valid values range from 0.25 to 4.00. .UNINDENT .INDENT 7.0 .TP .B dxf.actual_measurement Actual measurement (float, DXF R2000), this is an optional attribute and often not present. (read\-only value) .UNINDENT .INDENT 7.0 .TP .B dxf.text Dimension text explicitly entered by the user (str), default value is an empty string. .sp If empty string or “<>”, the dimension measurement is drawn as the text, if “ ” (one blank space), the text is suppressed. Anything else will be displayed as the dimension text. .UNINDENT .INDENT 7.0 .TP .B dxf.oblique_angle The optional \fBdxf.oblique_angle\fP defines the angle of the extension lines for linear dimension. .UNINDENT .INDENT 7.0 .TP .B dxf.text_rotation Defines is the rotation angle of the dimension text away from its default orientation (the direction of the dimension line). (float) .UNINDENT .INDENT 7.0 .TP .B dxf.horizontal_direction Indicates the horizontal direction for the dimension entity (float). .sp This attribute determines the orientation of dimension text and lines for horizontal, vertical, and rotated linear dimensions. This value is the negative of the angle in the OCS xy\-plane between the dimension line and the OCS x\-axis. .UNINDENT .INDENT 7.0 .TP .B property dimtype: int \fI\%dxf.dimtype\fP without binary flags (32, 62, 128). .UNINDENT .INDENT 7.0 .TP .B property is_dimensional_constraint: bool Returns \fBTrue\fP if the DIMENSION entity is a dimensional constraint object. .UNINDENT .INDENT 7.0 .TP .B get_dim_style() -> \fI\%DimStyle\fP Returns the associated \fI\%DimStyle\fP entity. .UNINDENT .INDENT 7.0 .TP .B get_geometry_block() -> \fI\%BlockLayout\fP | None Returns \fI\%BlockLayout\fP of associated anonymous dimension block, which contains the entities that make up the dimension picture. Returns \fBNone\fP if block name is not set or the BLOCK itself does not exist .UNINDENT .INDENT 7.0 .TP .B get_measurement() -> float | \fI\%Vec3\fP Returns the actual dimension measurement in \fI\%WCS\fP units, no scaling applied for linear dimensions. Returns angle in degrees for angular dimension from 2 lines and angular dimension from 3 points. Returns vector from origin to feature location for ordinate dimensions. .UNINDENT .INDENT 7.0 .TP .B override() -> DimStyleOverride Returns the \fI\%DimStyleOverride\fP object. .UNINDENT .INDENT 7.0 .TP .B render() -> None Renders the graphical representation of the DIMENSION entity as DXF primitives (TEXT, LINE, ARC, …) into an anonymous content BLOCK. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Dimension Transform the DIMENSION entity by transformation matrix \fIm\fP inplace. .sp Raises \fBNonUniformScalingError()\fP for non uniform scaling. .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterator[DXFGraphic] Yields the graphical representation of the anonymous content BLOCK as virtual DXF primitives (LINE, ARC, TEXT, …). .sp These virtual entities are located at the original location of the DIMENSION entity, but they are not stored in the entity database, have no handle and are not assigned to any layout. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: \fI\%BaseLayout\fP | None = None) -> \fI\%EntityQuery\fP Explodes the graphical representation of the DIMENSION entity as DXF primitives (LINE, ARC, TEXT, …) into the target layout, \fBNone\fP for the same layout as the source DIMENSION entity. .sp Returns an \fI\%EntityQuery\fP container containing all DXF primitives. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for the DXF primitives, \fBNone\fP for same layout as source DIMENSION entity. .UNINDENT .UNINDENT .UNINDENT .SS DimStyleOverride .sp All of the \fI\%DimStyle\fP attributes can be overridden for each \fI\%Dimension\fP entity individually. .sp The \fI\%DimStyleOverride\fP class manages all the complex dependencies between \fI\%DimStyle\fP and \fI\%Dimension\fP, the different features of all DXF versions and the rendering process to create the \fI\%Dimension\fP picture as BLOCK, which is required for AutoCAD. .INDENT 0.0 .TP .B class ezdxf.entities.DimStyleOverride .INDENT 7.0 .TP .B dimension Base \fI\%Dimension\fP entity. .UNINDENT .INDENT 7.0 .TP .B dimstyle By \fI\%dimension\fP referenced \fI\%DimStyle\fP entity. .UNINDENT .INDENT 7.0 .TP .B dimstyle_attribs Contains all overridden attributes of \fI\%dimension\fP, as a \fBdict\fP with \fI\%DimStyle\fP attribute names as keys. .UNINDENT .INDENT 7.0 .TP .B __getitem__(key: str) -> Any Returns DIMSTYLE attribute \fIkey\fP, see also \fI\%get()\fP\&. .UNINDENT .INDENT 7.0 .TP .B __setitem__(key: str, value: Any) -> None Set DIMSTYLE attribute \fIkey\fP in \fI\%dimstyle_attribs\fP\&. .UNINDENT .INDENT 7.0 .TP .B __delitem__(key: str) -> None Deletes DIMSTYLE attribute \fIkey\fP from \fI\%dimstyle_attribs\fP, ignores \fBKeyErrors\fP silently. .UNINDENT .INDENT 7.0 .TP .B get(attribute: str, default: Any = None) -> Any Returns DIMSTYLE \fIattribute\fP from override dict \fI\%dimstyle_attribs\fP or base \fI\%DimStyle\fP\&. .sp Returns \fIdefault\fP value for attributes not supported by DXF R12. This is a hack to use the same algorithm to render DXF R2000 and DXF R12 DIMENSION entities. But the DXF R2000 attributes are not stored in the DXF R12 file! This method does not catch invalid attribute names! Check debug log for ignored DIMSTYLE attributes. .UNINDENT .INDENT 7.0 .TP .B pop(attribute: str, default: Any = None) -> Any Returns DIMSTYLE \fIattribute\fP from override dict \fI\%dimstyle_attribs\fP and removes this \fIattribute\fP from override dict. .UNINDENT .INDENT 7.0 .TP .B update(attribs: dict) -> None Update override dict \fI\%dimstyle_attribs\fP\&. .INDENT 7.0 .TP .B Parameters \fBattribs\fP – \fBdict\fP of DIMSTYLE attributes .UNINDENT .UNINDENT .INDENT 7.0 .TP .B commit() -> None Writes overridden DIMSTYLE attributes into ACAD:DSTYLE section of XDATA of the DIMENSION entity. .UNINDENT .INDENT 7.0 .TP .B get_arrow_names() -> tuple[str, str] Get arrow names as strings like ‘ARCHTICK’ as tuple (dimblk1, dimblk2). .UNINDENT .INDENT 7.0 .TP .B set_arrows(blk: str | None = None, blk1: str | None = None, blk2: str | None = None, ldrblk: str | None = None, size: float | None = None) -> None Set arrows or user defined blocks and disable oblique stroke as tick. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBblk\fP – defines both arrows at once as name str or user defined block .IP \(bu 2 \fBblk1\fP – defines left arrow as name str or as user defined block .IP \(bu 2 \fBblk2\fP – defines right arrow as name str or as user defined block .IP \(bu 2 \fBldrblk\fP – defines leader arrow as name str or as user defined block .IP \(bu 2 \fBsize\fP – arrow size in drawing units .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_tick(size: float = 1) -> None Use oblique stroke as tick, disables arrows. .INDENT 7.0 .TP .B Parameters \fBsize\fP – arrow size in daring units .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_text_align(halign: str | None = None, valign: str | None = None, vshift: float | None = None) -> None Set measurement text alignment, \fIhalign\fP defines the horizontal alignment, \fIvalign\fP defines the vertical alignment, \fIabove1\fP and \fIabove2\fP means above extension line 1 or 2 and aligned with extension line. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBhalign\fP – \fIleft\fP, \fIright\fP, \fIcenter\fP, \fIabove1\fP, \fIabove2\fP, requires DXF R2000+ .IP \(bu 2 \fBvalign\fP – \fIabove\fP, \fIcenter\fP, \fIbelow\fP .IP \(bu 2 \fBvshift\fP – vertical text shift, if \fIvalign\fP is \fIcenter\fP; >0 shift upward, <0 shift downwards .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_tolerance(upper: float, lower: float | None = None, hfactor: float | None = None, align: \fI\%MTextLineAlignment\fP | None = None, dec: int | None = None, leading_zeros: bool | None = None, trailing_zeros: bool | None = None) -> None Set tolerance text format, upper and lower value, text height factor, number of decimal places or leading and trailing zero suppression. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBupper\fP – upper tolerance value .IP \(bu 2 \fBlower\fP – lower tolerance value, if None same as upper .IP \(bu 2 \fBhfactor\fP – tolerance text height factor in relation to the dimension text height .IP \(bu 2 \fBalign\fP – tolerance text alignment enum \fI\%ezdxf.enums.MTextLineAlignment\fP .IP \(bu 2 \fBdec\fP – Sets the number of decimal places displayed .IP \(bu 2 \fBleading_zeros\fP – suppress leading zeros for decimal dimensions if \fBFalse\fP .IP \(bu 2 \fBtrailing_zeros\fP – suppress trailing zeros for decimal dimensions if \fBFalse\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_limits(upper: float, lower: float, hfactor: float | None = None, dec: int | None = None, leading_zeros: bool | None = None, trailing_zeros: bool | None = None) -> None Set limits text format, upper and lower limit values, text height factor, number of decimal places or leading and trailing zero suppression. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBupper\fP – upper limit value added to measurement value .IP \(bu 2 \fBlower\fP – lower limit value subtracted from measurement value .IP \(bu 2 \fBhfactor\fP – limit text height factor in relation to the dimension text height .IP \(bu 2 \fBdec\fP – Sets the number of decimal places displayed, requires DXF R2000+ .IP \(bu 2 \fBleading_zeros\fP – suppress leading zeros for decimal dimensions if \fBFalse\fP, requires DXF R2000+ .IP \(bu 2 \fBtrailing_zeros\fP – suppress trailing zeros for decimal dimensions if \fBFalse\fP, requires DXF R2000+ .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_text_format(prefix: str = \(aq\(aq, postfix: str = \(aq\(aq, rnd: float | None = None, dec: int | None = None, sep: str | None = None, leading_zeros: bool | None = None, trailing_zeros: bool | None = None) -> None Set dimension text format, like prefix and postfix string, rounding rule and number of decimal places. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBprefix\fP – dimension text prefix text as string .IP \(bu 2 \fBpostfix\fP – dimension text postfix text as string .IP \(bu 2 \fBrnd\fP – Rounds all dimensioning distances to the specified value, for instance, if DIMRND is set to 0.25, all distances round to the nearest 0.25 unit. If you set DIMRND to 1.0, all distances round to the nearest integer. .IP \(bu 2 \fBdec\fP – Sets the number of decimal places displayed for the primary units of a dimension. requires DXF R2000+ .IP \(bu 2 \fBsep\fP – “.” or “,” as decimal separator .IP \(bu 2 \fBleading_zeros\fP – suppress leading zeros for decimal dimensions if \fBFalse\fP .IP \(bu 2 \fBtrailing_zeros\fP – suppress trailing zeros for decimal dimensions if \fBFalse\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_dimline_format(color: int | None = None, linetype: str | None = None, lineweight: int | None = None, extension: float | None = None, disable1: bool | None = None, disable2: bool | None = None) Set dimension line properties. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – color index .IP \(bu 2 \fBlinetype\fP – linetype as string .IP \(bu 2 \fBlineweight\fP – line weight as int, 13 = 0.13mm, 200 = 2.00mm .IP \(bu 2 \fBextension\fP – extension length .IP \(bu 2 \fBdisable1\fP – True to suppress first part of dimension line .IP \(bu 2 \fBdisable2\fP – True to suppress second part of dimension line .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_extline_format(color: int | None = None, lineweight: int | None = None, extension: float | None = None, offset: float | None = None, fixed_length: float | None = None) Set common extension line attributes. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – color index .IP \(bu 2 \fBlineweight\fP – line weight as int, 13 = 0.13mm, 200 = 2.00mm .IP \(bu 2 \fBextension\fP – extension length above dimension line .IP \(bu 2 \fBoffset\fP – offset from measurement point .IP \(bu 2 \fBfixed_length\fP – set fixed length extension line, length below the dimension line .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_extline1(linetype: str | None = None, disable=False) Set attributes of the first extension line. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlinetype\fP – linetype for the first extension line .IP \(bu 2 \fBdisable\fP – disable first extension line if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_extline2(linetype: str | None = None, disable=False) Set attributes of the second extension line. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlinetype\fP – linetype for the second extension line .IP \(bu 2 \fBdisable\fP – disable the second extension line if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_text(text: str = \(aq<>\(aq) -> None Set dimension text. .INDENT 7.0 .IP \(bu 2 \fItext\fP = “ “ to suppress dimension text .IP \(bu 2 \fItext\fP = “” or “<>” to use measured distance as dimension text .IP \(bu 2 otherwise display \fItext\fP literally .UNINDENT .UNINDENT .INDENT 7.0 .TP .B shift_text(dh: float, dv: float) -> None Set relative text movement, implemented as user location override without leader. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdh\fP – shift text in text direction .IP \(bu 2 \fBdv\fP – shift text perpendicular to text direction .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_location(location: \fI\%UVec\fP, leader=False, relative=False) -> None Set text location by user, special version for linear dimensions, behaves for other dimension types like \fI\%user_location_override()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlocation\fP – user defined text location .IP \(bu 2 \fBleader\fP – create leader from text to dimension line .IP \(bu 2 \fBrelative\fP – \fIlocation\fP is relative to default location. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B user_location_override(location: \fI\%UVec\fP) -> None Set text location by user, \fIlocation\fP is relative to the origin of the UCS defined in the \fI\%render()\fP method or WCS if the \fIucs\fP argument is \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B render(ucs: \fI\%UCS\fP | None = None, discard=False) -> BaseDimensionRenderer Starts the dimension line rendering process and also writes overridden dimension style attributes into the DSTYLE XDATA section. The rendering process “draws” the graphical representation of the DIMENSION entity as DXF primitives (TEXT, LINE, ARC, …) into an anonymous content BLOCK. .sp You can discard the content BLOCK for a friendly CAD applications like BricsCAD, because the rendering of the dimension entity is done automatically by BricsCAD if the content BLOCK is missing, and the result is in most cases better than the rendering done by \fIezdxf\fP\&. .sp AutoCAD does not render DIMENSION entities automatically, therefore I see AutoCAD as an unfriendly CAD application. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBucs\fP – user coordinate system .IP \(bu 2 \fBdiscard\fP – discard the content BLOCK created by \fIezdxf\fP, this works for BricsCAD, AutoCAD refuses to open DXF files containing DIMENSION entities without a content BLOCK .UNINDENT .TP .B Returns The rendering object of the DIMENSION entity for analytics .UNINDENT .UNINDENT .UNINDENT .SS ArcDimension .sp The ARC_DIMENSION entity was introduced in DXF R2004 and is \fBnot\fP documented in the DXF reference. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Arc Dimensions\fP .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Dimension\fP T} _ T{ DXF type T} T{ \fB\(aqARC_DIMENSION\(aq\fP T} _ T{ factory function T} T{ .INDENT 0.0 .IP \(bu 2 \fI\%add_arc_dim_3p()\fP .IP \(bu 2 \fI\%add_arc_dim_cra()\fP .IP \(bu 2 \fI\%add_arc_dim_arc()\fP .UNINDENT T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ R2004 / AC1018 T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.ArcDimension .INDENT 7.0 .TP .B dxf.defpoint2 start point of first extension line in \fI\%OCS\fP .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint3 start point of second extension line in \fI\%OCS\fP .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint4 center point of arc in \fI\%OCS\fP .UNINDENT .INDENT 7.0 .TP .B dxf.start_angle .UNINDENT .INDENT 7.0 .TP .B dxf.end_angle .UNINDENT .INDENT 7.0 .TP .B dxf.is_partial .UNINDENT .INDENT 7.0 .TP .B dxf.has_leader .UNINDENT .INDENT 7.0 .TP .B dxf.leader_point1 .UNINDENT .INDENT 7.0 .TP .B dxf.leader_point2 .UNINDENT .INDENT 7.0 .TP .B dimtype Returns always \fB8\fP\&. .UNINDENT .UNINDENT .SS Ellipse .sp The ELLIPSE entity (\fI\%DXF Reference\fP) is an elliptic 3D curve defined by the DXF attributes \fBdxf.center\fP, the \fBdxf.major_axis\fP vector and the \fBdxf.extrusion\fP vector. .sp The \fBdxf.ratio\fP attribute is the ratio of minor axis to major axis and has to be smaller or equal 1. The \fBdxf.start_param\fP and \fBdxf.end_param\fP attributes defines the starting\- and the end point of the ellipse, a full ellipse goes from 0 to 2π. The curve always goes from start\- to end param in counter clockwise orientation. .sp The \fBdxf.extrusion\fP vector defines the normal vector of the ellipse plane. The minor axis direction is calculated by \fBdxf.extrusion\fP cross \fBdxf.major_axis\fP\&. The default extrusion vector (0, 0, 1) defines an ellipse plane parallel to xy\-plane of the \fI\%WCS\fP\&. .sp All coordinates and vectors in \fI\%WCS\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Simple DXF Entities\fP, section \fI\%Ellipse\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionEllipse\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqELLIPSE\(aq\fP T} _ T{ factory function T} T{ \fI\%add_ellipse()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Ellipse .INDENT 7.0 .TP .B dxf.center Center point of circle (2D/3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.major_axis Endpoint of major axis, relative to the \fBdxf.center\fP (Vec3), default value is (1, 0, 0). .UNINDENT .INDENT 7.0 .TP .B dxf.ratio Ratio of minor axis to major axis (float), has to be in range from 0.000001 to 1.0, default value is 1. .UNINDENT .INDENT 7.0 .TP .B dxf.start_param Start parameter (float), default value is 0. .UNINDENT .INDENT 7.0 .TP .B dxf.end_param End parameter (float), default value is 2π. .UNINDENT .INDENT 7.0 .TP .B start_point Returns the start point of the ellipse in WCS. .UNINDENT .INDENT 7.0 .TP .B end_point Returns the end point of the ellipse in WCS. .UNINDENT .INDENT 7.0 .TP .B minor_axis Returns the minor axis of the ellipse as \fBVec3\fP in WCS. .UNINDENT .INDENT 7.0 .TP .B construction_tool() -> \fI\%ConstructionEllipse\fP Returns construction tool \fI\%ezdxf.math.ConstructionEllipse\fP\&. .UNINDENT .INDENT 7.0 .TP .B apply_construction_tool(e: \fI\%ConstructionEllipse\fP) -> Ellipse Set ELLIPSE data from construction tool \fI\%ezdxf.math.ConstructionEllipse\fP\&. .UNINDENT .INDENT 7.0 .TP .B vertices(params: Iterable[float]) -> Iterable[\fI\%Vec3\fP] Yields vertices on ellipse for iterable \fIparams\fP in WCS. .INDENT 7.0 .TP .B Parameters \fBparams\fP – param values in the range from 0 to 2π in radians, param goes counter\-clockwise around the extrusion vector, major_axis = local x\-axis = 0 rad. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flattening(distance: float, segments: int = 8) -> Iterable[\fI\%Vec3\fP] Adaptive recursive flattening. The argument \fIsegments\fP is the minimum count of approximation segments, if the distance from the center of the approximation segment to the curve is bigger than \fIdistance\fP the segment will be subdivided. Returns a closed polygon for a full ellipse where the start vertex has the same value as the end vertex. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the projected curve point onto the segment chord. .IP \(bu 2 \fBsegments\fP – minimum segment count .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B params(num: int) -> Iterable[float] Returns \fInum\fP params from start\- to end param in counter\-clockwise order. .sp All params are normalized in the range [0, 2π). .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Ellipse Transform the ELLIPSE entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> Ellipse Optimized ELLIPSE translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis, returns \fIself\fP (floating interface). .UNINDENT .INDENT 7.0 .TP .B to_spline(replace=True) -> \fI\%Spline\fP Convert ELLIPSE to a \fI\%Spline\fP entity. .sp Adds the new SPLINE entity to the entity database and to the same layout as the source entity. .INDENT 7.0 .TP .B Parameters \fBreplace\fP – replace (delete) source entity by SPLINE entity if \fBTrue\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_arc(entity: DXFGraphic) -> Ellipse Create a new virtual ELLIPSE entity from an ARC or a CIRCLE entity. .sp The new entity has no owner, no handle, is not stored in the entity database nor assigned to any layout! .UNINDENT .UNINDENT .SS Hatch .sp The HATCH entity (\fI\%DXF Reference\fP) fills a closed area defined by one or more boundary paths by a hatch pattern, a solid fill, or a gradient fill. .sp All points in \fI\%OCS\fP as (x, y) tuples (\fI\%Hatch.dxf.elevation\fP is the z\-axis value). .sp There are two different hatch pattern default scaling, depending on the HEADER variable $MEASUREMENT, one for ISO measurement (m, cm, mm, …) and one for imperial measurement (in, ft, yd, …). .sp The default scaling for predefined hatch pattern will be chosen according this measurement setting in the HEADER section, this replicates the behavior of BricsCAD and other CAD applications. \fIEzdxf\fP uses the ISO pattern definitions as a base line and scales this pattern down by factor 1/25.6 for imperial measurement usage. The pattern scaling is independent from the drawing units of the document defined by the HEADER variable $INSUNITS. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Hatch\fP and \fI\%DXF Units\fP .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqHATCH\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_hatch()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp Boundary paths classes .sp Path manager: \fI\%BoundaryPaths\fP .INDENT 0.0 .IP \(bu 2 \fI\%PolylinePath\fP .IP \(bu 2 .INDENT 2.0 .TP .B \fI\%EdgePath\fP .INDENT 7.0 .IP \(bu 2 \fI\%LineEdge\fP .IP \(bu 2 \fI\%ArcEdge\fP .IP \(bu 2 \fI\%EllipseEdge\fP .IP \(bu 2 \fI\%SplineEdge\fP .UNINDENT .UNINDENT .UNINDENT .sp Pattern and gradient classes .INDENT 0.0 .IP \(bu 2 \fI\%Pattern\fP .IP \(bu 2 \fI\%PatternLine\fP .IP \(bu 2 \fBGradien\fP .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Hatch .INDENT 7.0 .TP .B dxf.pattern_name Pattern name as string .UNINDENT .INDENT 7.0 .TP .B dxf.solid_fill .TS center; |l|l|. _ T{ 1 T} T{ solid fill, use method \fI\%Hatch.set_solid_fill()\fP T} _ T{ 0 T} T{ pattern fill, use method \fI\%Hatch.set_pattern_fill()\fP T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.associative .TS center; |l|l|. _ T{ 1 T} T{ associative hatch T} _ T{ 0 T} T{ not associative hatch T} _ .TE .sp Associations are not managed by \fIezdxf\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.hatch_style .TS center; |l|l|. _ T{ 0 T} T{ normal T} _ T{ 1 T} T{ outer T} _ T{ 2 T} T{ ignore T} _ .TE .sp (search AutoCAD help for more information) .UNINDENT .INDENT 7.0 .TP .B dxf.pattern_type .TS center; |l|l|. _ T{ 0 T} T{ user T} _ T{ 1 T} T{ predefined T} _ T{ 2 T} T{ custom T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.pattern_angle The actual pattern rotation angle in degrees (float). Changing this value does not rotate the pattern, use \fI\%set_pattern_angle()\fP for this task. .UNINDENT .INDENT 7.0 .TP .B dxf.pattern_scale The actual pattern scale factor (float). Changing this value does not scale the pattern use \fI\%set_pattern_scale()\fP for this task. .UNINDENT .INDENT 7.0 .TP .B dxf.pattern_double 1 = double pattern size else 0. (int) .UNINDENT .INDENT 7.0 .TP .B dxf.n_seed_points Count of seed points (use \fBget_seed_points()\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.elevation Z value represents the elevation height of the \fI\%OCS\fP\&. (float) .UNINDENT .INDENT 7.0 .TP .B paths \fI\%BoundaryPaths\fP object. .UNINDENT .INDENT 7.0 .TP .B pattern \fI\%Pattern\fP object. .UNINDENT .INDENT 7.0 .TP .B gradient \fI\%Gradient\fP object. .UNINDENT .INDENT 7.0 .TP .B seeds A list of seed points as (x, y) tuples. .UNINDENT .INDENT 7.0 .TP .B property has_solid_fill: bool \fBTrue\fP if entity has a solid fill. (read only) .UNINDENT .INDENT 7.0 .TP .B property has_pattern_fill: bool \fBTrue\fP if entity has a pattern fill. (read only) .UNINDENT .INDENT 7.0 .TP .B property has_gradient_data: bool \fBTrue\fP if entity has a gradient fill. A hatch with gradient fill has also a solid fill. (read only) .UNINDENT .INDENT 7.0 .TP .B property bgcolor: \fI\%RGB\fP | None Set pattern fill background color as (r, g, b)\-tuple, rgb values in the range [0, 255] (read/write/del) .sp usage: .INDENT 7.0 .INDENT 3.5 .sp .EX r, g, b = entity.bgcolor # get pattern fill background color entity.bgcolor = (10, 20, 30) # set pattern fill background color del entity.bgcolor # delete pattern fill background color .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_definition(lines: Sequence, factor: float = 1, angle: float = 0) -> None Setup pattern definition by a list of definition lines and the definition line is a 4\-tuple (angle, base_point, offset, dash_length_items). The pattern definition should be designed for a pattern scale factor of 1 and a pattern rotation angle of 0. .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 angle: line angle in degrees .IP \(bu 2 base\-point: (x, y) tuple .IP \(bu 2 offset: (dx, dy) tuple .IP \(bu 2 dash_length_items: list of dash items (item > 0 is a line, item < 0 is a gap and item == 0.0 is a point) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlines\fP – list of definition lines .IP \(bu 2 \fBfactor\fP – pattern scale factor .IP \(bu 2 \fBangle\fP – rotation angle in degrees .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_scale(scale: float) -> None Sets the pattern scale factor and scales the pattern definition. .sp The method always starts from the original base scale, the \fBset_pattern_scale(1)\fP call resets the pattern scale to the original appearance as defined by the pattern designer, but only if the pattern attribute \fI\%dxf.pattern_scale\fP represents the actual scale, it cannot restore the original pattern scale from the pattern definition itself. .INDENT 7.0 .TP .B Parameters \fBscale\fP – pattern scale factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_angle(angle: float) -> None Sets the pattern rotation angle and rotates the pattern definition. .sp The method always starts from the original base rotation of 0, the \fBset_pattern_angle(0)\fP call resets the pattern rotation angle to the original appearance as defined by the pattern designer, but only if the pattern attribute \fI\%dxf.pattern_angle\fP represents the actual pattern rotation, it cannot restore the original rotation angle from the pattern definition itself. .INDENT 7.0 .TP .B Parameters \fBangle\fP – pattern rotation angle in degrees .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_solid_fill(color: int = 7, style: int = 1, rgb: \fI\%RGB\fP | None = None) Set the solid fill mode and removes all gradient and pattern fill related data. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – \fI\%AutoCAD Color Index (ACI)\fP, (0 = BYBLOCK; 256 = BYLAYER) .IP \(bu 2 \fBstyle\fP – hatch style (0 = normal; 1 = outer; 2 = ignore) .IP \(bu 2 \fBrgb\fP – true color value as (r, g, b)\-tuple \- has higher priority than \fIcolor\fP\&. True color support requires DXF R2000. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_fill(name: str, color: int = 7, angle: float = 0.0, scale: float = 1.0, double: int = 0, style: int = 1, pattern_type: int = 1, definition=None) -> None Sets the pattern fill mode and removes all gradient related data. .sp The pattern definition should be designed for a scale factor 1 and a rotation angle of 0 degrees. The predefined hatch pattern like “ANSI33” are scaled according to the HEADER variable $MEASUREMENT for ISO measurement (m, cm, … ), or imperial units (in, ft, …), this replicates the behavior of BricsCAD. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – pattern name as string .IP \(bu 2 \fBcolor\fP – pattern color as \fI\%AutoCAD Color Index (ACI)\fP .IP \(bu 2 \fBangle\fP – pattern rotation angle in degrees .IP \(bu 2 \fBscale\fP – pattern scale factor .IP \(bu 2 \fBdouble\fP – double size flag .IP \(bu 2 \fBstyle\fP – hatch style (0 = normal; 1 = outer; 2 = ignore) .IP \(bu 2 \fBpattern_type\fP – pattern type (0 = user\-defined; 1 = predefined; 2 = custom) .IP \(bu 2 \fBdefinition\fP – list of definition lines and a definition line is a 4\-tuple [angle, base_point, offset, dash_length_items], see \fI\%set_pattern_definition()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_gradient(color1: \fI\%RGB\fP = RGB(0, 0, 0), color2: \fI\%RGB\fP = RGB(255, 255, 255), rotation: float = 0.0, centered: float = 0.0, one_color: int = 0, tint: float = 0.0, name: str = \(aqLINEAR\(aq) -> None Sets the gradient fill mode and removes all pattern fill related data, requires DXF R2004 or newer. A gradient filled hatch is also a solid filled hatch. .sp Valid gradient type names are: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 “LINEAR” .IP \(bu 2 “CYLINDER” .IP \(bu 2 “INVCYLINDER” .IP \(bu 2 “SPHERICAL” .IP \(bu 2 “INVSPHERICAL” .IP \(bu 2 “HEMISPHERICAL” .IP \(bu 2 “INVHEMISPHERICAL” .IP \(bu 2 “CURVED” .IP \(bu 2 “INVCURVED” .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor1\fP – (r, g, b)\-tuple for first color, rgb values as int in the range [0, 255] .IP \(bu 2 \fBcolor2\fP – (r, g, b)\-tuple for second color, rgb values as int in the range [0, 255] .IP \(bu 2 \fBrotation\fP – rotation angle in degrees .IP \(bu 2 \fBcentered\fP – determines whether the gradient is centered or not .IP \(bu 2 \fBone_color\fP – 1 for gradient from \fIcolor1\fP to tinted \fIcolor1\fP .IP \(bu 2 \fBtint\fP – determines the tinted target \fIcolor1\fP for a one color gradient. (valid range 0.0 to 1.0) .IP \(bu 2 \fBname\fP – name of gradient type, default “LINEAR” .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_seed_points(points: Iterable[tuple[float, float]]) -> None Set seed points, \fIpoints\fP is an iterable of (x, y)\-tuples. I don’t know why there can be more than one seed point. All points in \fI\%OCS\fP (\fI\%Hatch.dxf.elevation\fP is the Z value) .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%Hatch\fP Transform entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B associate(path: AbstractBoundaryPath, entities: Iterable[\fI\%DXFEntity\fP]) Set association from hatch boundary \fIpath\fP to DXF geometry \fIentities\fP\&. .sp A HATCH entity can be associative to a base geometry, this association is \fBnot\fP maintained nor verified by \fIezdxf\fP, so if you modify the base geometry the geometry of the boundary path is not updated and no verification is done to check if the associated geometry matches the boundary path, this opens many possibilities to create invalid DXF files: USE WITH CARE! .UNINDENT .INDENT 7.0 .TP .B remove_association() Remove associated path elements. .UNINDENT .UNINDENT .SS Boundary Paths .sp The hatch entity is build by different path types, these are the filter flags for the \fI\%Hatch.dxf.hatch_style\fP: .INDENT 0.0 .IP \(bu 2 EXTERNAL: defines the outer boundary of the hatch .IP \(bu 2 OUTERMOST: defines the first tier of inner hatch boundaries .IP \(bu 2 DEFAULT: default boundary path .UNINDENT .sp As you will learn in the next sections, these are more the recommended usage type for the flags, but the fill algorithm doesn’t care much about that, for instance an OUTERMOST path doesn’t have to be inside the EXTERNAL path. .SS Island Detection .sp In general the island detection algorithm works always from outside to inside and alternates filled and unfilled areas. The area between then 1st and the 2nd boundary is filled, the area between the 2nd and the 3rd boundary is unfilled and so on. The different hatch styles defined by the \fI\%Hatch.dxf.hatch_style\fP attribute are created by filtering some boundary path types. .SS Hatch Style .INDENT 0.0 .IP \(bu 2 HATCH_STYLE_IGNORE: Ignores all paths except the paths marked as EXTERNAL, if there are more than one path marked as EXTERNAL, they are filled in NESTED style. Creates no hatch if no path is marked as EXTERNAL. .IP \(bu 2 HATCH_STYLE_OUTERMOST: Ignores all paths marked as DEFAULT, remaining EXTERNAL and OUTERMOST paths are filled in NESTED style. Creates no hatch if no path is marked as EXTERNAL or OUTERMOST. .IP \(bu 2 HATCH_STYLE_NESTED: Use all existing paths. .UNINDENT .SS Hatch Boundary Classes .INDENT 0.0 .TP .B class ezdxf.entities.BoundaryPaths Defines the borders of the hatch, a hatch can consist of more than one path. .INDENT 7.0 .TP .B paths List of all boundary paths. Contains \fI\%PolylinePath\fP and \fI\%EdgePath\fP objects. (read/write) .UNINDENT .INDENT 7.0 .TP .B external_paths() -> Iterable[AbstractBoundaryPath] Iterable of external paths, could be empty. .UNINDENT .INDENT 7.0 .TP .B outermost_paths() -> Iterable[AbstractBoundaryPath] Iterable of outermost paths, could be empty. .UNINDENT .INDENT 7.0 .TP .B default_paths() -> Iterable[AbstractBoundaryPath] Iterable of default paths, could be empty. .UNINDENT .INDENT 7.0 .TP .B rendering_paths(hatch_style: int = const.HATCH_STYLE_NESTED) -> Iterable[AbstractBoundaryPath] Iterable of paths to process for rendering, filters unused boundary paths according to the given hatch style: .INDENT 7.0 .IP \(bu 2 NESTED: use all boundary paths .IP \(bu 2 OUTERMOST: use EXTERNAL and OUTERMOST boundary paths .IP \(bu 2 IGNORE: ignore all paths except EXTERNAL boundary paths .UNINDENT .sp Yields paths in order of EXTERNAL, OUTERMOST and DEFAULT. .UNINDENT .INDENT 7.0 .TP .B add_polyline_path(path_vertices: Iterable[tuple[float, \&...]], is_closed: bool = True, flags: int = 1) -> PolylinePath Create and add a new \fI\%PolylinePath\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpath_vertices\fP – iterable of polyline vertices as (x, y) or (x, y, bulge)\-tuples. .IP \(bu 2 \fBis_closed\fP – 1 for a closed polyline else 0 .IP \(bu 2 \fBflags\fP – external(1) or outermost(16) or default (0) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_edge_path(flags: int = 1) -> EdgePath Create and add a new \fI\%EdgePath\fP object. .INDENT 7.0 .TP .B Parameters \fBflags\fP – external(1) or outermost(16) or default (0) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B polyline_to_edge_paths(just_with_bulge=True) -> None Convert polyline paths including bulge values to line\- and arc edges. .INDENT 7.0 .TP .B Parameters \fBjust_with_bulge\fP – convert only polyline paths including bulge values if \fBTrue\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B edge_to_polyline_paths(distance: float, segments: int = 16) Convert all edge paths to simple polyline paths without bulges. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the center of the curve to the center of the line segment between two approximation points to determine if a segment should be subdivided. .IP \(bu 2 \fBsegments\fP – minimum segment count per curve .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B arc_edges_to_ellipse_edges() -> None Convert all arc edges to ellipse edges. .UNINDENT .INDENT 7.0 .TP .B ellipse_edges_to_spline_edges(num: int = 32) -> None Convert all ellipse edges to spline edges (approximation). .INDENT 7.0 .TP .B Parameters \fBnum\fP – count of control points for a \fBfull\fP ellipse, partial ellipses have proportional fewer control points but at least 3. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B spline_edges_to_line_edges(factor: int = 8) -> None Convert all spline edges to line edges (approximation). .INDENT 7.0 .TP .B Parameters \fBfactor\fP – count of approximation segments = count of control points x factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B all_to_spline_edges(num: int = 64) -> None Convert all bulge, arc and ellipse edges to spline edges (approximation). .INDENT 7.0 .TP .B Parameters \fBnum\fP – count of control points for a \fBfull\fP circle/ellipse, partial circles/ellipses have proportional fewer control points but at least 3. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B all_to_line_edges(num: int = 64, spline_factor: int = 8) -> None Convert all bulge, arc and ellipse edges to spline edges and approximate this splines by line edges. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBnum\fP – count of control points for a \fBfull\fP circle/ellipse, partial circles/ellipses have proportional fewer control points but at least 3. .IP \(bu 2 \fBspline_factor\fP – count of spline approximation segments = count of control points x spline_factor .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B clear() -> None Remove all boundary paths. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.BoundaryPathType .INDENT 7.0 .TP .B POLYLINE polyline path type .UNINDENT .INDENT 7.0 .TP .B EDGE edge path type .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.PolylinePath A polyline as hatch boundary path. .INDENT 7.0 .TP .B type Path type as \fI\%BoundaryPathType.POLYLINE\fP enum .UNINDENT .INDENT 7.0 .TP .B path_type_flags (bit coded flags) .TS center; |l|l|. _ T{ 0 T} T{ default T} _ T{ 1 T} T{ external T} _ T{ 2 T} T{ polyline, will be set by \fIezdxf\fP T} _ T{ 16 T} T{ outermost T} _ .TE .sp My interpretation of the \fI\%path_type_flags\fP, see also \fI\%Tutorial for Hatch\fP: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 external: path is part of the hatch outer border .IP \(bu 2 outermost: path is completely inside of one or more external paths .IP \(bu 2 default: path is completely inside of one or more outermost paths .UNINDENT .UNINDENT .UNINDENT .sp If there are troubles with AutoCAD, maybe the hatch entity has the \fBHatch.dxf.pixel_size\fP attribute set \- delete it \fBdel hatch.dxf.pixel_size\fP and maybe the problem is solved. \fIEzdxf\fP does not use the \fBHatch.dxf.pixel_size\fP attribute, but it can occur in DXF files created by other applications. .UNINDENT .INDENT 7.0 .TP .B is_closed \fBTrue\fP if polyline path is closed. .UNINDENT .INDENT 7.0 .TP .B vertices List of path vertices as (x, y, bulge)\-tuples. (read/write) .UNINDENT .INDENT 7.0 .TP .B source_boundary_objects List of handles of the associated DXF entities for associative hatches. There is no support for associative hatches by \fIezdxf\fP, you have to do it all by yourself. (read/write) .UNINDENT .INDENT 7.0 .TP .B set_vertices(vertices: Iterable[Sequence[float]], is_closed: bool = True) -> None Set new \fIvertices\fP as new polyline path, a vertex has to be a (x, y) or a (x, y, bulge)\-tuple. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Removes all vertices and all handles to associated DXF objects (\fI\%source_boundary_objects\fP). .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.EdgePath Boundary path build by edges. There are four different edge types: \fI\%LineEdge\fP, \fI\%ArcEdge\fP, \fI\%EllipseEdge\fP of \fI\%SplineEdge\fP\&. Make sure there are no gaps between edges and the edge path must be closed to be recognized as path. AutoCAD is very picky in this regard. \fIEzdxf\fP performs no checks on gaps between the edges and does not prevent creating open loops. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fI\%ArcEdge\fP and \fI\%EllipseEdge\fP are ALWAYS represented in counter\-clockwise orientation, even if an clockwise oriented edge is required to build a closed loop. To add a clockwise oriented curve swap start\- and end angles and set the \fIccw\fP flag to \fIFalse\fP and \fIezdxf\fP will export a correct clockwise orientated curve. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B type Path type as \fI\%BoundaryPathType.EDGE\fP enum .UNINDENT .INDENT 7.0 .TP .B path_type_flags (bit coded flags) .TS center; |l|l|. _ T{ 0 T} T{ default T} _ T{ 1 T} T{ external T} _ T{ 16 T} T{ outermost T} _ .TE .sp see \fI\%PolylinePath.path_type_flags\fP .UNINDENT .INDENT 7.0 .TP .B edges List of boundary edges of type \fI\%LineEdge\fP, \fI\%ArcEdge\fP, \fI\%EllipseEdge\fP of \fI\%SplineEdge\fP .UNINDENT .INDENT 7.0 .TP .B source_boundary_objects Required for associative hatches, list of handles to the associated DXF entities. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Delete all edges. .UNINDENT .INDENT 7.0 .TP .B add_line(start: \fI\%UVec\fP, end: \fI\%UVec\fP) -> LineEdge Add a \fI\%LineEdge\fP from \fIstart\fP to \fIend\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart\fP – start point of line, (x, y)\-tuple .IP \(bu 2 \fBend\fP – end point of line, (x, y)\-tuple .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_arc(center: \fI\%UVec\fP, radius: float = 1.0, start_angle: float = 0.0, end_angle: float = 360.0, ccw: bool = True) -> ArcEdge Add an \fI\%ArcEdge\fP\&. .sp \fBAdding Clockwise Oriented Arcs:\fP .sp Clockwise oriented \fI\%ArcEdge\fP objects are sometimes necessary to build closed loops, but the \fI\%ArcEdge\fP objects are always represented in counter\-clockwise orientation. To add a clockwise oriented \fI\%ArcEdge\fP you have to swap the start\- and end angle and set the \fIccw\fP flag to \fBFalse\fP, e.g. to add a clockwise oriented \fI\%ArcEdge\fP from 180 to 90 degree, add the \fI\%ArcEdge\fP in counter\-clockwise orientation with swapped angles: .INDENT 7.0 .INDENT 3.5 .sp .EX edge_path.add_arc(center, radius, start_angle=90, end_angle=180, ccw=False) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of arc, (x, y)\-tuple .IP \(bu 2 \fBradius\fP – radius of circle .IP \(bu 2 \fBstart_angle\fP – start angle of arc in degrees (\fIend_angle\fP for a clockwise oriented arc) .IP \(bu 2 \fBend_angle\fP – end angle of arc in degrees (\fIstart_angle\fP for a clockwise oriented arc) .IP \(bu 2 \fBccw\fP – \fBTrue\fP for counter\-clockwise \fBFalse\fP for clockwise orientation .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_ellipse(center: \fI\%UVec\fP, major_axis: \fI\%UVec\fP = (1.0, 0.0), ratio: float = 1.0, start_angle: float = 0.0, end_angle: float = 360.0, ccw: bool = True) -> EllipseEdge Add an \fI\%EllipseEdge\fP\&. .sp \fBAdding Clockwise Oriented Ellipses:\fP .sp Clockwise oriented \fI\%EllipseEdge\fP objects are sometimes necessary to build closed loops, but the \fI\%EllipseEdge\fP objects are always represented in counter\-clockwise orientation. To add a clockwise oriented \fI\%EllipseEdge\fP you have to swap the start\- and end angle and set the \fIccw\fP flag to \fBFalse\fP, e.g. to add a clockwise oriented \fI\%EllipseEdge\fP from 180 to 90 degree, add the \fI\%EllipseEdge\fP in counter\-clockwise orientation with swapped angles: .INDENT 7.0 .INDENT 3.5 .sp .EX edge_path.add_ellipse(center, major_axis, ratio, start_angle=90, end_angle=180, ccw=False) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of ellipse, (x, y)\-tuple .IP \(bu 2 \fBmajor_axis\fP – vector of major axis as (x, y)\-tuple .IP \(bu 2 \fBratio\fP – ratio of minor axis to major axis as float .IP \(bu 2 \fBstart_angle\fP – start angle of ellipse in degrees (\fIend_angle\fP for a clockwise oriented ellipse) .IP \(bu 2 \fBend_angle\fP – end angle of ellipse in degrees (\fIstart_angle\fP for a clockwise oriented ellipse) .IP \(bu 2 \fBccw\fP – \fBTrue\fP for counter\-clockwise \fBFalse\fP for clockwise orientation .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_spline(fit_points: Iterable[\fI\%UVec\fP] | None = None, control_points: Iterable[\fI\%UVec\fP] | None = None, knot_values: Iterable[float] | None = None, weights: Iterable[float] | None = None, degree: int = 3, periodic: int = 0, start_tangent: \fI\%UVec\fP | None = None, end_tangent: \fI\%UVec\fP | None = None) -> SplineEdge Add a \fI\%SplineEdge\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – points through which the spline must go, at least 3 fit points are required. list of (x, y)\-tuples .IP \(bu 2 \fBcontrol_points\fP – affects the shape of the spline, mandatory and AutoCAD crashes on invalid data. list of (x, y)\-tuples .IP \(bu 2 \fBknot_values\fP – (knot vector) mandatory and AutoCAD crashes on invalid data. list of floats; \fIezdxf\fP provides two tool functions to calculate valid knot values: \fI\%ezdxf.math.uniform_knot_vector()\fP, \fI\%ezdxf.math.open_uniform_knot_vector()\fP (default if \fBNone\fP) .IP \(bu 2 \fBweights\fP – weight of control point, not mandatory, list of floats. .IP \(bu 2 \fBdegree\fP – degree of spline (int) .IP \(bu 2 \fBperiodic\fP – 1 for periodic spline, 0 for none periodic spline .IP \(bu 2 \fBstart_tangent\fP – start_tangent as 2d vector, optional .IP \(bu 2 \fBend_tangent\fP – end_tangent as 2d vector, optional .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 Unlike for the spline entity AutoCAD does not calculate the necessary \fIknot_values\fP for the spline edge itself. On the contrary, if the \fIknot_values\fP in the spline edge are missing or invalid AutoCAD \fBcrashes\fP\&. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.EdgeType .INDENT 7.0 .TP .B LINE .UNINDENT .INDENT 7.0 .TP .B ARC .UNINDENT .INDENT 7.0 .TP .B ELLIPSE .UNINDENT .INDENT 7.0 .TP .B SPLINE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.LineEdge Straight boundary edge. .INDENT 7.0 .TP .B type Edge type as \fI\%EdgeType.LINE\fP enum .UNINDENT .INDENT 7.0 .TP .B start Start point as (x, y)\-tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B end End point as (x, y)\-tuple. (read/write) .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.ArcEdge Arc as boundary edge in counter\-clockwise orientation, see \fI\%EdgePath.add_arc()\fP\&. .INDENT 7.0 .TP .B type Edge type as \fI\%EdgeType.ARC\fP enum .UNINDENT .INDENT 7.0 .TP .B center Center point of arc as (x, y)\-tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B radius Arc radius as float. (read/write) .UNINDENT .INDENT 7.0 .TP .B start_angle Arc start angle in counter\-clockwise orientation in degrees. (read/write) .UNINDENT .INDENT 7.0 .TP .B end_angle Arc end angle in counter\-clockwise orientation in degrees. (read/write) .UNINDENT .INDENT 7.0 .TP .B ccw \fBTrue\fP for counter clockwise arc else \fBFalse\fP\&. (read/write) .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.EllipseEdge Elliptic arc as boundary edge in counter\-clockwise orientation, see \fI\%EdgePath.add_ellipse()\fP\&. .INDENT 7.0 .TP .B type Edge type as \fI\%EdgeType.ELLIPSE\fP enum .UNINDENT .INDENT 7.0 .TP .B major_axis_vector Ellipse major axis vector as (x, y)\-tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B minor_axis_length Ellipse minor axis length as float. (read/write) .UNINDENT .INDENT 7.0 .TP .B radius Ellipse radius as float. (read/write) .UNINDENT .INDENT 7.0 .TP .B start_angle Ellipse start angle in counter\-clockwise orientation in degrees. (read/write) .UNINDENT .INDENT 7.0 .TP .B end_angle Ellipse end angle in counter\-clockwise orientation in degrees. (read/write) .UNINDENT .INDENT 7.0 .TP .B ccw \fBTrue\fP for counter clockwise ellipse else \fBFalse\fP\&. (read/write) .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.SplineEdge Spline as boundary edge. .INDENT 7.0 .TP .B type Edge type as \fI\%EdgeType.SPLINE\fP enum .UNINDENT .INDENT 7.0 .TP .B degree Spline degree as int. (read/write) .UNINDENT .INDENT 7.0 .TP .B rational 1 for rational spline else 0. (read/write) .UNINDENT .INDENT 7.0 .TP .B periodic 1 for periodic spline else 0. (read/write) .UNINDENT .INDENT 7.0 .TP .B knot_values List of knot values as floats. (read/write) .UNINDENT .INDENT 7.0 .TP .B control_points List of control points as (x, y)\-tuples. (read/write) .UNINDENT .INDENT 7.0 .TP .B fit_points List of fit points as (x, y)\-tuples. (read/write) .UNINDENT .INDENT 7.0 .TP .B weights List of weights (of control points) as floats. (read/write) .UNINDENT .INDENT 7.0 .TP .B start_tangent Spline start tangent (vector) as (x, y)\-tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B end_tangent Spline end tangent (vector) as (x, y)\-tuple. (read/write) .UNINDENT .UNINDENT .SS Hatch Pattern Definition Classes .INDENT 0.0 .TP .B class ezdxf.entities.Pattern .INDENT 7.0 .TP .B lines List of pattern definition lines (read/write). see \fI\%PatternLine\fP .UNINDENT .INDENT 7.0 .TP .B add_line(angle: float = 0, base_point: \fI\%UVec\fP = (0, 0), offset: \fI\%UVec\fP = (0, 0), dash_length_items: Iterable[float] | None = None) -> None Create a new pattern definition line and add the line to the \fI\%Pattern.lines\fP attribute. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Delete all pattern definition lines. .UNINDENT .INDENT 7.0 .TP .B scale(factor: float = 1, angle: float = 0) -> None Scale and rotate pattern. .sp Be careful, this changes the base pattern definition, maybe better use \fI\%Hatch.set_pattern_scale()\fP or \fI\%Hatch.set_pattern_angle()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfactor\fP – scaling factor .IP \(bu 2 \fBangle\fP – rotation angle in degrees .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.PatternLine Represents a pattern definition line, use factory function \fI\%Pattern.add_line()\fP to create new pattern definition lines. .INDENT 7.0 .TP .B angle Line angle in degrees. (read/write) .UNINDENT .INDENT 7.0 .TP .B base_point Base point as (x, y)\-tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B offset Offset as (x, y)\-tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B dash_length_items List of dash length items (item > 0 is line, < 0 is gap, 0.0 = dot). (read/write) .UNINDENT .UNINDENT .SS Hatch Gradient Fill Class .INDENT 0.0 .TP .B class ezdxf.entities.Gradient .INDENT 7.0 .TP .B color1 First rgb color as (r, g, b)\-tuple, rgb values in range 0 to 255. (read/write) .UNINDENT .INDENT 7.0 .TP .B color2 Second rgb color as (r, g, b)\-tuple, rgb values in range 0 to 255. (read/write) .UNINDENT .INDENT 7.0 .TP .B one_color If \fI\%one_color\fP is 1 \- the hatch is filled with a smooth transition between \fI\%color1\fP and a specified \fI\%tint\fP of \fI\%color1\fP\&. (read/write) .UNINDENT .INDENT 7.0 .TP .B rotation Gradient rotation in degrees. (read/write) .UNINDENT .INDENT 7.0 .TP .B centered Specifies a symmetrical gradient configuration. If this option is not selected, the gradient fill is shifted up and to the left, creating the illusion of a light source to the left of the object. (read/write) .UNINDENT .INDENT 7.0 .TP .B tint Specifies the tint (\fI\%color1\fP mixed with white) of a color to be used for a gradient fill of one color. (read/write) .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Hatch Pattern Definition\fP .UNINDENT .UNINDENT .SS Helix .sp The HELIX entity (\fI\%DXF Reference\fP). .sp The helix curve is represented by a cubic B\-spline curve, therefore the HELIX entity is also derived from the SPLINE entity. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Wikipedia\fP article about the helix shape .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Spline\fP T} _ T{ DXF type T} T{ \fB\(aqHELIX\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_helix()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Helix All points in \fI\%WCS\fP as (x, y, z) tuples .INDENT 7.0 .TP .B dxf.axis_base_point The base point of the helix axis (Vec3). .UNINDENT .INDENT 7.0 .TP .B dxf.start_point The starting point of the helix curve (Vec3). This also defines the base radius as the distance from the start point to the axis base point. .UNINDENT .INDENT 7.0 .TP .B dxf.axis_vector Defines the direction of the helix axis (Vec3). .UNINDENT .INDENT 7.0 .TP .B dxf.radius Defines the top radius of the helix (float). .UNINDENT .INDENT 7.0 .TP .B dxf.turn_height Defines the pitch (height if one helix turn) of the helix (float). .UNINDENT .INDENT 7.0 .TP .B dxf.turns The count of helix turns (float). .UNINDENT .INDENT 7.0 .TP .B dxf.handedness Helix orientation (int). .TS center; |l|l|. _ T{ 0 T} T{ clock wise (left handed) T} _ T{ 1 T} T{ counter clockwise (right handed) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.constrain .TS center; |l|l|. _ T{ 0 T} T{ constrain turn height (pitch) T} _ T{ 1 T} T{ constrain count of turns T} _ T{ 2 T} T{ constrain total height T} _ .TE .UNINDENT .UNINDENT .SS Image .sp The IMAGE entity (\fI\%DXF Reference\fP) represents a raster image, the image file itself is not embedded into the DXF file, it is always a separated file. The IMAGE entity is like a block reference, it can be used to add the image multiple times at different locations with different scale and rotation angles. Every IMAGE entity requires an image definition, see entity \fI\%ImageDef\fP\&. \fIEzdxf\fP creates only images in the xy\-plan, it’s possible to place images in 3D space, therefore the \fI\%Image.dxf.u_pixel\fP and the \fI\%Image.dxf.v_pixel\fP vectors has to be set accordingly. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqIMAGE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_image()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Image .INDENT 7.0 .TP .B dxf.insert Insertion point, lower left corner of the image (3D Point in \fI\%WCS\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.u_pixel U\-vector of a single pixel as (x, y, z) tuple. This vector points along the visual bottom of the image, starting at the insertion point. .UNINDENT .INDENT 7.0 .TP .B dxf.v_pixel V\-vector of a single pixel as (x, y, z) tuple. This vector points along the visual left side of the image, starting at the insertion point. .UNINDENT .INDENT 7.0 .TP .B dxf.image_size Image size in pixels as (x, y) tuple .UNINDENT .INDENT 7.0 .TP .B dxf.image_def_handle Handle to the image definition entity, see \fI\%ImageDef\fP .UNINDENT .INDENT 7.0 .TP .B dxf.flags .TS center; |l|l|l|. _ T{ \fBImage.SHOW_IMAGE\fP T} T{ 1 T} T{ Show image T} _ T{ \fBImage.SHOW_WHEN_NOT_ALIGNED\fP T} T{ 2 T} T{ Show image when not aligned with screen T} _ T{ \fBImage.USE_CLIPPING_BOUNDARY\fP T} T{ 4 T} T{ Use clipping boundary T} _ T{ \fBImage.USE_TRANSPARENCY\fP T} T{ 8 T} T{ Transparency is on T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.clipping Clipping state: .TS center; |l|l|. _ T{ 0 T} T{ clipping off T} _ T{ 1 T} T{ clipping on T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.brightness Brightness value in the range [0, 100], default is 50 .UNINDENT .INDENT 7.0 .TP .B dxf.contrast Contrast value in the range [0, 100], default is 50 .UNINDENT .INDENT 7.0 .TP .B dxf.fade Fade value in the range [0, 100], default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.clipping_boundary_type .TS center; |l|l|. _ T{ 1 T} T{ Rectangular T} _ T{ 2 T} T{ Polygonal T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.count_boundary_points Number of clip boundary vertices, this attribute is maintained by \fIezdxf\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.clip_mode .TS center; |l|l|. _ T{ 0 T} T{ Outside T} _ T{ 1 T} T{ Inside T} _ .TE .sp requires DXF R2010 or newer .UNINDENT .INDENT 7.0 .TP .B boundary_path A list of vertices as pixel coordinates, Two vertices describe a rectangle, lower left corner is (\-0.5, \-0.5) and upper right corner is (ImageSizeX\-0.5, ImageSizeY\-0.5), more than two vertices is a polygon as clipping path. All vertices as pixel coordinates. (read/write) .UNINDENT .INDENT 7.0 .TP .B image_def Returns the associated IMAGEDEF entity, see \fI\%ImageDef\fP\&. .UNINDENT .INDENT 7.0 .TP .B reset_boundary_path() -> None Reset boundary path to the default rectangle [(\-0.5, \-0.5), (ImageSizeX\-0.5, ImageSizeY\-0.5)]. .UNINDENT .INDENT 7.0 .TP .B set_boundary_path(vertices: Iterable[\fI\%UVec\fP]) -> None Set boundary path to \fIvertices\fP\&. Two vertices describe a rectangle (lower left and upper right corner), more than two vertices is a polygon as clipping path. .UNINDENT .INDENT 7.0 .TP .B boundary_path_wcs() -> list[\fI\%Vec3\fP] Returns the boundary/clipping path in WCS coordinates. .sp It’s recommended to acquire the clipping path as \fI\%Path\fP object by the \fI\%make_path()\fP function: .INDENT 7.0 .INDENT 3.5 .sp .EX from ezdxf.path import make_path image = ... # get image entity clipping_path = make_path(image) .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> ImageBase Transform IMAGE entity by transformation matrix \fIm\fP inplace. .UNINDENT .UNINDENT .SS Leader .sp The LEADER entity (\fI\%DXF Reference\fP) represents a pointer line, made up of one or more vertices (or spline fit points) and an arrowhead. The label or other content to which the \fI\%Leader\fP is attached is stored as a separate entity, and is not part of the \fI\%Leader\fP itself. .sp The LEADER entity uses parts of the styling infrastructure of the DIMENSION entity. .sp By default a \fI\%Leader\fP without any annotation is created. For creating more fancy leaders and annotations see the documentation provided by Autodesk or \fI\%Demystifying DXF: LEADER and MULTILEADER implementation notes\fP . .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqLEADER\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_leader()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Leader .INDENT 7.0 .TP .B dxf.dimstyle Name of \fBDimstyle\fP as string. .UNINDENT .INDENT 7.0 .TP .B dxf.has_arrowhead .TS center; |l|l|. _ T{ 0 T} T{ Disabled T} _ T{ 1 T} T{ Enabled T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.path_type Leader path type: .TS center; |l|l|. _ T{ 0 T} T{ Straight line segments T} _ T{ 1 T} T{ Spline T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.annotation_type .TS center; |l|l|. _ T{ 0 T} T{ Created with text annotation T} _ T{ 1 T} T{ Created with tolerance annotation T} _ T{ 2 T} T{ Created with block reference annotation T} _ T{ 3 T} T{ Created without any annotation (default) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.hookline_direction Hook line direction flag: .TS center; |l|l|. _ T{ 0 T} T{ Hookline (or end of tangent for a splined leader) is the opposite direction from the horizontal vector T} _ T{ 1 T} T{ Hookline (or end of tangent for a splined leader) is the same direction as horizontal vector (see \fBhas_hook_line\fP) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.has_hookline .TS center; |l|l|. _ T{ 0 T} T{ No hookline T} _ T{ 1 T} T{ Has a hookline T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_height Text annotation height in drawing units. .UNINDENT .INDENT 7.0 .TP .B dxf.text_width Text annotation width. .UNINDENT .INDENT 7.0 .TP .B dxf.block_color Color to use if leader’s DIMCLRD = BYBLOCK .UNINDENT .INDENT 7.0 .TP .B dxf.annotation_handle Hard reference (handle) to associated annotation (\fI\%MText\fP, \fBTolerance\fP, or \fI\%Insert\fP entity) .UNINDENT .INDENT 7.0 .TP .B dxf.normal_vector Extrusion vector? default is (0, 0, 1). .UNINDENT .INDENT 7.0 .TP .B \&.dxf.horizontal_direction \fIHorizontal\fP direction for leader, default is (1, 0, 0). .UNINDENT .INDENT 7.0 .TP .B dxf.leader_offset_block_ref Offset of last leader vertex from block reference insertion point, default is (0, 0, 0). .UNINDENT .INDENT 7.0 .TP .B dxf.leader_offset_annotation_placement Offset of last leader vertex from annotation placement point, default (0, 0, 0). .UNINDENT .INDENT 7.0 .TP .B vertices List of \fI\%Vec3\fP objects, representing the vertices of the leader (3D Point in \fI\%WCS\fP). .UNINDENT .INDENT 7.0 .TP .B set_vertices(vertices: Iterable[\fI\%UVec\fP]) Set vertices of the leader, vertices is an iterable of (x, y [,z]) tuples or \fI\%Vec3\fP\&. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%Leader\fP Transform LEADER entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterator[DXFGraphic] Yields the DXF primitives the LEADER entity is build up as virtual entities. .sp These entities are located at the original location, but are not stored in the entity database, have no handle and are not assigned to any layout. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: \fI\%BaseLayout\fP | None = None) -> \fI\%EntityQuery\fP Explode parts of the LEADER entity as DXF primitives into target layout, if target layout is \fBNone\fP, the target layout is the layout of the LEADER entity. This method destroys the source entity. .sp Returns an \fI\%EntityQuery\fP container referencing all DXF primitives. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for the created DXF primitives, \fBNone\fP for the same layout as the source entity. .UNINDENT .UNINDENT .UNINDENT .SS Line .sp The LINE entity (\fI\%DXF Reference\fP) is a 3D line defined by the DXF attributes \fBdxf.start\fP and \fBdxf.end\fP\&. The LINE entity has \fI\%WCS\fP coordinates. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Simple DXF Entities\fP, section \fI\%Line\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionRay\fP .IP \(bu 2 \fI\%ezdxf.math.ConstructionLine\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqLINE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_line()\fP T} _ T{ Inherited DXF Attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Line .INDENT 7.0 .TP .B dxf.start start point of line (2D/3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.end end point of line (2D/3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.thickness Line thickness in 3D space in direction \fBextrusion\fP, default value is 0. This value should not be confused with the \fI\%lineweight\fP value. .UNINDENT .INDENT 7.0 .TP .B dxf.extrusion extrusion vector, default value is (0, 0, 1) .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Line Transform the LINE entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> Line Optimized LINE translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis. .UNINDENT .UNINDENT .SS LWPolyline .sp The LWPOLYLINE entity (Lightweight POLYLINE, \fI\%DXF Reference\fP) is defined as a single graphic entity, which differs from the old\-style \fI\%Polyline\fP entity, which is defined as a group of sub\-entities. \fI\%LWPolyline\fP display faster (in AutoCAD) and consume less disk space, it is a planar element, therefore all points are located in the \fI\%OCS\fP as (x, y)\-tuples (\fI\%LWPolyline.dxf.elevation\fP is the z\-axis value). .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqLWPOLYLINE\(aq\fP T} _ T{ factory function T} T{ \fI\%add_lwpolyline()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp Bulge value .sp The bulge value is used to create arc shaped line segments for \fI\%Polyline\fP and \fI\%LWPolyline\fP entities. The arc starts at the vertex which includes the bulge value and ends at the following vertex. The bulge value defines the ratio of the arc sagitta (versine) to half line segment length, a bulge value of 1 defines a semicircle. .sp The sign of the bulge value defines the side of the bulge: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 positive value (> 0): bulge is right of line (counter clockwise) .IP \(bu 2 negative value (< 0): bulge is left of line (clockwise) .IP \(bu 2 0 = no bulge .UNINDENT .UNINDENT .UNINDENT [image] .sp Start\- and end width .sp The start width and end width values defines the width in drawing units for the following line segment. To use the default width value for a line segment set value to 0. .sp Width and bulge values at last point .sp The width and bulge values of the last point has only a meaning if the polyline is closed, and they apply to the last line segment from the last to the first point. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for LWPolyline\fP and \fI\%Bulge Related Functions\fP .UNINDENT .UNINDENT .SS User Defined Point Format Codes .INDENT 0.0 .INDENT 3.5 .TS center; |l|l|. _ T{ Code T} T{ Point Component T} _ T{ x T} T{ x\-coordinate T} _ T{ y T} T{ y\-coordinate T} _ T{ s T} T{ start width T} _ T{ e T} T{ end width T} _ T{ b T} T{ bulge value T} _ T{ v T} T{ (x, y [, z]) as tuple T} _ .TE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.LWPolyline .INDENT 7.0 .TP .B dxf.elevation \fI\%OCS\fP z\-axis value for all polyline points, default=0 .UNINDENT .INDENT 7.0 .TP .B dxf.flags Constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|l|. _ T{ dxf.flags T} T{ Value T} T{ Description T} _ T{ LWPOLYLINE_CLOSED T} T{ 1 T} T{ polyline is closed T} _ T{ LWPOLYLINE_PLINEGEN T} T{ 128 T} T{ linetype is generated across the points T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.const_width Constant line width (float), default value is 0. .UNINDENT .INDENT 7.0 .TP .B dxf.count Count of polyline points (read only), same as \fBlen(polyline)\fP .UNINDENT .INDENT 7.0 .TP .B property closed: bool Get/set closed state of polyline. A closed polyline has a connection segment from the last vertex to the first vertex. .UNINDENT .INDENT 7.0 .TP .B property is_closed: bool Get closed state of LWPOLYLINE. Compatibility interface to \fI\%Polyline\fP .UNINDENT .INDENT 7.0 .TP .B close(state: bool = True) -> None Set closed state of LWPOLYLINE. Compatibility interface to \fI\%Polyline\fP .UNINDENT .INDENT 7.0 .TP .B property has_arc: bool Returns \fBTrue\fP if LWPOLYLINE has an arc segment. .UNINDENT .INDENT 7.0 .TP .B property has_width: bool Returns \fBTrue\fP if LWPOLYLINE has any segment with width attributes or the DXF attribute const_width is not 0. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of polyline points. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index: int) -> Tuple[float, float, float, float, float] Returns point at position \fIindex\fP as (x, y, start_width, end_width, bulge) tuple. start_width, end_width and bulge is 0 if not present, supports extended slicing. Point format is fixed as “xyseb”. .sp All coordinates in \fI\%OCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B __setitem__(index: int, value: Sequence[float]) -> None Set point at position \fIindex\fP as (x, y, [start_width, [end_width, [bulge]]]) tuple. If start_width or end_width is 0 or left off the default width value is used. If the bulge value is left off, bulge is 0 by default (straight line). Does NOT support extend slicing. Point format is fixed as “xyseb”. .sp All coordinates in \fI\%OCS\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBindex\fP – point index .IP \(bu 2 \fBvalue\fP – point value as (x, y, [start_width, [end_width, [bulge]]]) tuple .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __delitem__(index: int) -> None Delete point at position \fIindex\fP, supports extended slicing. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[Tuple[float, float, float, float, float]] Returns iterable of tuples (x, y, start_width, end_width, bulge). .UNINDENT .INDENT 7.0 .TP .B vertices() -> Iterator[tuple[float, float]] Returns iterable of all polyline points as (x, y) tuples in \fI\%OCS\fP (\fI\%dxf.elevation\fP is the z\-axis value). .UNINDENT .INDENT 7.0 .TP .B vertices_in_wcs() -> Iterator[\fI\%Vec3\fP] Returns iterable of all polyline points as Vec3(x, y, z) in \fI\%WCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B append(point: Sequence[float], format: str = DEFAULT_FORMAT) -> None Append \fIpoint\fP to polyline, \fIformat\fP specifies a user defined point format. .sp All coordinates in \fI\%OCS\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – (x, y, [start_width, [end_width, [bulge]]]) tuple .IP \(bu 2 \fBformat\fP – format string, default is “xyseb”, see: \fI\%format codes\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append_points(points: Iterable[Sequence[float]], format: str = DEFAULT_FORMAT) -> None Append new \fIpoints\fP to polyline, \fIformat\fP specifies a user defined point format. .sp All coordinates in \fI\%OCS\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of point, point is (x, y, [start_width, [end_width, [bulge]]]) tuple .IP \(bu 2 \fBformat\fP – format string, default is “xyseb”, see: \fI\%format codes\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B insert(pos: int, point: Sequence[float], format: str = DEFAULT_FORMAT) -> None Insert new point in front of positions \fIpos\fP, \fIformat\fP specifies a user defined point format. .sp All coordinates in \fI\%OCS\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpos\fP – insert position .IP \(bu 2 \fBpoint\fP – point data .IP \(bu 2 \fBformat\fP – format string, default is “xyseb”, see: \fI\%format codes\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B clear() -> None Remove all points. .UNINDENT .INDENT 7.0 .TP .B get_points(format: str = DEFAULT_FORMAT) -> list[Sequence[float]] Returns all points as list of tuples, format specifies a user defined point format. .sp All points in \fI\%OCS\fP as (x, y) tuples (\fI\%dxf.elevation\fP is the z\-axis value). .INDENT 7.0 .TP .B Parameters \fBformat\fP – format string, default is “xyseb”, see \fI\%format codes\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_points(points: Iterable[Sequence[float]], format: str = DEFAULT_FORMAT) -> None Remove all points and append new \fIpoints\fP\&. .sp All coordinates in \fI\%OCS\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of point, point is (x, y, [start_width, [end_width, [bulge]]]) tuple .IP \(bu 2 \fBformat\fP – format string, default is “xyseb”, see \fI\%format codes\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B points(format: str = DEFAULT_FORMAT) -> Iterator[list[Sequence[float]]] Context manager for polyline points. Returns a standard Python list of points, according to the format string. .sp All coordinates in \fI\%OCS\fP\&. .INDENT 7.0 .TP .B Parameters \fBformat\fP – format string, see \fI\%format codes\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> LWPolyline Transform the LWPOLYLINE entity by transformation matrix \fIm\fP inplace. .sp A non\-uniform scaling is not supported if the entity contains circular arc segments (bulges). .INDENT 7.0 .TP .B Parameters \fBm\fP – transformation \fI\%Matrix44\fP .TP .B Raises \fBNonUniformScalingError\fP – for non\-uniform scaling of entity containing circular arc segments (bulges) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterator[\fI\%Line\fP | \fI\%Arc\fP] Yields the graphical representation of LWPOLYLINE as virtual DXF primitives (LINE or ARC). .sp These virtual entities are located at the original location, but are not stored in the entity database, have no handle and are not assigned to any layout. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: \fI\%BaseLayout\fP | None = None) -> \fI\%EntityQuery\fP Explode the LWPOLYLINE entity as DXF primitives (LINE or ARC) into the target layout, if the target layout is \fBNone\fP, the target layout is the layout of the source entity. This method destroys the source entity. .sp Returns an \fI\%EntityQuery\fP container referencing all DXF primitives. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for the DXF primitives, \fBNone\fP for same layout as the source entity. .UNINDENT .UNINDENT .UNINDENT .SS MLine .sp The MLINE entity (\fI\%DXF Reference\fP). .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqMLINE\(aq\fP T} _ T{ factory function T} T{ \fI\%add_mline()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.MLine .INDENT 7.0 .TP .B dxf.style_name \fI\%MLineStyle\fP name stored in \fBDrawing.mline_styles\fP dictionary, use \fI\%set_style()\fP to change the MLINESTYLE and update geometry accordingly. .UNINDENT .INDENT 7.0 .TP .B dxf.style_handle Handle of \fI\%MLineStyle\fP, use \fI\%set_style()\fP to change the MLINESTYLE and update geometry accordingly. .UNINDENT .INDENT 7.0 .TP .B dxf.scale_factor MLINE scaling factor, use method \fI\%set_scale_factor()\fP to change the scaling factor and update geometry accordingly. .UNINDENT .INDENT 7.0 .TP .B dxf.justification Justification defines the location of the MLINE in relation to the reference line, use method \fI\%set_justification()\fP to change the justification and update geometry accordingly. .sp Constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|. _ T{ dxf.justification T} T{ Value T} _ T{ MLINE_TOP T} T{ 0 T} _ T{ MLINE_ZERO T} T{ 1 T} _ T{ MLINE_BOTTOM T} T{ 2 T} _ T{ MLINE_RIGHT (alias) T} T{ 0 T} _ T{ MLINE_CENTER (alias) T} T{ 1 T} _ T{ MLINE_LEFT (alias) T} T{ 2 T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.flags Use method \fI\%close()\fP and the properties \fI\%start_caps\fP and \fI\%end_caps\fP to change these flags. .sp Constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|. _ T{ dxf.flags T} T{ Value T} _ T{ MLINE_HAS_VERTEX T} T{ 1 T} _ T{ MLINE_CLOSED T} T{ 2 T} _ T{ MLINE_SUPPRESS_START_CAPS T} T{ 4 T} _ T{ MLINE_SUPPRESS_END_CAPS T} T{ 8 T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.start_location Start location of the reference line. (read only) .UNINDENT .INDENT 7.0 .TP .B dxf.count Count of MLINE vertices. (read only) .UNINDENT .INDENT 7.0 .TP .B dxf.style_element_count Count of elements in \fI\%MLineStyle\fP definition. (read only) .UNINDENT .INDENT 7.0 .TP .B dxf.extrusion Normal vector of the entity plane, but MLINE is not an OCS entity, all vertices of the reference line are WCS! (read only) .UNINDENT .INDENT 7.0 .TP .B vertices MLINE vertices as \fI\%MLineVertex\fP objects, stored in a regular Python list. .UNINDENT .INDENT 7.0 .TP .B property style: MLineStyle | None Get associated MLINESTYLE. .UNINDENT .INDENT 7.0 .TP .B set_style(name: str) -> None Set MLINESTYLE by name and update geometry accordingly. The MLINESTYLE definition must exist. .UNINDENT .INDENT 7.0 .TP .B set_scale_factor(value: float) -> None Set the scale factor and update geometry accordingly. .UNINDENT .INDENT 7.0 .TP .B set_justification(value: int) -> None Set MLINE justification and update geometry accordingly. See \fI\%dxf.justification\fP for valid settings. .UNINDENT .INDENT 7.0 .TP .B property is_closed: bool Returns \fBTrue\fP if MLINE is closed. Compatibility interface to \fI\%Polyline\fP .UNINDENT .INDENT 7.0 .TP .B close(state: bool = True) -> None Get/set closed state of MLINE and update geometry accordingly. Compatibility interface to \fI\%Polyline\fP .UNINDENT .INDENT 7.0 .TP .B property start_caps: bool Get/Set start caps state. \fBTrue\fP to enable start caps and \fBFalse\fP tu suppress start caps. .UNINDENT .INDENT 7.0 .TP .B property end_caps: bool Get/Set end caps state. \fBTrue\fP to enable end caps and \fBFalse\fP tu suppress start caps. .UNINDENT .INDENT 7.0 .TP .B __len__() Count of MLINE vertices. .UNINDENT .INDENT 7.0 .TP .B start_location() -> \fI\%Vec3\fP Returns the start location of the reference line. Callback function for \fI\%dxf.start_location\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_locations() -> list[\fI\%Vec3\fP] Returns the vertices of the reference line. .UNINDENT .INDENT 7.0 .TP .B extend(vertices: Iterable[\fI\%UVec\fP]) -> None Append multiple vertices to the reference line. .sp It is possible to work with 3D vertices, but all vertices have to be in the same plane and the normal vector of this plan is stored as extrusion vector in the MLINE entity. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Remove all MLINE vertices. .UNINDENT .INDENT 7.0 .TP .B update_geometry() -> None Regenerate the MLINE geometry based on current settings. .UNINDENT .INDENT 7.0 .TP .B generate_geometry(vertices: list[\fI\%Vec3\fP]) -> None Regenerate the MLINE geometry for new reference line defined by \fIvertices\fP\&. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%DXFGraphic\fP Transform MLINE entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterator[DXFGraphic] Yields virtual DXF primitives of the MLINE entity as LINE, ARC and HATCH entities. .sp These entities are located at the original positions, but are not stored in the entity database, have no handle and are not assigned to any layout. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: \fI\%BaseLayout\fP | None = None) -> \fI\%EntityQuery\fP Explode the MLINE entity as LINE, ARC and HATCH entities into target layout, if target layout is \fBNone\fP, the target layout is the layout of the MLINE. This method destroys the source entity. .sp Returns an \fI\%EntityQuery\fP container referencing all DXF primitives. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for DXF primitives, \fBNone\fP for same layout as source entity. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.MLineVertex .INDENT 7.0 .TP .B location Reference line vertex location. .UNINDENT .INDENT 7.0 .TP .B line_direction Reference line direction. .UNINDENT .INDENT 7.0 .TP .B miter_direction .UNINDENT .INDENT 7.0 .TP .B line_params The line parameterization is a list of float values. The list may contain zero or more items. .sp The first value (miter\-offset) is the distance from the vertex \fI\%location\fP along the \fI\%miter_direction\fP vector to the point where the line element’s path intersects the miter vector. .sp The next value (line\-start\-offset) is the distance along the \fI\%line_direction\fP from the miter/line path intersection point to the actual start of the line element. .sp The next value (dash\-length) is the distance from the start of the line element (dash) to the first break (gap) in the line element. The successive values continue to list the start and stop points of the line element in this segment of the mline. .UNINDENT .INDENT 7.0 .TP .B fill_params The fill parameterization is also a list of float values. Similar to the line parameterization, it describes the parameterization of the fill area for this mline segment. The values are interpreted identically to the line parameters and when taken as a whole for all line elements in the mline segment, they define the boundary of the fill area for the mline segment. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.MLineStyle The \fI\%MLineStyle\fP stores the style properties for the MLINE entity. .INDENT 7.0 .TP .B dxf.name .UNINDENT .INDENT 7.0 .TP .B dxf.description .UNINDENT .INDENT 7.0 .TP .B dxf.flags .UNINDENT .INDENT 7.0 .TP .B dxf.fill_color \fI\%AutoCAD Color Index (ACI)\fP value of the fill color .UNINDENT .INDENT 7.0 .TP .B dxf.start_angle .UNINDENT .INDENT 7.0 .TP .B dxf.end_angle .UNINDENT .INDENT 7.0 .TP .B elements \fI\%MLineStyleElements\fP object .UNINDENT .INDENT 7.0 .TP .B update_all() Update all MLINE entities using this MLINESTYLE. .sp The update is required if elements were added or removed or the offset of any element was changed. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.mline.MLineStyleElements .INDENT 7.0 .TP .B elements List of \fI\%MLineStyleElement\fP objects, one for each line element. .UNINDENT .INDENT 7.0 .TP .B MLineStyleElements.__len__() .UNINDENT .INDENT 7.0 .TP .B MLineStyleElements.__getitem__(item) .UNINDENT .INDENT 7.0 .TP .B MLineStyleElements.append(offset: float, color: int = 0, linetype: str = \(aqBYLAYER\(aq) -> None Append a new line element. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBoffset\fP – normal offset from the reference line: if justification is \fBMLINE_ZERO\fP, positive values are above and negative values are below the reference line. .IP \(bu 2 \fBcolor\fP – \fI\%AutoCAD Color Index (ACI)\fP value .IP \(bu 2 \fBlinetype\fP – linetype name .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.mline.MLineStyleElement Named tuple to store properties of a line element. .INDENT 7.0 .TP .B offset Normal offset from the reference line: if justification is \fBMLINE_ZERO\fP, positive values are above and negative values are below the reference line. .UNINDENT .INDENT 7.0 .TP .B color \fI\%AutoCAD Color Index (ACI)\fP value .UNINDENT .INDENT 7.0 .TP .B linetype Linetype name .UNINDENT .UNINDENT .SS Mesh .sp The MESH entity (\fI\%DXF Reference\fP) is a 3D surface in \fI\%WCS\fP build up from vertices and faces similar to the \fI\%Polyface\fP entity. .sp All vertices in \fI\%WCS\fP as (x, y, z) tuples .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqMESH\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_mesh()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Mesh\fP and helper classes: \fI\%MeshBuilder\fP, \fI\%MeshVertexMerger\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Mesh .INDENT 7.0 .TP .B dxf.version .UNINDENT .INDENT 7.0 .TP .B dxf.blend_crease 0 = off, 1 = on .UNINDENT .INDENT 7.0 .TP .B dxf.subdivision_levels 0 for no smoothing else integer greater than 0. .UNINDENT .INDENT 7.0 .TP .B vertices Vertices as list like \fI\%VertexArray\fP\&. (read/write) .UNINDENT .INDENT 7.0 .TP .B edges Edges as list like \fI\%TagArray\fP\&. (read/write) .UNINDENT .INDENT 7.0 .TP .B faces Faces as list like \fI\%TagList\fP\&. (read/write) .UNINDENT .INDENT 7.0 .TP .B creases Creases as \fBarray.array\fP\&. (read/write) .UNINDENT .INDENT 7.0 .TP .B edit_data() -> Iterator[MeshData] Context manager for various mesh data, returns a \fI\%MeshData\fP instance. .sp Despite that vertices, edge and faces are accessible as packed data types, the usage of \fI\%MeshData\fP by context manager \fI\%edit_data()\fP is still recommended. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Mesh Transform the MESH entity by transformation matrix \fIm\fP inplace. .UNINDENT .UNINDENT .SS MeshData .INDENT 0.0 .TP .B class ezdxf.entities.MeshData .INDENT 7.0 .TP .B vertices A standard Python list with (x, y, z) tuples (read/write) .UNINDENT .INDENT 7.0 .TP .B faces A standard Python list with (v1, v2, v3,…) tuples (read/write) .sp Each face consist of a list of vertex indices (= index in \fI\%vertices\fP). .UNINDENT .INDENT 7.0 .TP .B edges A Python list with (v1, v2) tuples (read/write). This list represents the edges to which the \fI\%edge_crease_values\fP values will be applied. Each edge consist of exact two vertex indices (= index in \fI\%vertices\fP). .UNINDENT .INDENT 7.0 .TP .B edge_crease_values A Python list of float values, one value for each edge. (read/write) .UNINDENT .INDENT 7.0 .TP .B add_face(vertices: Iterable[\fI\%UVec\fP]) -> Sequence[int] Add a face by coordinates, vertices is a list of \fB(x, y, z)\fP tuples. .UNINDENT .INDENT 7.0 .TP .B add_edge_crease(v1: int, v2: int, crease: float) Add an edge crease value, the edge is defined by the vertex indices \fIv1\fP and \fIv2\fP\&. The crease value defines the amount of subdivision that will be applied to this edge. A crease value of the subdivision level prevents the edge from deformation and a value of 0.0 means no protection from subdividing. .UNINDENT .INDENT 7.0 .TP .B optimize(precision: int = 6) Try to reduce vertex count by merging near vertices. \fIprecision\fP defines the decimal places for coordinate be equal to merge two vertices. .UNINDENT .UNINDENT .SS MPolygon .sp The MPOLYGON entity is not a core DXF entity and is not supported by all CAD applications and DXF libraries. The \fI\%MPolygon\fP class is very similar to the \fI\%Hatch\fP class with small differences in the supported features and DXF attributes. .sp The boundary paths of the MPOLYGON are visible and use the graphical DXF attributes of the main entity like \fBdxf.color\fP, \fBdxf.linetype\fP and so on. The solid filling is only visible if the attribute \fBdxf.solid_fill\fP is 1, the color of the solid fill is defined by \fBdxf.fill_color\fP as \fI\%AutoCAD Color Index (ACI)\fP\&. The MPOLYGON supports \fI\%ezdxf.entities.Gradient\fP settings like HATCH for DXF R2004 and newer. This feature is used by method \fI\%MPolygon.set_solid_fill()\fP to set a solid RGB fill color as linear gradient, this disables pattern fill automatically. The MPOLYGON does not support associated source path entities, because the MPOLYGON also represents the boundary paths as visible graphical objects. Hatch patterns are supported, but the hatch style tag is not supported, the default hatch style is \fBezdxf.const.HATCH_STYLE_NESTED\fP and the style flags of the boundary paths are ignored. Background color for pattern fillings is supported, set background color by property \fI\%MPolygon.bgcolor\fP as RGB tuple. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Background RGB fill color for solid fill and pattern fill is set differently! .UNINDENT .UNINDENT .sp Autodesk products do support polyline paths including bulges. An example for edge paths as boundary paths is not available or edge paths are not supported. \fIEzdxf\fP does \fBnot\fP export MPOLYGON entities including edge paths! The \fI\%BoundaryPaths.edge_to_polyline_paths()\fP method converts all edge paths to simple polyline paths with approximated curves, this conversion has to be done explicit. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For more information see the \fI\%ezdxf.entities.Hatch\fP documentation. .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqMPOLYGON\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_mpolygon()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.MPolygon .INDENT 7.0 .TP .B dxf.pattern_name Pattern name as string .UNINDENT .INDENT 7.0 .TP .B dxf.solid_fill .TS center; |l|l|. _ T{ 1 T} T{ solid fill, better use: \fI\%MPolygon.set_solid_fill()\fP T} _ T{ 0 T} T{ pattern fill, better use: \fI\%MPolygon.set_pattern_fill()\fP T} _ .TE .sp (search AutoCAD help for more information) .UNINDENT .INDENT 7.0 .TP .B dxf.pattern_type .TS center; |l|l|. _ T{ 0 T} T{ user T} _ T{ 1 T} T{ predefined T} _ T{ 2 T} T{ custom T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.pattern_angle Actual pattern angle in degrees (float). Changing this value does not rotate the pattern, use \fI\%set_pattern_angle()\fP for this task. .UNINDENT .INDENT 7.0 .TP .B dxf.pattern_scale Actual pattern scaling factor (float). Changing this value does not scale the pattern use \fI\%set_pattern_scale()\fP for this task. .UNINDENT .INDENT 7.0 .TP .B dxf.pattern_double 1 = double pattern size else 0. (int) .UNINDENT .INDENT 7.0 .TP .B dxf.elevation Z value represents the elevation height of the \fI\%OCS\fP\&. (float) .UNINDENT .INDENT 7.0 .TP .B paths \fI\%BoundaryPaths\fP object. .UNINDENT .INDENT 7.0 .TP .B pattern \fI\%Pattern\fP object. .UNINDENT .INDENT 7.0 .TP .B gradient \fI\%Gradient\fP object. .UNINDENT .INDENT 7.0 .TP .B property has_solid_fill: bool \fBTrue\fP if entity has a solid fill. (read only) .UNINDENT .INDENT 7.0 .TP .B property has_pattern_fill: bool \fBTrue\fP if entity has a pattern fill. (read only) .UNINDENT .INDENT 7.0 .TP .B property has_gradient_data: bool \fBTrue\fP if entity has a gradient fill. A hatch with gradient fill has also a solid fill. (read only) .UNINDENT .INDENT 7.0 .TP .B property bgcolor: \fI\%RGB\fP | None Set pattern fill background color as (r, g, b)\-tuple, rgb values in the range [0, 255] (read/write/del) .sp usage: .INDENT 7.0 .INDENT 3.5 .sp .EX r, g, b = entity.bgcolor # get pattern fill background color entity.bgcolor = (10, 20, 30) # set pattern fill background color del entity.bgcolor # delete pattern fill background color .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_definition(lines: Sequence, factor: float = 1, angle: float = 0) -> None Setup pattern definition by a list of definition lines and the definition line is a 4\-tuple (angle, base_point, offset, dash_length_items). The pattern definition should be designed for a pattern scale factor of 1 and a pattern rotation angle of 0. .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 angle: line angle in degrees .IP \(bu 2 base\-point: (x, y) tuple .IP \(bu 2 offset: (dx, dy) tuple .IP \(bu 2 dash_length_items: list of dash items (item > 0 is a line, item < 0 is a gap and item == 0.0 is a point) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlines\fP – list of definition lines .IP \(bu 2 \fBfactor\fP – pattern scale factor .IP \(bu 2 \fBangle\fP – rotation angle in degrees .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_scale(scale: float) -> None Sets the pattern scale factor and scales the pattern definition. .sp The method always starts from the original base scale, the \fBset_pattern_scale(1)\fP call resets the pattern scale to the original appearance as defined by the pattern designer, but only if the pattern attribute \fI\%dxf.pattern_scale\fP represents the actual scale, it cannot restore the original pattern scale from the pattern definition itself. .INDENT 7.0 .TP .B Parameters \fBscale\fP – pattern scale factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_angle(angle: float) -> None Sets the pattern rotation angle and rotates the pattern definition. .sp The method always starts from the original base rotation of 0, the \fBset_pattern_angle(0)\fP call resets the pattern rotation angle to the original appearance as defined by the pattern designer, but only if the pattern attribute \fI\%dxf.pattern_angle\fP represents the actual pattern rotation, it cannot restore the original rotation angle from the pattern definition itself. .INDENT 7.0 .TP .B Parameters \fBangle\fP – pattern rotation angle in degrees .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_solid_fill(color: int = 7, style: int = 1, rgb: \fI\%RGB\fP | None = None) Set \fI\%MPolygon\fP to solid fill mode and removes all gradient and pattern fill related data. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – \fI\%AutoCAD Color Index (ACI)\fP, (0 = BYBLOCK; 256 = BYLAYER) .IP \(bu 2 \fBstyle\fP – hatch style is not supported by MPOLYGON, just for symmetry to HATCH .IP \(bu 2 \fBrgb\fP – true color value as (r, g, b)\-tuple \- has higher priority than \fIcolor\fP\&. True color support requires DXF R2004+ .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_fill(name: str, color: int = 7, angle: float = 0.0, scale: float = 1.0, double: int = 0, style: int = 1, pattern_type: int = 1, definition=None) -> None Sets the pattern fill mode and removes all gradient related data. .sp The pattern definition should be designed for a scale factor 1 and a rotation angle of 0 degrees. The predefined hatch pattern like “ANSI33” are scaled according to the HEADER variable $MEASUREMENT for ISO measurement (m, cm, … ), or imperial units (in, ft, …), this replicates the behavior of BricsCAD. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – pattern name as string .IP \(bu 2 \fBcolor\fP – pattern color as \fI\%AutoCAD Color Index (ACI)\fP .IP \(bu 2 \fBangle\fP – pattern rotation angle in degrees .IP \(bu 2 \fBscale\fP – pattern scale factor .IP \(bu 2 \fBdouble\fP – double size flag .IP \(bu 2 \fBstyle\fP – hatch style (0 = normal; 1 = outer; 2 = ignore) .IP \(bu 2 \fBpattern_type\fP – pattern type (0 = user\-defined; 1 = predefined; 2 = custom) .IP \(bu 2 \fBdefinition\fP – list of definition lines and a definition line is a 4\-tuple [angle, base_point, offset, dash_length_items], see \fI\%set_pattern_definition()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_gradient(color1: \fI\%RGB\fP = RGB(0, 0, 0), color2: \fI\%RGB\fP = RGB(255, 255, 255), rotation: float = 0.0, centered: float = 0.0, one_color: int = 0, tint: float = 0.0, name: str = \(aqLINEAR\(aq) -> None Sets the gradient fill mode and removes all pattern fill related data, requires DXF R2004 or newer. A gradient filled hatch is also a solid filled hatch. .sp Valid gradient type names are: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 “LINEAR” .IP \(bu 2 “CYLINDER” .IP \(bu 2 “INVCYLINDER” .IP \(bu 2 “SPHERICAL” .IP \(bu 2 “INVSPHERICAL” .IP \(bu 2 “HEMISPHERICAL” .IP \(bu 2 “INVHEMISPHERICAL” .IP \(bu 2 “CURVED” .IP \(bu 2 “INVCURVED” .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor1\fP – (r, g, b)\-tuple for first color, rgb values as int in the range [0, 255] .IP \(bu 2 \fBcolor2\fP – (r, g, b)\-tuple for second color, rgb values as int in the range [0, 255] .IP \(bu 2 \fBrotation\fP – rotation angle in degrees .IP \(bu 2 \fBcentered\fP – determines whether the gradient is centered or not .IP \(bu 2 \fBone_color\fP – 1 for gradient from \fIcolor1\fP to tinted \fIcolor1\fP .IP \(bu 2 \fBtint\fP – determines the tinted target \fIcolor1\fP for a one color gradient. (valid range 0.0 to 1.0) .IP \(bu 2 \fBname\fP – name of gradient type, default “LINEAR” .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> DXFPolygon Transform entity by transformation matrix \fIm\fP inplace. .UNINDENT .UNINDENT .SS MText .sp The MTEXT entity (\fI\%DXF Reference\fP) fits a multiline text in a specified width but can extend vertically to an indefinite length. You can format individual words or characters within the \fI\%MText\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for MText and MTextEditor\fP .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqMTEXT\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_mtext()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.MText .INDENT 7.0 .TP .B dxf.insert Insertion point (3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.char_height Initial text height (float); default=1.0 .UNINDENT .INDENT 7.0 .TP .B dxf.width Reference text width (float), forces text wrapping at given width. .UNINDENT .INDENT 7.0 .TP .B dxf.attachment_point Constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|. _ T{ MText.dxf.attachment_point T} T{ Value T} _ T{ MTEXT_TOP_LEFT T} T{ 1 T} _ T{ MTEXT_TOP_CENTER T} T{ 2 T} _ T{ MTEXT_TOP_RIGHT T} T{ 3 T} _ T{ MTEXT_MIDDLE_LEFT T} T{ 4 T} _ T{ MTEXT_MIDDLE_CENTER T} T{ 5 T} _ T{ MTEXT_MIDDLE_RIGHT T} T{ 6 T} _ T{ MTEXT_BOTTOM_LEFT T} T{ 7 T} _ T{ MTEXT_BOTTOM_CENTER T} T{ 8 T} _ T{ MTEXT_BOTTOM_RIGHT T} T{ 9 T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.flow_direction Constants defined in \fBezdxf.const\fP: .TS center; |l|l|l|. _ T{ MText.dxf.flow_direction T} T{ Value T} T{ Description T} _ T{ MTEXT_LEFT_TO_RIGHT T} T{ 1 T} T{ left to right T} _ T{ MTEXT_TOP_TO_BOTTOM T} T{ 3 T} T{ top to bottom T} _ T{ MTEXT_BY_STYLE T} T{ 5 T} T{ by style (the flow direction is inherited from the associated text style) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.style Text style (string); default is “STANDARD” .UNINDENT .INDENT 7.0 .TP .B dxf.text_direction X\-axis direction vector in \fI\%WCS\fP (3D Point); default value is (1, 0, 0); if \fBdxf.rotation\fP and \fBdxf.text_direction\fP are present, \fBdxf.text_direction\fP wins. .UNINDENT .INDENT 7.0 .TP .B dxf.rotation Text rotation in degrees (float); default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.line_spacing_style Line spacing style (int), see table below .UNINDENT .INDENT 7.0 .TP .B dxf.line_spacing_factor Percentage of default (3\-on\-5) line spacing to be applied. Valid values range from 0.25 to 4.00 (float). .sp Constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|l|. _ T{ MText.dxf.line_spacing_style T} T{ Value T} T{ Description T} _ T{ MTEXT_AT_LEAST T} T{ 1 T} T{ taller characters will override T} _ T{ MTEXT_EXACT T} T{ 2 T} T{ taller characters will not override T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.bg_fill Defines the background fill type. (DXF R2007) .TS center; |l|l|l|. _ T{ MText.dxf.bg_fill T} T{ Value T} T{ Description T} _ T{ MTEXT_BG_OFF T} T{ 0 T} T{ no background color T} _ T{ MTEXT_BG_COLOR T} T{ 1 T} T{ use specified color T} _ T{ MTEXT_BG_WINDOW_COLOR T} T{ 2 T} T{ use window color (?) T} _ T{ MTEXT_BG_CANVAS_COLOR T} T{ 3 T} T{ use canvas background color T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.box_fill_scale Determines how much border there is around the text. (DXF R2007) .sp Requires that the attributes \fIbg_fill\fP, \fIbg_fill_color\fP are present otherwise AutoCAD complains. .sp It’s recommended to use \fBset_bg_color()\fP .UNINDENT .INDENT 7.0 .TP .B dxf.bg_fill_color Background fill color as \fI\%AutoCAD Color Index (ACI)\fP (DXF R2007) .sp It’s recommended to use \fBset_bg_color()\fP .UNINDENT .INDENT 7.0 .TP .B dxf.bg_fill_true_color Background fill color as true color value (DXF R2007), also the \fBdxf.bg_fill_color\fP attribute must be present otherwise AutoCAD complains. .sp It’s recommended to use \fBset_bg_color()\fP .UNINDENT .INDENT 7.0 .TP .B dxf.bg_fill_color_name Background fill color as name string (?) (DXF R2007), also the \fBdxf.bg_fill_color\fP attribute must be present otherwise AutoCAD complains. .sp It’s recommended to use \fBset_bg_color()\fP .UNINDENT .INDENT 7.0 .TP .B dxf.transparency Transparency of background fill color (DXF R2007), not supported by AutoCAD nor BricsCAD. .UNINDENT .INDENT 7.0 .TP .B text MTEXT content as string (read/write). .sp The line ending character \fB\en\fP will be replaced by the MTEXT line ending \fB\eP\fP at DXF export, but \fBnot\fP vice versa the \fB\eP\fP character by \fB\en\fP at DXF file loading, therefore loaded MTEXT entities always use the \fB\eP\fP character for line endings. .UNINDENT .INDENT 7.0 .TP .B set_location(insert: \fI\%UVec\fP, rotation: float | None = None, attachment_point: int | None = None) -> MText Sets the attributes \fI\%dxf.insert\fP, \fI\%dxf.rotation\fP and \fI\%dxf.attachment_point\fP, \fBNone\fP for \fI\%dxf.rotation\fP or \fI\%dxf.attachment_point\fP preserves the existing value. .UNINDENT .INDENT 7.0 .TP .B get_rotation() -> float Returns the text rotation in degrees. .UNINDENT .INDENT 7.0 .TP .B set_rotation(angle: float) -> MText Sets the attribute \fBrotation\fP to \fIangle\fP (in degrees) and deletes \fI\%dxf.text_direction\fP if present. .UNINDENT .INDENT 7.0 .TP .B get_text_direction() -> \fI\%Vec3\fP Returns the horizontal text direction as \fI\%Vec3\fP object, even if only the text rotation is defined. .UNINDENT .INDENT 7.0 .TP .B set_bg_color(color: int | str | \fI\%RGB\fP | None, scale: float = 1.5, text_frame=False) Sets the background color as \fI\%AutoCAD Color Index (ACI)\fP value, as name string or as (r, g, b) tuple. .sp Use the special color name \fBcanvas\fP, to set the background color to the canvas background color. Remove the background filling by setting argument \fIcolor\fP to \fBNone\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP, string, (r, g, b) tuple or \fBNone\fP .IP \(bu 2 \fBscale\fP – determines how much border there is around the text, the value is based on the text height, and should be in the range of [1, 5], where 1 fits exact the MText entity. .IP \(bu 2 \fBtext_frame\fP – draw a text frame in text color if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __iadd__(text: str) -> MText Append \fItext\fP to existing content (\fI\%text\fP attribute). .UNINDENT .INDENT 7.0 .TP .B append(text: str) -> MText Append \fItext\fP to existing content (\fI\%text\fP attribute). .UNINDENT .INDENT 7.0 .TP .B plain_text(split=False, fast=True) -> list[str] | str Returns the text content without inline formatting codes. .sp The “fast” mode is accurate if the DXF content was created by reliable (and newer) CAD applications like AutoCAD or BricsCAD. The “accurate” mode is for some rare cases where the content was created by older CAD applications or unreliable DXF libraries and CAD applications. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsplit\fP – split content text at line breaks if \fBTrue\fP and returns a list of strings without line endings .IP \(bu 2 \fBfast\fP – uses the “fast” mode to extract the plain MTEXT content if \fBTrue\fP or the “accurate” mode if set to \fBFalse\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B all_columns_plain_text(split=False) -> list[str] | str Returns the text content of all columns without inline formatting codes. .INDENT 7.0 .TP .B Parameters \fBsplit\fP – split content text at line breaks if \fBTrue\fP and returns a list of strings without line endings .UNINDENT .UNINDENT .INDENT 7.0 .TP .B all_columns_raw_content() -> str Returns the text content of all columns as a single string including the inline formatting codes. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> MText Transform the MTEXT entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B ucs() -> \fI\%UCS\fP Returns the \fI\%UCS\fP of the \fI\%MText\fP entity, defined by the insert location (origin), the text direction or rotation (x\-axis) and the extrusion vector (z\-axis). .UNINDENT .UNINDENT .SS MText Inline Codes .TS center; |l|l|. _ T{ Code T} T{ Description T} _ T{ \eL T} T{ Start underline T} _ T{ \el T} T{ Stop underline T} _ T{ \eO T} T{ Start overline T} _ T{ \eo T} T{ Stop overline T} _ T{ \eK T} T{ Start strike\-through T} _ T{ \ek T} T{ Stop strike\-through T} _ T{ \eP T} T{ New paragraph (new line) T} _ T{ \ep T} T{ Paragraphs properties: indentation, alignment, tabulator stops T} _ T{ \eX T} T{ Paragraph wrap on the dimension line (only in dimensions) T} _ T{ \eQ T} T{ Slanting (oblique) text by angle \- e.g. \eQ30; T} _ T{ \eH T} T{ Text height \- e.g. relative \eH3x; absolut \eH3; T} _ T{ \eW T} T{ Text width \- e.g. relative \eW0.8x; absolut \eW0.8; T} _ T{ \eT T} T{ Tracking, character spacing \- e.g. relative \eT0.5x; absolut \eT2; T} _ T{ \eF T} T{ Font selection e.g. \eFgdt;o \- GDT\-tolerance T} _ T{ \eS T} T{ Stacking, fractions e.g. \eSA^ B; space after “^” is required to avoid caret decoding, \eSX/Y; \eS1#4; T} _ T{ \eA T} T{ Alignment .INDENT 0.0 .IP \(bu 2 \eA0; = bottom .IP \(bu 2 \eA1; = center .IP \(bu 2 \eA2; = top .UNINDENT T} _ T{ \eC T} T{ Color change .INDENT 0.0 .IP \(bu 2 \eC1; = red .IP \(bu 2 \eC2; = yellow .IP \(bu 2 \eC3; = green .IP \(bu 2 \eC4; = cyan .IP \(bu 2 \eC5; = blue .IP \(bu 2 \eC6; = magenta .IP \(bu 2 \eC7; = white .UNINDENT T} _ T{ \e~ T} T{ Non breaking space T} _ T{ {} T} T{ Braces \- define the text area influenced by the code, codes and braces can be nested up to 8 levels deep T} _ T{ \e T} T{ Escape character \- e.g. \e{ = “{” T} _ .TE .SS Convenient constants defined in MTextEditor: .TS center; |l|l|. _ T{ Constant T} T{ Description T} _ T{ UNDERLINE_START T} T{ start underline text T} _ T{ UNDERLINE_STOP T} T{ stop underline text T} _ T{ OVERSTRIKE_START T} T{ start overline T} _ T{ OVERSTRIKE_STOP T} T{ stop overline T} _ T{ STRIKE_START T} T{ start strike through T} _ T{ STRIKE_STOP T} T{ stop strike through T} _ T{ GROUP_START T} T{ start of group T} _ T{ GROUP_END T} T{ end of group T} _ T{ NEW_LINE T} T{ start in new line T} _ T{ NBSP T} T{ none breaking space T} _ .TE .SS MultiLeader .sp The MULTILEADER entity (\fI\%DXF Reference\fP) represents one or more leaders, made up of one or more vertices (or spline fit points) and an arrowhead. In contrast to the \fI\%Leader\fP entity the text\- or block content is part of the MULTILEADER entity. .sp AutoCAD, BricsCAD and maybe other CAD applications do accept “MLEADER” as type string but they always create entities with “MULTILEADER” as type string. .sp Because of the complexity of the MULTILEADER entity, the usage of factory methods to create new entities by special builder classes is recommended: .INDENT 0.0 .IP \(bu 2 \fI\%add_multileader_mtext()\fP returns a new \fI\%MultiLeaderMTextBuilder\fP instance .IP \(bu 2 \fI\%add_multileader_block()\fP returns a new \fI\%MultiLeaderBlockBuilder\fP instance .UNINDENT .sp The visual design is based on an associated \fI\%MLeaderStyle\fP, but almost all attributes are also stored in the MULTILEADER entity itself. .sp The attribute \fI\%MultiLeader.dxf.property_override_flags\fP should indicate which MLEADERSTYLE attributes are overridden by MULTILEADER attributes, but these flags do not always reflect the state of overridden attributes. The \fIezdxf\fP MULTILEADER renderer uses always the attributes from the MULTILEADER entity and ignores the override flags. .sp All vertices are WCS coordinates, even those for BLOCK entities which are OCS coordinates for regular usage. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.entities.MLeaderStyle\fP .IP \(bu 2 \fI\%ezdxf.render.MultiLeaderBuilder\fP .IP \(bu 2 \fI\%Tutorial for MultiLeader\fP .IP \(bu 2 \fI\%MULTILEADER Internals\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqMULTILEADER\(aq\fP T} _ T{ Factory functions T} T{ .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.layouts.BaseLayout.add_multileader_mtext()\fP .IP \(bu 2 \fI\%ezdxf.layouts.BaseLayout.add_multileader_block()\fP .UNINDENT T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.MultiLeader .INDENT 7.0 .TP .B dxf.arrow_head_handle handle of the arrow head, see also \fI\%ezdxf.render.arrows\fP module, “closed filled” arrow if not set .UNINDENT .INDENT 7.0 .TP .B dxf.arrow_head_size arrow head size in drawing units .UNINDENT .INDENT 7.0 .TP .B dxf.block_color block color as \fI\%raw\-color\fP value, default is BY_BLOCK_RAW_VALUE .UNINDENT .INDENT 7.0 .TP .B dxf.block_connection_type .TS center; |l|l|. _ T{ 0 T} T{ center extents T} _ T{ 1 T} T{ insertion point T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.block_record_handle handle to block record of the BLOCK content .UNINDENT .INDENT 7.0 .TP .B dxf.block_rotation BLOCK rotation in radians .UNINDENT .INDENT 7.0 .TP .B dxf.block_scale_vector \fBVec3\fP object which stores the scaling factors for the x\-, y\- and z\-axis .UNINDENT .INDENT 7.0 .TP .B dxf.content_type .TS center; |l|l|. _ T{ 0 T} T{ none T} _ T{ 1 T} T{ BLOCK T} _ T{ 2 T} T{ MTEXT T} _ T{ 3 T} T{ TOLERANCE T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.dogleg_length dogleg length in drawing units .UNINDENT .INDENT 7.0 .TP .B dxf.has_dogleg .UNINDENT .INDENT 7.0 .TP .B dxf.has_landing .UNINDENT .INDENT 7.0 .TP .B dxf.has_text_frame .UNINDENT .INDENT 7.0 .TP .B dxf.is_annotative .UNINDENT .INDENT 7.0 .TP .B dxf.is_text_direction_negative .UNINDENT .INDENT 7.0 .TP .B dxf.leader_extend_to_text .UNINDENT .INDENT 7.0 .TP .B dxf.leader_line_color leader line color as \fI\%raw\-color\fP value .UNINDENT .INDENT 7.0 .TP .B dxf.leader_linetype_handle handle of the leader linetype, “CONTINUOUS” if not set .UNINDENT .INDENT 7.0 .TP .B dxf.leader_lineweight .UNINDENT .INDENT 7.0 .TP .B dxf.leader_type .TS center; |l|l|. _ T{ 0 T} T{ invisible T} _ T{ 1 T} T{ straight line leader T} _ T{ 2 T} T{ spline leader T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.property_override_flags Each bit shows if the MLEADERSTYLE is overridden by the value in the MULTILEADER entity, but this is not always the case for all values, it seems to be save to always use the value from the MULTILEADER entity. .UNINDENT .INDENT 7.0 .TP .B dxf.scale overall scaling factor .UNINDENT .INDENT 7.0 .TP .B dxf.style_handle handle to the associated MLEADERSTYLE object .UNINDENT .INDENT 7.0 .TP .B dxf.text_IPE_align unknown meaning .UNINDENT .INDENT 7.0 .TP .B dxf.text_alignment_type unknown meaning \- its not the MTEXT attachment point! .UNINDENT .INDENT 7.0 .TP .B dxf.text_angle_type .TS center; |l|l|. _ T{ 0 T} T{ text angle is equal to last leader line segment angle T} _ T{ 1 T} T{ text is horizontal T} _ T{ 2 T} T{ text angle is equal to last leader line segment angle, but potentially rotated by 180 degrees so the right side is up for readability. T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_attachment_direction defines whether the leaders attach to the left & right of the content BLOCK/MTEXT or attach to the top & bottom: .TS center; |l|l|. _ T{ 0 T} T{ horizontal \- left & right of content T} _ T{ 1 T} T{ vertical \- top & bottom of content T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_attachment_point MTEXT attachment point .TS center; |l|l|. _ T{ 1 T} T{ top left T} _ T{ 2 T} T{ top center T} _ T{ 3 T} T{ top right T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_bottom_attachment_type .TS center; |l|l|. _ T{ 9 T} T{ center T} _ T{ 10 T} T{ overline and center T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_color MTEXT color as \fI\%raw\-color\fP value .UNINDENT .INDENT 7.0 .TP .B dxf.text_left_attachment_type .TS center; |l|l|. _ T{ 0 T} T{ top of top MTEXT line T} _ T{ 1 T} T{ middle of top MTEXT line T} _ T{ 2 T} T{ middle of whole MTEXT T} _ T{ 3 T} T{ middle of bottom MTEXT line T} _ T{ 4 T} T{ bottom of bottom MTEXT line T} _ T{ 5 T} T{ bottom of bottom MTEXT line & underline bottom MTEXT line T} _ T{ 6 T} T{ bottom of top MTEXT line & underline top MTEXT line T} _ T{ 7 T} T{ bottom of top MTEXT line T} _ T{ 8 T} T{ bottom of top MTEXT line & underline all MTEXT lines T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_right_attachment_type .TS center; |l|l|. _ T{ 0 T} T{ top of top MTEXT line T} _ T{ 1 T} T{ middle of top MTEXT line T} _ T{ 2 T} T{ middle of whole MTEXT T} _ T{ 3 T} T{ middle of bottom MTEXT line T} _ T{ 4 T} T{ bottom of bottom MTEXT line T} _ T{ 5 T} T{ bottom of bottom MTEXT line & underline bottom MTEXT line T} _ T{ 6 T} T{ bottom of top MTEXT line & underline top MTEXT line T} _ T{ 7 T} T{ bottom of top MTEXT line T} _ T{ 8 T} T{ bottom of top MTEXT line & underline all MTEXT lines T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_style_handle handle of the MTEXT text style, “Standard” if not set .UNINDENT .INDENT 7.0 .TP .B dxf.text_top_attachment_type .TS center; |l|l|. _ T{ 9 T} T{ center T} _ T{ 10 T} T{ overline and center T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.version always 2? .UNINDENT .INDENT 7.0 .TP .B context \fI\%MLeaderContext\fP instance .UNINDENT .INDENT 7.0 .TP .B arrow_heads list of \fI\%ArrowHeadData\fP .UNINDENT .INDENT 7.0 .TP .B block_attribs list of \fI\%AttribData\fP .UNINDENT .INDENT 7.0 .TP .B property has_mtext_content: bool \fBTrue\fP if MULTILEADER has MTEXT content. .UNINDENT .INDENT 7.0 .TP .B get_mtext_content() -> str Get MTEXT content as string, return “” if MULTILEADER has BLOCK content. .UNINDENT .INDENT 7.0 .TP .B set_mtext_content(text: str) Set MTEXT content as string, does nothing if MULTILEADER has BLOCK content. .UNINDENT .INDENT 7.0 .TP .B property has_block_content: bool \fBTrue\fP if MULTILEADER has BLOCK content. .UNINDENT .INDENT 7.0 .TP .B get_block_content() -> dict[str, str] Get BLOCK attributes as dictionary of (tag, value) pairs. Returns an empty dictionary if MULTILEADER has MTEXT content. .UNINDENT .INDENT 7.0 .TP .B set_block_content(content: dict[str, str]) Set BLOCK attributes by a dictionary of (tag, value) pairs. Does nothing if MULTILEADER has MTEXT content. .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterator[DXFGraphic] Yields the graphical representation of MULTILEADER as virtual DXF primitives. .sp These entities are located at the original location, but are not stored in the entity database, have no handle and are not assigned to any layout. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: \fI\%BaseLayout\fP | None = None) -> \fI\%EntityQuery\fP Explode MULTILEADER as DXF primitives into target layout, if target layout is \fBNone\fP, the target layout is the layout of the source entity. .sp Returns an \fI\%EntityQuery\fP container with all DXF primitives. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for the DXF primitives, \fBNone\fP for same layout as the source entity. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> MultiLeader Transform the MULTILEADER entity by transformation matrix \fIm\fP inplace. .sp Non\-uniform scaling is not supported. .INDENT 7.0 .TP .B Parameters \fBm\fP – transformation \fI\%Matrix44\fP .TP .B Raises \fBNonUniformScalingError\fP – for non\-uniform scaling .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.MLeaderContext .INDENT 7.0 .TP .B leaders list of \fI\%LeaderData\fP objects .UNINDENT .INDENT 7.0 .TP .B scale redundant data: \fI\%MultiLeader.dxf.scale\fP .UNINDENT .INDENT 7.0 .TP .B base_point insert location as \fBVec3\fP of the MTEXT or the BLOCK entity? .UNINDENT .INDENT 7.0 .TP .B char_height MTEXT char height, already scaled .UNINDENT .INDENT 7.0 .TP .B arrow_head_size redundant data: \fI\%MultiLeader.dxf.arrow_head_size\fP .UNINDENT .INDENT 7.0 .TP .B landing_gap_size .UNINDENT .INDENT 7.0 .TP .B left_attachment redundant data: \fI\%MultiLeader.dxf.text_left_attachment_type\fP .UNINDENT .INDENT 7.0 .TP .B right_attachment redundant data: \fI\%MultiLeader.dxf.text_right_attachment_type\fP .UNINDENT .INDENT 7.0 .TP .B text_align_type redundant data: \fI\%MultiLeader.dxf.text_attachment_point\fP .UNINDENT .INDENT 7.0 .TP .B attachment_type BLOCK alignment? .TS center; |l|l|. _ T{ 0 T} T{ content extents T} _ T{ 1 T} T{ insertion point T} _ .TE .UNINDENT .INDENT 7.0 .TP .B mtext instance of \fI\%MTextData\fP if content is MTEXT otherwise \fBNone\fP .UNINDENT .INDENT 7.0 .TP .B block instance of \fI\%BlockData\fP if content is BLOCK otherwise \fBNone\fP .UNINDENT .INDENT 7.0 .TP .B plane_origin \fBVec3\fP .UNINDENT .INDENT 7.0 .TP .B plane_x_axis \fBVec3\fP .UNINDENT .INDENT 7.0 .TP .B plane_y_axis \fBVec3\fP .UNINDENT .INDENT 7.0 .TP .B plane_normal_reversed the plan normal is x\-axis “cross” y\-axis (right\-hand\-rule), this flag indicates to invert this plan normal .UNINDENT .INDENT 7.0 .TP .B top_attachment redundant data: \fI\%MultiLeader.dxf.text_top_attachment_type\fP .UNINDENT .INDENT 7.0 .TP .B bottom_attachment redundant data: \fI\%MultiLeader.dxf.text_bottom_attachment_type\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.LeaderData .INDENT 7.0 .TP .B lines list of \fI\%LeaderLine\fP .UNINDENT .INDENT 7.0 .TP .B has_last_leader_line unknown meaning .UNINDENT .INDENT 7.0 .TP .B has_dogleg_vector .UNINDENT .INDENT 7.0 .TP .B last_leader_point WCS point as \fBVec3\fP .UNINDENT .INDENT 7.0 .TP .B dogleg_vector WCS direction as \fBVec3\fP .UNINDENT .INDENT 7.0 .TP .B dogleg_length redundant data: \fI\%MultiLeader.dxf.dogleg_length\fP .UNINDENT .INDENT 7.0 .TP .B index leader index? .UNINDENT .INDENT 7.0 .TP .B attachment_direction redundant data: \fI\%MultiLeader.dxf.text_attachment_direction\fP .UNINDENT .INDENT 7.0 .TP .B breaks list of break vertices as \fBVec3\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.LeaderLine .INDENT 7.0 .TP .B vertices list of WCS coordinates as \fBVec3\fP .UNINDENT .INDENT 7.0 .TP .B breaks mixed list of mixed integer indices and break coordinates or \fBNone\fP leader lines without breaks in it .UNINDENT .INDENT 7.0 .TP .B index leader line index? .UNINDENT .INDENT 7.0 .TP .B color leader line color override, ignore override value if BY_BLOCK_RAW_VALUE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.ArrowHeadData .INDENT 7.0 .TP .B index arrow head index? .UNINDENT .INDENT 7.0 .TP .B handle handle to arrow head block .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.AttribData .INDENT 7.0 .TP .B handle handle to \fBAttdef\fP entity in the BLOCK definition .UNINDENT .INDENT 7.0 .TP .B index unknown meaning .UNINDENT .INDENT 7.0 .TP .B width text width factor? .UNINDENT .INDENT 7.0 .TP .B text \fI\%Attrib\fP content .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.MTextData stores the content and attributes of the MTEXT entity .INDENT 7.0 .TP .B default_content content as string .UNINDENT .INDENT 7.0 .TP .B extrusion extrusion vector of the MTEXT entity but MTEXT is not an OCS entity! .UNINDENT .INDENT 7.0 .TP .B style_handle redundant data: \fI\%MultiLeader.dxf.text_style_handle\fP .UNINDENT .INDENT 7.0 .TP .B insert insert location in WCS coordinates, same as \fI\%MLeaderContext.base_point\fP? .UNINDENT .INDENT 7.0 .TP .B text_direction “horizontal” text direction vector in WCS .UNINDENT .INDENT 7.0 .TP .B rotation rotation angle in radians (!) around the extrusion vector, calculated as it were an OCS entity .UNINDENT .INDENT 7.0 .TP .B width unscaled column width .UNINDENT .INDENT 7.0 .TP .B defined_height unscaled defined column height .UNINDENT .INDENT 7.0 .TP .B line_spacing_factor see \fI\%MText.dxf.line_spacing_factor\fP .UNINDENT .INDENT 7.0 .TP .B line_spacing_style see \fI\%MText.dxf.line_spacing_style\fP .UNINDENT .INDENT 7.0 .TP .B color redundant data: \fI\%MultiLeader.dxf.text_color\fP .UNINDENT .INDENT 7.0 .TP .B alignment redundant data: \fI\%MultiLeader.dxf.text_attachment_point\fP .UNINDENT .INDENT 7.0 .TP .B flow_direction .TS center; |l|l|. _ T{ 1 T} T{ horizontal T} _ T{ 3 T} T{ vertical T} _ T{ 6 T} T{ by text style T} _ .TE .UNINDENT .INDENT 7.0 .TP .B bg_color background color as \fI\%raw\-color\fP value .UNINDENT .INDENT 7.0 .TP .B bg_scale_factor see \fI\%MText.dxf.box_fill_scale\fP .UNINDENT .INDENT 7.0 .TP .B bg_transparency background transparency value .UNINDENT .INDENT 7.0 .TP .B use_window_bg_color .UNINDENT .INDENT 7.0 .TP .B has_bg_fill .UNINDENT .INDENT 7.0 .TP .B column_type unknown meaning \- most likely: .TS center; |l|l|. _ T{ 0 T} T{ none T} _ T{ 1 T} T{ static T} _ T{ 2 T} T{ dynamic T} _ .TE .UNINDENT .INDENT 7.0 .TP .B use_auto_height .UNINDENT .INDENT 7.0 .TP .B column_width unscaled column width, redundant data \fI\%width\fP .UNINDENT .INDENT 7.0 .TP .B column_gutter_width unscaled column gutter width .UNINDENT .INDENT 7.0 .TP .B column_flow_reversed .UNINDENT .INDENT 7.0 .TP .B column_sizes list of unscaled columns heights for dynamic column with manual heights .UNINDENT .INDENT 7.0 .TP .B use_word_break .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.BlockData stores the attributes for the \fI\%Insert\fP entity .INDENT 7.0 .TP .B block_record_handle redundant data: \fI\%MultiLeader.dxf.block_record_handle\fP .UNINDENT .INDENT 7.0 .TP .B extrusion extrusion vector in WCS .UNINDENT .INDENT 7.0 .TP .B insert insertion location in WCS as \fBVec3\fP, same as \fI\%MLeaderContext.base_point\fP? .UNINDENT .INDENT 7.0 .TP .B scale redundant data: \fI\%MultiLeader.dxf.block_scale_vector\fP .UNINDENT .INDENT 7.0 .TP .B rotation redundant data: \fI\%MultiLeader.dxf.block_rotation\fP .UNINDENT .INDENT 7.0 .TP .B color redundant data: \fI\%MultiLeader.dxf.block_color\fP .UNINDENT .UNINDENT .SS Point .sp The POINT entity (\fI\%DXF Reference\fP) represents a dimensionless point in \fI\%WCS\fP\&. .sp The POINT styling is a global setting, stored as header variable \fI\%$PDMODE\fP, this also means \fBall\fP POINT entities in a DXF document have the same styling: .TS center; |l|l|. _ T{ 0 T} T{ center dot (.) T} _ T{ 1 T} T{ none ( ) T} _ T{ 2 T} T{ cross (+) T} _ T{ 3 T} T{ x\-cross (x) T} _ T{ 4 T} T{ tick (‘) T} _ .TE .sp Combined with these bit values .TS center; |l|l|. _ T{ 32 T} T{ circle T} _ T{ 64 T} T{ Square T} _ .TE .sp e.g. circle + square + center dot = 32 + 64 + 0 = 96 [image] .sp The size of the points is defined by the header variable \fI\%$PDSIZE\fP: .TS center; |l|l|. _ T{ 0 T} T{ 5% of draw area height T} _ T{ <0 T} T{ Specifies a percentage of the viewport size T} _ T{ >0 T} T{ Specifies an absolute size T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Tutorial for Simple DXF Entities\fP, section \fI\%Point\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqPOINT\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_point()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Point .INDENT 7.0 .TP .B dxf.location Location of the point (2D/3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.angle Angle in degrees of the x\-axis for the UCS in effect when POINT was drawn (float); used when PDMODE is nonzero. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Point Transform the POINT entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> Point Optimized POINT translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(pdsize: float = 1, pdmode: int = 0) -> Iterator[DXFGraphic] Yields the graphical representation of POINT as virtual DXF primitives (LINE and CIRCLE). The dimensionless point is rendered as zero\-length line! .sp Check for this condition: .INDENT 7.0 .INDENT 3.5 .sp .EX e.dxftype() == \(aqLINE\(aq and e.dxf.start.isclose(e.dxf.end) .EE .UNINDENT .UNINDENT .sp if the rendering engine can’t handle zero\-length lines. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpdsize\fP – point size in drawing units .IP \(bu 2 \fBpdmode\fP – point styling mode .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Polyline .sp The POLYLINE entity (\fI\%POLYLINE DXF Reference\fP) is very complex, it’s used to build 2D/3D polylines, 3D meshes and 3D polyfaces. For every type exists a different wrapper class but they all have the same DXF type “POLYLINE”. Detect the actual POLYLINE type by the method \fI\%Polyline.get_mode()\fP\&. .sp POLYLINE types returned by \fI\%Polyline.get_mode()\fP: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB\(aqAcDb2dPolyline\(aq\fP for 2D \fI\%Polyline\fP .IP \(bu 2 \fB\(aqAcDb3dPolyline\(aq\fP for 3D \fI\%Polyline\fP .IP \(bu 2 \fB\(aqAcDbPolygonMesh\(aq\fP for \fI\%Polymesh\fP .IP \(bu 2 \fB\(aqAcDbPolyFaceMesh\(aq\fP for \fI\%Polyface\fP .UNINDENT .UNINDENT .UNINDENT .sp For 2D entities all vertices in \fI\%OCS\fP\&. .sp For 3D entities all vertices in \fI\%WCS\fP\&. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqPOLYLINE\(aq\fP T} _ T{ 2D factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_polyline2d()\fP T} _ T{ 3D factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_polyline3d()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Polyline The \fI\%Vertex\fP entities are stored in the Python list \fI\%Polyline.vertices\fP\&. The VERTEX entities can be retrieved and deleted by direct access to the \fI\%Polyline.vertices\fP attribute: .INDENT 7.0 .INDENT 3.5 .sp .EX # delete first and second vertex del polyline.vertices[:2] .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxf.elevation Elevation point, the X and Y values are always 0, and the Z value is the polyline elevation (3D Point). .UNINDENT .INDENT 7.0 .TP .B dxf.flags Constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|l|. _ T{ \fI\%Polyline.dxf.flags\fP T} T{ Value T} T{ Description T} _ T{ POLYLINE_CLOSED T} T{ 1 T} T{ This is a closed Polyline (or a polygon mesh closed in the M direction) T} _ T{ POLYLINE_MESH_CLOSED_M_DIRECTION T} T{ 1 T} T{ equals POLYLINE_CLOSED T} _ T{ POLYLINE_CURVE_FIT_VERTICES_ADDED T} T{ 2 T} T{ Curve\-fit vertices have been added T} _ T{ POLYLINE_SPLINE_FIT_VERTICES_ADDED T} T{ 4 T} T{ Spline\-fit vertices have been added T} _ T{ POLYLINE_3D_POLYLINE T} T{ 8 T} T{ This is a 3D Polyline T} _ T{ POLYLINE_3D_POLYMESH T} T{ 16 T} T{ This is a 3D polygon mesh T} _ T{ POLYLINE_MESH_CLOSED_N_DIRECTION T} T{ 32 T} T{ The polygon mesh is closed in the N direction T} _ T{ POLYLINE_POLYFACE_MESH T} T{ 64 T} T{ This Polyline is a polyface mesh T} _ T{ POLYLINE_GENERATE_LINETYPE_PATTERN T} T{ 128 T} T{ The linetype pattern is generated continuously around the vertices of this Polyline T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.default_start_width Default line start width (float); default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.default_end_width Default line end width (float); default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.m_count Polymesh M vertex count (int); default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.n_count Polymesh N vertex count (int); default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.m_smooth_density Smooth surface M density (int); default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.n_smooth_density Smooth surface N density (int); default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.smooth_type Curves and smooth surface type (int); default is 0, see table below .sp Constants for \fBsmooth_type\fP defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|l|. _ T{ \fI\%Polyline.dxf.smooth_type\fP T} T{ Value T} T{ Description T} _ T{ POLYMESH_NO_SMOOTH T} T{ 0 T} T{ no smooth surface fitted T} _ T{ POLYMESH_QUADRATIC_BSPLINE T} T{ 5 T} T{ quadratic B\-spline surface T} _ T{ POLYMESH_CUBIC_BSPLINE T} T{ 6 T} T{ cubic B\-spline surface T} _ T{ POLYMESH_BEZIER_SURFACE T} T{ 8 T} T{ Bezier surface T} _ .TE .UNINDENT .INDENT 7.0 .TP .B vertices List of \fI\%Vertex\fP entities. .UNINDENT .INDENT 7.0 .TP .B is_2d_polyline \fBTrue\fP if POLYLINE is a 2D polyline. .UNINDENT .INDENT 7.0 .TP .B is_3d_polyline \fBTrue\fP if POLYLINE is a 3D polyline. .UNINDENT .INDENT 7.0 .TP .B is_polygon_mesh \fBTrue\fP if POLYLINE is a polygon mesh, see \fI\%Polymesh\fP .UNINDENT .INDENT 7.0 .TP .B is_poly_face_mesh \fBTrue\fP if POLYLINE is a poly face mesh, see \fI\%Polyface\fP .UNINDENT .INDENT 7.0 .TP .B is_closed \fBTrue\fP if POLYLINE is closed. .UNINDENT .INDENT 7.0 .TP .B is_m_closed \fBTrue\fP if POLYLINE (as \fI\%Polymesh\fP) is closed in m direction. .UNINDENT .INDENT 7.0 .TP .B is_n_closed \fBTrue\fP if POLYLINE (as \fI\%Polymesh\fP) is closed in n direction. .UNINDENT .INDENT 7.0 .TP .B has_arc Returns \fBTrue\fP if 2D POLYLINE has an arc segment. .UNINDENT .INDENT 7.0 .TP .B has_width Returns \fBTrue\fP if 2D POLYLINE has default width values or any segment with width attributes. .UNINDENT .INDENT 7.0 .TP .B get_mode() -> str Returns POLYLINE type as string: .INDENT 7.0 .IP \(bu 2 “AcDb2dPolyline” .IP \(bu 2 “AcDb3dPolyline” .IP \(bu 2 “AcDbPolygonMesh” .IP \(bu 2 “AcDbPolyFaceMesh” .UNINDENT .UNINDENT .INDENT 7.0 .TP .B m_close(status=True) -> None Close POLYMESH in m direction if \fIstatus\fP is \fBTrue\fP (also closes POLYLINE), clears closed state if \fIstatus\fP is \fBFalse\fP\&. .UNINDENT .INDENT 7.0 .TP .B n_close(status=True) -> None Close POLYMESH in n direction if \fIstatus\fP is \fBTrue\fP, clears closed state if \fIstatus\fP is \fBFalse\fP\&. .UNINDENT .INDENT 7.0 .TP .B close(m_close=True, n_close=False) -> None Set closed state of POLYMESH and POLYLINE in m direction and n direction. \fBTrue\fP set closed flag, \fBFalse\fP clears closed flag. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of \fI\%Vertex\fP entities. .UNINDENT .INDENT 7.0 .TP .B __getitem__(pos) -> DXFVertex Get \fI\%Vertex\fP entity at position \fIpos\fP, supports list\-like slicing. .UNINDENT .INDENT 7.0 .TP .B points() -> Iterator[\fI\%Vec3\fP] Returns iterable of all polyline vertices as (x, y, z) tuples, not as \fI\%Vertex\fP objects. .UNINDENT .INDENT 7.0 .TP .B append_vertex(point: \fI\%UVec\fP, dxfattribs=None) -> None Append a single \fI\%Vertex\fP entity at location \fIpoint\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – as (x, y[, z]) tuple .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for \fI\%Vertex\fP class .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append_vertices(points: Iterable[\fI\%UVec\fP], dxfattribs=None) -> None Append multiple \fI\%Vertex\fP entities at location \fIpoints\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of (x, y[, z]) tuples .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for the VERTEX objects .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append_formatted_vertices(points: Iterable[\fI\%UVec\fP], format: str = \(aqxy\(aq, dxfattribs=None) -> None Append multiple \fI\%Vertex\fP entities at location \fIpoints\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of (x, y, [start_width, [end_width, [bulge]]]) tuple .IP \(bu 2 \fBformat\fP – format string, default is “xy”, see: \fI\%User Defined Point Format Codes\fP .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for the VERTEX objects .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B insert_vertices(pos: int, points: Iterable[\fI\%UVec\fP], dxfattribs=None) -> None Insert vertices \fIpoints\fP into \fI\%Polyline.vertices\fP list at insertion location \fIpos\fP . .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpos\fP – insertion position of list \fI\%Polyline.vertices\fP .IP \(bu 2 \fBpoints\fP – list of (x, y[, z]) tuples .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for \fI\%Vertex\fP class .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Polyline Transform the POLYLINE entity by transformation matrix \fIm\fP inplace. .sp A non\-uniform scaling is not supported if a 2D POLYLINE contains circular arc segments (bulges). .INDENT 7.0 .TP .B Parameters \fBm\fP – transformation \fI\%Matrix44\fP .TP .B Raises \fBNonUniformScalingError\fP – for non\-uniform scaling of 2D POLYLINE containing circular arc segments (bulges) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterator[\fI\%Line\fP | \fI\%Arc\fP | \fI\%Face3d\fP] Yields the graphical representation of POLYLINE as virtual DXF primitives (LINE, ARC or 3DFACE). .sp These virtual entities are located at the original location, but are not stored in the entity database, have no handle and are not assigned to any layout. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: \fI\%BaseLayout\fP | None = None) -> \fI\%EntityQuery\fP Explode the POLYLINE entity as DXF primitives (LINE, ARC or 3DFACE) into the target layout, if the target layout is \fBNone\fP, the target layout is the layout of the POLYLINE entity. .sp Returns an \fI\%EntityQuery\fP container referencing all DXF primitives. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for DXF primitives, \fBNone\fP for same layout as source entity. .UNINDENT .UNINDENT .UNINDENT .SS Vertex .sp A VERTEX (\fI\%VERTEX DXF Reference\fP) represents a polyline/mesh vertex. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqVERTEX\(aq\fP T} _ T{ Factory function T} T{ \fI\%Polyline.append_vertex()\fP T} _ T{ Factory function T} T{ \fBPolyline.extend()\fP T} _ T{ Factory function T} T{ \fI\%Polyline.insert_vertices()\fP T} _ T{ Inherited DXF Attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Vertex .INDENT 7.0 .TP .B dxf.location Vertex location (2D/3D Point \fI\%OCS\fP when 2D, \fI\%WCS\fP when 3D) .UNINDENT .INDENT 7.0 .TP .B dxf.start_width Line segment start width (float); default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.end_width Line segment end width (float); default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.bulge \fI\%Bulge value\fP (float); default is 0. .sp The bulge value is used to create arc shaped line segments. .UNINDENT .INDENT 7.0 .TP .B dxf.flags Constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|l|. _ T{ Vertex.dxf.flags T} T{ Value T} T{ Description T} _ T{ VTX_EXTRA_VERTEX_CREATED T} T{ 1 T} T{ Extra vertex created by curve\-fitting T} _ T{ VTX_CURVE_FIT_TANGENT T} T{ 2 T} T{ curve\-fit tangent defined for this vertex. A curve\-fit tangent direction of 0 may be omitted from the DXF output, but is significant if this bit is set. T} _ T{ VTX_SPLINE_VERTEX_CREATED T} T{ 8 T} T{ spline vertex created by spline\-fitting T} _ T{ VTX_SPLINE_FRAME_CONTROL_POINT T} T{ 16 T} T{ spline frame control point T} _ T{ VTX_3D_POLYLINE_VERTEX T} T{ 32 T} T{ 3D polyline vertex T} _ T{ VTX_3D_POLYGON_MESH_VERTEX T} T{ 64 T} T{ 3D polygon mesh T} _ T{ VTX_3D_POLYFACE_MESH_VERTEX T} T{ 128 T} T{ polyface mesh vertex T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.tangent Curve fit tangent direction (float), used for 2D spline in DXF R12. .UNINDENT .INDENT 7.0 .TP .B dxf.vtx1 Index of 1st vertex, if used as face (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx2 Index of 2nd vertex, if used as face (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx3 Index of 3rd vertex, if used as face (feature for experts) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx4 Index of 4th vertex, if used as face (feature for experts) .UNINDENT .INDENT 7.0 .TP .B is_2d_polyline_vertex .UNINDENT .INDENT 7.0 .TP .B is_3d_polyline_vertex .UNINDENT .INDENT 7.0 .TP .B is_polygon_mesh_vertex .UNINDENT .INDENT 7.0 .TP .B is_poly_face_mesh_vertex .UNINDENT .INDENT 7.0 .TP .B is_face_record .UNINDENT .INDENT 7.0 .TP .B format(format=\(aqxyz\(aq) -> Sequence Return formatted vertex components as tuple. .sp Format codes: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 “x” = x\-coordinate .IP \(bu 2 “y” = y\-coordinate .IP \(bu 2 “z” = z\-coordinate .IP \(bu 2 “s” = start width .IP \(bu 2 “e” = end width .IP \(bu 2 “b” = bulge value .IP \(bu 2 “v” = (x, y, z) as tuple .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Args: format: format string, default is “xyz” .UNINDENT .UNINDENT .UNINDENT .SS Polymesh .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Polyline\fP T} _ T{ DXF type T} T{ \fB\(aqPOLYLINE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_polymesh()\fP T} _ T{ Inherited DXF Attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Polymesh A polymesh is a grid of \fBm_count\fP by \fBn_count\fP vertices, every vertex has its own (x, y, z) location. The \fI\%Polymesh\fP is a subclass of \fI\%Polyline\fP, the DXF type is also “POLYLINE”, the method \fBget_mode()\fP returns “AcDbPolygonMesh”. .INDENT 7.0 .TP .B get_mesh_vertex(pos: tuple[int, int]) -> DXFVertex Get location of a single mesh vertex. .INDENT 7.0 .TP .B Parameters \fBpos\fP – 0\-based (row, col) tuple, position of mesh vertex .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_mesh_vertex(pos: tuple[int, int], point: \fI\%UVec\fP, dxfattribs=None) Set location and DXF attributes of a single mesh vertex. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpos\fP – 0\-based (row, col) tuple, position of mesh vertex .IP \(bu 2 \fBpoint\fP – (x, y, z) tuple, new 3D coordinates of the mesh vertex .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_mesh_vertex_cache() -> MeshVertexCache Get a \fI\%MeshVertexCache\fP object for this POLYMESH. The caching object provides fast access to the \fBlocation\fP attribute of mesh vertices. .UNINDENT .UNINDENT .SS MeshVertexCache .INDENT 0.0 .TP .B class ezdxf.entities.MeshVertexCache Cache mesh vertices in a dict, keys are 0\-based (row, col) tuples. .sp Set vertex location: \fBcache[row, col] = (x, y, z)\fP .sp Get vertex location: \fBx, y, z = cache[row, col]\fP .INDENT 7.0 .TP .B vertices Dict of mesh vertices, keys are 0\-based (row, col) tuples. .UNINDENT .INDENT 7.0 .TP .B __getitem__(pos: tuple[int, int]) -> \fI\%UVec\fP Get mesh vertex location as (x, y, z)\-tuple. .INDENT 7.0 .TP .B Parameters \fBpos\fP – 0\-based (row, col)\-tuple. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __setitem__(pos: tuple[int, int], location: \fI\%UVec\fP) -> None Get mesh vertex location as (x, y, z)\-tuple. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpos\fP – 0\-based (row, col)\-tuple. .IP \(bu 2 \fBlocation\fP – (x, y, z)\-tuple .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Polyface .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Polyline\fP T} _ T{ DXF type T} T{ \fB\(aqPOLYLINE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_polyface()\fP T} _ T{ Inherited DXF Attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for Polyface\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Polyface A polyface consist of multiple 3D areas called faces, only faces with 3 or 4 vertices are supported. The \fI\%Polyface\fP is a subclass of \fI\%Polyline\fP, the DXF type is also “POLYLINE”, the \fI\%get_mode()\fP returns “AcDbPolyFaceMesh”. .INDENT 7.0 .TP .B append_face(face: FaceType, dxfattribs=None) -> None Append a single face. A \fIface\fP is a sequence of (x, y, z) tuples. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBface\fP – sequence of (x, y, z) tuples .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for the VERTEX objects .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append_faces(faces: Iterable[FaceType], dxfattribs=None) -> None Append multiple \fIfaces\fP\&. \fIfaces\fP is a list of single faces and a single face is a sequence of (x, y, z) tuples. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfaces\fP – iterable of sequences of (x, y, z) tuples .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for the VERTEX entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B faces() -> Iterator[list[DXFVertex]] Iterable of all faces, a face is a tuple of vertices. .INDENT 7.0 .TP .B Returns list of [vertex, vertex, vertex, [vertex,] face_record] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B optimize(precision: int = 6) -> None Rebuilds the \fI\%Polyface\fP by merging vertices with nearly same vertex locations. .INDENT 7.0 .TP .B Parameters \fBprecision\fP – floating point precision for determining identical vertex locations .UNINDENT .UNINDENT .UNINDENT .SS Ray .sp The RAY entity (\fI\%DXF Reference\fP) starts at \fBRay.dxf.point\fP and continues to infinity (construction line). .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.XLine\fP T} _ T{ DXF type T} T{ \fB\(aqRAY\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_ray()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Ray .INDENT 7.0 .TP .B dxf.start .UNINDENT .sp Start point as (3D Point in \fI\%WCS\fP) .INDENT 7.0 .TP .B dxf.unit_vector .UNINDENT .sp Unit direction vector as (3D Point in \fI\%WCS\fP) .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> XLine Transform the XLINE/RAY entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> XLine Optimized XLINE/RAY translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis. .UNINDENT .UNINDENT .SS Region .sp REGION entity (\fI\%DXF Reference\fP) created by an ACIS geometry kernel provided by the \fI\%Spatial Corp.\fP .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP has only very limited support for ACIS based entities, for more information see the FAQ: \fI\%How to add/edit ACIS based entities like 3DSOLID, REGION or SURFACE?\fP .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Body\fP T} _ T{ DXF type T} T{ \fB\(aqREGION\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_region()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Region Same attributes and methods as parent class \fI\%Body\fP\&. .UNINDENT .SS Shape .sp The SHAPE entity (\fI\%DXF Reference\fP) is used like a block references, each SHAPE reference can be scaled and rotated individually. The SHAPE definitions are stored in external shape files (*.SHX), and \fIezdxf\fP can not load or create these shape files. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqSHAPE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_shape()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Shape .INDENT 7.0 .TP .B dxf.insert Insertion location as (2D/3D Point in \fI\%WCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.name Shape name (str) .UNINDENT .INDENT 7.0 .TP .B dxf.size Shape size (float) .UNINDENT .INDENT 7.0 .TP .B dxf.rotation Rotation angle in degrees; default value is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.xscale Relative X scale factor (float); default value is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.oblique Oblique angle in degrees (float); default value is 0 .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%Shape\fP Transform the SHAPE entity by transformation matrix \fIm\fP inplace. .UNINDENT .UNINDENT .SS Solid .sp The SOLID entity (\fI\%DXF Reference\fP) is a filled triangle or quadrilateral. Access vertices by name (\fBentity.dxf.vtx0 = (1.7, 2.3)\fP) or by index (\fBentity[0] = (1.7, 2.3)\fP). If only 3 vertices are provided the last (3rd) vertex will be repeated in the DXF file. .sp The SOLID entity stores the vertices in an unusual way, the last two vertices are reversed: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_solid([(0, 0), (10, 0), (10, 10), (0, 10)]) .EE .UNINDENT .UNINDENT [image] .sp Reverse the last two vertices to get the \fIexpected\fP square: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_solid([(0, 0), (10, 0), (0, 10), (10, 10)]) .EE .UNINDENT .UNINDENT [image] .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The quirky vertex order is preserved at the lowest access level because \fIezdxf\fP is intended as a DXF file format interface and presents the content of the DXF document to the package user as natively as possible. .sp The \fI\%Solid.vertices()\fP and \fI\%Solid.wcs_vertices()\fP methods return the vertices in the \fIexpected\fP (reversed) order. .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqSOLID\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_solid()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Solid .INDENT 7.0 .TP .B dxf.vtx0 Location of 1. vertex (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx1 Location of 2. vertex (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx2 Location of 3. vertex (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx3 Location of 4. vertex (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Solid Transform the SOLID/TRACE entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B vertices(close: bool = False) -> list[\fI\%Vec3\fP] Returns OCS vertices in correct order, if argument \fIclose\fP is \fBTrue\fP, last vertex == first vertex. Does \fBnot\fP return the duplicated last vertex if the entity represents a triangle. .UNINDENT .INDENT 7.0 .TP .B wcs_vertices(close: bool = False) -> list[\fI\%Vec3\fP] Returns WCS vertices in correct order, if argument \fIclose\fP is \fBTrue\fP, last vertex == first vertex. Does \fBnot\fP return the duplicated last vertex if the entity represents a triangle. .UNINDENT .UNINDENT .SS Spline .sp The SPLINE entity (\fI\%DXF Reference\fP) is a 3D curve, all coordinates have to be 3D coordinates even if the spline is just a 2D planar curve. .sp The spline curve is defined by control points, knot values and weights. The control points establish the spline, the various types of knot vector determines the shape of the curve and the weights of rational splines define how strong a control point influences the shape. .sp A SPLINE can be created just from fit points \- knot values and weights are optional (tested with AutoCAD 2010). If you add additional data, be sure you know what you do, because invalid data may invalidate the whole DXF file. .sp The function \fI\%ezdxf.math.fit_points_to_cad_cv()\fP calculates control vertices from given fit points. This control vertices define a cubic B\-spline which matches visually the SPLINE entities created by BricsCAD and AutoCAD from fit points. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Wikipedia\fP article about B_splines .IP \(bu 2 Department of Computer Science and Technology at the \fI\%Cambridge\fP University .IP \(bu 2 \fI\%Tutorial for Spline\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqSPLINE\(aq\fP T} _ T{ Factory function T} T{ see table below T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .SS Factory Functions .TS center; |l|l|. _ T{ Basic spline entity T} T{ \fI\%add_spline()\fP T} _ T{ Spline control frame from fit points T} T{ \fI\%add_spline_control_frame()\fP T} _ T{ Open uniform spline T} T{ \fI\%add_open_spline()\fP T} _ T{ Closed uniform spline T} T{ \fBadd_closed_spline()\fP T} _ T{ Open rational uniform spline T} T{ \fI\%add_rational_spline()\fP T} _ T{ Closed rational uniform spline T} T{ \fBadd_closed_rational_spline()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Spline All points in \fI\%WCS\fP as (x, y, z) tuples .INDENT 7.0 .TP .B dxf.degree Degree of the spline curve (int). .UNINDENT .INDENT 7.0 .TP .B dxf.flags Bit coded option flags, constants defined in \fI\%ezdxf.lldxf.const\fP: .TS center; |l|l|l|. _ T{ dxf.flags T} T{ Value T} T{ Description T} _ T{ CLOSED_SPLINE T} T{ 1 T} T{ Spline is closed T} _ T{ PERIODIC_SPLINE T} T{ 2 T} T{ T} _ T{ RATIONAL_SPLINE T} T{ 4 T} T{ T} _ T{ PLANAR_SPLINE T} T{ 8 T} T{ T} _ T{ LINEAR_SPLINE T} T{ 16 T} T{ planar bit is also set T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.n_knots Count of knot values (int), automatically set by \fIezdxf\fP (read only) .UNINDENT .INDENT 7.0 .TP .B dxf.n_fit_points Count of fit points (int), automatically set by ezdxf (read only) .UNINDENT .INDENT 7.0 .TP .B dxf.n_control_points Count of control points (int), automatically set by ezdxf (read only) .UNINDENT .INDENT 7.0 .TP .B dxf.knot_tolerance Knot tolerance (float); default is 1e\-10 .UNINDENT .INDENT 7.0 .TP .B dxf.fit_tolerance Fit tolerance (float); default is 1e\-10 .UNINDENT .INDENT 7.0 .TP .B dxf.control_point_tolerance Control point tolerance (float); default is 1e\-10 .UNINDENT .INDENT 7.0 .TP .B dxf.start_tangent Start tangent vector as 3D vector in \fI\%WCS\fP .UNINDENT .INDENT 7.0 .TP .B dxf.end_tangent End tangent vector as 3D vector in \fI\%WCS\fP .UNINDENT .INDENT 7.0 .TP .B closed \fBTrue\fP if spline is closed. A closed spline has a connection from the last control point to the first control point. (read/write) .UNINDENT .INDENT 7.0 .TP .B control_points \fI\%VertexArray\fP of control points in \fI\%WCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B fit_points \fI\%VertexArray\fP of fit points in \fI\%WCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B knots Knot values as \fBarray.array(\(aqd\(aq)\fP\&. .UNINDENT .INDENT 7.0 .TP .B weights Control point weights as \fBarray.array(\(aqd\(aq)\fP\&. .UNINDENT .INDENT 7.0 .TP .B control_point_count() -> int Count of control points. .UNINDENT .INDENT 7.0 .TP .B fit_point_count() -> int Count of fit points. .UNINDENT .INDENT 7.0 .TP .B knot_count() -> int Count of knot values. .UNINDENT .INDENT 7.0 .TP .B construction_tool() -> \fI\%BSpline\fP Returns the construction tool \fI\%ezdxf.math.BSpline\fP\&. .UNINDENT .INDENT 7.0 .TP .B apply_construction_tool(s) -> Spline Apply SPLINE data from a \fI\%BSpline\fP construction tool or from a \fBgeomdl.BSpline.Curve\fP object. .UNINDENT .INDENT 7.0 .TP .B flattening(distance: float, segments: int = 4) -> Iterator[\fI\%Vec3\fP] Adaptive recursive flattening. The argument \fIsegments\fP is the minimum count of approximation segments between two knots, if the distance from the center of the approximation segment to the curve is bigger than \fIdistance\fP the segment will be subdivided. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the projected curve point onto the segment chord. .IP \(bu 2 \fBsegments\fP – minimum segment count between two knots .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_open_uniform(control_points: Sequence[\fI\%UVec\fP], degree: int = 3) -> None Open B\-spline with a uniform knot vector, start and end at your first and last control points. .UNINDENT .INDENT 7.0 .TP .B set_uniform(control_points: Sequence[\fI\%UVec\fP], degree: int = 3) -> None B\-spline with a uniform knot vector, does NOT start and end at your first and last control points. .UNINDENT .INDENT 7.0 .TP .B set_closed(control_points: Sequence[\fI\%UVec\fP], degree=3) -> None Closed B\-spline with a uniform knot vector, start and end at your first control point. .UNINDENT .INDENT 7.0 .TP .B set_open_rational(control_points: Sequence[\fI\%UVec\fP], weights: Sequence[float], degree: int = 3) -> None Open rational B\-spline with a uniform knot vector, start and end at your first and last control points, and has additional control possibilities by weighting each control point. .UNINDENT .INDENT 7.0 .TP .B set_uniform_rational(control_points: Sequence[\fI\%UVec\fP], weights: Sequence[float], degree: int = 3) -> None Rational B\-spline with a uniform knot vector, does NOT start and end at your first and last control points, and has additional control possibilities by weighting each control point. .UNINDENT .INDENT 7.0 .TP .B set_closed_rational(control_points: Sequence[\fI\%UVec\fP], weights: Sequence[float], degree: int = 3) -> None Closed rational B\-spline with a uniform knot vector, start and end at your first control point, and has additional control possibilities by weighting each control point. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Spline Transform the SPLINE entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B classmethod from_arc(entity: DXFGraphic) -> Spline Create a new SPLINE entity from a CIRCLE, ARC or ELLIPSE entity. .sp The new SPLINE entity has no owner, no handle, is not stored in the entity database nor assigned to any layout! .UNINDENT .UNINDENT .SS Surface .sp SURFACE entity (\fI\%DXF Reference\fP) created by an ACIS geometry kernel provided by the \fI\%Spatial Corp.\fP .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fIEzdxf\fP has only very limited support for ACIS based entities, for more information see the FAQ: \fI\%How to add/edit ACIS based entities like 3DSOLID, REGION or SURFACE?\fP .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Body\fP T} _ T{ DXF type T} T{ \fB\(aqSURFACE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_surface()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Surface Same attributes and methods as parent class \fI\%Body\fP\&. .INDENT 7.0 .TP .B dxf.u_count Number of U isolines. .UNINDENT .INDENT 7.0 .TP .B dxf.v_count Number of V2 isolines. .UNINDENT .UNINDENT .SS ExtrudedSurface .sp (\fI\%DXF Reference\fP) .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Surface\fP T} _ T{ DXF type T} T{ \fB\(aqEXTRUDEDSURFACE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_extruded_surface()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2007 (\fB\(aqAC1021\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.ExtrudedSurface Same attributes and methods as parent class \fI\%Surface\fP\&. .INDENT 7.0 .TP .B dxf.class_id .UNINDENT .INDENT 7.0 .TP .B dxf.sweep_vector .UNINDENT .INDENT 7.0 .TP .B dxf.draft_angle .UNINDENT .INDENT 7.0 .TP .B dxf.draft_start_distance .UNINDENT .INDENT 7.0 .TP .B dxf.draft_end_distance .UNINDENT .INDENT 7.0 .TP .B dxf.twist_angle .UNINDENT .INDENT 7.0 .TP .B dxf.scale_factor .UNINDENT .INDENT 7.0 .TP .B dxf.align_angle .UNINDENT .INDENT 7.0 .TP .B dxf.solid .UNINDENT .INDENT 7.0 .TP .B dxf.sweep_alignment_flags .TS center; |l|l|. _ T{ 0 T} T{ No alignment T} _ T{ 1 T} T{ Align sweep entity to path T} _ T{ 2 T} T{ Translate sweep entity to path T} _ T{ 3 T} T{ Translate path to sweep entity T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.align_start .UNINDENT .INDENT 7.0 .TP .B dxf.bank .UNINDENT .INDENT 7.0 .TP .B dxf.base_point_set .UNINDENT .INDENT 7.0 .TP .B dxf.sweep_entity_transform_computed .UNINDENT .INDENT 7.0 .TP .B dxf.path_entity_transform_computed .UNINDENT .INDENT 7.0 .TP .B dxf.reference_vector_for_controlling_twist .UNINDENT .INDENT 7.0 .TP .B transformation_matrix_extruded_entity type: \fI\%Matrix44\fP .UNINDENT .INDENT 7.0 .TP .B sweep_entity_transformation_matrix type: \fI\%Matrix44\fP .UNINDENT .INDENT 7.0 .TP .B path_entity_transformation_matrix type: \fI\%Matrix44\fP .UNINDENT .UNINDENT .SS LoftedSurface .sp (\fI\%DXF Reference\fP) .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Surface\fP T} _ T{ DXF type T} T{ \fB\(aqLOFTEDSURFACE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_lofted_surface()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2007 (\fB\(aqAC1021\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.LoftedSurface Same attributes and methods as parent class \fI\%Surface\fP\&. .INDENT 7.0 .TP .B dxf.plane_normal_lofting_type .UNINDENT .INDENT 7.0 .TP .B dxf.start_draft_angle .UNINDENT .INDENT 7.0 .TP .B dxf.end_draft_angle .UNINDENT .INDENT 7.0 .TP .B dxf.start_draft_magnitude .UNINDENT .INDENT 7.0 .TP .B dxf.end_draft_magnitude .UNINDENT .INDENT 7.0 .TP .B dxf.arc_length_parameterization .UNINDENT .INDENT 7.0 .TP .B dxf.no_twist .UNINDENT .INDENT 7.0 .TP .B dxf.align_direction .UNINDENT .INDENT 7.0 .TP .B dxf.simple_surfaces .UNINDENT .INDENT 7.0 .TP .B dxf.closed_surfaces .UNINDENT .INDENT 7.0 .TP .B dxf.solid .UNINDENT .INDENT 7.0 .TP .B dxf.ruled_surface .UNINDENT .INDENT 7.0 .TP .B dxf.virtual_guide .UNINDENT .INDENT 7.0 .TP .B set_transformation_matrix_lofted_entity type: \fI\%Matrix44\fP .UNINDENT .UNINDENT .SS RevolvedSurface .sp (\fI\%DXF Reference\fP) .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Surface\fP T} _ T{ DXF type T} T{ \fB\(aqREVOLVEDSURFACE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_revolved_surface()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2007 (\fB\(aqAC1021\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.RevolvedSurface Same attributes and methods as parent class \fI\%Surface\fP\&. .INDENT 7.0 .TP .B dxf.class_id .UNINDENT .INDENT 7.0 .TP .B dxf.axis_point .UNINDENT .INDENT 7.0 .TP .B dxf.axis_vector .UNINDENT .INDENT 7.0 .TP .B dxf.revolve_angle .UNINDENT .INDENT 7.0 .TP .B dxf.start_angle .UNINDENT .INDENT 7.0 .TP .B dxf.draft_angle .UNINDENT .INDENT 7.0 .TP .B dxf.start_draft_distance .UNINDENT .INDENT 7.0 .TP .B dxf.end_draft_distance .UNINDENT .INDENT 7.0 .TP .B dxf.twist_angle .UNINDENT .INDENT 7.0 .TP .B dxf.solid .UNINDENT .INDENT 7.0 .TP .B dxf.close_to_axis .UNINDENT .INDENT 7.0 .TP .B transformation_matrix_revolved_entity type: \fI\%Matrix44\fP .UNINDENT .UNINDENT .SS SweptSurface .sp (\fI\%DXF Reference\fP) .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Surface\fP T} _ T{ DXF type T} T{ \fB\(aqSWEPTSURFACE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_swept_surface()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2007 (\fB\(aqAC1021\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.SweptSurface Same attributes and methods as parent class \fI\%Surface\fP\&. .INDENT 7.0 .TP .B dxf.swept_entity_id .UNINDENT .INDENT 7.0 .TP .B dxf.path_entity_id .UNINDENT .INDENT 7.0 .TP .B dxf.draft_angle .UNINDENT .INDENT 7.0 .TP .B draft_start_distance .UNINDENT .INDENT 7.0 .TP .B dxf.draft_end_distance .UNINDENT .INDENT 7.0 .TP .B dxf.twist_angle .UNINDENT .INDENT 7.0 .TP .B dxf.scale_factor .UNINDENT .INDENT 7.0 .TP .B dxf.align_angle .UNINDENT .INDENT 7.0 .TP .B dxf.solid .UNINDENT .INDENT 7.0 .TP .B dxf.sweep_alignment .UNINDENT .INDENT 7.0 .TP .B dxf.align_start .UNINDENT .INDENT 7.0 .TP .B dxf.bank .UNINDENT .INDENT 7.0 .TP .B dxf.base_point_set .UNINDENT .INDENT 7.0 .TP .B dxf.sweep_entity_transform_computed .UNINDENT .INDENT 7.0 .TP .B dxf.path_entity_transform_computed .UNINDENT .INDENT 7.0 .TP .B dxf.reference_vector_for_controlling_twist .UNINDENT .INDENT 7.0 .TP .B transformation_matrix_sweep_entity type: \fI\%Matrix44\fP .UNINDENT .INDENT 7.0 .TP .B transformation_matrix_path_entity() type: \fI\%Matrix44\fP .UNINDENT .INDENT 7.0 .TP .B sweep_entity_transformation_matrix() type: \fI\%Matrix44\fP .UNINDENT .INDENT 7.0 .TP .B path_entity_transformation_matrix() type: \fI\%Matrix44\fP .UNINDENT .UNINDENT .SS Text .sp The TEXT entity (\fI\%DXF Reference\fP) represents a single line of text. The \fI\%style\fP attribute stores the associated \fI\%Textstyle\fP entity as string, which defines the basic font properties. The text size is stored as cap\-height in the \fI\%height\fP attribute in drawing units. Text alignments are defined as enums of type \fI\%ezdxf.enums.TextEntityAlignment\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 See the documentation for the \fI\%Textstyle\fP class to understand the limitations of text representation in the DXF format. .sp \fI\%Tutorial for Text\fP .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqTEXT\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_text()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Text .INDENT 7.0 .TP .B dxf.text Text content as string. .UNINDENT .INDENT 7.0 .TP .B dxf.insert First alignment point of text (2D/3D Point in \fI\%OCS\fP), relevant for the adjustments LEFT, ALIGNED and FIT. .UNINDENT .INDENT 7.0 .TP .B dxf.align_point The main alignment point of text (2D/3D Point in \fI\%OCS\fP), if the alignment is anything else than LEFT, or the second alignment point for the ALIGNED and FIT alignments. .UNINDENT .INDENT 7.0 .TP .B dxf.height Text height in drawing units as float value, the default value is 1. .UNINDENT .INDENT 7.0 .TP .B dxf.rotation Text rotation in degrees as float value, the default value is 0. .UNINDENT .INDENT 7.0 .TP .B dxf.oblique Text oblique angle (slanting) in degrees as float value, the default value is 0 (straight vertical text). .UNINDENT .INDENT 7.0 .TP .B dxf.style \fI\%Textstyle\fP name as case insensitive string, the default value is “Standard” .UNINDENT .INDENT 7.0 .TP .B dxf.width Width scale factor as float value, the default value is 1. .UNINDENT .INDENT 7.0 .TP .B dxf.halign Horizontal alignment flag as int value, use the \fI\%set_placement()\fP and \fI\%get_align_enum()\fP methods to handle text alignment, the default value is 0. .TS center; |l|l|. _ T{ 0 T} T{ Left T} _ T{ 2 T} T{ Right T} _ T{ 3 T} T{ Aligned (if vertical alignment = 0) T} _ T{ 4 T} T{ Middle (if vertical alignment = 0) T} _ T{ 5 T} T{ Fit (if vertical alignment = 0) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.valign Vertical alignment flag as int value, use the \fI\%set_placement()\fP and \fI\%get_align_enum()\fP methods to handle text alignment, the default value is 0. .TS center; |l|l|. _ T{ 0 T} T{ Baseline T} _ T{ 1 T} T{ Bottom T} _ T{ 2 T} T{ Middle T} _ T{ 3 T} T{ Top T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_generation_flag Text generation flags as int value, use the \fBis_backward\fP and \fBis_upside_down\fP attributes to handle this flags. .TS center; |l|l|. _ T{ 2 T} T{ text is backward (mirrored in X) T} _ T{ 4 T} T{ text is upside down (mirrored in Y) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B property is_backward: bool Get/set text generation flag BACKWARDS, for mirrored text along the x\-axis. .UNINDENT .INDENT 7.0 .TP .B property is_upside_down: bool Get/set text generation flag UPSIDE_DOWN, for mirrored text along the y\-axis. .UNINDENT .INDENT 7.0 .TP .B set_placement(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP | None = None, align: \fI\%TextEntityAlignment\fP | None = None) -> Text Set text alignment and location. .sp The alignments \fBALIGNED\fP and \fBFIT\fP are special, they require a second alignment point, the text is aligned on the virtual line between these two points and sits vertically at the baseline. .INDENT 7.0 .IP \(bu 2 \fBALIGNED\fP: Text is stretched or compressed to fit exactly between \fIp1\fP and \fIp2\fP and the text height is also adjusted to preserve height/width ratio. .IP \(bu 2 \fBFIT\fP: Text is stretched or compressed to fit exactly between \fIp1\fP and \fIp2\fP but only the text width is adjusted, the text height is fixed by the \fI\%dxf.height\fP attribute. .IP \(bu 2 \fBMIDDLE\fP: also a special adjustment, centered text like \fBMIDDLE_CENTER\fP, but vertically centred at the total height of the text. .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – first alignment point as (x, y[, z]) .IP \(bu 2 \fBp2\fP – second alignment point as (x, y[, z]), required for \fBALIGNED\fP and \fBFIT\fP else ignored .IP \(bu 2 \fBalign\fP – new alignment as enum \fI\%TextEntityAlignment\fP, \fBNone\fP to preserve the existing alignment. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_placement() -> tuple[\fI\%TextEntityAlignment\fP, \fI\%Vec3\fP, \fI\%Vec3\fP | None] Returns a tuple (\fIalign\fP, \fIp1\fP, \fIp2\fP), \fIalign\fP is the alignment enum \fBTextEntityAlignment\fP, \fIp1\fP is the alignment point, \fIp2\fP is only relevant if \fIalign\fP is \fBALIGNED\fP or \fBFIT\fP, otherwise it is \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_align_enum() -> \fI\%TextEntityAlignment\fP Returns the current text alignment as \fI\%TextEntityAlignment\fP, see also \fI\%set_placement()\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_align_enum(align=TextEntityAlignment.LEFT) -> Text Just for experts: Sets the text alignment without setting the alignment points, set adjustment points attr:\fIdxf.insert\fP and \fI\%dxf.align_point\fP manually. .INDENT 7.0 .TP .B Parameters \fBalign\fP – \fI\%TextEntityAlignment\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Text Transform the TEXT entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> Text Optimized TEXT/ATTRIB/ATTDEF translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis, returns \fIself\fP\&. .UNINDENT .INDENT 7.0 .TP .B plain_text() -> str Returns text content without formatting codes. .UNINDENT .INDENT 7.0 .TP .B font_name() -> str Returns the font name of the associated \fI\%Textstyle\fP\&. .UNINDENT .INDENT 7.0 .TP .B fit_length() -> float Returns the text length for alignments \fBTextEntityAlignment.FIT\fP and \fBTextEntityAlignment.ALIGNED\fP, defined by the distance from the insertion point to the align point or 0 for all other alignments. .UNINDENT .UNINDENT .SS Trace .sp The TRACE entity (\fI\%DXF Reference\fP) is solid filled triangle or quadrilateral. Access vertices by name (\fBentity.dxf.vtx0 = (1.7, 2.3)\fP) or by index (\fBentity[0] = (1.7, 2.3)\fP). If only 3 vertices are provided the last (3rd) vertex will be repeated in the DXF file. .sp The TRACE entity stores the vertices in an unusual way, the last two vertices are reversed: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_solid([(0, 0), (10, 0), (10, 10), (0, 10)]) .EE .UNINDENT .UNINDENT [image] .sp Reverse the last two vertices to get the \fIexpected\fP square: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_solid([(0, 0), (10, 0), (0, 10), (10, 10)]) .EE .UNINDENT .UNINDENT [image] .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The quirky vertex order is preserved at the lowest access level because \fIezdxf\fP is intended as a DXF file format interface and presents the content of the DXF document to the package user as natively as possible. .sp The \fI\%Trace.vertices()\fP and \fI\%Trace.wcs_vertices()\fP methods return the vertices in the \fIexpected\fP (reversed) order. .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqTRACE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_trace()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Trace .INDENT 7.0 .TP .B dxf.vtx0 Location of 1. vertex (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx1 Location of 2. vertex (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx2 Location of 3. vertex (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx3 Location of 4. vertex (2D/3D Point in \fI\%OCS\fP) .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Solid Transform the SOLID/TRACE entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B vertices(close: bool = False) -> list[\fI\%Vec3\fP] Returns OCS vertices in correct order, if argument \fIclose\fP is \fBTrue\fP, last vertex == first vertex. Does \fBnot\fP return the duplicated last vertex if the entity represents a triangle. .UNINDENT .INDENT 7.0 .TP .B wcs_vertices(close: bool = False) -> list[\fI\%Vec3\fP] Returns WCS vertices in correct order, if argument \fIclose\fP is \fBTrue\fP, last vertex == first vertex. Does \fBnot\fP return the duplicated last vertex if the entity represents a triangle. .UNINDENT .UNINDENT .SS Underlay .sp The UNDERLAY entity (\fI\%DXF Reference\fP) links an underlay file to the DXF file, the file itself is not embedded into the DXF file, it is always a separated file. The (PDF)UNDERLAY entity is like a block reference, you can use it multiple times to add the underlay on different locations with different scales and rotations. But therefore you need a also a (PDF)DEFINITION entity, see \fI\%UnderlayDefinition\fP\&. .sp The DXF standard supports three different file formats: PDF, DWF (DWFx) and DGN. An Underlay can be clipped by a rectangle or a polygon path. The clipping coordinates are 2D \fI\%OCS\fP coordinates in drawing units but without scaling. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ internal base class T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_underlay()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Underlay Base class of \fI\%PdfUnderlay\fP, \fI\%DwfUnderlay\fP and \fI\%DgnUnderlay\fP .INDENT 7.0 .TP .B dxf.insert Insertion point, lower left corner of the image in \fI\%OCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.scale_x Scaling factor in x\-direction (float) .UNINDENT .INDENT 7.0 .TP .B dxf.scale_y Scaling factor in y\-direction (float) .UNINDENT .INDENT 7.0 .TP .B dxf.scale_z Scaling factor in z\-direction (float) .UNINDENT .INDENT 7.0 .TP .B dxf.rotation ccw rotation in degrees around the extrusion vector (float) .UNINDENT .INDENT 7.0 .TP .B dxf.extrusion extrusion vector, default is (0, 0, 1) .UNINDENT .INDENT 7.0 .TP .B dxf.underlay_def_handle Handle to the underlay definition entity, see \fI\%UnderlayDefinition\fP .UNINDENT .INDENT 7.0 .TP .B dxf.flags .TS center; |l|l|l|. _ T{ \fBdxf.flags\fP T} T{ Value T} T{ Description T} _ T{ UNDERLAY_CLIPPING T} T{ 1 T} T{ clipping is on/off T} _ T{ UNDERLAY_ON T} T{ 2 T} T{ underlay is on/off T} _ T{ UNDERLAY_MONOCHROME T} T{ 4 T} T{ Monochrome T} _ T{ UNDERLAY_ADJUST_FOR_BACKGROUND T} T{ 8 T} T{ Adjust for background T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.contrast Contrast value (20 \- 100; default is 100) .UNINDENT .INDENT 7.0 .TP .B dxf.fade Fade value (0 \- 80; default is 0) .UNINDENT .INDENT 7.0 .TP .B clipping \fBTrue\fP or \fBFalse\fP (read/write) .UNINDENT .INDENT 7.0 .TP .B on \fBTrue\fP or \fBFalse\fP (read/write) .UNINDENT .INDENT 7.0 .TP .B monochrome \fBTrue\fP or \fBFalse\fP (read/write) .UNINDENT .INDENT 7.0 .TP .B adjust_for_background \fBTrue\fP or \fBFalse\fP (read/write) .UNINDENT .INDENT 7.0 .TP .B scale Scaling (x, y, z) tuple (read/write) .UNINDENT .INDENT 7.0 .TP .B boundary_path Boundary path as list of vertices (read/write). .sp Two vertices describe a rectangle (lower left and upper right corner), more than two vertices is a polygon as clipping path. .UNINDENT .INDENT 7.0 .TP .B get_underlay_def() Returns the associated DEFINITION entity. see \fI\%UnderlayDefinition\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_underlay_def() Set the associated DEFINITION entity. see \fI\%UnderlayDefinition\fP\&. .UNINDENT .INDENT 7.0 .TP .B reset_boundary_path() -> None Removes the clipping path. .UNINDENT .UNINDENT .SS PdfUnderlay .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Underlay\fP T} _ T{ DXF type T} T{ \fB\(aqPDFUNDERLAY\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_underlay()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.PdfUnderlay PDF underlay. .UNINDENT .SS DwfUnderlay .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Underlay\fP T} _ T{ DXF type T} T{ \fB\(aqDWFUNDERLAY\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_underlay()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.DwfUnderlay DWF underlay. .UNINDENT .SS DgnUnderlay .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Underlay\fP T} _ T{ DXF type T} T{ \fB\(aqDGNUNDERLAY\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_underlay()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.DgnUnderlay DGN underlay. .UNINDENT .SS Viewport .sp The VIEWPORT entity (\fI\%DXF Reference\fP) is a window from a paperspace layout to the modelspace. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqVIEWPORT\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.Paperspace.add_viewport()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Viewport .INDENT 7.0 .TP .B dxf.center Center point of the viewport located in the paper space layout in paper space units stored as 3D point. (Error in the DXF reference) .UNINDENT .INDENT 7.0 .TP .B dxf.width Viewport width in paperspace units (float) .UNINDENT .INDENT 7.0 .TP .B dxf.height Viewport height in paperspace units (float) .UNINDENT .INDENT 7.0 .TP .B dxf.status Viewport status field (int) .TS center; |l|l|. _ T{ \-1 T} T{ On, but is fully off screen, or is one of the viewports that is not active because the $MAXACTVP count is currently being exceeded. T} _ T{ 0 T} T{ Off T} _ T{ >0 T} T{ On and active. The value indicates the order of stacking for the viewports, where 1 is the active viewport, 2 is the next, and so forth. T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.id Viewport id (int) .UNINDENT .INDENT 7.0 .TP .B dxf.view_center_point View center point in modelspace stored as 2D point, but represents a \fI\%WCS\fP point. (Error in the DXF reference) .UNINDENT .INDENT 7.0 .TP .B dxf.snap_base_point .UNINDENT .INDENT 7.0 .TP .B dxf.snap_spacing .UNINDENT .INDENT 7.0 .TP .B dxf.snap_angle .UNINDENT .INDENT 7.0 .TP .B dxf.grid_spacing .UNINDENT .INDENT 7.0 .TP .B dxf.view_direction_vector View direction (3D vector in \fI\%WCS\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.view_target_point View target point (3D point in \fI\%WCS\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.perspective_lens_length Lens focal length in mm as 35mm film equivalent. .UNINDENT .INDENT 7.0 .TP .B dxf.front_clip_plane_z_value .UNINDENT .INDENT 7.0 .TP .B dxf.back_clip_plane_z_value .UNINDENT .INDENT 7.0 .TP .B dxf.view_height View height in \fI\%WCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.view_twist_angle .UNINDENT .INDENT 7.0 .TP .B dxf.circle_zoom .UNINDENT .INDENT 7.0 .TP .B dxf.flags Viewport status bit\-coded flags: .TS center; |l|l|l|. _ T{ Bit value T} T{ Constant in \fBezdxf.const\fP T} T{ Description T} _ T{ 1 (0x1) T} T{ VSF_PERSPECTIVE_MODE T} T{ Enables perspective mode T} _ T{ 2 (0x2) T} T{ VSF_FRONT_CLIPPING T} T{ Enables front clipping T} _ T{ 4 (0x4) T} T{ VSF_BACK_CLIPPING T} T{ Enables back clipping T} _ T{ 8 (0x8) T} T{ VSF_USC_FOLLOW T} T{ Enables UCS follow T} _ T{ 16 (0x10) T} T{ VSF_FRONT_CLIPPING_NOT_AT_EYE T} T{ Enables front clip not at eye T} _ T{ 32 (0x20) T} T{ VSF_UCS_ICON_VISIBILITY T} T{ Enables UCS icon visibility T} _ T{ 64 (0x40) T} T{ VSF_UCS_ICON_AT_ORIGIN T} T{ Enables UCS icon at origin T} _ T{ 128 (0x80) T} T{ VSF_FAST_ZOOM T} T{ Enables fast zoom T} _ T{ 256 (0x100) T} T{ VSF_SNAP_MODE T} T{ Enables snap mode T} _ T{ 512 (0x200) T} T{ VSF_GRID_MODE T} T{ Enables grid mode T} _ T{ 1024 (0x400) T} T{ VSF_ISOMETRIC_SNAP_STYLE T} T{ Enables isometric snap style T} _ T{ 2048 (0x800) T} T{ VSF_HIDE_PLOT_MODE T} T{ Enables hide plot mode T} _ T{ 4096 (0x1000) T} T{ VSF_KISOPAIR_TOP T} T{ kIsoPairTop. If set and kIsoPairRight is not set, then isopair top is enabled. If both kIsoPairTop and kIsoPairRight are set, then isopair left is enabled T} _ T{ 8192 (0x2000) T} T{ VSF_KISOPAIR_RIGHT T} T{ kIsoPairRight. If set and kIsoPairTop is not set, then isopair right is enabled T} _ T{ 16384 (0x4000) T} T{ VSF_LOCK_ZOOM T} T{ Enables viewport zoom locking T} _ T{ 32768 (0x8000) T} T{ VSF_CURRENTLY_ALWAYS_ENABLED T} T{ Currently always enabled T} _ T{ 65536 (0x10000) T} T{ VSF_NON_RECTANGULAR_CLIPPING T} T{ Enables non\-rectangular clipping T} _ T{ 131072 (0x20000) T} T{ VSF_TURN_VIEWPORT_OFF T} T{ Turns the viewport off T} _ T{ 262144 (0x40000) T} T{ VSF_NO_GRID_LIMITS T} T{ Enables the display of the grid beyond the drawing limits T} _ T{ 524288 (0x80000) T} T{ VSF_ADAPTIVE_GRID_DISPLAY T} T{ Enable adaptive grid display T} _ T{ 1048576 (0x100000) T} T{ VSF_SUBDIVIDE_GRID T} T{ Enables subdivision of the grid below the set grid spacing when the grid display is adaptive T} _ T{ 2097152 (0x200000) T} T{ VSF_GRID_FOLLOW_WORKPLANE T} T{ Enables grid follows workplane switching T} _ .TE .sp Use helper method \fI\%set_flag_state()\fP to set and clear viewport flags, e.g. lock viewport: .INDENT 7.0 .INDENT 3.5 .sp .EX vp.set_flag_state(ezdxf.const.VSF_LOCK_ZOOM, True) .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxf.clipping_boundary_handle .UNINDENT .INDENT 7.0 .TP .B dxf.plot_style_name .UNINDENT .INDENT 7.0 .TP .B dxf.render_mode .TS center; |l|l|. _ T{ 0 T} T{ 2D Optimized (classic 2D) T} _ T{ 1 T} T{ Wireframe T} _ T{ 2 T} T{ Hidden line T} _ T{ 3 T} T{ Flat shaded T} _ T{ 4 T} T{ Gouraud shaded T} _ T{ 5 T} T{ Flat shaded with wireframe T} _ T{ 6 T} T{ Gouraud shaded with wireframe T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_per_viewport .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_icon .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_origin UCS origin as 3D point. .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_x_axis UCS x\-axis as 3D vector. .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_y_axis UCS y\-axis as 3D vector. .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_handle Handle of \fBUCSTable\fP if UCS is a named UCS. If not present, then UCS is unnamed. .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_ortho_type .TS center; |l|l|. _ T{ 0 T} T{ not orthographic T} _ T{ 1 T} T{ Top T} _ T{ 2 T} T{ Bottom T} _ T{ 3 T} T{ Front T} _ T{ 4 T} T{ Back T} _ T{ 5 T} T{ Left T} _ T{ 6 T} T{ Right T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_base_handle Handle of \fBUCSTable\fP of base UCS if UCS is orthographic (\fI\%Viewport.dxf.ucs_ortho_type\fP is non\-zero). If not present and \fI\%Viewport.dxf.ucs_ortho_type\fP is non\-zero, then base UCS is taken to be WORLD. .UNINDENT .INDENT 7.0 .TP .B dxf.elevation .UNINDENT .INDENT 7.0 .TP .B dxf.shade_plot_mode (DXF R2004) .TS center; |l|l|. _ T{ 0 T} T{ As Displayed T} _ T{ 1 T} T{ Wireframe T} _ T{ 2 T} T{ Hidden T} _ T{ 3 T} T{ Rendered T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.grid_frequency Frequency of major grid lines compared to minor grid lines. (DXF R2007) .UNINDENT .INDENT 7.0 .TP .B dxf.background_handle .UNINDENT .INDENT 7.0 .TP .B dxf.shade_plot_handle .UNINDENT .INDENT 7.0 .TP .B dxf.visual_style_handle .UNINDENT .INDENT 7.0 .TP .B dxf.default_lighting_flag .UNINDENT .INDENT 7.0 .TP .B dxf.default_lighting_style .TS center; |l|l|. _ T{ 0 T} T{ One distant light T} _ T{ 1 T} T{ Two distant lights T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.view_brightness .UNINDENT .INDENT 7.0 .TP .B dxf.view_contrast .UNINDENT .INDENT 7.0 .TP .B dxf.ambient_light_color_1 as \fI\%AutoCAD Color Index (ACI)\fP .UNINDENT .INDENT 7.0 .TP .B dxf.ambient_light_color_2 as true color value .UNINDENT .INDENT 7.0 .TP .B dxf.ambient_light_color_3 as true color value .UNINDENT .INDENT 7.0 .TP .B dxf.sun_handle .UNINDENT .INDENT 7.0 .TP .B dxf.ref_vp_object_1 .UNINDENT .INDENT 7.0 .TP .B dxf.ref_vp_object_2 .UNINDENT .INDENT 7.0 .TP .B dxf.ref_vp_object_3 .UNINDENT .INDENT 7.0 .TP .B dxf.ref_vp_object_4 .UNINDENT .INDENT 7.0 .TP .B frozen_layers Set/get frozen layers as list of layer names. .UNINDENT .INDENT 7.0 .TP .B is_frozen(layer_name: str) -> bool Returns \fBTrue\fP if \fIlayer_name\fP id frozen in this viewport. .UNINDENT .INDENT 7.0 .TP .B freeze(layer_name: str) -> None Freeze \fIlayer_name\fP in this viewport. .UNINDENT .INDENT 7.0 .TP .B thaw(layer_name: str) -> None Thaw \fIlayer_name\fP in this viewport. .UNINDENT .INDENT 7.0 .TP .B has_extended_clipping_path Returns \fBTrue\fP if a non\-rectangular clipping path is defined. .UNINDENT .INDENT 7.0 .TP .B clipping_rect() -> tuple[\fI\%Vec2\fP, \fI\%Vec2\fP] Returns the lower left and the upper right corner of the clipping rectangle in paperspace coordinates. .UNINDENT .INDENT 7.0 .TP .B clipping_rect_corners() -> list[\fI\%Vec2\fP] Returns the default rectangular clipping path as list of vertices. Use function \fI\%ezdxf.path.make_path()\fP to get also non\-rectangular shaped clipping paths if defined. .UNINDENT .INDENT 7.0 .TP .B get_aspect_ratio() -> float Returns the aspect ratio of the viewport, return 0.0 if width or height is zero. .UNINDENT .INDENT 7.0 .TP .B get_modelspace_limits() -> tuple[float, float, float, float] Returns the limits of the modelspace to view in drawing units as tuple (min_x, min_y, max_x, max_y). .UNINDENT .INDENT 7.0 .TP .B get_scale() -> float Returns the scaling factor from modelspace to viewport. .UNINDENT .INDENT 7.0 .TP .B get_transformation_matrix() -> \fI\%Matrix44\fP Returns the transformation matrix from modelspace to paperspace coordinates. .UNINDENT .UNINDENT .SS Wipeout .sp The WIPEOUT entity (\fI\%DXF Reference\fP) is a polygonal area that masks underlying objects with the current background color. The WIPEOUT entity is based on the IMAGE entity, but usage does not require any knowledge about the IMAGE entity. .sp The handles to the support entities \fI\%ImageDef\fP and \fI\%ImageDefReactor\fP are always “0”, both are not needed by the WIPEOUT entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Image\fP T} _ T{ DXF type T} T{ \fB\(aqWIPEOUT\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_wipeout()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate entity classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Wipeout .INDENT 7.0 .TP .B set_masking_area(vertices: Iterable[\fI\%UVec\fP]) -> None Set a new masking area, the area is placed in the layout xy\-plane. .UNINDENT .UNINDENT .SS XLine .sp The XLINE entity (\fI\%DXF Reference\fP) is a construction line that extents to infinity in both directions. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqXLINE\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.BaseLayout.add_xline()\fP T} _ T{ Inherited DXF attributes T} T{ \fI\%Common graphical DXF attributes\fP T} _ T{ Required DXF version T} T{ DXF R2000 (\fB\(aqAC1015\(aq\fP) T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.XLine .INDENT 7.0 .TP .B dxf.start .UNINDENT .sp Location point of line as (3D Point in \fI\%WCS\fP) .INDENT 7.0 .TP .B dxf.unit_vector .UNINDENT .sp Unit direction vector as (3D Point in \fI\%WCS\fP) .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> XLine Transform the XLINE/RAY entity by transformation matrix \fIm\fP inplace. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> XLine Optimized XLINE/RAY translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis. .UNINDENT .UNINDENT .SS DXF Objects .sp All DXF objects can only reside in the OBJECTS section of a DXF document. .sp The purpose of the OBJECTS section is to allow CAD software developers to define and store custom objects that are not included in the basic DXF file format. These custom objects can be used to represent complex data structures, such as database tables or project management information, that are not easily represented by basic DXF entities. .sp By including custom objects in the OBJECTS section, CAD software developers can extend the functionality of their software to support new types of data and objects. For example, a custom application might define a new type of block or dimension style that is specific to a particular industry or workflow. By storing this custom object definition in the OBJECTS section, the CAD software can recognize and use the new object type in a drawing. .sp In summary, the OBJECTS section is an important part of the DXF file format because it allows CAD software developers to extend the functionality of their software by defining and storing custom objects and entity types. This makes it possible to represent complex data structures and workflows in CAD drawings, and allows CAD software to be customized to meet the specific needs of different industries and applications. .SS Dictionary .sp The \fI\%DICTIONARY\fP entity is a general storage entity. .sp AutoCAD maintains items such as MLINE_STYLES and GROUP definitions as objects in dictionaries. Other applications are free to create and use their own dictionaries as they see fit. The prefix \fB\(aqACAD_\(aq\fP is reserved for use by AutoCAD applications. .sp Dictionary entries are (key, \fI\%DXFEntity\fP) pairs for fully loaded or new created DXF documents. The referenced entities are owned by the dictionary and cannot be graphical entities that always belong to the layout in which they are located. .sp Loading DXF files is done in two passes, because at the first loading stage not all referenced objects are already stored in the entity database. Therefore the entities are stored as handles strings at the first loading stage and have to be replaced by the real entity at the second loading stage. If the entity is still a handle string after the second loading stage, the entity does not exist. .sp Dictionary keys are handled case insensitive by AutoCAD, but not by \fIezdxf\fP, in doubt use an uppercase key. AutoCAD stores all keys in uppercase. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqDICTIONARY\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_dictionary()\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate object classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Dictionary .INDENT 7.0 .TP .B dxf.hard_owned If set to 1, indicates that elements of the dictionary are to be treated as hard\-owned. .UNINDENT .INDENT 7.0 .TP .B dxf.cloning Duplicate record cloning flag (determines how to merge duplicate entries, ignored by \fIezdxf\fP): .TS center; |l|l|. _ T{ 0 T} T{ not applicable T} _ T{ 1 T} T{ keep existing T} _ T{ 2 T} T{ use clone T} _ T{ 3 T} T{ $0$ T} _ T{ 4 T} T{ $0$ T} _ T{ 5 T} T{ Unmangle name T} _ .TE .UNINDENT .INDENT 7.0 .TP .B is_hard_owner Returns \fBTrue\fP if the dictionary is hard owner of entities. Hard owned entities will be destroyed by deleting the dictionary. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of dictionary entries. .UNINDENT .INDENT 7.0 .TP .B __contains__(key: str) -> bool Returns \fIkey\fP \fBin\fP self. .UNINDENT .INDENT 7.0 .TP .B __getitem__(key: str) -> DXFEntity Return self[\fIkey\fP]. .sp The returned value can be a handle string if the entity does not exist. .INDENT 7.0 .TP .B Raises \fI\%DXFKeyError\fP – \fIkey\fP does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __setitem__(key: str, entity: DXFObject) -> None Set self[\fIkey\fP] = \fIentity\fP\&. .sp Only DXF objects stored in the OBJECTS section are allowed as content of \fI\%Dictionary\fP objects. DXF entities stored in layouts are not allowed. .INDENT 7.0 .TP .B Raises \fI\%DXFTypeError\fP – invalid DXF type .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __delitem__(key: str) -> None Delete self[\fIkey\fP]. .INDENT 7.0 .TP .B Raises \fI\%DXFKeyError\fP – \fIkey\fP does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B keys() Returns a \fBKeysView\fP of all dictionary keys. .UNINDENT .INDENT 7.0 .TP .B items() Returns an \fBItemsView\fP for all dictionary entries as (key, entity) pairs. An entity can be a handle string if the entity does not exist. .UNINDENT .INDENT 7.0 .TP .B count() -> int Returns count of dictionary entries. .UNINDENT .INDENT 7.0 .TP .B get(key: str, default: DXFObject | None = None) -> DXFObject | None Returns the \fI\%DXFEntity\fP for \fIkey\fP, if \fIkey\fP exist else \fIdefault\fP\&. An entity can be a handle string if the entity does not exist. .UNINDENT .INDENT 7.0 .TP .B add(key: str, entity: DXFObject) -> None Add entry (key, value). .sp If the DICTIONARY is hard owner of its entries, the \fI\%add()\fP does NOT take ownership of the entity automatically. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFValueError\fP – invalid entity handle .IP \(bu 2 \fI\%DXFTypeError\fP – invalid DXF type .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B remove(key: str) -> None Delete entry \fIkey\fP\&. Raises \fBDXFKeyError\fP, if \fIkey\fP does not exist. Destroys hard owned DXF entities. .UNINDENT .INDENT 7.0 .TP .B discard(key: str) -> None Delete entry \fIkey\fP if exists. Does not raise an exception if \fIkey\fP doesn’t exist and does not destroy hard owned DXF entities. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Delete all entries from the dictionary and destroys hard owned DXF entities. .UNINDENT .INDENT 7.0 .TP .B add_new_dict(key: str, hard_owned: bool = False) -> Dictionary Create a new sub\-dictionary of type \fI\%Dictionary\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBkey\fP – name of the sub\-dictionary .IP \(bu 2 \fBhard_owned\fP – entries of the new dictionary are hard owned .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_required_dict(key: str, hard_owned=False) -> Dictionary Get entry \fIkey\fP or create a new \fI\%Dictionary\fP, if \fIKey\fP not exist. .UNINDENT .INDENT 7.0 .TP .B add_dict_var(key: str, value: str) -> DictionaryVar Add a new \fI\%DictionaryVar\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBkey\fP – entry name as string .IP \(bu 2 \fBvalue\fP – entry value as string .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_xrecord(key: str) -> \fI\%XRecord\fP Add a new \fI\%XRecord\fP\&. .INDENT 7.0 .TP .B Parameters \fBkey\fP – entry name as string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B link_dxf_object(name: str, obj: DXFObject) -> None Add \fIobj\fP and set owner of \fIobj\fP to this dictionary. .sp Graphical DXF entities have to reside in a layout and therefore can not be owned by a \fI\%Dictionary\fP\&. .INDENT 7.0 .TP .B Raises \fI\%DXFTypeError\fP – \fIobj\fP has invalid DXF type .UNINDENT .UNINDENT .UNINDENT .SS DictionaryWithDefault .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.Dictionary\fP T} _ T{ DXF type T} T{ \fB\(aqACDBDICTIONARYWDFLT\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_dictionary_with_default()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.DictionaryWithDefault .INDENT 7.0 .TP .B dxf.default Handle to default entry as hex string like \fBFF00\fP\&. .UNINDENT .INDENT 7.0 .TP .B get(key: str, default: DXFObject | None = None) -> DXFObject | None Returns \fI\%DXFEntity\fP for \fIkey\fP or the predefined dictionary wide \fI\%dxf.default\fP entity if \fIkey\fP does not exist or \fBNone\fP if default value also not exist. .UNINDENT .INDENT 7.0 .TP .B set_default(default: DXFObject) -> None Set dictionary wide default entry. .INDENT 7.0 .TP .B Parameters \fBdefault\fP – default entry as \fI\%DXFEntity\fP .UNINDENT .UNINDENT .UNINDENT .SS DictionaryVar .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqDICTIONARYVAR\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.entities.Dictionary.add_dict_var()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.DictionaryVar .INDENT 7.0 .TP .B dxf.schema Object schema number (currently set to 0) .UNINDENT .INDENT 7.0 .TP .B dxf.value Value as string. .UNINDENT .INDENT 7.0 .TP .B property value: str Get/set the value of the \fI\%DictionaryVar\fP as string. .UNINDENT .UNINDENT .SS DXFLayout .sp \fI\%LAYOUT\fP entity is part of a modelspace or paperspace layout definitions. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.PlotSettings\fP T} _ T{ DXF type T} T{ \fB\(aqLAYOUT\(aq\fP T} _ T{ Factory function T} T{ internal data structure, use \fI\%Layouts\fP to manage layout objects. T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.DXFLayout .INDENT 7.0 .TP .B dxf.name Layout name as shown in tabs by \fI\%CAD\fP applications .UNINDENT .INDENT 7.0 .TP .B dxf.layout_flags .TS center; |l|l|. _ T{ 1 T} T{ Indicates the PSLTSCALE value for this layout when this layout is current T} _ T{ 2 T} T{ Indicates the LIMCHECK value for this layout when this layout is current T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.tab_order default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.limmin default is Vec2(0, 0) .UNINDENT .INDENT 7.0 .TP .B dxf.limmax default is Vec2(420, 297) .UNINDENT .INDENT 7.0 .TP .B dxf.insert_base default is Vec3(0, 0, 0) .UNINDENT .INDENT 7.0 .TP .B dxf.extmin default is Vec3(1e20, 1e20, 1e20) .UNINDENT .INDENT 7.0 .TP .B dxf.extmax default is Vec3(\-1e20, \-1e20, \-1e20) .UNINDENT .INDENT 7.0 .TP .B dxf.elevation default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_origin default is Vec3(0, 0, 0) .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_xaxis default is Vec3(1, 0, 0) .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_yaxis default is Vec3(0, 1, 0) .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_type .TS center; |l|l|. _ T{ 0 T} T{ UCS is not orthographic T} _ T{ 1 T} T{ Top T} _ T{ 2 T} T{ Bottom T} _ T{ 3 T} T{ Front T} _ T{ 4 T} T{ Back T} _ T{ 5 T} T{ Left T} _ T{ 6 T} T{ Right T} _ .TE .sp default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.block_record_handle .UNINDENT .INDENT 7.0 .TP .B dxf.viewport_handle .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_handle .UNINDENT .INDENT 7.0 .TP .B dxf.base_ucs_handle .UNINDENT .UNINDENT .SS DXFObject .sp Common base class for all non\-graphical DXF objects. .INDENT 0.0 .TP .B class ezdxf.entities.DXFObject A class hierarchy marker class and subclass of \fI\%ezdxf.entities.DXFEntity\fP .UNINDENT .SS GeoData .sp The \fI\%GEODATA\fP entity is associated to the \fI\%Modelspace\fP object. The \fI\%GEODATA\fP entity is supported since the DXF version R2000, but was officially documented the first time in the DXF reference for version R2009. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqGEODATA\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.layouts.Modelspace.new_geodata()\fP T} _ T{ Required DXF version T} T{ R2010 (\fB\(aqAC1024\(aq\fP) T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%geodata_setup_local_grid.py\fP .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate object classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.GeoData .INDENT 7.0 .TP .B dxf.version .TS center; |l|l|. _ T{ 1 T} T{ R2009 T} _ T{ 2 T} T{ R2010 T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.coordinate_type .TS center; |l|l|. _ T{ 0 T} T{ unknown T} _ T{ 1 T} T{ local grid T} _ T{ 2 T} T{ projected grid T} _ T{ 3 T} T{ geographic (latitude/longitude) T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.block_record_handle Handle of host BLOCK_RECORD table entry, in general the \fI\%Modelspace\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.design_point Reference point in \fI\%WCS\fP coordinates. .UNINDENT .INDENT 7.0 .TP .B dxf.reference_point Reference point in geo coordinates, valid only when coordinate type is \fIlocal grid\fP\&. The difference between \fIdxf.design_point\fP and \fIdxf.reference_point\fP defines the translation from WCS coordinates to geo\-coordinates. .UNINDENT .INDENT 7.0 .TP .B dxf.north_direction North direction as 2D vector. Defines the rotation (about the \fIdxf.design_point\fP) to transform from WCS coordinates to geo\-coordinates .UNINDENT .INDENT 7.0 .TP .B dxf.horizontal_unit_scale Horizontal unit scale, factor which converts horizontal design coordinates to meters by multiplication. .UNINDENT .INDENT 7.0 .TP .B dxf.vertical_unit_scale Vertical unit scale, factor which converts vertical design coordinates to meters by multiplication. .UNINDENT .INDENT 7.0 .TP .B dxf.horizontal_units Horizontal units (see \fI\%BlockRecord\fP). Will be 0 (Unitless) if units specified by horizontal unit scale is not supported by AutoCAD enumeration. .UNINDENT .INDENT 7.0 .TP .B dxf.vertical_units Vertical units (see \fI\%BlockRecord\fP). Will be 0 (Unitless) if units specified by vertical unit scale is not supported by AutoCAD enumeration. .UNINDENT .INDENT 7.0 .TP .B dxf.up_direction Up direction as 3D vector. .UNINDENT .INDENT 7.0 .TP .B dxf.scale_estimation_method .TS center; |l|l|. _ T{ 1 T} T{ none T} _ T{ 2 T} T{ user specified scale factor T} _ T{ 3 T} T{ grid scale at reference point T} _ T{ 4 T} T{ prismoidal T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.sea_level_correction Bool flag specifying whether to do sea level correction. .UNINDENT .INDENT 7.0 .TP .B dxf.user_scale_factor .UNINDENT .INDENT 7.0 .TP .B dxf.sea_level_elevation .UNINDENT .INDENT 7.0 .TP .B dxf.coordinate_projection_radius .UNINDENT .INDENT 7.0 .TP .B dxf.geo_rss_tag .UNINDENT .INDENT 7.0 .TP .B dxf.observation_from_tag .UNINDENT .INDENT 7.0 .TP .B dxf.observation_to_tag .UNINDENT .INDENT 7.0 .TP .B dxf.mesh_faces_count .UNINDENT .INDENT 7.0 .TP .B source_vertices 2D source vertices in the CRS of the GeoData as \fI\%VertexArray\fP\&. Used together with \fItarget_vertices\fP to define the transformation from the CRS of the GeoData to WGS84. .UNINDENT .INDENT 7.0 .TP .B target_vertices 2D target vertices in WGS84 (EPSG:4326) as \fI\%VertexArray\fP\&. Used together with \fIsource_vertices\fP to define the transformation from the CRS of the geoData to WGS84. .UNINDENT .INDENT 7.0 .TP .B faces List of face definition tuples, each face entry is a 3\-tuple of vertex indices (0\-based). .UNINDENT .INDENT 7.0 .TP .B coordinate_system_definition The coordinate system definition string. Stored as XML. Defines the CRS used by the GeoData. The EPSG number and other details like the axis\-ordering of the CRS is stored. .UNINDENT .INDENT 7.0 .TP .B get_crs() -> tuple[int, bool] Returns the EPSG index and axis\-ordering, axis\-ordering is \fBTrue\fP if fist axis is labeled “E” or “W” and \fBFalse\fP if first axis is labeled “N” or “S”. .sp If axis\-ordering is \fBFalse\fP the CRS is not compatible with the \fB__geo_interface__\fP or GeoJSON (see chapter 3.1.1). .INDENT 7.0 .TP .B Raises \fBInvalidGeoDataException\fP – for invalid or unknown XML data .UNINDENT .sp The EPSG number is stored in a tag like: .INDENT 7.0 .INDENT 3.5 .sp .EX OSGB1936.NationalGrid EPSG Code .EE .UNINDENT .UNINDENT .sp The axis\-ordering is stored in a tag like: .INDENT 7.0 .INDENT 3.5 .sp .EX 1 Easting E east 2 Northing N north .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_crs_transformation(*, no_checks: bool = False) -> tuple[\fI\%Matrix44\fP, int] Returns the transformation matrix and the EPSG index to transform WCS coordinates into CRS coordinates. Because of the lack of proper documentation this method works only for tested configurations, set argument \fIno_checks\fP to \fBTrue\fP to use the method for untested geodata configurations, but the results may be incorrect. .sp Supports only “Local Grid” transformation! .INDENT 7.0 .TP .B Raises \fBInvalidGeoDataException\fP – for untested geodata configurations .UNINDENT .UNINDENT .INDENT 7.0 .TP .B setup_local_grid(*, design_point: \fI\%UVec\fP, reference_point: \fI\%UVec\fP, north_direction: \fI\%UVec\fP = (0, 1), crs: str = EPSG_3395) Setup local grid coordinate system. This method is designed to setup CRS similar to \fIEPSG:3395 World Mercator\fP, the basic features of the CRS should fulfill these assumptions: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 base unit of reference coordinates is 1 meter .IP \(bu 2 right\-handed coordinate system: +Y=north/+X=east/+Z=up .UNINDENT .UNINDENT .UNINDENT .sp The CRS string is not validated nor interpreted! .sp \fBHINT:\fP .INDENT 7.0 .INDENT 3.5 The reference point must be a 2D cartesian map coordinate and not a globe (lon/lat) coordinate like stored in GeoJSON or GPS data. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdesign_point\fP – WCS coordinates of the CRS reference point .IP \(bu 2 \fBreference_point\fP – CRS reference point in 2D cartesian coordinates .IP \(bu 2 \fBnorth_direction\fP – north direction a 2D vertex, default is (0, 1) .IP \(bu 2 \fBcrs\fP – Coordinate Reference System definition XML string, default is the definition string for \fIEPSG:3395 World Mercator\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS ImageDef .sp The \fI\%IMAGEDEF\fP entity defines an image file, which can be placed by the \fI\%Image\fP entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqIMAGEDEF\(aq\fP T} _ T{ Factory function (1) T} T{ \fI\%ezdxf.document.Drawing.add_image_def()\fP T} _ T{ Factory function (2) T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_image_def()\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate object classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.ImageDef .INDENT 7.0 .TP .B dxf.class_version Current version is 0. .UNINDENT .INDENT 7.0 .TP .B dxf.filename Relative (to the DXF file) or absolute path to the image file as string. .UNINDENT .INDENT 7.0 .TP .B dxf.image_size Image size in pixel as (x, y) tuple. .UNINDENT .INDENT 7.0 .TP .B dxf.pixel_size Default size of one pixel in drawing units as (x, y) tuple. .UNINDENT .INDENT 7.0 .TP .B dxf.loaded 0 = unloaded; 1 = loaded, default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.resolution_units .TS center; |l|l|. _ T{ 0 T} T{ No units T} _ T{ 2 T} T{ Centimeters T} _ T{ 5 T} T{ Inch T} _ .TE .sp default is 0 .UNINDENT .UNINDENT .SS ImageDefReactor .INDENT 0.0 .TP .B class ezdxf.entities.ImageDefReactor .INDENT 7.0 .TP .B dxf.class_version .UNINDENT .INDENT 7.0 .TP .B dxf.image_handle .UNINDENT .UNINDENT .SS MLeaderStyle .sp The MLEADERSTYLE entity (\fI\%DXF Reference\fP) stores all attributes required to create new \fI\%MultiLeader\fP entities. The meaning of these attributes are not really documented in the \fI\%DXF Reference\fP\&. The default style “Standard” always exist. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.entities.MultiLeader\fP .IP \(bu 2 \fI\%ezdxf.render.MultiLeaderBuilder\fP .IP \(bu 2 \fI\%Tutorial for MultiLeader\fP .UNINDENT .UNINDENT .UNINDENT .sp Create a new \fI\%MLeaderStyle\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new() new_style = doc.mleader_styles.new(\(dqNewStyle\(dq) .EE .UNINDENT .UNINDENT .sp Duplicate an existing style: .INDENT 0.0 .INDENT 3.5 .sp .EX duplicated_style = doc.mleader_styles.duplicate_entry(\(dqStandard\(dq, \(dqDuplicatedStyle\(dq) .EE .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqMLEADERSTYLE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.document.Drawing.mleader_styles.new()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.MLeaderStyle .INDENT 7.0 .TP .B dxf.align_space unknown meaning .UNINDENT .INDENT 7.0 .TP .B dxf.arrow_head_handle handle of default arrow head, see also \fI\%ezdxf.render.arrows\fP module, by default no handle is set, which mean default arrow “closed filled” .UNINDENT .INDENT 7.0 .TP .B dxf.arrow_head_size default arrow head size in drawing units, default is 4.0 .UNINDENT .INDENT 7.0 .TP .B dxf.block_color default block color as ;term:\fIraw color\fP value, default is BY_BLOCK_RAW_VALUE .UNINDENT .INDENT 7.0 .TP .B dxf.block_connection_type .TS center; |l|l|. _ T{ 0 T} T{ center extents T} _ T{ 1 T} T{ insertion point T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.block_record_handle handle to block record of the BLOCK content, not set by default .UNINDENT .INDENT 7.0 .TP .B dxf.block_rotation default BLOCK rotation in radians, default is 0.0 .UNINDENT .INDENT 7.0 .TP .B dxf.block_scale_x default block x\-axis scale factor, default is 1.0 .UNINDENT .INDENT 7.0 .TP .B dxf.block_scale_y default block y\-axis scale factor, default is 1.0 .UNINDENT .INDENT 7.0 .TP .B dxf.block_scale_z default block z\-axis scale factor, default is 1.0 .UNINDENT .INDENT 7.0 .TP .B dxf.break_gap_size default break gap size, default is 3.75 .UNINDENT .INDENT 7.0 .TP .B dxf.char_height default MTEXT char height, default is 4.0 .UNINDENT .INDENT 7.0 .TP .B dxf.content_type .TS center; |l|l|. _ T{ 0 T} T{ none T} _ T{ 1 T} T{ BLOCK T} _ T{ 2 T} T{ MTEXT T} _ T{ 3 T} T{ TOLERANCE T} _ .TE .sp default is MTEXT (2) .UNINDENT .INDENT 7.0 .TP .B dxf.default_text_content default MTEXT content as string, default is “” .UNINDENT .INDENT 7.0 .TP .B dxf.dogleg_length default dogleg length, default is 8.0 .UNINDENT .INDENT 7.0 .TP .B dxf.draw_leader_order_type unknown meaning .UNINDENT .INDENT 7.0 .TP .B dxf.draw_mleader_order_type unknown meaning .UNINDENT .INDENT 7.0 .TP .B dxf.first_segment_angle_constraint angle of fist leader segment in radians, default is 0.0 .UNINDENT .INDENT 7.0 .TP .B dxf.has_block_rotation .UNINDENT .INDENT 7.0 .TP .B dxf.has_block_scaling .UNINDENT .INDENT 7.0 .TP .B dxf.has_dogleg default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.has_landing default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.is_annotative default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.landing_gap default landing gap size, default is 2.0 .UNINDENT .INDENT 7.0 .TP .B dxf.leader_line_color default leader line color as \fI\%raw\-color\fP value, default is BY_BLOCK_RAW_VALUE .UNINDENT .INDENT 7.0 .TP .B dxf.leader_linetype_handle handle of default leader linetype .UNINDENT .INDENT 7.0 .TP .B dxf.leader_lineweight default leader lineweight, default is LINEWEIGHT_BYBLOCK .UNINDENT .INDENT 7.0 .TP .B dxf.leader_type .TS center; |l|l|. _ T{ 0 T} T{ invisible T} _ T{ 1 T} T{ straight line leader T} _ T{ 2 T} T{ spline leader T} _ .TE .sp default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.max_leader_segments_points max count of leader segments, default is 2 .UNINDENT .INDENT 7.0 .TP .B dxf.name MLEADERSTYLE name .UNINDENT .INDENT 7.0 .TP .B dxf.overwrite_property_value unknown meaning .UNINDENT .INDENT 7.0 .TP .B dxf.scale overall scaling factor, default is 1.0 .UNINDENT .INDENT 7.0 .TP .B dxf.second_segment_angle_constraint angle of fist leader segment in radians, default is 0.0 .UNINDENT .INDENT 7.0 .TP .B dxf.text_align_always_left use always left side to attach leaders, default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.text_alignment_type unknown meaning \- its not the MTEXT attachment point! .UNINDENT .INDENT 7.0 .TP .B dxf.text_angle_type .TS center; |l|l|. _ T{ 0 T} T{ text angle is equal to last leader line segment angle T} _ T{ 1 T} T{ text is horizontal T} _ T{ 2 T} T{ text angle is equal to last leader line segment angle, but potentially rotated by 180 degrees so the right side is up for readability. T} _ .TE .sp default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.text_attachment_direction defines whether the leaders attach to the left & right of the content BLOCK/MTEXT or attach to the top & bottom: .TS center; |l|l|. _ T{ 0 T} T{ horizontal \- left & right of content T} _ T{ 1 T} T{ vertical \- top & bottom of content T} _ .TE .sp default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.text_bottom_attachment_type .TS center; |l|l|. _ T{ 9 T} T{ center T} _ T{ 10 T} T{ overline and center T} _ .TE .sp default is 9 .UNINDENT .INDENT 7.0 .TP .B dxf.text_color default MTEXT color as \fI\%raw\-color\fP value, default is BY_BLOCK_RAW_VALUE .UNINDENT .INDENT 7.0 .TP .B dxf.text_left_attachment_type .TS center; |l|l|. _ T{ 0 T} T{ top of top MTEXT line T} _ T{ 1 T} T{ middle of top MTEXT line T} _ T{ 2 T} T{ middle of whole MTEXT T} _ T{ 3 T} T{ middle of bottom MTEXT line T} _ T{ 4 T} T{ bottom of bottom MTEXT line T} _ T{ 5 T} T{ bottom of bottom MTEXT line & underline bottom MTEXT line T} _ T{ 6 T} T{ bottom of top MTEXT line & underline top MTEXT line T} _ T{ 7 T} T{ bottom of top MTEXT line T} _ T{ 8 T} T{ bottom of top MTEXT line & underline all MTEXT lines T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_right_attachment_type .TS center; |l|l|. _ T{ 0 T} T{ top of top MTEXT line T} _ T{ 1 T} T{ middle of top MTEXT line T} _ T{ 2 T} T{ middle of whole MTEXT T} _ T{ 3 T} T{ middle of bottom MTEXT line T} _ T{ 4 T} T{ bottom of bottom MTEXT line T} _ T{ 5 T} T{ bottom of bottom MTEXT line & underline bottom MTEXT line T} _ T{ 6 T} T{ bottom of top MTEXT line & underline top MTEXT line T} _ T{ 7 T} T{ bottom of top MTEXT line T} _ T{ 8 T} T{ bottom of top MTEXT line & underline all MTEXT lines T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.text_style_handle handle of the default MTEXT text style, not set by default, which means “Standard” .UNINDENT .INDENT 7.0 .TP .B dxf.text_top_attachment_type .TS center; |l|l|. _ T{ 9 T} T{ center T} _ T{ 10 T} T{ overline and center T} _ .TE .UNINDENT .UNINDENT .SS Placeholder .sp The \fI\%ACDBPLACEHOLDER\fP object for internal usage. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqACDBPLACEHOLDER\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_placeholder()\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate object classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Placeholder .UNINDENT .SS PlotSettings .sp All \fI\%PLOTSETTINGS\fP attributes are part of the \fI\%DXFLayout\fP entity, I don’t know if this entity also appears as standalone entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqPLOTSETTINGS\(aq\fP T} _ T{ Factory function T} T{ internal data structure T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.PlotSettings .INDENT 7.0 .TP .B dxf.page_setup_name default is “” .UNINDENT .INDENT 7.0 .TP .B dxf.plot_configuration_file default is “Adobe PDF” .UNINDENT .INDENT 7.0 .TP .B dxf.paper_size default is “A3” .UNINDENT .INDENT 7.0 .TP .B dxf.plot_view_name default is “” .UNINDENT .INDENT 7.0 .TP .B dxf.left_margin default is 7.5 mm .UNINDENT .INDENT 7.0 .TP .B dxf.bottom_margin default is 20 mm .UNINDENT .INDENT 7.0 .TP .B dxf.right_margin default is 7.5 mm .UNINDENT .INDENT 7.0 .TP .B dxf.top_margin default is 20 mm .UNINDENT .INDENT 7.0 .TP .B dxf.paper_width default is 420 mm .UNINDENT .INDENT 7.0 .TP .B dxf.paper_height default is 297 mm .UNINDENT .INDENT 7.0 .TP .B dxf.plot_origin_x_offset default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.plot_origin_y_offset default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.plot_window_x1 default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.plot_window_y1 default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.plot_window_x2 default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.plot_window_y2 default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.scale_numerator default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.scale_denominator default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.plot_layout_flags .TS center; |l|l|. _ T{ 1 T} T{ plot viewport borders T} _ T{ 2 T} T{ show plot\-styles T} _ T{ 4 T} T{ plot centered T} _ T{ 8 T} T{ plot hidden == hide paperspace entities? T} _ T{ 16 T} T{ use standard scale T} _ T{ 32 T} T{ plot with plot\-styles T} _ T{ 64 T} T{ scale lineweights T} _ T{ 128 T} T{ plot entity lineweights T} _ T{ 512 T} T{ draw viewports first T} _ T{ 1024 T} T{ model type T} _ T{ 2048 T} T{ update paper T} _ T{ 4096 T} T{ zoom to paper on update T} _ T{ 8192 T} T{ initializing T} _ T{ 16384 T} T{ prev plot\-init T} _ .TE .sp default is 688 .UNINDENT .INDENT 7.0 .TP .B dxf.plot_paper_units .TS center; |l|l|. _ T{ 0 T} T{ Plot in inches T} _ T{ 1 T} T{ Plot in millimeters T} _ T{ 2 T} T{ Plot in pixels T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.plot_rotation .TS center; |l|l|. _ T{ 0 T} T{ No rotation T} _ T{ 1 T} T{ 90 degrees counterclockwise T} _ T{ 2 T} T{ Upside\-down T} _ T{ 3 T} T{ 90 degrees clockwise T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.plot_type .TS center; |l|l|. _ T{ 0 T} T{ Last screen display T} _ T{ 1 T} T{ Drawing extents T} _ T{ 2 T} T{ Drawing limits T} _ T{ 3 T} T{ View specified by code 6 T} _ T{ 4 T} T{ Window specified by codes 48, 49, 140, and 141 T} _ T{ 5 T} T{ Layout information T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.current_style_sheet default is “” .UNINDENT .INDENT 7.0 .TP .B dxf.standard_scale_type .TS center; |l|l|. _ T{ 0 T} T{ Scaled to Fit T} _ T{ 1 T} T{ 1/128”=1’ T} _ T{ 2 T} T{ 1/64”=1’ T} _ T{ 3 T} T{ 1/32”=1’ T} _ T{ 4 T} T{ 1/16”=1’ T} _ T{ 5 T} T{ 3/32”=1’ T} _ T{ 6 T} T{ 1/8”=1’ T} _ T{ 7 T} T{ 3/16”=1’ T} _ T{ 8 T} T{ 1/4”=1’ T} _ T{ 9 T} T{ 3/8”=1’ T} _ T{ 10 T} T{ 1/2”=1’ T} _ T{ 11 T} T{ 3/4”=1’ T} _ T{ 12 T} T{ 1”=1’ T} _ T{ 13 T} T{ 3”=1’ T} _ T{ 14 T} T{ 6”=1’ T} _ T{ 15 T} T{ 1’=1’ T} _ T{ 16 T} T{ 1:1 T} _ T{ 17 T} T{ 1:2 T} _ T{ 18 T} T{ 1:4 T} _ T{ 19 T} T{ 1:8 T} _ T{ 20 T} T{ 1:10 T} _ T{ 21 T} T{ 1:16 T} _ T{ 22 T} T{ 1:20 T} _ T{ 23 T} T{ 1:30 T} _ T{ 24 T} T{ 1:40 T} _ T{ 25 T} T{ 1:50 T} _ T{ 26 T} T{ 1:100 T} _ T{ 27 T} T{ 2:1 T} _ T{ 28 T} T{ 4:1 T} _ T{ 29 T} T{ 8:1 T} _ T{ 30 T} T{ 10:1 T} _ T{ 31 T} T{ 100:1 T} _ T{ 32 T} T{ 1000:1 T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.shade_plot_mode .TS center; |l|l|. _ T{ 0 T} T{ As Displayed T} _ T{ 1 T} T{ Wireframe T} _ T{ 2 T} T{ Hidden T} _ T{ 3 T} T{ Rendered T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.shade_plot_resolution_level .TS center; |l|l|. _ T{ 0 T} T{ Draft T} _ T{ 1 T} T{ Preview T} _ T{ 2 T} T{ Normal T} _ T{ 3 T} T{ Presentation T} _ T{ 4 T} T{ Maximum T} _ T{ 5 T} T{ Custom T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.shade_plot_custom_dpi default is 300 .UNINDENT .INDENT 7.0 .TP .B dxf.unit_factor default is 1 .UNINDENT .INDENT 7.0 .TP .B dxf.paper_image_origin_x default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.paper_image_origin_y default is 0 .UNINDENT .INDENT 7.0 .TP .B dxf.shade_plot_handle .UNINDENT .UNINDENT .SS Sun .sp The \fI\%SUN\fP entity defines properties of the sun. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqSUN\(aq\fP T} _ T{ Factory function T} T{ creating a new SUN entity is not supported T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Sun .INDENT 7.0 .TP .B dxf.version Current version is 1. .UNINDENT .INDENT 7.0 .TP .B dxf.status on = 1 or off = 0 .UNINDENT .INDENT 7.0 .TP .B dxf.color \fI\%AutoCAD Color Index (ACI)\fP value of the sun. .UNINDENT .INDENT 7.0 .TP .B dxf.true_color \fI\%true\-color\fP value of the sun. .UNINDENT .INDENT 7.0 .TP .B dxf.intensity Intensity value in the range of [0, 1]. (float) .UNINDENT .INDENT 7.0 .TP .B dxf.julian_day use \fI\%calendardate()\fP to convert \fBdxf.julian_day\fP to \fBdatetime.datetime\fP object. .UNINDENT .INDENT 7.0 .TP .B dxf.time Day time in seconds past midnight. (int) .UNINDENT .INDENT 7.0 .TP .B dxf.daylight_savings_time .UNINDENT .INDENT 7.0 .TP .B dxf.shadows .TS center; |l|l|. _ T{ 0 T} T{ Sun do not cast shadows T} _ T{ 1 T} T{ Sun do cast shadows T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.shadow_type .UNINDENT .INDENT 7.0 .TP .B dxf.shadow_map_size .UNINDENT .INDENT 7.0 .TP .B dxf.shadow_softness .UNINDENT .UNINDENT .SS UnderlayDefinition .sp \fI\%UnderlayDefinition\fP (\fI\%DXF Reference\fP) defines an underlay file, which can be placed by the \fI\%Underlay\fP entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ internal base class T} _ T{ Factory function (1) T} T{ \fI\%ezdxf.document.Drawing.add_underlay_def()\fP T} _ T{ Factory function (2) T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_underlay_def()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.UnderlayDefinition Base class of \fI\%PdfDefinition\fP, \fI\%DwfDefinition\fP and \fI\%DgnDefinition\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .TP .B dxf.filename Relative (to the DXF file) or absolute path to the underlay file as string. .UNINDENT .INDENT 0.0 .TP .B dxf.name Defines which part of the underlay file to display. .TS center; |l|l|. _ T{ “pdf” T} T{ PDF page number T} _ T{ “dgn” T} T{ always “default” T} _ T{ “dwf” T} T{ ? T} _ .TE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate object classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .SS PdfDefinition .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.UnderlayDefinition\fP T} _ T{ DXF type T} T{ \fB\(aqPDFDEFINITION\(aq\fP T} _ T{ Factory function (1) T} T{ \fI\%ezdxf.document.Drawing.add_underlay_def()\fP T} _ T{ Factory function (2) T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_underlay_def()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.PdfDefinition PDF underlay file. .UNINDENT .SS DwfDefinition .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.UnderlayDefinition\fP T} _ T{ DXF type T} T{ \fB\(aqDWFDEFINITION\(aq\fP T} _ T{ Factory function (1) T} T{ \fI\%ezdxf.document.Drawing.add_underlay_def()\fP T} _ T{ Factory function (2) T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_underlay_def()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.DwfDefinition DWF underlay file. .UNINDENT .SS DgnDefinition .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.UnderlayDefinition\fP T} _ T{ DXF type T} T{ \fB\(aqDGNDEFINITION\(aq\fP T} _ T{ Factory function (1) T} T{ \fI\%ezdxf.document.Drawing.add_underlay_def()\fP T} _ T{ Factory function (2) T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_underlay_def()\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.DgnDefinition DGN underlay file. .UNINDENT .SS XRecord .sp Important class for storing application defined data in DXF files. .sp The \fI\%XRECORD\fP entities are used to store and manage arbitrary data. They are composed of DXF group codes ranging from 1 through 369. This object is similar in concept to XDATA but is not limited by size or order. .sp To reference a XRECORD by an DXF entity, store the handle of the XRECORD in the XDATA section, application defined data or the \fBExtensionDict\fP of the DXF entity. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Extended Data (XDATA)\fP .IP \(bu 2 \fI\%Extension Dictionary\fP .IP \(bu 2 \fI\%Storing Custom Data in DXF Files\fP .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fI\%ezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqXRECORD\(aq\fP T} _ T{ Factory function T} T{ \fI\%ezdxf.sections.objects.ObjectsSection.add_xrecord()\fP T} _ .TE .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not instantiate object classes by yourself \- always use the provided factory functions! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.XRecord .INDENT 7.0 .TP .B dxf.cloning Duplicate record cloning flag (determines how to merge duplicate entries, ignored by \fIezdxf\fP): .TS center; |l|l|. _ T{ 0 T} T{ not applicable T} _ T{ 1 T} T{ keep existing T} _ T{ 2 T} T{ use clone T} _ T{ 3 T} T{ $0$ T} _ T{ 4 T} T{ $0$ T} _ T{ 5 T} T{ Unmangle name T} _ .TE .UNINDENT .INDENT 7.0 .TP .B tags Raw DXF tag container \fI\%Tags\fP\&. Be careful \fIezdxf\fP does not validate the content of XRECORDS. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Remove all DXF tags. .UNINDENT .INDENT 7.0 .TP .B reset(tags: Iterable[tuple[int, Any] | \fI\%DXFTag\fP]) -> None Reset DXF tags. .UNINDENT .INDENT 7.0 .TP .B extend(tags: Iterable[tuple[int, Any] | \fI\%DXFTag\fP]) -> None Extend DXF tags. .UNINDENT .UNINDENT .SS Extended Data (XDATA) .sp Extended data (XDATA) is a DXF tags structure to store arbitrary data in DXF entities. The XDATA is associated to an \fI\%AppID\fP and only one tag list is supported for each AppID per entity. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Low level usage of XDATA is an advanced feature, it is the responsibility of the programmer to create valid XDATA structures. Any errors can invalidate the DXF file! .UNINDENT .UNINDENT .sp This section shows how to store DXF tags directly in DXF entity but there is also a more user friendly and safer way to store custom XDATA in DXF entities: .INDENT 0.0 .IP \(bu 2 \fI\%XDataUserList\fP .IP \(bu 2 \fI\%XDataUserDict\fP .UNINDENT .sp Use the high level methods of \fI\%DXFEntity\fP to manage XDATA tags. .INDENT 0.0 .IP \(bu 2 \fI\%has_xdata()\fP .IP \(bu 2 \fI\%get_xdata()\fP .IP \(bu 2 \fI\%set_xdata()\fP .UNINDENT .sp Get XDATA tags as a \fI\%ezdxf.lldxf.tags.Tags\fP data structure, \fBwithout\fP the mandatory first tag (1001, AppID): .INDENT 0.0 .INDENT 3.5 .sp .EX if entity.has_xdata(\(dqEZDXF\(dq): tags = entity.get_xdata(\(dqEZDXF\(dq) # or use alternatively: try: tags = entity.get_xdata(\(dqEZDXF\(dq) except DXFValueError: # XDATA for \(dqEZDXF\(dq does not exist ... .EE .UNINDENT .UNINDENT .sp Set DXF tags as list of (group code, value) tuples or as \fI\%ezdxf.lldxf.tags.Tags\fP data structure, valid DXF tags for XDATA are documented in the section about the \fI\%Extended Data\fP internals. The mandatory first tag (1001, AppID) is inserted automatically if not present. .sp Set only new XDATA tags: .INDENT 0.0 .INDENT 3.5 .sp .EX if not entity.has_xdata(\(dqEZDXF\(dq): entity.set_xdata(\(dqEZDXF\(dq, [(1000, \(dqMyString\(dq)]) .EE .UNINDENT .UNINDENT .sp Replace or set new XDATA tags: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.set_xdata(\(dqEZDXF\(dq, [(1000, \(dqMyString\(dq)]) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Tutorial: \fI\%Storing Custom Data in DXF Files\fP .IP \(bu 2 Internals about \fI\%Extended Data\fP tags .IP \(bu 2 Internal XDATA management class: \fI\%XData\fP .IP \(bu 2 \fI\%DXF R2018 Reference\fP .UNINDENT .UNINDENT .UNINDENT .SS Application\-Defined Data (AppData) .sp The application\-defined data feature is not very well documented in the DXF reference, so usage as custom data store is not recommended. AutoCAD uses these feature to store the handle to the extension dictionary (\fI\%ExtensionDict\fP) of a DXF entity and the handles to the persistent reactors (\fI\%Reactors\fP) of a DXF entity. .sp Use the high level methods of \fI\%DXFEntity\fP to manage application\-defined data tags. .INDENT 0.0 .IP \(bu 2 \fI\%has_app_data()\fP .IP \(bu 2 \fI\%get_app_data()\fP .IP \(bu 2 \fI\%set_app_data()\fP .IP \(bu 2 \fI\%discard_app_data()\fP .UNINDENT .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 Ezdxf uses special classes to manage the extension dictionary and the reactor handles. These features cannot be accessed by the methods above. .UNINDENT .UNINDENT .sp Set application\-defined data: .INDENT 0.0 .INDENT 3.5 .sp .EX entity.set_app_data(\(dqYOURAPPID\(dq, [(1, \(dqDataString\(dq)])) .EE .UNINDENT .UNINDENT .sp Setting the content tags can contain the opening structure tag (102, “{YOURAPPID”) and the closing tag (102, “}”), but doesn’t have to. The returned \fI\%Tags\fP objects does not contain these structure tags. Which tags are valid for application\-defined data is not documented. .sp The AppID has to have an entry in the AppID table. .sp Get application\-defined data: .INDENT 0.0 .INDENT 3.5 .sp .EX if entity.has_app_data(\(dqYOURAPPID\(dq): tags = entity.get_app_data(\(dqYOURAPPID\(dq) # tags content is [DXFTag(1, \(aqDataString\(aq)] .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Internals about \fI\%Application\-Defined Codes\fP .IP \(bu 2 Internal AppData management class: \fI\%AppData\fP .UNINDENT .UNINDENT .UNINDENT .SS Extension Dictionary .sp Every entity can have an extension dictionary, which can reference arbitrary DXF objects from the OBJECTS section but not graphical entities. Using this mechanism, several applications can attach data to the same entity. The usage of extension dictionaries is more complex than \fI\%Extended Data (XDATA)\fP but also more flexible with higher capacity for adding data. .sp Use the high level methods of \fI\%DXFEntity\fP to manage extension dictionaries. .INDENT 0.0 .IP \(bu 2 \fI\%has_extension_dict()\fP .IP \(bu 2 \fI\%get_extension_dict()\fP .IP \(bu 2 \fI\%new_extension_dict()\fP .IP \(bu 2 \fI\%discard_extension_dict()\fP .UNINDENT .sp The main data storage objects referenced by extension dictionaries are: .INDENT 0.0 .IP \(bu 2 \fI\%Dictionary\fP, structural container .IP \(bu 2 \fI\%DictionaryVar\fP, stores a single string .IP \(bu 2 \fI\%XRecord\fP, stores arbitrary data .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Tutorial: \fI\%Storing Custom Data in DXF Files\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.xdict.ExtensionDict Internal management class for extension dictionaries. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Underlying DXF \fI\%Dictionary\fP class .IP \(bu 2 DXF Internals: \fI\%Extension Dictionary\fP .IP \(bu 2 \fI\%DXF R2018 Reference\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property is_alive Returns \fBTrue\fP if the underlying \fI\%Dictionary\fP object is not deleted. .UNINDENT .INDENT 7.0 .TP .B __contains__(key: str) Return \fIkey\fP in self. .UNINDENT .INDENT 7.0 .TP .B __getitem__(key: str) Get self[key]. .UNINDENT .INDENT 7.0 .TP .B __setitem__(key: str, value) Set self[key] to value. .sp Only DXF objects stored in the OBJECTS section are allowed as content of the extension dictionary. DXF entities stored in layouts are not allowed. .INDENT 7.0 .TP .B Raises \fI\%DXFTypeError\fP – invalid DXF type .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __delitem__(key: str) Delete self[key], destroys referenced entity. .UNINDENT .INDENT 7.0 .TP .B __len__() Returns count of extension dictionary entries. .UNINDENT .INDENT 7.0 .TP .B get(key: str, default=None) -> \fI\%DXFEntity\fP | None Return extension dictionary entry \fIkey\fP\&. .UNINDENT .INDENT 7.0 .TP .B keys() Returns a \fBKeysView\fP of all extension dictionary keys. .UNINDENT .INDENT 7.0 .TP .B items() Returns an \fBItemsView\fP for all extension dictionary entries as (key, entity) pairs. An entity can be a handle string if the entity does not exist. .UNINDENT .INDENT 7.0 .TP .B discard(key: str) -> None Discard extension dictionary entry \fIkey\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_dictionary(name: str, hard_owned: bool = True) -> \fI\%Dictionary\fP Create a new \fI\%Dictionary\fP object as extension dictionary entry \fIname\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_dictionary_var(name: str, value: str) -> \fI\%DictionaryVar\fP Create a new \fI\%DictionaryVar\fP object as extension dictionary entry \fIname\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_xrecord(name: str) -> \fI\%XRecord\fP Create a new \fI\%XRecord\fP object as extension dictionary entry \fIname\fP\&. .UNINDENT .INDENT 7.0 .TP .B link_dxf_object(name: str, obj: \fI\%DXFObject\fP) -> None Link \fIobj\fP to the extension dictionary as entry \fIname\fP\&. .sp Linked objects are owned by the extensions dictionary and therefore cannot be a graphical entity, which have to be owned by a \fI\%BaseLayout\fP\&. .INDENT 7.0 .TP .B Raises \fI\%DXFTypeError\fP – \fIobj\fP has invalid DXF type .UNINDENT .UNINDENT .INDENT 7.0 .TP .B destroy() Destroy the underlying \fI\%Dictionary\fP object. .UNINDENT .UNINDENT .SS Reactors .sp Persistent reactors are optional object handles of objects registering themselves as reactors on an object. Any DXF object or DXF entity may have reactors. .sp Use the high level methods of \fI\%DXFEntity\fP to manage persistent reactor handles. .INDENT 0.0 .IP \(bu 2 \fI\%has_reactors()\fP .IP \(bu 2 \fI\%get_reactors()\fP .IP \(bu 2 \fI\%set_reactors()\fP .IP \(bu 2 \fI\%append_reactor_handle()\fP .IP \(bu 2 \fI\%discard_reactor_handle()\fP .UNINDENT .sp \fIEzdxf\fP keeps these reactors only up to date, if this is absolute necessary according to the DXF reference. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Internals about \fI\%Persistent Reactors\fP .IP \(bu 2 Internal Reactors management class: \fI\%Reactors\fP .UNINDENT .UNINDENT .UNINDENT .SS Block Reference Management .sp The package \fIezdxf\fP is not designed as a CAD library and does not automatically monitor all internal changes. This enables faster entity processing at the cost of an unknown state of the DXF document. .sp In order to carry out precise BLOCK reference management, i.e. to handle dependencies or to delete unused BLOCK definition, the block reference status (counter) must be acquired explicitly by the package user. All block reference management structures must be explicitly recreated each time the document content is changed. This is not very efficient, but it is safe. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 And even with all this careful approach, it is always possible to destroy a DXF document by deleting an absolutely necessary block definition. .UNINDENT .UNINDENT .sp Always remember that \fIezdxf\fP is not intended or suitable as a basis for a CAD application! .INDENT 0.0 .TP .B class ezdxf.blkrefs.BlockDefinitionIndex(doc: \fI\%Drawing\fP) Index of all \fI\%BlockRecord\fP entities representing real BLOCK definitions, excluding all \fI\%BlockRecord\fP entities defining model space or paper space layouts. External references (XREF) and XREF overlays are included. .INDENT 7.0 .TP .B property block_records: Iterator[\fI\%BlockRecord\fP] Returns an iterator of all \fI\%BlockRecord\fP entities representing BLOCK definitions. .UNINDENT .INDENT 7.0 .TP .B rebuild() Rebuild index from scratch. .UNINDENT .INDENT 7.0 .TP .B has_handle(handle: str) -> bool Returns \fBTrue\fP if a \fI\%BlockRecord\fP for the given block record handle exist. .UNINDENT .INDENT 7.0 .TP .B by_handle(handle: str) -> \fI\%BlockRecord\fP | None Returns the \fI\%BlockRecord\fP for the given block record handle or \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B has_name(name: str) -> bool Returns \fBTrue\fP if a \fI\%BlockRecord\fP for the given block name exist. .UNINDENT .INDENT 7.0 .TP .B by_name(name: str) -> \fI\%BlockRecord\fP | None Returns \fI\%BlockRecord\fP for the given block name or \fBNone\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.blkrefs.BlockReferenceCounter(doc: \fI\%Drawing\fP, index: \fI\%BlockDefinitionIndex\fP | None = None) Counts all block references in a DXF document. .sp Check if a block is referenced by any entity or any resource (DIMSYTLE, MLEADERSTYLE) in a DXF document: .INDENT 7.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.blkrefs import BlockReferenceCounter doc = ezdxf.readfile(\(dqyour.dxf\(dq) counter = BlockReferenceCounter(doc) count = counter.by_name(\(dqXYZ\(dq) print(f\(dqBlock \(aqXYZ\(aq if referenced {count} times.\(dq) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B by_handle(handle: str) -> int Returns the block reference count for a given \fI\%BlockRecord\fP handle. .UNINDENT .INDENT 7.0 .TP .B by_name(block_name: str) -> int Returns the block reference count for a given block name. .UNINDENT .UNINDENT .SS Const .sp The module \fI\%ezdxf.lldxf.const\fP, is also accessible from the \fBezdxf\fP namespace: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.lldxf.const import DXF12 import ezdxf print(DXF12) print(ezdxf.const.DXF12) .EE .UNINDENT .UNINDENT .SS DXF Version Strings .TS center; |l|l|l|. _ T{ Name T} T{ Version T} T{ Alias T} _ T{ DXF9 T} T{ “AC1004” T} T{ “R9” T} _ T{ DXF10 T} T{ “AC1006” T} T{ “R10” T} _ T{ DXF12 T} T{ “AC1009” T} T{ “R12” T} _ T{ DXF13 T} T{ “AC1012” T} T{ “R13” T} _ T{ DXF14 T} T{ “AC1014” T} T{ “R14” T} _ T{ DXF2000 T} T{ “AC1015” T} T{ “R2000” T} _ T{ DXF2004 T} T{ “AC1018” T} T{ “R2004” T} _ T{ DXF2007 T} T{ “AC1021” T} T{ “R2007” T} _ T{ DXF2010 T} T{ “AC1024” T} T{ “R2010” T} _ T{ DXF2013 T} T{ “AC1027” T} T{ “R2013” T} _ T{ DXF2018 T} T{ “AC1032” T} T{ “R2018” T} _ .TE .SS Exceptions .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFError Base exception for all \fIezdxf\fP exceptions. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFStructureError(DXFError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFVersionError(DXFError) Errors related to features not supported by the chosen DXF Version .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFValueError(DXFError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFInvalidLineType(DXFValueError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFBlockInUseError(DXFValueError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFKeyError(DXFError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFUndefinedBlockError(DXFKeyError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFAttributeError(DXFError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFIndexError(DXFError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFTypeError(DXFError) .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.DXFTableEntryError(DXFValueError) .UNINDENT .SS DXF Entity Creation .SS Layout Factory Methods .sp Recommended way to create DXF entities. .sp For all supported entities exist at least one factory method in the \fI\%ezdxf.layouts.BaseLayout\fP class. All factory methods have the prefix: \fBadd_...\fP .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf doc = ezdxf.new() msp = doc.modelspace() msp.add_line((0, 0, 0), (3, 0, 0), dxfattribs={\(dqcolor\(dq: 2}) .EE .UNINDENT .UNINDENT .SS Thematic Index of Layout Factory Methods .SS DXF Primitives .INDENT 0.0 .IP \(bu 2 \fI\%add_3dface()\fP .IP \(bu 2 \fI\%add_arc()\fP .IP \(bu 2 \fI\%add_circle()\fP .IP \(bu 2 \fI\%add_ellipse()\fP .IP \(bu 2 \fI\%add_hatch()\fP .IP \(bu 2 \fI\%add_helix()\fP .IP \(bu 2 \fI\%add_image()\fP .IP \(bu 2 \fI\%add_leader()\fP .IP \(bu 2 \fI\%add_line()\fP .IP \(bu 2 \fI\%add_lwpolyline()\fP .IP \(bu 2 \fI\%add_mesh()\fP .IP \(bu 2 \fI\%add_mline()\fP .IP \(bu 2 \fI\%add_mpolygon()\fP .IP \(bu 2 \fI\%add_multileader_mtext()\fP .IP \(bu 2 \fI\%add_multileader_block()\fP .IP \(bu 2 \fI\%add_point()\fP .IP \(bu 2 \fI\%add_polyface()\fP .IP \(bu 2 \fI\%add_polyline2d()\fP .IP \(bu 2 \fI\%add_polyline3d()\fP .IP \(bu 2 \fI\%add_polymesh()\fP .IP \(bu 2 \fI\%add_ray()\fP .IP \(bu 2 \fI\%add_shape()\fP .IP \(bu 2 \fI\%add_solid()\fP .IP \(bu 2 \fI\%add_trace()\fP .IP \(bu 2 \fI\%add_wipeout()\fP .IP \(bu 2 \fI\%add_xline()\fP .UNINDENT .SS Text Entities .INDENT 0.0 .IP \(bu 2 \fI\%add_attdef()\fP .IP \(bu 2 \fI\%add_mtext_dynamic_auto_height_columns()\fP .IP \(bu 2 \fI\%add_mtext_dynamic_manual_height_columns()\fP .IP \(bu 2 \fI\%add_mtext_static_columns()\fP .IP \(bu 2 \fI\%add_mtext()\fP .IP \(bu 2 \fI\%add_text()\fP .UNINDENT .SS Spline Entity .INDENT 0.0 .IP \(bu 2 \fI\%add_cad_spline_control_frame()\fP .IP \(bu 2 \fI\%add_open_spline()\fP .IP \(bu 2 \fI\%add_rational_spline()\fP .IP \(bu 2 \fI\%add_spline_control_frame()\fP .IP \(bu 2 \fI\%add_spline()\fP .UNINDENT .SS Block References and Underlays .INDENT 0.0 .IP \(bu 2 \fBadd_arrow_blockref()\fP .IP \(bu 2 \fI\%add_auto_blockref()\fP .IP \(bu 2 \fI\%add_blockref()\fP .IP \(bu 2 \fI\%add_underlay()\fP .UNINDENT .SS Viewport Entity .sp Only available in paper space layouts. .INDENT 0.0 .IP \(bu 2 \fBadd_viewport()\fP .UNINDENT .SS Dimension Entities .sp Linear Dimension .INDENT 0.0 .IP \(bu 2 \fI\%add_aligned_dim()\fP .IP \(bu 2 \fI\%add_linear_dim()\fP .IP \(bu 2 \fI\%add_multi_point_linear_dim()\fP .UNINDENT .sp Radius and Diameter Dimension .INDENT 0.0 .IP \(bu 2 \fI\%add_diameter_dim_2p()\fP .IP \(bu 2 \fI\%add_diameter_dim()\fP .IP \(bu 2 \fI\%add_radius_dim_2p()\fP .IP \(bu 2 \fI\%add_radius_dim_cra()\fP .IP \(bu 2 \fI\%add_radius_dim()\fP .UNINDENT .sp Angular Dimension .INDENT 0.0 .IP \(bu 2 \fI\%add_angular_dim_2l()\fP .IP \(bu 2 \fI\%add_angular_dim_3p()\fP .IP \(bu 2 \fI\%add_angular_dim_arc()\fP .IP \(bu 2 \fI\%add_angular_dim_cra()\fP .UNINDENT .sp Arc Dimension .INDENT 0.0 .IP \(bu 2 \fI\%add_arc_dim_3p()\fP .IP \(bu 2 \fI\%add_arc_dim_arc()\fP .IP \(bu 2 \fI\%add_arc_dim_cra()\fP .UNINDENT .sp Ordinate Dimension .INDENT 0.0 .IP \(bu 2 \fI\%add_ordinate_dim()\fP .IP \(bu 2 \fI\%add_ordinate_x_dim()\fP .IP \(bu 2 \fI\%add_ordinate_y_dim()\fP .UNINDENT .SS Miscellaneous .INDENT 0.0 .IP \(bu 2 \fI\%add_entity()\fP .IP \(bu 2 \fI\%add_foreign_entity()\fP .IP \(bu 2 \fBadd_arrow()\fP .UNINDENT .SS ACIS Entities .sp The creation of the required \fI\%ACIS\fP data has do be done by an external library! .INDENT 0.0 .IP \(bu 2 \fI\%add_3dsolid()\fP .IP \(bu 2 \fI\%add_body()\fP .IP \(bu 2 \fI\%add_extruded_surface()\fP .IP \(bu 2 \fI\%add_lofted_surface()\fP .IP \(bu 2 \fI\%add_region()\fP .IP \(bu 2 \fI\%add_revolved_surface()\fP .IP \(bu 2 \fI\%add_surface()\fP .IP \(bu 2 \fI\%add_swept_surface()\fP .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Layout base class: \fI\%BaseLayout\fP .UNINDENT .UNINDENT .SS Factory Functions .sp Alternative way to create DXF entities for advanced \fIezdxf\fP users. .sp The \fBezdxf.entities.factory\fP module provides the \fBnew()\fP function to create new DXF entities by their DXF name and a dictionary of DXF attributes. This will bypass the validity checks in the factory methods of the \fI\%BaseLayout\fP class. .sp This new created entities are virtual entities which are not assigned to any DXF document nor to any layout. Add the entity to a layout (and document) by the layout method \fI\%add_entity()\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.entities import factory doc = ezdxf.new() msp = doc.modelspace() line = factory.new( \(dqLINE\(dq, dxfattribs={ \(dqstart\(dq: (0, 0, 0), \(dqend\(dq: (3, 0, 0), \(dqcolor\(dq: 2, }, ) msp.add_entity(line) .EE .UNINDENT .UNINDENT .SS Direct Object Instantiation .sp For advanced developers with knowledge about the internal design of \fIezdxf\fP\&. .sp Import the entity classes from sub\-package \fI\%ezdxf.entities\fP and instantiate them. This will bypass the validity checks in the factory methods of the \fI\%BaseLayout\fP class and maybe additional required setup procedures for some entities \- \fBstudy the source code!\fP\&. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 A refactoring of the internal \fIezdxf\fP structures will break your code. .UNINDENT .UNINDENT .sp This new created entities are virtual entities which are not assigned to any DXF document nor to any layout. Add the entity to a layout (and document) by the layout method \fI\%add_entity()\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.entities import Line doc = ezdxf.new() msp = doc.modelspace() line = Line.new( dxfattribs={ \(dqstart\(dq: (0, 0, 0), \(dqend\(dq: (3, 0, 0), \(dqcolor\(dq: 2, } ) msp.add_entity(line) .EE .UNINDENT .UNINDENT .SS Enums .SS TextEntityAlignment .INDENT 0.0 .TP .B class ezdxf.enums.TextEntityAlignment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Text alignment enum for the \fI\%Text\fP, \fI\%Attrib\fP and \fI\%AttDef\fP entities. .INDENT 7.0 .TP .B LEFT .UNINDENT .INDENT 7.0 .TP .B CENTER .UNINDENT .INDENT 7.0 .TP .B RIGHT .UNINDENT .INDENT 7.0 .TP .B ALIGNED .UNINDENT .INDENT 7.0 .TP .B MIDDLE .UNINDENT .INDENT 7.0 .TP .B FIT .UNINDENT .INDENT 7.0 .TP .B BOTTOM_LEFT .UNINDENT .INDENT 7.0 .TP .B BOTTOM_CENTER .UNINDENT .INDENT 7.0 .TP .B BOTTOM_RIGHT .UNINDENT .INDENT 7.0 .TP .B MIDDLE_LEFT .UNINDENT .INDENT 7.0 .TP .B MIDDLE_CENTER .UNINDENT .INDENT 7.0 .TP .B MIDDLE_RIGHT .UNINDENT .INDENT 7.0 .TP .B TOP_LEFT .UNINDENT .INDENT 7.0 .TP .B TOP_CENTER .UNINDENT .INDENT 7.0 .TP .B TOP_RIGHT .UNINDENT .UNINDENT .SS MTextEntityAlignment .INDENT 0.0 .TP .B class ezdxf.enums.MTextEntityAlignment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Text alignment enum for the \fI\%MText\fP entity. .INDENT 7.0 .TP .B TOP_LEFT .UNINDENT .INDENT 7.0 .TP .B TOP_CENTER .UNINDENT .INDENT 7.0 .TP .B TOP_RIGHT .UNINDENT .INDENT 7.0 .TP .B MIDDLE_LEFT .UNINDENT .INDENT 7.0 .TP .B MIDDLE_CENTER .UNINDENT .INDENT 7.0 .TP .B MIDDLE_RIGHT .UNINDENT .INDENT 7.0 .TP .B BOTTOM_LEFT .UNINDENT .INDENT 7.0 .TP .B BOTTOM_CENTER .UNINDENT .INDENT 7.0 .TP .B BOTTOM_RIGHT .UNINDENT .UNINDENT .SS MTextParagraphAlignment .INDENT 0.0 .TP .B class ezdxf.enums.MTextParagraphAlignment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B DEFAULT .UNINDENT .INDENT 7.0 .TP .B LEFT .UNINDENT .INDENT 7.0 .TP .B RIGHT .UNINDENT .INDENT 7.0 .TP .B CENTER .UNINDENT .INDENT 7.0 .TP .B JUSTIFIED .UNINDENT .INDENT 7.0 .TP .B DISTRIBUTED .UNINDENT .UNINDENT .SS MTextFlowDirection .INDENT 0.0 .TP .B class ezdxf.enums.MTextFlowDirection(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B LEFT_TO_RIGHT .UNINDENT .INDENT 7.0 .TP .B TOP_TO_BOTTOM .UNINDENT .INDENT 7.0 .TP .B BY_STYLE .UNINDENT .UNINDENT .SS MTextLineAlignment .INDENT 0.0 .TP .B class ezdxf.enums.MTextLineAlignment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B BOTTOM .UNINDENT .INDENT 7.0 .TP .B MIDDLE .UNINDENT .INDENT 7.0 .TP .B TOP .UNINDENT .UNINDENT .SS MTextStroke .INDENT 0.0 .TP .B class ezdxf.enums.MTextStroke(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Combination of flags is supported: UNDERLINE + STRIKE_THROUGH .INDENT 7.0 .TP .B UNDERLINE .UNINDENT .INDENT 7.0 .TP .B STRIKE_THROUGH .UNINDENT .INDENT 7.0 .TP .B OVERLINE .UNINDENT .UNINDENT .SS MTextLineSpacing .INDENT 0.0 .TP .B class ezdxf.enums.MTextLineSpacing(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B AT_LEAST .UNINDENT .INDENT 7.0 .TP .B EXACT .UNINDENT .UNINDENT .SS MTextBackgroundColor .INDENT 0.0 .TP .B class ezdxf.enums.MTextBackgroundColor(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B OFF .UNINDENT .INDENT 7.0 .TP .B COLOR .UNINDENT .INDENT 7.0 .TP .B WINDOW .UNINDENT .INDENT 7.0 .TP .B CANVAS .UNINDENT .UNINDENT .SS InsertUnits .INDENT 0.0 .TP .B class ezdxf.enums.InsertUnits(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B Unitless .UNINDENT .INDENT 7.0 .TP .B Inches .UNINDENT .INDENT 7.0 .TP .B Feet .UNINDENT .INDENT 7.0 .TP .B Miles .UNINDENT .INDENT 7.0 .TP .B Millimeters .UNINDENT .INDENT 7.0 .TP .B Centimeters .UNINDENT .INDENT 7.0 .TP .B Meters .UNINDENT .INDENT 7.0 .TP .B Kilometers .UNINDENT .INDENT 7.0 .TP .B Microinches .UNINDENT .INDENT 7.0 .TP .B Mils .UNINDENT .INDENT 7.0 .TP .B Yards .UNINDENT .INDENT 7.0 .TP .B Angstroms .UNINDENT .INDENT 7.0 .TP .B Nanometers .UNINDENT .INDENT 7.0 .TP .B Microns .UNINDENT .INDENT 7.0 .TP .B Decimeters .UNINDENT .INDENT 7.0 .TP .B Decameters .UNINDENT .INDENT 7.0 .TP .B Hectometers .UNINDENT .INDENT 7.0 .TP .B Gigameters .UNINDENT .INDENT 7.0 .TP .B AstronomicalUnits .UNINDENT .INDENT 7.0 .TP .B Lightyears .UNINDENT .INDENT 7.0 .TP .B Parsecs .UNINDENT .INDENT 7.0 .TP .B USSurveyFeet .UNINDENT .INDENT 7.0 .TP .B USSurveyInch .UNINDENT .INDENT 7.0 .TP .B USSurveyYard .UNINDENT .INDENT 7.0 .TP .B USSurveyMile .UNINDENT .UNINDENT .SS Measurement .INDENT 0.0 .TP .B class ezdxf.enums.Measurement(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B Imperial .UNINDENT .INDENT 7.0 .TP .B Metric .UNINDENT .UNINDENT .SS LengthUnits .INDENT 0.0 .TP .B class ezdxf.enums.LengthUnits(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B Scientific .UNINDENT .INDENT 7.0 .TP .B Decimal .UNINDENT .INDENT 7.0 .TP .B Engineering .UNINDENT .INDENT 7.0 .TP .B Architectural .UNINDENT .INDENT 7.0 .TP .B Fractional .UNINDENT .UNINDENT .SS AngularUnits .INDENT 0.0 .TP .B class ezdxf.enums.AngularUnits(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B DecimalDegrees .UNINDENT .INDENT 7.0 .TP .B DegreesMinutesSeconds .UNINDENT .INDENT 7.0 .TP .B Grad .UNINDENT .INDENT 7.0 .TP .B Radians .UNINDENT .UNINDENT .SS SortEntities .INDENT 0.0 .TP .B class ezdxf.enums.SortEntities(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B DISABLE .UNINDENT .INDENT 7.0 .TP .B SELECTION Sorts for object selection .UNINDENT .INDENT 7.0 .TP .B SNAP Sorts for object snap .UNINDENT .INDENT 7.0 .TP .B REDRAW Sorts for redraws; obsolete .UNINDENT .INDENT 7.0 .TP .B MSLIDE Sorts for MSLIDE command slide creation; obsolete .UNINDENT .INDENT 7.0 .TP .B REGEN Sorts for REGEN commands .UNINDENT .INDENT 7.0 .TP .B PLOT Sorts for plotting .UNINDENT .INDENT 7.0 .TP .B POSTSCRIPT Sorts for PostScript output; obsolete .UNINDENT .UNINDENT .SS ACI .INDENT 0.0 .TP .B class ezdxf.enums.ACI(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) AutoCAD Color Index .INDENT 7.0 .TP .B BYBLOCK .UNINDENT .INDENT 7.0 .TP .B BYLAYER .UNINDENT .INDENT 7.0 .TP .B BYOBJECT .UNINDENT .INDENT 7.0 .TP .B RED .UNINDENT .INDENT 7.0 .TP .B YELLOW .UNINDENT .INDENT 7.0 .TP .B GREEN .UNINDENT .INDENT 7.0 .TP .B CYAN .UNINDENT .INDENT 7.0 .TP .B BLUE .UNINDENT .INDENT 7.0 .TP .B MAGENTA .UNINDENT .INDENT 7.0 .TP .B BLACK .UNINDENT .INDENT 7.0 .TP .B WHITE .UNINDENT .INDENT 7.0 .TP .B GRAY .UNINDENT .INDENT 7.0 .TP .B LIGHT_GRAY .UNINDENT .UNINDENT .SS EndCaps .INDENT 0.0 .TP .B class ezdxf.enums.EndCaps(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Lineweight end caps setting for new objects. .INDENT 7.0 .TP .B NONE .UNINDENT .INDENT 7.0 .TP .B ROUND .UNINDENT .INDENT 7.0 .TP .B ANGLE .UNINDENT .INDENT 7.0 .TP .B SQUARE .UNINDENT .UNINDENT .SS JoinStyle .INDENT 0.0 .TP .B class ezdxf.enums.JoinStyle(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Lineweight joint setting for new objects. .INDENT 7.0 .TP .B NONE .UNINDENT .INDENT 7.0 .TP .B ROUND .UNINDENT .INDENT 7.0 .TP .B ANGLE .UNINDENT .INDENT 7.0 .TP .B FLAT .UNINDENT .UNINDENT .SS Colors .SS Colors Module .sp This module provides functions and constants to manage all kinds of colors in DXF documents. .SS Converter Functions .INDENT 0.0 .TP .B ezdxf.colors.rgb2int(rgb: \fI\%RGB\fP | tuple[int, int, int]) -> int Combined integer value from (r, g, b) tuple. .UNINDENT .INDENT 0.0 .TP .B ezdxf.colors.int2rgb(value: int) -> \fI\%RGB\fP Split RGB integer \fIvalue\fP into (r, g, b) tuple. .UNINDENT .INDENT 0.0 .TP .B ezdxf.colors.aci2rgb(index: int) -> \fI\%RGB\fP Convert \fI\%AutoCAD Color Index (ACI)\fP into (r, g, b) tuple, based on default AutoCAD colors. .UNINDENT .INDENT 0.0 .TP .B ezdxf.colors.luminance(color: \fI\%RGB\fP) -> float Returns perceived luminance for an RGB color in the range [0.0, 1.0] from dark to light. .UNINDENT .INDENT 0.0 .TP .B ezdxf.colors.decode_raw_color(value: int) -> tuple[int, int | \fI\%RGB\fP] Decode \fI\%raw\-color\fP value as tuple(type, Union[aci, (r, g, b)]), the true color value is a (r, g, b) tuple. .UNINDENT .INDENT 0.0 .TP .B ezdxf.colors.decode_raw_color_int(value: int) -> tuple[int, int] Decode \fI\%raw\-color\fP value as tuple(type, int), the true color value is a 24\-bit int value. .UNINDENT .INDENT 0.0 .TP .B ezdxf.colors.encode_raw_color(value: int | \fI\%RGB\fP) -> int Encode \fI\%true\-color\fP value or \fI\%AutoCAD Color Index (ACI)\fP color value into a :term: \fIraw color\fP value. .UNINDENT .INDENT 0.0 .TP .B ezdxf.colors.transparency2float(value: int) -> float Returns transparency value as float from 0 to 1, 0 for no transparency (opaque) and 1 for 100% transparency. .INDENT 7.0 .TP .B Parameters \fBvalue\fP – DXF integer transparency value, 0 for 100% transparency and 255 for opaque .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.colors.float2transparency(value: float) -> int Returns DXF transparency value as integer in the range from 0 to 255, where 0 is 100% transparent and 255 is opaque. .INDENT 7.0 .TP .B Parameters \fBvalue\fP – transparency value as float in the range from 0 to 1, where 0 is opaque and 1 is 100% transparent. .UNINDENT .UNINDENT .SS RGB Class .INDENT 0.0 .TP .B class ezdxf.colors.RGB(r: int, g: int, b: int) Named tuple representing an RGB color value. .INDENT 7.0 .TP .B r red channel in range [0, 255] .INDENT 7.0 .TP .B Type int .UNINDENT .UNINDENT .INDENT 7.0 .TP .B g green channel in range [0, 255] .INDENT 7.0 .TP .B Type int .UNINDENT .UNINDENT .INDENT 7.0 .TP .B b blue channel in range [0, 255] .INDENT 7.0 .TP .B Type int .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property luminance: float Returns perceived luminance for an RGB color in range [0.0, 1.0] from dark to light. .UNINDENT .INDENT 7.0 .TP .B to_hex() -> str Returns the color value as hex string “#RRGGBB”. .UNINDENT .INDENT 7.0 .TP .B classmethod from_hex(color: str) -> Self Returns an \fI\%RGB\fP instance from a hex color string, the \fIcolor\fP string is a hex string “RRGGBB” with an optional leading “#”, an appended alpha channel is ignore. .UNINDENT .INDENT 7.0 .TP .B to_floats() -> tuple[float, float, float] Returns the color value as a tuple of floats in range [0, 1]. .UNINDENT .INDENT 7.0 .TP .B classmethod from_floats(rgb: tuple[float, float, float]) -> Self Returns an \fI\%RGB\fP instance from floats in range [0, 1]. .UNINDENT .UNINDENT .SS ACI Color Values .sp Common \fI\%AutoCAD Color Index (ACI)\fP values, also accessible as IntEnum \fI\%ezdxf.enums.ACI\fP .TS center; |l|l|. _ T{ BYBLOCK T} T{ 0 T} _ T{ BYLAYER T} T{ 256 T} _ T{ BYOBJECT T} T{ 257 T} _ T{ RED T} T{ 1 T} _ T{ YELLOW T} T{ 2 T} _ T{ GREEN T} T{ 3 T} _ T{ CYAN T} T{ 4 T} _ T{ BLUE T} T{ 5 T} _ T{ MAGENTA T} T{ 6 T} _ T{ BLACK (on light background) T} T{ 7 T} _ T{ WHITE (on dark background) T} T{ 7 T} _ T{ GRAY T} T{ 8 T} _ T{ LIGHT_GRAY T} T{ 9 T} _ .TE .SS Default Palettes .sp Default color mappings from \fI\%AutoCAD Color Index (ACI)\fP to \fI\%true\-color\fP values. .TS center; |l|l|. _ T{ model space T} T{ DXF_DEFAULT_COLORS T} _ T{ paper space T} T{ DXF_DEFAULT_PAPERSPACE_COLORS T} _ .TE .SS Raw Color Types .TS center; |l|l|. _ T{ COLOR_TYPE_BY_LAYER T} T{ 0xC0 T} _ T{ COLOR_TYPE_BY_BLOCK T} T{ 0xC1 T} _ T{ COLOR_TYPE_RGB T} T{ 0xC2 T} _ T{ COLOR_TYPE_ACI T} T{ 0xC3 T} _ T{ COLOR_TYPE_WINDOW_BG T} T{ 0xC8 T} _ .TE .SS Raw Color Vales .TS center; |l|l|. _ T{ BY_LAYER_RAW_VALUE T} T{ \-1073741824 T} _ T{ BY_BLOCK_RAW_VALUE T} T{ \-1056964608 T} _ T{ WINDOW_BG_RAW_VALUE T} T{ \-939524096 T} _ .TE .SS Transparency Values .TS center; |l|l|. _ T{ OPAQUE T} T{ 0x20000FF T} _ T{ TRANSPARENCY_10 T} T{ 0x20000E5 T} _ T{ TRANSPARENCY_20 T} T{ 0x20000CC T} _ T{ TRANSPARENCY_30 T} T{ 0x20000B2 T} _ T{ TRANSPARENCY_40 T} T{ 0x2000099 T} _ T{ TRANSPARENCY_50 T} T{ 0x200007F T} _ T{ TRANSPARENCY_60 T} T{ 0x2000066 T} _ T{ TRANSPARENCY_70 T} T{ 0x200004C T} _ T{ TRANSPARENCY_80 T} T{ 0x2000032 T} _ T{ TRANSPARENCY_90 T} T{ 0x2000019 T} _ T{ TRANSPARENCY_BYBLOCK T} T{ 0x1000000 T} _ .TE .SS Data Query .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For usage of the query features see the tutorial: \fI\%Tutorial for Getting Data from DXF Files\fP .UNINDENT .UNINDENT .SS Entity Query String .INDENT 0.0 .INDENT 3.5 .sp .EX QueryString := EntityQuery (\(dq[\(dq AttribQuery \(dq]\(dq \(dqi\(dq?)* .EE .UNINDENT .UNINDENT .sp The query string is the combination of two queries, first the required entity query and second the optional attribute query, enclosed in square brackets, append \fB\(aqi\(aq\fP after the closing square bracket to ignore case for strings. .SS Entity Query .sp The entity query is a whitespace separated list of DXF entity names or the special name \fB\(aq*\(aq\fP\&. Where \fB\(aq*\(aq\fP means all DXF entities, exclude some entity types by appending their names with a preceding \fB!\fP (e.g. all entities except LINE = \fB\(aq* !LINE\(aq\fP). All DXF names have to be uppercase. .SS Attribute Query .sp The \fIoptional\fP attribute query is a boolean expression, supported operators are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 not (!): !term is true, if term is false .IP \(bu 2 and (&): term & term is true, if both terms are true .IP \(bu 2 or (|): term | term is true, if one term is true .IP \(bu 2 and arbitrary nested round brackets .IP \(bu 2 append (i) after the closing square bracket to ignore case for strings .UNINDENT .UNINDENT .UNINDENT .sp Attribute selection is a term: “name comparator value”, where name is a DXF entity attribute in lowercase, value is a integer, float or double quoted string, valid comparators are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB==\fP equal “value” .IP \(bu 2 \fB!=\fP not equal “value” .IP \(bu 2 \fB<\fP lower than “value” .IP \(bu 2 \fB<=\fP lower or equal than “value” .IP \(bu 2 \fB>\fP greater than “value” .IP \(bu 2 \fB>=\fP greater or equal than “value” .IP \(bu 2 \fB?\fP match regular expression “value” .IP \(bu 2 \fB!?\fP does not match regular expression “value” .UNINDENT .UNINDENT .UNINDENT .SS Query Result .sp The \fI\%EntityQuery\fP class is the return type of all \fBquery()\fP methods. \fI\%EntityQuery\fP contains all DXF entities of the source collection, which matches one name of the entity query AND the whole attribute query. If a DXF entity does not have or support a required attribute, the corresponding attribute search term is \fBFalse\fP\&. .sp examples: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBLINE[text ? \(dq.*\(dq]\fP: always empty, because the LINE entity has no text attribute. .IP \(bu 2 \fBLINE CIRCLE[layer==\(dqconstruction\(dq]\fP: all LINE and CIRCLE entities with layer == \fB\(dqconstruction\(dq\fP .IP \(bu 2 \fB*[!(layer==\(dqconstruction\(dq & color<7)]\fP: all entities except those with layer == \fB\(dqconstruction\(dq\fP and color < \fB7\fP .IP \(bu 2 \fB*[layer==\(dqconstruction\(dq]i\fP, (ignore case) all entities with layer == \fB\(dqconstruction\(dq\fP | \fB\(dqConstruction\(dq\fP | \fB\(dqConStruction\(dq\fP … .UNINDENT .UNINDENT .UNINDENT .SS EntityQuery Class .INDENT 0.0 .TP .B class ezdxf.query.EntityQuery The \fI\%EntityQuery\fP class is a result container, which is filled with DXF entities matching the query string. It is possible to add entities to the container (extend), remove entities from the container and to filter the container. Supports the standard \fI\%Python Sequence\fP methods and protocols. Does not remove automatically destroyed entities (entities deleted by calling method \fBdestroy()\fP), the method \fI\%purge()\fP has to be called explicitly to remove the destroyed entities. .INDENT 7.0 .TP .B first First entity or \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B last Last entity or \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of DXF entities. .UNINDENT .INDENT 7.0 .TP .B __getitem__(item) Returns DXFEntity at index \fIitem\fP, supports negative indices and slicing. Returns all entities which support a specific DXF attribute, if \fIitem\fP is a DXF attribute name as string. .UNINDENT .INDENT 7.0 .TP .B __setitem__(key, value) Set the DXF attribute \fIkey\fP for all supported DXF entities to \fIvalue\fP\&. .UNINDENT .INDENT 7.0 .TP .B __delitem__(key) Discard the DXF attribute \fIkey\fP from all supported DXF entities. .UNINDENT .INDENT 7.0 .TP .B __eq__(other) Equal selector (self == other). Returns all entities where the selected DXF attribute is equal to \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B __ne__(other) Not equal selector (self != other). Returns all entities where the selected DXF attribute is not equal to \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B __lt__(other) Less than selector (self < other). Returns all entities where the selected DXF attribute is less than \fIother\fP\&. .INDENT 7.0 .TP .B Raises \fBTypeError\fP – for vector based attributes like \fIcenter\fP or \fIinsert\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __le__(other) Less equal selector (self <= other). Returns all entities where the selected DXF attribute is less or equal \fIother\fP\&. .INDENT 7.0 .TP .B Raises \fBTypeError\fP – for vector based attributes like \fIcenter\fP or \fIinsert\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __gt__(other) Greater than selector (self > other). Returns all entities where the selected DXF attribute is greater than \fIother\fP\&. .INDENT 7.0 .TP .B Raises \fBTypeError\fP – for vector based attributes like \fIcenter\fP or \fIinsert\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __ge__(other) Greater equal selector (self >= other). Returns all entities where the selected DXF attribute is greater or equal \fIother\fP\&. .INDENT 7.0 .TP .B Raises \fBTypeError\fP – for vector based attributes like \fIcenter\fP or \fIinsert\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B match(pattern: str) -> \fI\%EntityQuery\fP Returns all entities where the selected DXF attribute matches the regular expression \fIpattern\fP\&. .INDENT 7.0 .TP .B Raises \fBTypeError\fP – for non\-string based attributes .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __or__(other) Union operator, see \fI\%union()\fP\&. .UNINDENT .INDENT 7.0 .TP .B __and__(other) Intersection operator, see \fI\%intersection()\fP\&. .UNINDENT .INDENT 7.0 .TP .B __sub__(other) Difference operator, see \fI\%difference()\fP\&. .UNINDENT .INDENT 7.0 .TP .B __xor__(other) Symmetric difference operator, see \fI\%symmetric_difference()\fP\&. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[DXFEntity] Returns iterable of DXFEntity objects. .UNINDENT .INDENT 7.0 .TP .B purge() -> \fI\%EntityQuery\fP Remove destroyed entities. .UNINDENT .INDENT 7.0 .TP .B extend(entities: Iterable[DXFEntity], query: str = \(aq*\(aq) -> \fI\%EntityQuery\fP Extent the \fI\%EntityQuery\fP container by entities matching an additional query. .UNINDENT .INDENT 7.0 .TP .B remove(query: str = \(aq*\(aq) -> \fI\%EntityQuery\fP Remove all entities from \fI\%EntityQuery\fP container matching this additional query. .UNINDENT .INDENT 7.0 .TP .B query(query: str = \(aq*\(aq) -> \fI\%EntityQuery\fP Returns a new \fI\%EntityQuery\fP container with all entities matching this additional query. .INDENT 7.0 .TP .B Raises \fBpyparsing.ParseException\fP – query string parsing error .UNINDENT .UNINDENT .INDENT 7.0 .TP .B groupby(dxfattrib: str = \(aq\(aq, key: Callable[[DXFEntity], Hashable] | None = None) -> dict[Hashable, list[DXFEntity]] Returns a dict of entity lists, where entities are grouped by a DXF attribute or a key function. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdxfattrib\fP – grouping DXF attribute as string like \fB\(aqlayer\(aq\fP .IP \(bu 2 \fBkey\fP – key function, which accepts a DXFEntity as argument, returns grouping key of this entity or \fBNone\fP for ignore this object. Reason for ignoring: a queried DXF attribute is not supported by this entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B filter(func: Callable[[DXFEntity], bool]) -> \fI\%EntityQuery\fP Returns a new \fI\%EntityQuery\fP with all entities from this container for which the callable \fIfunc\fP returns \fBTrue\fP\&. .sp Build your own operator to filter by attributes which are not DXF attributes or to build complex queries: .INDENT 7.0 .INDENT 3.5 .sp .EX result = msp.query().filter( lambda e: hasattr(e, \(dqrgb\(dq) and e.rbg == (0, 0, 0) ) .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B union(other: \fI\%EntityQuery\fP) -> \fI\%EntityQuery\fP Returns a new \fI\%EntityQuery\fP with entities from \fIself\fP and \fIother\fP\&. All entities are unique \- no duplicates. .UNINDENT .INDENT 7.0 .TP .B intersection(other: \fI\%EntityQuery\fP) -> \fI\%EntityQuery\fP Returns a new \fI\%EntityQuery\fP with entities common to \fIself\fP and \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B difference(other: \fI\%EntityQuery\fP) -> \fI\%EntityQuery\fP Returns a new \fI\%EntityQuery\fP with all entities from \fIself\fP that are not in \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B symmetric_difference(other: \fI\%EntityQuery\fP) -> \fI\%EntityQuery\fP Returns a new \fI\%EntityQuery\fP with entities in either \fIself\fP or \fIother\fP but not both. .UNINDENT .UNINDENT .SS Extended EntityQuery Features .sp The \fB[]\fP operator got extended features in version 0.18, until then the \fI\%EntityQuery\fP implemented the \fB__getitem__()\fP interface like a sequence to get entities from the container: .INDENT 0.0 .INDENT 3.5 .sp .EX result = msp.query(...) first = result[0] last = result[\-1] sequence = result[1:\-2] # returns not an EntityQuery container! .EE .UNINDENT .UNINDENT .sp Now the \fB__getitem__()\fP function accepts also a DXF attribute name and returns all entities which support this attribute, this is the base for supporting queries by relational operators. More on that later. .sp The \fB__setitem__()\fP method assigns a DXF attribute to all supported entities in the \fI\%EntityQuery\fP container: .INDENT 0.0 .INDENT 3.5 .sp .EX result = msp.query(...) result[\(dqlayer\(dq] = \(dqMyLayer\(dq .EE .UNINDENT .UNINDENT .sp Entities which do not support an attribute are silently ignored: .INDENT 0.0 .INDENT 3.5 .sp .EX result = msp.query(...) result[\(dqcenter\(dq] = (0, 0) # set center only of CIRCLE and ARC entities .EE .UNINDENT .UNINDENT .sp The \fB__delitem__()\fP method discards DXF attributes from all entities in the \fI\%EntityQuery\fP container: .INDENT 0.0 .INDENT 3.5 .sp .EX result = msp.query(...) # reset the layer attribute from all entities in container result to the # default layer \(dq0\(dq del result[\(dqlayer\(dq] .EE .UNINDENT .UNINDENT .SS Descriptors for DXF Attributes .sp For some basic DXF attributes exist descriptors in the \fI\%EntityQuery\fP class: .INDENT 0.0 .IP \(bu 2 \fBlayer\fP: layer name as string .IP \(bu 2 \fBcolor\fP: \fI\%AutoCAD Color Index (ACI)\fP, see \fI\%ezdxf.colors\fP .IP \(bu 2 \fBlinetype\fP: linetype as string .IP \(bu 2 \fBltscale\fP: linetype scaling factor as float value .IP \(bu 2 \fBlineweight\fP: \fI\%Lineweights\fP .IP \(bu 2 \fBinvisible\fP: 0 if visible 1 if invisible, 0 is the default value .IP \(bu 2 \fBtrue_color\fP: true color as int value, see \fI\%ezdxf.colors\fP, has no default value .IP \(bu 2 \fBtransparency\fP: transparency as int value, see \fI\%ezdxf.colors\fP, has no default value .UNINDENT .sp A descriptor simplifies the attribute access through the \fI\%EntityQuery\fP container and has auto\-completion support from IDEs: .INDENT 0.0 .INDENT 3.5 .sp .EX result = msp.query(...) # set attribute of all entities in result result.layer = \(dqMyLayer\(dq # delete attribute from all entities in result del result.layer # and for selector usage, see following section assert len(result.layer == \(dqMyLayer\(dq) == 1 .EE .UNINDENT .UNINDENT .SS Relational Selection Operators .sp The attribute selection by \fB__getitem__()\fP allows further selections by relational operators: .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_line((0, 0), (1, 0), dxfattribs={\(dqlayer\(dq: \(dqMyLayer}) lines = msp.query(\(dqLINE\(dq) # select all entities on layer \(dqMyLayer\(dq entities = lines[\(dqlayer\(dq] == \(dqMyLayer\(dq assert len(entities) == 1 # or select all entities except the entities on layer \(dqMyLayer\(dq entities = lines[\(dqlayer\(dq] != \(dqMyLayer\(dq .EE .UNINDENT .UNINDENT .sp These operators work only with real DXF attributes, for instance the \fBrgb\fP attribute of graphical entities is not a real DXF attribute either the \fBvertices\fP of the LWPOLYLINE entity. .sp The selection by relational operators is case insensitive by default, because all names of DXF table entries are handled case insensitive. But if required the selection mode can be set to case sensitive: .INDENT 0.0 .INDENT 3.5 .sp .EX lines = msp.query(\(dqLINE\(dq) # use case sensitive selection: \(dqMyLayer\(dq != \(dqMYLAYER\(dq lines.ignore_case = False entities = lines[\(dqlayer\(dq] == \(dqMYLAYER\(dq assert len(entities) == 0 # the result container has the default setting: assert entities.ignore_case is True .EE .UNINDENT .UNINDENT .sp Supported selection operators are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB==\fP equal “value” .IP \(bu 2 \fB!=\fP not equal “value” .IP \(bu 2 \fB<\fP lower than “value” .IP \(bu 2 \fB<=\fP lower or equal than “value” .IP \(bu 2 \fB>\fP greater than “value” .IP \(bu 2 \fB>=\fP greater or equal than “value” .UNINDENT .UNINDENT .UNINDENT .sp The relational operators <, >, <= and >= are not supported for vector\-based attributes such as \fIcenter\fP or \fIinsert\fP and raise a \fBTypeError\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 These operators are selection operators and not logic operators, therefore the logic operators \fBand\fP, \fBor\fP and \fBnot\fP are \fBnot\fP applicable. The methods \fI\%union()\fP, \fI\%intersection()\fP, \fI\%difference()\fP and \fI\%symmetric_difference()\fP can be used to combine selection. See section \fI\%Query Set Operators\fP and \fI\%Build Own Filters\fP\&. .UNINDENT .UNINDENT .SS Regular Expression Selection .sp The \fI\%EntityQuery.match()\fP method returns all entities where the selected DXF attribute matches the given regular expression. This methods work only on string based attributes, raises \fBTypeError\fP otherwise. .sp From here on I use only descriptors for attribute selection if possible. .INDENT 0.0 .INDENT 3.5 .sp .EX msp.add_line((0, 0), (1, 0), dxfattribs={\(dqlayer\(dq: \(dqLay1\(dq}) msp.add_line((0, 0), (1, 0), dxfattribs={\(dqlayer\(dq: \(dqLay2\(dq}) lines = msp.query(\(dqLINE\(dq) # select all entities at layers starting with \(dqLay\(dq, # selection is also case insensitive by default: assert len(lines.layer.match(\(dq^Lay.*\(dq)) == 2 .EE .UNINDENT .UNINDENT .SS Build Own Filters .sp The method \fI\%EntityQuery.filter\fP can be used to build operators for none\-DXF attributes or for complex logic expressions. .sp Find all MTEXT entities in modelspace containing “SearchText”. All \fI\%MText\fP entities have a \fBtext\fP attribute, no need for a safety check: .INDENT 0.0 .INDENT 3.5 .sp .EX mtext = msp.query(\(dqMTEXT\(dq).filter(lambda e: \(dqSearchText\(dq in e.text) .EE .UNINDENT .UNINDENT .sp This filter checks the non\-DXF attribute \fBrgb\fP\&. The filter has to check if the \fBrgb\fP attributes exist to avoid exceptions, because not all entities in modelspace may have the \fBrgb\fP attribute e.g. the \fBDXFTagStorage\fP entities which preserve unknown DXF entities: .INDENT 0.0 .INDENT 3.5 .sp .EX result = msp.query().filter( lambda e: hasattr(e, \(dqrgb\(dq) and e.rgb == (0, 0, 0) ) .EE .UNINDENT .UNINDENT .sp Build 1\-pass logic filters for complex queries, which would require otherwise multiple passes: .INDENT 0.0 .INDENT 3.5 .sp .EX result = msp.query().filter(lambda e: e.dxf.color < 7 and e.dxf.layer == \(dq0\(dq) .EE .UNINDENT .UNINDENT .sp Combine filters for more complex operations. The first filter passes only valid entities and the second filter does the actual check: .INDENT 0.0 .INDENT 3.5 .sp .EX def validator(entity): return True # if entity is valid and has all required attributes def check(entity): return True # if entity passes the attribute checks result = msp.query().filter(validator).filter(check) .EE .UNINDENT .UNINDENT .SS Query Set Operators .sp The \fB|\fP operator or \fI\%EntityQuery.union()\fP returns a new \fI\%EntityQuery\fP with all entities from both queries. All entities are unique \- no duplicates. This operator acts like the logical \fBor\fP operator. .INDENT 0.0 .INDENT 3.5 .sp .EX entities = msp.query() # select all entities with color < 2 or color > 7 result = (entities.color < 2 ) | (entities.color > 7) .EE .UNINDENT .UNINDENT .sp The \fB&\fP operator or \fI\%EntityQuery.intersection()\fP returns a new \fI\%EntityQuery\fP with entities common to \fIself\fP and \fIother\fP\&. This operator acts like the logical \fBand\fP operator. .INDENT 0.0 .INDENT 3.5 .sp .EX entities = msp.query() # select all entities with color > 1 and color < 7 result = (entities.color > 1) & (entities.color < 7) .EE .UNINDENT .UNINDENT .sp The \fB\-\fP operator or \fI\%EntityQuery.difference()\fP returns a new \fI\%EntityQuery\fP with all entities from \fIself\fP that are not in \fIother\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX entities = msp.query() # select all entities with color > 1 and not layer == \(dqMyLayer\(dq result = (entities.color > 1) \- (entities.layer != \(dqMyLayer\(dq) .EE .UNINDENT .UNINDENT .sp The \fB^\fP operator or \fI\%EntityQuery.symmetric_difference()\fP returns a new \fI\%EntityQuery\fP with entities in either \fIself\fP or \fIother\fP but not both. .INDENT 0.0 .INDENT 3.5 .sp .EX entities = msp.query() # select all entities with color > 1 or layer == \(dqMyLayer\(dq, exclusive # entities with color > 1 and layer == \(dqMyLayer\(dq result = (entities.color > 1) ^ (entities.layer == \(dqMyLayer\(dq) .EE .UNINDENT .UNINDENT .SS The new() Function .INDENT 0.0 .TP .B ezdxf.query.new(entities: Iterable[DXFEntity] | None = None, query: str = \(aq*\(aq) -> \fI\%EntityQuery\fP Start a new query based on sequence \fIentities\fP\&. The \fIentities\fP argument has to be an iterable of \fI\%DXFEntity\fP or inherited objects and returns an \fI\%EntityQuery\fP object. .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For usage of the groupby features see the tutorial: \fI\%Retrieve entities by groupby() function\fP .UNINDENT .UNINDENT .SS Groupby Function .INDENT 0.0 .TP .B ezdxf.groupby.groupby(entities: Iterable[\fI\%DXFEntity\fP], dxfattrib: str = \(aq\(aq, key: KeyFunc | None = None) -> dict[Hashable, list[\fI\%DXFEntity\fP]] Groups a sequence of DXF entities by a DXF attribute like \fB\(aqlayer\(aq\fP, returns a dict with \fIdxfattrib\fP values as key and a list of entities matching this \fIdxfattrib\fP\&. A \fIkey\fP function can be used to combine some DXF attributes (e.g. layer and color) and should return a hashable data type like a tuple of strings, integers or floats, \fIkey\fP function example: .INDENT 7.0 .INDENT 3.5 .sp .EX def group_key(entity: DXFEntity): return entity.dxf.layer, entity.dxf.color .EE .UNINDENT .UNINDENT .sp For not suitable DXF entities return \fBNone\fP to exclude this entity, in this case it’s not required, because \fI\%groupby()\fP catches \fBDXFAttributeError\fP exceptions to exclude entities, which do not provide layer and/or color attributes, automatically. .sp Result dict for \fIdxfattrib\fP = \fB\(aqlayer\(aq\fP may look like this: .INDENT 7.0 .INDENT 3.5 .sp .EX { \(aq0\(aq: [ ... list of entities ], \(aqExampleLayer1\(aq: [ ... ], \(aqExampleLayer2\(aq: [ ... ], ... } .EE .UNINDENT .UNINDENT .sp Result dict for \fIkey\fP = \fIgroup_key\fP, which returns a \fB(layer, color)\fP tuple, may look like this: .INDENT 7.0 .INDENT 3.5 .sp .EX { (\(aq0\(aq, 1): [ ... list of entities ], (\(aq0\(aq, 3): [ ... ], (\(aq0\(aq, 7): [ ... ], (\(aqExampleLayer1\(aq, 1): [ ... ], (\(aqExampleLayer1\(aq, 2): [ ... ], (\(aqExampleLayer1\(aq, 5): [ ... ], (\(aqExampleLayer2\(aq, 7): [ ... ], ... } .EE .UNINDENT .UNINDENT .sp All entity containers (modelspace, paperspace layouts and blocks) and the \fI\%EntityQuery\fP object have a dedicated \fI\%groupby()\fP method. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentities\fP – sequence of DXF entities to group by a DXF attribute or a \fIkey\fP function .IP \(bu 2 \fBdxfattrib\fP – grouping DXF attribute like \fB\(aqlayer\(aq\fP .IP \(bu 2 \fBkey\fP – key function, which accepts a \fBDXFEntity\fP as argument and returns a hashable grouping key or \fBNone\fP to ignore this entity .UNINDENT .UNINDENT .UNINDENT .SS Math .SS Core .sp Math core module: \fI\%ezdxf.math\fP .sp These are the core math functions and classes which should be imported from \fI\%ezdxf.math\fP\&. .SS Utility Functions .TS center; |l|l|. _ T{ \fI\%arc_angle_span_deg\fP T} T{ Returns the counter\-clockwise angle span from \fIstart\fP to \fIend\fP in degrees. T} _ T{ \fI\%arc_angle_span_rad\fP T} T{ Returns the counter\-clockwise angle span from \fIstart\fP to \fIend\fP in radians. T} _ T{ \fI\%arc_chord_length\fP T} T{ Returns the chord length for an arc defined by \fIradius\fP and the \fI\%sagitta\fP\&. T} _ T{ \fI\%arc_segment_count\fP T} T{ Returns the count of required segments for the approximation of an arc for a given maximum \fI\%sagitta\fP\&. T} _ T{ \fI\%area\fP T} T{ Returns the area of a polygon, returns the projected area in the xy\-plane for any vertices (z\-axis will be ignored). T} _ T{ \fI\%closest_point\fP T} T{ Returns the closest point to a give \fIbase\fP point. T} _ T{ \fI\%ellipse_param_span\fP T} T{ Returns the counter\-clockwise params span of an elliptic arc from start\- to end param. T} _ T{ \fI\%has_matrix_2d_stretching\fP T} T{ Returns \fBTrue\fP if matrix \fIm\fP performs a non\-uniform xy\-scaling. T} _ T{ \fI\%has_matrix_3d_stretching\fP T} T{ Returns \fBTrue\fP if matrix \fIm\fP performs a non\-uniform xyz\-scaling. T} _ T{ \fI\%linspace\fP T} T{ Return evenly spaced numbers over a specified interval, like numpy.linspace(). T} _ T{ \fI\%open_uniform_knot_vector\fP T} T{ Returns an open (clamped) uniform knot vector for a B\-spline of \fIorder\fP and \fIcount\fP control points. T} _ T{ \fI\%required_knot_values\fP T} T{ Returns the count of required knot\-values for a B\-spline of \fIorder\fP and \fIcount\fP control points. T} _ T{ \fI\%uniform_knot_vector\fP T} T{ Returns an uniform knot vector for a B\-spline of \fIorder\fP and \fIcount\fP control points. T} _ T{ \fI\%xround\fP T} T{ Extended rounding function. T} _ .TE .INDENT 0.0 .TP .B ezdxf.math.closest_point(base: \fI\%UVec\fP, points: Iterable[\fI\%UVec\fP]) -> \fI\%Vec3\fP Returns the closest point to a give \fIbase\fP point. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbase\fP – base point as \fI\%Vec3\fP compatible object .IP \(bu 2 \fBpoints\fP – iterable of points as \fI\%Vec3\fP compatible object .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.uniform_knot_vector(count: int, order: int, normalize=False) -> list[float] Returns an uniform knot vector for a B\-spline of \fIorder\fP and \fIcount\fP control points. .sp \fIorder\fP = degree + 1 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of control points .IP \(bu 2 \fBorder\fP – spline order .IP \(bu 2 \fBnormalize\fP – normalize values in range [0, 1] if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.open_uniform_knot_vector(count: int, order: int, normalize=False) -> list[float] Returns an open (clamped) uniform knot vector for a B\-spline of \fIorder\fP and \fIcount\fP control points. .sp \fIorder\fP = degree + 1 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of control points .IP \(bu 2 \fBorder\fP – spline order .IP \(bu 2 \fBnormalize\fP – normalize values in range [0, 1] if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.required_knot_values(count: int, order: int) -> int Returns the count of required knot\-values for a B\-spline of \fIorder\fP and \fIcount\fP control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of control points, in text\-books referred as “n + 1” .IP \(bu 2 \fBorder\fP – order of B\-Spline, in text\-books referred as “k” .UNINDENT .UNINDENT .sp Relationship: .sp “p” is the degree of the B\-spline, text\-book notation. .INDENT 7.0 .IP \(bu 2 k = p + 1 .IP \(bu 2 2 ≤ k ≤ n + 1 .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.xround(value: float, rounding: float = 0.) -> float Extended rounding function. .sp The argument \fIrounding\fP defines the rounding limit: .TS center; |l|l|. _ T{ 0 T} T{ remove fraction T} _ T{ 0.1 T} T{ round next to x.1, x.2, … x.0 T} _ T{ 0.25 T} T{ round next to x.25, x.50, x.75 or x.00 T} _ T{ 0.5 T} T{ round next to x.5 or x.0 T} _ T{ 1.0 T} T{ round to a multiple of 1: remove fraction T} _ T{ 2.0 T} T{ round to a multiple of 2: xxx2, xxx4, xxx6 … T} _ T{ 5.0 T} T{ round to a multiple of 5: xxx5 or xxx0 T} _ T{ 10.0 T} T{ round to a multiple of 10: xx10, xx20, … T} _ .TE .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvalue\fP – float value to round .IP \(bu 2 \fBrounding\fP – rounding limit .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linspace(start: float, stop: float, num: int, endpoint=True) -> Iterator[float] Return evenly spaced numbers over a specified interval, like numpy.linspace(). .sp Returns \fInum\fP evenly spaced samples, calculated over the interval [start, stop]. The endpoint of the interval can optionally be excluded. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.area(vertices: Iterable[\fI\%UVec\fP]) -> float Returns the area of a polygon, returns the projected area in the xy\-plane for any vertices (z\-axis will be ignored). .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.arc_angle_span_deg(start: float, end: float) -> float Returns the counter\-clockwise angle span from \fIstart\fP to \fIend\fP in degrees. .sp Returns the angle span in the range of [0, 360], 360 is a full circle. Full circle handling is a special case, because normalization of angles which describe a full circle would return 0 if treated as regular angles. e.g. (0, 360) → 360, (0, \-360) → 360, (180, \-180) → 360. Input angles with the same value always return 0 by definition: (0, 0) → 0, (\-180, \-180) → 0, (360, 360) → 0. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.arc_angle_span_rad(start: float, end: float) -> float Returns the counter\-clockwise angle span from \fIstart\fP to \fIend\fP in radians. .sp Returns the angle span in the range of [0, 2π], 2π is a full circle. Full circle handling is a special case, because normalization of angles which describe a full circle would return 0 if treated as regular angles. e.g. (0, 2π) → 2π, (0, \-2π) → 2π, (π, \-π) → 2π. Input angles with the same value always return 0 by definition: (0, 0) → 0, (\-π, \-π) → 0, (2π, 2π) → 0. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.arc_segment_count(radius: float, angle: float, sagitta: float) -> int Returns the count of required segments for the approximation of an arc for a given maximum \fI\%sagitta\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP – arc radius .IP \(bu 2 \fBangle\fP – angle span of the arc in radians .IP \(bu 2 \fBsagitta\fP – max. distance from the center of an arc segment to the center of its chord .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.arc_chord_length(radius: float, sagitta: float) -> float Returns the chord length for an arc defined by \fIradius\fP and the \fI\%sagitta\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP – arc radius .IP \(bu 2 \fBsagitta\fP – distance from the center of the arc to the center of its base .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.ellipse_param_span(start_param: float, end_param: float) -> float Returns the counter\-clockwise params span of an elliptic arc from start\- to end param. .sp Returns the param span in the range [0, 2π], 2π is a full ellipse. Full ellipse handling is a special case, because normalization of params which describe a full ellipse would return 0 if treated as regular params. e.g. (0, 2π) → 2π, (0, \-2π) → 2π, (π, \-π) → 2π. Input params with the same value always return 0 by definition: (0, 0) → 0, (\-π, \-π) → 0, (2π, 2π) → 0. .sp Alias to function: \fI\%ezdxf.math.arc_angle_span_rad()\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.has_matrix_2d_stretching(m: \fI\%Matrix44\fP) -> bool Returns \fBTrue\fP if matrix \fIm\fP performs a non\-uniform xy\-scaling. Uniform scaling is not stretching in this context. .sp Does not check if the target system is a cartesian coordinate system, use the \fI\%Matrix44\fP property \fI\%is_cartesian\fP for that. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.has_matrix_3d_stretching(m: \fI\%Matrix44\fP) -> bool Returns \fBTrue\fP if matrix \fIm\fP performs a non\-uniform xyz\-scaling. Uniform scaling is not stretching in this context. .sp Does not check if the target system is a cartesian coordinate system, use the \fI\%Matrix44\fP property \fI\%is_cartesian\fP for that. .UNINDENT .SS Bulge Related Functions .TS center; |l|l|. _ T{ \fI\%arc_to_bulge\fP T} T{ Returns bulge parameters from arc parameters. T} _ T{ \fI\%bulge_3_points\fP T} T{ Returns bulge value defined by three points. T} _ T{ \fI\%bulge_center\fP T} T{ Returns center of arc described by the given bulge parameters. T} _ T{ \fI\%bulge_radius\fP T} T{ Returns radius of arc defined by the given bulge parameters. T} _ T{ \fI\%bulge_to_arc\fP T} T{ Returns arc parameters from bulge parameters. T} _ T{ \fI\%bulge_from_radius_and_chord\fP T} T{ Returns the bulge value for the given arc radius and chord length. T} _ T{ \fI\%bulge_from_arc_angle\fP T} T{ Returns the bulge value for the given arc angle. T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Description of the \fI\%Bulge value\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.arc_to_bulge(center: \fI\%UVec\fP, start_angle: float, end_angle: float, radius: float) -> tuple[\fI\%Vec2\fP, \fI\%Vec2\fP, float] Returns bulge parameters from arc parameters. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – circle center point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBstart_angle\fP – start angle in radians .IP \(bu 2 \fBend_angle\fP – end angle in radians .IP \(bu 2 \fBradius\fP – circle radius .UNINDENT .TP .B Returns (start_point, end_point, bulge) .TP .B Return type tuple .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.bulge_3_points(start_point: \fI\%UVec\fP, end_point: \fI\%UVec\fP, point: \fI\%UVec\fP) -> float Returns bulge value defined by three points. .sp Based on 3\-Points to Bulge by \fI\%Lee Mac\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_point\fP – start point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBend_point\fP – end point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBpoint\fP – arbitrary point as \fI\%Vec2\fP compatible object .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.bulge_center(start_point: \fI\%UVec\fP, end_point: \fI\%UVec\fP, bulge: float) -> \fI\%Vec2\fP Returns center of arc described by the given bulge parameters. .sp Based on Bulge Center by \fI\%Lee Mac\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_point\fP – start point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBend_point\fP – end point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBbulge\fP – bulge value as float .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.bulge_radius(start_point: \fI\%UVec\fP, end_point: \fI\%UVec\fP, bulge: float) -> float Returns radius of arc defined by the given bulge parameters. .sp Based on Bulge Radius by \fI\%Lee Mac\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_point\fP – start point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBend_point\fP – end point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBbulge\fP – bulge value .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.bulge_to_arc(start_point: \fI\%UVec\fP, end_point: \fI\%UVec\fP, bulge: float) -> tuple[\fI\%Vec2\fP, float, float, float] Returns arc parameters from bulge parameters. .sp The arcs defined by bulge values of \fI\%LWPolyline\fP and 2D \fI\%Polyline\fP entities start at the vertex which includes the bulge value and ends at the following vertex. .sp Based on Bulge to Arc by \fI\%Lee Mac\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_point\fP – start vertex as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBend_point\fP – end vertex as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBbulge\fP – bulge value .UNINDENT .TP .B Returns (center, start_angle, end_angle, radius) .TP .B Return type Tuple .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.bulge_from_radius_and_chord(radius: float, chord: float) -> float Returns the bulge value for the given arc radius and chord length. Returns 0 if the radius is zero or the radius is too small for the given chord length to create an arc. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP – arc radius .IP \(bu 2 \fBchord\fP – chord length .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.bulge_from_arc_angle(angle: float) -> float Returns the bulge value for the given arc angle. .INDENT 7.0 .TP .B Parameters \fBangle\fP – arc angle in radians .UNINDENT .UNINDENT .SS 2D Graphic Functions .TS center; |l|l|. _ T{ \fI\%convex_hull_2d\fP T} T{ Returns the 2D convex hull of given \fIpoints\fP\&. T} _ T{ \fI\%distance_point_line_2d\fP T} T{ Returns the normal distance from \fIpoint\fP to 2D line defined by \fIstart\-\fP and \fIend\fP point. T} _ T{ \fI\%intersect_polylines_2d\fP T} T{ Returns the intersection points for two polylines as list of \fI\%Vec2\fP objects, the list is empty if no intersection points exist. T} _ T{ \fI\%intersection_line_line_2d\fP T} T{ Compute the intersection of two lines in the xy\-plane. T} _ T{ \fI\%is_convex_polygon_2d\fP T} T{ Returns \fBTrue\fP if the 2D \fIpolygon\fP is convex. T} _ T{ \fI\%is_point_in_polygon_2d\fP T} T{ Test if \fIpoint\fP is inside \fIpolygon\fP\&. T} _ T{ \fI\%is_point_left_of_line\fP T} T{ Returns \fBTrue\fP if \fIpoint\fP is \(dqleft of line\(dq defined by \fIstart\-\fP and \fIend\fP point, a colinear point is also \(dqleft of line\(dq if argument \fIcolinear\fP is \fBTrue\fP\&. T} _ T{ \fI\%is_point_on_line_2d\fP T} T{ Returns \fBTrue\fP if \fIpoint\fP is on \fIline\fP\&. T} _ T{ \fI\%offset_vertices_2d\fP T} T{ Yields vertices of the offset line to the shape defined by \fIvertices\fP\&. T} _ T{ \fI\%point_to_line_relation\fP T} T{ Returns \fB\-1\fP if \fIpoint\fP is left \fIline\fP, \fB+1\fP if \fIpoint\fP is right of \fIline\fP and \fB0\fP if \fIpoint\fP is on the \fIline\fP\&. T} _ T{ \fI\%rytz_axis_construction\fP T} T{ The Rytz’s axis construction is a basic method of descriptive Geometry to find the axes, the semi\-major axis and semi\-minor axis, starting from two conjugated half\-diameters. T} _ .TE .INDENT 0.0 .TP .B ezdxf.math.convex_hull_2d(points: Iterable[\fI\%UVec\fP]) -> list[\fI\%Vec2\fP] Returns the 2D convex hull of given \fIpoints\fP\&. .sp Returns a closed polyline, first vertex is equal to the last vertex. .INDENT 7.0 .TP .B Parameters \fBpoints\fP – iterable of points, z\-axis is ignored .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.distance_point_line_2d(point: \fI\%Vec2\fP, start: \fI\%Vec2\fP, end: \fI\%Vec2\fP) -> float Returns the normal distance from \fIpoint\fP to 2D line defined by \fIstart\-\fP and \fIend\fP point. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersect_polylines_2d(p1: Sequence[\fI\%Vec2\fP], p2: Sequence[\fI\%Vec2\fP], abs_tol=1e\-10) -> list[\fI\%Vec2\fP] Returns the intersection points for two polylines as list of \fI\%Vec2\fP objects, the list is empty if no intersection points exist. Does not return self intersection points of \fIp1\fP or \fIp2\fP\&. Duplicate intersection points are removed from the result list, but the list does not have a particular order! You can sort the result list by \fBresult.sort()\fP to introduce an order. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – first polyline as sequence of \fI\%Vec2\fP objects .IP \(bu 2 \fBp2\fP – second polyline as sequence of \fI\%Vec2\fP objects .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for comparisons .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersection_line_line_2d(line1: Sequence[\fI\%Vec2\fP], line2: Sequence[\fI\%Vec2\fP], virtual=True, abs_tol=TOLERANCE) -> \fI\%Vec2\fP | None Compute the intersection of two lines in the xy\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBline1\fP – start\- and end point of first line to test e.g. ((x1, y1), (x2, y2)). .IP \(bu 2 \fBline2\fP – start\- and end point of second line to test e.g. ((x3, y3), (x4, y4)). .IP \(bu 2 \fBvirtual\fP – \fBTrue\fP returns any intersection point, \fBFalse\fP returns only real intersection points. .IP \(bu 2 \fBabs_tol\fP – tolerance for intersection test. .UNINDENT .TP .B Returns \fBNone\fP if there is no intersection point (parallel lines) or intersection point as \fI\%Vec2\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.is_convex_polygon_2d(polygon: list[\fI\%Vec2\fP], *, strict=False, epsilon=1e\-6) -> bool Returns \fBTrue\fP if the 2D \fIpolygon\fP is convex. This function works with open and closed polygons and clockwise or counter\-clockwise vertex orientation. Coincident vertices will always be skipped and if argument \fIstrict\fP is \fBTrue\fP, polygons with collinear vertices are not considered as convex. .sp This solution works only for simple non\-self\-intersecting polygons! .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.is_point_in_polygon_2d(point: \fI\%Vec2\fP, polygon: Sequence[\fI\%Vec2\fP], abs_tol=TOLERANCE) -> int Test if \fIpoint\fP is inside \fIpolygon\fP\&. Returns \fB\-1\fP (for outside) if the polygon is degenerated, no exception will be raised. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – 2D point to test as \fI\%Vec2\fP .IP \(bu 2 \fBpolygon\fP – sequence of 2D points as \fI\%Vec2\fP .IP \(bu 2 \fBabs_tol\fP – tolerance for distance check .UNINDENT .TP .B Returns \fB+1\fP for inside, \fB0\fP for on boundary line, \fB\-1\fP for outside .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.is_point_left_of_line(point: \fI\%Vec2\fP, start: \fI\%Vec2\fP, end: \fI\%Vec2\fP, colinear=False) -> bool Returns \fBTrue\fP if \fIpoint\fP is “left of line” defined by \fIstart\-\fP and \fIend\fP point, a colinear point is also “left of line” if argument \fIcolinear\fP is \fBTrue\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – 2D point to test as \fI\%Vec2\fP .IP \(bu 2 \fBstart\fP – line definition point as \fI\%Vec2\fP .IP \(bu 2 \fBend\fP – line definition point as \fI\%Vec2\fP .IP \(bu 2 \fBcolinear\fP – a colinear point is also “left of line” if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.is_point_on_line_2d(point: \fI\%Vec2\fP, start: \fI\%Vec2\fP, end: \fI\%Vec2\fP, ray=True, abs_tol=TOLERANCE) -> bool Returns \fBTrue\fP if \fIpoint\fP is on \fIline\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – 2D point to test as \fI\%Vec2\fP .IP \(bu 2 \fBstart\fP – line definition point as \fI\%Vec2\fP .IP \(bu 2 \fBend\fP – line definition point as \fI\%Vec2\fP .IP \(bu 2 \fBray\fP – if \fBTrue\fP point has to be on the infinite ray, if \fBFalse\fP point has to be on the line segment .IP \(bu 2 \fBabs_tol\fP – tolerance for on the line test .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.offset_vertices_2d(vertices: Iterable[\fI\%UVec\fP], offset: float, closed: bool = False) -> Iterable[\fI\%Vec2\fP] Yields vertices of the offset line to the shape defined by \fIvertices\fP\&. The source shape consist of straight segments and is located in the xy\-plane, the z\-axis of input vertices is ignored. Takes closed shapes into account if argument \fIclosed\fP is \fBTrue\fP, which yields intersection of first and last offset segment as first vertex for a closed shape. For closed shapes the first and last vertex can be equal, else an implicit closing segment from last to first vertex is added. A shape with equal first and last vertex is not handled automatically as closed shape. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 Adjacent collinear segments in \fIopposite\fP directions, same as a turn by 180 degree (U\-turn), leads to unexpected results. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – source shape defined by vertices .IP \(bu 2 \fBoffset\fP – line offset perpendicular to direction of shape segments defined by vertices order, offset > \fB0\fP is ‘left’ of line segment, offset < \fB0\fP is ‘right’ of line segment .IP \(bu 2 \fBclosed\fP – \fBTrue\fP to handle as closed shape .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX source = [(0, 0), (3, 0), (3, 3), (0, 3)] result = list(offset_vertices_2d(source, offset=0.5, closed=True)) .EE .UNINDENT .UNINDENT [image] .sp Example for a closed collinear shape, which creates 2 additional vertices and the first one has an unexpected location: .INDENT 0.0 .INDENT 3.5 .sp .EX source = [(0, 0), (0, 1), (0, 2), (0, 3)] result = list(offset_vertices_2d(source, offset=0.5, closed=True)) .EE .UNINDENT .UNINDENT [image] .INDENT 0.0 .TP .B ezdxf.math.point_to_line_relation(point: \fI\%Vec2\fP, start: \fI\%Vec2\fP, end: \fI\%Vec2\fP, abs_tol=TOLERANCE) -> int Returns \fB\-1\fP if \fIpoint\fP is left \fIline\fP, \fB+1\fP if \fIpoint\fP is right of \fIline\fP and \fB0\fP if \fIpoint\fP is on the \fIline\fP\&. The \fIline\fP is defined by two vertices given as arguments \fIstart\fP and \fIend\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – 2D point to test as \fI\%Vec2\fP .IP \(bu 2 \fBstart\fP – line definition point as \fI\%Vec2\fP .IP \(bu 2 \fBend\fP – line definition point as \fI\%Vec2\fP .IP \(bu 2 \fBabs_tol\fP – tolerance for minimum distance to line .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.rytz_axis_construction(d1: \fI\%Vec3\fP, d2: \fI\%Vec3\fP) -> tuple[\fI\%Vec3\fP, \fI\%Vec3\fP, float] The Rytz’s axis construction is a basic method of descriptive Geometry to find the axes, the semi\-major axis and semi\-minor axis, starting from two conjugated half\-diameters. .sp Source: \fI\%Wikipedia\fP .sp Given conjugated diameter \fId1\fP is the vector from center C to point P and the given conjugated diameter \fId2\fP is the vector from center C to point Q. Center of ellipse is always \fB(0, 0, 0)\fP\&. This algorithm works for 2D/3D vectors. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBd1\fP – conjugated semi\-major axis as \fI\%Vec3\fP .IP \(bu 2 \fBd2\fP – conjugated semi\-minor axis as \fI\%Vec3\fP .UNINDENT .TP .B Returns Tuple of (major axis, minor axis, ratio) .UNINDENT .UNINDENT .SS 3D Graphic Functions .TS center; |l|l|. _ T{ \fI\%basic_transformation\fP T} T{ Returns a combined transformation matrix for translation, scaling and rotation about the z\-axis. T} _ T{ \fI\%best_fit_normal\fP T} T{ Returns the \(dqbest fit\(dq normal for a plane defined by three or more vertices. T} _ T{ \fI\%bezier_to_bspline\fP T} T{ Convert multiple quadratic or cubic Bèzier curves into a single cubic B\-spline. T} _ T{ \fI\%closed_uniform_bspline\fP T} T{ Creates a closed uniform (periodic) \fI\%B\-spline\fP curve (\fI\%open curve\fP). T} _ T{ \fI\%cubic_bezier_bbox\fP T} T{ Returns the \fI\%BoundingBox\fP of a cubic Bézier curve of type \fI\%Bezier4P\fP\&. T} _ T{ \fI\%cubic_bezier_from_3p\fP T} T{ Returns a cubic Bèzier curve \fI\%Bezier4P\fP from three points. T} _ T{ \fI\%cubic_bezier_from_arc\fP T} T{ Returns an approximation for a circular 2D arc by multiple cubic Bézier\-curves. T} _ T{ \fI\%cubic_bezier_from_ellipse\fP T} T{ Returns an approximation for an elliptic arc by multiple cubic Bézier\-curves. T} _ T{ \fI\%cubic_bezier_interpolation\fP T} T{ Returns an interpolation curve for given data \fIpoints\fP as multiple cubic Bézier\-curves. T} _ T{ \fI\%distance_point_line_3d\fP T} T{ Returns the normal distance from a \fIpoint\fP to a 3D line. T} _ T{ \fI\%estimate_end_tangent_magnitude\fP T} T{ Estimate tangent magnitude of start\- and end tangents. T} _ T{ \fI\%estimate_tangents\fP T} T{ Estimate tangents for curve defined by given fit points. T} _ T{ \fI\%fit_points_to_cad_cv\fP T} T{ Returns a cubic \fI\%BSpline\fP from fit points as close as possible to common CAD applications like BricsCAD. T} _ T{ \fI\%fit_points_to_cubic_bezier\fP T} T{ Returns a cubic \fI\%BSpline\fP from fit points \fBwithout\fP end tangents. T} _ T{ \fI\%global_bspline_interpolation\fP T} T{ \fI\%B\-spline\fP interpolation by the \fI\%Global Curve Interpolation\fP\&. T} _ T{ \fI\%have_bezier_curves_g1_continuity\fP T} T{ Return \fBTrue\fP if the given adjacent Bézier curves have G1 continuity. T} _ T{ \fI\%intersect_polylines_3d\fP T} T{ Returns the intersection points for two polylines as list of \fI\%Vec3\fP objects, the list is empty if no intersection points exist. T} _ T{ \fI\%intersection_line_line_3d\fP T} T{ Returns the intersection point of two 3D lines, returns \fBNone\fP if lines do not intersect. T} _ T{ \fI\%intersection_line_polygon_3d\fP T} T{ Returns the intersection point of the 3D line form \fIstart\fP to \fIend\fP and the given \fIpolygon\fP\&. T} _ T{ \fI\%intersection_ray_polygon_3d\fP T} T{ Returns the intersection point of the infinite 3D ray defined by \fIorigin\fP and the \fIdirection\fP vector and the given \fIpolygon\fP\&. T} _ T{ \fI\%intersection_ray_ray_3d\fP T} T{ Calculate intersection of two 3D rays, returns a 0\-tuple for parallel rays, a 1\-tuple for intersecting rays and a 2\-tuple for not intersecting and not parallel rays with points of the closest approach on each ray. T} _ T{ \fI\%is_planar_face\fP T} T{ Returns \fBTrue\fP if sequence of vectors is a planar face. T} _ T{ \fI\%linear_vertex_spacing\fP T} T{ Returns \fIcount\fP evenly spaced vertices from \fIstart\fP to \fIend\fP\&. T} _ T{ \fI\%local_cubic_bspline_interpolation\fP T} T{ \fI\%B\-spline\fP interpolation by \(aqLocal Cubic Curve Interpolation\(aq, which creates B\-spline from fit points and estimated tangent direction at start\-, end\- and passing points. T} _ T{ \fI\%normal_vector_3p\fP T} T{ Returns normal vector for 3 points, which is the normalized cross product for: \fBa\->b x a\->c\fP\&. T} _ T{ \fI\%open_uniform_bspline\fP T} T{ Creates an open uniform (periodic) \fI\%B\-spline\fP curve (\fI\%open curve\fP). T} _ T{ \fI\%quadratic_bezier_bbox\fP T} T{ Returns the \fI\%BoundingBox\fP of a quadratic Bézier curve of type \fI\%Bezier3P\fP\&. T} _ T{ \fI\%quadratic_bezier_from_3p\fP T} T{ Returns a quadratic Bèzier curve \fI\%Bezier3P\fP from three points. T} _ T{ \fI\%quadratic_to_cubic_bezier\fP T} T{ Convert quadratic Bèzier curves (\fI\%ezdxf.math.Bezier3P\fP) into cubic Bèzier curves (\fI\%ezdxf.math.Bezier4P\fP). T} _ T{ \fI\%rational_bspline_from_arc\fP T} T{ Returns a rational B\-splines for a circular 2D arc. T} _ T{ \fI\%rational_bspline_from_ellipse\fP T} T{ Returns a rational B\-splines for an elliptic arc. T} _ T{ \fI\%safe_normal_vector\fP T} T{ Safe function to detect the normal vector for a face or polygon defined by 3 or more \fIvertices\fP\&. T} _ T{ \fI\%spherical_envelope\fP T} T{ Calculate the spherical envelope for the given points. T} _ T{ \fI\%split_bezier\fP T} T{ Split a Bèzier curve at parameter \fIt\fP\&. T} _ T{ \fI\%split_polygon_by_plane\fP T} T{ Split a convex \fIpolygon\fP by the given \fIplane\fP\&. T} _ T{ \fI\%subdivide_face\fP T} T{ Subdivides faces by subdividing edges and adding a center vertex. T} _ T{ \fI\%subdivide_ngons\fP T} T{ Subdivides faces into triangles by adding a center vertex. T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 The free online book \fI\%3D Math Primer for Graphics and Game Development\fP is a very good resource for learning vector math and other graphic related topics, it is easy to read for beginners and especially targeted to programmers. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.basic_transformation(move: \fI\%UVec\fP = (0, 0, 0), scale: \fI\%UVec\fP = (1, 1, 1), z_rotation: float = 0) -> \fI\%Matrix44\fP Returns a combined transformation matrix for translation, scaling and rotation about the z\-axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmove\fP – translation vector .IP \(bu 2 \fBscale\fP – x\-, y\- and z\-axis scaling as float triplet, e.g. (2, 2, 1) .IP \(bu 2 \fBz_rotation\fP – rotation angle about the z\-axis in radians .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.best_fit_normal(vertices: Iterable[\fI\%UVec\fP]) -> \fI\%Vec3\fP Returns the “best fit” normal for a plane defined by three or more vertices. This function tolerates imperfect plane vertices. Safe function to detect the extrusion vector of flat arbitrary polygons. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.bezier_to_bspline(curves: Iterable[\fI\%Bezier3P\fP | \fI\%Bezier4P\fP]) -> \fI\%BSpline\fP Convert multiple quadratic or cubic Bèzier curves into a single cubic B\-spline. .sp For good results the curves must be lined up seamlessly, i.e. the starting point of the following curve must be the same as the end point of the previous curve. G1 continuity or better at the connection points of the Bézier curves is required to get best results. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.closed_uniform_bspline(control_points: Iterable[\fI\%UVec\fP], order: int = 4, weights: Iterable[float] | None = None) -> \fI\%BSpline\fP Creates a closed uniform (periodic) \fI\%B\-spline\fP curve (\fI\%open curve\fP). .sp This B\-spline does not pass any of the control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – iterable of control points as \fI\%Vec3\fP compatible objects .IP \(bu 2 \fBorder\fP – spline order (degree + 1) .IP \(bu 2 \fBweights\fP – iterable of weight values .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.cubic_bezier_bbox(curve: \fI\%Bezier4P\fP, *, abs_tol=1e\-12) -> \fI\%BoundingBox\fP Returns the \fI\%BoundingBox\fP of a cubic Bézier curve of type \fI\%Bezier4P\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.cubic_bezier_from_3p(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, p3: \fI\%UVec\fP) -> \fI\%Bezier4P\fP Returns a cubic Bèzier curve \fI\%Bezier4P\fP from three points. The curve starts at \fIp1\fP, goes through \fIp2\fP and ends at \fIp3\fP\&. (source: \fI\%pomax\-2\fP) .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.cubic_bezier_from_arc(center: \fI\%UVec\fP = (0, 0, 0), radius: float = 1, start_angle: float = 0, end_angle: float = 360, segments: int = 1) -> Iterator[\fI\%Bezier4P\fP] Returns an approximation for a circular 2D arc by multiple cubic Bézier\-curves. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – circle center as \fI\%Vec3\fP compatible object .IP \(bu 2 \fBradius\fP – circle radius .IP \(bu 2 \fBstart_angle\fP – start angle in degrees .IP \(bu 2 \fBend_angle\fP – end angle in degrees .IP \(bu 2 \fBsegments\fP – count of Bèzier\-curve segments, at least one segment for each quarter (90 deg), 1 for as few as possible. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.cubic_bezier_from_ellipse(ellipse: \fI\%ConstructionEllipse\fP, segments: int = 1) -> Iterator[\fI\%Bezier4P\fP] Returns an approximation for an elliptic arc by multiple cubic Bézier\-curves. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBellipse\fP – ellipse parameters as \fI\%ConstructionEllipse\fP object .IP \(bu 2 \fBsegments\fP – count of Bèzier\-curve segments, at least one segment for each quarter (π/2), 1 for as few as possible. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.cubic_bezier_interpolation(points: Iterable[\fI\%UVec\fP]) -> Iterable[\fI\%Bezier4P\fP] Returns an interpolation curve for given data \fIpoints\fP as multiple cubic Bézier\-curves. Returns n\-1 cubic Bézier\-curves for n given data points, curve i goes from point[i] to point[i+1]. .INDENT 7.0 .TP .B Parameters \fBpoints\fP – data points .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.distance_point_line_3d(point: \fI\%Vec3\fP, start: \fI\%Vec3\fP, end: \fI\%Vec3\fP) -> float Returns the normal distance from a \fIpoint\fP to a 3D line. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – point to test .IP \(bu 2 \fBstart\fP – start point of the 3D line .IP \(bu 2 \fBend\fP – end point of the 3D line .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.estimate_end_tangent_magnitude(points: list[\fI\%Vec3\fP], method: str = \(aqchord\(aq) -> tuple[float, float] Estimate tangent magnitude of start\- and end tangents. .sp Available estimation methods: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 “chord”: total chord length, curve approximation by straight segments .IP \(bu 2 “arc”: total arc length, curve approximation by arcs .IP \(bu 2 “bezier\-n”: total length from cubic bezier curve approximation, n segments per section .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – start\-, end\- and passing points of curve .IP \(bu 2 \fBmethod\fP – tangent magnitude estimation method .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.estimate_tangents(points: list[\fI\%Vec3\fP], method: str = \(aq5\-points\(aq, normalize=True) -> list[\fI\%Vec3\fP] Estimate tangents for curve defined by given fit points. Calculated tangents are normalized (unit\-vectors). .sp Available tangent estimation methods: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 “3\-points”: 3 point interpolation .IP \(bu 2 “5\-points”: 5 point interpolation .IP \(bu 2 “bezier”: tangents from an interpolated cubic bezier curve .IP \(bu 2 “diff”: finite difference .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – start\-, end\- and passing points of curve .IP \(bu 2 \fBmethod\fP – tangent estimation method .IP \(bu 2 \fBnormalize\fP – normalize tangents if \fBTrue\fP .UNINDENT .TP .B Returns tangents as list of \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.fit_points_to_cad_cv(fit_points: Iterable[\fI\%UVec\fP], tangents: Iterable[\fI\%UVec\fP] | None = None) -> \fI\%BSpline\fP Returns a cubic \fI\%BSpline\fP from fit points as close as possible to common CAD applications like BricsCAD. .sp There exist infinite numerical correct solution for this setup, but some facts are known: .INDENT 7.0 .IP \(bu 2 CAD applications use the global curve interpolation with start\- and end derivatives if the end tangents are defined otherwise the equation system will be completed by setting the second derivatives of the start and end point to 0, for more information read this answer on stackoverflow: \fI\%https://stackoverflow.com/a/74863330/6162864\fP .IP \(bu 2 The degree of the B\-spline is always 3 regardless which degree is stored in the SPLINE entity, this is only valid for B\-splines defined by fit points .IP \(bu 2 Knot parametrization method is “chord” .IP \(bu 2 Knot distribution is “natural” .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – points the spline is passing through .IP \(bu 2 \fBtangents\fP – start\- and end tangent, default is autodetect .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.fit_points_to_cubic_bezier(fit_points: Iterable[\fI\%UVec\fP]) -> \fI\%BSpline\fP Returns a cubic \fI\%BSpline\fP from fit points \fBwithout\fP end tangents. .sp This function uses the cubic Bèzier interpolation to create multiple Bèzier curves and combine them into a single B\-spline, this works for short simple splines better than the \fI\%fit_points_to_cad_cv()\fP, but is worse for longer and more complex splines. .INDENT 7.0 .TP .B Parameters \fBfit_points\fP – points the spline is passing through .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.global_bspline_interpolation(fit_points: Iterable[\fI\%UVec\fP], degree: int = 3, tangents: Iterable[\fI\%UVec\fP] | None = None, method: str = \(aqchord\(aq) -> \fI\%BSpline\fP \fI\%B\-spline\fP interpolation by the \fI\%Global Curve Interpolation\fP\&. Given are the fit points and the degree of the B\-spline. The function provides 3 methods for generating the parameter vector t: .INDENT 7.0 .IP \(bu 2 “uniform”: creates a uniform t vector, from 0 to 1 evenly spaced, see \fI\%uniform\fP method .IP \(bu 2 “chord”, “distance”: creates a t vector with values proportional to the fit point distances, see \fI\%chord length\fP method .IP \(bu 2 “centripetal”, “sqrt_chord”: creates a t vector with values proportional to the fit point sqrt(distances), see \fI\%centripetal\fP method .IP \(bu 2 “arc”: creates a t vector with values proportional to the arc length between fit points. .UNINDENT .sp It is possible to constraint the curve by tangents, by start\- and end tangent if only two tangents are given or by one tangent for each fit point. .sp If tangents are given, they represent 1st derivatives and should be scaled if they are unit vectors, if only start\- and end tangents given the function \fI\%estimate_end_tangent_magnitude()\fP helps with an educated guess, if all tangents are given, scaling by chord length is a reasonable choice (Piegl & Tiller). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – fit points of B\-spline, as list of \fI\%Vec3\fP compatible objects .IP \(bu 2 \fBtangents\fP – if only two vectors are given, take the first and the last vector as start\- and end tangent constraints or if for all fit points a tangent is given use all tangents as interpolation constraints (optional) .IP \(bu 2 \fBdegree\fP – degree of B\-spline .IP \(bu 2 \fBmethod\fP – calculation method for parameter vector t .UNINDENT .TP .B Returns \fI\%BSpline\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.have_bezier_curves_g1_continuity(b1: \fI\%Bezier3P\fP | \fI\%Bezier4P\fP, b2: \fI\%Bezier3P\fP | \fI\%Bezier4P\fP, g1_tol: float = 1e\-4) -> bool Return \fBTrue\fP if the given adjacent Bézier curves have G1 continuity. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersect_polylines_3d(p1: Sequence[\fI\%Vec3\fP], p2: Sequence[\fI\%Vec3\fP], abs_tol=1e\-10) -> list[\fI\%Vec3\fP] Returns the intersection points for two polylines as list of \fI\%Vec3\fP objects, the list is empty if no intersection points exist. Does not return self intersection points of \fIp1\fP or \fIp2\fP\&. Duplicate intersection points are removed from the result list, but the list does not have a particular order! You can sort the result list by \fBresult.sort()\fP to introduce an order. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – first polyline as sequence of \fI\%Vec3\fP objects .IP \(bu 2 \fBp2\fP – second polyline as sequence of \fI\%Vec3\fP objects .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for comparisons .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersection_line_line_3d(line1: Sequence[\fI\%Vec3\fP], line2: Sequence[\fI\%Vec3\fP], virtual: bool = True, abs_tol: float = 1e\-10) -> \fI\%Vec3\fP | None Returns the intersection point of two 3D lines, returns \fBNone\fP if lines do not intersect. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBline1\fP – first line as tuple of two points as \fI\%Vec3\fP objects .IP \(bu 2 \fBline2\fP – second line as tuple of two points as \fI\%Vec3\fP objects .IP \(bu 2 \fBvirtual\fP – \fBTrue\fP returns any intersection point, \fBFalse\fP returns only real intersection points .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for comparisons .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersection_line_polygon_3d(start: \fI\%Vec3\fP, end: \fI\%Vec3\fP, polygon: Iterable[\fI\%Vec3\fP], *, coplanar=True, boundary=True, abs_tol=PLANE_EPSILON) -> \fI\%Vec3\fP | None Returns the intersection point of the 3D line form \fIstart\fP to \fIend\fP and the given \fIpolygon\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart\fP – start point of 3D line as \fI\%Vec3\fP .IP \(bu 2 \fBend\fP – end point of 3D line as \fI\%Vec3\fP .IP \(bu 2 \fBpolygon\fP – 3D polygon as iterable of \fI\%Vec3\fP .IP \(bu 2 \fBcoplanar\fP – if \fBTrue\fP a coplanar start\- or end point as intersection point is valid .IP \(bu 2 \fBboundary\fP – if \fBTrue\fP an intersection point at the polygon boundary line is valid .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for comparisons .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersection_ray_polygon_3d(origin: \fI\%Vec3\fP, direction: \fI\%Vec3\fP, polygon: Iterable[\fI\%Vec3\fP], *, boundary=True, abs_tol=PLANE_EPSILON) -> \fI\%Vec3\fP | None Returns the intersection point of the infinite 3D ray defined by \fIorigin\fP and the \fIdirection\fP vector and the given \fIpolygon\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – origin point of the 3D ray as \fI\%Vec3\fP .IP \(bu 2 \fBdirection\fP – direction vector of the 3D ray as \fI\%Vec3\fP .IP \(bu 2 \fBpolygon\fP – 3D polygon as iterable of \fI\%Vec3\fP .IP \(bu 2 \fBboundary\fP – if \fBTrue\fP intersection points at the polygon boundary line are valid .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for comparisons .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersection_ray_ray_3d(ray1: Sequence[\fI\%Vec3\fP], ray2: Sequence[\fI\%Vec3\fP], abs_tol=TOLERANCE) -> Sequence[\fI\%Vec3\fP] Calculate intersection of two 3D rays, returns a 0\-tuple for parallel rays, a 1\-tuple for intersecting rays and a 2\-tuple for not intersecting and not parallel rays with points of the closest approach on each ray. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBray1\fP – first ray as tuple of two points as \fI\%Vec3\fP objects .IP \(bu 2 \fBray2\fP – second ray as tuple of two points as \fI\%Vec3\fP objects .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for comparisons .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.is_planar_face(face: Sequence[\fI\%Vec3\fP], abs_tol=1e\-9) -> bool Returns \fBTrue\fP if sequence of vectors is a planar face. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBface\fP – sequence of \fI\%Vec3\fP objects .IP \(bu 2 \fBabs_tol\fP – tolerance for normals check .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linear_vertex_spacing(start: \fI\%Vec3\fP, end: \fI\%Vec3\fP, count: int) -> list[\fI\%Vec3\fP] Returns \fIcount\fP evenly spaced vertices from \fIstart\fP to \fIend\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.local_cubic_bspline_interpolation(fit_points: Iterable[\fI\%UVec\fP], method: str = \(aq5\-points\(aq, tangents: Iterable[\fI\%UVec\fP] | None = None) -> \fI\%BSpline\fP \fI\%B\-spline\fP interpolation by ‘Local Cubic Curve Interpolation’, which creates B\-spline from fit points and estimated tangent direction at start\-, end\- and passing points. .sp Source: Piegl & Tiller: “The NURBS Book” \- chapter 9.3.4 .sp Available tangent estimation methods: .INDENT 7.0 .IP \(bu 2 “3\-points”: 3 point interpolation .IP \(bu 2 “5\-points”: 5 point interpolation .IP \(bu 2 “bezier”: cubic bezier curve interpolation .IP \(bu 2 “diff”: finite difference .UNINDENT .sp or pass pre\-calculated tangents, which overrides tangent estimation. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – all B\-spline fit points as \fI\%Vec3\fP compatible objects .IP \(bu 2 \fBmethod\fP – tangent estimation method .IP \(bu 2 \fBtangents\fP – tangents as \fI\%Vec3\fP compatible objects (optional) .UNINDENT .TP .B Returns \fI\%BSpline\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.normal_vector_3p(a: \fI\%Vec3\fP, b: \fI\%Vec3\fP, c: \fI\%Vec3\fP) -> \fI\%Vec3\fP Returns normal vector for 3 points, which is the normalized cross product for: \fBa\->b x a\->c\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.open_uniform_bspline(control_points: Iterable[\fI\%UVec\fP], order: int = 4, weights: Iterable[float] | None = None) -> \fI\%BSpline\fP Creates an open uniform (periodic) \fI\%B\-spline\fP curve (\fI\%open curve\fP). .sp This is an unclamped curve, which means the curve passes none of the control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – iterable of control points as \fI\%Vec3\fP compatible objects .IP \(bu 2 \fBorder\fP – spline order (degree + 1) .IP \(bu 2 \fBweights\fP – iterable of weight values .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.quadratic_bezier_bbox(curve: \fI\%Bezier3P\fP, *, abs_tol=1e\-12) -> \fI\%BoundingBox\fP Returns the \fI\%BoundingBox\fP of a quadratic Bézier curve of type \fI\%Bezier3P\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.quadratic_bezier_from_3p(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, p3: \fI\%UVec\fP) -> \fI\%Bezier3P\fP Returns a quadratic Bèzier curve \fI\%Bezier3P\fP from three points. The curve starts at \fIp1\fP, goes through \fIp2\fP and ends at \fIp3\fP\&. (source: \fI\%pomax\-2\fP) .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.quadratic_to_cubic_bezier(curve: \fI\%Bezier3P\fP) -> \fI\%Bezier4P\fP Convert quadratic Bèzier curves (\fI\%ezdxf.math.Bezier3P\fP) into cubic Bèzier curves (\fI\%ezdxf.math.Bezier4P\fP). .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.rational_bspline_from_arc(center: \fI\%Vec3\fP = (0, 0), radius: float = 1, start_angle: float = 0, end_angle: float = 360, segments: int = 1) -> \fI\%BSpline\fP Returns a rational B\-splines for a circular 2D arc. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – circle center as \fI\%Vec3\fP compatible object .IP \(bu 2 \fBradius\fP – circle radius .IP \(bu 2 \fBstart_angle\fP – start angle in degrees .IP \(bu 2 \fBend_angle\fP – end angle in degrees .IP \(bu 2 \fBsegments\fP – count of spline segments, at least one segment for each quarter (90 deg), default is 1, for as few as needed. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.rational_bspline_from_ellipse(ellipse: \fI\%ConstructionEllipse\fP, segments: int = 1) -> \fI\%BSpline\fP Returns a rational B\-splines for an elliptic arc. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBellipse\fP – ellipse parameters as \fI\%ConstructionEllipse\fP object .IP \(bu 2 \fBsegments\fP – count of spline segments, at least one segment for each quarter (π/2), default is 1, for as few as needed. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.safe_normal_vector(vertices: Sequence[\fI\%Vec3\fP]) -> \fI\%Vec3\fP Safe function to detect the normal vector for a face or polygon defined by 3 or more \fIvertices\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.spherical_envelope(points: Sequence[\fI\%UVec\fP]) -> tuple[\fI\%Vec3\fP, float] Calculate the spherical envelope for the given points. Returns the centroid (a.k.a. geometric center) and the radius of the enclosing sphere. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 The result does not represent the minimal bounding sphere! .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.split_bezier(control_points: Sequence[T], t: float) -> tuple[list[T], list[T]] Split a Bèzier curve at parameter \fIt\fP\&. .sp Returns the control points for two new Bèzier curves of the same degree and type as the input curve. (source: \fI\%pomax\-1\fP) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – of the Bèzier curve as \fI\%Vec2\fP or \fI\%Vec3\fP objects. Requires 3 points for a quadratic curve, 4 points for a cubic curve , … .IP \(bu 2 \fBt\fP – parameter where to split the curve in the range [0, 1] .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.split_polygon_by_plane(polygon: Iterable[\fI\%Vec3\fP], plane: \fI\%Plane\fP, *, coplanar=True, abs_tol=PLANE_EPSILON) -> tuple[Sequence[\fI\%Vec3\fP], Sequence[\fI\%Vec3\fP]] Split a convex \fIpolygon\fP by the given \fIplane\fP\&. .sp Returns a tuple of front\- and back vertices (front, back). Returns also coplanar polygons if the argument \fIcoplanar\fP is \fBTrue\fP, the coplanar vertices goes into either front or back depending on their orientation with respect to this plane. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.subdivide_face(face: Sequence[\fI\%Vec2\fP | \fI\%Vec3\fP], quads: bool = True) -> Iterable[tuple[\fI\%Vec3\fP, \&...]] Subdivides faces by subdividing edges and adding a center vertex. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBface\fP – a sequence of vertices, \fI\%Vec2\fP and \fI\%Vec3\fP objects supported. .IP \(bu 2 \fBquads\fP – create quad faces if \fBTrue\fP else create triangles .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.subdivide_ngons(faces: Iterable[Sequence[\fI\%Vec2\fP | \fI\%Vec3\fP]], max_vertex_count=4) -> Iterable[Sequence[\fI\%Vec3\fP]] Subdivides faces into triangles by adding a center vertex. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfaces\fP – iterable of faces as sequence of \fI\%Vec2\fP and \fI\%Vec3\fP objects .IP \(bu 2 \fBmax_vertex_count\fP – subdivide only ngons with more vertices .UNINDENT .UNINDENT .UNINDENT .SS Transformation Classes .TS center; |l|l|. _ T{ \fI\%Matrix44\fP T} T{ An optimized 4x4 \fI\%transformation matrix\fP\&. T} _ T{ \fI\%OCS\fP T} T{ Establish an \fI\%OCS\fP for a given extrusion vector. T} _ T{ \fI\%UCS\fP T} T{ Establish a user coordinate system (\fI\%UCS\fP). T} _ .TE .SS OCS Class .INDENT 0.0 .TP .B class ezdxf.math.OCS(extrusion: \fI\%UVec\fP = Z_AXIS) Establish an \fI\%OCS\fP for a given extrusion vector. .INDENT 7.0 .TP .B Parameters \fBextrusion\fP – extrusion vector. .UNINDENT .INDENT 7.0 .TP .B ux x\-axis unit vector .UNINDENT .INDENT 7.0 .TP .B uy y\-axis unit vector .UNINDENT .INDENT 7.0 .TP .B uz z\-axis unit vector .UNINDENT .INDENT 7.0 .TP .B from_wcs(point: \fI\%UVec\fP) -> \fI\%UVec\fP Returns OCS vector for WCS \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_from_wcs(points: Iterable[\fI\%UVec\fP]) -> Iterable[\fI\%UVec\fP] Returns iterable of OCS vectors from WCS \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B to_wcs(point: \fI\%UVec\fP) -> \fI\%UVec\fP Returns WCS vector for OCS \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_to_wcs(points: Iterable[\fI\%UVec\fP]) -> Iterable[\fI\%UVec\fP] Returns iterable of WCS vectors for OCS \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B render_axis(layout: \fI\%BaseLayout\fP, length: float = 1, colors: \fI\%RGB\fP = RGB(1, 3, 5)) -> None Render axis as 3D lines into a \fIlayout\fP\&. .UNINDENT .UNINDENT .SS UCS Class .INDENT 0.0 .TP .B class ezdxf.math.UCS(origin: \fI\%UVec\fP = (0, 0, 0), ux: \fI\%UVec\fP | None = None, uy: \fI\%UVec\fP | None = None, uz: \fI\%UVec\fP | None = None) Establish a user coordinate system (\fI\%UCS\fP). The UCS is defined by the origin and two unit vectors for the x\-, y\- or z\-axis, all axis in \fI\%WCS\fP\&. The missing axis is the cross product of the given axis. .sp If x\- and y\-axis are \fBNone\fP: ux = \fB(1, 0, 0)\fP, uy = \fB(0, 1, 0)\fP, uz = \fB(0, 0, 1)\fP\&. .sp Unit vectors don’t have to be normalized, normalization is done at initialization, this is also the reason why scaling gets lost by copying or rotating. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – defines the UCS origin in world coordinates .IP \(bu 2 \fBux\fP – defines the UCS x\-axis as vector in \fI\%WCS\fP .IP \(bu 2 \fBuy\fP – defines the UCS y\-axis as vector in \fI\%WCS\fP .IP \(bu 2 \fBuz\fP – defines the UCS z\-axis as vector in \fI\%WCS\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B ux x\-axis unit vector .UNINDENT .INDENT 7.0 .TP .B uy y\-axis unit vector .UNINDENT .INDENT 7.0 .TP .B uz z\-axis unit vector .UNINDENT .INDENT 7.0 .TP .B is_cartesian Returns \fBTrue\fP if cartesian coordinate system. .UNINDENT .INDENT 7.0 .TP .B copy() -> \fI\%UCS\fP Returns a copy of this UCS. .UNINDENT .INDENT 7.0 .TP .B to_wcs(point: \fI\%Vec3\fP) -> \fI\%Vec3\fP Returns WCS point for UCS \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_to_wcs(points: Iterable[\fI\%Vec3\fP]) -> Iterable[\fI\%Vec3\fP] Returns iterable of WCS vectors for UCS \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B direction_to_wcs(vector: \fI\%Vec3\fP) -> \fI\%Vec3\fP Returns WCS direction for UCS \fIvector\fP without origin adjustment. .UNINDENT .INDENT 7.0 .TP .B from_wcs(point: \fI\%Vec3\fP) -> \fI\%Vec3\fP Returns UCS point for WCS \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_from_wcs(points: Iterable[\fI\%Vec3\fP]) -> Iterable[\fI\%Vec3\fP] Returns iterable of UCS vectors from WCS \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B direction_from_wcs(vector: \fI\%Vec3\fP) -> \fI\%Vec3\fP Returns UCS vector for WCS \fIvector\fP without origin adjustment. .UNINDENT .INDENT 7.0 .TP .B to_ocs(point: \fI\%Vec3\fP) -> \fI\%Vec3\fP Returns OCS vector for UCS \fIpoint\fP\&. .sp The \fI\%OCS\fP is defined by the z\-axis of the \fI\%UCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_to_ocs(points: Iterable[\fI\%Vec3\fP]) -> Iterable[\fI\%Vec3\fP] Returns iterable of OCS vectors for UCS \fIpoints\fP\&. .sp The \fI\%OCS\fP is defined by the z\-axis of the \fI\%UCS\fP\&. .INDENT 7.0 .TP .B Parameters \fBpoints\fP – iterable of UCS vertices .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_ocs_angle_deg(angle: float) -> float Transforms \fIangle\fP from current UCS to the parent coordinate system (most likely the WCS) including the transformation to the OCS established by the extrusion vector \fI\%UCS.uz\fP\&. .INDENT 7.0 .TP .B Parameters \fBangle\fP – in UCS in degrees .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%UCS\fP General inplace transformation interface, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters \fBm\fP – 4x4 transformation matrix (\fI\%ezdxf.math.Matrix44\fP) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(axis: \fI\%UVec\fP, angle: float) -> \fI\%UCS\fP Returns a new rotated UCS, with the same origin as the source UCS. The rotation vector is located in the origin and has \fI\%WCS\fP coordinates e.g. (0, 0, 1) is the WCS z\-axis as rotation vector. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBaxis\fP – arbitrary rotation axis as vector in \fI\%WCS\fP .IP \(bu 2 \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_local_x(angle: float) -> \fI\%UCS\fP Returns a new rotated UCS, rotation axis is the local x\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_local_y(angle: float) -> \fI\%UCS\fP Returns a new rotated UCS, rotation axis is the local y\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_local_z(angle: float) -> \fI\%UCS\fP Returns a new rotated UCS, rotation axis is the local z\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B shift(delta: \fI\%UVec\fP) -> \fI\%UCS\fP Shifts current UCS by \fIdelta\fP vector and returns \fIself\fP\&. .INDENT 7.0 .TP .B Parameters \fBdelta\fP – shifting vector .UNINDENT .UNINDENT .INDENT 7.0 .TP .B moveto(location: \fI\%UVec\fP) -> \fI\%UCS\fP Place current UCS at new origin \fIlocation\fP and returns \fIself\fP\&. .INDENT 7.0 .TP .B Parameters \fBlocation\fP – new origin in WCS .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_x_axis_and_point_in_xy(origin: \fI\%UVec\fP, axis: \fI\%UVec\fP, point: \fI\%UVec\fP) -> \fI\%UCS\fP Returns a new \fI\%UCS\fP defined by the origin, the x\-axis vector and an arbitrary point in the xy\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – UCS origin as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBaxis\fP – x\-axis vector as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the xy\-plane as (x, y, z) tuple in \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_x_axis_and_point_in_xz(origin: \fI\%UVec\fP, axis: \fI\%UVec\fP, point: \fI\%UVec\fP) -> \fI\%UCS\fP Returns a new \fI\%UCS\fP defined by the origin, the x\-axis vector and an arbitrary point in the xz\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – UCS origin as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBaxis\fP – x\-axis vector as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the xz\-plane as (x, y, z) tuple in \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_y_axis_and_point_in_xy(origin: \fI\%UVec\fP, axis: \fI\%UVec\fP, point: \fI\%UVec\fP) -> \fI\%UCS\fP Returns a new \fI\%UCS\fP defined by the origin, the y\-axis vector and an arbitrary point in the xy\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – UCS origin as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBaxis\fP – y\-axis vector as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the xy\-plane as (x, y, z) tuple in \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_y_axis_and_point_in_yz(origin: \fI\%UVec\fP, axis: \fI\%UVec\fP, point: \fI\%UVec\fP) -> \fI\%UCS\fP Returns a new \fI\%UCS\fP defined by the origin, the y\-axis vector and an arbitrary point in the yz\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – UCS origin as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBaxis\fP – y\-axis vector as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the yz\-plane as (x, y, z) tuple in \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_z_axis_and_point_in_xz(origin: \fI\%UVec\fP, axis: \fI\%UVec\fP, point: \fI\%UVec\fP) -> \fI\%UCS\fP Returns a new \fI\%UCS\fP defined by the origin, the z\-axis vector and an arbitrary point in the xz\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – UCS origin as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBaxis\fP – z\-axis vector as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the xz\-plane as (x, y, z) tuple in \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_z_axis_and_point_in_yz(origin: \fI\%UVec\fP, axis: \fI\%UVec\fP, point: \fI\%UVec\fP) -> \fI\%UCS\fP Returns a new \fI\%UCS\fP defined by the origin, the z\-axis vector and an arbitrary point in the yz\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – UCS origin as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBaxis\fP – z\-axis vector as (x, y, z) tuple in \fI\%WCS\fP .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the yz\-plane as (x, y, z) tuple in \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_axis(layout: \fI\%BaseLayout\fP, length: float = 1, colors: \fI\%RGB\fP = RGB(1, 3, 5)) Render axis as 3D lines into a \fIlayout\fP\&. .UNINDENT .UNINDENT .SS Matrix44 .INDENT 0.0 .TP .B class ezdxf.math.Matrix44(*args) An optimized 4x4 \fI\%transformation matrix\fP\&. .sp The utility functions for constructing transformations and transforming vectors and points assumes that vectors are stored as row vectors, meaning when multiplied, transformations are applied left to right (e.g. vAB transforms v by A then by B). .sp Matrix44 initialization: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBMatrix44()\fP returns the identity matrix. .IP \(bu 2 \fBMatrix44(values)\fP values is an iterable with the 16 components of the matrix. .IP \(bu 2 \fBMatrix44(row1, row2, row3, row4)\fP four rows, each row with four values. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __repr__() -> str Returns the representation string of the matrix: \fBMatrix44((col0, col1, col2, col3), (...), (...), (...))\fP .UNINDENT .INDENT 7.0 .TP .B get_row(row: int) -> tuple[float, \&...] Get row as list of four float values. .INDENT 7.0 .TP .B Parameters \fBrow\fP – row index [0 .. 3] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_row(row: int, values: Sequence[float]) -> None Sets the values in a row. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBrow\fP – row index [0 .. 3] .IP \(bu 2 \fBvalues\fP – iterable of four row values .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_col(col: int) -> tuple[float, \&...] Returns a column as a tuple of four floats. .INDENT 7.0 .TP .B Parameters \fBcol\fP – column index [0 .. 3] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_col(col: int, values: Sequence[float]) Sets the values in a column. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcol\fP – column index [0 .. 3] .IP \(bu 2 \fBvalues\fP – iterable of four column values .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B copy() -> \fI\%Matrix44\fP Returns a copy of same type. .UNINDENT .INDENT 7.0 .TP .B __copy__() -> \fI\%Matrix44\fP Returns a copy of same type. .UNINDENT .INDENT 7.0 .TP .B classmethod scale(sx: float, sy: float | None = None, sz: float | None = None) -> \fI\%Matrix44\fP Returns a scaling transformation matrix. If \fIsy\fP is \fBNone\fP, \fIsy\fP = \fIsx\fP, and if \fIsz\fP is \fBNone\fP \fIsz\fP = \fIsx\fP\&. .UNINDENT .INDENT 7.0 .TP .B classmethod translate(dx: float, dy: float, dz: float) -> \fI\%Matrix44\fP Returns a translation matrix for translation vector (dx, dy, dz). .UNINDENT .INDENT 7.0 .TP .B classmethod x_rotate(angle: float) -> \fI\%Matrix44\fP Returns a rotation matrix about the x\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod y_rotate(angle: float) -> \fI\%Matrix44\fP Returns a rotation matrix about the y\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod z_rotate(angle: float) -> \fI\%Matrix44\fP Returns a rotation matrix about the z\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod axis_rotate(axis: \fI\%UVec\fP, angle: float) -> \fI\%Matrix44\fP Returns a rotation matrix about an arbitrary \fIaxis\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBaxis\fP – rotation axis as \fB(x, y, z)\fP tuple or \fI\%Vec3\fP object .IP \(bu 2 \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod xyz_rotate(angle_x: float, angle_y: float, angle_z: float) -> \fI\%Matrix44\fP Returns a rotation matrix for rotation about each axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle_x\fP – rotation angle about x\-axis in radians .IP \(bu 2 \fBangle_y\fP – rotation angle about y\-axis in radians .IP \(bu 2 \fBangle_z\fP – rotation angle about z\-axis in radians .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod shear_xy(angle_x: float = 0, angle_y: float = 0) -> \fI\%Matrix44\fP Returns a translation matrix for shear mapping (visually similar to slanting) in the xy\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle_x\fP – slanting angle in x direction in radians .IP \(bu 2 \fBangle_y\fP – slanting angle in y direction in radians .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod perspective_projection(left: float, right: float, top: float, bottom: float, near: float, far: float) -> \fI\%Matrix44\fP Returns a matrix for a 2D projection. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBleft\fP – Coordinate of left of screen .IP \(bu 2 \fBright\fP – Coordinate of right of screen .IP \(bu 2 \fBtop\fP – Coordinate of the top of the screen .IP \(bu 2 \fBbottom\fP – Coordinate of the bottom of the screen .IP \(bu 2 \fBnear\fP – Coordinate of the near clipping plane .IP \(bu 2 \fBfar\fP – Coordinate of the far clipping plane .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod perspective_projection_fov(fov: float, aspect: float, near: float, far: float) -> \fI\%Matrix44\fP Returns a matrix for a 2D projection. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfov\fP – The field of view (in radians) .IP \(bu 2 \fBaspect\fP – The aspect ratio of the screen (width / height) .IP \(bu 2 \fBnear\fP – Coordinate of the near clipping plane .IP \(bu 2 \fBfar\fP – Coordinate of the far clipping plane .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static chain(*matrices: \fI\%Matrix44\fP) -> \fI\%Matrix44\fP Compose a transformation matrix from one or more \fImatrices\fP\&. .UNINDENT .INDENT 7.0 .TP .B static ucs(ux: \fI\%Vec3\fP = X_AXIS, uy: \fI\%Vec3\fP = Y_AXIS, uz: \fI\%Vec3\fP = Z_AXIS, origin: \fI\%Vec3\fP = NULLVEC) -> \fI\%Matrix44\fP Returns a matrix for coordinate transformation from WCS to UCS. For transformation from UCS to WCS, transpose the returned matrix. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBux\fP – x\-axis for UCS as unit vector .IP \(bu 2 \fBuy\fP – y\-axis for UCS as unit vector .IP \(bu 2 \fBuz\fP – z\-axis for UCS as unit vector .IP \(bu 2 \fBorigin\fP – UCS origin as location vector .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __hash__() Return hash(self). .UNINDENT .INDENT 7.0 .TP .B __getitem__(index: tuple[int, int]) Get (row, column) element. .UNINDENT .INDENT 7.0 .TP .B __setitem__(index: tuple[int, int], value: float) Set (row, column) element. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[float] Iterates over all matrix values. .UNINDENT .INDENT 7.0 .TP .B rows() -> Iterator[tuple[float, \&...]] Iterate over rows as 4\-tuples. .UNINDENT .INDENT 7.0 .TP .B columns() -> Iterator[tuple[float, \&...]] Iterate over columns as 4\-tuples. .UNINDENT .INDENT 7.0 .TP .B __mul__(other: \fI\%Matrix44\fP) -> \fI\%Matrix44\fP Returns a new matrix as result of the matrix multiplication with another matrix. .UNINDENT .INDENT 7.0 .TP .B __imul__(other: \fI\%Matrix44\fP) -> \fI\%Matrix44\fP Inplace multiplication with another matrix. .UNINDENT .INDENT 7.0 .TP .B transform(vector: \fI\%UVec\fP) -> \fI\%Vec3\fP Returns a transformed vertex. .UNINDENT .INDENT 7.0 .TP .B transform_direction(vector: \fI\%UVec\fP, normalize=False) -> \fI\%Vec3\fP Returns a transformed direction vector without translation. .UNINDENT .INDENT 7.0 .TP .B transform_vertices(vectors: Iterable[\fI\%UVec\fP]) -> Iterator[\fI\%Vec3\fP] Returns an iterable of transformed vertices. .UNINDENT .INDENT 7.0 .TP .B fast_2d_transform(points: Iterable[\fI\%UVec\fP]) -> Iterator[\fI\%Vec2\fP] Fast transformation of 2D points. For 3D input points the z\-axis will be ignored. This only works reliable if only 2D transformations have been applied to the 4x4 matrix! .sp Profiling results \- speed gains over \fI\%transform_vertices()\fP: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 pure Python code: ~1.6x .IP \(bu 2 Python with C\-extensions: less than 1.1x .IP \(bu 2 PyPy 3.8: ~4.3x .UNINDENT .UNINDENT .UNINDENT .sp But speed isn’t everything, returning the processed input points as \fI\%Vec2\fP instances is another advantage. .sp New in version 1.1. .UNINDENT .INDENT 7.0 .TP .B transform_directions(vectors: Iterable[\fI\%UVec\fP], normalize=False) -> Iterator[\fI\%Vec3\fP] Returns an iterable of transformed direction vectors without translation. .UNINDENT .INDENT 7.0 .TP .B transpose() -> None Swaps the rows for columns inplace. .UNINDENT .INDENT 7.0 .TP .B determinant() -> float Returns determinant. .UNINDENT .INDENT 7.0 .TP .B inverse() -> None Calculates the inverse of the matrix. .INDENT 7.0 .TP .B Raises \fBZeroDivisionError\fP – if matrix has no inverse. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property is_cartesian: bool Returns \fBTrue\fP if target coordinate system is a right handed orthogonal coordinate system. .UNINDENT .INDENT 7.0 .TP .B property is_orthogonal: bool Returns \fBTrue\fP if target coordinate system has orthogonal axis. .sp Does not check for left\- or right handed orientation, any orientation of the axis valid. .UNINDENT .UNINDENT .SS Basic Construction Classes .TS center; |l|l|. _ T{ \fI\%BoundingBox\fP T} T{ 3D bounding box. T} _ T{ \fI\%BoundingBox2d\fP T} T{ 2D bounding box. T} _ T{ \fI\%ConstructionArc\fP T} T{ Construction tool for 2D arcs. T} _ T{ \fI\%ConstructionBox\fP T} T{ Construction tool for 2D rectangles. T} _ T{ \fI\%ConstructionCircle\fP T} T{ Construction tool for 2D circles. T} _ T{ \fI\%ConstructionEllipse\fP T} T{ Construction tool for 3D ellipsis. T} _ T{ \fI\%ConstructionLine\fP T} T{ Construction tool for 2D lines. T} _ T{ \fI\%ConstructionPolyline\fP T} T{ Construction tool for 3D polylines. T} _ T{ \fI\%ConstructionRay\fP T} T{ Construction tool for infinite 2D rays. T} _ T{ \fI\%Plane\fP T} T{ Construction tool for 3D planes. T} _ T{ \fI\%Shape2d\fP T} T{ Construction tools for 2D shapes. T} _ T{ \fI\%Vec2\fP T} T{ Immutable 2D vector class. T} _ T{ \fI\%Vec3\fP T} T{ Immutable 3D vector class. T} _ .TE .SS UVec .INDENT 0.0 .TP .B class ezdxf.math.UVec Type alias for \fBUnion[Sequence[float], Vec2, Vec3]\fP .UNINDENT .SS Vec3 .INDENT 0.0 .TP .B class ezdxf.math.Vec3(*args) Immutable 3D vector class. .sp This class is optimized for universality not for speed. Immutable means you can’t change (x, y, z) components after initialization: .INDENT 7.0 .INDENT 3.5 .sp .EX v1 = Vec3(1, 2, 3) v2 = v1 v2.z = 7 # this is not possible, raises AttributeError v2 = Vec3(v2.x, v2.y, 7) # this creates a new Vec3() object assert v1.z == 3 # and v1 remains unchanged .EE .UNINDENT .UNINDENT .sp \fI\%Vec3\fP initialization: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBVec3()\fP, returns \fBVec3(0, 0, 0)\fP .IP \(bu 2 \fBVec3((x, y))\fP, returns \fBVec3(x, y, 0)\fP .IP \(bu 2 \fBVec3((x, y, z))\fP, returns \fBVec3(x, y, z)\fP .IP \(bu 2 \fBVec3(x, y)\fP, returns \fBVec3(x, y, 0)\fP .IP \(bu 2 \fBVec3(x, y, z)\fP, returns \fBVec3(x, y, z)\fP .UNINDENT .UNINDENT .UNINDENT .sp Addition, subtraction, scalar multiplication and scalar division left and right\-handed are supported: .INDENT 7.0 .INDENT 3.5 .sp .EX v = Vec3(1, 2, 3) v + (1, 2, 3) == Vec3(2, 4, 6) (1, 2, 3) + v == Vec3(2, 4, 6) v \- (1, 2, 3) == Vec3(0, 0, 0) (1, 2, 3) \- v == Vec3(0, 0, 0) v * 3 == Vec3(3, 6, 9) 3 * v == Vec3(3, 6, 9) Vec3(3, 6, 9) / 3 == Vec3(1, 2, 3) \-Vec3(1, 2, 3) == (\-1, \-2, \-3) .EE .UNINDENT .UNINDENT .sp Comparison between vectors and vectors or tuples is supported: .INDENT 7.0 .INDENT 3.5 .sp .EX Vec3(1, 2, 3) < Vec3 (2, 2, 2) (1, 2, 3) < tuple(Vec3(2, 2, 2)) # conversion necessary Vec3(1, 2, 3) == (1, 2, 3) bool(Vec3(1, 2, 3)) is True bool(Vec3(0, 0, 0)) is False .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B x x\-axis value .UNINDENT .INDENT 7.0 .TP .B y y\-axis value .UNINDENT .INDENT 7.0 .TP .B z z\-axis value .UNINDENT .INDENT 7.0 .TP .B xy Vec3 as \fB(x, y, 0)\fP, projected on the xy\-plane. .UNINDENT .INDENT 7.0 .TP .B xyz Vec3 as \fB(x, y, z)\fP tuple. .UNINDENT .INDENT 7.0 .TP .B vec2 Real 2D vector as \fI\%Vec2\fP object. .UNINDENT .INDENT 7.0 .TP .B magnitude Length of vector. .UNINDENT .INDENT 7.0 .TP .B magnitude_xy Length of vector in the xy\-plane. .UNINDENT .INDENT 7.0 .TP .B magnitude_square Square length of vector. .UNINDENT .INDENT 7.0 .TP .B is_null \fBVec3(0, 0, 0)\fP\&. Has a fixed absolute testing tolerance of 1e\-12! .INDENT 7.0 .TP .B Type \fBTrue\fP if all components are close to zero .UNINDENT .UNINDENT .INDENT 7.0 .TP .B angle Angle between vector and x\-axis in the xy\-plane in radians. .UNINDENT .INDENT 7.0 .TP .B angle_deg Returns angle of vector and x\-axis in the xy\-plane in degrees. .UNINDENT .INDENT 7.0 .TP .B spatial_angle Spatial angle between vector and x\-axis in radians. .UNINDENT .INDENT 7.0 .TP .B spatial_angle_deg Spatial angle between vector and x\-axis in degrees. .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Return \fB\(aq(x, y, z)\(aq\fP as string. .UNINDENT .INDENT 7.0 .TP .B __repr__() -> str Return \fB\(aqVec3(x, y, z)\(aq\fP as string. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns always \fB3\fP\&. .UNINDENT .INDENT 7.0 .TP .B __hash__() -> int Returns hash value of vector, enables the usage of vector as key in \fBset\fP and \fBdict\fP\&. .UNINDENT .INDENT 7.0 .TP .B copy() -> \fI\%Vec3\fP Returns a copy of vector as \fI\%Vec3\fP object. .UNINDENT .INDENT 7.0 .TP .B __copy__() -> \fI\%Vec3\fP Returns a copy of vector as \fI\%Vec3\fP object. .UNINDENT .INDENT 7.0 .TP .B __deepcopy__(memodict: dict) -> \fI\%Vec3\fP \fBcopy.deepcopy()\fP support. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index: int) -> float Support for indexing: .INDENT 7.0 .IP \(bu 2 v[0] is v.x .IP \(bu 2 v[1] is v.y .IP \(bu 2 v[2] is v.z .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[float] Returns iterable of x\-, y\- and z\-axis. .UNINDENT .INDENT 7.0 .TP .B __abs__() -> float Returns length (magnitude) of vector. .UNINDENT .INDENT 7.0 .TP .B replace(x: float | None = None, y: float | None = None, z: float | None = None) -> \fI\%Vec3\fP Returns a copy of vector with replaced x\-, y\- and/or z\-axis. .UNINDENT .INDENT 7.0 .TP .B classmethod generate(items: Iterable[\fI\%UVec\fP]) -> Iterable[\fI\%Vec3\fP] Returns an iterable of \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B classmethod list(items: Iterable[\fI\%UVec\fP]) -> list[\fI\%Vec3\fP] Returns a list of \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B classmethod tuple(items: Iterable[\fI\%UVec\fP]) -> Sequence[\fI\%Vec3\fP] Returns a tuple of \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B classmethod from_angle(angle: float, length: float = 1.0) -> \fI\%Vec3\fP Returns a \fI\%Vec3\fP object from \fIangle\fP in radians in the xy\-plane, z\-axis = \fB0\fP\&. .UNINDENT .INDENT 7.0 .TP .B classmethod from_deg_angle(angle: float, length: float = 1.0) -> \fI\%Vec3\fP Returns a \fI\%Vec3\fP object from \fIangle\fP in degrees in the xy\-plane, z\-axis = \fB0\fP\&. .UNINDENT .INDENT 7.0 .TP .B orthogonal(ccw: bool = True) -> \fI\%Vec3\fP Returns orthogonal 2D vector, z\-axis is unchanged. .INDENT 7.0 .TP .B Parameters \fBccw\fP – counter\-clockwise if \fBTrue\fP else clockwise .UNINDENT .UNINDENT .INDENT 7.0 .TP .B lerp(other: \fI\%UVec\fP, factor=0.5) -> \fI\%Vec3\fP Returns linear interpolation between \fIself\fP and \fIother\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBother\fP – end point as \fI\%Vec3\fP compatible object .IP \(bu 2 \fBfactor\fP – interpolation factor (0 = self, 1 = other, 0.5 = mid point) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B is_parallel(other: \fI\%Vec3\fP, *, rel_tol: float = 1e\-9, abs_tol: float = 1e\-12) -> bool Returns \fBTrue\fP if \fIself\fP and \fIother\fP are parallel to vectors. .UNINDENT .INDENT 7.0 .TP .B project(other: \fI\%UVec\fP) -> \fI\%Vec3\fP Returns projected vector of \fIother\fP onto \fIself\fP\&. .UNINDENT .INDENT 7.0 .TP .B normalize(length: float = 1.0) -> \fI\%Vec3\fP Returns normalized vector, optional scaled by \fIlength\fP\&. .UNINDENT .INDENT 7.0 .TP .B reversed() -> \fI\%Vec3\fP Returns negated vector (\-\fIself\fP). .UNINDENT .INDENT 7.0 .TP .B isclose(other: \fI\%UVec\fP, *, rel_tol: float = 1e\-9, abs_tol: float = 1e\-12) -> bool Returns \fBTrue\fP if \fIself\fP is close to \fIother\fP\&. Uses \fBmath.isclose()\fP to compare all axis. .sp Learn more about the \fBmath.isclose()\fP function in \fI\%PEP 485\fP\&. .UNINDENT .INDENT 7.0 .TP .B __neg__() -> \fI\%Vec3\fP Returns negated vector (\-\fIself\fP). .UNINDENT .INDENT 7.0 .TP .B __bool__() -> bool Returns \fBTrue\fP if vector is not (0, 0, 0). .UNINDENT .INDENT 7.0 .TP .B __eq__(other: \fI\%UVec\fP) -> bool Equal operator. .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vec3\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __lt__(other: \fI\%UVec\fP) -> bool Lower than operator. .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vec3\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __add__(other: \fI\%UVec\fP) -> \fI\%Vec3\fP Add \fI\%Vec3\fP operator: \fIself\fP + \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B __radd__(other: \fI\%UVec\fP) -> \fI\%Vec3\fP RAdd \fI\%Vec3\fP operator: \fIother\fP + \fIself\fP\&. .UNINDENT .INDENT 7.0 .TP .B __sub__(other: \fI\%UVec\fP) -> \fI\%Vec3\fP Sub \fI\%Vec3\fP operator: \fIself\fP \- \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B __rsub__(other: \fI\%UVec\fP) -> \fI\%Vec3\fP RSub \fI\%Vec3\fP operator: \fIother\fP \- \fIself\fP\&. .UNINDENT .INDENT 7.0 .TP .B __mul__(other: float) -> \fI\%Vec3\fP Scalar Mul operator: \fIself\fP * \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B __rmul__(other: float) -> \fI\%Vec3\fP Scalar RMul operator: \fIother\fP * \fIself\fP\&. .UNINDENT .INDENT 7.0 .TP .B __truediv__(other: float) -> \fI\%Vec3\fP Scalar Div operator: \fIself\fP / \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B dot(other: \fI\%UVec\fP) -> float Dot operator: \fIself\fP . \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vec3\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B cross(other: \fI\%UVec\fP) -> \fI\%Vec3\fP Cross operator: \fIself\fP x \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vec3\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B distance(other: \fI\%UVec\fP) -> float Returns distance between \fIself\fP and \fIother\fP vector. .UNINDENT .INDENT 7.0 .TP .B angle_about(base: \fI\%UVec\fP, target: \fI\%UVec\fP) -> float Returns counter\-clockwise angle in radians about \fIself\fP from \fIbase\fP to \fItarget\fP when projected onto the plane defined by \fIself\fP as the normal vector. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbase\fP – base vector, defines angle 0 .IP \(bu 2 \fBtarget\fP – target vector .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B angle_between(other: \fI\%UVec\fP) -> float Returns angle between \fIself\fP and \fIother\fP in radians. +angle is counter clockwise orientation. .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vec3\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle: float) -> \fI\%Vec3\fP Returns vector rotated about \fIangle\fP around the z\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_deg(angle: float) -> \fI\%Vec3\fP Returns vector rotated about \fIangle\fP around the z\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – angle in degrees .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static sum(items: Iterable[\fI\%UVec\fP]) -> \fI\%Vec3\fP Add all vectors in \fIitems\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.X_AXIS \fBVec3(1, 0, 0)\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.Y_AXIS \fBVec3(0, 1, 0)\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.Z_AXIS \fBVec3(0, 0, 1)\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.NULLVEC \fBVec3(0, 0, 0)\fP .UNINDENT .SS Vec2 .INDENT 0.0 .TP .B class ezdxf.math.Vec2(v=(0.0, 0.0), y=None) Immutable 2D vector class. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBv\fP – vector object with \fBx\fP and \fBy\fP attributes/properties or a sequence of float \fB[x, y, ...]\fP or x\-axis as float if argument \fIy\fP is not \fBNone\fP .IP \(bu 2 \fBy\fP – second float for \fBVec2(x, y)\fP .UNINDENT .UNINDENT .sp \fI\%Vec2\fP implements a subset of \fI\%Vec3\fP\&. .UNINDENT .SS Plane .INDENT 0.0 .TP .B class ezdxf.math.Plane(normal: \fI\%Vec3\fP, distance: float) Construction tool for 3D planes. .sp Represents a plane in 3D space as a normal vector and the perpendicular distance from the origin. .INDENT 7.0 .TP .B normal Normal vector of the plane. .UNINDENT .INDENT 7.0 .TP .B distance_from_origin The (perpendicular) distance of the plane from origin (0, 0, 0). .UNINDENT .INDENT 7.0 .TP .B vector Returns the location vector. .UNINDENT .INDENT 7.0 .TP .B classmethod from_3p(a: \fI\%Vec3\fP, b: \fI\%Vec3\fP, c: \fI\%Vec3\fP) -> \fI\%Plane\fP Returns a new plane from 3 points in space. .UNINDENT .INDENT 7.0 .TP .B classmethod from_vector(vector: \fI\%UVec\fP) -> \fI\%Plane\fP Returns a new plane from the given location vector. .UNINDENT .INDENT 7.0 .TP .B copy() -> \fI\%Plane\fP Returns a copy of the plane. .UNINDENT .INDENT 7.0 .TP .B signed_distance_to(v: \fI\%Vec3\fP) -> float Returns signed distance of vertex \fIv\fP to plane, if distance is > 0, \fIv\fP is in ‘front’ of plane, in direction of the normal vector, if distance is < 0, \fIv\fP is at the ‘back’ of the plane, in the opposite direction of the normal vector. .UNINDENT .INDENT 7.0 .TP .B distance_to(v: \fI\%Vec3\fP) -> float Returns absolute (unsigned) distance of vertex \fIv\fP to plane. .UNINDENT .INDENT 7.0 .TP .B is_coplanar_vertex(v: \fI\%Vec3\fP, abs_tol=1e\-9) -> bool Returns \fBTrue\fP if vertex \fIv\fP is coplanar, distance from plane to vertex \fIv\fP is 0. .UNINDENT .INDENT 7.0 .TP .B is_coplanar_plane(p: \fI\%Plane\fP, abs_tol=1e\-9) -> bool Returns \fBTrue\fP if plane \fIp\fP is coplanar, normal vectors in same or opposite direction. .UNINDENT .INDENT 7.0 .TP .B intersect_line(start: \fI\%Vec3\fP, end: \fI\%Vec3\fP, *, coplanar=True, abs_tol=PLANE_EPSILON) -> \fI\%Vec3\fP | None Returns the intersection point of the 3D line from \fIstart\fP to \fIend\fP and this plane or \fBNone\fP if there is no intersection. If the argument \fIcoplanar\fP is \fBFalse\fP the start\- or end point of the line are ignored as intersection points. .UNINDENT .INDENT 7.0 .TP .B intersect_ray(origin: \fI\%Vec3\fP, direction: \fI\%Vec3\fP) -> \fI\%Vec3\fP | None Returns the intersection point of the infinite 3D ray defined by \fIorigin\fP and the \fIdirection\fP vector and this plane or \fBNone\fP if there is no intersection. A coplanar ray does not intersect the plane! .UNINDENT .UNINDENT .SS BoundingBox .INDENT 0.0 .TP .B class ezdxf.math.BoundingBox(vertices: Iterable[\fI\%UVec\fP] | None = None) 3D bounding box. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of \fB(x, y, z)\fP tuples or \fI\%Vec3\fP objects .UNINDENT .INDENT 7.0 .TP .B extmin “lower left” corner of bounding box .UNINDENT .INDENT 7.0 .TP .B extmax “upper right” corner of bounding box .UNINDENT .INDENT 7.0 .TP .B property is_empty: bool Returns \fBTrue\fP if the bounding box is empty or the bounding box has a size of 0 in any or all dimensions or is undefined. .UNINDENT .INDENT 7.0 .TP .B property has_data: bool Returns \fBTrue\fP if the bonding box has known limits. .UNINDENT .INDENT 7.0 .TP .B property size Returns size of bounding box. .UNINDENT .INDENT 7.0 .TP .B property center Returns center of bounding box. .UNINDENT .INDENT 7.0 .TP .B inside(vertex: \fI\%UVec\fP) -> bool Returns \fBTrue\fP if \fIvertex\fP is inside this bounding box. .sp Vertices at the box border are inside! .UNINDENT .INDENT 7.0 .TP .B any_inside(vertices: Iterable[\fI\%UVec\fP]) -> bool Returns \fBTrue\fP if any vertex is inside this bounding box. .sp Vertices at the box border are inside! .UNINDENT .INDENT 7.0 .TP .B all_inside(vertices: Iterable[\fI\%UVec\fP]) -> bool Returns \fBTrue\fP if all vertices are inside this bounding box. .sp Vertices at the box border are inside! .UNINDENT .INDENT 7.0 .TP .B has_intersection(other: AbstractBoundingBox) -> bool Returns \fBTrue\fP if this bounding box intersects with \fIother\fP but does not include touching bounding boxes, see also \fI\%has_overlap()\fP: .INDENT 7.0 .INDENT 3.5 .sp .EX bbox1 = BoundingBox([(0, 0, 0), (1, 1, 1)]) bbox2 = BoundingBox([(1, 1, 1), (2, 2, 2)]) assert bbox1.has_intersection(bbox2) is False .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_overlap(other: AbstractBoundingBox) -> bool Returns \fBTrue\fP if this bounding box intersects with \fIother\fP but in contrast to \fI\%has_intersection()\fP includes touching bounding boxes too: .INDENT 7.0 .INDENT 3.5 .sp .EX bbox1 = BoundingBox([(0, 0, 0), (1, 1, 1)]) bbox2 = BoundingBox([(1, 1, 1), (2, 2, 2)]) assert bbox1.has_overlap(bbox2) is True .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B contains(other: AbstractBoundingBox) -> bool Returns \fBTrue\fP if the \fIother\fP bounding box is completely inside this bounding box. .UNINDENT .INDENT 7.0 .TP .B extend(vertices: Iterable[\fI\%UVec\fP]) -> None Extend bounds by \fIvertices\fP\&. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of vertices .UNINDENT .UNINDENT .INDENT 7.0 .TP .B union(other: AbstractBoundingBox) Returns a new bounding box as union of this and \fIother\fP bounding box. .UNINDENT .INDENT 7.0 .TP .B intersection(other: AbstractBoundingBox) -> \fI\%BoundingBox\fP Returns the bounding box of the intersection cube of both 3D bounding boxes. Returns an empty bounding box if the intersection volume is 0. .UNINDENT .INDENT 7.0 .TP .B rect_vertices() -> Sequence[\fI\%Vec2\fP] Returns the corners of the bounding box in the xy\-plane as \fI\%Vec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B cube_vertices() -> Sequence[\fI\%Vec3\fP] Returns the 3D corners of the bounding box as \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B grow(value: float) -> None Grow or shrink the bounding box by an uniform value in x, y and z\-axis. A negative value shrinks the bounding box. Raises \fBValueError\fP for shrinking the size of the bounding box to zero or below in any dimension. .UNINDENT .UNINDENT .SS BoundingBox2d .INDENT 0.0 .TP .B class ezdxf.math.BoundingBox2d(vertices: Iterable[\fI\%UVec\fP] | None = None) 2D bounding box. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of \fB(x, y[, z])\fP tuples or \fI\%Vec3\fP objects .UNINDENT .INDENT 7.0 .TP .B extmin “lower left” corner of bounding box .UNINDENT .INDENT 7.0 .TP .B extmax “upper right” corner of bounding box .UNINDENT .INDENT 7.0 .TP .B property is_empty: bool Returns \fBTrue\fP if the bounding box is empty. The bounding box has a size of 0 in any or all dimensions or is undefined. .UNINDENT .INDENT 7.0 .TP .B property has_data: bool Returns \fBTrue\fP if the bonding box has known limits. .UNINDENT .INDENT 7.0 .TP .B property size Returns size of bounding box. .UNINDENT .INDENT 7.0 .TP .B property center Returns center of bounding box. .UNINDENT .INDENT 7.0 .TP .B inside(vertex: \fI\%UVec\fP) -> bool Returns \fBTrue\fP if \fIvertex\fP is inside this bounding box. .sp Vertices at the box border are inside! .UNINDENT .INDENT 7.0 .TP .B any_inside(vertices: Iterable[\fI\%UVec\fP]) -> bool Returns \fBTrue\fP if any vertex is inside this bounding box. .sp Vertices at the box border are inside! .UNINDENT .INDENT 7.0 .TP .B all_inside(vertices: Iterable[\fI\%UVec\fP]) -> bool Returns \fBTrue\fP if all vertices are inside this bounding box. .sp Vertices at the box border are inside! .UNINDENT .INDENT 7.0 .TP .B has_intersection(other: AbstractBoundingBox) -> bool Returns \fBTrue\fP if this bounding box intersects with \fIother\fP but does not include touching bounding boxes, see also \fI\%has_overlap()\fP: .INDENT 7.0 .INDENT 3.5 .sp .EX bbox1 = BoundingBox2d([(0, 0), (1, 1)]) bbox2 = BoundingBox2d([(1, 1), (2, 2)]) assert bbox1.has_intersection(bbox2) is False .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_overlap(other: AbstractBoundingBox) -> bool Returns \fBTrue\fP if this bounding box intersects with \fIother\fP but in contrast to \fI\%has_intersection()\fP includes touching bounding boxes too: .INDENT 7.0 .INDENT 3.5 .sp .EX bbox1 = BoundingBox2d([(0, 0), (1, 1)]) bbox2 = BoundingBox2d([(1, 1), (2, 2)]) assert bbox1.has_overlap(bbox2) is True .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B contains(other: AbstractBoundingBox) -> bool Returns \fBTrue\fP if the \fIother\fP bounding box is completely inside this bounding box. .UNINDENT .INDENT 7.0 .TP .B extend(vertices: Iterable[\fI\%UVec\fP]) -> None Extend bounds by \fIvertices\fP\&. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of vertices .UNINDENT .UNINDENT .INDENT 7.0 .TP .B union(other: AbstractBoundingBox) Returns a new bounding box as union of this and \fIother\fP bounding box. .UNINDENT .INDENT 7.0 .TP .B intersection(other: AbstractBoundingBox) -> \fI\%BoundingBox2d\fP Returns the bounding box of the intersection rectangle of both 2D bounding boxes. Returns an empty bounding box if the intersection area is 0. .UNINDENT .INDENT 7.0 .TP .B rect_vertices() -> Sequence[\fI\%Vec2\fP] Returns the corners of the bounding box in the xy\-plane as \fI\%Vec2\fP objects. .UNINDENT .UNINDENT .SS ConstructionRay .INDENT 0.0 .TP .B class ezdxf.math.ConstructionRay(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP | None = None, angle: float | None = None) Construction tool for infinite 2D rays. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – definition point 1 .IP \(bu 2 \fBp2\fP – ray direction as 2nd point or \fBNone\fP .IP \(bu 2 \fBangle\fP – ray direction as angle in radians or \fBNone\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B location Location vector as \fI\%Vec2\fP\&. .UNINDENT .INDENT 7.0 .TP .B direction Direction vector as \fI\%Vec2\fP\&. .UNINDENT .INDENT 7.0 .TP .B slope Slope of ray or \fBNone\fP if vertical. .UNINDENT .INDENT 7.0 .TP .B angle Angle between x\-axis and ray in radians. .UNINDENT .INDENT 7.0 .TP .B angle_deg Angle between x\-axis and ray in degrees. .UNINDENT .INDENT 7.0 .TP .B is_vertical \fBTrue\fP if ray is vertical (parallel to y\-axis). .UNINDENT .INDENT 7.0 .TP .B is_horizontal \fBTrue\fP if ray is horizontal (parallel to x\-axis). .UNINDENT .INDENT 7.0 .TP .B __str__() Return str(self). .UNINDENT .INDENT 7.0 .TP .B is_parallel(other: \fI\%ConstructionRay\fP) -> bool Returns \fBTrue\fP if rays are parallel. .UNINDENT .INDENT 7.0 .TP .B intersect(other: \fI\%ConstructionRay\fP) -> \fI\%Vec2\fP Returns the intersection point as \fB(x, y)\fP tuple of \fIself\fP and \fIother\fP\&. .INDENT 7.0 .TP .B Raises \fBParallelRaysError\fP – if rays are parallel .UNINDENT .UNINDENT .INDENT 7.0 .TP .B orthogonal(location: \fI\%UVec\fP) -> \fI\%ConstructionRay\fP Returns orthogonal ray at \fIlocation\fP\&. .UNINDENT .INDENT 7.0 .TP .B bisectrix(other: \fI\%ConstructionRay\fP) -> \fI\%ConstructionRay\fP Bisectrix between \fIself\fP and \fIother\fP\&. .UNINDENT .INDENT 7.0 .TP .B yof(x: float) -> float Returns y\-value of ray for \fIx\fP location. .INDENT 7.0 .TP .B Raises \fBArithmeticError\fP – for vertical rays .UNINDENT .UNINDENT .INDENT 7.0 .TP .B xof(y: float) -> float Returns x\-value of ray for \fIy\fP location. .INDENT 7.0 .TP .B Raises \fBArithmeticError\fP – for horizontal rays .UNINDENT .UNINDENT .UNINDENT .SS ConstructionLine .INDENT 0.0 .TP .B class ezdxf.math.ConstructionLine(start: \fI\%UVec\fP, end: \fI\%UVec\fP) Construction tool for 2D lines. .sp The \fI\%ConstructionLine\fP class is similar to \fI\%ConstructionRay\fP, but has a start\- and endpoint. The direction of line goes from start\- to endpoint, “left of line” is always in relation to this line direction. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart\fP – start point of line as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBend\fP – end point of line as \fI\%Vec2\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B start start point as \fI\%Vec2\fP .UNINDENT .INDENT 7.0 .TP .B end end point as \fI\%Vec2\fP .UNINDENT .INDENT 7.0 .TP .B bounding_box bounding box of line as \fI\%BoundingBox2d\fP object. .UNINDENT .INDENT 7.0 .TP .B ray collinear \fI\%ConstructionRay\fP\&. .UNINDENT .INDENT 7.0 .TP .B is_vertical \fBTrue\fP if line is vertical. .UNINDENT .INDENT 7.0 .TP .B is_horizontal \fBTrue\fP if line is horizontal. .UNINDENT .INDENT 7.0 .TP .B __str__() Return str(self). .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float) -> None Move line about \fIdx\fP in x\-axis and about \fIdy\fP in y\-axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP – translation in x\-axis .IP \(bu 2 \fBdy\fP – translation in y\-axis .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B length() -> float Returns length of line. .UNINDENT .INDENT 7.0 .TP .B midpoint() -> \fI\%Vec2\fP Returns mid point of line. .UNINDENT .INDENT 7.0 .TP .B inside_bounding_box(point: \fI\%UVec\fP) -> bool Returns \fBTrue\fP if \fIpoint\fP is inside of line bounding box. .UNINDENT .INDENT 7.0 .TP .B intersect(other: \fI\%ConstructionLine\fP, abs_tol: float = TOLERANCE) -> \fI\%Vec2\fP | None Returns the intersection point of to lines or \fBNone\fP if they have no intersection point. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBother\fP – other \fI\%ConstructionLine\fP .IP \(bu 2 \fBabs_tol\fP – tolerance for distance check .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_intersection(other: \fI\%ConstructionLine\fP, abs_tol: float = TOLERANCE) -> bool Returns \fBTrue\fP if has intersection with \fIother\fP line. .UNINDENT .INDENT 7.0 .TP .B is_point_left_of_line(point: \fI\%UVec\fP, colinear=False) -> bool Returns \fBTrue\fP if \fIpoint\fP is left of construction line in relation to the line direction from start to end. .sp If \fIcolinear\fP is \fBTrue\fP, a colinear point is also left of the line. .UNINDENT .UNINDENT .SS ConstructionCircle .INDENT 0.0 .TP .B class ezdxf.math.ConstructionCircle(center: \fI\%UVec\fP, radius: float = 1.0) Construction tool for 2D circles. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBradius\fP – circle radius > \fI0\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B center center point as \fI\%Vec2\fP .UNINDENT .INDENT 7.0 .TP .B radius radius as float .UNINDENT .INDENT 7.0 .TP .B bounding_box 2D bounding box of circle as \fI\%BoundingBox2d\fP object. .UNINDENT .INDENT 7.0 .TP .B static from_3p(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, p3: \fI\%UVec\fP) -> \fI\%ConstructionCircle\fP Creates a circle from three points, all points have to be compatible to \fI\%Vec2\fP class. .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Returns string representation of circle “ConstructionCircle(center, radius)”. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float) -> None Move circle about \fIdx\fP in x\-axis and about \fIdy\fP in y\-axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP – translation in x\-axis .IP \(bu 2 \fBdy\fP – translation in y\-axis .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B point_at(angle: float) -> \fI\%Vec2\fP Returns point on circle at \fIangle\fP as \fI\%Vec2\fP object. .INDENT 7.0 .TP .B Parameters \fBangle\fP – angle in radians, angle goes counter clockwise around the z\-axis, x\-axis = 0 deg. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B vertices(angles: Iterable[float]) -> Iterable[\fI\%Vec2\fP] Yields vertices of the circle for iterable \fIangles\fP\&. .INDENT 7.0 .TP .B Parameters \fBangles\fP – iterable of angles as radians, angle goes counter\-clockwise around the z\-axis, x\-axis = 0 deg. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flattening(sagitta: float) -> Iterator[\fI\%Vec2\fP] Approximate the circle by vertices, argument \fIsagitta\fP is the max. distance from the center of an arc segment to the center of its chord. Returns a closed polygon where the start vertex is coincident with the end vertex! .UNINDENT .INDENT 7.0 .TP .B inside(point: \fI\%UVec\fP) -> bool Returns \fBTrue\fP if \fIpoint\fP is inside circle. .UNINDENT .INDENT 7.0 .TP .B tangent(angle: float) -> \fI\%ConstructionRay\fP Returns tangent to circle at \fIangle\fP as \fI\%ConstructionRay\fP object. .INDENT 7.0 .TP .B Parameters \fBangle\fP – angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_ray(ray: \fI\%ConstructionRay\fP, abs_tol: float = 1e\-10) -> Sequence[\fI\%Vec2\fP] Returns intersection points of circle and \fIray\fP as sequence of \fI\%Vec2\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBray\fP – intersection ray .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for tests (e.g. test for tangents) .UNINDENT .TP .B Returns tuple of \fI\%Vec2\fP objects .TS center; |l|l|. _ T{ tuple size T} T{ Description T} _ T{ 0 T} T{ no intersection T} _ T{ 1 T} T{ ray is a tangent to circle T} _ T{ 2 T} T{ ray intersects with the circle T} _ .TE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_line(line: \fI\%ConstructionLine\fP, abs_tol: float = 1e\-10) -> Sequence[\fI\%Vec2\fP] Returns intersection points of circle and \fIline\fP as sequence of \fI\%Vec2\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBline\fP – intersection line .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for tests (e.g. test for tangents) .UNINDENT .TP .B Returns tuple of \fI\%Vec2\fP objects .TS center; |l|l|. _ T{ tuple size T} T{ Description T} _ T{ 0 T} T{ no intersection T} _ T{ 1 T} T{ line intersects or touches the circle at one point T} _ T{ 2 T} T{ line intersects the circle at two points T} _ .TE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_circle(other: \fI\%ConstructionCircle\fP, abs_tol: float = 1e\-10) -> Sequence[\fI\%Vec2\fP] Returns intersection points of two circles as sequence of \fI\%Vec2\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBother\fP – intersection circle .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for tests .UNINDENT .TP .B Returns tuple of \fI\%Vec2\fP objects .TS center; |l|l|. _ T{ tuple size T} T{ Description T} _ T{ 0 T} T{ no intersection T} _ T{ 1 T} T{ circle touches the \fIother\fP circle at one point T} _ T{ 2 T} T{ circle intersects with the \fIother\fP circle T} _ .TE .UNINDENT .UNINDENT .UNINDENT .SS ConstructionArc .INDENT 0.0 .TP .B class ezdxf.math.ConstructionArc(center: \fI\%UVec\fP = (0, 0), radius: float = 1.0, start_angle: float = 0.0, end_angle: float = 360.0, is_counter_clockwise: bool | None = True) Construction tool for 2D arcs. .sp \fI\%ConstructionArc\fP represents a 2D arc in the xy\-plane, use an \fI\%UCS\fP to place a DXF \fI\%Arc\fP entity in 3D space, see method \fI\%add_to_layout()\fP\&. .sp Implements the 2D transformation tools: \fI\%translate()\fP, \fI\%scale_uniform()\fP and \fI\%rotate_z()\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBradius\fP – radius .IP \(bu 2 \fBstart_angle\fP – start angle in degrees .IP \(bu 2 \fBend_angle\fP – end angle in degrees .IP \(bu 2 \fBis_counter_clockwise\fP – swaps start\- and end angle if \fBFalse\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B center center point as \fI\%Vec2\fP .UNINDENT .INDENT 7.0 .TP .B radius radius as float .UNINDENT .INDENT 7.0 .TP .B start_angle start angle in degrees .UNINDENT .INDENT 7.0 .TP .B end_angle end angle in degrees .UNINDENT .INDENT 7.0 .TP .B angle_span Returns angle span of arc from start\- to end param. .UNINDENT .INDENT 7.0 .TP .B start_angle_rad Returns the start angle in radians. .UNINDENT .INDENT 7.0 .TP .B end_angle_rad Returns the end angle in radians. .UNINDENT .INDENT 7.0 .TP .B start_point start point of arc as \fI\%Vec2\fP\&. .UNINDENT .INDENT 7.0 .TP .B end_point end point of arc as \fI\%Vec2\fP\&. .UNINDENT .INDENT 7.0 .TP .B bounding_box bounding box of arc as \fI\%BoundingBox2d\fP\&. .UNINDENT .INDENT 7.0 .TP .B angles(num: int) -> Iterable[float] Returns \fInum\fP angles from start\- to end angle in degrees in counter\-clockwise order. .sp All angles are normalized in the range from [0, 360). .UNINDENT .INDENT 7.0 .TP .B vertices(a: Iterable[float]) -> Iterable[\fI\%Vec2\fP] Yields vertices on arc for angles in iterable \fIa\fP in WCS as location vectors. .INDENT 7.0 .TP .B Parameters \fBa\fP – angles in the range from 0 to 360 in degrees, arc goes counter clockwise around the z\-axis, WCS x\-axis = 0 deg. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B tangents(a: Iterable[float]) -> Iterable[\fI\%Vec2\fP] Yields tangents on arc for angles in iterable \fIa\fP in WCS as direction vectors. .INDENT 7.0 .TP .B Parameters \fBa\fP – angles in the range from 0 to 360 in degrees, arc goes counter\-clockwise around the z\-axis, WCS x\-axis = 0 deg. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float) -> \fI\%ConstructionArc\fP Move arc about \fIdx\fP in x\-axis and about \fIdy\fP in y\-axis, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP – translation in x\-axis .IP \(bu 2 \fBdy\fP – translation in y\-axis .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale_uniform(s: float) -> \fI\%ConstructionArc\fP Scale arc inplace uniform about \fIs\fP in x\- and y\-axis, returns \fIself\fP (floating interface). .UNINDENT .INDENT 7.0 .TP .B rotate_z(angle: float) -> \fI\%ConstructionArc\fP Rotate arc inplace about z\-axis, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in degrees .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_2p_angle(start_point: \fI\%UVec\fP, end_point: \fI\%UVec\fP, angle: float, ccw: bool = True) -> \fI\%ConstructionArc\fP Create arc from two points and enclosing angle. Additional precondition: arc goes by default in counter\-clockwise orientation from \fIstart_point\fP to \fIend_point\fP, can be changed by \fIccw\fP = \fBFalse\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_point\fP – start point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBend_point\fP – end point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBangle\fP – enclosing angle in degrees .IP \(bu 2 \fBccw\fP – counter\-clockwise direction if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_2p_radius(start_point: \fI\%UVec\fP, end_point: \fI\%UVec\fP, radius: float, ccw: bool = True, center_is_left: bool = True) -> \fI\%ConstructionArc\fP Create arc from two points and arc radius. Additional precondition: arc goes by default in counter\-clockwise orientation from \fIstart_point\fP to \fIend_point\fP can be changed by \fIccw\fP = \fBFalse\fP\&. .sp The parameter \fIcenter_is_left\fP defines if the center of the arc is left or right of the line from \fIstart_point\fP to \fIend_point\fP\&. Parameter \fIccw\fP = \fBFalse\fP swaps start\- and end point, which also inverts the meaning of \fBcenter_is_left\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_point\fP – start point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBend_point\fP – end point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBradius\fP – arc radius .IP \(bu 2 \fBccw\fP – counter\-clockwise direction if \fBTrue\fP .IP \(bu 2 \fBcenter_is_left\fP – center point of arc is left of line from start\- to end point if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_3p(start_point: \fI\%UVec\fP, end_point: \fI\%UVec\fP, def_point: \fI\%UVec\fP, ccw: bool = True) -> \fI\%ConstructionArc\fP Create arc from three points. Additional precondition: arc goes in counter\-clockwise orientation from \fIstart_point\fP to \fIend_point\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_point\fP – start point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBend_point\fP – end point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBdef_point\fP – additional definition point as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBccw\fP – counter\-clockwise direction if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_to_layout(layout: \fI\%BaseLayout\fP, ucs: \fI\%UCS\fP | None = None, dxfattribs=None) -> \fI\%Arc\fP Add arc as DXF \fI\%Arc\fP entity to a layout. .sp Supports 3D arcs by using an \fI\%UCS\fP\&. An \fI\%ConstructionArc\fP is always defined in the xy\-plane, but by using an arbitrary UCS, the arc can be placed in 3D space, automatically OCS transformation included. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – destination layout as \fI\%BaseLayout\fP object .IP \(bu 2 \fBucs\fP – place arc in 3D space by \fI\%UCS\fP object .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the ARC entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_ray(ray: \fI\%ConstructionRay\fP, abs_tol: float = 1e\-10) -> Sequence[\fI\%Vec2\fP] Returns intersection points of arc and \fIray\fP as sequence of \fI\%Vec2\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBray\fP – intersection ray .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for tests (e.g. test for tangents) .UNINDENT .TP .B Returns tuple of \fI\%Vec2\fP objects .TS center; |l|l|. _ T{ tuple size T} T{ Description T} _ T{ 0 T} T{ no intersection T} _ T{ 1 T} T{ line intersects or touches the arc at one point T} _ T{ 2 T} T{ line intersects the arc at two points T} _ .TE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_line(line: \fI\%ConstructionLine\fP, abs_tol: float = 1e\-10) -> Sequence[\fI\%Vec2\fP] Returns intersection points of arc and \fIline\fP as sequence of \fI\%Vec2\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBline\fP – intersection line .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for tests (e.g. test for tangents) .UNINDENT .TP .B Returns tuple of \fI\%Vec2\fP objects .TS center; |l|l|. _ T{ tuple size T} T{ Description T} _ T{ 0 T} T{ no intersection T} _ T{ 1 T} T{ line intersects or touches the arc at one point T} _ T{ 2 T} T{ line intersects the arc at two points T} _ .TE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_circle(circle: \fI\%ConstructionCircle\fP, abs_tol: float = 1e\-10) -> Sequence[\fI\%Vec2\fP] Returns intersection points of arc and \fIcircle\fP as sequence of \fI\%Vec2\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcircle\fP – intersection circle .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for tests .UNINDENT .TP .B Returns tuple of \fI\%Vec2\fP objects .TS center; |l|l|. _ T{ tuple size T} T{ Description T} _ T{ 0 T} T{ no intersection T} _ T{ 1 T} T{ circle intersects or touches the arc at one point T} _ T{ 2 T} T{ circle intersects the arc at two points T} _ .TE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_arc(other: \fI\%ConstructionArc\fP, abs_tol: float = 1e\-10) -> Sequence[\fI\%Vec2\fP] Returns intersection points of two arcs as sequence of \fI\%Vec2\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBother\fP – other intersection arc .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for tests .UNINDENT .TP .B Returns tuple of \fI\%Vec2\fP objects .TS center; |l|l|. _ T{ tuple size T} T{ Description T} _ T{ 0 T} T{ no intersection T} _ T{ 1 T} T{ other arc intersects or touches the arc at one point T} _ T{ 2 T} T{ other arc intersects the arc at two points T} _ .TE .UNINDENT .UNINDENT .UNINDENT .SS ConstructionEllipse .INDENT 0.0 .TP .B class ezdxf.math.ConstructionEllipse(center: \fI\%UVec\fP = NULLVEC, major_axis: \fI\%UVec\fP = X_AXIS, extrusion: \fI\%UVec\fP = Z_AXIS, ratio: float = 1, start_param: float = 0, end_param: float = math.tau, ccw: bool = True) Construction tool for 3D ellipsis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – 3D center point .IP \(bu 2 \fBmajor_axis\fP – major axis as 3D vector .IP \(bu 2 \fBextrusion\fP – normal vector of ellipse plane .IP \(bu 2 \fBratio\fP – ratio of minor axis to major axis .IP \(bu 2 \fBstart_param\fP – start param in radians .IP \(bu 2 \fBend_param\fP – end param in radians .IP \(bu 2 \fBccw\fP – is counter\-clockwise flag \- swaps start\- and end param if \fBFalse\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B center center point as \fI\%Vec3\fP .UNINDENT .INDENT 7.0 .TP .B major_axis major axis as \fI\%Vec3\fP .UNINDENT .INDENT 7.0 .TP .B minor_axis minor axis as \fI\%Vec3\fP, automatically calculated from \fI\%major_axis\fP and \fI\%extrusion\fP\&. .UNINDENT .INDENT 7.0 .TP .B extrusion extrusion vector (normal of ellipse plane) as \fI\%Vec3\fP .UNINDENT .INDENT 7.0 .TP .B ratio ratio of minor axis to major axis (float) .UNINDENT .INDENT 7.0 .TP .B start start param in radians (float) .UNINDENT .INDENT 7.0 .TP .B end end param in radians (float) .UNINDENT .INDENT 7.0 .TP .B start_point Returns start point of ellipse as Vec3. .UNINDENT .INDENT 7.0 .TP .B end_point Returns end point of ellipse as Vec3. .UNINDENT .INDENT 7.0 .TP .B property param_span: float Returns the counter\-clockwise params span from start\- to end param, see also \fI\%ezdxf.math.ellipse_param_span()\fP for more information. .UNINDENT .INDENT 7.0 .TP .B to_ocs() -> \fI\%ConstructionEllipse\fP Returns ellipse parameters as OCS representation. .sp OCS elevation is stored in \fBcenter.z\fP\&. .UNINDENT .INDENT 7.0 .TP .B params(num: int) -> Iterable[float] Returns \fInum\fP params from start\- to end param in counter\-clockwise order. .sp All params are normalized in the range from [0, 2π). .UNINDENT .INDENT 7.0 .TP .B vertices(params: Iterable[float]) -> Iterable[\fI\%Vec3\fP] Yields vertices on ellipse for iterable \fIparams\fP in WCS. .INDENT 7.0 .TP .B Parameters \fBparams\fP – param values in the range from [0, 2π) in radians, param goes counter\-clockwise around the extrusion vector, major_axis = local x\-axis = 0 rad. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flattening(distance: float, segments: int = 4) -> Iterable[\fI\%Vec3\fP] Adaptive recursive flattening. The argument \fIsegments\fP is the minimum count of approximation segments, if the distance from the center of the approximation segment to the curve is bigger than \fIdistance\fP the segment will be subdivided. Returns a closed polygon for a full ellipse: start vertex == end vertex. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the projected curve point onto the segment chord. .IP \(bu 2 \fBsegments\fP – minimum segment count .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B params_from_vertices(vertices: Iterable[\fI\%UVec\fP]) -> Iterable[float] Yields ellipse params for all given \fIvertices\fP\&. .sp The vertex don’t have to be exact on the ellipse curve or in the range from start\- to end param or even in the ellipse plane. Param is calculated from the intersection point of the ray projected on the ellipse plane from the center of the ellipse through the vertex. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 An input for start\- and end vertex at param 0 and 2π return unpredictable results because of floating point inaccuracy, sometimes 0 and sometimes 2π. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxfattribs() -> dict[str, Any] Returns required DXF attributes to build an ELLIPSE entity. .sp Entity ELLIPSE has always a ratio in range from 1e\-6 to 1. .UNINDENT .INDENT 7.0 .TP .B main_axis_points() -> Iterable[\fI\%Vec3\fP] Yields main axis points of ellipse in the range from start\- to end param. .UNINDENT .INDENT 7.0 .TP .B classmethod from_arc(center: \fI\%UVec\fP = NULLVEC, radius: float = 1, extrusion: \fI\%UVec\fP = Z_AXIS, start_angle: float = 0, end_angle: float = 360, ccw: bool = True) -> \fI\%ConstructionEllipse\fP Returns \fI\%ConstructionEllipse\fP from arc or circle. .sp Arc and Circle parameters defined in OCS. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center in OCS .IP \(bu 2 \fBradius\fP – arc or circle radius .IP \(bu 2 \fBextrusion\fP – OCS extrusion vector .IP \(bu 2 \fBstart_angle\fP – start angle in degrees .IP \(bu 2 \fBend_angle\fP – end angle in degrees .IP \(bu 2 \fBccw\fP – arc curve goes counter clockwise from start to end if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> None Transform ellipse in place by transformation matrix \fIm\fP\&. .UNINDENT .INDENT 7.0 .TP .B swap_axis() -> None Swap axis and adjust start\- and end parameter. .UNINDENT .INDENT 7.0 .TP .B add_to_layout(layout: \fI\%BaseLayout\fP, dxfattribs=None) -> \fI\%Ellipse\fP Add ellipse as DXF \fI\%Ellipse\fP entity to a layout. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – destination layout as \fI\%BaseLayout\fP object .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the ELLIPSE entity .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS ConstructionBox .INDENT 0.0 .TP .B class ezdxf.math.ConstructionBox(center: \fI\%UVec\fP = (0, 0), width: float = 1, height: float = 1, angle: float = 0) Construction tool for 2D rectangles. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center of rectangle .IP \(bu 2 \fBwidth\fP – width of rectangle .IP \(bu 2 \fBheight\fP – height of rectangle .IP \(bu 2 \fBangle\fP – angle of rectangle in degrees .UNINDENT .UNINDENT .INDENT 7.0 .TP .B center box center .UNINDENT .INDENT 7.0 .TP .B width box width .UNINDENT .INDENT 7.0 .TP .B height box height .UNINDENT .INDENT 7.0 .TP .B angle rotation angle in degrees .UNINDENT .INDENT 7.0 .TP .B corners box corners as sequence of \fI\%Vec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B bounding_box \fI\%BoundingBox2d\fP .UNINDENT .INDENT 7.0 .TP .B incircle_radius incircle radius .UNINDENT .INDENT 7.0 .TP .B circumcircle_radius circum circle radius .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[\fI\%Vec2\fP] Iterable of box corners as \fI\%Vec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B __getitem__(corner) -> \fI\%Vec2\fP Get corner by index \fIcorner\fP, \fBlist\fP like slicing is supported. .UNINDENT .INDENT 7.0 .TP .B __repr__() -> str Returns string representation of box as \fBConstructionBox(center, width, height, angle)\fP .UNINDENT .INDENT 7.0 .TP .B classmethod from_points(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP) -> \fI\%ConstructionBox\fP Creates a box from two opposite corners, box sides are parallel to x\- and y\-axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – first corner as \fI\%Vec2\fP compatible object .IP \(bu 2 \fBp2\fP – second corner as \fI\%Vec2\fP compatible object .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float) -> None Move box about \fIdx\fP in x\-axis and about \fIdy\fP in y\-axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP – translation in x\-axis .IP \(bu 2 \fBdy\fP – translation in y\-axis .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B expand(dw: float, dh: float) -> None Expand box: \fIdw\fP expand width, \fIdh\fP expand height. .UNINDENT .INDENT 7.0 .TP .B scale(sw: float, sh: float) -> None Scale box: \fIsw\fP scales width, \fIsh\fP scales height. .UNINDENT .INDENT 7.0 .TP .B rotate(angle: float) -> None Rotate box by \fIangle\fP in degrees. .UNINDENT .INDENT 7.0 .TP .B is_inside(point: \fI\%UVec\fP) -> bool Returns \fBTrue\fP if \fIpoint\fP is inside of box. .UNINDENT .INDENT 7.0 .TP .B is_any_corner_inside(other: \fI\%ConstructionBox\fP) -> bool Returns \fBTrue\fP if any corner of \fIother\fP box is inside this box. .UNINDENT .INDENT 7.0 .TP .B is_overlapping(other: \fI\%ConstructionBox\fP) -> bool Returns \fBTrue\fP if this box and \fIother\fP box do overlap. .UNINDENT .INDENT 7.0 .TP .B border_lines() -> Sequence[\fI\%ConstructionLine\fP] Returns borderlines of box as sequence of \fI\%ConstructionLine\fP\&. .UNINDENT .INDENT 7.0 .TP .B intersect(line: \fI\%ConstructionLine\fP) -> list[\fI\%Vec2\fP] Returns 0, 1 or 2 intersection points between \fIline\fP and box borderlines. .INDENT 7.0 .TP .B Parameters \fBline\fP – line to intersect with borderlines .TP .B Returns list of intersection points .TS center; |l|l|. _ T{ list size T} T{ Description T} _ T{ 0 T} T{ no intersection T} _ T{ 1 T} T{ line touches box at one corner T} _ T{ 2 T} T{ line intersects with box T} _ .TE .UNINDENT .UNINDENT .UNINDENT .SS ConstructionPolyline .INDENT 0.0 .TP .B class ezdxf.math.ConstructionPolyline(vertices: Iterable[\fI\%UVec\fP], close: bool = False, rel_tol: float = REL_TOL) Construction tool for 3D polylines. .sp A polyline construction tool to measure, interpolate and divide anything that can be approximated or flattened into vertices. This is an immutable data structure which supports the \fBSequence\fP interface. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – iterable of polyline vertices .IP \(bu 2 \fBclose\fP – \fBTrue\fP to close the polyline (first vertex == last vertex) .IP \(bu 2 \fBrel_tol\fP – relative tolerance for floating point comparisons .UNINDENT .UNINDENT .sp Example to measure or divide a SPLINE entity: .INDENT 7.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.math import ConstructionPolyline doc = ezdxf.readfile(\(dqyour.dxf\(dq) msp = doc.modelspace() spline = msp.query(\(dqSPLINE\(dq).first if spline is not None: polyline = ConstructionPolyline(spline.flattening(0.01)) print(f\(dqEntity {spline} has an approximated length of {polyline.length}\(dq) # get dividing points with a distance of 1.0 drawing unit to each other points = list(polyline.divide_by_length(1.0)) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property length: float Returns the overall length of the polyline. .UNINDENT .INDENT 7.0 .TP .B property is_closed: bool Returns \fBTrue\fP if the polyline is closed (first vertex == last vertex). .UNINDENT .INDENT 7.0 .TP .B data(index: int) -> tuple[float, float, \fI\%Vec3\fP] Returns the tuple (distance from start, distance from previous vertex, vertex). All distances measured along the polyline. .UNINDENT .INDENT 7.0 .TP .B index_at(distance: float) -> int Returns the data index of the exact or next data entry for the given \fIdistance\fP\&. Returns the index of last entry if \fIdistance\fP > \fI\%length\fP\&. .UNINDENT .INDENT 7.0 .TP .B vertex_at(distance: float) -> \fI\%Vec3\fP Returns the interpolated vertex at the given \fIdistance\fP from the start of the polyline. .UNINDENT .INDENT 7.0 .TP .B divide(count: int) -> Iterator[\fI\%Vec3\fP] Returns \fIcount\fP interpolated vertices along the polyline. Argument \fIcount\fP has to be greater than 2 and the start\- and end vertices are always included. .UNINDENT .INDENT 7.0 .TP .B divide_by_length(length: float, force_last: bool = False) -> Iterator[\fI\%Vec3\fP] Returns interpolated vertices along the polyline. Each vertex has a fix distance \fIlength\fP from its predecessor. Yields the last vertex if argument \fIforce_last\fP is \fBTrue\fP even if the last distance is not equal to \fIlength\fP\&. .UNINDENT .UNINDENT .SS Shape2d .INDENT 0.0 .TP .B class ezdxf.math.Shape2d(vertices: Iterable[\fI\%UVec\fP] | None = None) Construction tools for 2D shapes. .sp A 2D geometry object as list of \fI\%Vec2\fP objects, vertices can be moved, rotated and scaled. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of \fI\%Vec2\fP compatible objects. .UNINDENT .INDENT 7.0 .TP .B vertices List of \fI\%Vec2\fP objects .UNINDENT .INDENT 7.0 .TP .B bounding_box \fI\%BoundingBox2d\fP .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns \fIcount\fP of vertices. .UNINDENT .INDENT 7.0 .TP .B __getitem__(item: int | slice) -> \fI\%Vec2\fP Get vertex by index \fIitem\fP, supports \fBlist\fP like slicing. .UNINDENT .INDENT 7.0 .TP .B append(vertex: \fI\%UVec\fP) -> None Append single \fIvertex\fP\&. .INDENT 7.0 .TP .B Parameters \fBvertex\fP – vertex as \fI\%Vec2\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B extend(vertices: Iterable) -> None Append multiple \fIvertices\fP\&. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of vertices as \fI\%Vec2\fP compatible objects .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(vector: \fI\%UVec\fP) -> None Translate shape about \fIvector\fP\&. .UNINDENT .INDENT 7.0 .TP .B scale(sx: float = 1.0, sy: float = 1.0) -> None Scale shape about \fIsx\fP in x\-axis and \fIsy\fP in y\-axis. .UNINDENT .INDENT 7.0 .TP .B scale_uniform(scale: float) -> None Scale shape uniform about \fIscale\fP in x\- and y\-axis. .UNINDENT .INDENT 7.0 .TP .B rotate(angle: float, center: \fI\%UVec\fP | None = None) -> None Rotate shape around rotation \fIcenter\fP about \fIangle\fP in degrees. .UNINDENT .INDENT 7.0 .TP .B rotate_rad(angle: float, center: \fI\%UVec\fP | None = None) -> None Rotate shape around rotation \fIcenter\fP about \fIangle\fP in radians. .UNINDENT .INDENT 7.0 .TP .B offset(offset: float, closed: bool = False) -> \fI\%Shape2d\fP Returns a new offset shape, for more information see also \fI\%ezdxf.math.offset_vertices_2d()\fP function. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBoffset\fP – line offset perpendicular to direction of shape segments defined by vertices order, offset > \fB0\fP is ‘left’ of line segment, offset < \fB0\fP is ‘right’ of line segment .IP \(bu 2 \fBclosed\fP – \fBTrue\fP to handle as closed shape .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B convex_hull() -> \fI\%Shape2d\fP Returns convex hull as new shape. .UNINDENT .UNINDENT .SS Curves .TS center; |l|l|. _ T{ \fI\%ApproxParamT\fP T} T{ Approximation tool for parametrized curves. T} _ T{ \fI\%BSpline\fP T} T{ B\-spline construction tool. T} _ T{ \fI\%Bezier\fP T} T{ Generic \fI\%Bézier curve\fP of any degree. T} _ T{ \fI\%Bezier3P\fP T} T{ Implements an optimized quadratic \fI\%Bézier curve\fP for exact 3 control points. T} _ T{ \fI\%Bezier4P\fP T} T{ Implements an optimized cubic \fI\%Bézier curve\fP for exact 4 control points. T} _ T{ \fI\%BezierSurface\fP T} T{ \fI\%BezierSurface\fP defines a mesh of \fIm\fP x \fIn\fP control points. T} _ T{ \fI\%EulerSpiral\fP T} T{ This class represents an euler spiral (clothoid) for \fIcurvature\fP (Radius of curvature). T} _ .TE .SS BSpline .INDENT 0.0 .TP .B class ezdxf.math.BSpline(control_points: Iterable[\fI\%UVec\fP], order: int = 4, knots: Iterable[float] | None = None, weights: Iterable[float] | None = None) B\-spline construction tool. .sp Internal representation of a \fI\%B\-spline\fP curve. The default configuration of the knot vector is a uniform open \fI\%knot\fP vector (“clamped”). .sp Factory functions: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%fit_points_to_cad_cv()\fP .IP \(bu 2 \fI\%fit_points_to_cubic_bezier()\fP .IP \(bu 2 \fI\%open_uniform_bspline()\fP .IP \(bu 2 \fI\%closed_uniform_bspline()\fP .IP \(bu 2 \fI\%rational_bspline_from_arc()\fP .IP \(bu 2 \fI\%rational_bspline_from_ellipse()\fP .IP \(bu 2 \fI\%global_bspline_interpolation()\fP .IP \(bu 2 \fI\%local_cubic_bspline_interpolation()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – iterable of control points as \fI\%Vec3\fP compatible objects .IP \(bu 2 \fBorder\fP – spline order (degree + 1) .IP \(bu 2 \fBknots\fP – iterable of knot values .IP \(bu 2 \fBweights\fP – iterable of weight values .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property control_points: Sequence[\fI\%Vec3\fP] Control points as tuple of \fI\%Vec3\fP .UNINDENT .INDENT 7.0 .TP .B property count: int Count of control points, (n + 1 in text book notation). .UNINDENT .INDENT 7.0 .TP .B property order: int Order (k) of B\-spline = p + 1 .UNINDENT .INDENT 7.0 .TP .B property degree: int Degree (p) of B\-spline = order \- 1 .UNINDENT .INDENT 7.0 .TP .B property max_t: float Biggest \fI\%knot\fP value. .UNINDENT .INDENT 7.0 .TP .B property is_rational Returns \fBTrue\fP if curve is a rational B\-spline. (has weights) .UNINDENT .INDENT 7.0 .TP .B property is_clamped Returns \fBTrue\fP if curve is a clamped (open) B\-spline. .UNINDENT .INDENT 7.0 .TP .B knots() -> Sequence[float] Returns a tuple of \fI\%knot\fP values as floats, the knot vector \fBalways\fP has order + count values (n + p + 2 in text book notation). .UNINDENT .INDENT 7.0 .TP .B weights() -> Sequence[float] Returns a tuple of weights values as floats, one for each control point or an empty tuple. .UNINDENT .INDENT 7.0 .TP .B params(segments: int) -> Iterable[float] Yield evenly spaced parameters for given segment count. .UNINDENT .INDENT 7.0 .TP .B reverse() -> \fI\%BSpline\fP Returns a new \fI\%BSpline\fP object with reversed control point order. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%BSpline\fP Returns a new \fI\%BSpline\fP object transformed by a \fI\%Matrix44\fP transformation matrix. .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int = 20) -> Iterable[\fI\%Vec3\fP] Approximates curve by vertices as \fI\%Vec3\fP objects, vertices count = segments + 1. .UNINDENT .INDENT 7.0 .TP .B flattening(distance: float, segments: int = 4) -> Iterator[\fI\%Vec3\fP] Adaptive recursive flattening. The argument \fIsegments\fP is the minimum count of approximation segments between two knots, if the distance from the center of the approximation segment to the curve is bigger than \fIdistance\fP the segment will be subdivided. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the projected curve point onto the segment chord. .IP \(bu 2 \fBsegments\fP – minimum segment count between two knots .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B point(t: float) -> \fI\%Vec3\fP Returns point for parameter \fIt\fP\&. .INDENT 7.0 .TP .B Parameters \fBt\fP – parameter in range [0, max_t] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B points(t: Iterable[float]) -> Iterable[\fI\%Vec3\fP] Yields points for parameter vector \fIt\fP\&. .INDENT 7.0 .TP .B Parameters \fBt\fP – parameters in range [0, max_t] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B derivative(t: float, n: int = 2) -> list[\fI\%Vec3\fP] Return point and derivatives up to \fIn\fP <= degree for parameter \fIt\fP\&. .sp e.g. n=1 returns point and 1st derivative. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBt\fP – parameter in range [0, max_t] .IP \(bu 2 \fBn\fP – compute all derivatives up to n <= degree .UNINDENT .TP .B Returns n+1 values as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 7.0 .TP .B derivatives(t: Iterable[float], n: int = 2) -> Iterable[list[\fI\%Vec3\fP]] Yields points and derivatives up to \fIn\fP <= degree for parameter vector \fIt\fP\&. .sp e.g. n=1 returns point and 1st derivative. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBt\fP – parameters in range [0, max_t] .IP \(bu 2 \fBn\fP – compute all derivatives up to n <= degree .UNINDENT .TP .B Returns List of n+1 values as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 7.0 .TP .B insert_knot(t: float) -> \fI\%BSpline\fP Insert an additional knot, without altering the shape of the curve. Returns a new \fI\%BSpline\fP object. .INDENT 7.0 .TP .B Parameters \fBt\fP – position of new knot 0 < t < max_t .UNINDENT .UNINDENT .INDENT 7.0 .TP .B knot_refinement(u: Iterable[float]) -> \fI\%BSpline\fP Insert multiple knots, without altering the shape of the curve. Returns a new \fI\%BSpline\fP object. .INDENT 7.0 .TP .B Parameters \fBu\fP – vector of new knots t and for each t: 0 < t < max_t .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_ellipse(ellipse: \fI\%ConstructionEllipse\fP) -> \fI\%BSpline\fP Returns the ellipse as \fI\%BSpline\fP of 2nd degree with as few control points as possible. .UNINDENT .INDENT 7.0 .TP .B static from_arc(arc: \fI\%ConstructionArc\fP) -> \fI\%BSpline\fP Returns the arc as \fI\%BSpline\fP of 2nd degree with as few control points as possible. .UNINDENT .INDENT 7.0 .TP .B static from_fit_points(points: Iterable[\fI\%UVec\fP], degree=3, method=\(aqchord\(aq) -> \fI\%BSpline\fP Returns \fI\%BSpline\fP defined by fit points. .UNINDENT .INDENT 7.0 .TP .B static arc_approximation(arc: \fI\%ConstructionArc\fP, num: int = 16) -> \fI\%BSpline\fP Returns an arc approximation as \fI\%BSpline\fP with \fInum\fP control points. .UNINDENT .INDENT 7.0 .TP .B static ellipse_approximation(ellipse: \fI\%ConstructionEllipse\fP, num: int = 16) -> \fI\%BSpline\fP Returns an ellipse approximation as \fI\%BSpline\fP with \fInum\fP control points. .UNINDENT .INDENT 7.0 .TP .B bezier_decomposition() -> Iterable[list[\fI\%Vec3\fP]] Decompose a non\-rational B\-spline into multiple Bézier curves. .sp This is the preferred method to represent the most common non\-rational B\-splines of 3rd degree by cubic Bézier curves, which are often supported by render backends. .INDENT 7.0 .TP .B Returns Yields control points of Bézier curves, each Bézier segment has degree+1 control points e.g. B\-spline of 3rd degree yields cubic Bézier curves of 4 control points. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B cubic_bezier_approximation(level: int = 3, segments: int | None = None) -> Iterable[\fI\%Bezier4P\fP] Approximate arbitrary B\-splines (degree != 3 and/or rational) by multiple segments of cubic Bézier curves. The choice of cubic Bézier curves is based on the widely support of this curves by many render backends. For cubic non\-rational B\-splines, which is maybe the most common used B\-spline, is \fI\%bezier_decomposition()\fP the better choice. .INDENT 7.0 .IP 1. 3 approximation by \fIlevel\fP: an educated guess, the first level of approximation segments is based on the count of control points and their distribution along the B\-spline, every additional level is a subdivision of the previous level. .UNINDENT .sp E.g. a B\-Spline of 8 control points has 7 segments at the first level, 14 at the 2nd level and 28 at the 3rd level, a level >= 3 is recommended. .INDENT 7.0 .IP 2. 3 approximation by a given count of evenly distributed approximation segments. .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlevel\fP – subdivision level of approximation segments (ignored if argument \fIsegments\fP is not \fBNone\fP) .IP \(bu 2 \fBsegments\fP – absolute count of approximation segments .UNINDENT .TP .B Returns Yields control points of cubic Bézier curves as \fI\%Bezier4P\fP objects .UNINDENT .UNINDENT .UNINDENT .SS Bezier .INDENT 0.0 .TP .B class ezdxf.math.Bezier(defpoints: Iterable[\fI\%UVec\fP]) Generic \fI\%Bézier curve\fP of any degree. .sp A \fI\%Bézier curve\fP is a parametric curve used in computer graphics and related fields. Bézier curves are used to model smooth curves that can be scaled indefinitely. “Paths”, as they are commonly referred to in image manipulation programs, are combinations of linked Bézier curves. Paths are not bound by the limits of rasterized images and are intuitive to modify. (Source: Wikipedia) .sp This is a generic implementation which works with any count of definition points greater than 2, but it is a simple and slow implementation. For more performance look at the specialized \fI\%Bezier4P\fP and \fI\%Bezier3P\fP classes. .sp Objects are immutable. .INDENT 7.0 .TP .B Parameters \fBdefpoints\fP – iterable of definition points as \fI\%Vec3\fP compatible objects. .UNINDENT .INDENT 7.0 .TP .B control_points Control points as tuple of \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B params(segments: int) -> Iterable[float] Yield evenly spaced parameters from 0 to 1 for given segment count. .UNINDENT .INDENT 7.0 .TP .B reverse() -> \fI\%Bezier\fP Returns a new Bèzier\-curve with reversed control point order. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%Bezier\fP General transformation interface, returns a new \fI\%Bezier\fP curve. .INDENT 7.0 .TP .B Parameters \fBm\fP – 4x4 transformation matrix (\fI\%ezdxf.math.Matrix44\fP) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int = 20) -> Iterable[\fI\%Vec3\fP] Approximates curve by vertices as \fI\%Vec3\fP objects, vertices count = segments + 1. .UNINDENT .INDENT 7.0 .TP .B flattening(distance: float, segments: int = 4) -> Iterable[\fI\%Vec3\fP] Adaptive recursive flattening. The argument \fIsegments\fP is the minimum count of approximation segments, if the distance from the center of the approximation segment to the curve is bigger than \fIdistance\fP the segment will be subdivided. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the center of the curve (Cn) to the center of the linear (C1) curve between two approximation points to determine if a segment should be subdivided. .IP \(bu 2 \fBsegments\fP – minimum segment count .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B point(t: float) -> \fI\%Vec3\fP Returns a point for parameter \fIt\fP in range [0, 1] as \fI\%Vec3\fP object. .UNINDENT .INDENT 7.0 .TP .B points(t: Iterable[float]) -> Iterable[\fI\%Vec3\fP] Yields multiple points for parameters in vector \fIt\fP as \fI\%Vec3\fP objects. Parameters have to be in range [0, 1]. .UNINDENT .INDENT 7.0 .TP .B derivative(t: float) -> tuple[\fI\%Vec3\fP, \fI\%Vec3\fP, \fI\%Vec3\fP] Returns (point, 1st derivative, 2nd derivative) tuple for parameter \fIt\fP in range [0, 1] as \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B derivatives(t: Iterable[float]) -> Iterable[tuple[\fI\%Vec3\fP, \fI\%Vec3\fP, \fI\%Vec3\fP]] Returns multiple (point, 1st derivative, 2nd derivative) tuples for parameter vector \fIt\fP as \fI\%Vec3\fP objects. Parameters in range [0, 1] .UNINDENT .UNINDENT .SS Bezier4P .INDENT 0.0 .TP .B class ezdxf.math.Bezier4P(defpoints: Sequence[\fI\%UVec\fP]) Implements an optimized cubic \fI\%Bézier curve\fP for exact 4 control points. .sp A \fI\%Bézier curve\fP is a parametric curve, parameter \fIt\fP goes from 0 to 1, where 0 is the first control point and 1 is the fourth control point. .sp Special behavior: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 2D control points in, returns 2D results as \fI\%Vec2\fP objects .IP \(bu 2 3D control points in, returns 3D results as \fI\%Vec3\fP objects .IP \(bu 2 Object is immutable. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters \fBdefpoints\fP – iterable of definition points as \fI\%Vec2\fP or \fI\%Vec3\fP compatible objects. .UNINDENT .INDENT 7.0 .TP .B control_points Control points as tuple of \fI\%Vec3\fP or \fI\%Vec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B reverse() -> \fI\%Bezier4P\fP Returns a new Bèzier\-curve with reversed control point order. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%Bezier4P\fP General transformation interface, returns a new \fBBezier4p\fP curve as a 3D curve. .INDENT 7.0 .TP .B Parameters \fBm\fP – 4x4 transformation matrix (\fI\%ezdxf.math.Matrix44\fP) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int) -> Iterator[AnyVec] Approximate \fI\%Bézier curve\fP by vertices, yields \fIsegments\fP + 1 vertices as \fB(x, y[, z])\fP tuples. .INDENT 7.0 .TP .B Parameters \fBsegments\fP – count of segments for approximation .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flattening(distance: float, segments: int = 4) -> Iterator[\fI\%Vec3\fP | \fI\%Vec2\fP] Adaptive recursive flattening. The argument \fIsegments\fP is the minimum count of approximation segments, if the distance from the center of the approximation segment to the curve is bigger than \fIdistance\fP the segment will be subdivided. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the center of the cubic (C3) curve to the center of the linear (C1) curve between two approximation points to determine if a segment should be subdivided. .IP \(bu 2 \fBsegments\fP – minimum segment count .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B approximated_length(segments: int = 128) -> float Returns estimated length of Bèzier\-curve as approximation by line \fIsegments\fP\&. .UNINDENT .INDENT 7.0 .TP .B point(t: float) -> AnyVec Returns point for location \fIt\(ga\fP at the Bèzier\-curve. .INDENT 7.0 .TP .B Parameters \fBt\fP – curve position in the range \fB[0, 1]\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B tangent(t: float) -> AnyVec Returns direction vector of tangent for location \fIt\fP at the Bèzier\-curve. .INDENT 7.0 .TP .B Parameters \fBt\fP – curve position in the range \fB[0, 1]\fP .UNINDENT .UNINDENT .UNINDENT .SS Bezier3P .INDENT 0.0 .TP .B class ezdxf.math.Bezier3P(defpoints: Sequence[\fI\%UVec\fP]) Implements an optimized quadratic \fI\%Bézier curve\fP for exact 3 control points. .sp Special behavior: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 2D control points in, returns 2D results as \fI\%Vec2\fP objects .IP \(bu 2 3D control points in, returns 3D results as \fI\%Vec3\fP objects .IP \(bu 2 Object is immutable. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters \fBdefpoints\fP – iterable of definition points as \fI\%Vec2\fP or \fI\%Vec3\fP compatible objects. .UNINDENT .INDENT 7.0 .TP .B control_points Control points as tuple of \fI\%Vec3\fP or \fI\%Vec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B reverse() -> \fI\%Bezier3P\fP Returns a new Bèzier\-curve with reversed control point order. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> \fI\%Bezier3P\fP General transformation interface, returns a new \fI\%Bezier3P\fP curve and it is always a 3D curve. .INDENT 7.0 .TP .B Parameters \fBm\fP – 4x4 transformation matrix (\fI\%ezdxf.math.Matrix44\fP) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int) -> Iterator[AnyVec] Approximate \fI\%Bézier curve\fP by vertices, yields \fIsegments\fP + 1 vertices as \fB(x, y[, z])\fP tuples. .INDENT 7.0 .TP .B Parameters \fBsegments\fP – count of segments for approximation .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flattening(distance: float, segments: int = 4) -> Iterator[AnyVec] Adaptive recursive flattening. The argument \fIsegments\fP is the minimum count of approximation segments, if the distance from the center of the approximation segment to the curve is bigger than \fIdistance\fP the segment will be subdivided. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the center of the quadratic (C2) curve to the center of the linear (C1) curve between two approximation points to determine if a segment should be subdivided. .IP \(bu 2 \fBsegments\fP – minimum segment count .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B approximated_length(segments: int = 128) -> float Returns estimated length of Bèzier\-curve as approximation by line \fIsegments\fP\&. .UNINDENT .INDENT 7.0 .TP .B point(t: float) -> AnyVec Returns point for location \fIt\(ga\fP at the Bèzier\-curve. .INDENT 7.0 .TP .B Parameters \fBt\fP – curve position in the range \fB[0, 1]\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B tangent(t: float) -> AnyVec Returns direction vector of tangent for location \fIt\fP at the Bèzier\-curve. .INDENT 7.0 .TP .B Parameters \fBt\fP – curve position in the range \fB[0, 1]\fP .UNINDENT .UNINDENT .UNINDENT .SS ApproxParamT .INDENT 0.0 .TP .B class ezdxf.math.ApproxParamT(curve, *, max_t: float = 1.0, segments: int = 100) Approximation tool for parametrized curves. .INDENT 7.0 .IP \(bu 2 approximate parameter \fIt\fP for a given distance from the start of the curve .IP \(bu 2 approximate the distance for a given parameter \fIt\fP from the start of the curve .UNINDENT .sp These approximations can be applied to all parametrized curves which provide a \fBpoint()\fP method, like \fI\%Bezier4P\fP, \fI\%Bezier3P\fP and \fI\%BSpline\fP\&. .sp The approximation is based on equally spaced parameters from 0 to \fImax_t\fP for a given segment count. The \fBflattening()\fP method can not be used for the curve approximation, because the required parameter \fIt\fP is not logged by the flattening process. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcurve\fP – curve object, requires a method \fBpoint()\fP .IP \(bu 2 \fBmax_t\fP – the max. parameter value .IP \(bu 2 \fBsegments\fP – count of approximation segments .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property max_t: float .UNINDENT .INDENT 7.0 .TP .B property polyline: \fI\%ConstructionPolyline\fP .UNINDENT .INDENT 7.0 .TP .B param_t(distance: float) Approximate parameter t for the given \fIdistance\fP from the start of the curve. .UNINDENT .INDENT 7.0 .TP .B distance(t: float) -> float Approximate the distance from the start of the curve to the point \fIt\fP on the curve. .UNINDENT .UNINDENT .SS BezierSurface .INDENT 0.0 .TP .B class ezdxf.math.BezierSurface(defpoints: list[list[\fI\%UVec\fP]]) \fI\%BezierSurface\fP defines a mesh of \fIm\fP x \fIn\fP control points. This is a parametric surface, which means the \fIm\fP\-dimension goes from \fB0\fP to \fB1\fP as parameter \fIu\fP and the \fIn\fP\-dimension goes from \fB0\fP to \fB1\fP as parameter \fIv\fP\&. .INDENT 7.0 .TP .B Parameters \fBdefpoints\fP – matrix (list of lists) of \fIm\fP rows and \fIn\fP columns: [ [m1n1, m1n2, … ], [m2n1, m2n2, …] … ] each element is a 3D location as \fB(x, y, z)\fP tuple. .UNINDENT .INDENT 7.0 .TP .B nrows count of rows (m\-dimension) .UNINDENT .INDENT 7.0 .TP .B ncols count of columns (n\-dimension) .UNINDENT .INDENT 7.0 .TP .B point(u: float, v: float) -> \fI\%Vec3\fP Returns a point for location (\fIu\fP, \fIv\fP) at the Bézier surface as \fB(x, y, z)\fP tuple, parameters \fIu\fP and \fIv\fP in the range of \fB[0, 1]\fP\&. .UNINDENT .INDENT 7.0 .TP .B approximate(usegs: int, vsegs: int) -> list[list[\fI\%Vec3\fP]] Approximate surface as grid of \fB(x, y, z)\fP \fI\%Vec3\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBusegs\fP – count of segments in \fIu\fP\-direction (m\-dimension) .IP \(bu 2 \fBvsegs\fP – count of segments in \fIv\fP\-direction (n\-dimension) .UNINDENT .TP .B Returns list of \fIusegs\fP + 1 rows, each row is a list of \fIvsegs\fP + 1 vertices as \fI\%Vec3\fP\&. .UNINDENT .UNINDENT .UNINDENT .SS EulerSpiral .INDENT 0.0 .TP .B class ezdxf.math.EulerSpiral(curvature: float = 1.0) This class represents an euler spiral (clothoid) for \fIcurvature\fP (Radius of curvature). .sp This is a parametric curve, which always starts at the origin = \fB(0, 0)\fP\&. .INDENT 7.0 .TP .B Parameters \fBcurvature\fP – radius of curvature .UNINDENT .INDENT 7.0 .TP .B radius(t: float) -> float Get radius of circle at distance \fIt\fP\&. .UNINDENT .INDENT 7.0 .TP .B tangent(t: float) -> \fI\%Vec3\fP Get tangent at distance \fIt\fP as \fI\%Vec3\fP object. .UNINDENT .INDENT 7.0 .TP .B distance(radius: float) -> float Get distance L from origin for \fIradius\fP\&. .UNINDENT .INDENT 7.0 .TP .B point(t: float) -> \fI\%Vec3\fP Get point at distance \fIt\fP as \fI\%Vec3\fP\&. .UNINDENT .INDENT 7.0 .TP .B circle_center(t: float) -> \fI\%Vec3\fP Get circle center at distance \fIt\fP\&. .UNINDENT .INDENT 7.0 .TP .B approximate(length: float, segments: int) -> Iterable[\fI\%Vec3\fP] Approximate curve of length with line segments. Generates segments+1 vertices as \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B bspline(length: float, segments: int = 10, degree: int = 3, method: str = \(aquniform\(aq) -> \fI\%BSpline\fP Approximate euler spiral as B\-spline. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlength\fP – length of euler spiral .IP \(bu 2 \fBsegments\fP – count of fit points for B\-spline calculation .IP \(bu 2 \fBdegree\fP – degree of BSpline .IP \(bu 2 \fBmethod\fP – calculation method for parameter vector t .UNINDENT .TP .B Returns \fI\%BSpline\fP .UNINDENT .UNINDENT .UNINDENT .SS Clipping .sp Clipping module: \fI\%ezdxf.math.clipping\fP .INDENT 0.0 .TP .B ezdxf.math.clipping.greiner_hormann_union(p1: Iterable[\fI\%UVec\fP], p2: Iterable[\fI\%UVec\fP]) -> list[list[\fI\%Vec2\fP]] Returns the UNION of polygon \fIp1\fP | polygon \fIp2\fP\&. This algorithm works only for polygons with real intersection points and line end points on face edges are not considered as such intersection points! .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.clipping.greiner_hormann_difference(p1: Iterable[\fI\%UVec\fP], p2: Iterable[\fI\%UVec\fP]) -> list[list[\fI\%Vec2\fP]] Returns the DIFFERENCE of polygon \fIp1\fP \- polygon \fIp2\fP\&. This algorithm works only for polygons with real intersection points and line end points on face edges are not considered as such intersection points! .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.clipping.greiner_hormann_intersection(p1: Iterable[\fI\%UVec\fP], p2: Iterable[\fI\%UVec\fP]) -> list[list[\fI\%Vec2\fP]] Returns the INTERSECTION of polygon \fIp1\fP & polygon \fIp2\fP\&. This algorithm works only for polygons with real intersection points and line end points on face edges are not considered as such intersection points! .UNINDENT .INDENT 0.0 .TP .B class ezdxf.math.clipping.ClippingPolygon2d(vertices: Iterable[\fI\%Vec2\fP], ccw_check=True) The clipping path is an arbitrary polygon. .INDENT 7.0 .TP .B clip_polygon(polygon: Iterable[\fI\%Vec2\fP]) -> Sequence[\fI\%Vec2\fP] Returns the clipped polygon. .UNINDENT .INDENT 7.0 .TP .B clip_polyline(polyline: Iterable[\fI\%Vec2\fP]) -> Sequence[Sequence[\fI\%Vec2\fP]] Returns the parts of the clipped polyline. .UNINDENT .INDENT 7.0 .TP .B clip_line(start: \fI\%Vec2\fP, end: \fI\%Vec2\fP) -> Sequence[\fI\%Vec2\fP] Returns the clipped line. .UNINDENT .INDENT 7.0 .TP .B is_inside(point: \fI\%Vec2\fP) -> bool Returns \fBTrue\fP if \fIpoint\fP is inside the clipping polygon. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.math.clipping.ClippingRect2d(bottom_left: \fI\%Vec2\fP, top_right: \fI\%Vec2\fP) The clipping path is a rectangle parallel to the x\- and y\-axis. .sp This class will get an optimized implementation in the future. .INDENT 7.0 .TP .B clip_polygon(polygon: Iterable[\fI\%Vec2\fP]) -> Sequence[\fI\%Vec2\fP] Returns the clipped polygon. .UNINDENT .INDENT 7.0 .TP .B clip_polyline(polyline: Iterable[\fI\%Vec2\fP]) -> Sequence[Sequence[\fI\%Vec2\fP]] Returns the parts of the clipped polyline. .UNINDENT .INDENT 7.0 .TP .B clip_line(start: \fI\%Vec2\fP, end: \fI\%Vec2\fP) -> Sequence[\fI\%Vec2\fP] Returns the clipped line. .UNINDENT .INDENT 7.0 .TP .B is_inside(point: \fI\%Vec2\fP) -> bool Returns \fBTrue\fP if \fIpoint\fP is inside the clipping rectangle. .UNINDENT .UNINDENT .SS Clustering .sp Clustering module: \fI\%ezdxf.math.clustering\fP .INDENT 0.0 .TP .B ezdxf.math.clustering.average_cluster_radius(clusters: list[list[\fI\%Vec2\fP | \fI\%Vec3\fP]]) -> float Returns the average cluster radius. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.clustering.average_intra_cluster_distance(clusters: list[list[\fI\%Vec2\fP | \fI\%Vec3\fP]]) -> float Returns the average point\-to\-point intra cluster distance. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.clustering.dbscan(points: list[\fI\%Vec2\fP | \fI\%Vec3\fP], *, radius: float, min_points: int = 4, rtree: \fI\%RTree\fP | None = None, max_node_size: int = 5) -> list[list[\fI\%Vec2\fP | \fI\%Vec3\fP]] DBSCAN clustering. .sp \fI\%https://en.wikipedia.org/wiki/DBSCAN\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – list of points to cluster .IP \(bu 2 \fBradius\fP – radius of the dense regions .IP \(bu 2 \fBmin_points\fP – minimum number of points that needs to be within the \fIradius\fP for a point to be a core point (must be >= 2) .IP \(bu 2 \fBrtree\fP – optional \fI\%RTree\fP .IP \(bu 2 \fBmax_node_size\fP – max node size for internally created RTree .UNINDENT .TP .B Returns list of clusters, each cluster is a list of points .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.clustering.k_means(points: list[\fI\%Vec2\fP | \fI\%Vec3\fP], k: int, max_iter: int = 10) -> list[list[\fI\%Vec2\fP | \fI\%Vec3\fP]] K\-means clustering. .sp \fI\%https://en.wikipedia.org/wiki/K\-means_clustering\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – list of points to cluster .IP \(bu 2 \fBk\fP – number of clusters .IP \(bu 2 \fBmax_iter\fP – max iterations .UNINDENT .TP .B Returns list of clusters, each cluster is a list of points .UNINDENT .UNINDENT .SS Linear Algebra .sp Linear algebra module \fBfor internal usage\fP: \fI\%ezdxf.math.linalg\fP .SS Functions .INDENT 0.0 .TP .B ezdxf.math.linalg.gauss_jordan_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> tuple[\fI\%Matrix\fP, \fI\%Matrix\fP] Solves the linear equation system given by a nxn Matrix A . x = B, right\-hand side quantities as nxm Matrix B by the \fI\%Gauss\-Jordan\fP algorithm, which is the slowest of all, but it is very reliable. Returns a copy of the modified input matrix \fIA\fP and the result matrix \fIx\fP\&. .sp Internally used for matrix inverse calculation. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBA\fP – matrix [[a11, a12, …, a1n], [a21, a22, …, a2n], [a21, a22, …, a2n], … [an1, an2, …, ann]] .IP \(bu 2 \fBB\fP – matrix [[b11, b12, …, b1m], [b21, b22, …, b2m], … [bn1, bn2, …, bnm]] .UNINDENT .TP .B Returns 2\-tuple of \fI\%Matrix\fP objects .TP .B Raises \fBZeroDivisionError\fP – singular matrix .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.gauss_jordan_inverse(A: Iterable[Iterable[float]]) -> \fI\%Matrix\fP Returns the inverse of matrix \fIA\fP as \fI\%Matrix\fP object. .sp \fBHINT:\fP .INDENT 7.0 .INDENT 3.5 For small matrices (n<10) is this function faster than LUDecomposition(m).inverse() and as fast even if the decomposition is already done. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Raises \fBZeroDivisionError\fP – singular matrix .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.gauss_vector_solver(A: Iterable[Iterable[float]], B: Iterable[float]) -> list[float] Solves the linear equation system given by a nxn Matrix A . x = B, right\-hand side quantities as vector B with n elements by the \fI\%Gauss\-Elimination\fP algorithm, which is faster than the \fI\%Gauss\-Jordan\fP algorithm. The speed improvement is more significant for solving multiple right\-hand side quantities as matrix at once. .sp Reference implementation for error checking. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBA\fP – matrix [[a11, a12, …, a1n], [a21, a22, …, a2n], [a21, a22, …, a2n], … [an1, an2, …, ann]] .IP \(bu 2 \fBB\fP – vector [b1, b2, …, bn] .UNINDENT .TP .B Returns vector as list of floats .TP .B Raises \fBZeroDivisionError\fP – singular matrix .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.gauss_matrix_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> \fI\%Matrix\fP Solves the linear equation system given by a nxn Matrix A . x = B, right\-hand side quantities as nxm Matrix B by the \fI\%Gauss\-Elimination\fP algorithm, which is faster than the \fI\%Gauss\-Jordan\fP algorithm. .sp Reference implementation for error checking. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBA\fP – matrix [[a11, a12, …, a1n], [a21, a22, …, a2n], [a21, a22, …, a2n], … [an1, an2, …, ann]] .IP \(bu 2 \fBB\fP – matrix [[b11, b12, …, b1m], [b21, b22, …, b2m], … [bn1, bn2, …, bnm]] .UNINDENT .TP .B Returns matrix as \fI\%Matrix\fP object .TP .B Raises \fBZeroDivisionError\fP – singular matrix .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.tridiagonal_vector_solver(A: Iterable[Iterable[float]], B: Iterable[float]) -> list[float] Solves the linear equation system given by a tri\-diagonal nxn Matrix A . x = B, right\-hand side quantities as vector B. Matrix A is diagonal matrix defined by 3 diagonals [\-1 (a), 0 (b), +1 (c)]. .sp Note: a0 is not used but has to be present, cn\-1 is also not used and must not be present. .sp If an \fBZeroDivisionError\fP exception occurs, the equation system can possibly be solved by \fBBandedMatrixLU(A, 1, 1).solve_vector(B)\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBA\fP – .sp diagonal matrix [[a0..an\-1], [b0..bn\-1], [c0..cn\-1]] .INDENT 2.0 .INDENT 3.5 .sp .EX [[b0, c0, 0, 0, ...], [a1, b1, c1, 0, ...], [0, a2, b2, c2, ...], \&... ] .EE .UNINDENT .UNINDENT .IP \(bu 2 \fBB\fP – iterable of floats [[b1, b1, …, bn] .UNINDENT .TP .B Returns list of floats .TP .B Raises \fBZeroDivisionError\fP – singular matrix .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.tridiagonal_matrix_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> \fI\%Matrix\fP Solves the linear equation system given by a tri\-diagonal nxn Matrix A . x = B, right\-hand side quantities as nxm Matrix B. Matrix A is diagonal matrix defined by 3 diagonals [\-1 (a), 0 (b), +1 (c)]. .sp Note: a0 is not used but has to be present, cn\-1 is also not used and must not be present. .sp If an \fBZeroDivisionError\fP exception occurs, the equation system can possibly be solved by \fBBandedMatrixLU(A, 1, 1).solve_vector(B)\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBA\fP – .sp diagonal matrix [[a0..an\-1], [b0..bn\-1], [c0..cn\-1]] .INDENT 2.0 .INDENT 3.5 .sp .EX [[b0, c0, 0, 0, ...], [a1, b1, c1, 0, ...], [0, a2, b2, c2, ...], \&... ] .EE .UNINDENT .UNINDENT .IP \(bu 2 \fBB\fP – matrix [[b11, b12, …, b1m], [b21, b22, …, b2m], … [bn1, bn2, …, bnm]] .UNINDENT .TP .B Returns matrix as \fI\%Matrix\fP object .TP .B Raises \fBZeroDivisionError\fP – singular matrix .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.banded_matrix(A: \fI\%Matrix\fP, check_all=True) -> tuple[\fI\%Matrix\fP, int, int] Transform matrix A into a compact banded matrix representation. Returns compact representation as \fI\%Matrix\fP object and lower\- and upper band count m1 and m2. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBA\fP – input \fI\%Matrix\fP .IP \(bu 2 \fBcheck_all\fP – check all diagonals if \fBTrue\fP or abort testing after first all zero diagonal if \fBFalse\fP\&. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.detect_banded_matrix(A: \fI\%Matrix\fP, check_all=True) -> tuple[int, int] Returns lower\- and upper band count m1 and m2. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBA\fP – input \fI\%Matrix\fP .IP \(bu 2 \fBcheck_all\fP – check all diagonals if \fBTrue\fP or abort testing after first all zero diagonal if \fBFalse\fP\&. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.compact_banded_matrix(A: \fI\%Matrix\fP, m1: int, m2: int) -> \fI\%Matrix\fP Returns compact banded matrix representation as \fI\%Matrix\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBA\fP – matrix to transform .IP \(bu 2 \fBm1\fP – lower band count, excluding main matrix diagonal .IP \(bu 2 \fBm2\fP – upper band count, excluding main matrix diagonal .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.linalg.freeze_matrix(A: Iterable[Iterable[float]] | \fI\%Matrix\fP) -> \fI\%Matrix\fP Returns a frozen matrix, all data is stored in immutable tuples. .UNINDENT .SS Matrix Class .INDENT 0.0 .TP .B class ezdxf.math.linalg.Matrix(items: Any = None, shape: Tuple[int, int] | None = None, matrix: List[List[float]] | None = None) Basic matrix implementation without any optimization for speed or memory usage. Matrix data is stored in row major order, this means in a list of rows, where each row is a list of floats. Direct access to the data is accessible by the attribute \fBMatrix.matrix\fP\&. .sp The matrix can be frozen by function \fI\%freeze_matrix()\fP or method \fI\%Matrix.freeze()\fP, than the data is stored in immutable tuples. .sp Initialization: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Matrix(shape=(rows, cols)) … new matrix filled with zeros .IP \(bu 2 Matrix(matrix[, shape=(rows, cols)]) … from copy of matrix and optional reshape .IP \(bu 2 Matrix([[row_0], [row_1], …, [row_n]]) … from Iterable[Iterable[float]] .IP \(bu 2 Matrix([a1, a2, …, an], shape=(rows, cols)) … from Iterable[float] and shape .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B nrows Count of matrix rows. .UNINDENT .INDENT 7.0 .TP .B ncols Count of matrix columns. .UNINDENT .INDENT 7.0 .TP .B shape Shape of matrix as (n, m) tuple for n rows and m columns. .UNINDENT .INDENT 7.0 .TP .B static reshape(items: Iterable[float], shape: Tuple[int, int]) -> \fI\%Matrix\fP Returns a new matrix for iterable \fIitems\fP in the configuration of \fIshape\fP\&. .UNINDENT .INDENT 7.0 .TP .B classmethod identity(shape: Tuple[int, int]) -> \fI\%Matrix\fP Returns the identity matrix for configuration \fIshape\fP\&. .UNINDENT .INDENT 7.0 .TP .B row(index: int) -> list[float] Returns row \fIindex\fP as list of floats. .UNINDENT .INDENT 7.0 .TP .B iter_row(index: int) -> Iterator[float] Yield values of row \fIindex\fP\&. .UNINDENT .INDENT 7.0 .TP .B col(index: int) -> list[float] Return column \fIindex\fP as list of floats. .UNINDENT .INDENT 7.0 .TP .B iter_col(index: int) -> Iterator[float] Yield values of column \fIindex\fP\&. .UNINDENT .INDENT 7.0 .TP .B diag(index: int) -> list[float] Returns diagonal \fIindex\fP as list of floats. .sp An \fIindex\fP of 0 specifies the main diagonal, negative values specifies diagonals below the main diagonal and positive values specifies diagonals above the main diagonal. .sp e.g. given a 4x4 matrix: .INDENT 7.0 .IP \(bu 2 index 0 is [00, 11, 22, 33], .IP \(bu 2 index \-1 is [10, 21, 32] and .IP \(bu 2 index +1 is [01, 12, 23] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B iter_diag(index: int) -> Iterator[float] Yield values of diagonal \fIindex\fP, see also \fI\%diag()\fP\&. .UNINDENT .INDENT 7.0 .TP .B rows() -> List[List[float]] Return a list of all rows. .UNINDENT .INDENT 7.0 .TP .B cols() -> List[List[float]] Return a list of all columns. .UNINDENT .INDENT 7.0 .TP .B set_row(index: int, items: float | Sequence[float] = 1.0) -> None Set row values to a fixed value or from an iterable of floats. .UNINDENT .INDENT 7.0 .TP .B set_col(index: int, items: float | Iterable[float] = 1.0) -> None Set column values to a fixed value or from an iterable of floats. .UNINDENT .INDENT 7.0 .TP .B set_diag(index: int = 0, items: float | Iterable[float] = 1.0) -> None Set diagonal values to a fixed value or from an iterable of floats. .sp An \fIindex\fP of \fB0\fP specifies the main diagonal, negative values specifies diagonals below the main diagonal and positive values specifies diagonals above the main diagonal. .sp e.g. given a 4x4 matrix: index \fB0\fP is [00, 11, 22, 33], index \fB\-1\fP is [10, 21, 32] and index \fB+1\fP is [01, 12, 23] .UNINDENT .INDENT 7.0 .TP .B append_row(items: Sequence[float]) -> None Append a row to the matrix. .UNINDENT .INDENT 7.0 .TP .B append_col(items: Sequence[float]) -> None Append a column to the matrix. .UNINDENT .INDENT 7.0 .TP .B swap_rows(a: int, b: int) -> None Swap rows \fIa\fP and \fIb\fP inplace. .UNINDENT .INDENT 7.0 .TP .B swap_cols(a: int, b: int) -> None Swap columns \fIa\fP and \fIb\fP inplace. .UNINDENT .INDENT 7.0 .TP .B transpose() -> \fI\%Matrix\fP Returns a new transposed matrix. .UNINDENT .INDENT 7.0 .TP .B inverse() -> \fI\%Matrix\fP Returns inverse of matrix as new object. .UNINDENT .INDENT 7.0 .TP .B determinant() -> float Returns determinant of matrix, raises \fBZeroDivisionError\fP if matrix is singular. .UNINDENT .INDENT 7.0 .TP .B freeze() -> \fI\%Matrix\fP Returns a frozen matrix, all data is stored in immutable tuples. .UNINDENT .INDENT 7.0 .TP .B lu_decomp() -> \fI\%LUDecomposition\fP Returns the \fI\%LU decomposition\fP as \fI\%LUDecomposition\fP object, a faster linear equation solver. .UNINDENT .INDENT 7.0 .TP .B __getitem__(item: tuple[int, int]) -> float Get value by (row, col) index tuple, fancy slicing as known from numpy is not supported. .UNINDENT .INDENT 7.0 .TP .B __setitem__(item: tuple[int, int], value: float) Set value by (row, col) index tuple, fancy slicing as known from numpy is not supported. .UNINDENT .INDENT 7.0 .TP .B __eq__(other: object) -> bool Returns \fBTrue\fP if matrices are equal, tolerance value for comparison is adjustable by the attribute \fBMatrix.abs_tol\fP\&. .UNINDENT .INDENT 7.0 .TP .B __add__(other: \fI\%Matrix\fP | float) -> \fI\%Matrix\fP Matrix addition by another matrix or a float, returns a new matrix. .UNINDENT .INDENT 7.0 .TP .B __sub__(other: \fI\%Matrix\fP | float) -> \fI\%Matrix\fP Matrix subtraction by another matrix or a float, returns a new matrix. .UNINDENT .INDENT 7.0 .TP .B __mul__(other: \fI\%Matrix\fP | float) -> \fI\%Matrix\fP Matrix multiplication by another matrix or a float, returns a new matrix. .UNINDENT .UNINDENT .SS LUDecomposition Class .INDENT 0.0 .TP .B class ezdxf.math.linalg.LUDecomposition(A: Iterable[Iterable[float]]) Represents a \fI\%LU decomposition\fP matrix of A, raise \fBZeroDivisionError\fP for a singular matrix. .sp This algorithm is a little bit faster than the \fI\%Gauss\-Elimination\fP algorithm using CPython and much faster when using pypy. .sp The \fBLUDecomposition.matrix\fP attribute gives access to the matrix data as list of rows like in the \fI\%Matrix\fP class, and the \fBLUDecomposition.index\fP attribute gives access to the swapped row indices. .INDENT 7.0 .TP .B Parameters \fBA\fP – matrix [[a11, a12, …, a1n], [a21, a22, …, a2n], [a21, a22, …, a2n], … [an1, an2, …, ann]] .TP .B Raises \fBZeroDivisionError\fP – singular matrix .UNINDENT .INDENT 7.0 .TP .B nrows Count of matrix rows (and cols). .UNINDENT .INDENT 7.0 .TP .B solve_vector(B: Iterable[float]) -> list[float] Solves the linear equation system given by the nxn Matrix A . x = B, right\-hand side quantities as vector B with n elements. .INDENT 7.0 .TP .B Parameters \fBB\fP – vector [b1, b2, …, bn] .TP .B Returns vector as list of floats .UNINDENT .UNINDENT .INDENT 7.0 .TP .B solve_matrix(B: Iterable[Iterable[float]]) -> \fI\%Matrix\fP Solves the linear equation system given by the nxn Matrix A . x = B, right\-hand side quantities as nxm Matrix B. .INDENT 7.0 .TP .B Parameters \fBB\fP – matrix [[b11, b12, …, b1m], [b21, b22, …, b2m], … [bn1, bn2, …, bnm]] .TP .B Returns matrix as \fI\%Matrix\fP object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B inverse() -> \fI\%Matrix\fP Returns the inverse of matrix as \fI\%Matrix\fP object, raise \fBZeroDivisionError\fP for a singular matrix. .UNINDENT .INDENT 7.0 .TP .B determinant() -> float Returns the determinant of matrix, raises \fBZeroDivisionError\fP if matrix is singular. .UNINDENT .UNINDENT .SS BandedMatrixLU Class .INDENT 0.0 .TP .B class ezdxf.math.linalg.BandedMatrixLU(A: \fI\%Matrix\fP, m1: int, m2: int) Represents a LU decomposition of a compact banded matrix. .INDENT 7.0 .TP .B upper Upper triangle .UNINDENT .INDENT 7.0 .TP .B lower Lower triangle .UNINDENT .INDENT 7.0 .TP .B m1 Lower band count, excluding main matrix diagonal .UNINDENT .INDENT 7.0 .TP .B m2 Upper band count, excluding main matrix diagonal .UNINDENT .INDENT 7.0 .TP .B index Swapped indices .UNINDENT .INDENT 7.0 .TP .B nrows Count of matrix rows. .UNINDENT .INDENT 7.0 .TP .B solve_vector(B: Iterable[float]) -> list[float] Solves the linear equation system given by the banded nxn Matrix A . x = B, right\-hand side quantities as vector B with n elements. .INDENT 7.0 .TP .B Parameters \fBB\fP – vector [b1, b2, …, bn] .TP .B Returns vector as list of floats .UNINDENT .UNINDENT .INDENT 7.0 .TP .B solve_matrix(B: Iterable[Iterable[float]]) -> \fI\%Matrix\fP Solves the linear equation system given by the banded nxn Matrix A . x = B, right\-hand side quantities as nxm Matrix B. .INDENT 7.0 .TP .B Parameters \fBB\fP – matrix [[b11, b12, …, b1m], [b21, b22, …, b2m], … [bn1, bn2, …, bnm]] .TP .B Returns matrix as \fI\%Matrix\fP object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B determinant() -> float Returns the determinant of matrix. .UNINDENT .UNINDENT .SS RTree .sp RTree module: \fI\%ezdxf.math.rtree\fP .INDENT 0.0 .TP .B class ezdxf.math.rtree.RTree(points: Iterable[AnyVec], max_node_size: int = 5) Immutable spatial search tree loosely based on \fI\%R\-trees\fP\&. .sp The search tree is buildup once at initialization and immutable afterwards, because rebuilding the tree after inserting or deleting nodes is very costly and also keeps the implementation very simple. Without the ability to alter the content the restrictions which forces the tree balance at growing and shrinking of the original \fI\%R\-trees\fP, could be ignored, like the fixed minimum and maximum node size. .sp This class uses internally only 3D bounding boxes, but also supports \fBVec2\fP as well as \fBVec3\fP objects as input data, but point types should not be mixed in a single search tree. .sp The point objects keep their type and identity and the returned points of queries can be compared by the \fBis\fP operator for identity to the input points. .sp The implementation requires a maximum node size of at least 2 and does not support empty trees! .INDENT 7.0 .TP .B Raises \fBValueError\fP – max. node size too small or no data given .UNINDENT .INDENT 7.0 .TP .B __len__() Returns the count of points in the search tree. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[\fI\%Vec3\fP | \fI\%Vec2\fP] Yields all points in the search tree. .UNINDENT .INDENT 7.0 .TP .B contains(point: \fI\%Vec2\fP | \fI\%Vec3\fP) -> bool Returns \fBTrue\fP if \fIpoint\fP exists, the comparison is done by the \fBisclose()\fP method and not by the identity operator \fBis\fP\&. .UNINDENT .INDENT 7.0 .TP .B nearest_neighbor(target: \fI\%Vec2\fP | \fI\%Vec3\fP) -> tuple[\fI\%Vec2\fP | \fI\%Vec3\fP, float] Returns the closest point to the \fItarget\fP point and the distance between these points. .UNINDENT .INDENT 7.0 .TP .B points_in_sphere(center: \fI\%Vec2\fP | \fI\%Vec3\fP, radius: float) -> Iterator[\fI\%Vec3\fP | \fI\%Vec2\fP] Returns all points in the range of the given sphere including the points at the boundary. .UNINDENT .INDENT 7.0 .TP .B points_in_bbox(bbox: \fI\%BoundingBox\fP) -> Iterator[\fI\%Vec3\fP | \fI\%Vec2\fP] Returns all points in the range of the given bounding box including the points at the boundary. .UNINDENT .INDENT 7.0 .TP .B avg_leaf_size(spread: float = 1.0) -> float Returns the average size of the leaf bounding boxes. The size of a leaf bounding box is the maximum size in all dimensions. Excludes outliers of sizes beyond mean + standard deviation * spread. Returns 0.0 if less than two points in tree. .UNINDENT .INDENT 7.0 .TP .B avg_spherical_envelope_radius(spread: float = 1.0) -> float Returns the average radius of spherical envelopes of the leaf nodes. Excludes outliers with radius beyond mean + standard deviation * spread. Returns 0.0 if less than two points in tree. .UNINDENT .INDENT 7.0 .TP .B avg_nn_distance(spread: float = 1.0) -> float Returns the average of the nearest neighbor distances inside (!) leaf nodes. Excludes outliers with a distance beyond the overall mean + standard deviation * spread. Returns 0.0 if less than two points in tree. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 This is a brute force check with O(n!) for each leaf node, where n is the point count of the leaf node. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Triangulation .sp Triangulation module: \fI\%ezdxf.math.triangulation\fP .INDENT 0.0 .TP .B ezdxf.math.triangulation.mapbox_earcut_2d(exterior: Iterable[\fI\%UVec\fP], holes: Iterable[Iterable[\fI\%UVec\fP]] | None = None) -> list[Sequence[\fI\%Vec2\fP]] Mapbox triangulation algorithm with hole support for 2D polygons. .sp Implements a modified ear slicing algorithm, optimized by z\-order curve hashing and extended to handle holes, twisted polygons, degeneracies and self\-intersections in a way that doesn’t guarantee correctness of triangulation, but attempts to always produce acceptable results for practical data. .sp Source: \fI\%https://github.com/mapbox/earcut\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBexterior\fP – exterior polygon as iterable of \fBVec2\fP objects .IP \(bu 2 \fBholes\fP – iterable of holes as iterable of \fBVec2\fP objects, a hole with single point represents a \fI\%Steiner point\fP\&. .UNINDENT .TP .B Returns yields the result as 3\-tuples of \fBVec2\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.triangulation.mapbox_earcut_3d(exterior: Iterable[\fI\%UVec\fP], holes: Iterable[Iterable[\fI\%UVec\fP]] | None = None) -> Iterator[tuple[\fI\%Vec3\fP, \fI\%Vec3\fP, \fI\%Vec3\fP]] Mapbox triangulation algorithm with hole support for flat 3D polygons. .sp Implements a modified ear slicing algorithm, optimized by z\-order curve hashing and extended to handle holes, twisted polygons, degeneracies and self\-intersections in a way that doesn’t guarantee correctness of triangulation, but attempts to always produce acceptable results for practical data. .sp Source: \fI\%https://github.com/mapbox/earcut\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBexterior\fP – exterior polygon as iterable of \fBVec3\fP objects .IP \(bu 2 \fBholes\fP – iterable of holes as iterable of \fBVec3\fP objects, a hole with single point represents a \fI\%Steiner point\fP\&. .UNINDENT .TP .B Returns yields the result as 3\-tuples of \fBVec3\fP objects .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBTypeError\fP – invalid input data type .IP \(bu 2 \fBZeroDivisionError\fP – normal vector calculation failed .UNINDENT .UNINDENT .UNINDENT .SS Construction .SS Path .sp This module implements a geometric \fI\%Path\fP, supported by several render backends, with the goal to create such paths from DXF entities like LWPOLYLINE, POLYLINE or HATCH and send them to the render backend, see \fI\%ezdxf.addons.drawing\fP\&. .sp Minimum common interface: .INDENT 0.0 .IP \(bu 2 .INDENT 2.0 .TP .B matplotlib: \fI\%PathPatch\fP .INDENT 7.0 .IP \(bu 2 matplotlib.path.Path() codes: .IP \(bu 2 MOVETO .IP \(bu 2 LINETO .IP \(bu 2 CURVE3 \- quadratic Bèzier\-curve .IP \(bu 2 CURVE4 \- cubic Bèzier\-curve .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B PyQt: \fI\%QPainterPath\fP .INDENT 7.0 .IP \(bu 2 moveTo() .IP \(bu 2 lineTo() .IP \(bu 2 quadTo() \- quadratic Bèzier\-curve (converted to a cubic Bèzier\-curve) .IP \(bu 2 cubicTo() \- cubic Bèzier\-curve .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B PyCairo: \fI\%Context\fP .INDENT 7.0 .IP \(bu 2 move_to() .IP \(bu 2 line_to() .IP \(bu 2 no support for quadratic Bèzier\-curve .IP \(bu 2 curve_to() \- cubic Bèzier\-curve .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B SVG: \fI\%SVG\-Path\fP .INDENT 7.0 .IP \(bu 2 “M” \- absolute move to .IP \(bu 2 “L” \- absolute line to .IP \(bu 2 “Q” \- absolute quadratic Bèzier\-curve .IP \(bu 2 “C” \- absolute cubic Bèzier\-curve .UNINDENT .UNINDENT .UNINDENT .sp ARC and ELLIPSE entities are approximated by multiple cubic Bézier\-curves, which are close enough for display rendering. Non\-rational SPLINES of 3rd degree can be represented exact as multiple cubic Bézier\-curves, other B\-splines will be approximated. The XLINE and the RAY entities are not supported, because of their infinite nature. .sp This \fI\%Path\fP class is a full featured 3D object, although the backends only support 2D paths. .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 A \fI\%Path\fP can not represent a point. A \fI\%Path\fP with only a start point yields no vertices! .UNINDENT .UNINDENT .sp The usability of the \fI\%Path\fP class expanded by the introduction of the reverse conversion from \fI\%Path\fP to DXF entities (LWPOLYLINE, POLYLINE, LINE), and many other tools in \fIezdxf\fP v0.16. To emphasize this new usability, the \fI\%Path\fP class has got its own subpackage \fI\%ezdxf.path\fP\&. .INDENT 0.0 .TP .B Empty\-Path Contains only a start point, the length of the path is 0 and the methods \fI\%Path.approximate()\fP, \fI\%Path.flattening()\fP and \fI\%Path.control_vertices()\fP do not yield any vertices. .TP .B Single\-Path The \fI\%Path\fP object contains only one path without gaps, the property \fI\%Path.has_sub_paths\fP is \fBFalse\fP and the method \fI\%Path.sub_paths()\fP yields only this one path. .TP .B Multi\-Path The \fI\%Path\fP object contains more than one path, the property \fI\%Path.has_sub_paths\fP is \fBTrue\fP and the method \fI\%Path.sub_paths()\fP yields all paths within this object as single\-path objects. It is not possible to detect the orientation of a multi\-path object, therefore the methods \fI\%Path.has_clockwise_orientation()\fP, \fI\%Path.clockwise()\fP and \fI\%Path.counter_clockwise()\fP raise a \fBTypeError\fP exception. .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Always import from the top level \fI\%ezdxf.path\fP, never from the sub\-modules .UNINDENT .UNINDENT .SS Factory Functions .sp Functions to create \fI\%Path\fP objects from other objects. .INDENT 0.0 .TP .B ezdxf.path.make_path(entity: \fI\%DXFEntity\fP) -> \fI\%Path\fP Factory function to create a single \fI\%Path\fP object from a DXF entity. Supported DXF types: .INDENT 7.0 .IP \(bu 2 LINE .IP \(bu 2 CIRCLE .IP \(bu 2 ARC .IP \(bu 2 ELLIPSE .IP \(bu 2 SPLINE and HELIX .IP \(bu 2 LWPOLYLINE .IP \(bu 2 2D and 3D POLYLINE .IP \(bu 2 SOLID, TRACE, 3DFACE .IP \(bu 2 IMAGE, WIPEOUT clipping path .IP \(bu 2 VIEWPORT clipping path .IP \(bu 2 HATCH as \fI\%Multi\-Path\fP object .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP – DXF entity .IP \(bu 2 \fBsegments\fP – minimal count of cubic Bézier\-curves for elliptical arcs like CIRCLE, ARC, ELLIPSE, BULGE see \fBPath.add_ellipse()\fP .IP \(bu 2 \fBlevel\fP – subdivide level for SPLINE approximation, see \fBPath.add_spline()\fP .UNINDENT .TP .B Raises \fBTypeError\fP – for unsupported DXF types .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.from_hatch(hatch: DXFPolygon, offset: \fI\%Vec3\fP = NULLVEC) -> Iterator[Path] Yield all HATCH/MPOLYGON boundary paths as separated \fI\%Path\fP objects in WCS coordinates. .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.from_vertices(vertices: Iterable[\fI\%UVec\fP], close=False) -> Path Returns a \fI\%Path\fP object from the given \fIvertices\fP\&. .UNINDENT .SS Render Functions .sp Functions to create DXF entities from paths and add them to the modelspace, a paperspace layout or a block definition. .INDENT 0.0 .TP .B ezdxf.path.render_hatches(layout: GenericLayoutType, paths: Iterable[\fI\%Path\fP], *, edge_path: bool = True, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, g1_tol: float = G1_TOL, extrusion: \fI\%UVec\fP = Z_AXIS, dxfattribs=None) -> \fI\%EntityQuery\fP Render the given \fIpaths\fP into \fIlayout\fP as \fI\%Hatch\fP entities. The \fIextrusion\fP vector is applied to all paths, all vertices are projected onto the plane normal to this extrusion vector. The default extrusion vector is the WCS z\-axis. The plane elevation is the distance from the WCS origin to the start point of the first path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – the modelspace, a paperspace layout or a block definition .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP or \fBPath2d\fP objects .IP \(bu 2 \fBedge_path\fP – \fBTrue\fP for edge paths build of LINE and SPLINE edges, \fBFalse\fP for only LWPOLYLINE paths as boundary paths .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve to flatten polyline paths .IP \(bu 2 \fBg1_tol\fP – tolerance for G1 continuity check to separate SPLINE edges .IP \(bu 2 \fBextrusion\fP – extrusion vector for all paths .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns created entities in an \fI\%EntityQuery\fP object .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.render_lines(layout: GenericLayoutType, paths: Iterable[\fI\%Path\fP], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, dxfattribs=None) -> \fI\%EntityQuery\fP Render the given \fIpaths\fP into \fIlayout\fP as \fI\%Line\fP entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – the modelspace, a paperspace layout or a block definition .IP \(bu 2 \fBpaths\fP – iterable of \fBPath\(gaor :class:\(gaPath2d\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns created entities in an \fI\%EntityQuery\fP object .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.render_lwpolylines(layout: GenericLayoutType, paths: Iterable[\fI\%Path\fP], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, extrusion: \fI\%UVec\fP = Z_AXIS, dxfattribs=None) -> \fI\%EntityQuery\fP Render the given \fIpaths\fP into \fIlayout\fP as \fI\%LWPolyline\fP entities. The \fIextrusion\fP vector is applied to all paths, all vertices are projected onto the plane normal to this extrusion vector. The default extrusion vector is the WCS z\-axis. The plane elevation is the distance from the WCS origin to the start point of the first path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – the modelspace, a paperspace layout or a block definition .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP or \fBPath2d\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .IP \(bu 2 \fBextrusion\fP – extrusion vector for all paths .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns created entities in an \fI\%EntityQuery\fP object .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.render_mpolygons(layout: GenericLayoutType, paths: Iterable[\fI\%Path\fP], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, extrusion: \fI\%UVec\fP = Z_AXIS, dxfattribs=None) -> \fI\%EntityQuery\fP Render the given \fIpaths\fP into \fIlayout\fP as \fI\%MPolygon\fP entities. The MPOLYGON entity supports only polyline boundary paths. All curves will be approximated. .sp The \fIextrusion\fP vector is applied to all paths, all vertices are projected onto the plane normal to this extrusion vector. The default extrusion vector is the WCS z\-axis. The plane elevation is the distance from the WCS origin to the start point of the first path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – the modelspace, a paperspace layout or a block definition .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP or \fBPath2d\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve to flatten polyline paths .IP \(bu 2 \fBextrusion\fP – extrusion vector for all paths .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns created entities in an \fI\%EntityQuery\fP object .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.render_polylines2d(layout: GenericLayoutType, paths: Iterable[\fI\%Path\fP], *, distance: float = 0.01, segments: int = 4, extrusion: \fI\%UVec\fP = Z_AXIS, dxfattribs=None) -> \fI\%EntityQuery\fP Render the given \fIpaths\fP into \fIlayout\fP as 2D \fI\%Polyline\fP entities. The \fIextrusion\fP vector is applied to all paths, all vertices are projected onto the plane normal to this extrusion vector.The default extrusion vector is the WCS z\-axis. The plane elevation is the distance from the WCS origin to the start point of the first path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – the modelspace, a paperspace layout or a block definition .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP or \fBPath2d\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .IP \(bu 2 \fBextrusion\fP – extrusion vector for all paths .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns created entities in an \fI\%EntityQuery\fP object .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.render_polylines3d(layout: GenericLayoutType, paths: Iterable[\fI\%Path\fP], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, dxfattribs=None) -> \fI\%EntityQuery\fP Render the given \fIpaths\fP into \fIlayout\fP as 3D \fI\%Polyline\fP entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – the modelspace, a paperspace layout or a block definition .IP \(bu 2 \fBpaths\fP – iterable of \fBPath\(gaor :class:\(gaPath2d\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns created entities in an \fI\%EntityQuery\fP object .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.render_splines_and_polylines(layout: GenericLayoutType, paths: Iterable[\fI\%Path\fP], *, g1_tol: float = G1_TOL, dxfattribs=None) -> \fI\%EntityQuery\fP Render the given \fIpaths\fP into \fIlayout\fP as \fI\%Spline\fP and 3D \fI\%Polyline\fP entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – the modelspace, a paperspace layout or a block definition .IP \(bu 2 \fBpaths\fP – iterable of \fBPath\(gaor :class:\(gaPath2d\fP objects .IP \(bu 2 \fBg1_tol\fP – tolerance for G1 continuity check .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns created entities in an \fI\%EntityQuery\fP object .UNINDENT .UNINDENT .SS Entity Maker .sp Functions to create DXF entities from paths. .INDENT 0.0 .TP .B ezdxf.path.to_hatches(paths: Iterable[Path], *, edge_path: bool = True, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, g1_tol: float = G1_TOL, extrusion: \fI\%UVec\fP = Z_AXIS, dxfattribs=None) -> Iterator[Hatch] Convert the given \fIpaths\fP into \fI\%Hatch\fP entities. Uses LWPOLYLINE paths for boundaries without curves and edge paths, build of LINE and SPLINE edges, as boundary paths for boundaries including curves. The \fIextrusion\fP vector is applied to all paths, all vertices are projected onto the plane normal to this extrusion vector. The default extrusion vector is the WCS z\-axis. The plane elevation is the distance from the WCS origin to the start point of the first path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP objects .IP \(bu 2 \fBedge_path\fP – \fBTrue\fP for edge paths build of LINE and SPLINE edges, \fBFalse\fP for only LWPOLYLINE paths as boundary paths .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve to flatten LWPOLYLINE paths .IP \(bu 2 \fBg1_tol\fP – tolerance for G1 continuity check to separate SPLINE edges .IP \(bu 2 \fBextrusion\fP – extrusion vector to all paths .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns iterable of \fI\%Hatch\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.to_lines(paths: Iterable[Path], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, dxfattribs=None) -> Iterator[Line] Convert the given \fIpaths\fP into \fI\%Line\fP entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns iterable of \fI\%Line\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.to_lwpolylines(paths: Iterable[Path], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, extrusion: \fI\%UVec\fP = Z_AXIS, dxfattribs=None) -> Iterator[LWPolyline] Convert the given \fIpaths\fP into \fI\%LWPolyline\fP entities. The \fIextrusion\fP vector is applied to all paths, all vertices are projected onto the plane normal to this extrusion vector. The default extrusion vector is the WCS z\-axis. The plane elevation is the distance from the WCS origin to the start point of the first path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .IP \(bu 2 \fBextrusion\fP – extrusion vector for all paths .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns iterable of \fI\%LWPolyline\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.to_mpolygons(paths: Iterable[Path], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, extrusion: \fI\%UVec\fP = Z_AXIS, dxfattribs=None) -> Iterator[MPolygon] Convert the given \fIpaths\fP into \fI\%MPolygon\fP entities. In contrast to HATCH, MPOLYGON supports only polyline boundary paths. All curves will be approximated. .sp The \fIextrusion\fP vector is applied to all paths, all vertices are projected onto the plane normal to this extrusion vector. The default extrusion vector is the WCS z\-axis. The plane elevation is the distance from the WCS origin to the start point of the first path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve to flatten LWPOLYLINE paths .IP \(bu 2 \fBextrusion\fP – extrusion vector to all paths .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns iterable of \fI\%MPolygon\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.to_polylines2d(paths: Iterable[Path], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, extrusion: \fI\%UVec\fP = Z_AXIS, dxfattribs=None) -> Iterator[Polyline] Convert the given \fIpaths\fP into 2D \fI\%Polyline\fP entities. The \fIextrusion\fP vector is applied to all paths, all vertices are projected onto the plane normal to this extrusion vector. The default extrusion vector is the WCS z\-axis. The plane elevation is the distance from the WCS origin to the start point of the first path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .IP \(bu 2 \fBextrusion\fP – extrusion vector for all paths .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns iterable of 2D \fI\%Polyline\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.to_polylines3d(paths: Iterable[Path], *, distance: float = MAX_DISTANCE, segments: int = MIN_SEGMENTS, dxfattribs=None) -> Iterator[Polyline] Convert the given \fIpaths\fP into 3D \fI\%Polyline\fP entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP objects .IP \(bu 2 \fBdistance\fP – maximum distance, see \fI\%Path.flattening()\fP .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns iterable of 3D \fI\%Polyline\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.to_splines_and_polylines(paths: Iterable[Path], *, g1_tol: float = G1_TOL, dxfattribs=None) -> Iterator[Spline | Polyline] Convert the given \fIpaths\fP into \fI\%Spline\fP and 3D \fI\%Polyline\fP entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP objects .IP \(bu 2 \fBg1_tol\fP – tolerance for G1 continuity check .IP \(bu 2 \fBdxfattribs\fP – additional DXF attribs .UNINDENT .TP .B Returns iterable of \fI\%Line\fP objects .UNINDENT .UNINDENT .SS Tool Maker .sp Functions to create construction tools. .INDENT 0.0 .TP .B ezdxf.path.to_bsplines_and_vertices(path: Path, g1_tol: float = G1_TOL) -> Iterator[\fI\%BSpline\fP | List[\fI\%Vec3\fP]] Convert a \fI\%Path\fP object into multiple cubic B\-splines and polylines as lists of vertices. Breaks adjacent Bèzier without G1 continuity into separated B\-splines. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpath\fP – \fI\%Path\fP objects .IP \(bu 2 \fBg1_tol\fP – tolerance for G1 continuity check .UNINDENT .TP .B Returns \fI\%BSpline\fP and lists of \fI\%Vec3\fP .UNINDENT .UNINDENT .SS Utility Functions .INDENT 0.0 .TP .B ezdxf.path.add_bezier3p(path: Path, curves: Iterable[\fI\%Bezier3P\fP]) -> None Add multiple quadratic Bèzier\-curves to the given \fIpath\fP\&. .sp Auto\-detect the connection point to the given \fIpath\fP, if neither the start\- nor the end point of the curves is close to the path end point, a line from the path end point to the start point of the first curve will be added automatically. .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.add_bezier4p(path: Path, curves: Iterable[\fI\%Bezier4P\fP]) -> None Add multiple cubic Bèzier\-curves to the given \fIpath\fP\&. .sp Auto\-detect the connection point to the given \fIpath\fP, if neither the start\- nor the end point of the curves is close to the path end point, a line from the path end point to the start point of the first curve will be added automatically. .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.add_ellipse(path: Path, ellipse: \fI\%ConstructionEllipse\fP, segments=1, reset=True) -> None Add an elliptical arc as multiple cubic Bèzier\-curves to the given \fIpath\fP, use \fI\%from_arc()\fP constructor of class \fI\%ConstructionEllipse\fP to add circular arcs. .sp Auto\-detect the connection point to the given \fIpath\fP, if neither the start\- nor the end point of the ellipse is close to the path end point, a line from the path end point to the ellipse start point will be added automatically (see \fI\%add_bezier4p()\fP). .sp By default, the start of an \fBempty\fP path is set to the start point of the ellipse, setting argument \fIreset\fP to \fBFalse\fP prevents this behavior. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpath\fP – \fI\%Path\fP object .IP \(bu 2 \fBellipse\fP – ellipse parameters as \fI\%ConstructionEllipse\fP object .IP \(bu 2 \fBsegments\fP – count of Bèzier\-curve segments, at least one segment for each quarter (pi/2), \fB1\fP for as few as possible. .IP \(bu 2 \fBreset\fP – set start point to start of ellipse if path is empty .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.add_spline(path: Path, spline: \fI\%BSpline\fP, level=4, reset=True) -> None Add a B\-spline as multiple cubic Bèzier\-curves. .sp Non\-rational B\-splines of 3rd degree gets a perfect conversion to cubic Bézier curves with a minimal count of curve segments, all other B\-spline require much more curve segments for approximation. .sp Auto\-detect the connection point to the given \fIpath\fP, if neither the start\- nor the end point of the B\-spline is close to the path end point, a line from the path end point to the start point of the B\-spline will be added automatically. (see \fI\%add_bezier4p()\fP). .sp By default, the start of an \fBempty\fP path is set to the start point of the spline, setting argument \fIreset\fP to \fBFalse\fP prevents this behavior. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpath\fP – \fI\%Path\fP object .IP \(bu 2 \fBspline\fP – B\-spline parameters as \fI\%BSpline\fP object .IP \(bu 2 \fBlevel\fP – subdivision level of approximation segments .IP \(bu 2 \fBreset\fP – set start point to start of spline if path is empty .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.bbox(paths: Iterable[Path], *, fast=False) -> \fI\%BoundingBox\fP Returns the \fI\%BoundingBox\fP for the given paths. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP or \fBPath2d\fP objects .IP \(bu 2 \fBfast\fP – calculates the precise bounding box of Bèzier curves if \fBFalse\fP, otherwise uses the control points of Bézier curves to determine their bounding box. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.chamfer(points: Sequence[\fI\%Vec3\fP], length: float) -> Path Returns a \fI\%Path\fP with chamfers of given \fIlength\fP between straight line segments. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – coordinates of the line segments .IP \(bu 2 \fBlength\fP – chamfer length .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.chamfer2(points: Sequence[\fI\%Vec3\fP], a: float, b: float) -> Path Returns a \fI\%Path\fP with chamfers at the given distances \fIa\fP and \fIb\fP from the segment points between straight line segments. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – coordinates of the line segments .IP \(bu 2 \fBa\fP – distance of the chamfer start point to the segment point .IP \(bu 2 \fBb\fP – distance of the chamfer end point to the segment point .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.fillet(points: Sequence[\fI\%Vec3\fP], radius: float) -> Path Returns a \fI\%Path\fP with circular fillets of given \fIradius\fP between straight line segments. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – coordinates of the line segments .IP \(bu 2 \fBradius\fP – fillet radius .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.fit_paths_into_box(paths: Iterable[Path], size: tuple[float, float, float], uniform: bool = True, source_box: \fI\%BoundingBox\fP | None = None) -> list[Path] Scale the given \fIpaths\fP to fit into a box of the given \fIsize\fP, so that all path vertices are inside these borders. If \fIsource_box\fP is \fBNone\fP the default source bounding box is calculated from the control points of the \fIpaths\fP\&. .sp \fINote:\fP if the target size has a z\-size of 0, the \fIpaths\fP are projected into the xy\-plane, same is true for the x\-size, projects into the yz\-plane and the y\-size, projects into and xz\-plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP objects .IP \(bu 2 \fBsize\fP – target box size as tuple of x\-, y\- and z\-size values .IP \(bu 2 \fBuniform\fP – \fBTrue\fP for uniform scaling .IP \(bu 2 \fBsource_box\fP – pass precalculated source bounding box, or \fBNone\fP to calculate the default source bounding box from the control vertices .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.have_close_control_vertices(a: Path, b: Path, *, rel_tol=1e\-9, abs_tol=1e\-12) -> bool Returns \fBTrue\fP if the control vertices of given paths are close. .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.lines_to_curve3(path: Path) -> Path Replaces all lines by quadratic Bézier curves. Returns a new \fI\%Path\fP instance. .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.lines_to_curve4(path: Path) -> Path Replaces all lines by cubic Bézier curves. Returns a new \fI\%Path\fP instance. .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.polygonal_fillet(points: Sequence[\fI\%Vec3\fP], radius: float, count: int = 32) -> Path Returns a \fI\%Path\fP with polygonal fillets of given \fIradius\fP between straight line segments. The \fIcount\fP argument defines the vertex count of the fillet for a full circle. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – coordinates of the line segments .IP \(bu 2 \fBradius\fP – fillet radius .IP \(bu 2 \fBcount\fP – polygon vertex count for a full circle, minimum is 4 .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.single_paths(paths: Iterable[Path]) -> Iterable[Path] Yields all given paths and their sub\-paths as single path objects. .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.to_multi_path(paths: Iterable[Path]) -> Path Returns a multi\-path object from all given paths and their sub\-paths. Ignores paths without any commands (empty paths). .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.transform_paths(paths: Iterable[Path], m: \fI\%Matrix44\fP) -> list[Path] Transform multiple path objects at once by transformation matrix \fIm\fP\&. Returns a list of the transformed path objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP or \fBPath2d\fP objects .IP \(bu 2 \fBm\fP – transformation matrix of type \fI\%Matrix44\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.transform_paths_to_ocs(paths: Iterable[Path], ocs: \fI\%OCS\fP) -> list[Path] Transform multiple \fI\%Path\fP objects at once from WCS to OCS. Returns a list of the transformed \fI\%Path\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of \fI\%Path\fP or \fBPath2d\fP objects .IP \(bu 2 \fBocs\fP – OCS transformation of type \fI\%OCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.triangulate(paths: Iterable[Path], max_sagitta: float = 0.01, min_segments: int = 16) -> Iterator[Sequence[\fI\%Vec2\fP]] Tessellate nested 2D paths into triangle\-faces. For 3D paths the projection onto the xy\-plane will be triangulated. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpaths\fP – iterable of nested Path instances .IP \(bu 2 \fBmax_sagitta\fP – maximum distance from the center of the curve to the center of the line segment between two approximation points to determine if a segment should be subdivided. .IP \(bu 2 \fBmin_segments\fP – minimum segment count per Bézier curve .UNINDENT .UNINDENT .UNINDENT .SS Basic Shapes .INDENT 0.0 .TP .B ezdxf.path.elliptic_transformation(center: \fI\%UVec\fP = (0, 0, 0), radius: float = 1, ratio: float = 1, rotation: float = 0) -> \fI\%Matrix44\fP Returns the transformation matrix to transform a unit circle into an arbitrary circular\- or elliptic arc. .sp Example how to create an ellipse with a major axis length of 3, a minor axis length 1.5 and rotated about 90°: .INDENT 7.0 .INDENT 3.5 .sp .EX m = elliptic_transformation(radius=3, ratio=0.5, rotation=math.pi / 2) ellipse = shapes.unit_circle(transform=m) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – curve center in WCS .IP \(bu 2 \fBradius\fP – radius of the major axis in drawing units .IP \(bu 2 \fBratio\fP – ratio of minor axis to major axis .IP \(bu 2 \fBrotation\fP – rotation angle about the z\-axis in radians .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.gear(count: int, top_width: float, bottom_width: float, height: float, outside_radius: float, transform: \fI\%Matrix44\fP = None) -> Path Returns a \fI\%gear\fP (cogwheel) shape as a \fI\%Path\fP object, with the center at (0, 0, 0). The base geometry is created by function \fI\%ezdxf.render.forms.gear()\fP\&. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 This function does not create correct gears for mechanical engineering! .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – teeth count >= 3 .IP \(bu 2 \fBtop_width\fP – teeth width at outside radius .IP \(bu 2 \fBbottom_width\fP – teeth width at base radius .IP \(bu 2 \fBheight\fP – teeth height; base radius = outside radius \- height .IP \(bu 2 \fBoutside_radius\fP – outside radius .IP \(bu 2 \fBtransform\fP – transformation Matrix applied to the gear shape .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.helix(radius: float, pitch: float, turns: float, ccw=True, segments: int = 4) -> Path Returns a \fI\%helix\fP as a \fI\%Path\fP object. The center of the helix is always (0, 0, 0), a positive \fIpitch\fP value creates a helix along the +z\-axis, a negative value along the \-z\-axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP – helix radius .IP \(bu 2 \fBpitch\fP – the height of one complete helix turn .IP \(bu 2 \fBturns\fP – count of turns .IP \(bu 2 \fBccw\fP – creates a counter\-clockwise turning (right\-handed) helix if \fBTrue\fP .IP \(bu 2 \fBsegments\fP – cubic Bezier segments per turn .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.ngon(count: int, length: float | None = None, radius: float = 1.0, transform: \fI\%Matrix44\fP | None = None) -> Path Returns a \fI\%regular polygon\fP a \fI\%Path\fP object, with the center at (0, 0, 0). The polygon size is determined by the edge \fIlength\fP or the circum \fIradius\fP argument. If both are given \fIlength\fP has higher priority. Default size is a \fIradius\fP of 1. The ngon starts with the first vertex is on the x\-axis! The base geometry is created by function \fI\%ezdxf.render.forms.ngon()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of polygon corners >= 3 .IP \(bu 2 \fBlength\fP – length of polygon side .IP \(bu 2 \fBradius\fP – circum radius, default is 1 .IP \(bu 2 \fBtransform\fP – transformation Matrix applied to the ngon .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.rect(width: float = 1, height: float = 1, transform: \fI\%Matrix44\fP = None) -> Path Returns a closed rectangle as a \fI\%Path\fP object, with the center at (0, 0, 0) and the given \fIwidth\fP and \fIheight\fP in drawing units. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBwidth\fP – width of the rectangle in drawing units, width > 0 .IP \(bu 2 \fBheight\fP – height of the rectangle in drawing units, height > 0 .IP \(bu 2 \fBtransform\fP – transformation Matrix applied to the rectangle .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.star(count: int, r1: float, r2: float, transform: \fI\%Matrix44\fP = None) -> Path Returns a \fI\%star shape\fP as a \fI\%Path\fP object, with the center at (0, 0, 0). .sp Argument \fIcount\fP defines the count of star spikes, \fIr1\fP defines the radius of the “outer” vertices and \fIr2\fP defines the radius of the “inner” vertices, but this does not mean that \fIr1\fP has to be greater than \fIr2\fP\&. The star shape starts with the first vertex is on the x\-axis! The base geometry is created by function \fI\%ezdxf.render.forms.star()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – spike count >= 3 .IP \(bu 2 \fBr1\fP – radius 1 .IP \(bu 2 \fBr2\fP – radius 2 .IP \(bu 2 \fBtransform\fP – transformation Matrix applied to the star .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.unit_circle(start_angle: float = 0, end_angle: float = math.tau, segments: int = 1, transform: \fI\%Matrix44\fP = None) -> Path Returns a unit circle as a \fI\%Path\fP object, with the center at (0, 0, 0) and the radius of 1 drawing unit. .sp The arc spans from the start\- to the end angle in counter\-clockwise orientation. The end angle has to be greater than the start angle and the angle span has to be greater than 0. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_angle\fP – start angle in radians .IP \(bu 2 \fBend_angle\fP – end angle in radians (end_angle > start_angle!) .IP \(bu 2 \fBsegments\fP – count of Bèzier\-curve segments, default is one segment for each arc quarter (π/2) .IP \(bu 2 \fBtransform\fP – transformation Matrix applied to the unit circle .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.path.wedge(start_angle: float, end_angle: float, segments: int = 1, transform: \fI\%Matrix44\fP = None) -> Path Returns a wedge as a \fI\%Path\fP object, with the center at (0, 0, 0) and the radius of 1 drawing unit. .sp The arc spans from the start\- to the end angle in counter\-clockwise orientation. The end angle has to be greater than the start angle and the angle span has to be greater than 0. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart_angle\fP – start angle in radians .IP \(bu 2 \fBend_angle\fP – end angle in radians (end_angle > start_angle!) .IP \(bu 2 \fBsegments\fP – count of Bèzier\-curve segments, default is one segment for each arc quarter (π/2) .IP \(bu 2 \fBtransform\fP – transformation Matrix applied to the wedge .UNINDENT .UNINDENT .UNINDENT .sp The \fI\%text2path\fP add\-on provides additional functions to create paths from text strings and DXF text entities. .SS The Path Class .INDENT 0.0 .TP .B class ezdxf.path.Path .INDENT 7.0 .TP .B property end: \fI\%Vec3\fP \fI\%Path\fP end point. .UNINDENT .INDENT 7.0 .TP .B property has_curves: bool Returns \fBTrue\fP if the path has any curve segments. .UNINDENT .INDENT 7.0 .TP .B property has_lines: bool Returns \fBTrue\fP if the path has any line segments. .UNINDENT .INDENT 7.0 .TP .B property has_sub_paths: bool Returns \fBTrue\fP if the path is a \fI\%Multi\-Path\fP object that contains multiple sub\-paths. .UNINDENT .INDENT 7.0 .TP .B property is_closed: bool Returns \fBTrue\fP if the start point is close to the end point. .UNINDENT .INDENT 7.0 .TP .B property start: \fI\%Vec3\fP \fI\%Path\fP start point, resetting the start point of an empty path is possible. .UNINDENT .INDENT 7.0 .TP .B property user_data: Any Attach arbitrary user data to a \fI\%Path\fP object. The user data is copied by reference, no deep copy is applied therefore a mutable state is shared between copies. .UNINDENT .INDENT 7.0 .TP .B append_path(path: Path) -> None Append another path to this path. Adds a \fBself.line_to(path.start)\fP if the end of this path != the start of appended path. .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int = 20) -> Iterator[\fI\%Vec3\fP] Approximate path by vertices, \fIsegments\fP is the count of approximation segments for each Bézier curve. .sp Does not yield any vertices for empty paths, where only a start point is present! .sp Approximation of \fI\%Multi\-Path\fP objects is possible, but gaps are indistinguishable from line segments. .UNINDENT .INDENT 7.0 .TP .B bbox() -> \fI\%BoundingBox\fP Returns the bounding box of all control vertices as \fI\%BoundingBox\fP instance. .UNINDENT .INDENT 7.0 .TP .B clockwise() -> Self Returns new \fI\%Path\fP in clockwise orientation. .INDENT 7.0 .TP .B Raises \fBTypeError\fP – can’t detect orientation of a \fI\%Multi\-Path\fP object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B clone() -> Self Returns a new copy of \fI\%Path\fP with shared immutable data. .UNINDENT .INDENT 7.0 .TP .B close() -> None Close path by adding a line segment from the end point to the start point. .UNINDENT .INDENT 7.0 .TP .B close_sub_path() -> None Close last sub\-path by adding a line segment from the end point to the start point of the last sub\-path. Behaves like \fI\%close()\fP for \fI\%Single\-Path\fP instances. .UNINDENT .INDENT 7.0 .TP .B control_vertices() -> list[\fI\%Vec3\fP] Yields all path control vertices in consecutive order. .UNINDENT .INDENT 7.0 .TP .B counter_clockwise() -> Self Returns new \fI\%Path\fP in counter\-clockwise orientation. .INDENT 7.0 .TP .B Raises \fBTypeError\fP – can’t detect orientation of a \fI\%Multi\-Path\fP object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B curve3_to(location: \fI\%UVec\fP, ctrl: \fI\%UVec\fP) -> None Add a quadratic Bèzier\-curve from actual path end point to \fIlocation\fP, \fIctrl\fP is the control point for the quadratic Bèzier\-curve. .UNINDENT .INDENT 7.0 .TP .B curve4_to(location: \fI\%UVec\fP, ctrl1: \fI\%UVec\fP, ctrl2: \fI\%UVec\fP) -> None Add a cubic Bèzier\-curve from actual path end point to \fIlocation\fP, \fIctrl1\fP and \fIctrl2\fP are the control points for the cubic Bèzier\-curve. .UNINDENT .INDENT 7.0 .TP .B extend_multi_path(path: Path) -> None Extend the path by another path. The source path is automatically a \fI\%Multi\-Path\fP object, even if the previous end point matches the start point of the appended path. Ignores paths without any commands (empty paths). .UNINDENT .INDENT 7.0 .TP .B flattening(distance: float, segments: int = 4) -> Iterator[\fI\%Vec3\fP] Approximate path by vertices and use adaptive recursive flattening to approximate Bèzier curves. The argument \fIsegments\fP is the minimum count of approximation segments for each curve, if the distance from the center of the approximation segment to the curve is bigger than \fIdistance\fP the segment will be subdivided. .sp Does not yield any vertices for empty paths, where only a start point is present! .sp Flattening of \fI\%Multi\-Path\fP objects is possible, but gaps are indistinguishable from line segments. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdistance\fP – maximum distance from the center of the curve to the center of the line segment between two approximation points to determine if a segment should be subdivided. .IP \(bu 2 \fBsegments\fP – minimum segment count per Bézier curve .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_clockwise_orientation() -> bool Returns \fBTrue\fP if 2D path has clockwise orientation, ignores z\-axis of all control vertices. .INDENT 7.0 .TP .B Raises \fBTypeError\fP – can’t detect orientation of a \fI\%Multi\-Path\fP object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B line_to(location: \fI\%UVec\fP) -> None Add a line from actual path end point to \fIlocation\fP\&. .UNINDENT .INDENT 7.0 .TP .B move_to(location: \fI\%UVec\fP) -> None Start a new sub\-path at \fIlocation\fP\&. This creates a gap between the current end\-point and the start\-point of the new sub\-path. This converts the instance into a \fI\%Multi\-Path\fP object. .sp If the \fI\%move_to()\fP command is the first command, the start point of the path will be reset to \fIlocation\fP\&. .UNINDENT .INDENT 7.0 .TP .B reversed() -> Self Returns a new \fI\%Path\fP with reversed commands and control vertices. .UNINDENT .INDENT 7.0 .TP .B sub_paths() -> Iterator[Self] Yield all sub\-paths as \fI\%Single\-Path\fP objects. .sp It’s safe to call \fI\%sub_paths()\fP on any path\-type: \fI\%Single\-Path\fP, \fI\%Multi\-Path\fP and \fI\%Empty\-Path\fP\&. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> Self Returns a new transformed path. .INDENT 7.0 .TP .B Parameters \fBm\fP – transformation matrix of type \fI\%Matrix44\fP .UNINDENT .UNINDENT .UNINDENT .SS Disassemble .sp This module provide tools for the recursive decomposition of nested block reference structures into a flat stream of DXF entities and converting DXF entities into geometric primitives of \fI\%Path\fP and \fBMeshBuilder\fP objects encapsulated into intermediate \fI\%Primitive\fP classes. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Do not expect advanced vectorization capabilities: Text entities like TEXT, ATTRIB, ATTDEF and MTEXT get only a rough border box representation. The \fI\%text2path\fP add\-on can convert text into paths. VIEWPORT, IMAGE and WIPEOUT are represented by their clipping path. Unsupported entities: all ACIS based entities, XREF, UNDERLAY, ACAD_TABLE, RAY, XLINE. Unsupported entities will be ignored. .UNINDENT .UNINDENT .SS Text Boundary Calculation .sp Text boundary calculations are based on monospaced (fixed\-pitch, fixed\-width, non\-proportional) font metrics, which do not provide a good accuracy for text height calculation and much less accuracy for text width calculation. It is possible to improve this results by using the font support from the \fBoptional\fP \fIMatplotlib\fP package. .sp Install Matplotlib from command line: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> pip3 install matplotlib .EE .UNINDENT .UNINDENT .sp The \fIMatplotlib\fP font support will improve the results for TEXT, ATTRIB and ATTDEF. The MTEXT entity has many advanced features which would require a full “Rich Text Format” rendering and that is far beyond the goals and capabilities of this library, therefore the boundary box for MTEXT will \fBnever\fP be as accurate as in a dedicated CAD application. .sp Using the \fIMatplotlib\fP font support adds \fBruntime overhead\fP, therefore it is possible to deactivate the \fIMatplotlib\fP font support by setting the global option: .INDENT 0.0 .INDENT 3.5 .sp .EX options.use_matplotlib_font_support = False .EE .UNINDENT .UNINDENT .SS Flatten Complex DXF Entities .INDENT 0.0 .TP .B ezdxf.disassemble.recursive_decompose(entities: Iterable[DXFEntity]) -> Iterable[DXFEntity] Recursive decomposition of the given DXF entity collection into a flat stream of DXF entities. All block references (INSERT) and entities which provide a \fBvirtual_entities()\fP method will be disassembled into simple DXF sub\-entities, therefore the returned entity stream does not contain any INSERT entity. .sp Point entities will \fBnot\fP be disassembled into DXF sub\-entities, as defined by the current point style $PDMODE. .sp These entity types include sub\-entities and will be decomposed into simple DXF entities: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 INSERT .IP \(bu 2 DIMENSION .IP \(bu 2 LEADER .IP \(bu 2 MLEADER .IP \(bu 2 MLINE .UNINDENT .UNINDENT .UNINDENT .sp Decomposition of XREF, UNDERLAY and ACAD_TABLE entities is not supported. .UNINDENT .SS Entity Deconstruction .sp These functions disassemble DXF entities into simple geometric objects like meshes, paths or vertices. The \fI\%Primitive\fP is a simplified intermediate class to use a common interface on various DXF entities. .INDENT 0.0 .TP .B ezdxf.disassemble.make_primitive(entity: DXFEntity, max_flattening_distance=None) -> \fI\%Primitive\fP Factory to create path/mesh primitives. The \fImax_flattening_distance\fP defines the max distance between the approximation line and the original curve. Use \fImax_flattening_distance\fP to override the default value. .sp Returns an \fBempty primitive\fP for unsupported entities. The \fIempty\fP state of a primitive can be checked by the property \fBis_empty\fP\&. The \fBpath\fP and the \fBmesh\fP attributes of an empty primitive are \fBNone\fP and the \fBvertices()\fP method yields no vertices. .UNINDENT .INDENT 0.0 .TP .B ezdxf.disassemble.to_primitives(entities: Iterable[DXFEntity], max_flattening_distance: float | None = None) -> Iterable[\fI\%Primitive\fP] Yields all DXF entities as path or mesh primitives. Yields unsupported entities as empty primitives, see \fI\%make_primitive()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentities\fP – iterable of DXF entities .IP \(bu 2 \fBmax_flattening_distance\fP – override the default value .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.disassemble.to_meshes(primitives: Iterable[\fI\%Primitive\fP]) -> Iterable[MeshBuilder] Yields all \fI\%MeshBuilder\fP objects from the given \fIprimitives\fP\&. Ignores primitives without a defined mesh. .UNINDENT .INDENT 0.0 .TP .B ezdxf.disassemble.to_paths(primitives: Iterable[\fI\%Primitive\fP]) -> Iterable[Path] Yields all \fI\%Path\fP objects from the given \fIprimitives\fP\&. Ignores primitives without a defined path. .UNINDENT .INDENT 0.0 .TP .B ezdxf.disassemble.to_vertices(primitives: Iterable[\fI\%Primitive\fP]) -> Iterable[\fI\%Vec3\fP] Yields all vertices from the given \fIprimitives\fP\&. Paths will be flattened to create the associated vertices. See also \fI\%to_control_vertices()\fP to collect only the control vertices from the paths without flattening. .UNINDENT .INDENT 0.0 .TP .B ezdxf.disassemble.to_control_vertices(primitives: Iterable[\fI\%Primitive\fP]) -> Iterable[\fI\%Vec3\fP] Yields all path control vertices and all mesh vertices from the given \fIprimitives\fP\&. Like \fI\%to_vertices()\fP, but without flattening. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.disassemble.Primitive Interface class for path/mesh primitives. .INDENT 7.0 .TP .B entity .UNINDENT .sp Reference to the source DXF entity of this primitive. .INDENT 7.0 .TP .B max_flattening_distance .UNINDENT .sp The \fImax_flattening_distance\fP attribute defines the max distance in drawing units between the approximation line and the original curve. Set the value by direct attribute access. (float) default = 0.01 .INDENT 7.0 .TP .B property path: Path | None \fI\%Path\fP representation or \fBNone\fP, idiom to check if is a path representation (could be empty): .INDENT 7.0 .INDENT 3.5 .sp .EX if primitive.path is not None: process(primitive.path) .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property mesh: MeshBuilder | None \fBMeshBuilder\fP representation or \fBNone\fP, idiom to check if is a mesh representation (could be empty): .INDENT 7.0 .INDENT 3.5 .sp .EX if primitive.mesh is not None: process(primitive.mesh) .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property is_empty: bool Returns \fITrue\fP if represents an empty primitive which do not yield any vertices. .UNINDENT .INDENT 7.0 .TP .B abstract vertices() -> Iterable[\fI\%Vec3\fP] Yields all vertices of the path/mesh representation as \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B bbox(fast=False) -> \fI\%BoundingBox\fP Returns the \fI\%BoundingBox\fP of the path/mesh representation. Returns the precise bounding box for the path representation if \fIfast\fP is \fBFalse\fP, otherwise the bounding box for Bézier curves is based on their control points. .UNINDENT .UNINDENT .SS Bounding Box .sp The \fI\%ezdxf.bbox\fP module provide tools to calculate bounding boxes for many DXF entities, but not for all. The bounding box calculation is based on the \fI\%ezdxf.disassemble\fP module and therefore has the same limitation. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 If accurate boundary boxes for text entities are important for you, read this first: \fI\%Text Boundary Calculation\fP\&. TL;DR: Boundary boxes for text entities are \fBnot accurate!\fP .UNINDENT .UNINDENT .sp Unsupported DXF entities: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 All ACIS based types like BODY, 3DSOLID or REGION .IP \(bu 2 External references (XREF) and UNDERLAY object .IP \(bu 2 RAY and XRAY, extend into infinite .IP \(bu 2 ACAD_TABLE, no basic support \- only preserved by \fIezdxf\fP .UNINDENT .UNINDENT .UNINDENT .sp Unsupported entities are silently ignored, filtering of these DXF types is not necessary. .sp The base type for bounding boxes is the \fI\%BoundingBox\fP class from the module \fI\%ezdxf.math\fP\&. .sp The \fIentities\fP iterable as input can be the whole modelspace, an entity query or any iterable container of DXF entities. .sp The Calculation of bounding boxes of curves is done by flattening the curve by a default flattening distance of 0.01. Set argument \fIflatten\fP to 0 to speedup the bounding box calculation by accepting less precision for curved objects by using only the control vertices. .sp The \fBoptional\fP caching object \fI\%Cache\fP has to be instantiated by the user, this is only useful if the same entities will be processed multiple times. .sp Example usage with caching: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf import bbox msp = doc.modelspace() cache = bbox.Cache() # get overall bounding box first_bbox = bbox.extents(msp, cache=cache) # bounding box of all LINE entities second_bbox = bbox.extend(msp.query(\(dqLINE\(dq), cache=cache) .EE .UNINDENT .UNINDENT .SS Functions .INDENT 0.0 .TP .B ezdxf.bbox.extents(entities: Iterable[\fI\%DXFEntity\fP], *, fast=False, cache: \fI\%Cache\fP | None = None) -> \fI\%BoundingBox\fP Returns a single bounding box for all given \fIentities\fP\&. .sp If argument \fIfast\fP is \fBTrue\fP the calculation of Bézier curves is based on their control points, this may return a slightly larger bounding box. .UNINDENT .INDENT 0.0 .TP .B ezdxf.bbox.multi_flat(entities: Iterable[\fI\%DXFEntity\fP], *, fast=False, cache: \fI\%Cache\fP | None = None) -> Iterable[\fI\%BoundingBox\fP] Yields a bounding box for each of the given \fIentities\fP\&. .sp If argument \fIfast\fP is \fBTrue\fP the calculation of Bézier curves is based on their control points, this may return a slightly larger bounding box. .UNINDENT .INDENT 0.0 .TP .B ezdxf.bbox.multi_recursive(entities: Iterable[\fI\%DXFEntity\fP], *, fast=False, cache: \fI\%Cache\fP | None = None) -> Iterable[\fI\%BoundingBox\fP] Yields all bounding boxes for the given \fIentities\fP \fBor\fP all bounding boxes for their sub entities. If an entity (INSERT) has sub entities, only the bounding boxes of these sub entities will be yielded, \fBnot\fP the bounding box of the entity (INSERT) itself. .sp If argument \fIfast\fP is \fBTrue\fP the calculation of Bézier curves is based on their control points, this may return a slightly larger bounding box. .UNINDENT .SS Caching Strategies .sp Because \fIezdxf\fP is not a CAD application, \fIezdxf\fP does not manage data structures which are optimized for a usage by a CAD kernel. This means that the content of complex entities like block references or leaders has to be created on demand by DXF primitives on the fly. These temporarily created entities are called virtual entities and have no handle and are not stored in the entity database. .sp All this is required to calculate the bounding box of complex entities, and it is therefore a very time consuming task. By using a \fI\%Cache\fP object it is possible to speedup this calculations, but this is not a magically feature, it requires an understanding of what is happening under the hood to achieve any performance gains. .sp For a single bounding box calculation, without any reuse of entities it makes no sense of using a \fI\%Cache\fP object, e.g. calculation of the modelspace extents: .INDENT 0.0 .INDENT 3.5 .sp .EX from pathlib import Path import ezdxf from ezdxf import bbox CADKitSamples = Path(ezdxf.EZDXF_TEST_FILES) / \(aqCADKitSamples\(aq doc = ezdxf.readfile(CADKitSamples / \(aqA_000217.dxf\(aq) cache = bbox.Cache() ext = bbox.extents(doc.modelspace(), cache) print(cache) .EE .UNINDENT .UNINDENT .sp 1226 cached objects and not a single cache hit: .INDENT 0.0 .INDENT 3.5 .sp .EX Cache(n=1226, hits=0, misses=3273) .EE .UNINDENT .UNINDENT .sp The result for using UUIDs to cache virtual entities is not better: .INDENT 0.0 .INDENT 3.5 .sp .EX Cache(n=2206, hits=0, misses=3273) .EE .UNINDENT .UNINDENT .sp Same count of hits and misses, but now the cache also references ~1000 virtual entities, which block your memory until the cache is deleted, luckily this is a small DXF file (~838 kB). .sp Bounding box calculations for multiple entity queries, which have overlapping entity results, using a \fI\%Cache\fP object may speedup the calculation: .INDENT 0.0 .INDENT 3.5 .sp .EX doc = ezdxf.readfile(CADKitSamples / \(aqA_000217.dxf.dxf\(aq) msp = doc.modelspace() cache = bbox.Cache(uuid=False) ext = bbox.extents(msp, cache) print(cache) # process modelspace again ext = bbox.extents(msp, cache) print(cache) .EE .UNINDENT .UNINDENT .sp Processing the same data again leads some hits: .INDENT 0.0 .INDENT 3.5 .sp .EX 1st run: Cache(n=1226, hits=0, misses=3273) 2nd run: Cache(n=1226, hits=1224, misses=3309) .EE .UNINDENT .UNINDENT .sp Using \fBuuid=True\fP leads not to more hits, but more cache entries: .INDENT 0.0 .INDENT 3.5 .sp .EX 1st run: Cache(n=2206, hits=0, misses=3273) 2nd run: Cache(n=2206, hits=1224, misses=3309) .EE .UNINDENT .UNINDENT .sp Creating stable virtual entities by disassembling the entities at first leads to more hits: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf import disassemble entities = list(disassemble.recursive_decompose(msp)) cache = bbox.Cache(uuid=False) bbox.extents(entities, cache) print(cache) bbox.extents(entities, cache) print(cache) .EE .UNINDENT .UNINDENT .sp First without UUID for stable virtual entities: .INDENT 0.0 .INDENT 3.5 .sp .EX 1st run: Cache(n=1037, hits=0, misses=4074) 2nd run: Cache(n=1037, hits=1037, misses=6078) .EE .UNINDENT .UNINDENT .sp Using UUID for stable virtual entities leads to more hits: .INDENT 0.0 .INDENT 3.5 .sp .EX 1st run: Cache(n=2019, hits=0, misses=4074) 2nd run: Cache(n=2019, hits=2018, misses=4116) .EE .UNINDENT .UNINDENT .sp But caching virtual entities needs also more memory. .sp In conclusion: Using a cache is only useful, if you often process \fBnearly the same data\fP; only then can an increase in performance be expected. .SS Cache Class .INDENT 0.0 .TP .B class ezdxf.bbox.Cache(uuid=False) Caching object for \fI\%ezdxf.math.BoundingBox\fP objects. .INDENT 7.0 .TP .B Parameters \fBuuid\fP – use UUIDs for virtual entities .UNINDENT .INDENT 7.0 .TP .B has_data \fBTrue\fP if the cache contains any bounding boxes .UNINDENT .INDENT 7.0 .TP .B hits .UNINDENT .INDENT 7.0 .TP .B misses .UNINDENT .INDENT 7.0 .TP .B invalidate(entities: Iterable[\fI\%DXFEntity\fP]) -> None Invalidate cache entries for the given DXF \fIentities\fP\&. .sp If entities are changed by the user, it is possible to invalidate individual entities. Use with care \- discarding the whole cache is the safer workflow. .sp Ignores entities which are not stored in cache. .UNINDENT .UNINDENT .SS Upright .sp The functions in this module can help to convert an inverted \fI\%OCS\fP defined by an extrusion vector (0, 0, \-1) into a \fI\%WCS\fP aligned OCS defined by an extrusion vector (0, 0, 1). .sp This simplifies 2D entity processing for \fIezdxf\fP users and creates DXF output for 3rd party DXF libraries which ignore the existence of the \fI\%OCS\fP\&. .sp Supported DXF entities: .INDENT 0.0 .IP \(bu 2 CIRCLE .IP \(bu 2 ARC .IP \(bu 2 ELLIPSE (WCS entity, flips only the extrusion vector) .IP \(bu 2 SOLID .IP \(bu 2 TRACE .IP \(bu 2 LWPOLYLINE .IP \(bu 2 POLYLINE (only 2D entities) .IP \(bu 2 HATCH .IP \(bu 2 MPOLYGON .IP \(bu 2 INSERT (block references) .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The WCS representation of OCS entities with flipped extrusion vector is not 100% identical to the source entity, curve orientation and vertex order may change, see \fI\%additional explanation\fP below. A mirrored text represented by an extrusion vector (0, 0, \-1) cannot represented by an extrusion vector (0, 0, 1), therefore this CANNOT work for text entities or entities including text: TEXT, ATTRIB, ATTDEF, MTEXT, DIMENSION, LEADER, MLEADER .UNINDENT .UNINDENT .SS Usage .sp The functions can be applied to any DXF entity without expecting errors or exceptions if the DXF entity is not supported or the extrusion vector differs from (0, 0, \-1). This also means you can apply the functions multiple times to the same entities without any problems. A common case would be to upright all entities of the model space: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.upright import upright_all doc = ezdxf.readfile(\(dqyour.dxf\(dq) msp = doc.modelspace() upright_all(msp) # doing it again is no problem but also has no further effects upright_all(msp) .EE .UNINDENT .UNINDENT .sp Another use case is exploding block references (INSERT) which may include reflections (= scaling by negative factors) that can lead to inverted extrusion vectors. .INDENT 0.0 .INDENT 3.5 .sp .EX for block_ref in msp.query(\(dqINSERT\(dq): entities = block_ref.explode() # \-> EntityQuery object upright_all(entities) .EE .UNINDENT .UNINDENT .SS Functions .INDENT 0.0 .TP .B ezdxf.upright.upright(entity: DXFGraphic) -> None Flips an inverted \fI\%OCS\fP defined by extrusion vector (0, 0, \-1) into a \fI\%WCS\fP aligned \fI\%OCS\fP defined by extrusion vector (0, 0, 1). DXF entities with other extrusion vectors and unsupported DXF entities will be silently ignored. For more information about the limitations read the documentation of the \fI\%ezdxf.upright\fP module. .UNINDENT .INDENT 0.0 .TP .B ezdxf.upright.upright_all(entities: Iterable[DXFGraphic]) -> None Call function \fI\%upright()\fP for all DXF entities in iterable \fIentities\fP: .INDENT 7.0 .INDENT 3.5 .sp .EX upright_all(doc.modelspace()) .EE .UNINDENT .UNINDENT .UNINDENT .SS Additional Explanation .sp This example shows why the entities with an inverted OCS, extrusion vector is (0, 0, \-1), are not exact the same as with an WCS aligned OCS, extrusion vector is (0, 0, 1). .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The ARC entity represents the curve \fBalways\fP in counter\-clockwise orientation around the extrusion vector. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.upright import upright from ezdxf.math import Matrix44 doc = ezdxf.new() msp = doc.modelspace() arc = msp.add_arc( (5, 0), radius=5, start_angle=\-90, end_angle=90, dxfattribs={\(dqcolor\(dq: ezdxf.const.RED}, ) # draw lines to the start\- and end point of the ARC msp.add_line((0, 0), arc.start_point, dxfattribs={\(dqcolor\(dq: ezdxf.const.GREEN}) msp.add_line((0, 0), arc.end_point, dxfattribs={\(dqcolor\(dq: ezdxf.const.BLUE}) # copy arc mirrored_arc = arc.copy() msp.add_entity(mirrored_arc) # mirror copy mirrored_arc.transform(Matrix44.scale(\-1, 1, 1)) # This creates an inverted extrusion vector: assert mirrored_arc.dxf.extrusion.isclose((0, 0, \-1)) # draw lines to the start\- and end point of the mirrored ARC msp.add_line((0, 0), mirrored_arc.start_point, dxfattribs={\(dqcolor\(dq: ezdxf.const.GREEN}) msp.add_line((0, 0), mirrored_arc.end_point, dxfattribs={\(dqcolor\(dq: ezdxf.const.BLUE}) .EE .UNINDENT .UNINDENT .sp Result without applying the \fI\%upright()\fP function \- true mirroring: [image] .INDENT 0.0 .INDENT 3.5 .sp .EX \&... # This creates an inverted extrusion vector: assert mirrored_arc.dxf.extrusion.isclose((0, 0, \-1)) start_point_inv = mirrored_arc.start_point end_point_inv = mirrored_arc.end_point upright(mirrored_arc) # OCS is aligned with WCS: assert mirrored_arc.dxf.extrusion.isclose((0, 0, 1)) # start\- and end points are swapped after applying upright() assert mirrored_arc.start_point.isclose(end_point_inv) assert mirrored_arc.end_point.isclose(start_point_inv) # draw lines to the start\- and end point of the mirrored ARC msp.add_line((0, 0), mirrored_arc.start_point, dxfattribs={\(dqcolor\(dq: ezdxf.const.GREEN}) msp.add_line((0, 0), mirrored_arc.end_point, dxfattribs={\(dqcolor\(dq: ezdxf.const.BLUE}) .EE .UNINDENT .UNINDENT .sp Result after applying the \fI\%upright()\fP function \- false mirroring: [image] .sp To avoid this issue the ARC entity would have to represent the curve in clockwise orientation around the extrusion vector (0, 0, 1), which is not possible! .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The shape of the mirrored arcs is the same for both extrusion vectors, but the start\- and the end points are swapped (reversed vertex order)! .UNINDENT .UNINDENT .SS Reorder .sp Tools to reorder DXF entities by handle or a special sort handle mapping. .sp Such reorder mappings are stored only in layouts as \fI\%Modelspace\fP, \fI\%Paperspace\fP or \fI\%BlockLayout\fP, and can be retrieved by the method \fBget_redraw_order()\fP\&. .sp Each entry in the handle mapping replaces the actual entity handle, where the “0” handle has a special meaning, this handle always shows up at last in ascending ordering. .INDENT 0.0 .TP .B ezdxf.reorder.ascending(entities: Iterable[\fI\%DXFGraphic\fP], mapping: dict | Iterable[tuple[str, str]] | None = None) -> Iterable[\fI\%DXFGraphic\fP] Yields entities in ascending handle order. .sp The sort\-handle doesn’t have to be the entity handle, every entity handle in \fImapping\fP will be replaced by the given sort\-handle, \fImapping\fP is an iterable of 2\-tuples (entity_handle, sort_handle) or a dict (entity_handle, sort_handle). Entities with equal sort\-handles show up in source entities order. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentities\fP – iterable of \fBDXFGraphic\fP objects .IP \(bu 2 \fBmapping\fP – iterable of 2\-tuples (entity_handle, sort_handle) or a handle mapping as dict. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.reorder.descending(entities: Iterable[\fI\%DXFGraphic\fP], mapping: dict | Iterable[tuple[str, str]] | None = None) -> Iterable[\fI\%DXFGraphic\fP] Yields entities in descending handle order. .sp The sort\-handle doesn’t have to be the entity handle, every entity handle in \fImapping\fP will be replaced by the given sort\-handle, \fImapping\fP is an iterable of 2\-tuples (entity_handle, sort_handle) or a dict (entity_handle, sort_handle). Entities with equal sort\-handles show up in reversed source entities order. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentities\fP – iterable of \fBDXFGraphic\fP objects .IP \(bu 2 \fBmapping\fP – iterable of 2\-tuples (entity_handle, sort_handle) or a handle mapping as dict. .UNINDENT .UNINDENT .UNINDENT .SS Transform .sp New in version 1.1. .sp This module provides functions to apply transformations to multiple DXF entities inplace or to virtual copies of that entities in a convenient and safe way: .INDENT 0.0 .INDENT 3.5 .sp .EX import math import ezdxf from ezdxf import transform doc = ezdxf.readfile(\(dqmy.dxf\(dq) msp = doc.modelspace() log = transform.inplace(msp, m=transform.Matrix44.rotate_z(math.pi/2)) # or more simple log = transform.z_rotate(msp, math.pi/2) .EE .UNINDENT .UNINDENT .sp All functions handle errors by collecting them in an logging object without raising an error. The input \fIentities\fP are an iterable of \fI\%DXFEntity\fP, which can be any layout, \fI\%EntityQuery\fP or just a list/sequence of entities and virtual entities are supported as well. .TS center; |l|l|. _ T{ \fI\%inplace\fP T} T{ Transforms the given \fIentities\fP inplace by the transformation matrix \fIm\fP, non\-uniform scaling is supported. T} _ T{ \fI\%copies\fP T} T{ Copy entities and transform them by matrix \fIm\fP\&. T} _ T{ \fI\%translate\fP T} T{ Translates (moves) \fIentities\fP inplace by the \fIoffset\fP vector. T} _ T{ \fI\%scale_uniform\fP T} T{ Scales \fIentities\fP inplace by a \fIfactor\fP in all axis. T} _ T{ \fI\%scale\fP T} T{ Scales \fIentities\fP inplace by the factors \fIsx\fP in x\-axis, \fIsy\fP in y\-axis and \fIsz\fP in z\-axis. T} _ T{ \fI\%x_rotate\fP T} T{ Rotates \fIentities\fP inplace by \fIangle\fP in radians about the x\-axis. T} _ T{ \fI\%y_rotate\fP T} T{ Rotates \fIentities\fP inplace by \fIangle\fP in radians about the y\-axis. T} _ T{ \fI\%z_rotate\fP T} T{ Rotates \fIentities\fP inplace by \fIangle\fP in radians about the x\-axis. T} _ T{ \fI\%axis_rotate\fP T} T{ Rotates \fIentities\fP inplace by \fIangle\fP in radians about the rotation axis starting at the origin pointing in \fIaxis\fP direction. T} _ .TE .INDENT 0.0 .TP .B ezdxf.transform.inplace(entities: Iterable[DXFEntity], m: \fI\%Matrix44\fP) -> \fI\%Logger\fP Transforms the given \fIentities\fP inplace by the transformation matrix \fIm\fP, non\-uniform scaling is supported. The function converts circular arcs into ellipses to perform non\-uniform scaling. The function logs errors and does not raise errors for unsupported entities or transformation errors, see enum \fI\%Error\fP\&. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 The \fI\%inplace()\fP function does not support type conversion for virtual entities e.g. non\-uniform scaling for CIRCLE, ARC or POLYLINE with bulges, see also function \fI\%copies()\fP\&. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.copies(entities: Iterable[DXFEntity], m: \fI\%Matrix44\fP | None = None) -> Tuple[\fI\%Logger\fP, List[DXFEntity]] Copy entities and transform them by matrix \fIm\fP\&. Does not raise any exception and ignores all entities that cannot be copied or transformed. Just copies the input entities if matrix \fIm\fP is \fBNone\fP\&. Returns a tuple of \fI\%Logger\fP and a list of transformed virtual copies. The function supports virtual entities as input and converts circular arcs into ellipses to perform non\-uniform scaling. .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.translate(entities: Iterable[DXFEntity], offset: \fI\%UVec\fP) -> \fI\%Logger\fP Translates (moves) \fIentities\fP inplace by the \fIoffset\fP vector. .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.scale_uniform(entities: Iterable[DXFEntity], factor: float) -> \fI\%Logger\fP Scales \fIentities\fP inplace by a \fIfactor\fP in all axis. Scaling factors smaller than \fI\%MIN_SCALING_FACTOR\fP are ignored. .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.scale(entities: Iterable[DXFEntity], sx: float, sy: float, sz: float) -> \fI\%Logger\fP Scales \fIentities\fP inplace by the factors \fIsx\fP in x\-axis, \fIsy\fP in y\-axis and \fIsz\fP in z\-axis. Scaling factors smaller than \fI\%MIN_SCALING_FACTOR\fP are ignored. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 same limitations for virtual entities as the \fI\%inplace()\fP function .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.x_rotate(entities: Iterable[DXFEntity], angle: float) -> \fI\%Logger\fP Rotates \fIentities\fP inplace by \fIangle\fP in radians about the x\-axis. .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.y_rotate(entities: Iterable[DXFEntity], angle: float) -> \fI\%Logger\fP Rotates \fIentities\fP inplace by \fIangle\fP in radians about the y\-axis. .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.z_rotate(entities: Iterable[DXFEntity], angle: float) -> \fI\%Logger\fP Rotates \fIentities\fP inplace by \fIangle\fP in radians about the x\-axis. .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.axis_rotate(entities: Iterable[DXFEntity], axis: \fI\%UVec\fP, angle: float) -> \fI\%Logger\fP Rotates \fIentities\fP inplace by \fIangle\fP in radians about the rotation axis starting at the origin pointing in \fIaxis\fP direction. .UNINDENT .INDENT 0.0 .TP .B ezdxf.transform.MIN_SCALING_FACTOR Minimal scaling factor: 1e\-12 .UNINDENT .INDENT 0.0 .TP .B class ezdxf.transform.Error .INDENT 7.0 .TP .B NONE No error, same as a boolean \fBFalse\fP, this allows check \fBif error: ...\fP .UNINDENT .INDENT 7.0 .TP .B COPY_NOT_SUPPORTED Entity without copy support. .UNINDENT .INDENT 7.0 .TP .B TRANSFORMATION_NOT_SUPPORTED Entity without transformation support. .UNINDENT .INDENT 7.0 .TP .B NON_UNIFORM_SCALING_ERROR Circular arcs (CIRCLE, ARC, bulges in POLYLINE and LWPOLYLINE entities) cannot be scaled non\-uniformly. .UNINDENT .INDENT 7.0 .TP .B INSERT_TRANSFORMATION_ERROR INSERT entities cannot represent a non\-orthogonal target coordinate system. Maybe exploding the INSERT entities (recursively) beforehand can solve this issue, see function \fI\%ezdxf.disassemble.recursive_decompose()\fP\&. .UNINDENT .INDENT 7.0 .TP .B VIRTUAL_ENTITY_NOT_SUPPORTED Transformation not supported for virtual entities e.g. non\-uniform scaling for CIRCLE, ARC or POLYLINE with bulges .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.transform.Logger A \fBSequence\fP of errors as \fI\%Logger.Entry\fP instances. .INDENT 7.0 .TP .B class Entry Named tuple representing a logger entry. .INDENT 7.0 .TP .B error \fI\%Error\fP enum .UNINDENT .INDENT 7.0 .TP .B msg error message as string .UNINDENT .INDENT 7.0 .TP .B entity DXF entity which causes the error .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns the count of error entries. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index: int) -> \fI\%Entry\fP Returns the error entry at \fIindex\fP\&. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[\fI\%Entry\fP] Iterates over all error entries. .UNINDENT .INDENT 7.0 .TP .B messages() -> list[str] Returns all error messages as list of strings. .UNINDENT .UNINDENT .SS Math Construction Tools .sp These are links to tools in the \fI\%ezdxf.math\fP core module: .TS center; |l|l|. _ T{ \fI\%ezdxf.math.ConstructionRay\fP T} T{ Construction tool for infinite 2D rays. T} _ T{ \fI\%ezdxf.math.ConstructionLine\fP T} T{ Construction tool for 2D lines. T} _ T{ \fI\%ezdxf.math.ConstructionCircle\fP T} T{ Construction tool for 2D circles. T} _ T{ \fI\%ezdxf.math.ConstructionArc\fP T} T{ Construction tool for 2D arcs. T} _ T{ \fI\%ezdxf.math.ConstructionEllipse\fP T} T{ Construction tool for 3D ellipsis. T} _ T{ \fI\%ezdxf.math.ConstructionBox\fP T} T{ Construction tool for 2D rectangles. T} _ T{ \fI\%ezdxf.math.ConstructionPolyline\fP T} T{ Construction tool for 3D polylines. T} _ T{ \fI\%ezdxf.math.Shape2d\fP T} T{ Construction tools for 2D shapes. T} _ T{ \fI\%ezdxf.math.BSpline\fP T} T{ B\-spline construction tool. T} _ T{ \fI\%ezdxf.math.Bezier4P\fP T} T{ Implements an optimized cubic \fI\%Bézier curve\fP for exact 4 control points. T} _ T{ \fI\%ezdxf.math.Bezier3P\fP T} T{ Implements an optimized quadratic \fI\%Bézier curve\fP for exact 3 control points. T} _ T{ \fI\%ezdxf.math.Bezier\fP T} T{ Generic \fI\%Bézier curve\fP of any degree. T} _ T{ \fI\%ezdxf.math.BezierSurface\fP T} T{ \fBBezierSurface\fP defines a mesh of \fIm\fP x \fIn\fP control points. T} _ T{ \fI\%ezdxf.math.EulerSpiral\fP T} T{ This class represents an euler spiral (clothoid) for \fIcurvature\fP (Radius of curvature). T} _ .TE .SS Custom Data .SS Custom XDATA .sp The classes \fI\%XDataUserList\fP and \fI\%XDataUserDict\fP manage custom user data stored in the XDATA section of a DXF entity. For more information about XDATA see reference section: \fI\%Extended Data (XDATA)\fP .sp These classes store only a limited set of data types with fixed group codes and the types are checked by \fBisinstance()\fP so a \fBVec3\fP object can not be replaced by a (x, y, z)\-tuple: .TS center; |l|l|. _ T{ Group Code T} T{ Data Type T} _ T{ 1000 T} T{ str, limited to 255 characters, line breaks \fB\(dq\en\(dq\fP and \fB\(dq\er\(dq\fP are not allowed T} _ T{ 1010 T} T{ Vec3 T} _ T{ 1040 T} T{ float T} _ T{ 1071 T} T{ 32\-bit int, restricted by the DXF standard not by Python! T} _ .TE .sp Strings are limited to 255 characters, line breaks \fB\(dq\en\(dq\fP and \fB\(dq\er\(dq\fP are not allowed. .sp This classes assume a certain XDATA structure and therefore can not manage arbitrary XDATA! .sp This classes do not create the required AppID table entry, only the default AppID “EZDXF” exist by default. Setup a new AppID in the AppID table: \fBdoc.appids.add(\(dqMYAPP\(dq)\fP\&. .sp For usage look at this \fI\%example\fP at github or go to the tutorial: \fI\%Storing Custom Data in DXF Files\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Tutorial: \fI\%Storing Custom Data in DXF Files\fP .IP \(bu 2 \fI\%Example\fP at github .IP \(bu 2 XDATA reference: \fI\%Extended Data (XDATA)\fP .IP \(bu 2 XDATA management class: \fI\%XData\fP .UNINDENT .UNINDENT .UNINDENT .SS XDataUserList .INDENT 0.0 .TP .B class ezdxf.entities.xdata.XDataUserList Manage user data as a named list\-like object in XDATA. Multiple user lists with different names can be stored in a single \fI\%XData\fP instance for a single AppID. .sp Recommended usage by context manager \fI\%entity()\fP: .INDENT 7.0 .INDENT 3.5 .sp .EX with XDataUserList.entity(entity, name=\(dqMyList\(dq, appid=\(dqMYAPP\(dq) as ul: ul.append(\(dqThe value of PI\(dq) # str \(dq\en\(dq and \(dq\er\(dq are not allowed ul.append(3.141592) # float ul.append(1) # int ul.append(Vec3(1, 2, 3)) # Vec3 # invalid data type raises DXFTypeError ul.append((1, 2, 3)) # tuple instead of Vec3 # retrieve a single value s = ul[0] # store whole content into a Python list data = list(ul) .EE .UNINDENT .UNINDENT .sp Implements the \fBMutableSequence\fP interface. .INDENT 7.0 .TP .B xdata The underlying \fI\%XData\fP instance. .UNINDENT .INDENT 7.0 .TP .B __init__(xdata: \fI\%XData\fP | None = None, name=\(aqDefaultList\(aq, appid=\(aqEZDXF\(aq) Setup a XDATA user list \fIname\fP for the given \fIappid\fP\&. .sp The data is stored in the given \fIxdata\fP object, or in a new created \fI\%XData\fP instance if \fBNone\fP\&. Changes of the content has to be committed at the end to be stored in the underlying \fIxdata\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBxdata\fP (\fI\%XData\fP) – underlying \fI\%XData\fP instance, if \fBNone\fP a new one will be created .IP \(bu 2 \fBname\fP (\fIstr\fP) – name of the user list .IP \(bu 2 \fBappid\fP (\fIstr\fP) – application specific AppID .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __str__() Return str(self). .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns len(self). .UNINDENT .INDENT 7.0 .TP .B __getitem__(item) Get self[item]. .UNINDENT .INDENT 7.0 .TP .B __setitem__(item, value) Set self[item] to value. .UNINDENT .INDENT 7.0 .TP .B __delitem__(item) Delete self[item]. .UNINDENT .INDENT 7.0 .TP .B classmethod entity(entity: \fI\%DXFEntity\fP, name=\(aqDefaultList\(aq, appid=\(aqEZDXF\(aq) -> Iterator[\fI\%XDataUserList\fP] Context manager to manage a XDATA list \fIname\fP for a given DXF \fIentity\fP\&. Appends the user list to the existing \fI\%XData\fP instance or creates new \fI\%XData\fP instance. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP (\fI\%DXFEntity\fP) – target DXF entity for the XDATA .IP \(bu 2 \fBname\fP (\fIstr\fP) – name of the user list .IP \(bu 2 \fBappid\fP (\fIstr\fP) – application specific AppID .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B commit() -> None Store all changes to the underlying \fI\%XData\fP instance. This call is not required if using the \fI\%entity()\fP context manager. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFValueError\fP – invalid chars \fB\(dq\en\(dq\fP or \fB\(dq\er\(dq\fP in a string .IP \(bu 2 \fI\%DXFTypeError\fP – invalid data type .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS XDataUserDict .INDENT 0.0 .TP .B class ezdxf.entities.xdata.XDataUserDict Manage user data as a named dict\-like object in XDATA. Multiple user dicts with different names can be stored in a single \fI\%XData\fP instance for a single AppID. The keys have to be strings. .sp Recommended usage by context manager \fI\%entity()\fP: .INDENT 7.0 .INDENT 3.5 .sp .EX with XDataUserDict.entity(entity, name=\(dqMyDict\(dq, appid=\(dqMYAPP\(dq) as ud: ud[\(dqcomment\(dq] = \(dqThe value of PI\(dq # str \(dq\en\(dq and \(dq\er\(dq are not allowed ud[\(dqpi\(dq] = 3.141592 # float ud[\(dqnumber\(dq] = 1 # int ud[\(dqvertex\(dq] = Vec3(1, 2, 3) # Vec3 # invalid data type raises DXFTypeError ud[\(dqvertex\(dq] = (1, 2, 3) # tuple instead of Vec3 # retrieve single values s = ud[\(dqcomment\(dq] pi = ud.get(\(dqpi\(dq, 3.141592) # store whole content into a Python dict data = dict(ud) .EE .UNINDENT .UNINDENT .sp Implements the \fBMutableMapping\fP interface. .sp The data is stored in XDATA like a \fI\%XDataUserList\fP by (key, value) pairs, therefore a \fI\%XDataUserDict\fP can also be loaded as \fI\%XDataUserList\fP\&. It is not possible to distinguish a \fI\%XDataUserDict\fP from a \fI\%XDataUserList\fP except by the name of the data structure. .INDENT 7.0 .TP .B xdata The underlying \fI\%XData\fP instance. .UNINDENT .INDENT 7.0 .TP .B __init__(xdata: \fI\%XData\fP | None = None, name=\(aqDefaultDict\(aq, appid=\(aqEZDXF\(aq) Setup a XDATA user dict \fIname\fP for the given \fIappid\fP\&. .sp The data is stored in the given \fIxdata\fP object, or in a new created \fI\%XData\fP instance if \fBNone\fP\&. Changes of the content has to be committed at the end to be stored in the underlying \fIxdata\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBxdata\fP (\fI\%XData\fP) – underlying \fI\%XData\fP instance, if \fBNone\fP a new one will be created .IP \(bu 2 \fBname\fP (\fIstr\fP) – name of the user list .IP \(bu 2 \fBappid\fP (\fIstr\fP) – application specific AppID .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __str__() Return str(self). .UNINDENT .INDENT 7.0 .TP .B __len__() Returns len(self). .UNINDENT .INDENT 7.0 .TP .B __getitem__(key) Get self[key]. .UNINDENT .INDENT 7.0 .TP .B __setitem__(key, item) Set self[key] to value, key has to be a string. .INDENT 7.0 .TP .B Raises \fI\%DXFTypeError\fP – key is not a string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __delitem__(key) Delete self[key]. .UNINDENT .INDENT 7.0 .TP .B discard(key) Delete self[key], without raising a \fBKeyError\fP if \fIkey\fP does not exist. .UNINDENT .INDENT 7.0 .TP .B __iter__() Implement iter(self). .UNINDENT .INDENT 7.0 .TP .B classmethod entity(entity: \fI\%DXFEntity\fP, name=\(aqDefaultDict\(aq, appid=\(aqEZDXF\(aq) -> Iterator[\fI\%XDataUserDict\fP] Context manager to manage a XDATA dict \fIname\fP for a given DXF \fIentity\fP\&. Appends the user dict to the existing \fI\%XData\fP instance or creates new \fI\%XData\fP instance. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP (\fI\%DXFEntity\fP) – target DXF entity for the XDATA .IP \(bu 2 \fBname\fP (\fIstr\fP) – name of the user list .IP \(bu 2 \fBappid\fP (\fIstr\fP) – application specific AppID .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B commit() -> None Store all changes to the underlying \fI\%XData\fP instance. This call is not required if using the \fI\%entity()\fP context manager. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFValueError\fP – invalid chars \fB\(dq\en\(dq\fP or \fB\(dq\er\(dq\fP in a string .IP \(bu 2 \fI\%DXFTypeError\fP – invalid data type .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Custom XRecord .sp The \fI\%UserRecord\fP and \fI\%BinaryRecord\fP classes help to store custom data in DXF files in \fI\%XRecord\fP objects a simple and safe way. This way requires DXF version R2000 or later, for DXF version R12 the only way to store custom data is \fI\%Extended Data (XDATA)\fP\&. .sp The \fI\%UserRecord\fP stores Python types and nested container types: \fBint\fP, \fBfloat\fP, \fBstr\fP, \fI\%Vec2\fP, \fI\%Vec3\fP, \fBlist\fP and \fBdict\fP\&. .sp Requirements for Python structures: .INDENT 0.0 .IP \(bu 2 The top level structure has to be a \fBlist\fP\&. .IP \(bu 2 Strings has to have max. 2049 characters and can not contain line breaks \fB\(dq\e\en\(dq\fP or \fB\(dq\e\er\(dq\fP\&. .IP \(bu 2 Dict keys have to be simple Python types: \fBint\fP, \fBfloat\fP, \fBstr\fP\&. .UNINDENT .sp DXF Tag layout for Python types and structures stored in the \fI\%XRecord\fP object: .sp Only for the \fI\%UserRecord\fP the first tag is (2, user record name). .TS center; |l|l|. _ T{ Type T} T{ DXF Tag(s) T} _ T{ str T} T{ (1, value) string with less than 2050 chars and including no line breaks T} _ T{ int T} T{ (90, value) int 32\-bit, restricted by the DXF standard not by Python! T} _ T{ float T} T{ (40, value) “C” double T} _ T{ Vec2 T} T{ (10, x), (20, y) T} _ T{ Vec3 T} T{ (10, x) (20, y) (30, z) T} _ T{ list T} T{ starts with (2, “[”) and ends with (2, “]”) T} _ T{ dict T} T{ starts with (2, “{”) and ends with (2, “}”) T} _ .TE .sp The \fI\%BinaryRecord\fP stores arbitrary binary data as \fI\%BLOB\fP\&. .sp Storage size limits of XRECORD according the DXF reference: .INDENT 0.0 .INDENT 3.5 “This object is similar in concept to XDATA but is not limited by size or order.” .UNINDENT .UNINDENT .sp For usage look at this \fI\%example\fP at github or go to the tutorial: \fI\%Storing Custom Data in DXF Files\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Tutorial: \fI\%Storing Custom Data in DXF Files\fP .IP \(bu 2 \fI\%Example\fP at github .IP \(bu 2 \fI\%ezdxf.entities.XRecord\fP .UNINDENT .UNINDENT .UNINDENT .SS UserRecord .INDENT 0.0 .TP .B class ezdxf.urecord.UserRecord .INDENT 7.0 .TP .B xrecord The underlying \fI\%XRecord\fP instance .UNINDENT .INDENT 7.0 .TP .B name The name of the \fI\%UserRecord\fP, an arbitrary string with less than 2050 chars and including no line breaks. .UNINDENT .INDENT 7.0 .TP .B data The Python data. The top level structure has to be a list (\fBMutableSequence\fP). Inside this container the following Python types are supported: str, int, float, Vec2, Vec3, list, dict .sp Nested data structures are supported list or/and dict in list or dict. Dict keys have to be simple Python types: int, float, str. .UNINDENT .INDENT 7.0 .TP .B property handle: str | None DXF handle of the underlying \fI\%XRecord\fP instance. .UNINDENT .INDENT 7.0 .TP .B __init__(xrecord: \fI\%XRecord\fP | None = None, *, name: str = DEFAULT_NAME, doc: \fI\%Drawing\fP | None = None) Setup a \fI\%UserRecord\fP with the given \fIname\fP\&. .sp The data is stored in the given \fIxrecord\fP object, or in a new created \fI\%XRecord\fP instance if \fBNone\fP\&. If \fIdoc\fP is not \fBNone\fP the new xrecord is added to the OBJECTS section of the DXF document. .sp Changes of the content has to be committed at the end to be stored in the underlying \fI\%xrecord\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBxrecord\fP (\fI\%XRecord\fP) – underlying \fI\%XRecord\fP instance, if \fBNone\fP a new one will be created .IP \(bu 2 \fBname\fP (\fIstr\fP) – name of the user list .IP \(bu 2 \fBdoc\fP (\fI\%Drawing\fP) – DXF document or \fBNone\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __str__() Return str(self). .UNINDENT .INDENT 7.0 .TP .B commit() -> XRecord Store \fI\%data\fP in the underlying \fI\%XRecord\fP instance. This call is not required if using the class by the \fBwith\fP statement. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFValueError\fP – invalid chars \fB\(dq\en\(dq\fP or \fB\(dq\er\(dq\fP in a string .IP \(bu 2 \fI\%DXFTypeError\fP – invalid data type .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS BinaryRecord .INDENT 0.0 .TP .B class ezdxf.urecord.BinaryRecord .INDENT 7.0 .TP .B xrecord The underlying \fI\%XRecord\fP instance .UNINDENT .INDENT 7.0 .TP .B data The binary data as bytes, bytearray or memoryview. .UNINDENT .INDENT 7.0 .TP .B property handle: str | None DXF handle of the underlying \fI\%XRecord\fP instance. .UNINDENT .INDENT 7.0 .TP .B __init__(xrecord: \fI\%XRecord\fP | None = None, *, doc: \fI\%Drawing\fP | None = None) Setup a \fI\%BinaryRecord\fP\&. .sp The data is stored in the given \fIxrecord\fP object, or in a new created \fI\%XRecord\fP instance if \fBNone\fP\&. If \fIdoc\fP is not \fBNone\fP the new xrecord is added to the OBJECTS section of the DXF document. .sp Changes of the content has to be committed at the end to be stored in the underlying \fI\%xrecord\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBxrecord\fP (\fI\%XRecord\fP) – underlying \fI\%XRecord\fP instance, if \fBNone\fP a new one will be created .IP \(bu 2 \fBdoc\fP (\fI\%Drawing\fP) – DXF document or \fBNone\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Return str(self). .UNINDENT .INDENT 7.0 .TP .B commit() -> XRecord Store binary \fI\%data\fP in the underlying \fI\%XRecord\fP instance. This call is not required if using the class by the \fBwith\fP statement. .UNINDENT .UNINDENT .SS Fonts .SS Fonts .sp The module \fI\%ezdxf.fonts.fonts\fP manages the internal usage of fonts and has no relation how the DXF formats manages text styles. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%Textstyle\fP entity, the DXF way to define fonts. .UNINDENT .UNINDENT .sp New in version 1.1. .sp Since \fIezdxf\fP v1.1 text rendering is done by the \fI\%fontTools\fP package. Support for stroke fonts, these are the basic vector fonts included in CAD applications, like .shx, .shp or .lff fonts was also added. .sp None of the required font files (.ttf, .ttc, .otf, .shx, .shp or .lff) are included in \fIezdxf\fP as they are copyrighted or, in the case of the LibreCAD font format (.lff), licensed under the “GPL v2 and later”. .SS Font Locations .SS TrueType Fonts .sp The font manager searches the following directories recursively for .ttf, .ttc and .otf font files. .INDENT 0.0 .IP \(bu 2 .INDENT 2.0 .TP .B Windows: .INDENT 7.0 .IP \(bu 2 ~/AppData/Local/Microsoft/Windows/Fonts .IP \(bu 2 /Fonts .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Linux and other *nix like systems: .INDENT 7.0 .IP \(bu 2 /usr/share/fonts .IP \(bu 2 /usr/local/share/fonts .IP \(bu 2 ~/.fonts .IP \(bu 2 ~/.local/share/fonts .IP \(bu 2 ~/.local/share/texmf/fonts .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B macOS: .INDENT 7.0 .IP \(bu 2 /Library/Fonts .UNINDENT .UNINDENT .UNINDENT .sp The \fIfc\-list\fP command on Linux shows all available fonts and their location. .sp The default font is selected in the following order, if none of them is available on your system \- install one of them, the open source fonts can be found in the github repository in the folder \fI\%ezdxf/fonts\fP\&. .INDENT 0.0 .IP \(bu 2 Arial.ttf .IP \(bu 2 DejaVuSansCondensed.ttf .IP \(bu 2 DejaVuSans.ttf .IP \(bu 2 LiberationSans\-Regular.ttf .IP \(bu 2 OpenSans\-Regular.ttf .UNINDENT .SS Basic Stroke Fonts .sp There is no universal way to find the basic stroke fonts of CAD applications on a system, beside scanning all drives. Set the paths to the stroke fonts in your config file manually to tell \fIezdxf\fP where to search for them, all paths are search recursively, see also option \fI\%ezdxf.options.support_dirs\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX [core] support_dirs = \(dqC:\eProgram Files\eBricsys\eBricsCAD V23 en_US\eFonts\(dq, ~/shx_fonts, ~/shp_fonts, ~/lff_fonts, .EE .UNINDENT .UNINDENT .sp The .shx fonts can be found on the internet but be aware that they are not free as all websites claim. The LibreCAD font files (.llf) can be downloaded from their github repository: \fI\%https://github.com/LibreCAD/LibreCAD/tree/master/librecad/support/fonts\fP .SS Font Caching .sp The fonts available on a system are cached automatically, the cache has to be rebuild to recognize new installed fonts by \fI\%build_system_font_cache()\fP\&. The cache is stored in the users home directory “~/.cache/ezdxf” or the directory specified by the environment variable “XDG_CACHE_HOME”. .SS Rebuilding the Font Cache .sp When you add new fonts to your system or add a font directory to the support directories in the config file you have to rebuild the font\-cache of \fIezdxf\fP to recognize these new fonts: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.fonts import fonts fonts.build_system_font_cache() .EE .UNINDENT .UNINDENT .sp or call the \fIezdxf\fP launcher to do that: .INDENT 0.0 .INDENT 3.5 .sp .EX ezdxf \-\-fonts .EE .UNINDENT .UNINDENT .SS Functions .INDENT 0.0 .TP .B ezdxf.fonts.fonts.make_font(font_name: str, cap_height: float, width_factor: float = 1.0) -> \fI\%AbstractFont\fP Returns a font abstraction based on class \fI\%AbstractFont\fP\&. .sp Supported font types: .INDENT 7.0 .IP \(bu 2 \&.ttf, .ttc and .otf \- TrueType fonts .IP \(bu 2 \&.shx, .shp \- Autodesk® shapefile fonts .IP \(bu 2 \&.lff \- LibreCAD font format .UNINDENT .sp The special name “*monospace” returns the fallback font \fI\%MonospaceFont\fP for testing and basic measurements. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 The font definition files are not included in \fIezdxf\fP\&. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfont_name\fP – font file name as stored in the \fI\%Textstyle\fP entity e.g. “OpenSans\-Regular.ttf” .IP \(bu 2 \fBcap_height\fP – desired cap height in drawing units. .IP \(bu 2 \fBwidth_factor\fP – horizontal text stretch factor .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.get_font_face(font_name: str, map_shx=True) -> \fI\%FontFace\fP Returns the \fI\%FontFace\fP definition for the given font filename e.g. “LiberationSans\-Regular.ttf”. .sp This function translates a DXF font definition by the TTF font file name into a \fI\%FontFace\fP object. Returns the \fI\%FontFace\fP of the default font when a font is not available on the current system. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfont_name\fP – raw font file name as stored in the \fI\%Textstyle\fP entity .IP \(bu 2 \fBmap_shx\fP – maps SHX font names to TTF replacement fonts, e.g. “TXT” \-> “txt_____.ttf” .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.find_font_face(font_name: str) -> \fI\%FontFace\fP Returns the \fI\%FontFace\fP definition for the given font filename e.g. “LiberationSans\-Regular.ttf”. .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.find_font_file_name(font_face: \fI\%FontFace\fP) -> str Returns the true type font file name without parent directories e.g. “Arial.ttf”. .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.find_best_match(*, family: str = \(aqsans\-serif\(aq, style: str = \(aqRegular\(aq, weight: int = 400, width: int = 5, italic: bool | None = False) -> \fI\%FontFace\fP | None Returns a \fI\%FontFace\fP that matches the given properties best. The search is based the descriptive properties and not on comparing glyph shapes. Returns \fBNone\fP if no font was found. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfamily\fP – font family name e.g. “sans\-serif”, “Liberation Sans” .IP \(bu 2 \fBstyle\fP – font style e.g. “Regular”, “Italic”, “Bold” .IP \(bu 2 \fBweight\fP – weight in the range from 1\-1000 (usWeightClass) .IP \(bu 2 \fBwidth\fP – width in the range from 1\-9 (usWidthClass) .IP \(bu 2 \fBitalic\fP – \fBTrue\fP, \fBFalse\fP or \fBNone\fP to ignore this flag .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.get_entity_font_face(entity: \fI\%DXFEntity\fP, doc: \fI\%Drawing\fP | None = None) -> \fI\%FontFace\fP Returns the \fI\%FontFace\fP defined by the associated text style. Returns the default font face if the \fIentity\fP does not have or support the DXF attribute “style”. Supports the extended font information stored in \fI\%Textstyle\fP table entries. .sp Pass a DXF document as argument \fIdoc\fP to resolve text styles for virtual entities which are not assigned to a DXF document. The argument \fIdoc\fP always overrides the DXF document to which the \fIentity\fP is assigned to. .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.get_font_measurements(font_name: str, map_shx=True) -> FontMeasurements Get \fI\%FontMeasurements\fP for the given font filename e.g. “LiberationSans\-Regular.ttf”. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfont_name\fP – raw font file name as stored in the \fI\%Textstyle\fP entity .IP \(bu 2 \fBmap_shx\fP – maps SHX font names to TTF replacement fonts, e.g. “TXT” \-> “txt_____.ttf” .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.build_system_font_cache() Builds or rebuilds the font manager cache. The font manager cache has a fixed location in the cache directory of the users home directory “~/.cache/ezdxf” or the directory specified by the environment variable “XDG_CACHE_HOME”. .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.load() Reload all cache files. The cache files are loaded automatically at the import of \fIezdxf\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.fonts.fonts.sideload_ttf(font_path: str | PathLike, cap_height) -> \fI\%AbstractFont\fP This function bypasses the FontManager and loads the TrueType font straight from the file system, requires the absolute font file path e.g. “C:/Windows/Fonts/Arial.ttf”. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 Expert feature, use with care: no fallback font and no error handling. .UNINDENT .UNINDENT .UNINDENT .SS Classes .INDENT 0.0 .TP .B class ezdxf.fonts.fonts.AbstractFont(measurements: FontMeasurements) The \fIezdxf\fP font abstraction for text measurement and text path rendering. .INDENT 7.0 .TP .B name The font filename e.g. “LiberationSans\-Regular.ttf” .UNINDENT .INDENT 7.0 .TP .B font_render_type The font type, see enum \fI\%FontRenderType\fP .UNINDENT .INDENT 7.0 .TP .B measurement The \fI\%FontMeasurements\fP data. .UNINDENT .INDENT 7.0 .TP .B abstract text_width(text: str) -> float Returns the text width in drawing units for the given \fItext\fP string. .UNINDENT .INDENT 7.0 .TP .B abstract text_width_ex(text: str, cap_height: float, width_factor: float = 1.0) -> float Returns the text width in drawing units, bypasses the stored \fIcap_height\fP and \fIwidth_factor\fP\&. .UNINDENT .INDENT 7.0 .TP .B abstract text_path(text: str) -> NumpyPath2d Returns the 2D text path for the given text. .UNINDENT .INDENT 7.0 .TP .B abstract text_path_ex(text: str, cap_height: float, width_factor: float = 1.0) -> NumpyPath2d Returns the 2D text path for the given text, bypasses the stored \fIcap_height\fP and \fIwidth_factor\fP\&. .UNINDENT .INDENT 7.0 .TP .B abstract space_width() -> float Returns the width of a “space” character a.k.a. word spacing. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.fonts.fonts.MonospaceFont(cap_height: float, width_factor: float = 1.0, baseline: float = 0, descender_factor: float = DESCENDER_FACTOR, x_height_factor: float = X_HEIGHT_FACTOR) Represents a monospaced font where each letter has the same cap\- and descender height and the same width. The given cap height and width factor are the default values for measurements and rendering. The extended methods can override these default values. .sp This font exists only for generic text measurement in tests and does not render any glyphs! .UNINDENT .INDENT 0.0 .TP .B class ezdxf.fonts.fonts.TrueTypeFont(font_name: str, cap_height: float, width_factor: float = 1.0) Represents a TrueType font. Font measurement and glyph rendering is done by the \fIfontTools\fP package. The given cap height and width factor are the default values for measurements and glyph rendering. The extended methods can override these default values. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.fonts.fonts.ShapeFileFont(font_name: str, cap_height: float, width_factor: float = 1.0) Represents a shapefile font (.shx, .shp). Font measurement and glyph rendering is done by the ezdxf.fonts.shapefile module. The given cap height and width factor are the default values for measurements and glyph rendering. The extended methods can override these default values. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.fonts.fonts.LibreCadFont(font_name: str, cap_height: float, width_factor: float = 1.0) Represents a LibreCAD font (.shx, .shp). Font measurement and glyph rendering is done by the ezdxf.fonts.lff module. The given cap height and width factor are the default values for measurements and glyph rendering. The extended methods can override these default values. .UNINDENT .SS Font Anatomy .INDENT 0.0 .IP \(bu 2 A Visual Guide to the Anatomy of Typography: \fI\%https://visme.co/blog/type\-anatomy/\fP .IP \(bu 2 Anatomy of a Character: \fI\%https://www.fonts.com/content/learning/fontology/level\-1/type\-anatomy/anatomy\fP .UNINDENT .SS Font Properties .sp DXF to store fonts in the \fI\%Textstyle\fP entity as TTF file name e.g. “LiberationSans\-Regular.ttf”. .sp The \fI\%FontFace\fP class can be used to specify a font in a more generic way: .INDENT 0.0 .TP .B family font name e.g. “Liberation Sans” or “Arial”, may a generic font family name, either “serif”, “sans\-serif” or “monospace” .TP .B style “Regular”, “Italic”, “Oblique”, “Bold”, “BoldOblique”, … .TP .B width (usWidthClass) A numeric value in the range 0\-9 .TS center; |l|l|. _ T{ 1 T} T{ UltraCondensed T} _ T{ 2 T} T{ ExtraCondensed T} _ T{ 3 T} T{ Condensed T} _ T{ 4 T} T{ SemiCondensed T} _ T{ 5 T} T{ Normal or Medium T} _ T{ 6 T} T{ SemiExpanded T} _ T{ 7 T} T{ Expanded T} _ T{ 8 T} T{ ExtraExpanded T} _ T{ 9 T} T{ UltraExpanded T} _ .TE .TP .B weight (usWeightClass) A numeric value in the range 0\-1000 .TS center; |l|l|. _ T{ 100 T} T{ Thin T} _ T{ 200 T} T{ ExtraLight T} _ T{ 300 T} T{ Light T} _ T{ 400 T} T{ Normal T} _ T{ 500 T} T{ Medium T} _ T{ 600 T} T{ SemiBold T} _ T{ 700 T} T{ Bold T} _ T{ 800 T} T{ ExtraBold T} _ T{ 900 T} T{ Black T} _ .TE .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 W3C: \fI\%https://www.w3.org/TR/2018/REC\-css\-fonts\-3\-20180920/\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.fonts.fonts.FontRenderType Enumeration of font render type. .INDENT 7.0 .TP .B STROKE Basic stroke font, can only be rendered as linear paths. .UNINDENT .INDENT 7.0 .TP .B OUTLINE TrueType or similar font, can be rendered as filled paths or as outline strokes. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.fonts.fonts.FontFace(filename, family, style, weight, width) .INDENT 7.0 .TP .B filename font file name without parent directories as string, e.g. “arial.ttf” .UNINDENT .INDENT 7.0 .TP .B family Family name as string, the default value is “sans\-serif” .UNINDENT .INDENT 7.0 .TP .B style Font style as string, the default value is “Regular” .UNINDENT .INDENT 7.0 .TP .B weight Font weight as int in the renge from 0\-1000, the default value is 400 (Normal) .UNINDENT .INDENT 7.0 .TP .B property weight_str: str Returns the \fI\%weight\fP as string e.g. “Thin”, “Normal”, “Bold”, … .UNINDENT .INDENT 7.0 .TP .B width Font width (stretch) as int in the range from 1\-9, the default value is 5 (Normal) .UNINDENT .INDENT 7.0 .TP .B property width_str: str Returns the \fI\%width\fP as string e.g. “Condensed”, “Expanded”, … .UNINDENT .INDENT 7.0 .TP .B property is_italic: bool Returns \fBTrue\fP if font face is italic. .UNINDENT .INDENT 7.0 .TP .B property is_oblique: bool Returns \fBTrue\fP if font face is oblique. .UNINDENT .INDENT 7.0 .TP .B property is_bold: bool Returns \fBTrue\fP if font face weight > 400. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.fonts.fonts.FontMeasurements See \fI\%Font Anatomy\fP for more information. .INDENT 7.0 .TP .B baseline .UNINDENT .INDENT 7.0 .TP .B cap_height .UNINDENT .INDENT 7.0 .TP .B x_height .UNINDENT .INDENT 7.0 .TP .B descender_height .UNINDENT .INDENT 7.0 .TP .B scale(factor: float = 1.0) -> FontMeasurements .UNINDENT .INDENT 7.0 .TP .B scale_from_baseline(desired_cap_height: float) -> FontMeasurements .UNINDENT .INDENT 7.0 .TP .B shift(distance: float = 0.0) -> FontMeasurements .UNINDENT .INDENT 7.0 .TP .B property cap_top: float .UNINDENT .INDENT 7.0 .TP .B property x_top: float .UNINDENT .INDENT 7.0 .TP .B property bottom: float .UNINDENT .INDENT 7.0 .TP .B property total_height: float .UNINDENT .UNINDENT .SS Tools .SS Functions .SS DXF Unicode Decoder .sp The DXF format uses a special form of unicode encoding: “\eU+xxxx”. .sp To avoid a speed penalty such encoded characters are not decoded automatically by the regular loading function:func:\fIezdxf.readfile\fP, only the \fI\%recover\fP module does the decoding automatically, because this loading mode is already slow. .sp This kind of encoding is most likely used only in older DXF versions, because since DXF R2007 the whole DXF file is encoded in \fButf8\fP and a special unicode encoding is not necessary. .sp The \fI\%ezdxf.has_dxf_unicode()\fP and \fI\%ezdxf.decode_dxf_unicode()\fP are new support functions to decode unicode characters “\eU+xxxx” manually. .INDENT 0.0 .TP .B ezdxf.has_dxf_unicode(s: str) -> bool Returns \fBTrue\fP if string \fIs\fP contains \fB\eU+xxxx\fP encoded characters. .UNINDENT .INDENT 0.0 .TP .B ezdxf.decode_dxf_unicode(s: str) -> str Decode \fB\eU+xxxx\fP encoded characters. .UNINDENT .SS Tools .sp Some handy tool functions used internally by \fBezdxf\fP\&. .INDENT 0.0 .TP .B ezdxf.tools.juliandate(date: datetime) -> float .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.calendardate(juliandate: float) -> datetime .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.set_flag_state(flags: int, flag: int, state: bool = True) -> int Set/clear binary \fIflag\fP in data \fIflags\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBflags\fP – data value .IP \(bu 2 \fBflag\fP – flag to set/clear .IP \(bu 2 \fBstate\fP – \fBTrue\fP for setting, \fBFalse\fP for clearing .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.guid() -> str Returns a general unique ID, based on \fBuuid.uuid4()\fP\&. .sp This function creates a GUID for the header variables $VERSIONGUID and $FINGERPRINTGUID, which matches the AutoCAD pattern \fB{XXXXXXXX\-XXXX\-XXXX\-XXXX\-XXXXXXXXXXXX}\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.bytes_to_hexstr(data: bytes) -> str Returns \fIdata\fP bytes as plain hex string. .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.suppress_zeros(s: str, leading: bool = False, trailing: bool = True) Suppress trailing and/or leading \fB0\fP of string \fIs\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBs\fP – data string .IP \(bu 2 \fBleading\fP – suppress leading \fB0\fP .IP \(bu 2 \fBtrailing\fP – suppress trailing \fB0\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.normalize_text_angle(angle: float, fix_upside_down=True) -> float Normalizes text \fIangle\fP to the range from 0 to 360 degrees and fixes upside down text angles. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP – text angle in degrees .IP \(bu 2 \fBfix_upside_down\fP – rotate upside down text angle about 180 degree .UNINDENT .UNINDENT .UNINDENT .SS SAT Format “Encryption” .INDENT 0.0 .TP .B ezdxf.tools.crypt.encode(text_lines: Iterable[str]) -> Iterable[str] Encode the Standard \fI\%ACIS\fP Text (SAT) format by AutoCAD “encryption” algorithm. .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.crypt.decode(text_lines: Iterable[str]) -> Iterable[str] Decode the Standard \fI\%ACIS\fP Text (SAT) format “encrypted” by AutoCAD. .UNINDENT .SS GfxAttribs .sp The \fI\%ezdxf.gfxattribs\fP module provides the \fI\%GfxAttribs\fP class to create valid attribute dictionaries for the most often used DXF attributes supported by all graphical DXF entities. The advantage of using this class is auto\-completion support by IDEs and an instant validation of the attribute values. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.gfxattribs import GfxAttribs doc = ezdxf.new() msp = doc.modelspace() attribs = GfxAttribs(layer=\(dqMyLayer\(dq, color=ezdxf.colors.RED) line = msp.add_line((0, 0), (1, 0), dxfattribs=attribs) circle = msp.add_circle((0, 0), radius=1.0, dxfattribs=attribs) # Update DXF attributes of existing entities: attribs = GfxAttribs(layer=\(dqMyLayer2\(dq, color=ezdxf.colors.BLUE) # Convert GfxAttribs() to dict(), but this method cannot reset # attributes to the default values like setting layer to \(dq0\(dq. line.update_dxf_attribs(dict(attribs)) # Using GfxAttribs.asdict(default_values=True), can reset attributes to the # default values like setting layer to \(dq0\(dq, except for true_color and # transparency, which do not have default values, their absence is the # default value. circle.update_dxf_attribs(attribs.asdict(default_values=True)) # Remove true_color and transparency by assigning None attribs.transparency = None # reset to transparency by layer! attribs.rgb = None .EE .UNINDENT .UNINDENT .sp Validation features: .INDENT 0.0 .IP \(bu 2 \fBlayer\fP \- string which can not contain certain characters: \fB<>/\e\(dq:;?*=\(ga\fP .IP \(bu 2 \fBcolor\fP \- \fI\%AutoCAD Color Index (ACI)\fP value as integer in the range from 0 to 257 .IP \(bu 2 \fBrgb\fP \- true color value as (red, green, blue) tuple, all channel values as integer values in the range from 0 to 255 .IP \(bu 2 \fBlinetype\fP \- string which can not contain certain characters: \fB<>/\e\(dq:;?*=\(ga\fP, does not check if the linetype exists .IP \(bu 2 \fBlineweight\fP \- integer value in the range from 0 to 211, see \fI\%Lineweights\fP for valid values .IP \(bu 2 \fBtransparency\fP \- float value in the range from 0.0 to 1.0 and \-1.0 for transparency by block .IP \(bu 2 \fBltscale\fP \- float value > 0.0 .UNINDENT .INDENT 0.0 .TP .B class ezdxf.gfxattribs.GfxAttribs(*, layer: str = DEFAULT_LAYER, color: int = DEFAULT_ACI_COLOR, rgb: \fI\%RGB\fP | None = None, linetype: str = DEFAULT_LINETYPE, lineweight: int = DEFAULT_LINEWEIGHT, transparency: float | None = None, ltscale: float = DEFAULT_LTSCALE) Represents often used DXF attributes of graphical entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayer\fP (\fIstr\fP) – layer name as string .IP \(bu 2 \fBcolor\fP (\fIint\fP) – \fI\%AutoCAD Color Index (ACI)\fP color value as integer .IP \(bu 2 \fBrgb\fP – RGB true color (red, green, blue) tuple, each channel value in the range from 0 to 255, \fBNone\fP for not set .IP \(bu 2 \fBlinetype\fP (\fIstr\fP) – linetype name, does not check if the linetype exist! .IP \(bu 2 \fBlineweight\fP (\fIint\fP) – see \fI\%Lineweights\fP documentation for valid values .IP \(bu 2 \fBtransparency\fP (\fIfloat\fP) – transparency value in the range from 0.0 to 1.0, where 0.0 is opaque and 1.0 if fully transparent, \-1.0 for transparency by block, \fBNone\fP for transparency by layer .IP \(bu 2 \fBltscale\fP (\fIfloat\fP) – linetype scaling factor > 0.0, default factor is 1.0 .UNINDENT .TP .B Raises \fI\%DXFValueError\fP – invalid attribute value .UNINDENT .INDENT 7.0 .TP .B property layer: str layer name .UNINDENT .INDENT 7.0 .TP .B property color: int \fI\%AutoCAD Color Index (ACI)\fP color value .UNINDENT .INDENT 7.0 .TP .B property rgb: \fI\%RGB\fP | None true color value as (red, green, blue) tuple, \fBNone\fP for not set .UNINDENT .INDENT 7.0 .TP .B property linetype: str linetype name .UNINDENT .INDENT 7.0 .TP .B property lineweight: int .UNINDENT .INDENT 7.0 .TP .B property transparency: float | None transparency value from 0.0 for opaque to 1.0 is fully transparent, \-1.0 is for transparency by block and \fBNone\fP if for transparency by layer .UNINDENT .INDENT 7.0 .TP .B property ltscale: float linetype scaling factor .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Return str(self). .UNINDENT .INDENT 7.0 .TP .B __repr__() -> str Return repr(self). .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[tuple[str, Any]] Returns iter(self). .UNINDENT .INDENT 7.0 .TP .B asdict(default_values=False) -> dict[str, Any] Returns the DXF attributes as \fBdict\fP, returns also the default values if argument \fIdefault_values\fP is \fBTrue\fP\&. The true_color and transparency attributes do not have default values, the absence of these attributes is the default value. .UNINDENT .INDENT 7.0 .TP .B items(default_values=False) -> list[tuple[str, Any]] Returns the DXF attributes as list of name, value pairs, returns also the default values if argument \fIdefault_values\fP is \fBTrue\fP\&. The true_color and transparency attributes do not have default values, the absence of these attributes is the default value. .UNINDENT .INDENT 7.0 .TP .B classmethod load_from_header(doc: \fI\%Drawing\fP) -> \fI\%GfxAttribs\fP Load default DXF attributes from the HEADER section. .sp There is no default true color value and the default transparency is not stored in the HEADER section. .sp Loads following header variables: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB$CLAYER\fP \- current layer name .IP \(bu 2 \fB$CECOLOR\fP \- current ACI color .IP \(bu 2 \fB$CELTYPE\fP \- current linetype name .IP \(bu 2 \fB$CELWEIGHT\fP \- current lineweight .IP \(bu 2 \fB$CELTSCALE\fP \- current linetype scaling factor .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B write_to_header(doc: \fI\%Drawing\fP) -> None Write DXF attributes as default values to the HEADER section. .sp Writes following header variables: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB$CLAYER\fP \- current layer name, if a layer table entry exist in \fIdoc\fP .IP \(bu 2 \fB$CECOLOR\fP \- current ACI color .IP \(bu 2 \fB$CELTYPE\fP \- current linetype name, if a linetype table entry exist in \fIdoc\fP .IP \(bu 2 \fB$CELWEIGHT\fP \- current lineweight .IP \(bu 2 \fB$CELTSCALE\fP \- current linetype scaling factor .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_entity(entity: \fI\%DXFEntity\fP) -> \fI\%GfxAttribs\fP Get the graphical attributes of an \fIentity\fP as \fI\%GfxAttribs\fP object. .UNINDENT .INDENT 7.0 .TP .B classmethod from_dict(d: dict[str, Any]) -> \fI\%GfxAttribs\fP Construct \fI\%GfxAttribs\fP from a dictionary of raw DXF values. .sp Supported attributes are: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 layer: layer name as string .IP \(bu 2 color: \fI\%AutoCAD Color Index (ACI)\fP value as int .IP \(bu 2 true_color: raw DXF integer value for RGB colors .IP \(bu 2 rgb: RGB tuple of int or \fBNone\fP .IP \(bu 2 linetype: linetype name as string .IP \(bu 2 lineweight: lineweight as int, see basic concept of \fI\%Lineweights\fP .IP \(bu 2 transparency: raw DXF integer value of transparency or a float in the range from 0.0 to 1.0 .IP \(bu 2 ltscale: linetype scaling factor as float .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Text Tools .SS MTextEditor .INDENT 0.0 .TP .B class ezdxf.tools.text.MTextEditor(text: str = \(aq\(aq) The \fI\%MTextEditor\fP is a helper class to build MTEXT content strings with support for inline codes to change color, font or paragraph properties. The result is always accessible by the \fI\%text\fP attribute or the magic \fI\%__str__()\fP function as \fBstr(MTextEditor(\(dqtext\(dq))\fP\&. .sp All text building methods return \fIself\fP to implement a floating interface: .INDENT 7.0 .INDENT 3.5 .sp .EX e = MTextEditor(\(dqThis example \(dq).color(\(dqred\(dq).append(\(dqswitches color to red.\(dq) mtext = msp.add_mtext(str(e)) .EE .UNINDENT .UNINDENT .sp The initial text height, color, text style and so on is determined by the DXF attributes of the \fI\%MText\fP entity. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 The \fI\%MTextEditor\fP assembles just the inline code, which has to be parsed and rendered by the target CAD application, \fIezdxf\fP has no influence to that result. .sp Keep inline formatting as simple as possible, don’t test the limits of its capabilities, this will not work across different CAD applications and keep the formatting in a logic manner like, do not change paragraph properties in the middle of a paragraph. .sp \fBThere is no official documentation for the inline codes!\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters \fBtext\fP – init value of the MTEXT content string. .UNINDENT .INDENT 7.0 .TP .B text The MTEXT content as a simple string. .UNINDENT .INDENT 7.0 .TP .B append(text: str) -> \fI\%MTextEditor\fP Append \fItext\fP\&. .UNINDENT .INDENT 7.0 .TP .B __iadd__(text: str) -> \fI\%MTextEditor\fP Append \fItext\fP: .INDENT 7.0 .INDENT 3.5 .sp .EX e = MTextEditor(\(dqFirst paragraph.\eP\(dq) e += \(dqSecond paragraph.\eP\(dq) .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Returns the MTEXT content attribute \fI\%text\fP\&. .UNINDENT .INDENT 7.0 .TP .B clear() Reset the content to an empty string. .UNINDENT .INDENT 7.0 .TP .B font(name: str, bold: bool = False, italic: bool = False) -> \fI\%MTextEditor\fP Set the text font by the font family name. Changing the font height should be done by the \fI\%height()\fP or the \fI\%scale_height()\fP method. The font family name is the name shown in font selection widgets in desktop applications: “Arial”, “Times New Roman”, “Comic Sans MS”. Switching the codepage is not supported. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – font family name .IP \(bu 2 \fBbold\fP – flag .IP \(bu 2 \fBitalic\fP – flag .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B height(height: float) -> \fI\%MTextEditor\fP Set the absolute text height in drawing units. .UNINDENT .INDENT 7.0 .TP .B scale_height(factor: float) -> \fI\%MTextEditor\fP Scale the text height by a \fIfactor\fP\&. This scaling will accumulate, which means starting at height 2.5 and scaling by 2 and again by 3 will set the text height to 2.5 x 2 x 3 = 15. The current text height is not stored in the \fI\%MTextEditor\fP, you have to track the text height by yourself! The initial text height is stored in the \fI\%MText\fP entity as DXF attribute \fI\%char_height\fP\&. .UNINDENT .INDENT 7.0 .TP .B width_factor(factor: float) -> \fI\%MTextEditor\fP Set the absolute text width factor. .UNINDENT .INDENT 7.0 .TP .B char_tracking_factor(factor: float) -> \fI\%MTextEditor\fP Set the absolute character tracking factor. .UNINDENT .INDENT 7.0 .TP .B oblique(angle: int) -> \fI\%MTextEditor\fP Set the text oblique angle in degrees, vertical is 0, a value of 15 will lean the text 15 degree to the right. .UNINDENT .INDENT 7.0 .TP .B color(name: str) -> \fI\%MTextEditor\fP Set the text color by color name: “red”, “yellow”, “green”, “cyan”, “blue”, “magenta” or “white”. .UNINDENT .INDENT 7.0 .TP .B aci(aci: int) -> \fI\%MTextEditor\fP Set the text color by \fI\%AutoCAD Color Index (ACI)\fP in range [0, 256]. .UNINDENT .INDENT 7.0 .TP .B rgb(rgb: \fI\%RGB\fP) -> \fI\%MTextEditor\fP Set the text color as RGB value. .UNINDENT .INDENT 7.0 .TP .B underline(text: str) -> \fI\%MTextEditor\fP Append \fItext\fP with a line below the text. .UNINDENT .INDENT 7.0 .TP .B overline(text: str) -> \fI\%MTextEditor\fP Append \fItext\fP with a line above the text. .UNINDENT .INDENT 7.0 .TP .B strike_through(text: str) -> \fI\%MTextEditor\fP Append \fItext\fP with a line through the text. .UNINDENT .INDENT 7.0 .TP .B group(text: str) -> \fI\%MTextEditor\fP Group \fItext\fP, all properties changed inside a group are reverted at the end of the group. AutoCAD supports grouping up to 8 levels. .UNINDENT .INDENT 7.0 .TP .B stack(upr: str, lwr: str, t: str = \(aq^\(aq) -> \fI\%MTextEditor\fP Append stacked text \fIupr\fP over \fIlwr\fP, argument \fIt\fP defines the kind of stacking, the space “ “ after the “^” will be added automatically to avoid caret decoding: .INDENT 7.0 .INDENT 3.5 .sp .EX \(dq^\(dq: vertical stacked without divider line, e.g. \eSA^ B: A B \(dq/\(dq: vertical stacked with divider line, e.g. \eSX/Y: X \- Y \(dq#\(dq: diagonal stacked, with slanting divider line, e.g. \eS1#4: 1/4 .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B paragraph(props: \fI\%ParagraphProperties\fP) -> \fI\%MTextEditor\fP Set paragraph properties by a \fI\%ParagraphProperties\fP object. .UNINDENT .INDENT 7.0 .TP .B bullet_list(indent: float, bullets: Iterable[str], content: Iterable[str]) -> \fI\%MTextEditor\fP Build bulleted lists by utilizing paragraph indentation and a tabulator stop. Any string can be used as bullet. Indentation is a multiple of the initial MTEXT char height (see also docs about \fI\%ParagraphProperties\fP), which means indentation in drawing units is \fBMText.dxf.char_height\fP x \fIindent\fP\&. .sp Useful UTF bullets: .INDENT 7.0 .IP \(bu 2 “bull” U+2022 = • (Alt Numpad 7) .IP \(bu 2 “circle” U+25CB = ○ (Alt Numpad 9) .UNINDENT .sp For numbered lists just use numbers as bullets: .INDENT 7.0 .INDENT 3.5 .sp .EX MTextEditor.bullet_list( indent=2, bullets=[\(dq1.\(dq, \(dq2.\(dq], content=[\(dqfirst\(dq, \(dqsecond\(dq], ) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBindent\fP – content indentation as multiple of the initial MTEXT char height .IP \(bu 2 \fBbullets\fP – iterable of bullet strings, e.g. \fB[\(dq\-\(dq] * 3\fP, for 3 dashes as bullet strings .IP \(bu 2 \fBcontent\fP – iterable of list item strings, one string per list item, list items should not contain new line or new paragraph commands. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp Constants stored in the \fI\%MTextEditor\fP class: .TS center; |l|l|. _ T{ NEW_LINE T} T{ \fB\(aq\eP\(aq\fP T} _ T{ NEW_PARAGRAPH T} T{ \fB\(aq\eP\(aq\fP T} _ T{ NEW_COLUMN T} T{ \fB\(aq\eN\fP T} _ T{ UNDERLINE_START T} T{ \fB\(aq\eL\(aq\fP T} _ T{ UNDERLINE_STOP T} T{ \fB\(aq\el\(aq\fP T} _ T{ OVERSTRIKE_START T} T{ \fB\(aq\eO\(aq\fP T} _ T{ OVERSTRIKE_STOP T} T{ \fB\(aq\eo\(aq\fP T} _ T{ STRIKE_START T} T{ \fB\(aq\eK\(aq\fP T} _ T{ STRIKE_STOP T} T{ \fB\(aq\ek\(aq\fP T} _ T{ ALIGN_BOTTOM T} T{ \fB\(aq\eA0;\(aq\fP T} _ T{ ALIGN_MIDDLE T} T{ \fB\(aq\eA1;\(aq\fP T} _ T{ ALIGN_TOP T} T{ \fB\(aq\eA2;\(aq\fP T} _ T{ NBSP T} T{ \fB\(aq\e~\(aq\fP T} _ T{ TAB T} T{ \fB\(aq^I\(aq\fP T} _ .TE .INDENT 0.0 .TP .B class ezdxf.tools.text.ParagraphProperties(indent=0, left=0, right=0, align=DEFAULT, tab_stops=[]) Stores all known MTEXT paragraph properties in a \fBNamedTuple\fP\&. Indentations and tab stops are multiples of the default text height \fBMText.dxf.char_height\fP\&. E.g. \fBchar_height\fP is 0.25 and \fBindent\fP is 4, the real indentation is 4 x 0.25 = 1 drawing unit. The default tabulator stops are 4, 8, 12, … if no tabulator stops are explicit defined. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBindent\fP (\fIfloat\fP) – left indentation of the first line, relative to \fBleft\fP, which means an \fBindent\fP of 0 has always the same indentation as \fBleft\fP .IP \(bu 2 \fBleft\fP (\fIfloat\fP) – left indentation of the paragraph except for the first line .IP \(bu 2 \fBright\fP (\fIfloat\fP) – left indentation of the paragraph .IP \(bu 2 \fBalign\fP – \fI\%MTextParagraphAlignment\fP enum .IP \(bu 2 \fBtab_stops\fP – tuple of tabulator stops, as \fBfloat\fP or as \fBstr\fP, \fBfloat\fP values are left aligned tab stops, strings with prefix \fB\(dqc\(dq\fP are center aligned tab stops and strings with prefix \fB\(dqr\(dq\fP are right aligned tab stops .UNINDENT .UNINDENT .INDENT 7.0 .TP .B tostring() -> str Returns the MTEXT paragraph properties as MTEXT inline code e.g. \fB\(dq\epxi\-2,l2;\(dq\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.const.MTextParagraphAlignment .INDENT 7.0 .TP .B DEFAULT .UNINDENT .INDENT 7.0 .TP .B LEFT .UNINDENT .INDENT 7.0 .TP .B RIGHT .UNINDENT .INDENT 7.0 .TP .B CENTER .UNINDENT .INDENT 7.0 .TP .B JUSTIFIED .UNINDENT .INDENT 7.0 .TP .B DISTRIBUTED .UNINDENT .UNINDENT .SS Single Line Text .INDENT 0.0 .TP .B class ezdxf.tools.text.TextLine(text: str, font: \fI\%fonts.AbstractFont\fP) Helper class which represents a single line text entity (e.g. \fI\%Text\fP). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – content string .IP \(bu 2 \fBfont\fP – ezdxf font definition like \fI\%MonospaceFont\fP or \fI\%TrueTypeFont\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property width: float Returns the final (stretched) text width. .UNINDENT .INDENT 7.0 .TP .B property height: float Returns the final (stretched) text height. .UNINDENT .INDENT 7.0 .TP .B stretch(alignment: \fI\%TextEntityAlignment\fP, p1: \fI\%Vec3\fP, p2: \fI\%Vec3\fP) -> None Set stretch factors for FIT and ALIGNED alignments to fit the text between \fIp1\fP and \fIp2\fP, only the distance between these points is important. Other given \fIalignment\fP values are ignore. .UNINDENT .INDENT 7.0 .TP .B font_measurements() -> \fI\%fonts.FontMeasurements\fP Returns the scaled font measurements. .UNINDENT .INDENT 7.0 .TP .B baseline_vertices(insert: \fI\%UVec\fP, halign: int = 0, valign: int = 0, angle: float = 0, scale: tuple[float, float] = (1, 1)) -> list[\fI\%Vec3\fP] Returns the left and the right baseline vertex of the text line. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinsert\fP – insertion location .IP \(bu 2 \fBhalign\fP – horizontal alignment left=0, center=1, right=2 .IP \(bu 2 \fBvalign\fP – vertical alignment baseline=0, bottom=1, middle=2, top=3 .IP \(bu 2 \fBangle\fP – text rotation in radians .IP \(bu 2 \fBscale\fP – scale in x\- and y\-axis as 2\-tuple of float .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B corner_vertices(insert: \fI\%UVec\fP, halign: int = 0, valign: int = 0, angle: float = 0, scale: tuple[float, float] = (1, 1), oblique: float = 0) -> list[\fI\%Vec3\fP] Returns the corner vertices of the text line in the order bottom left, bottom right, top right, top left. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinsert\fP – insertion location .IP \(bu 2 \fBhalign\fP – horizontal alignment left=0, center=1, right=2 .IP \(bu 2 \fBvalign\fP – vertical alignment baseline=0, bottom=1, middle=2, top=3 .IP \(bu 2 \fBangle\fP – text rotation in radians .IP \(bu 2 \fBscale\fP – scale in x\- and y\-axis as 2\-tuple of float .IP \(bu 2 \fBoblique\fP – shear angle (slanting) in x\-direction in radians .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static transform_2d(vertices: Iterable[\fI\%UVec\fP], insert: \fI\%UVec\fP = Vec3(0, 0, 0), shift: tuple[float, float] = (0, 0), rotation: float = 0, scale: tuple[float, float] = (1, 1), oblique: float = 0) -> list[\fI\%Vec3\fP] Transform any vertices from the text line located at the base location at (0, 0) and alignment LEFT. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – iterable of vertices .IP \(bu 2 \fBinsert\fP – insertion location .IP \(bu 2 \fBshift\fP – (shift\-x, shift\-y) as 2\-tuple of float .IP \(bu 2 \fBrotation\fP – text rotation in radians .IP \(bu 2 \fBscale\fP – (scale\-x, scale\-y) as 2\-tuple of float .IP \(bu 2 \fBoblique\fP – shear angle (slanting) in x\-direction in radians .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Functions .INDENT 0.0 .TP .B ezdxf.tools.text.caret_decode(text: str) -> str DXF stores some special characters using caret notation. This function decodes this notation to normalise the representation of special characters in the string. .sp see: \fI\%https://en.wikipedia.org/wiki/Caret_notation\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.estimate_mtext_content_extents(content: str, font: \fI\%fonts.AbstractFont\fP, column_width: float = 0.0, line_spacing_factor: float = 1.0) -> tuple[float, float] Estimate the width and height of the \fI\%MText\fP content string. The result is very inaccurate if inline codes are used or line wrapping at the column border is involved! Column breaks \fB\eN\fP will be ignored. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontent\fP – the \fI\%MText\fP content string .IP \(bu 2 \fBfont\fP – font abstraction based on \fBezdxf.tools.fonts.AbstractFont\fP .IP \(bu 2 \fBcolumn_width\fP – \fBMText.dxf.width\fP or 0.0 for an unrestricted column width .IP \(bu 2 \fBline_spacing_factor\fP – \fBMText.dxf.line_spacing_factor\fP .UNINDENT .TP .B Returns tuple[width, height] .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.estimate_mtext_extents(mtext: \fI\%MText\fP) -> tuple[float, float] Estimate the width and height of a single column \fI\%MText\fP entity. .sp This function is faster than the \fI\%mtext_size()\fP function, but the result is very inaccurate if inline codes are used or line wrapping at the column border is involved! .INDENT 7.0 .TP .B Returns Tuple[width, height] .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.fast_plain_mtext(text: str, split=False) -> list[str] | str Returns the plain MTEXT content as a single string or a list of strings if \fIsplit\fP is \fBTrue\fP\&. Replaces \fB\eP\fP by \fB\en\fP and removes other controls chars and inline codes. .sp This function is more than 4x faster than \fI\%plain_mtext()\fP, but does not remove single letter inline commands with arguments without a terminating semicolon like this \fB\(dq\eC1red text\(dq\fP\&. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 Well behaved CAD applications and libraries always create inline codes for commands with arguments with a terminating semicolon like this \fB\(dq\eC1;red text\(dq\fP! .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – MTEXT content string .IP \(bu 2 \fBsplit\fP – split content at line endings \fB\eP\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.is_text_vertical_stacked(text: \fI\%DXFEntity\fP) -> bool Returns \fBTrue\fP if the associated text \fI\%Textstyle\fP is vertical stacked. .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.is_upside_down_text_angle(angle: float, tol: float = 3.0) -> bool Returns \fBTrue\fP if the given text \fIangle\fP in degrees causes an upside down text in the \fI\%WCS\fP\&. The strict flip range is 90° < \fIangle\fP < 270°, the tolerance angle \fItol\fP extends this range to: 90+tol < \fIangle\fP < 270\-tol. The angle is normalized to [0, 360). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP – text angle in degrees .IP \(bu 2 \fBtol\fP – tolerance range in which text flipping will be avoided .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.leading(cap_height: float, line_spacing: float = 1.0) -> float Returns the distance from baseline to baseline. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcap_height\fP – cap height of the line .IP \(bu 2 \fBline_spacing\fP – line spacing factor as percentage of 3\-on\-5 spacing .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.plain_mtext(text: str, split=False, tabsize: int = 4) -> list[str] | str Returns the plain MTEXT content as a single string or a list of strings if \fIsplit\fP is \fBTrue\fP\&. Replaces \fB\eP\fP by \fB\en\fP and removes other controls chars and inline codes. .sp This function is much slower than \fI\%fast_plain_mtext()\fP, but removes all inline codes. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – MTEXT content string .IP \(bu 2 \fBsplit\fP – split content at line endings \fB\eP\fP .IP \(bu 2 \fBtabsize\fP – count of replacement spaces for tabulators \fB^I\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.plain_text(text: str) -> str Returns the plain text for \fI\%Text\fP, \fI\%Attrib\fP and \fBAttdef\fP content. .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.safe_string(s: str | None, max_len: int = MAX_STR_LEN) -> str Returns a string with line breaks \fB\en\fP replaced by \fB\eP\fP and the length limited to \fImax_len\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.text_wrap(text: str, box_width: float | None, get_text_width: Callable[[str], float]) -> list[str] Wrap text at \fB\en\fP and given \fIbox_width\fP\&. This tool was developed for usage with the MTEXT entity. This isn’t the most straightforward word wrapping algorithm, but it aims to match the behavior of AutoCAD. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – text to wrap, included \fB\en\fP are handled as manual line breaks .IP \(bu 2 \fBbox_width\fP – wrapping length, \fBNone\fP to just wrap at \fB\en\fP .IP \(bu 2 \fBget_text_width\fP – callable which returns the width of the given string .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text.upright_text_angle(angle: float, tol: float = 3.0) -> float Returns a readable (upright) text angle in the range \fIangle\fP <= 90+tol or \fIangle\fP >= 270\-tol. The angle is normalized to [0, 360). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP – text angle in degrees .IP \(bu 2 \fBtol\fP – tolerance range in which text flipping will be avoided .UNINDENT .UNINDENT .UNINDENT .SS Text Size Tools .INDENT 0.0 .TP .B class ezdxf.tools.text_size.TextSize A frozen dataclass as return type for the \fI\%text_size()\fP function. .INDENT 7.0 .TP .B width The text width in drawing units (float). .UNINDENT .INDENT 7.0 .TP .B cap_height The font cap\-height in drawing units (float). .UNINDENT .INDENT 7.0 .TP .B total_height The font total\-height = cap\-height + descender\-height in drawing units (float). .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text_size.text_size(text: Text) -> \fI\%TextSize\fP Returns the measured text width, the font cap\-height and the font total\-height for a \fI\%Text\fP entity. This function uses the optional \fIMatplotlib\fP package if available to measure the final rendering width and font\-height for the \fBText\fP entity as close as possible. This function does not measure the real char height! Without access to the \fIMatplotlib\fP package the \fBMonospaceFont\fP is used and the measurements are very inaccurate. .sp See the \fI\%text2path\fP add\-on for more tools to work with the text path objects created by the \fIMatplotlib\fP package. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.tools.text_size.MTextSize A frozen dataclass as return type for the \fI\%mtext_size()\fP function. .INDENT 7.0 .TP .B total_width The total width in drawing units (float) .UNINDENT .INDENT 7.0 .TP .B total_height The total height in drawing units (float), same as \fBmax(column_heights)\fP\&. .UNINDENT .INDENT 7.0 .TP .B column_width The width of a single column in drawing units (float) .UNINDENT .INDENT 7.0 .TP .B gutter_width The space between columns in drawing units (float) .UNINDENT .INDENT 7.0 .TP .B column_heights A tuple of columns heights (float) in drawing units. Contains at least one column height and the column height is 0 for an empty column. .UNINDENT .INDENT 7.0 .TP .B column_count The count of columns (int). .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text_size.mtext_size(mtext: MText, tool: MTextSizeDetector | None = None) -> \fI\%MTextSize\fP Returns the total\-width, \-height and columns information for a \fI\%MText\fP entity. .sp This function uses the optional \fIMatplotlib\fP package if available to do font measurements and the internal text layout engine to determine the final rendering size for the \fBMText\fP entity as close as possible. Without access to the \fIMatplotlib\fP package the \fBMonospaceFont\fP is used and the measurements are very inaccurate. .sp Attention: The required full layout calculation is slow! .sp The first call to this function with \fIMatplotlib\fP support is very slow, because \fIMatplotlib\fP lookup all available fonts on the system. To speedup the calculation and accepting inaccurate results you can disable the \fIMatplotlib\fP support manually: .INDENT 7.0 .INDENT 3.5 .sp .EX ezdxf.option.use_matplotlib = False .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.text_size.estimate_mtext_extents(mtext: \fI\%MText\fP) -> tuple[float, float] Estimate the width and height of a single column \fI\%MText\fP entity. .sp This function is faster than the \fI\%mtext_size()\fP function, but the result is very inaccurate if inline codes are used or line wrapping at the column border is involved! .INDENT 7.0 .TP .B Returns Tuple[width, height] .UNINDENT .UNINDENT .SS ACIS Tools .sp The \fI\%ezdxf.acis\fP sub\-package provides some \fI\%ACIS\fP data management tools. The main goals of this tools are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP 1. 3 load and parse simple and known \fI\%ACIS\fP data structures .IP 2. 3 create and export simple and known \fI\%ACIS\fP data structures .UNINDENT .UNINDENT .UNINDENT .sp It is NOT a goal to load and edit arbitrary existing \fI\%ACIS\fP structures. .INDENT 0.0 .INDENT 3.5 Don’t even try it! .UNINDENT .UNINDENT .sp These tools cannot replace the official \fI\%ACIS\fP SDK due to the complexity of the data structures and the absence of an \fI\%ACIS\fP kernel. Without access to the full documentation it is very cumbersome to reverse\-engineer entities and their properties, therefore the analysis of the \fI\%ACIS\fP data structures is limited to the use as embedded data in DXF and DWG files. .sp The \fIezdxf\fP library does not provide an \fI\%ACIS\fP kernel and there are no plans for implementing one because this is far beyond my capabilities, but it is possible to extract geometries made up only by flat polygonal faces (polyhedron) from ACIS data. Exporting polyhedrons as ACIS data and loading this DXF file by Autodesk products or BricsCAD works for \fI\%SAT\fP data for DXF R2000\-R2010 and for \fI\%SAB\fP data for DXF R2013\-R2018. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 Always import from the public interface module \fI\%ezdxf.acis.api\fP, the internal package and module structure may change in the future and imports from other modules than \fBapi\fP will break. .UNINDENT .UNINDENT .SS Functions .INDENT 0.0 .TP .B ezdxf.acis.api.load_dxf(entity: DXFEntity) -> list[\fI\%Body\fP] Load the \fI\%ACIS\fP bodies from the given DXF entity. This is the recommended way to load ACIS data. .sp The DXF entity has to be an ACIS based entity and inherit from \fI\%ezdxf.entities.Body\fP\&. The entity has to be bound to a valid DXF document and the DXF version of the document has to be DXF R2000 or newer. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFTypeError\fP – invalid DXF entity type .IP \(bu 2 \fI\%DXFValueError\fP – invalid DXF document .IP \(bu 2 \fI\%DXFVersionError\fP – invalid DXF version .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 Only a limited count of \fI\%ACIS\fP entities is supported, all unsupported entities are loaded as \fBNONE_ENTITY\fP and their data is lost. Exporting such \fBNONE_ENTITIES\fP will raise an \fI\%ExportError\fP exception. .sp To emphasize that again: \fBIt is not possible to load and re\-export arbitrary ACIS data!\fP .UNINDENT .UNINDENT .UNINDENT .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.acis import api as acis doc = ezdxf.readfile(\(dqyour.dxf\(dq) msp = doc.modelspace() for e in msp.query(\(dq3DSOLID\(dq): bodies = acis.load_dxf(e) ... .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.acis.api.export_dxf(entity: DXFEntity, bodies: Sequence[\fI\%Body\fP]) Store the \fI\%ACIS\fP bodies in the given DXF entity. This is the recommended way to set ACIS data of DXF entities. .sp The DXF entity has to be an ACIS based entity and inherit from \fI\%ezdxf.entities.Body\fP\&. The entity has to be bound to a valid DXF document and the DXF version of the document has to be DXF R2000 or newer. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFTypeError\fP – invalid DXF entity type .IP \(bu 2 \fI\%DXFValueError\fP – invalid DXF document .IP \(bu 2 \fI\%DXFVersionError\fP – invalid DXF version .UNINDENT .UNINDENT .UNINDENT .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.render import forms from ezdxf.acis import api as acis doc = ezdxf.new(\(dqR2000\(dq) msp = doc.modelspace() # create an ACIS body from a simple cube\-mesh body = acis.body_from_mesh(forms.cube()) solid3d = msp.add_3dsolid() acis.export_dxf(solid3d, [body]) doc.saveas(\(dqcube.dxf\(dq) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.acis.api.load(data: str | Sequence[str] | bytes | bytearray) -> list[\fI\%Body\fP] Returns a list of \fBBody\fP entities from \fI\%SAT\fP or \fI\%SAB\fP data. Accepts \fI\%SAT\fP data as a single string or a sequence of strings and \fI\%SAB\fP data as bytes or bytearray. .UNINDENT .INDENT 0.0 .TP .B ezdxf.acis.api.export_sat(bodies: Sequence[\fI\%Body\fP], version: int = const.DEFAULT_SAT_VERSION) -> list[str] Export one or more \fBBody\fP entities as text based \fI\%SAT\fP data. .sp ACIS version 700 is sufficient for DXF versions R2000, R2004, R2007 and R2010, later DXF versions require \fI\%SAB\fP data. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%ExportError\fP – ACIS structures contain unsupported entities .IP \(bu 2 \fI\%InvalidLinkStructure\fP – corrupt link structure .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.acis.api.export_sab(bodies: Sequence[\fI\%Body\fP], version: int = const.DEFAULT_SAB_VERSION) -> bytes Export one or more \fBBody\fP entities as binary encoded \fI\%SAB\fP data. .sp ACIS version 21800 is sufficient for DXF versions R2013 and R2018, earlier DXF versions require \fI\%SAT\fP data. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%ExportError\fP – ACIS structures contain unsupported entities .IP \(bu 2 \fI\%InvalidLinkStructure\fP – corrupt link structure .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.acis.api.mesh_from_body(body: \fI\%Body\fP, merge_lumps=True) -> list[MeshTransformer] Returns a list of \fI\%MeshTransformer\fP instances from the given ACIS \fBBody\fP entity. The list contains multiple meshes if \fImerge_lumps\fP is \fBFalse\fP or just a single mesh if \fImerge_lumps\fP is \fBTrue\fP\&. .sp The ACIS format stores the faces in counter\-clockwise orientation where the face\-normal points outwards (away) from the solid body (material). .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 This function returns meshes build up only from flat polygonal \fBFace\fP entities, for a tessellation of more complex ACIS entities (spline surfaces, tori, cones, …) is an ACIS kernel required which \fIezdxf\fP does not provide. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbody\fP – ACIS entity of type \fBBody\fP .IP \(bu 2 \fBmerge_lumps\fP – returns all \fBLump\fP entities from a body as a single mesh if \fBTrue\fP otherwise each \fBLump\fP entity is a separated mesh .UNINDENT .TP .B Raises \fBTypeError\fP – given \fIbody\fP entity has invalid type .UNINDENT .UNINDENT .sp The following images show the limitations of the \fI\%mesh_from_body()\fP function. The first image shows the source \fB3DSOLID\fP entities with subtraction of entities with flat and curved faces: [image] .sp Example script to extracts all flat polygonal faces as meshes: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.acis import api as acis doc = ezdxf.readfile(\(dq3dsolids.dxf\(dq) msp = doc.modelspace() doc_out = ezdxf.new() msp_out = doc_out.modelspace() for e in msp.query(\(dq3DSOLID\(dq): for body in acis.load_dxf(data): for mesh in acis.mesh_from_body(body): mesh.render_mesh(msp_out) doc_out.saveas(\(dqmeshes.dxf\(dq) .EE .UNINDENT .UNINDENT .sp The second image shows the flat faces extracted from the \fB3DSOLID\fP entities and exported as \fI\%Mesh\fP entities: [image] .sp As you can see all faces which do not have straight lines as boundaries are lost. .INDENT 0.0 .TP .B ezdxf.acis.api.body_from_mesh(mesh: MeshBuilder, precision: int = 6) -> \fI\%Body\fP Returns a \fI\%ACIS\fP \fI\%Body\fP entity from a \fI\%MeshBuilder\fP instance. .sp This entity can be assigned to a \fI\%Solid3d\fP DXF entity as \fI\%SAT\fP or \fI\%SAB\fP data according to the version your DXF document uses (SAT for DXF R2000 to R2010 and SAB for DXF R2013 and later). .sp If the \fImesh\fP contains multiple separated meshes, each mesh will be a separated \fI\%Lump\fP node. If each mesh should get its own \fI\%Body\fP entity, separate the meshes beforehand by the method \fI\%separate_meshes\fP\&. .sp A closed mesh creates a solid body and an open mesh creates an open (hollow) shell. The detection if the mesh is open or closed is based on the edges of the mesh: if \fBall\fP edges of mesh have two adjacent faces the mesh is closed. .sp The current implementation applies automatically a vertex optimization, which merges coincident vertices into a single vertex. .UNINDENT .SS Exceptions .INDENT 0.0 .TP .B class ezdxf.acis.api.AcisException Base exception of the \fI\%ezdxf.acis\fP package. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.acis.api.ParsingError Exception raised when loading invalid or unknown \fI\%ACIS\fP structures. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.acis.api.ExportError Exception raised when exporting invalid or unknown \fI\%ACIS\fP structures. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.acis.api.InvalidLinkStructure Exception raised when the internal link structure is damaged. .UNINDENT .SS Entities .sp A document (\fI\%sat.pdf\fP) about the basic ACIS 7.0 file format is floating in the internet. .sp This section contains the additional information about the entities, I got from analyzing the SAT data extracted from DXF files exported by BricsCAD. .sp This documentation ignores the differences to the ACIS format prior to version 7.0 and all this differences are handled internally. .sp Writing support for ACIS version < 7.0 is not required because all CAD applications should be able to process version 7.0, even if embedded in a very old DXF R2000 format (tested with Autodesk TrueView, BricsCAD and Nemetschek Allplan). .sp The first goal is to document the entities which are required to represent a geometry as flat polygonal faces (polyhedron), which can be converted into a \fI\%MeshBuilder\fP object. .sp Topology Entities: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Body\fP .IP \(bu 2 \fI\%Lump\fP .IP \(bu 2 \fI\%Shell\fP .IP \(bu 2 \fI\%Face\fP .IP \(bu 2 \fI\%Loop\fP .IP \(bu 2 \fI\%Coedge\fP .IP \(bu 2 \fI\%Edge\fP .IP \(bu 2 \fI\%Vertex\fP .UNINDENT .UNINDENT .UNINDENT .sp Geometry Entities: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Transform\fP .IP \(bu 2 \fI\%Surface\fP .IP \(bu 2 \fI\%Plane\fP .IP \(bu 2 \fI\%Curve\fP .IP \(bu 2 \fI\%StraightCurve\fP .IP \(bu 2 \fI\%Point\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.acis.entities.NONE_REF Special sentinel entity which supports the \fBtype\fP attribute and the \fBis_none\fP property. Represents all unset entities. Use this idiom on any entity type to check if an entity is unset: .INDENT 7.0 .INDENT 3.5 .sp .EX if entity.is_none: ... .EE .UNINDENT .UNINDENT .UNINDENT .SS AcisEntity .INDENT 0.0 .TP .B class ezdxf.acis.entities.AcisEntity Base class for all ACIS entities. .INDENT 7.0 .TP .B type Name of the type as str. .UNINDENT .INDENT 7.0 .TP .B id Unique id as int or \-1 if not set. .UNINDENT .INDENT 7.0 .TP .B attributes Reference to the first \fBAttribute\fP entity (not supported). .UNINDENT .INDENT 7.0 .TP .B is_none \fBTrue\fP for unset entities represented by the \fI\%NONE_REF\fP instance. .UNINDENT .UNINDENT .SS Transform .INDENT 0.0 .TP .B class ezdxf.acis.entities.Transform(AcisEntity) Represents an affine transformation operation which transform the \fBbody\fP to the final location, size and rotation. .INDENT 7.0 .TP .B matrix Transformation matrix of type \fI\%ezdxf.math.Matrix44\fP\&. .UNINDENT .UNINDENT .SS Body .INDENT 0.0 .TP .B class ezdxf.acis.entities.Body(AcisEntity) Represents a solid geometry, which can consist of multiple \fI\%Lump\fP entities. .INDENT 7.0 .TP .B pattern Reference to the \fI\%Pattern\fP entity. .UNINDENT .INDENT 7.0 .TP .B lump Reference to the first \fI\%Lump\fP entity .UNINDENT .INDENT 7.0 .TP .B wire Reference to the first \fI\%Wire\fP entity .UNINDENT .INDENT 7.0 .TP .B transform Reference to the \fI\%Transform\fP entity (optional) .UNINDENT .INDENT 7.0 .TP .B lumps() -> list[\fI\%Lump\fP] Returns all linked \fI\%Lump\fP entities as a list. .UNINDENT .INDENT 7.0 .TP .B append_lump(lump: \fI\%Lump\fP) -> None Append a \fI\%Lump\fP entity as last lump. .UNINDENT .UNINDENT .SS Pattern .INDENT 0.0 .TP .B class ezdxf.acis.entities.Pattern(AcisEntity) Not implemented. .UNINDENT .SS Lump .INDENT 0.0 .TP .B class ezdxf.acis.entities.Lump(AcisEntity) The lump represents a connected entity and there can be multiple lumps in a \fI\%Body\fP\&. Multiple lumps are linked together by the \fI\%next_lump\fP attribute which points to the next lump entity the last lump has a \fBNONE_REF\fP as next lump. The \fI\%body\fP attribute references to the parent \fI\%Body\fP entity. .INDENT 7.0 .TP .B next_lump Reference to the next \fI\%Lump\fP entity, the last lump references \fI\%NONE_REF\fP\&. .UNINDENT .INDENT 7.0 .TP .B shell Reference to the \fI\%Shell\fP entity. .UNINDENT .INDENT 7.0 .TP .B body Reference to the parent \fI\%Body\fP entity. .UNINDENT .INDENT 7.0 .TP .B shells() -> list[\fI\%Shell\fP] Returns all linked \fI\%Shell\fP entities as a list. .UNINDENT .INDENT 7.0 .TP .B append_shell(shell: \fI\%Shell\fP) -> None Append a \fI\%Shell\fP entity as last shell. .UNINDENT .UNINDENT .SS Wire .INDENT 0.0 .TP .B class ezdxf.acis.entities.Wire(AcisEntity) Not implemented. .UNINDENT .SS Shell .INDENT 0.0 .TP .B class ezdxf.acis.entities.Shell(AcisEntity) A shell defines the boundary of a solid object or a void (subtraction object). A shell references a list of \fI\%Face\fP and \fI\%Wire\fP entities. All linked \fI\%Shell\fP entities are disconnected. .INDENT 7.0 .TP .B next_shell Reference to the next \fI\%Shell\fP entity, the last shell references \fI\%NONE_REF\fP\&. .UNINDENT .INDENT 7.0 .TP .B subshell Reference to the first \fI\%Subshell\fP entity. .UNINDENT .INDENT 7.0 .TP .B face Reference to the first \fI\%Face\fP entity. .UNINDENT .INDENT 7.0 .TP .B wire Reference to the first \fI\%Wire\fP entity. .UNINDENT .INDENT 7.0 .TP .B lump Reference to the parent \fI\%Lump\fP entity. .UNINDENT .INDENT 7.0 .TP .B faces() -> list[\fI\%Face\fP] Returns all linked \fI\%Face\fP entities as a list. .UNINDENT .INDENT 7.0 .TP .B append_face(face: \fI\%Face\fP) -> None Append a \fI\%Face\fP entity as last face. .UNINDENT .UNINDENT .SS Subshell .INDENT 0.0 .TP .B class ezdxf.acis.entities.Subshell(AcisEntity) Not implemented. .UNINDENT .SS Face .INDENT 0.0 .TP .B class ezdxf.acis.entities.Face(AcisEntity) A face is the building block for \fI\%Shell\fP entities. The boundary of a face is represented by one or more \fI\%Loop\fP entities. The spatial geometry of the face is defined by the \fI\%surface\fP object, which is a bounded or unbounded parametric 3d surface (plane, ellipsoid, spline\-surface, …). .INDENT 7.0 .TP .B next_face Reference to the next \fI\%Face\fP entity, the last face references \fI\%NONE_REF\fP\&. .UNINDENT .INDENT 7.0 .TP .B loop Reference to the first \fI\%Loop\fP entity. .UNINDENT .INDENT 7.0 .TP .B shell Reference to the parent \fI\%Shell\fP entity. .UNINDENT .INDENT 7.0 .TP .B subshell Reference to the parent \fI\%Subshell\fP entity. .UNINDENT .INDENT 7.0 .TP .B surface Reference to the parametric \fI\%Surface\fP geometry. .UNINDENT .INDENT 7.0 .TP .B sense Boolean value of direction of the face normal with respect to the \fI\%Surface\fP entity: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBTrue\fP: “reversed” direction of the face normal .IP \(bu 2 \fBFalse\fP: “forward” for same direction of the face normal .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B double_sided Boolean value which indicates the sides of the face: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBTrue\fP: the face is part of a hollow object and has two sides. .IP \(bu 2 \fBFalse\fP: the face is part of a solid object and has only one side which points away from the “material”. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B containment Unknown meaning. .sp If \fI\%double_sided\fP is \fBTrue\fP: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBTrue\fP is “in” .IP \(bu 2 \fBFalse\fP is “out” .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B loops() -> list[\fI\%Loop\fP] Returns all linked \fI\%Loop\fP entities as a list. .UNINDENT .INDENT 7.0 .TP .B append_loop(loop: \fI\%Loop\fP) -> None Append a \fI\%Loop\fP entity as last loop. .UNINDENT .UNINDENT .SS Loop .INDENT 0.0 .TP .B class ezdxf.acis.entities.Loop(AcisEntity) A loop represents connected coedges which are building the boundaries of a \fI\%Face\fP, there can be multiple loops for a single face e.g. faces can contain holes. The \fI\%coedge\fP attribute references the first \fI\%Coedge\fP of the loop, the additional coedges are linked to this first \fI\%Coedge\fP\&. In closed loops the coedges are organized as a circular list, in open loops the last coedge references the \fI\%NONE_REF\fP entity as \fBnext_coedge\fP and the first coedge references the \fI\%NONE_REF\fP as \fBprev_coedge\fP\&. .INDENT 7.0 .TP .B next_loop Reference to the next \fI\%Loop\fP entity, the last loop references \fI\%NONE_REF\fP\&. .UNINDENT .INDENT 7.0 .TP .B coedge Reference to the first \fI\%Coedge\fP entity. .UNINDENT .INDENT 7.0 .TP .B face Reference to the parent \fI\%Face\fP entity. .UNINDENT .INDENT 7.0 .TP .B coedges() -> list[\fI\%Coedge\fP] Returns all linked \fI\%Coedge\fP entities as a list. .UNINDENT .INDENT 7.0 .TP .B set_coedges(coedges: list[\fI\%Coedge\fP], close=True) -> None Set all coedges of a loop at once. .UNINDENT .UNINDENT .SS Coedge .INDENT 0.0 .TP .B class ezdxf.acis.entities.Coedge(AcisEntity) The coedges are a double linked list where \fI\%next_coedge\fP points to the next \fI\%Coedge\fP and \fI\%prev_coedge\fP to the previous \fI\%Coedge\fP\&. .sp The \fI\%partner_coedge\fP attribute references the first partner \fI\%Coedge\fP of an adjacent \fI\%Face\fP, the partner edges are organized as a circular list. In a manifold closed surface each \fI\%Face\fP is connected to one partner face by an \fI\%Coedge\fP\&. In a non\-manifold surface a face can have more than one partner face. .INDENT 7.0 .TP .B next_coedge References the next \fI\%Coedge\fP, reference the \fI\%NONE_REF\fP if it is the last coedge in an open \fI\%Loop\fP\&. .UNINDENT .INDENT 7.0 .TP .B prev_coedge References the previous \fI\%Coedge\fP, reference the \fI\%NONE_REF\fP if it is the first coedge in an open \fI\%Loop\fP\&. .UNINDENT .INDENT 7.0 .TP .B partner_coedge References the partner \fI\%Coedge\fP of an adjacent \fI\%Face\fP entity. The partner coedges are organized in a circular list. .UNINDENT .INDENT 7.0 .TP .B edge References the \fI\%Edge\fP entity. .UNINDENT .INDENT 7.0 .TP .B loop References the parent \fI\%Loop\fP entity. .UNINDENT .INDENT 7.0 .TP .B pcurve References the \fI\%PCurve\fP entity. .UNINDENT .UNINDENT .SS Edge .INDENT 0.0 .TP .B class ezdxf.acis.entities.Edge(AcisEntity) The \fI\%Edge\fP entity represents the physical edge of an object. Its geometry is defined by the bounded portion of a parametric space curve. This bounds are stored as object\-space \fI\%Vertex\fP entities. .INDENT 7.0 .TP .B start_vertex The start \fI\%Vertex\fP of the space\-curve in object coordinates, if \fI\%NONE_REF\fP the curve is unbounded in this direction. .UNINDENT .INDENT 7.0 .TP .B start_param The parametric starting bound for the parametric curve. Evaluating the \fI\%curve\fP for this parameter should return the coordinates of the \fI\%start_vertex\fP\&. .UNINDENT .INDENT 7.0 .TP .B end_vertex The end \fI\%Vertex\fP of the space\-curve in object coordinates, if \fI\%NONE_REF\fP the curve is unbounded in this direction. .UNINDENT .INDENT 7.0 .TP .B end_param The parametric end bound for the parametric curve. .UNINDENT .INDENT 7.0 .TP .B coedge Parent \fI\%Coedge\fP of this edge. .UNINDENT .INDENT 7.0 .TP .B curve The parametric space\-curve which defines this edge. The curve can be the \fBNULL_REF\fP while both \fI\%Vertex\fP entities are the same vertex. In this case the \fI\%Edge\fP represents an single point like the apex of a cone. .UNINDENT .INDENT 7.0 .TP .B sense Boolean value which indicates the direction of the edge: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBTrue\fP: the edge has the “reversed” direction as the underlying curve .IP \(bu 2 \fBFalse\fP: the edge has the same direction as the underlying curve (“forward”) .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B convexity Unknown meaning, always the string “unknown”. .UNINDENT .UNINDENT .SS Vertex .INDENT 0.0 .TP .B class ezdxf.acis.entities.Vertex(AcisEntity) Represents a vertex of an \fI\%Edge\fP entity and references a \fI\%Point\fP entity. .INDENT 7.0 .TP .B point The spatial location in object\-space as \fI\%Point\fP entity. .UNINDENT .INDENT 7.0 .TP .B edge Parent \fI\%Edge\fP of this vertex. The vertex can be referenced by multiple edges, anyone of them can be the parent of the vertex. .UNINDENT .UNINDENT .SS Surface .INDENT 0.0 .TP .B class ezdxf.acis.entities.Surface(AcisEntity) Abstract base class for all parametric surfaces. .sp The parameterization of any \fI\%Surface\fP maps a 2D rectangle (u, v parameters) into the spatial object\-space (x, y, z). .INDENT 7.0 .TP .B u_bounds Tuple of (start bound, end bound) parameters as two floats which define the bounds of the parametric surface in the u\-direction, one or both values can be \fBmath.inf\fP which indicates an unbounded state of the surface in that direction. .UNINDENT .INDENT 7.0 .TP .B v_bounds Tuple of (start bound, end bound) parameters as two floats which define the bounds of the parametric surface in the v\-direction, one or both values can be \fBmath.inf\fP which indicates an unbounded state of the surface in that direction. .UNINDENT .INDENT 7.0 .TP .B abstract evaluate(u: float, v: float) -> \fI\%Vec3\fP Returns the spatial location at the parametric surface for the given parameters \fIu\fP and \fIv\fP\&. .UNINDENT .UNINDENT .SS Plane .INDENT 0.0 .TP .B class ezdxf.acis.entities.Plane(Surface) Defines a flat plan as parametric surface. .INDENT 7.0 .TP .B origin Location vector of the origin of the flat plane as \fI\%Vec3\fP\&. .UNINDENT .INDENT 7.0 .TP .B normal Normal vector of the plane as \fI\%Vec3\fP\&. Has to be an unit\-vector! .UNINDENT .INDENT 7.0 .TP .B u_dir Direction vector of the plane in u\-direction as \fI\%Vec3\fP\&. Has to be an unit\-vector! .UNINDENT .INDENT 7.0 .TP .B v_dir Direction vector of the plane in v\-direction as \fI\%Vec3\fP\&. Has to be an unit\-vector! .UNINDENT .INDENT 7.0 .TP .B reverse_v Boolean value which indicates the orientation of the coordinate system: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBTrue\fP: left\-handed system, the v\-direction is reversed and the normal vector is \fI\%v_dir\fP cross \fI\%u_dir\fP\&. .IP \(bu 2 \fBFalse\fP: right\-handed system and the normal vector is \fI\%u_dir\fP cross \fI\%v_dir\fP\&. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Curve .INDENT 0.0 .TP .B class ezdxf.acis.entities.Curve(AcisEntity) Abstract base class for all parametric curves. .sp The parameterization of any \fI\%Curve\fP maps a 1D line (the parameter) into the spatial object\-space (x, y, z). .INDENT 7.0 .TP .B bounds Tuple of (start bound, end bound) parameters as two floats which define the bounds of the parametric curve, one or both values can be \fBmath.inf\fP which indicates an unbounded state of the curve in that direction. .UNINDENT .INDENT 7.0 .TP .B abstract evaluate(param: float) -> \fI\%Vec3\fP Returns the spatial location at the parametric curve for the given parameter. .UNINDENT .UNINDENT .SS StraightCurve .INDENT 0.0 .TP .B class ezdxf.acis.entities.StraightCurve(Curve) Defines a straight line as parametric curve. .INDENT 7.0 .TP .B origin Location vector of the origin of the straight line as \fI\%Vec3\fP\&. .UNINDENT .INDENT 7.0 .TP .B direction Direction vector the straight line as \fI\%Vec3\fP\&. Has to be an unit\-vector! .UNINDENT .UNINDENT .SS PCurve .INDENT 0.0 .TP .B class ezdxf.acis.entities.PCurve(AcisEntity) Not implemented. .UNINDENT .SS Point .INDENT 0.0 .TP .B class ezdxf.acis.entities.Point(AcisEntity) Represents a point in the 3D object\-space. .INDENT 7.0 .TP .B location Cartesian coordinates as \fI\%Vec3\fP\&. .UNINDENT .UNINDENT .SS Global Options .SS Global Options Object .sp The global \fIezdxf\fP options are stored in the object \fI\%ezdxf.options\fP\&. .sp Recommended usage of the global \fBoptions\fP object: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf value = ezdxf.options.attribute .EE .UNINDENT .UNINDENT .sp The \fBoptions\fP object uses the Standard Python class \fBConfigParser\fP to manage the configuration. Shortcut attributes like \fI\%test_files\fP are simple properties and most shortcuts are read only marked by (Read only), read and writeable attributes are marked by (Read/Write). .sp To change options, especially the read only attributes, you have to edit the config file with a text editor, or set options by the \fI\%set()\fP method and write the current configuration into a config file. .SS Config Files .sp The default config files are loaded from the user home directory as “~/.config/ezdxf/ezdxf.ini”, and the current working directory as “./ezdxf.ini”. A custom config file can be specified by the environment variable \fBEZDXF_CONFIG_FILE\fP\&. Ezdxf follows the \fI\%XDG Base Directory specification\fP if the environment variable \fBXDG_CONFIG_HOME\fP is set. .sp The config file loading order: .INDENT 0.0 .IP 1. 3 user home directory: “~/.config/ezdxf/ezdxf.ini” .IP 2. 3 current working directory: “./ezdxf.ini” .IP 3. 3 config file specified by \fBEZDXF_CONFIG_FILE\fP .UNINDENT .sp A configuration file that is loaded later does not replace the previously loaded ones, only the existing options in the newly loaded file are added to the configuration and can overwrite existing options. .sp Configuration files are regular INI files, managed by the standard Python \fI\%ConfigParser\fP class. .sp File Structure: .INDENT 0.0 .INDENT 3.5 .sp .EX [core] default_dimension_text_style = OpenSansCondensed\-Light test_files = D:\eSource\edxftest support_dirs = \(dqC:\eProgram Files\eBricsys\eBricsCAD V23 en_US\eFonts\(dq, \(dq~/dir2\(dq, \(dq~/dir3\(dq, load_proxy_graphics = true store_proxy_graphics = true log_unprocessed_tags = false filter_invalid_xdata_group_codes = true write_fixed_meta_data_for_testing = false disable_c_ext = false [browse\-command] text_editor = \(dqC:\eProgram Files\eNotepad++\enotepad++.exe\(dq \(dq{filename}\(dq \-n{num} .EE .UNINDENT .UNINDENT .SS Modify and Save Changes .sp This code shows how to get and set values of the underlying \fBConfigParser\fP object, but use the shortcut attributes if available: .INDENT 0.0 .INDENT 3.5 .sp .EX # Set options, value has to ba a str, use \(dqtrue\(dq/\(dqfalse\(dq for boolean values ezdxf.options.set(section, key, value) # Get option as string value = ezdxf.options.get(section, key, default=\(dq\(dq) # Special getter for boolean, int and float value = ezdxf.options.get_bool(section, key, default=False) value = ezdxf.options.get_int(section, key, default=0) value = ezdxf.options.get_float(section, key, default=0.0) .EE .UNINDENT .UNINDENT .sp If you set options, they are not stored automatically in a config file, you have to write back the config file manually: .INDENT 0.0 .INDENT 3.5 .sp .EX # write back the default user config file \(dqezdxf.ini\(dq in the # user home directory ezdxf.options.write_home_config() # write back to the default config file \(dqezdxf.ini\(dq in the # current working directory ezdxf.options.write_file() # write back to a specific config file ezdxf.options.write_file(\(dqmy_config.ini\(dq) # which has to be loaded manually at startup ezdxf.options.read_file(\(dqmy_config.ini\(dq) .EE .UNINDENT .UNINDENT .sp This example shows how to change the \fI\%test_files\fP path and save the changes into a custom config file “my_config.ini”: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf test_files = Path(\(dq~/my\-dxf\-test\-files\(dq).expand_user() ezdxf.options.set( ezdxf.options.CORE, # section \(dqtest_files\(dq, # key \(dq~/my\-dxf\-test\-files\(dq, # value ) ezdxf.options.write_file(\(dqmy_config.ini\(dq) .EE .UNINDENT .UNINDENT .SS Use a Custom Config File .sp You can specify a config file by the environment variable \fBEZDXF_CONFIG_FILE\fP, which is loaded after the default config files. .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> set EZDXF_CONFIG_FILE=D:\euser\epath\ecustom.ini .EE .UNINDENT .UNINDENT .sp Custom config files are not loaded automatically like the default config files. .sp This example shows how to load the previous created custom config file “my_config.ini” from the current working directory: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf ezdxf.options.read(\(dqmy_config.ini\(dq) .EE .UNINDENT .UNINDENT .sp That is all and because this is the last loaded config file, it overrides all default config files and the config file specified by \fBEZDXF_CONFIG_FILE\fP\&. .SS Functions .INDENT 0.0 .TP .B ezdxf.options.set(section: str, key: str, value: str) Set option \fIkey\fP in \fIsection\fP to \fIvalues\fP as \fBstr\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.get(section: str, key: str, default: str = \(aq\(aq) -> str Get option \fIkey\fP in \fIsection\fP as string. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.get_bool(section: str, key: str, default: bool = False) -> bool Get option \fIkey\fP in \fIsection\fP as \fBbool\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.get_int(section: str, key: str, default: int = 0) -> int Get option \fIkey\fP in \fIsection\fP as \fBint\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.get_float(section: str, key: str, default: float = 0.0) -> flot Get option \fIkey\fP in \fIsection\fP as \fBfloat\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.write(fp: TextIO) Write configuration into given file object \fIfp\fP, the file object must be a writeable text file with “utf8” encoding. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.write_file(filename: str = \(aqezdxf.ini\(aq) Write current configuration into file \fIfilename\fP, default is “ezdxf.ini” in the current working directory. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.write_home_config() Write configuration into file “~/.config/ezdxf/ezdxf.ini”, \fB$XDG_CONFIG_HOME\fP is supported if set. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.read_file(filename: str) Append content from config file \fIfilename\fP, but does not reset the configuration. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.print() Print configuration to \fIstdout\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.reset() Reset options to factory default values. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.delete_default_config_files() Delete the default config files “ezdxf.ini” in the current working and in the user home directory “~/.config/ezdxf”, \fB$XDG_CONFIG_HOME\fP is supported if set. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.preserve_proxy_graphics(state=True) Enable/disable proxy graphic load/store support by setting the options \fBload_proxy_graphics\fP and \fBstore_proxy_graphics\fP to \fIstate\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.loaded_config_files Read only property of loaded config files as tuple for \fBPath\fP objects. .UNINDENT .SS Core Options .sp For all core options the section name is \fBcore\fP\&. .SS Default Dimension Text Style .sp The default dimension text style is used by the DIMENSION renderer of \fIezdxf\fP, if the specified text style exist in the STYLE table. To use any of the default style of \fIezdxf\fP you have to setup the styles at the creation of the DXF document: \fBezdxf.new(setup=True)\fP, or setup the \fIezdxf\fP default styles for a loaded DXF document: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.tool.standard import setup_drawing doc = ezdxf.readfile(\(dqyour.dxf\(dq) setup_drawing(doc) .EE .UNINDENT .UNINDENT .sp Config file key: \fBdefault_dimension_text_style\fP .sp Shortcut attribute: .INDENT 0.0 .TP .B ezdxf.options.default_dimension_text_style (Read/Write) Get/Set default text style for DIMENSION rendering, default value is \fBOpenSansCondensed\-Light\fP\&. .UNINDENT .SS Load Proxy Graphic .sp Proxy graphics are not essential for DXF files, but they can provide a simple graphical representation for complex entities, but extra memory is needed to store this information. You can save some memory by not loading the proxy graphic, but the proxy graphic is lost if you write back the DXF file. .sp The current version of \fIezdxf\fP uses this proxy graphic to render MLEADER entities by the \fI\%drawing\fP add\-on. .sp Config file key: \fBload_proxy_graphics\fP .sp Shortcut attribute: .INDENT 0.0 .TP .B ezdxf.options.load_proxy_graphics (Read/Write) Load proxy graphics if \fBTrue\fP, default is \fBTrue\fP\&. .UNINDENT .SS Store Proxy Graphic .sp Prevent exporting proxy graphics if set to \fBFalse\fP\&. .sp Config file key: \fBstore_proxy_graphics\fP .sp Shortcut attribute: .INDENT 0.0 .TP .B ezdxf.options.store_proxy_graphics (Read/Write) Export proxy graphics if \fBTrue\fP, default is \fBTrue\fP\&. .UNINDENT .SS Support Directories .sp Search directories for support files: .INDENT 0.0 .IP \(bu 2 plot style tables, the .ctb or .stb pen assignment files .IP \(bu 2 shape font files of type .shx or .shp or .lff .UNINDENT .sp Config file key: \fBsupport_dirs\fP .sp Shortcut attribute: .INDENT 0.0 .TP .B ezdxf.options.support_dirs (Read/Write) Search directories as list of strings. .UNINDENT .sp Use quotes for paths including spaces: .INDENT 0.0 .INDENT 3.5 .sp .EX [core] support_dirs = ~/dir1, ~/dir2, \(dq~/dir 3\(dq, .EE .UNINDENT .UNINDENT .SS Debugging Options .sp For all debugging options the section name is \fBcore\fP\&. .SS Test Files .sp Path to test files. Some of the \fI\%CADKit\fP test files are used by the integration tests, these files should be located in the \fBezdxf.options.test_files_path / \(dqCADKitSamples\(dq\fP folder. .sp Config file key: \fBtest_files\fP .sp Shortcut attributes: .INDENT 0.0 .TP .B ezdxf.options.test_files (Read only) Returns the path to the \fIezdxf\fP test files as \fBstr\fP, expands “~” construct automatically. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.test_files_path (Read only) Path to test files as \fBpathlib.Path\fP object. .UNINDENT .SS Filter Invalid XDATA Group Codes .sp Only a very limited set of group codes is valid in the XDATA section and AutoCAD is very picky about that. \fIEzdxf\fP removes invalid XDATA group codes if this option is set to \fBTrue\fP, but this needs processing time, which is wasted if you get your DXF files from trusted sources like AutoCAD or BricsCAD. .sp Config file key: \fBfilter_invalid_xdata_group_codes\fP .INDENT 0.0 .TP .B ezdxf.options.filter_invalid_xdata_group_codes (Read only) Filter invalid XDATA group codes, default value is \fBTrue\fP\&. .UNINDENT .SS Log Unprocessed Tags .sp Logs unprocessed DXF tags, this helps to find new and undocumented DXF features. .sp Config file key: \fBlog_unprocessed_tags\fP .INDENT 0.0 .TP .B ezdxf.options.log_unprocessed_tags (Read/Write) Log unprocessed DXF tags for debugging, default value is \fBFalse\fP\&. .UNINDENT .SS Write Fixed Meta Data for Testing .sp Write the DXF files with fixed meta data to test your DXF files by a diff\-like command, this is necessary to get always the same meta data like the saving time stored in the HEADER section. This may not work across different \fIezdxf\fP versions! .sp Config file key: \fBwrite_fixed_meta_data_for_testing\fP .INDENT 0.0 .TP .B ezdxf.options.write_fixed_meta_data_for_testing (Read/Write) Enable this option to always create same meta data for testing scenarios, e.g. to use a diff\-like tool to compare DXF documents, default is \fBFalse\fP\&. .UNINDENT .SS Disable C\-Extension .sp It is possible to deactivate the optional C\-extensions if there are any issues with the C\-extensions. This has to be done in a default config file or by environment variable before the first import of \fIezdxf\fP\&. For \fBpypy3\fP the C\-extensions are always disabled, because the JIT compiled Python code is much faster. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 This option works only in the \fBdefault config files\fP, user config files which are loaded by \fI\%ezdxf.options.read_file()\fP cannot disable the C\-Extensions, because at this point the setup process of \fIezdxf\fP is already finished! .UNINDENT .UNINDENT .sp Config file key: \fBdisable_c_ext\fP .INDENT 0.0 .TP .B ezdxf.options.disable_c_ext (Read only) This option disables the C\-extensions if \fBTrue\fP\&. This can only be done before the first import of \fIezdxf\fP by using a config file or the environment variable \fBEZDXF_DISABLE_C_EXT\fP\&. .UNINDENT .SS Use C\-Extensions .INDENT 0.0 .TP .B ezdxf.options.use_c_ext (Read only) Shows the actual state of C\-extensions usage. .UNINDENT .SS Environment Variables .sp Some feature can be controlled by environment variables. Command line example for disabling the optional C\-extensions on Windows: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> set EZDXF_DISABLE_C_EXT=1 .EE .UNINDENT .UNINDENT .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 If you change any environment variable, you have to restart the Python interpreter! .UNINDENT .UNINDENT .INDENT 0.0 .TP .B EZDXF_DISABLE_C_EXT Set environment variable \fBEZDXF_DISABLE_C_EXT\fP to \fB1\fP or \fBTrue\fP to disable the usage of the C\-extensions. .TP .B EZDXF_TEST_FILES Path to the \fIezdxf\fP test files required by some tests, for instance the \fI\%CADKit\fP sample files should be located in the \fBEZDXF_TEST_FILES/CADKitSamples\fP folder. See also option \fI\%ezdxf.options.test_files\fP\&. .TP .B EZDXF_CONFIG_FILE Specifies a user config file which will be loaded automatically after the default config files at the first import of \fIezdxf\fP\&. .UNINDENT .SS Miscellaneous .SS Zoom Layouts .sp These functions mimic the ZOOM commands in CAD applications. .sp Zooming means resetting the current viewport limits to new values. The coordinates for the functions \fI\%center()\fP and \fI\%window()\fP are drawing units for the model space and paper space units for paper space layouts. The modelspace units in \fBDrawing.units\fP are ignored. .sp The extents detection for the functions \fBentities()\fP and \fI\%extents()\fP is done by the \fI\%ezdxf.bbox\fP module. Read the associated documentation to understand the limitations of the \fI\%ezdxf.bbox\fP module. Tl;dr The extents detection is \fBslow\fP and \fBnot accurate\fP\&. .sp Because the ZOOM operations in CAD applications are not that precise, then zoom functions of this module uses the fast bounding box calculation mode of the \fBbbox\fP module, which means the argument \fIflatten\fP is always \fBFalse\fP for \fI\%extents()\fP function calls. .sp The region displayed by CAD applications also depends on the aspect ratio of the application window, which is not available to \fIezdxf\fP, therefore the viewport size is just an educated guess of an aspect ratio of 2:1 (16:9 minus top toolbars and the bottom status bar). .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 All zoom functions replace the current viewport configuration by a single window configuration. .UNINDENT .UNINDENT .sp Example to reset the main CAD viewport of the model space to the extents of its entities: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf import zoom doc = ezdxf.new() msp = doc.modelspace() \&... # add your DXF entities zoom.extents(msp) doc.saveas(\(dqyour.dxf\(dq) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.zoom.center(layout: Layout, point: Sequence[float] | \fI\%Vec2\fP | \fI\%Vec3\fP, size: Sequence[float] | \fI\%Vec2\fP | \fI\%Vec3\fP) Resets the active viewport center of \fIlayout\fP to the given \fIpoint\fP, argument \fIsize\fP defines the width and height of the viewport. Replaces the current viewport configuration by a single window configuration. .UNINDENT .INDENT 0.0 .TP .B ezdxf.zoom.objects(layout: Layout, entities: Iterable[DXFEntity], factor: float = 1) Resets the active viewport limits of \fIlayout\fP to the extents of the given \fIentities\fP\&. Only entities in the given \fIlayout\fP are taken into account. The argument \fIfactor\fP scales the viewport limits. Replaces the current viewport configuration by a single window configuration. .UNINDENT .INDENT 0.0 .TP .B ezdxf.zoom.extents(layout: Layout, factor: float = 1) Resets the active viewport limits of \fIlayout\fP to the extents of all entities in this \fIlayout\fP\&. The argument \fIfactor\fP scales the viewport limits. Replaces the current viewport configuration by a single window configuration. .UNINDENT .INDENT 0.0 .TP .B ezdxf.zoom.window(layout: Layout, p1: Sequence[float] | \fI\%Vec2\fP | \fI\%Vec3\fP, p2: Sequence[float] | \fI\%Vec2\fP | \fI\%Vec3\fP) Resets the active viewport limits of \fIlayout\fP to the lower left corner \fIp1\fP and the upper right corner \fIp2\fP\&. Replaces the current viewport configuration by a single window configuration. .UNINDENT .SS Load DXF Comments .INDENT 0.0 .TP .B ezdxf.comments.from_stream(stream: TextIO, codes: set[int] | None = None) -> Iterable[\fI\%DXFTag\fP] Yields comment tags from text \fIstream\fP as \fI\%DXFTag\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstream\fP – input text stream .IP \(bu 2 \fBcodes\fP – set of group codes to yield additional DXF tags e.g. {5, 0} to also yield handle and structure tags .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.comments.from_file(filename: str, codes: set[int] | None = None) -> Iterable[\fI\%DXFTag\fP] Yields comment tags from file \fIfilename\fP as \fI\%DXFTag\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – filename as string .IP \(bu 2 \fBcodes\fP – yields also additional tags with specified group codes e.g. {5, 0} to also yield handle and structure tags .UNINDENT .UNINDENT .UNINDENT .SH LAUNCHER .sp The command line script \fIezdxf\fP launches various sub\-commands: .TS center; |l|l|. _ T{ \fBpp\fP T} T{ DXF pretty printer, replacement for the previous \fIdxfpp\fP command T} _ T{ \fBaudit\fP T} T{ Audit and repair DXF files T} _ T{ \fBdraw\fP T} T{ Draw and convert DXF files by the Matplotlib backend T} _ T{ \fBview\fP T} T{ PyQt DXF file viewer T} _ T{ \fBbrowse\fP T} T{ PyQt DXF structure browser for DXF debugging and curious people T} _ T{ \fBbrowse\-acis\fP T} T{ PyQt ACIS entity content browser for SAT/SAB debugging T} _ T{ \fBstrip\fP T} T{ Strip comments and THUMBNAILIMAGE section from DXF files T} _ T{ \fBconfig\fP T} T{ Manage config files T} _ T{ \fBinfo\fP T} T{ Show information and optional stats of DXF files as loaded by ezdxf T} _ T{ \fBhpgl\fP T} T{ View and/or convert HPGL/2 plot files to DXF, SVG or PDF T} _ .TE .sp The help option \fB\-h\fP is supported by the main script and all sub\-commands: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf \-h usage: ezdxf [\-h] [\-V] [\-v] [\-\-config CONFIG] [\-\-log LOG] {pp,audit,draw,view,browse,browse\-acis,strip,config} ... Command launcher for the Python package \(dqezdxf\(dq: https://pypi.org/project/ezdxf/ positional arguments: {pp,audit,draw,view,browse,strip} pp pretty print DXF files as HTML file audit audit and repair DXF files draw draw and convert DXF files by Matplotlib view view DXF files by the PyQt viewer browse browse DXF file structure browse\-acis browse ACIS structures in DXF files strip strip comments from DXF files config manage config files info show information and optional stats of DXF files loaded by ezdxf, this may not represent the original content of the file, use the browse command to see the original content optional arguments: \-h, \-\-help show this help message and exit \-V, \-\-version show version and exit \-f, \-\-fonts rebuild system font cache and print all fonts found \-v, \-\-verbose give more output \-\-config CONFIG path to a config file \-\-log LOG path to a verbose appending log .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBezdxf\fP script is the only executable script installed on the user system. .UNINDENT .UNINDENT .SS System .sp \fBezdxf \-V\fP shows the \fIezdxf\fP and \fIPython\fP version your are running and if the C\-extensions are used. .INDENT 0.0 .INDENT 3.5 .sp .EX ezdxf 1.1.0b1 from c:\esource\eezdxf.git\esrc\eezdxf Python version: 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] using C\-extensions: yes .EE .UNINDENT .UNINDENT .sp \fBezdxf \-f\fP rebuilds the system font cache and shows all fonts found. .SS Pretty Printer .sp Pretty print the DXF text content as HTML file and open the file in the default web browser: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf pp \-o gear.dxf .EE .UNINDENT .UNINDENT [image] .sp Print help: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf pp \-h usage: ezdxf pp [\-h] [\-o] [\-r] [\-x] [\-l] [\-s SECTIONS] FILE [FILE ...] positional arguments: FILE DXF files pretty print optional arguments: \-h, \-\-help show this help message and exit \-o, \-\-open open generated HTML file by the default web browser \-r, \-\-raw raw mode, no DXF structure interpretation \-x, \-\-nocompile don\(aqt compile points coordinates into single tags (only in raw mode) \-l, \-\-legacy legacy mode, reorder DXF point coordinates \-s SECTIONS, \-\-sections SECTIONS choose sections to include and their order, h=HEADER, c=CLASSES, t=TABLES, b=BLOCKS, e=ENTITIES, o=OBJECTS .EE .UNINDENT .UNINDENT .SS Audit .sp Audit and recover the DXF file “gear.dxf” and save the recovered version as “gear.rec.dxf”: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf audit \-s gear.dxf auditing file: gear.dxf No errors found. Saved recovered file as: gear.rec.dxf .EE .UNINDENT .UNINDENT .sp Print help: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf audit \-h usage: ezdxf audit [\-h] [\-s] FILE [FILE ...] positional arguments: FILE audit DXF files optional arguments: \-h, \-\-help show this help message and exit \-s, \-\-save save recovered files with extension \(dq.rec.dxf\(dq .EE .UNINDENT .UNINDENT .SS Draw .sp Convert the DXF file “gear.dxf” into a SVG file by the \fIMatplotlib\fP backend: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf draw \-o gear.svg gear.dxf .EE .UNINDENT .UNINDENT .sp The “gear.svg” created by the \fIMatplotlib\fP backend: [image] .sp Show all output formats supported by the \fIMatplotlib\fP backend on your system. This output may vary: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf draw \-\-formats eps: Encapsulated Postscript jpg: Joint Photographic Experts Group jpeg: Joint Photographic Experts Group pdf: Portable Document Format pgf: PGF code for LaTeX png: Portable Network Graphics ps: Postscript raw: Raw RGBA bitmap rgba: Raw RGBA bitmap svg: Scalable Vector Graphics svgz: Scalable Vector Graphics tif: Tagged Image File Format tiff: Tagged Image File Format .EE .UNINDENT .UNINDENT .sp Print help: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf draw \-h usage: ezdxf draw [\-h] [\-\-formats] [\-l LAYOUT] [\-\-all\-layers\-visible] [\-\-all\-entities\-visible] [\-o OUT] [\-\-dpi DPI] [\-v] [FILE] positional arguments: FILE DXF file to view or convert optional arguments: \-h, \-\-help show this help message and exit \-\-formats show all supported export formats and exit \-l LAYOUT, \-\-layout LAYOUT select the layout to draw, default is \(dqModel\(dq \-\-all\-layers\-visible draw all layers including the ones marked as invisible \-\-all\-entities\-visible draw all entities including the ones marked as invisible (some entities are individually marked as invisible even if the layer is visible) \-o OUT, \-\-out OUT output filename for export \-\-dpi DPI target render resolution, default is 300 \-v, \-\-verbose give more output .EE .UNINDENT .UNINDENT .SS View .sp View the DXF file “gear.dxf” by the \fIPyQt\fP backend: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf view gear.dxf .EE .UNINDENT .UNINDENT [image] .sp Print help: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf view \-h usage: ezdxf view [\-h] [\-l LAYOUT] [\-\-lwscale LWSCALE] [FILE] positional arguments: FILE DXF file to view optional arguments: \-h, \-\-help show this help message and exit \-l LAYOUT, \-\-layout LAYOUT select the layout to draw, default is \(dqModel\(dq \-\-lwscale LWSCALE set custom line weight scaling, default is 0 to disable line weights at all .EE .UNINDENT .UNINDENT .SS Browse .sp Browse the internal structure of a DXF file like a file system: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf browse gear.dxf .EE .UNINDENT .UNINDENT [image] .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf browse \-h usage: ezdxf browse [\-h] [\-l LINE] [\-g HANDLE] [FILE] positional arguments: FILE DXF file to browse optional arguments: \-h, \-\-help show this help message and exit \-l LINE, \-\-line LINE go to line number \-g HANDLE, \-\-handle HANDLE go to entity by HANDLE, HANDLE has to be a hex value without any prefix like \(aqfefe\(aq .EE .UNINDENT .UNINDENT .sp The \fIbrowse\fP command stores options in the config file, e.g. for the \fINotepad++\fP on Windows: .INDENT 0.0 .INDENT 3.5 .sp .EX [browse\-command] text_editor = \(dqC:\eProgram Files\eNotepad++\enotepad++.exe\(dq \(dq{filename}\(dq \-n{num} icon_size = 32 .EE .UNINDENT .UNINDENT .sp \fBtext_editor\fP is a simple format string: \fBtext_editor.format(filename=\(dqtest.dxf\(dq, num=100)\fP .sp Quote commands including spaces and always quote the filename argument! .sp For \fIxed\fP on Linux Mint use (note: absolute path to executable): .INDENT 0.0 .INDENT 3.5 .sp .EX [browse\-command] text_editor = /usr/bin/xed \(dq{filename}\(dq +{num} icon_size = 32 .EE .UNINDENT .UNINDENT .sp For \fIgedit\fP on Linux use (untested): .INDENT 0.0 .INDENT 3.5 .sp .EX [browse\-command] text_editor = /usr/bin/gedit +{num} \(dq{filename}\(dq icon_size = 32 .EE .UNINDENT .UNINDENT .sp The \fIbrowse\fP command opens a DXF structure browser to investigate the internals of a DXF file without interpreting the content. The functionality of the DXF browser is similar to the DXF \fI\%Pretty Printer\fP (\fIpp\fP command), but without the disadvantage of creating giant HTML files. The intended usage is debugging invalid DXF files, which can not be loaded by the \fI\%ezdxf.readfile()\fP or the \fI\%ezdxf.recover.readfile()\fP functions. .SS Line Numbers .sp The low level tag loader ignores DXF comments (group code 999). If there are comments in the DXF file the line numbers displayed in the DXF browser are not synchronized, use the \fI\%strip\fP command beforehand to remove all comments from the DXF file in order to keep the line numbers synchronized. .SS GUI Features .sp The tree view on the left shows the outline of the DXF file. The number in round brackets on the right side of each item shows the count of structure entities within the structure layer, the value in angle brackets on the left side is the entity handle. .sp The right list view shows the entity content as DXF tags. Structure tags (data type ) are shown in blue, a double click on a reference handle (datatype ) jumps to the referenced entity, reference handles of non\-existent targets are shown in red. .sp Clicking on the first structure tag in the list opens the DXF reference provided by Autodesk in the standard web browser. .SS Auto Reload .sp The browser automatically displays a dialog for reloading DXF files if they have been modified by an external application. .SS Menus and Shortcuts .INDENT 0.0 .IP \(bu 2 .INDENT 2.0 .TP .B File Menu .INDENT 7.0 .IP \(bu 2 \fBOpen DXF file…\fP \fICtrl+O\fP .IP \(bu 2 \fBReload DXF file\fP \fICtrl+R\fP .IP \(bu 2 \fBOpen in Text Editor\fP \fICtrl+T\fP, open the DXF file in the associated text editor at the current location .IP \(bu 2 \fBExport DXF Entity…\fP \fICtrl+E\fP, export the current DXF entity shown in the list view as text file .IP \(bu 2 \fBCopy selected DXF Tags to Clipboard\fP \fICtrl+C\fP, copy the current selected DXF tags into the clipboard .IP \(bu 2 \fBCopy DXF Entity to Clipboard\fP \fICtrl+Shift+C\fP, copy all DXF tags of the current DXF entity shown in the list view into the clipboard .IP \(bu 2 \fBQuit\fP \fICtrl+Q\fP .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Navigate Menu .INDENT 7.0 .IP \(bu 2 \fBGo to Handle…\fP \fICtrl+G\fP .IP \(bu 2 \fBGo to Line…\fP \fICtrl+L\fP .IP \(bu 2 \fBFind Text…\fP \fICtrl+F\fP, opens the find text dialog .IP \(bu 2 \fBNext Entity\fP \fICtrl+Right\fP, go to the next entity in the DXF structure .IP \(bu 2 \fBPrevious Entity\fP \fICtrl+Right\fP, go to the previous entity in the DXF structure .IP \(bu 2 \fBShow Entity in TreeView\fP \fICtrl+Down\fP, expand the left tree view to the currently displayed entity in the list view \- this does not happen automatically for performance reasons .IP \(bu 2 \fBEntity History Back\fP \fIAlt+Left\fP .IP \(bu 2 \fBEntity History Forward\fP \fIAlt+Right\fP .IP \(bu 2 \fBGo to HEADERS Section\fP \fIShift+H\fP .IP \(bu 2 \fBGo to BLOCKS Section\fP \fIShift+B\fP .IP \(bu 2 \fBGo to ENTITIES Section\fP \fIShift+E\fP .IP \(bu 2 \fBGo to OBJECTS Section\fP \fIShift+O\fP .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Bookmarks Menu .INDENT 7.0 .IP \(bu 2 \fBStore Bookmark…\fP \fICtrl+Shift+B\fP, store current location as named bookmark .IP \(bu 2 \fBGo to Bookmark…\fP \fICtrl+B\fP, go to stored location .UNINDENT .UNINDENT .UNINDENT .SS Browse\-ACIS .sp Show and export the \fI\%SAT\fP or \fI\%SAB\fP content of \fI\%ACIS\fP entities: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf browse\-acis 3dsolid.dxf .EE .UNINDENT .UNINDENT [image] .sp The DXF format stores modern solid geometry as \fI\%SAT\fP data for DXF R2000 \- R2010 and as \fI\%SAB\fP data for DXF R2013 and later. This command shows the content of this entities and also let you export the raw data for further processing. .SS Entity View .sp The entity view is a read\-only text editor, it’s possible to select and copy parts of the text into the clipboard. To improve the readability all ACIS entities get automatically an id because AutoCAD and BricsCAD use relative references for ACIS data export and do not assign entity ids. The id is shown as decimal number in parenthesis after the entity name. The \fB~\fP character is a shortcut for a null\-pointer. .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e>ezdxf browse\-acis \-h usage: ezdxf browse\-acis [\-h] [\-g HANDLE] [FILE] positional arguments: FILE DXF file to browse options: \-h, \-\-help show this help message and exit \-g HANDLE, \-\-handle HANDLE go to entity by HANDLE, HANDLE has to be a hex value without any prefix like \(aqfefe\(aq .EE .UNINDENT .UNINDENT .SS Menus and Shortcuts .INDENT 0.0 .IP \(bu 2 .INDENT 2.0 .TP .B File Menu .INDENT 7.0 .IP \(bu 2 \fBOpen DXF file…\fP \fICtrl+O\fP .IP \(bu 2 \fBReload DXF file\fP \fICtrl+R\fP .IP \(bu 2 \fBExport Current Entity View…\fP \fICtrl+E\fP, Export the parsed content of the entity view as text file .IP \(bu 2 \fBExport Raw SAT/SAB Data…\fP \fICtrl+W\fP, export the raw SAT data as text file and the raw SAB data as a binary file for further processing .IP \(bu 2 \fBQuit\fP \fICtrl+Q\fP .UNINDENT .UNINDENT .UNINDENT .SS Strip .sp Strip comment tags (group code 999) from ASCII DXF files and can remove the THUMBNAILIMAGE section. Binary DXF files are not supported. .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf strip \-h usage: ezdxf strip [\-h] [\-b] [\-v] FILE [FILE ...] positional arguments: FILE DXF file to process, wildcards \(dq*\(dq and \(dq?\(dq are supported optional arguments: \-h, \-\-help show this help message and exit \-b, \-\-backup make a backup copy with extension \(dq.bak\(dq from the DXF file, overwrites existing backup files \-t, \-\-thumbnail strip THUMBNAILIMAGE section \-v, \-\-verbose give more output .EE .UNINDENT .UNINDENT .SS Config .sp Manage config files. .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf config \-h usage: ezdxf config [\-h] [\-p] [\-w FILE] [\-\-home] [\-\-reset] optional arguments: \-h, \-\-help show this help message and exit \-p, \-\-print print configuration \-w FILE, \-\-write FILE write configuration \-\-home create config file \(aqezdxf.ini\(aq in the user home directory \(aq~/.config/ezdxf\(aq, $XDG_CONFIG_HOME is supported if set \-\-reset factory reset, delete default config files \(aqezdxf.ini\(aq .EE .UNINDENT .UNINDENT .SS Info .sp Show information and optional stats of DXF files as loaded by \fIezdxf\fP, this may not represent the original content of the file, use the \fI\%browse\fP command to see the original content. The upgrade is necessary for very old DXF versions prior to R12 and for the “special” versions R13 and R14. The \fI\-s\fP option shows some statistics about the DXF content like entity count or table count. Use the \fI\-v\fP option show more of everything. .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf info \-h usage: ezdxf info [\-h] [\-v] [\-s] FILE [FILE ...] positional arguments: FILE DXF file to process, wildcards \(dq*\(dq and \(dq?\(dq are supported options: \-h, \-\-help show this help message and exit \-v, \-\-verbose give more output \-s, \-\-stats show content stats .EE .UNINDENT .UNINDENT .sp This is the verbose output for an old DXF R10 file and shows that the loading process created some required structures which do not exist in DXF R10 files, like the BLOCK_RECORD table or the OBJECTS section: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf info \-v \-s test_R10.dxf Filename: \(dqtest_R10.dxf\(dq Loaded content was upgraded from DXF Version AC1006 (R10) Release: R12 DXF Version: AC1009 Maintenance Version: Codepage: ANSI_1252 Encoding: cp1252 Unit system: Imperial Modelspace units: Unitless $LASTSAVEDBY: $HANDSEED: 0 $FINGERPRINTGUID: {9EADDC7C\-5982\-4C68\-B770\-8A62378C2B90} $VERSIONGUID: {49336E63\-D99B\-45EC\-803C\-4D2BD03A7DE0} $USERI1=0 $USERI2=0 $USERI3=0 $USERI4=0 $USERI5=0 $USERR1=0.0 $USERR2=0.0 $USERR3=0.0 $USERR4=0.0 $USERR5=0.0 File was not created by ezdxf >= 0.16.4 File was not written by ezdxf >= 0.16.4 Content stats: LAYER table entries: 18 0 Defpoints LYR_00 LYR_01 LYR_02 LYR_03 LYR_04 LYR_05 LYR_06 LYR_07 LYR_08 LYR_09 LYR_10 LYR_11 LYR_12 LYR_13 LYR_14 LYR_15 LTYPE table entries: 13 BORDER ByBlock ByLayer CENTER CONTINUOUS CUTTING DASHDOT DASHED DIVIDE DOT HIDDEN PHANTOM STITCH STYLE table entries: 1 STANDARD DIMSTYLE table entries: 1 Standard APPID table entries: 1 ACAD UCS table entries: 0 VIEW table entries: 0 VPORT table entries: 1 *Active BLOCK_RECORD table entries: 2 *Model_Space *Paper_Space Entities in modelspace: 78 ARC (2) CIRCLE (2) LINE (74) Entities in OBJECTS section: 20 ACDBDICTIONARYWDFLT (1) ACDBPLACEHOLDER (1) DICTIONARY (11) LAYOUT (2) MATERIAL (3) MLEADERSTYLE (1) MLINESTYLE (1) .EE .UNINDENT .UNINDENT .SS Show Version & Configuration .sp Show the \fIezdxf\fP version and configuration: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf \-Vv ezdxf v0.16.5b0 @ d:\esource\eezdxf.git\esrc\eezdxf Python version: 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] using C\-extensions: yes using Matplotlib: yes Configuration: [core] default_dimension_text_style = OpenSansCondensed\-Light test_files = D:\eSource\edxftest font_cache_directory = load_proxy_graphics = true store_proxy_graphics = true log_unprocessed_tags = false filter_invalid_xdata_group_codes = true write_fixed_meta_data_for_testing = false disable_c_ext = false [browse\-command] text_editor = \(dqC:\eProgram Files\eNotepad++\enotepad++.exe\(dq \(dq{filename}\(dq \-n{num} Environment Variables: EZDXF_DISABLE_C_EXT= EZDXF_TEST_FILES=D:\eSource\edxftest EZDXF_CONFIG_FILE= Existing Configuration Files: C:\eUsers\emanfred\e.config\eezdxf\eezdxf.ini .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Documentation of the \fI\%ezdxf.options\fP module and the \fI\%Environment Variables\fP\&. .UNINDENT .UNINDENT .SS HPGL/2 Viewer/Converter .sp New in version 1.1. .sp The \fBhpgl\fP command shows and/or converts \fI\%HPGL/2\fP plot files to DXF, SVG or PDF. .SS DXF .sp The page content is created at the origin of the modelspace and 1 drawing unit is 1 plot unit (1 plu = 0.025mm) unless scaling values are provided. .sp The content of HPGL files is intended to be plotted on white paper, so the appearance on a dark background in modelspace is not very clear. To fix this, the \fB\-\-map_black_to_white\fP option maps black fillings and lines to white. .sp All entities are mapped to a layer named \fBCOLOR_<#>\fP according to the pen number. In order to process the content better, it is also possible to assign the DXF elements an ACI color value according to the pen number through the \fB\-\-aci\fP option, but then the RGB color is lost because the RGB color always has the higher priority over the \fI\%ACI\fP value. .sp The first paperspace layout “Layout0” is set up to print the entire modelspace on one sheet, the size of the page is the size of the original plot file in millimeters. .SS SVG .sp The plot units are mapped 1:1 to \fBviewBox\fP units and the size of image is the size of the original plot file in millimeters. .SS PDF .sp The plot units are converted to PDF units (1/72 inch) so the size of image is the size of the original plot file in millimeters. .SS All Formats .sp HPGL/2’s merge control works at the pixel level and cannot be replicated by DXF, but to prevent fillings from obscuring text, the filled polygons are sorted by luminance \- this can be forced or disabled by the \fB\-\-merge_control\fP option. .sp Some plot files that contain pure HPGL/2 code do not contain the escape sequence “Enter HPGL/2 mode”, without this sequence the HPGL/2 parser cannot recognize the beginning of the HPGL/2 code. The \fB\-\-force\fP option inserts the “Enter HPGL/2 mode” escape sequence into the data stream, regardless of whether the file is an HPGL/2 plot file or not, so be careful. .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> ezdxf hpgl \-h usage: ezdxf hpgl [\-h] [\-e FORMAT] [\-r {0,90,180,270}] [\-x SX] [\-y SY] [\-m {0,1,2}] [\-f] [\-\-aci] [\-\-map_black_to_white] [FILE] positional arguments: FILE view and/or convert HPGL/2 plot files, wildcards (*, ?) supported in command line mode options: \-h, \-\-help show this help message and exit \-e FORMAT, \-\-export FORMAT convert HPGL/2 plot file to SVG, PDF or DXF from the command line (no gui) \-r {0,90,180,270}, \-\-rotate {0,90,180,270} rotate page about 90, 180 or 270 degrees (no gui) \-x SX, \-\-scale_x SX scale page in x\-axis direction, use negative values to mirror page, (no gui) \-y SY, \-\-scale_y SY scale page in y\-axis direction, use negative values to mirror page (no gui) \-m {0,1,2}, \-\-merge_control {0,1,2} provides control over the order of filled polygons, 0=off (print order), 1=luminance (order by luminance), 2=auto (default) \-f, \-\-force inserts the mandatory \(aqenter HPGL/2 mode\(aq escape sequence into the data stream; use this flag when no HPGL/2 data was found and you are sure the file is a HPGL/2 plot file \-\-aci use pen numbers as ACI colors (DXF only) \-\-map_black_to_white map black RGB plot colors to white RGB, does not affect ACI colors (DXF only) Note that plot files are intended to be plotted on white paper. .EE .UNINDENT .UNINDENT .SH RENDERING .sp The \fI\%ezdxf.render\fP subpackage provides helpful utilities to create complex forms. .INDENT 0.0 .IP \(bu 2 create complex meshes as \fI\%Mesh\fP entity. .IP \(bu 2 render complex curves like bezier curves, euler spirals or splines as \fI\%Polyline\fP entity .IP \(bu 2 vertex generators for simple and complex forms like circle, ellipse or euler spiral .UNINDENT .sp Content .SS Spline .INDENT 0.0 .TP .B class ezdxf.render.Spline(points: Iterable[\fI\%UVec\fP] | None = None, segments: int = 100) This class can be used to render B\-splines into DXF R12 files as approximated \fI\%Polyline\fP entities. The advantage of this class over the \fI\%R12Spline\fP class is, that this is a real 3D curve, which means that the B\-spline vertices do have to be located in a flat plane, and no \fI\%UCS\fP class is needed to place the curve in 3D space. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 The newer \fI\%BSpline\fP class provides the advanced vertex interpolation method \fI\%flattening()\fP\&. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __init__(points: Iterable[\fI\%UVec\fP] | None = None, segments: int = 100) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – spline definition points .IP \(bu 2 \fBsegments\fP – count of line segments for approximation, vertex count is \fIsegments\fP + 1 .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B subdivide(segments: int = 4) -> None Calculate overall segment count, where segments is the sub\-segment count, \fIsegments\fP = 4, means 4 line segments between two definition points e.g. 4 definition points and 4 segments = 12 overall segments, useful for fit point rendering. .INDENT 7.0 .TP .B Parameters \fBsegments\fP – sub\-segments count between two definition points .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_as_fit_points(layout: \fI\%BaseLayout\fP, degree: int = 3, method: str = \(aqchord\(aq, dxfattribs: dict | None = None) -> None Render a B\-spline as 2D/3D \fI\%Polyline\fP, where the definition points are fit points. .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 2D spline vertices uses: \fI\%add_polyline2d()\fP .IP \(bu 2 3D spline vertices uses: \fI\%add_polyline3d()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBmethod\fP – “uniform”, “distance”/”chord”, “centripetal”/”sqrt_chord” or “arc” calculation method for parameter t .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_open_bspline(layout: \fI\%BaseLayout\fP, degree: int = 3, dxfattribs=None) -> None Render an open uniform B\-spline as 3D \fI\%Polyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_uniform_bspline(layout: \fI\%BaseLayout\fP, degree: int = 3, dxfattribs=None) -> None Render a uniform B\-spline as 3D \fI\%Polyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_closed_bspline(layout: \fI\%BaseLayout\fP, degree: int = 3, dxfattribs=None) -> None Render a closed uniform B\-spline as 3D \fI\%Polyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_open_rbspline(layout: \fI\%BaseLayout\fP, weights: Iterable[float], degree: int = 3, dxfattribs=None) -> None Render a rational open uniform BSpline as 3D \fI\%Polyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBweights\fP – list of weights, requires a weight value (float) for each definition point. .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_uniform_rbspline(layout: \fI\%BaseLayout\fP, weights: Iterable[float], degree: int = 3, dxfattribs=None) -> None Render a rational uniform B\-spline as 3D \fI\%Polyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBweights\fP – list of weights, requires a weight value (float) for each definition point. .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_closed_rbspline(layout: \fI\%BaseLayout\fP, weights: Iterable[float], degree: int = 3, dxfattribs=None) -> None Render a rational B\-spline as 3D \fI\%Polyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBweights\fP – list of weights, requires a weight value (float) for each definition point. .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS R12Spline .INDENT 0.0 .TP .B class ezdxf.render.R12Spline(control_points: Iterable[\fI\%UVec\fP], degree: int = 2, closed: bool = True) DXF R12 supports 2D B\-splines, but Autodesk do not document the usage in the DXF Reference. The base entity for splines in DXF R12 is the POLYLINE entity. The spline itself is always in a plane, but as any 2D entity, the spline can be transformed into the 3D object by elevation and extrusion (\fI\%OCS\fP, \fI\%UCS\fP). .sp This way it was possible to store the spline parameters in the DXF R12 file, to allow CAD applications to modify the spline parameters and rerender the B\-spline afterward again as polyline approximation. Therefore, the result is not better than an approximation by the \fI\%Spline\fP class, it is also just a POLYLINE entity, but maybe someone need exact this tool in the future. .INDENT 7.0 .TP .B __init__(control_points: Iterable[\fI\%UVec\fP], degree: int = 2, closed: bool = True) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – B\-spline control frame vertices .IP \(bu 2 \fBdegree\fP – degree of B\-spline, only 2 and 3 is supported .IP \(bu 2 \fBclosed\fP – \fBTrue\fP for closed curve .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render(layout: \fI\%BaseLayout\fP, segments: int = 40, ucs: \fI\%UCS\fP | None = None, dxfattribs=None) -> \fI\%Polyline\fP Renders the B\-spline into \fIlayout\fP as 2D \fI\%Polyline\fP entity. Use an \fI\%UCS\fP to place the 2D spline in the 3D space, see \fI\%approximate()\fP for more information. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBsegments\fP – count of line segments for approximation, vertex count is \fIsegments\fP + 1 .IP \(bu 2 \fBucs\fP – \fI\%UCS\fP definition, control points in ucs coordinates. .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int = 40, ucs: \fI\%UCS\fP | None = None) -> list[\fI\%UVec\fP] Approximate the B\-spline by a polyline with \fIsegments\fP line segments. If \fIucs\fP is not \fBNone\fP, ucs defines an \fI\%UCS\fP, to transform the curve into \fI\%OCS\fP\&. The control points are placed xy\-plane of the UCS, don’t use z\-axis coordinates, if so make sure all control points are in a plane parallel to the OCS base plane (UCS xy\-plane), else the result is unpredictable and depends on the CAD application used to open the DXF file \- it may crash. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsegments\fP – count of line segments for approximation, vertex count is \fIsegments\fP + 1 .IP \(bu 2 \fBucs\fP – \fI\%UCS\fP definition, control points in ucs coordinates .UNINDENT .TP .B Returns list of vertices in \fI\%OCS\fP as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .UNINDENT .SS Bezier .INDENT 0.0 .TP .B class ezdxf.render.Bezier Render a bezier curve as 2D/3D \fI\%Polyline\fP\&. .sp The \fI\%Bezier\fP class is implemented with multiple segments, each segment is an optimized 4 point bezier curve, the 4 control points of the curve are: the start point (1) and the end point (4), point (2) is start point + start vector and point (3) is end point + end vector. Each segment has its own approximation count. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 The new \fI\%ezdxf.path\fP package provides many advanced construction tools based on the \fI\%Path\fP class. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B start(point: \fI\%UVec\fP, tangent: \fI\%UVec\fP) -> None Set start point and start tangent. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – start point .IP \(bu 2 \fBtangent\fP – start tangent as vector, example: (5, 0, 0) means a horizontal tangent with a length of 5 drawing units .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append(point: \fI\%UVec\fP, tangent1: \fI\%UVec\fP, tangent2: \fI\%UVec\fP | None = None, segments: int = 20) Append a control point with two control tangents. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – control point .IP \(bu 2 \fBtangent1\fP – first tangent as vector “left” of the control point .IP \(bu 2 \fBtangent2\fP – second tangent as vector “right” of the control point, if omitted \fItangent2\fP = \fI\-tangent1\fP .IP \(bu 2 \fBsegments\fP – count of line segments for the polyline approximation, count of line segments from the previous control point to the appended control point. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render(layout: \fI\%BaseLayout\fP, force3d: bool = False, dxfattribs=None) -> None Render Bezier curve as 2D/3D \fI\%Polyline\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBforce3d\fP – force 3D polyline rendering .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS EulerSpiral .INDENT 0.0 .TP .B class ezdxf.render.EulerSpiral(curvature: float = 1) Render an \fI\%euler spiral\fP as a 3D \fI\%Polyline\fP or a \fI\%Spline\fP entity. .sp This is a parametric curve, which always starts at the origin (0, 0). .INDENT 7.0 .TP .B __init__(curvature: float = 1) .INDENT 7.0 .TP .B Parameters \fBcurvature\fP – Radius of curvature .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_polyline(layout: \fI\%BaseLayout\fP, length: float = 1, segments: int = 100, matrix: \fI\%Matrix44\fP | None = None, dxfattribs=None) Render curve as \fI\%Polyline\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBlength\fP – length measured along the spiral curve from its initial position .IP \(bu 2 \fBsegments\fP – count of line segments to use, vertex count is \fIsegments\fP + 1 .IP \(bu 2 \fBmatrix\fP – transformation matrix as \fI\%Matrix44\fP .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Polyline\fP .UNINDENT .TP .B Returns \fI\%Polyline\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_spline(layout: \fI\%BaseLayout\fP, length: float = 1, fit_points: int = 10, degree: int = 3, matrix: \fI\%Matrix44\fP | None = None, dxfattribs=None) Render curve as \fI\%Spline\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBlength\fP – length measured along the spiral curve from its initial position .IP \(bu 2 \fBfit_points\fP – count of spline fit points to use .IP \(bu 2 \fBdegree\fP – degree of B\-spline .IP \(bu 2 \fBmatrix\fP – transformation matrix as \fI\%Matrix44\fP .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fI\%Spline\fP .UNINDENT .TP .B Returns \fI\%Spline\fP .UNINDENT .UNINDENT .UNINDENT .SS Random Paths .sp Random path generators for testing purpose. .INDENT 0.0 .TP .B ezdxf.render.random_2d_path(steps: int = 100, max_step_size: float = 1.0, max_heading: float = math.pi / 2, retarget: int = 20) -> Iterable[\fI\%Vec2\fP] Returns a random 2D path as iterable of \fI\%Vec2\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsteps\fP – count of vertices to generate .IP \(bu 2 \fBmax_step_size\fP – max step size .IP \(bu 2 \fBmax_heading\fP – limit heading angle change per step to ± max_heading/2 in radians .IP \(bu 2 \fBretarget\fP – specifies steps before changing global walking target .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.random_3d_path(steps: int = 100, max_step_size: float = 1.0, max_heading: float = math.pi / 2.0, max_pitch: float = math.pi / 8.0, retarget: int = 20) -> Iterable[\fI\%Vec3\fP] Returns a random 3D path as iterable of \fI\%Vec3\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsteps\fP – count of vertices to generate .IP \(bu 2 \fBmax_step_size\fP – max step size .IP \(bu 2 \fBmax_heading\fP – limit heading angle change per step to ± max_heading/2, rotation about the z\-axis in radians .IP \(bu 2 \fBmax_pitch\fP – limit pitch angle change per step to ± max_pitch/2, rotation about the x\-axis in radians .IP \(bu 2 \fBretarget\fP – specifies steps before changing global walking target .UNINDENT .UNINDENT .UNINDENT .SS Forms .INDENT 0.0 .INDENT 3.5 This module provides functions to create 2D and 3D forms as vertices or mesh objects. .sp 2D Forms .INDENT 0.0 .IP \(bu 2 \fI\%box()\fP .IP \(bu 2 \fI\%circle()\fP .IP \(bu 2 \fI\%ellipse()\fP .IP \(bu 2 \fI\%euler_spiral()\fP .IP \(bu 2 \fI\%gear()\fP .IP \(bu 2 \fI\%ngon()\fP .IP \(bu 2 \fI\%square()\fP .IP \(bu 2 \fI\%star()\fP .IP \(bu 2 \fI\%turtle()\fP .UNINDENT .sp 3D Forms .INDENT 0.0 .IP \(bu 2 \fI\%cone_2p()\fP .IP \(bu 2 \fI\%cone()\fP .IP \(bu 2 \fI\%cube()\fP .IP \(bu 2 \fI\%cylinder()\fP .IP \(bu 2 \fI\%cylinder_2p()\fP .IP \(bu 2 \fI\%helix()\fP .IP \(bu 2 \fI\%sphere()\fP .IP \(bu 2 \fI\%torus()\fP .UNINDENT .sp 3D Form Builder .INDENT 0.0 .IP \(bu 2 \fI\%extrude()\fP .IP \(bu 2 \fI\%extrude_twist_scale()\fP .IP \(bu 2 \fI\%from_profiles_linear()\fP .IP \(bu 2 \fI\%from_profiles_spline()\fP .IP \(bu 2 \fI\%rotation_form()\fP .IP \(bu 2 \fI\%sweep()\fP .IP \(bu 2 \fI\%sweep_profile()\fP .UNINDENT .UNINDENT .UNINDENT .SS 2D Forms .INDENT 0.0 .INDENT 3.5 Basic 2D shapes as iterable of \fI\%Vec3\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.box(sx: float = 1.0, sy: float = 1.0, center=False) -> tuple[\fI\%Vec3\fP, \fI\%Vec3\fP, \fI\%Vec3\fP, \fI\%Vec3\fP] Returns 4 vertices for a box with a width of \fIsx\fP by and a height of \fIsy\fP\&. The center of the box in (0, 0) if \fIcenter\fP is \fBTrue\fP otherwise the lower left corner is (0, 0), upper right corner is (\fIsx\fP, \fIsy\fP). .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.circle(count: int, radius: float = 1, elevation: float = 0, close: bool = False) -> Iterable[\fI\%Vec3\fP] Create polygon vertices for a \fI\%circle\fP with the given \fIradius\fP and approximated by \fIcount\fP vertices, \fIelevation\fP is the z\-axis for all vertices. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of polygon vertices .IP \(bu 2 \fBradius\fP – circle radius .IP \(bu 2 \fBelevation\fP – z\-axis for all vertices .IP \(bu 2 \fBclose\fP – yields first vertex also as last vertex if \fBTrue\fP\&. .UNINDENT .TP .B Returns vertices in counter\-clockwise orientation as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.ellipse(count: int, rx: float = 1, ry: float = 1, start_param: float = 0, end_param: float = math.tau, elevation: float = 0) -> Iterable[\fI\%Vec3\fP] Create polygon vertices for an \fI\%ellipse\fP with given \fIrx\fP as x\-axis radius and \fIry\fP as y\-axis radius approximated by \fIcount\fP vertices, \fIelevation\fP is the z\-axis for all vertices. The ellipse goes from \fIstart_param\fP to \fIend_param\fP in counter clockwise orientation. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of polygon vertices .IP \(bu 2 \fBrx\fP – ellipse x\-axis radius .IP \(bu 2 \fBry\fP – ellipse y\-axis radius .IP \(bu 2 \fBstart_param\fP – start of ellipse in range [0, 2π] .IP \(bu 2 \fBend_param\fP – end of ellipse in range [0, 2π] .IP \(bu 2 \fBelevation\fP – z\-axis for all vertices .UNINDENT .TP .B Returns vertices in counter clockwise orientation as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.euler_spiral(count: int, length: float = 1, curvature: float = 1, elevation: float = 0) -> Iterable[\fI\%Vec3\fP] Create polygon vertices for an \fI\%euler spiral\fP of a given \fIlength\fP and radius of curvature. This is a parametric curve, which always starts at the origin (0, 0). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of polygon vertices .IP \(bu 2 \fBlength\fP – length of curve in drawing units .IP \(bu 2 \fBcurvature\fP – radius of curvature .IP \(bu 2 \fBelevation\fP – z\-axis for all vertices .UNINDENT .TP .B Returns vertices as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.gear(count: int, top_width: float, bottom_width: float, height: float, outside_radius: float, elevation: float = 0, close: bool = False) -> Iterable[\fI\%Vec3\fP] Returns the corner vertices of a \fI\%gear shape\fP (cogwheel). .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 This function does not create correct gears for mechanical engineering! .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – teeth count >= 3 .IP \(bu 2 \fBtop_width\fP – teeth width at outside radius .IP \(bu 2 \fBbottom_width\fP – teeth width at base radius .IP \(bu 2 \fBheight\fP – teeth height; base radius = outside radius \- height .IP \(bu 2 \fBoutside_radius\fP – outside radius .IP \(bu 2 \fBelevation\fP – z\-axis for all vertices .IP \(bu 2 \fBclose\fP – yields first vertex also as last vertex if True. .UNINDENT .TP .B Returns vertices in counter clockwise orientation as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.ngon(count: int, length: float | None = None, radius: float | None = None, rotation: float = 0.0, elevation: float = 0.0, close: bool = False) -> Iterable[\fI\%Vec3\fP] Returns the corner vertices of a \fI\%regular polygon\fP\&. The polygon size is determined by the edge \fIlength\fP or the circum \fIradius\fP argument. If both are given \fIlength\fP has the higher priority. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of polygon corners >= 3 .IP \(bu 2 \fBlength\fP – length of polygon side .IP \(bu 2 \fBradius\fP – circum radius .IP \(bu 2 \fBrotation\fP – rotation angle in radians .IP \(bu 2 \fBelevation\fP – z\-axis for all vertices .IP \(bu 2 \fBclose\fP – yields first vertex also as last vertex if \fBTrue\fP\&. .UNINDENT .TP .B Returns vertices as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.square(size: float = 1.0, center=False) -> tuple[\fI\%Vec3\fP, \fI\%Vec3\fP, \fI\%Vec3\fP, \fI\%Vec3\fP] Returns 4 vertices for a square with a side length of the given \fIsize\fP\&. The center of the square in (0, 0) if \fIcenter\fP is \fBTrue\fP otherwise the lower left corner is (0, 0), upper right corner is (\fIsize\fP, \fIsize\fP). .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.star(count: int, r1: float, r2: float, rotation: float = 0.0, elevation: float = 0.0, close: bool = False) -> Iterable[\fI\%Vec3\fP] Returns the corner vertices for a \fI\%star shape\fP\&. .sp The shape has \fIcount\fP spikes, \fIr1\fP defines the radius of the “outer” vertices and \fIr2\fP defines the radius of the “inner” vertices, but this does not mean that \fIr1\fP has to be greater than \fIr2\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – spike count >= 3 .IP \(bu 2 \fBr1\fP – radius 1 .IP \(bu 2 \fBr2\fP – radius 2 .IP \(bu 2 \fBrotation\fP – rotation angle in radians .IP \(bu 2 \fBelevation\fP – z\-axis for all vertices .IP \(bu 2 \fBclose\fP – yields first vertex also as last vertex if \fBTrue\fP\&. .UNINDENT .TP .B Returns vertices as \fI\%Vec3\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.turtle(commands: str, start=Vec2(0, 0), angle: float = 0) -> Iterator[\fI\%Vec2\fP] Returns the 2D vertices of a polyline created by turtle\-graphic like commands: .INDENT 7.0 .IP \(bu 2 \fB\fP \- go units forward in current direction and yield vertex .IP \(bu 2 \fBr\fP \- turn right in degrees, a missing angle is 90 deg .IP \(bu 2 \fBl\fP \- turn left in degrees, a missing angle is 90 deg .IP \(bu 2 \fB@,\fP \- go relative , and yield vertex .UNINDENT .sp The command string \fB\(dq10 l 10 l 10\(dq\fP returns the 4 corner vertices of a square with a side length of 10 drawing units. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcommands\fP – command string, commands are separated by spaces .IP \(bu 2 \fBstart\fP – starting point, default is (0, 0) .IP \(bu 2 \fBangle\fP – starting direction, default is 0 deg .UNINDENT .UNINDENT .UNINDENT .SS 3D Forms .sp Create 3D forms as \fI\%MeshTransformer\fP objects. .INDENT 0.0 .TP .B ezdxf.render.forms.cube(center: bool = True) -> MeshTransformer Create a \fI\%cube\fP as \fI\%MeshTransformer\fP object. .INDENT 7.0 .TP .B Parameters \fBcenter\fP – ‘mass’ center of cube, \fB(0, 0, 0)\fP if \fBTrue\fP, else first corner at \fB(0, 0, 0)\fP .UNINDENT .sp Returns: \fI\%MeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.cone(count: int = 16, radius: float = 1.0, apex: \fI\%UVec\fP = (0, 0, 1), *, caps=True) -> MeshTransformer Create a \fI\%cone\fP as \fI\%MeshTransformer\fP object, the base center is fixed in the origin (0, 0, 0). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – edge count of basis_vector .IP \(bu 2 \fBradius\fP – radius of basis_vector .IP \(bu 2 \fBapex\fP – tip of the cone .IP \(bu 2 \fBcaps\fP – add a bottom face as ngon if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.cone_2p(count: int = 16, radius: float = 1.0, base_center: \fI\%UVec\fP = (0, 0, 0), apex: \fI\%UVec\fP = (0, 0, 1), *, caps=True) -> MeshTransformer Create a \fI\%cone\fP as \fI\%MeshTransformer\fP object from two points, \fIbase_center\fP is the center of the base circle and \fIapex\fP as the tip of the cone. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – edge count of basis_vector .IP \(bu 2 \fBradius\fP – radius of basis_vector .IP \(bu 2 \fBbase_center\fP – center point of base circle .IP \(bu 2 \fBapex\fP – tip of the cone .IP \(bu 2 \fBcaps\fP – add a bottom face as ngon if \fBTrue\fP .UNINDENT .TP .B Raises \fBValueError\fP – the cone orientation cannot be detected (base center == apex) .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.cylinder(count: int = 16, radius: float = 1.0, top_radius: float | None = None, top_center: \fI\%UVec\fP = (0, 0, 1), *, caps=True) -> MeshTransformer Create a \fI\%cylinder\fP as \fI\%MeshTransformer\fP object, the base center is fixed in the origin (0, 0, 0). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – profiles edge count .IP \(bu 2 \fBradius\fP – radius for bottom profile .IP \(bu 2 \fBtop_radius\fP – radius for top profile, if \fBNone\fP top_radius == radius .IP \(bu 2 \fBtop_center\fP – location vector for the center of the top profile .IP \(bu 2 \fBcaps\fP – close hull with top\- and bottom faces (ngons) .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.cylinder_2p(count: int = 16, radius: float = 1, base_center: \fI\%UVec\fP = (0, 0, 0), top_center: \fI\%UVec\fP = (0, 0, 1), *, caps=True) -> MeshTransformer Creates a \fI\%cylinder\fP as \fI\%MeshTransformer\fP object from two points, \fIbase_center\fP is the center of the base circle and, \fItop_center\fP the center of the top circle. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – cylinder profile edge count .IP \(bu 2 \fBradius\fP – radius for bottom profile .IP \(bu 2 \fBbase_center\fP – center of base circle .IP \(bu 2 \fBtop_center\fP – center of top circle .IP \(bu 2 \fBcaps\fP – close hull with top\- and bottom faces (ngons) .UNINDENT .TP .B Raises \fBValueError\fP – the cylinder orientation cannot be detected (base center == top center) .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.helix(radius: float, pitch: float, turns: float, resolution: int = 16, ccw=True) -> Iterator[\fI\%Vec3\fP] Yields the vertices of a \fI\%helix\fP\&. The center of the helix is always (0, 0), a positive \fIpitch\fP value creates a helix along the +z\-axis, a negative value along the \-z\-axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP – helix radius .IP \(bu 2 \fBpitch\fP – the height of one complete helix turn .IP \(bu 2 \fBturns\fP – count of turns .IP \(bu 2 \fBresolution\fP – vertices per turn .IP \(bu 2 \fBccw\fP – creates a counter\-clockwise turning (right\-handed) helix if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.sphere(count: int = 16, stacks: int = 8, radius: float = 1, *, quads=True) -> MeshTransformer Create a \fI\%sphere\fP as \fI\%MeshTransformer\fP object, the center of the sphere is always at (0, 0, 0). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – longitudinal slices .IP \(bu 2 \fBstacks\fP – latitude slices .IP \(bu 2 \fBradius\fP – radius of sphere .IP \(bu 2 \fBquads\fP – use quadrilaterals as faces if \fBTrue\fP else triangles .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.torus(major_count: int = 16, minor_count: int = 8, major_radius=1.0, minor_radius=0.1, start_angle: float = 0.0, end_angle: float = math.tau, *, caps=True) -> MeshTransformer Create a \fI\%torus\fP as \fI\%MeshTransformer\fP object, the center of the torus is always at (0, 0, 0). The \fImajor_radius\fP has to be bigger than the \fIminor_radius\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmajor_count\fP – count of circles .IP \(bu 2 \fBminor_count\fP – count of circle vertices .IP \(bu 2 \fBmajor_radius\fP – radius of the circle center .IP \(bu 2 \fBminor_radius\fP – radius of circle .IP \(bu 2 \fBstart_angle\fP – start angle of torus in radians .IP \(bu 2 \fBend_angle\fP – end angle of torus in radians .IP \(bu 2 \fBcaps\fP – close hull with start\- and end faces (ngons) if the torus is open .UNINDENT .UNINDENT .UNINDENT .SS 3D Form Builder .INDENT 0.0 .TP .B ezdxf.render.forms.extrude(profile: Iterable[\fI\%UVec\fP], path: Iterable[\fI\%UVec\fP], close=True, caps=False) -> MeshTransformer Extrude a \fIprofile\fP polygon along a \fIpath\fP polyline, the vertices of \fIprofile\fP should be in counter\-clockwise order. The sweeping profile will not be rotated at extrusion! .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBprofile\fP – sweeping profile as list of (x, y, z) tuples in counter\-clockwise order .IP \(bu 2 \fBpath\fP – extrusion path as list of (x, y, z) tuples .IP \(bu 2 \fBclose\fP – close profile polygon if \fBTrue\fP .IP \(bu 2 \fBcaps\fP – close hull with top\- and bottom faces (ngons) .UNINDENT .UNINDENT .sp Returns: \fI\%MeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.extrude_twist_scale(profile: Iterable[\fI\%UVec\fP], path: Iterable[\fI\%UVec\fP], *, twist: float = 0.0, scale: float = 1.0, step_size: float = 1.0, close=True, caps=False, quads=True) -> MeshTransformer Extrude a \fIprofile\fP polygon along a \fIpath\fP polyline, the vertices of \fIprofile\fP should be in counter\-clockwise order. This implementation can scale and twist the sweeping profile along the extrusion path. The \fIpath\fP segment points are fix points, the \fImax_step_size\fP is used to create intermediate profiles between this fix points. The \fImax_step_size\fP is adapted for each segment to create equally spaced distances. The twist angle is the rotation angle in radians and the scale \fIargument\fP defines the scale factor of the final profile. The twist angle and scaling factor of the intermediate profiles will be linear interpolated between the start and end values. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBprofile\fP – sweeping profile as list of (x, y, z) tuples in counter\-clockwise order .IP \(bu 2 \fBpath\fP – extrusion path as list of (x, y, z) tuples .IP \(bu 2 \fBtwist\fP – rotate sweeping profile up to the given end rotation angle in radians .IP \(bu 2 \fBscale\fP – scale sweeping profile gradually from 1.0 to given value .IP \(bu 2 \fBstep_size\fP – rough distance between automatically created intermediate profiles, the step size is adapted to the distances between the path segment points, a value od 0.0 disables creating intermediate profiles .IP \(bu 2 \fBclose\fP – close profile polygon if \fBTrue\fP .IP \(bu 2 \fBcaps\fP – close hull with top\- and bottom faces (ngons) .IP \(bu 2 \fBquads\fP – use quads for “sweeping” faces if \fBTrue\fP else triangles, the top and bottom faces are always ngons .UNINDENT .UNINDENT .sp Returns: \fI\%MeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.from_profiles_linear(profiles: Sequence[Sequence[\fI\%Vec3\fP]], *, close=True, quads=True, caps=False) -> MeshTransformer Returns a \fI\%MeshTransformer\fP instance from linear connected \fIprofiles\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBprofiles\fP – list of profiles .IP \(bu 2 \fBclose\fP – close profile polygon if \fBTrue\fP .IP \(bu 2 \fBquads\fP – use quadrilaterals as connection faces if \fBTrue\fP else triangles .IP \(bu 2 \fBcaps\fP – close hull with top\- and bottom faces (ngons) .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.from_profiles_spline(profiles: Sequence[Sequence[\fI\%Vec3\fP]], subdivide: int = 4, *, close=True, quads=True, caps=False) -> MeshTransformer Returns a \fI\%MeshTransformer\fP instance by spline interpolation between given \fIprofiles\fP\&. Requires at least 4 profiles. A \fIsubdivide\fP value of 4, means, create 4 face loops between two profiles, without interpolation two profiles create one face loop. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBprofiles\fP – list of profiles .IP \(bu 2 \fBsubdivide\fP – count of face loops .IP \(bu 2 \fBclose\fP – close profile polygon if \fBTrue\fP .IP \(bu 2 \fBquads\fP – use quadrilaterals as connection faces if \fBTrue\fP else triangles .IP \(bu 2 \fBcaps\fP – close hull with top\- and bottom faces (ngons) .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.rotation_form(count: int, profile: Iterable[\fI\%UVec\fP], angle: float = math.tau, axis: \fI\%UVec\fP = (1, 0, 0), *, caps=False) -> MeshTransformer Returns a \fI\%MeshTransformer\fP instance created by rotating a \fIprofile\fP around an \fIaxis\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of rotated profiles .IP \(bu 2 \fBprofile\fP – profile to rotate as list of vertices .IP \(bu 2 \fBangle\fP – rotation angle in radians .IP \(bu 2 \fBaxis\fP – rotation axis .IP \(bu 2 \fBcaps\fP – close hull with start\- and end faces (ngons) .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.sweep(profile: Iterable[\fI\%UVec\fP], sweeping_path: Iterable[\fI\%UVec\fP], *, close=True, quads=True, caps=True) -> MeshTransformer Returns the mesh from sweeping a profile along a 3D path, where the sweeping path defines the final location in the \fIWCS\fP\&. .sp The profile is defined in a reference system. The origin of this reference system will be moved along the sweeping path where the z\-axis of the reference system is pointing into the moving direction. .sp Returns the mesh as \fI\%ezdxf.render.MeshTransformer\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBprofile\fP – sweeping profile defined in the reference system as iterable of (x, y, z) coordinates in counter\-clockwise order .IP \(bu 2 \fBsweeping_path\fP – the sweeping path defined in the WCS as iterable of (x, y, z) coordinates .IP \(bu 2 \fBclose\fP – close sweeping profile if \fBTrue\fP .IP \(bu 2 \fBquads\fP – use quadrilaterals as connection faces if \fBTrue\fP else triangles .IP \(bu 2 \fBcaps\fP – close hull with top\- and bottom faces (ngons) .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.sweep_profile(profile: Iterable[\fI\%UVec\fP], sweeping_path: Iterable[\fI\%UVec\fP]) -> list[Sequence[\fI\%Vec3\fP]] Returns the intermediate profiles of sweeping a profile along a 3D path where the sweeping path defines the final location in the \fIWCS\fP\&. .sp The profile is defined in a reference system. The origin of this reference system will be moved along the sweeping path where the z\-axis of the reference system is pointing into the moving direction. .sp Returns the start\-, end\- and all intermediate profiles along the sweeping path. .UNINDENT .SS MeshBuilder .sp The \fI\%MeshBuilder\fP classes are helper tools to manage meshes buildup by vertices and faces. The vertices are stored in a vertices list as \fBVec3\fP instances. The faces are stored as a sequence of vertex indices which is the location of the vertex in the vertex list. A single \fI\%MeshBuilder\fP class can contain multiple separated meshes at the same time. .sp The method \fI\%MeshBuilder.render_mesh()\fP renders the content as a single DXF \fI\%Mesh\fP entity, which supports ngons, ngons are polygons with more than 4 vertices. This entity requires at least DXF R2000. .sp The method \fI\%MeshBuilder.render_polyface()\fP renders the content as a single DXF \fI\%Polyface\fP entity, which supports only triangles and quadrilaterals. This entity is supported by DXF R12. .sp The method \fI\%MeshBuilder.render_3dfaces()\fP renders each face of the mesh as a single DXF \fI\%Face3d\fP entity, which supports only triangles and quadrilaterals. This entity is supported by DXF R12. .sp The \fI\%MeshTransformer\fP class is often used as an interface object to transfer mesh data between functions and moduls, like for the mesh exchange add\-on \fI\%meshex\fP\&. .sp The basic \fI\%MeshBuilder\fP class does not support transformations. .INDENT 0.0 .TP .B class ezdxf.render.MeshBuilder .INDENT 7.0 .TP .B vertices List of vertices as \fI\%Vec3\fP or \fB(x, y, z)\fP tuple .UNINDENT .INDENT 7.0 .TP .B faces List of faces as list of vertex indices, where a vertex index is the index of the vertex in the \fI\%vertices\fP list. A face requires at least three vertices, \fI\%Mesh\fP supports ngons, so the count of vertices is not limited. .UNINDENT .INDENT 7.0 .TP .B add_face(vertices: Iterable[\fI\%UVec\fP]) -> None Add a face as vertices list to the mesh. A face requires at least 3 vertices, each vertex is a \fB(x, y, z)\fP tuple or \fI\%Vec3\fP object. The new vertex indices are stored as face in the \fI\%faces\fP list. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – list of at least 3 vertices \fB[(x1, y1, z1), (x2, y2, z2), (x3, y3, y3), ...]\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mesh(vertices: list[\fI\%Vec3\fP] | None = None, faces: list[Sequence[int]] | None = None, mesh=None) -> None Add another mesh to this mesh. .sp A \fImesh\fP can be a \fI\%MeshBuilder\fP, \fI\%MeshVertexMerger\fP or \fI\%Mesh\fP object or requires the attributes \fI\%vertices\fP and \fI\%faces\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – list of vertices, a vertex is a \fB(x, y, z)\fP tuple or \fI\%Vec3\fP object .IP \(bu 2 \fBfaces\fP – list of faces, a face is a list of vertex indices .IP \(bu 2 \fBmesh\fP – another mesh entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_vertices(vertices: Iterable[\fI\%UVec\fP]) -> Sequence[int] Add new vertices to the mesh, each vertex is a \fB(x, y, z)\fP tuple or a \fI\%Vec3\fP object, returns the indices of the \fIvertices\fP added to the \fI\%vertices\fP list. .sp e.g. adding 4 vertices to an empty mesh, returns the indices \fB(0, 1, 2, 3)\fP, adding additional 4 vertices returns the indices \fB(4, 5, 6, 7)\fP\&. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – list of vertices, vertex as \fB(x, y, z)\fP tuple or \fI\%Vec3\fP objects .TP .B Returns indices of the \fIvertices\fP added to the \fI\%vertices\fP list .TP .B Return type tuple .UNINDENT .UNINDENT .INDENT 7.0 .TP .B bbox() -> \fI\%BoundingBox\fP Returns the \fI\%BoundingBox\fP of the mesh. .UNINDENT .INDENT 7.0 .TP .B copy() Returns a copy of mesh. .UNINDENT .INDENT 7.0 .TP .B diagnose() -> MeshDiagnose Returns the \fI\%MeshDiagnose\fP object for this mesh. .UNINDENT .INDENT 7.0 .TP .B face_normals() -> Iterator[\fI\%Vec3\fP] Yields all face normals, yields the \fBNULLVEC\fP instance for degenerated faces. .UNINDENT .INDENT 7.0 .TP .B face_orientation_detector(reference: int = 0) -> \fI\%FaceOrientationDetector\fP Returns a \fI\%FaceOrientationDetector\fP or short \fIfod\fP instance. The forward orientation is defined by the \fIreference\fP face which is 0 by default. .sp The \fIfod\fP can check if all faces are reachable from the reference face and if all faces have the same orientation. The \fIfod\fP can be reused to unify the face orientation of the mesh. .UNINDENT .INDENT 7.0 .TP .B faces_as_vertices() -> Iterator[list[\fI\%Vec3\fP]] Yields all faces as list of vertices. .UNINDENT .INDENT 7.0 .TP .B flip_normals() -> None Flips the normals of all faces by reversing the vertex order inplace. .UNINDENT .INDENT 7.0 .TP .B classmethod from_builder(other: \fI\%MeshBuilder\fP) Create new mesh from other mesh builder, faster than \fI\%from_mesh()\fP but supports only \fI\%MeshBuilder\fP and inherited classes. .UNINDENT .INDENT 7.0 .TP .B classmethod from_mesh(other: \fI\%MeshBuilder\fP | \fI\%Mesh\fP) -> T Create new mesh from other mesh as class method. .INDENT 7.0 .TP .B Parameters \fBother\fP – \fImesh\fP of type \fI\%MeshBuilder\fP and inherited or DXF \fI\%Mesh\fP entity or any object providing attributes \fI\%vertices\fP, \fBedges\fP and \fI\%faces\fP\&. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_polyface(other: \fI\%Polymesh\fP | \fI\%Polyface\fP) -> T Create new mesh from a \fI\%Polyface\fP or \fI\%Polymesh\fP object. .UNINDENT .INDENT 7.0 .TP .B get_face_vertices(index: int) -> Sequence[\fI\%Vec3\fP] Returns the face \fIindex\fP as sequence of \fI\%Vec3\fP objects. .UNINDENT .INDENT 7.0 .TP .B get_face_normal(index: int) -> \fI\%Vec3\fP Returns the normal vector of the face \fIindex\fP as \fI\%Vec3\fP, returns the \fBNULLVEC\fP instance for degenerated faces. .UNINDENT .INDENT 7.0 .TP .B merge_coplanar_faces(passes: int = 1) -> MeshTransformer Returns a new \fI\%MeshBuilder\fP object with merged adjacent coplanar faces. .sp The faces have to share at least two vertices and have to have the same clockwise or counter\-clockwise vertex order. .sp The current implementation is not very capable! .UNINDENT .INDENT 7.0 .TP .B mesh_tessellation(max_vertex_count: int = 4) -> MeshTransformer Returns a new \fI\%MeshTransformer\fP instance, where each face has no more vertices than the given \fImax_vertex_count\fP\&. .sp The \fIfast\fP mode uses a shortcut for faces with less than 6 vertices which may not work for concave faces! .UNINDENT .INDENT 7.0 .TP .B normalize_faces() -> None Removes duplicated vertex indices from faces and stores all faces as open faces, where the last vertex is not coincident with the first vertex. .UNINDENT .INDENT 7.0 .TP .B open_faces() -> Iterator[Sequence[int]] Yields all faces as sequence of integers where the first vertex is not coincident with the last vertex. .UNINDENT .INDENT 7.0 .TP .B optimize_vertices(precision: int = 6) -> MeshTransformer Returns a new mesh with optimized vertices. Coincident vertices are merged together and all faces are open faces (first vertex != last vertex). Uses internally the \fI\%MeshVertexMerger\fP class to merge vertices. .UNINDENT .INDENT 7.0 .TP .B render_3dfaces(layout: GenericLayoutType, dxfattribs=None, matrix: \fI\%Matrix44\fP | None = None, ucs: \fI\%UCS\fP | None = None) Render mesh as \fI\%Face3d\fP entities into \fIlayout\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes e.g. \fB{\(aqlayer\(aq: \(aqmesh\(aq, \(aqcolor\(aq: 7}\fP .IP \(bu 2 \fBmatrix\fP – transformation matrix of type \fI\%Matrix44\fP .IP \(bu 2 \fBucs\fP – transform vertices by \fI\%UCS\fP to \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_mesh(layout: GenericLayoutType, dxfattribs=None, matrix: \fI\%Matrix44\fP | None = None, ucs: \fI\%UCS\fP | None = None) Render mesh as \fI\%Mesh\fP entity into \fIlayout\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes e.g. \fB{\(aqlayer\(aq: \(aqmesh\(aq, \(aqcolor\(aq: 7}\fP .IP \(bu 2 \fBmatrix\fP – transformation matrix of type \fI\%Matrix44\fP .IP \(bu 2 \fBucs\fP – transform vertices by \fI\%UCS\fP to \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_normals(layout: GenericLayoutType, length: float = 1, relative=True, dxfattribs=None) Render face normals as \fI\%Line\fP entities into \fIlayout\fP, useful to check orientation of mesh faces. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBlength\fP – visual length of normal, use length < 0 to point normals in opposite direction .IP \(bu 2 \fBrelative\fP – scale length relative to face size if \fBTrue\fP .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes e.g. \fB{\(aqlayer\(aq: \(aqnormals\(aq, \(aqcolor\(aq: 6}\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_polyface(layout: GenericLayoutType, dxfattribs=None, matrix: \fI\%Matrix44\fP | None = None, ucs: \fI\%UCS\fP | None = None) Render mesh as \fI\%Polyface\fP entity into \fIlayout\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fI\%BaseLayout\fP object .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes e.g. \fB{\(aqlayer\(aq: \(aqmesh\(aq, \(aqcolor\(aq: 7}\fP .IP \(bu 2 \fBmatrix\fP – transformation matrix of type \fI\%Matrix44\fP .IP \(bu 2 \fBucs\fP – transform vertices by \fI\%UCS\fP to \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B separate_meshes() -> list[MeshTransformer] A single \fI\%MeshBuilder\fP instance can store multiple separated meshes. This function returns this separated meshes as multiple \fI\%MeshTransformer\fP instances. .UNINDENT .INDENT 7.0 .TP .B subdivide(level: int = 1, quads=True) -> MeshTransformer Returns a new \fI\%MeshTransformer\fP object with all faces subdivided. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlevel\fP – subdivide levels from 1 to max of 5 .IP \(bu 2 \fBquads\fP – create quad faces if \fBTrue\fP else create triangles .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B subdivide_ngons(max_vertex_count=4) -> Iterator[Sequence[\fI\%Vec3\fP]] Yields all faces as sequence of \fI\%Vec3\fP instances, where all ngons which have more than \fImax_vertex_count\fP vertices gets subdivided. In contrast to the \fI\%tessellation()\fP method, creates this method a new vertex in the centroid of the face. This can create a more regular tessellation but only works reliable for convex faces! .UNINDENT .INDENT 7.0 .TP .B tessellation(max_vertex_count: int = 4) -> Iterator[Sequence[\fI\%Vec3\fP]] Yields all faces as sequence of \fI\%Vec3\fP instances, each face has no more vertices than the given \fImax_vertex_count\fP\&. This method uses the “ear clipping” algorithm which works with concave faces too and does not create any additional vertices. .UNINDENT .INDENT 7.0 .TP .B unify_face_normals(*, fod: \fI\%FaceOrientationDetector\fP | None = None) -> MeshTransformer Returns a new \fI\%MeshTransformer\fP object with unified face normal vectors of all faces. The forward direction (not necessarily outwards) is defined by the face\-normals of the majority of the faces. This function can not process non\-manifold meshes (more than two faces are connected by a single edge) or multiple disconnected meshes in a single \fI\%MeshBuilder\fP object. .sp It is possible to pass in an existing \fI\%FaceOrientationDetector\fP instance as argument \fIfod\fP\&. .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBNonManifoldError\fP – non\-manifold mesh .IP \(bu 2 \fBMultipleMeshesError\fP – the \fI\%MeshBuilder\fP object contains multiple disconnected meshes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B unify_face_normals_by_reference(reference: int = 0, *, force_outwards=False, fod: \fI\%FaceOrientationDetector\fP | None = None) -> MeshTransformer Returns a new \fI\%MeshTransformer\fP object with unified face normal vectors of all faces. The forward direction (not necessarily outwards) is defined by the reference face, which is the first face of the \fImesh\fP by default. This function can not process non\-manifold meshes (more than two faces are connected by a single edge) or multiple disconnected meshes in a single \fI\%MeshBuilder\fP object. .sp The outward direction of all face normals can be forced by stetting the argument \fIforce_outwards\fP to \fBTrue\fP but this works only for closed surfaces, and it’s time\-consuming! .sp It is not possible to check for a closed surface as long the face normal vectors are not unified. But it can be done afterward by the attribute \fI\%MeshDiagnose.is_closed_surface()\fP to see if the result is trustworthy. .sp It is possible to pass in an existing \fI\%FaceOrientationDetector\fP instance as argument \fIfod\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBreference\fP – index of the reference face .IP \(bu 2 \fBforce_outwards\fP – forces face\-normals to point outwards, this works only for closed surfaces, and it’s time\-consuming! .IP \(bu 2 \fBfod\fP – \fI\%FaceOrientationDetector\fP instance .UNINDENT .TP .B Raises \fBValueError\fP – non\-manifold mesh or the \fI\%MeshBuilder\fP object contains multiple disconnected meshes .UNINDENT .UNINDENT .UNINDENT .SS MeshTransformer .sp Same functionality as \fI\%MeshBuilder\fP but supports inplace transformation. .INDENT 0.0 .TP .B class ezdxf.render.MeshTransformer Subclass of \fI\%MeshBuilder\fP .INDENT 7.0 .TP .B transform(matrix: \fI\%Matrix44\fP) Transform mesh inplace by applying the transformation \fImatrix\fP\&. .INDENT 7.0 .TP .B Parameters \fBmatrix\fP – 4x4 transformation matrix as \fI\%Matrix44\fP object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx: float | \fI\%UVec\fP = 0, dy: float = 0, dz: float = 0) Translate mesh inplace. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP – translation in x\-axis or translation vector .IP \(bu 2 \fBdy\fP – translation in y\-axis .IP \(bu 2 \fBdz\fP – translation in z\-axis .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(sx: float = 1, sy: float = 1, sz: float = 1) Scale mesh inplace. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsx\fP – scale factor for x\-axis .IP \(bu 2 \fBsy\fP – scale factor for y\-axis .IP \(bu 2 \fBsz\fP – scale factor for z\-axis .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale_uniform(s: float) Scale mesh uniform inplace. .INDENT 7.0 .TP .B Parameters \fBs\fP – scale factor for x\-, y\- and z\-axis .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_x(angle: float) Rotate mesh around x\-axis about \fIangle\fP inplace. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_y(angle: float) Rotate mesh around y\-axis about \fIangle\fP inplace. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_z(angle: float) Rotate mesh around z\-axis about \fIangle\fP inplace. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_axis(axis: \fI\%UVec\fP, angle: float) Rotate mesh around an arbitrary axis located in the origin (0, 0, 0) about \fIangle\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBaxis\fP – rotation axis as Vec3 .IP \(bu 2 \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS MeshVertexMerger .sp Same functionality as \fI\%MeshBuilder\fP, but created meshes with unique vertices and no doublets, but \fI\%MeshVertexMerger\fP needs extra memory for bookkeeping and also does not support transformations. The location of the merged vertices is the location of the first vertex with the same key. .sp This class is intended as intermediate object to create compact meshes and convert them to \fI\%MeshTransformer\fP objects to apply transformations: .INDENT 0.0 .INDENT 3.5 .sp .EX mesh = MeshVertexMerger() # create your mesh mesh.add_face(...) # convert mesh to MeshTransformer object return MeshTransformer.from_builder(mesh) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.MeshVertexMerger(precision: int = 6) Subclass of \fI\%MeshBuilder\fP .sp Mesh with unique vertices and no doublets, but needs extra memory for bookkeeping. .sp \fI\%MeshVertexMerger\fP creates a key for every vertex by rounding its components by the Python \fBround()\fP function and a given \fIprecision\fP value. Each vertex with the same key gets the same vertex index, which is the index of first vertex with this key, so all vertices with the same key will be located at the location of this first vertex. If you want an average location of all vertices with the same key use the \fI\%MeshAverageVertexMerger\fP class. .INDENT 7.0 .TP .B Parameters \fBprecision\fP – floating point precision for vertex rounding .UNINDENT .UNINDENT .SS MeshAverageVertexMerger .sp This is an extended version of \fI\%MeshVertexMerger\fP\&. The location of the merged vertices is the average location of all vertices with the same key, this needs extra memory and runtime in comparison to \fI\%MeshVertexMerger\fP and this class also does not support transformations. .INDENT 0.0 .TP .B class ezdxf.render.MeshAverageVertexMerger(precision: int = 6) Subclass of \fI\%MeshBuilder\fP .sp Mesh with unique vertices and no doublets, but needs extra memory for bookkeeping and runtime for calculation of average vertex location. .sp \fI\%MeshAverageVertexMerger\fP creates a key for every vertex by rounding its components by the Python \fBround()\fP function and a given \fIprecision\fP value. Each vertex with the same key gets the same vertex index, which is the index of first vertex with this key, the difference to the \fI\%MeshVertexMerger\fP class is the calculation of the average location for all vertices with the same key, this needs extra memory to keep track of the count of vertices for each key and extra runtime for updating the vertex location each time a vertex with an existing key is added. .INDENT 7.0 .TP .B Parameters \fBprecision\fP – floating point precision for vertex rounding .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.mesh.EdgeStat(count: int, balance: int) Named tuple of edge statistics. .INDENT 7.0 .TP .B count how often the edge \fI(a, b)\fP is used in faces as \fI(a, b)\fP or \fI(b, a)\fP .UNINDENT .INDENT 7.0 .TP .B balance count of edges \fI(a, b)\fP \- count of edges \fI(b, a)\fP and should be 0 in “healthy” closed surfaces, if the balance is not 0, maybe doubled coincident faces exist or faces may have mixed clockwise and counter\-clockwise vertex orders .UNINDENT .UNINDENT .SS MeshBuilder Helper Classes .INDENT 0.0 .TP .B class ezdxf.render.MeshDiagnose Diagnose tool which can be used to analyze and detect errors of \fI\%MeshBuilder\fP objects like topology errors for closed surfaces. The object contains cached values, which do not get updated if the source mesh will be changed! .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 There exist no tools in \fIezdxf\fP to repair broken surfaces, but you can use the \fI\%ezdxf.addons.meshex\fP addon to exchange meshes with the open source tool \fI\%MeshLab\fP\&. .UNINDENT .UNINDENT .sp Create an instance of this tool by the \fI\%MeshBuilder.diagnose()\fP method. .INDENT 7.0 .TP .B property bbox: \fI\%BoundingBox\fP Returns the \fI\%BoundingBox\fP of the mesh. (cached data) .UNINDENT .INDENT 7.0 .TP .B property edge_stats: Dict[Tuple[int, int], \fI\%EdgeStat\fP] Returns the edge statistics as a \fBdict\fP\&. The dict\-key is the edge as tuple of two vertex indices \fI(a, b)\fP where \fIa\fP is always smaller than \fIb\fP\&. The dict\-value is an \fBEdgeStat\fP tuple of edge count and edge balance, see \fBEdgeStat\fP for the definition of edge count and edge balance. (cached data) .UNINDENT .INDENT 7.0 .TP .B property euler_characteristic: int Returns the Euler characteristic: \fI\%https://en.wikipedia.org/wiki/Euler_characteristic\fP .sp This number is always 2 for convex polyhedra. .UNINDENT .INDENT 7.0 .TP .B property face_normals: Sequence[\fI\%Vec3\fP] Returns all face normal vectors as sequence. The \fBNULLVEC\fP instance is used as normal vector for degenerated faces. (cached data) .UNINDENT .INDENT 7.0 .TP .B property faces: Sequence[Sequence[int]] Sequence of faces as \fBSequence[int]\fP .UNINDENT .INDENT 7.0 .TP .B property is_closed_surface: bool Returns \fBTrue\fP if the mesh has a closed surface. This method does not require a unified face orientation. If multiple separated meshes are present the state is only \fBTrue\fP if \fBall\fP meshes have a closed surface. (cached data) .sp Returns \fBFalse\fP for non\-manifold meshes. .UNINDENT .INDENT 7.0 .TP .B property is_edge_balance_broken: bool Returns \fBTrue\fP if the edge balance is broken, this indicates a topology error for closed surfaces. A non\-broken edge balance reflects that each edge connects two faces, where the edge is clockwise oriented in the first face and counter\-clockwise oriented in the second face. A broken edge balance indicates possible topology errors like mixed face vertex orientations or a non\-manifold mesh where an edge connects more than two faces. (cached data) .UNINDENT .INDENT 7.0 .TP .B property is_manifold: bool Returns \fBTrue\fP if all edges have an edge count < 3. (cached data) .sp A non\-manifold mesh has edges with 3 or more connected faces. .UNINDENT .INDENT 7.0 .TP .B property n_edges: int Returns the unique edge count. (cached data) .UNINDENT .INDENT 7.0 .TP .B property n_faces: int Returns the face count. .UNINDENT .INDENT 7.0 .TP .B property n_vertices: int Returns the vertex count. .UNINDENT .INDENT 7.0 .TP .B property vertices: Sequence[\fI\%Vec3\fP] Sequence of mesh vertices as \fI\%Vec3\fP instances .UNINDENT .INDENT 7.0 .TP .B centroid() -> \fI\%Vec3\fP Returns the centroid of all vertices. (center of mass) .UNINDENT .INDENT 7.0 .TP .B estimate_face_normals_direction() -> float Returns the estimated face\-normals direction as \fBfloat\fP value in the range [\-1.0, 1.0] for a closed surface. .sp This heuristic works well for simple convex hulls but struggles with more complex structures like a torus (doughnut). .sp A counter\-clockwise (ccw) vertex arrangement for outward pointing faces is assumed but a clockwise (cw) arrangement works too but the return values are reversed. .sp The closer the value to 1.0 (\-1.0 for cw) the more likely all normals pointing outwards from the surface. .sp The closer the value to \-1.0 (1.0 for cw) the more likely all normals pointing inwards from the surface. .sp There are no exact confidence values if all faces pointing outwards, here some examples for surfaces created by \fI\%ezdxf.render.forms\fP functions: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%cube()\fP returns 1.0 .IP \(bu 2 \fI\%cylinder()\fP returns 0.9992 .IP \(bu 2 \fI\%sphere()\fP returns 0.9994 .IP \(bu 2 \fI\%cone()\fP returns 0.9162 .IP \(bu 2 \fI\%cylinder()\fP with all hull faces pointing outwards but caps pointing inwards returns 0.7785 but the property \fI\%is_edge_balance_broken\fP returns \fBTrue\fP which indicates the mixed vertex orientation .IP \(bu 2 and the estimation of 0.0469 for a \fI\%torus()\fP is barely usable .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_non_planar_faces() -> bool Returns \fBTrue\fP if any face is non\-planar. .UNINDENT .INDENT 7.0 .TP .B surface_area() -> float Returns the surface area. .UNINDENT .INDENT 7.0 .TP .B total_edge_count() -> int Returns the total edge count of all faces, shared edges are counted separately for each face. In closed surfaces this count should be 2x the unique edge count \fI\%n_edges\fP\&. (cached data) .UNINDENT .INDENT 7.0 .TP .B unique_edges() -> Iterable[Tuple[int, int]] Yields the unique edges of the mesh as int 2\-tuples. (cached data) .UNINDENT .INDENT 7.0 .TP .B volume() -> float Returns the volume of a closed surface or 0 otherwise. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 The face vertices have to be in counter\-clockwise order, this requirement is not checked by this method. .sp The result is not correct for multiple separated meshes in a single MeshBuilder object!!! .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.FaceOrientationDetector(mesh: MeshBuilder, reference: int = 0) Helper class for face orientation and face normal vector detection. Use the method \fI\%MeshBuilder.face_orientation_detector()\fP to create an instance. .sp The face orientation detector classifies the faces of a mesh by their forward or backward orientation. The forward orientation is defined by a reference face, which is the first face of the mesh by default and this orientation is not necessarily outwards. .sp This class has some overlapping features with \fI\%MeshDiagnose\fP but it has a longer setup time and needs more memory than \fI\%MeshDiagnose\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmesh\fP – source mesh as \fI\%MeshBuilder\fP object .IP \(bu 2 \fBreference\fP – index of the reference face .UNINDENT .UNINDENT .INDENT 7.0 .TP .B is_manifold \fBTrue\fP if all edges have an edge count < 3. A non\-manifold mesh has edges with 3 or more connected faces. .UNINDENT .INDENT 7.0 .TP .B property all_reachable: bool Returns \fBTrue\fP if all faces are reachable from the reference face same as property \fI\%is_single_mesh\fP\&. .UNINDENT .INDENT 7.0 .TP .B property count: tuple[int, int] Returns the count of forward and backward oriented faces. .UNINDENT .INDENT 7.0 .TP .B property backward_faces: Iterator[Sequence[int]] Yields all backward oriented faces. .UNINDENT .INDENT 7.0 .TP .B property forward_faces: Iterator[Sequence[int]] Yields all forward oriented faces. .UNINDENT .INDENT 7.0 .TP .B property has_uniform_face_normals: bool Returns \fBTrue\fP if all reachable faces are forward oriented according to the reference face. .UNINDENT .INDENT 7.0 .TP .B property is_closed_surface: bool Returns \fBTrue\fP if the mesh has a closed surface. This method does not require a unified face orientation. If multiple separated meshes are present the state is only \fBTrue\fP if \fBall\fP meshes have a closed surface. .sp Returns \fBFalse\fP for non\-manifold meshes. .UNINDENT .INDENT 7.0 .TP .B property is_single_mesh: bool Returns \fBTrue\fP if only a single mesh is present same as property \fI\%all_reachable\fP\&. .UNINDENT .INDENT 7.0 .TP .B classify_faces(reference: int = 0) -> None Detect the forward and backward oriented faces. .sp The forward and backward orientation has to be defined by a \fIreference\fP face. .UNINDENT .INDENT 7.0 .TP .B is_reference_face_pointing_outwards() -> bool Returns \fBTrue\fP if the normal vector of the reference face is pointing outwards. This works only for meshes with unified faces which represent a closed surfaces, and it’s a time\-consuming calculation! .UNINDENT .UNINDENT .SS Trace .sp This module provides tools to create banded lines like LWPOLYLINE with width information. Path rendering as quadrilaterals: \fI\%Trace\fP, \fI\%Solid\fP or \fI\%Face3d\fP\&. .INDENT 0.0 .TP .B class ezdxf.render.trace.TraceBuilder Sequence of 2D banded lines like polylines with start\- and end width or curves with start\- and end width. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 Accepts 3D input, but z\-axis is ignored. The \fI\%TraceBuilder\fP is a 2D only object and uses only the \fI\%OCS\fP coordinates! .UNINDENT .UNINDENT .INDENT 7.0 .TP .B abs_tol Absolute tolerance for floating point comparisons .UNINDENT .INDENT 7.0 .TP .B append(trace: AbstractTrace) -> None Append a new trace. .UNINDENT .INDENT 7.0 .TP .B close() Close multi traces by merging first and last trace, if linear traces. .UNINDENT .INDENT 7.0 .TP .B faces() -> Iterable[Tuple[\fI\%Vec2\fP, \fI\%Vec2\fP, \fI\%Vec2\fP, \fI\%Vec2\fP]] Yields all faces as 4\-tuples of \fI\%Vec2\fP objects in \fI\%OCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B faces_wcs(ocs: \fI\%OCS\fP, elevation: float) -> Iterable[Sequence[\fI\%Vec3\fP]] Yields all faces as 4\-tuples of \fI\%Vec3\fP objects in \fI\%WCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(dxftype=\(aqTRACE\(aq, dxfattribs=None, doc: \fI\%Drawing\fP | None = None) -> Iterable[Quadrilateral] Yields faces as SOLID, TRACE or 3DFACE entities with DXF attributes given in \fIdxfattribs\fP\&. .sp If a document is given, the doc attribute of the new entities will be set and the new entities will be automatically added to the entity database of that document. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 The \fI\%TraceBuilder\fP is a 2D only object and uses only the \fI\%OCS\fP coordinates! .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdxftype\fP – DXF type as string, “SOLID”, “TRACE” or “3DFACE” .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for SOLID, TRACE or 3DFACE entities .IP \(bu 2 \fBdoc\fP – associated document .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_polyline(polyline: \fI\%DXFGraphic\fP, segments: int = 64) -> \fI\%TraceBuilder\fP Create a complete trace from a LWPOLYLINE or a 2D POLYLINE entity, the trace consist of multiple sub\-traces if \fI\%bulge\fP values are present. Uses only the \fI\%OCS\fP coordinates! .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpolyline\fP – \fI\%LWPolyline\fP or 2D \fI\%Polyline\fP .IP \(bu 2 \fBsegments\fP – count of segments for bulge approximation, given count is for a full circle, partial arcs have proportional less segments, but at least 3 .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __len__() .UNINDENT .INDENT 7.0 .TP .B __getitem__() .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.trace.LinearTrace Linear 2D banded lines like polylines with start\- and end width. .sp Accepts 3D input, but z\-axis is ignored. .INDENT 7.0 .TP .B abs_tol Absolute tolerance for floating point comparisons .UNINDENT .INDENT 7.0 .TP .B is_started \fITrue\fP if at least one station exist. .UNINDENT .INDENT 7.0 .TP .B add_station(point: \fI\%UVec\fP, start_width: float, end_width: float | None = None) -> None Add a trace station (like a vertex) at location \fIpoint\fP, \fIstart_width\fP is the width of the next segment starting at this station, \fIend_width\fP is the end width of the next segment. .sp Adding the last location again, replaces the actual last location e.g. adding lines (a, b), (b, c), creates only 3 stations (a, b, c), this is very important to connect to/from splines. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – 2D location (vertex), z\-axis of 3D vertices is ignored. .IP \(bu 2 \fBstart_width\fP – start width of next segment .IP \(bu 2 \fBend_width\fP – end width of next segment .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B faces() -> Iterable[Tuple[\fI\%Vec2\fP, \fI\%Vec2\fP, \fI\%Vec2\fP, \fI\%Vec2\fP]] Yields all faces as 4\-tuples of \fI\%Vec2\fP objects. .sp First and last miter is 90 degrees if the path is not closed, otherwise the intersection of first and last segment is taken into account, a closed path has to have explicit the same last and first vertex. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(dxftype=\(aqTRACE\(aq, dxfattribs=None, doc: \fI\%Drawing\fP | None = None) -> Iterable[Quadrilateral] Yields faces as SOLID, TRACE or 3DFACE entities with DXF attributes given in \fIdxfattribs\fP\&. .sp If a document is given, the doc attribute of the new entities will be set and the new entities will be automatically added to the entity database of that document. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdxftype\fP – DXF type as string, “SOLID”, “TRACE” or “3DFACE” .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for SOLID, TRACE or 3DFACE entities .IP \(bu 2 \fBdoc\fP – associated document .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.trace.CurvedTrace 2D banded curves like arcs or splines with start\- and end width. .sp Represents always only one curved entity and all miter of curve segments are perpendicular to curve tangents. .sp Accepts 3D input, but z\-axis is ignored. .INDENT 7.0 .TP .B faces() -> Iterable[Tuple[\fI\%Vec2\fP, \fI\%Vec2\fP, \fI\%Vec2\fP, \fI\%Vec2\fP]] Yields all faces as 4\-tuples of \fI\%Vec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(dxftype=\(aqTRACE\(aq, dxfattribs=None, doc: \fI\%Drawing\fP | None = None) -> Iterable[Quadrilateral] Yields faces as SOLID, TRACE or 3DFACE entities with DXF attributes given in \fIdxfattribs\fP\&. .sp If a document is given, the doc attribute of the new entities will be set and the new entities will be automatically added to the entity database of that document. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdxftype\fP – DXF type as string, “SOLID”, “TRACE” or “3DFACE” .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for SOLID, TRACE or 3DFACE entities .IP \(bu 2 \fBdoc\fP – associated document .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_arc(arc: \fI\%ConstructionArc\fP, start_width: float, end_width: float, segments: int = 64) -> \fI\%CurvedTrace\fP Create curved trace from an arc. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBarc\fP – \fI\%ConstructionArc\fP object .IP \(bu 2 \fBstart_width\fP – start width .IP \(bu 2 \fBend_width\fP – end width .IP \(bu 2 \fBsegments\fP – count of segments for full circle (360 degree) approximation, partial arcs have proportional less segments, but at least 3 .UNINDENT .TP .B Raises \fBValueError\fP – if arc.radius <= 0 .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_spline(spline: \fI\%BSpline\fP, start_width: float, end_width: float, segments: int) -> \fI\%CurvedTrace\fP Create curved trace from a B\-spline. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBspline\fP – \fI\%BSpline\fP object .IP \(bu 2 \fBstart_width\fP – start width .IP \(bu 2 \fBend_width\fP – end width .IP \(bu 2 \fBsegments\fP – count of segments for approximation .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Point Rendering .sp Helper function to render \fI\%Point\fP entities as DXF primitives. .INDENT 0.0 .TP .B ezdxf.render.point.virtual_entities(point: Point, pdsize: float = 1, pdmode: int = 0) -> list[DXFGraphic] Yields point graphic as DXF primitives LINE and CIRCLE entities. The dimensionless point is rendered as zero\-length line! .sp Check for this condition: .INDENT 7.0 .INDENT 3.5 .sp .EX e.dxftype() == \(aqLINE\(aq and e.dxf.start.isclose(e.dxf.end) .EE .UNINDENT .UNINDENT .sp if the rendering engine can’t handle zero\-length lines. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – DXF POINT entity .IP \(bu 2 \fBpdsize\fP – point size in drawing units .IP \(bu 2 \fBpdmode\fP – point styling mode, see \fI\%Point\fP class .UNINDENT .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Go to \fI\%ezdxf.entities.Point\fP class documentation for more information about POINT styling modes. .UNINDENT .UNINDENT .SS MultiLeaderBuilder .sp These are helper classes to build \fI\%MultiLeader\fP entities in an easy way. The \fBMultiLeader\fP entity supports two kinds of content, for each exist a specialized builder class: .INDENT 0.0 .IP \(bu 2 \fI\%MultiLeaderMTextBuilder\fP for \fI\%MText\fP content .IP \(bu 2 \fI\%MultiLeaderBlockBuilder\fP for \fI\%Block\fP content .UNINDENT .sp The usual steps of the building process are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP 1. 3 create entity by a factory method .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%add_multileader_mtext()\fP .IP \(bu 2 \fI\%add_multileader_block()\fP .UNINDENT .UNINDENT .UNINDENT .IP 2. 3 set the content .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%MultiLeaderMTextBuilder.set_content()\fP .IP \(bu 2 \fI\%MultiLeaderBlockBuilder.set_content()\fP .IP \(bu 2 \fI\%MultiLeaderBlockBuilder.set_attribute()\fP .UNINDENT .UNINDENT .UNINDENT .IP 3. 3 set properties .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%MultiLeaderBuilder.set_arrow_properties()\fP .IP \(bu 2 \fI\%MultiLeaderBuilder.set_connection_properties()\fP .IP \(bu 2 \fI\%MultiLeaderBuilder.set_connection_types()\fP .IP \(bu 2 \fI\%MultiLeaderBuilder.set_leader_properties()\fP .IP \(bu 2 \fI\%MultiLeaderBuilder.set_mleader_style()\fP .IP \(bu 2 \fI\%MultiLeaderBuilder.set_overall_scaling()\fP .UNINDENT .UNINDENT .UNINDENT .IP 4. 3 add one or more leader lines .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%MultiLeaderBuilder.add_leader_line()\fP .UNINDENT .UNINDENT .UNINDENT .IP 5. 3 finalize building process .INDENT 3.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%MultiLeaderBuilder.build()\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp The \fI\%Tutorial for MultiLeader\fP shows how to use these helper classes in more detail. .INDENT 0.0 .TP .B class ezdxf.render.MultiLeaderBuilder Abstract base class to build \fI\%MultiLeader\fP entities. .INDENT 7.0 .TP .B property context: MLeaderContext Returns the context entity \fI\%MLeaderContext\fP\&. .UNINDENT .INDENT 7.0 .TP .B property multileader: MultiLeader Returns the \fI\%MultiLeader\fP entity. .UNINDENT .INDENT 7.0 .TP .B add_leader_line(side: \fI\%ConnectionSide\fP, vertices: Iterable[\fI\%Vec2\fP]) -> None Add leader as iterable of vertices in render UCS coordinates (\fI\%WCS\fP by default). .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 Vertical (top, bottom) and horizontal attachment sides (left, right) can not be mixed in a single entity \- this is a limitation of the MULTILEADER entity. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBside\fP – connection side where to attach the leader line .IP \(bu 2 \fBvertices\fP – leader vertices .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B build(insert: \fI\%Vec2\fP, rotation: float = 0.0, ucs: \fI\%UCS\fP | None = None) -> None Compute the required geometry data. The construction plane is the xy\-plane of the given render \fI\%UCS\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinsert\fP – insert location for the content in render UCS coordinates .IP \(bu 2 \fBrotation\fP – content rotation angle around the render UCS z\-axis in degrees .IP \(bu 2 \fBucs\fP – the render \fI\%UCS\fP, default is the \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_arrow_properties(name: str = \(aq\(aq, size: float = 0.0) Set leader arrow properties all leader lines have the same arrow type. .sp The MULTILEADER entity is able to support multiple arrows, but this seems to be unsupported by CAD applications and is therefore also not supported by the builder classes. .UNINDENT .INDENT 7.0 .TP .B set_connection_properties(landing_gap: float = 0.0, dogleg_length: float = 0.0) Set the properties how to connect the leader line to the content. .sp The landing gap is the space between the content and the start of the leader line. The “dogleg” is the first line segment of the leader in the “horizontal” direction of the content. .UNINDENT .INDENT 7.0 .TP .B set_connection_types(left=HorizontalConnection.by_style, right=HorizontalConnection.by_style, top=VerticalConnection.by_style, bottom=VerticalConnection.by_style) Set the connection type for each connection side. .UNINDENT .INDENT 7.0 .TP .B set_leader_properties(color: int | \fI\%RGB\fP = colors.BYBLOCK, linetype: str = \(aqBYBLOCK\(aq, lineweight: int = const.LINEWEIGHT_BYBLOCK, leader_type=LeaderType.straight_lines) Set leader line properties. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – line color as \fI\%AutoCAD Color Index (ACI)\fP or RGB tuple .IP \(bu 2 \fBlinetype\fP – as name string, e.g. “BYLAYER” .IP \(bu 2 \fBlineweight\fP – as integer value, see: \fI\%Lineweights\fP .IP \(bu 2 \fBleader_type\fP – straight lines of spline type .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_mleader_style(style: MLeaderStyle) Reset base properties by \fI\%MLeaderStyle\fP properties. This also resets the content! .UNINDENT .INDENT 7.0 .TP .B set_overall_scaling(scale: float) Set the overall scaling factor for the whole entity, except for the leader line vertices! .INDENT 7.0 .TP .B Parameters \fBscale\fP – scaling factor > 0.0 .UNINDENT .UNINDENT .UNINDENT .SS MultiLeaderMTextBuilder .sp Specialization of \fI\%MultiLeaderBuilder\fP to build \fI\%MultiLeader\fP with MTEXT content. .INDENT 0.0 .TP .B class ezdxf.render.MultiLeaderMTextBuilder .INDENT 7.0 .TP .B set_content(content: str, color: int | \fI\%RGB\fP | None = None, char_height: float = 0.0, alignment: \fI\%TextAlignment\fP = TextAlignment.left, style: str = \(aq\(aq) Set MTEXT content. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontent\fP – MTEXT content as string .IP \(bu 2 \fBcolor\fP – block color as \fI\%AutoCAD Color Index (ACI)\fP or RGB tuple .IP \(bu 2 \fBchar_height\fP – initial char height in drawing units .IP \(bu 2 \fBalignment\fP – \fI\%TextAlignment\fP \- left, center, right .IP \(bu 2 \fBstyle\fP – name of \fI\%Textstyle\fP as string .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B quick_leader(content: str, target: \fI\%Vec2\fP, segment1: \fI\%Vec2\fP, segment2: \fI\%Vec2\fP | None = None, connection_type: \fI\%HorizontalConnection\fP | \fI\%VerticalConnection\fP = HorizontalConnection.middle_of_top_line, ucs: \fI\%UCS\fP | None = None) -> None Creates a quick MTEXT leader. The \fItarget\fP point defines where the leader points to. The \fIsegment1\fP is the first segment of the leader line relative to the \fItarget\fP point, \fIsegment2\fP is an optional second line segment relative to the first line segment. The \fIconnection_type\fP defines the type of connection (horizontal or vertical) and the MTEXT alignment (left, center or right). Horizontal connections are always left or right aligned, vertical connections are always center aligned. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontent\fP – MTEXT content string .IP \(bu 2 \fBtarget\fP – leader target point as \fBVec2\fP .IP \(bu 2 \fBsegment1\fP – first leader line segment as relative distance to \fIinsert\fP .IP \(bu 2 \fBsegment2\fP – optional second leader line segment as relative distance to first line segment .IP \(bu 2 \fBconnection_type\fP – one of \fI\%HorizontalConnection\fP or \fI\%VerticalConnection\fP .IP \(bu 2 \fBucs\fP – the rendering \fI\%UCS\fP, default is the \fI\%WCS\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS MultiLeaderBlockBuilder .sp Specialization of \fI\%MultiLeaderBuilder\fP to build \fI\%MultiLeader\fP with BLOCK content. .INDENT 0.0 .TP .B class ezdxf.render.MultiLeaderBlockBuilder .INDENT 7.0 .TP .B property block_layout: \fI\%BlockLayout\fP Returns the block layout. .UNINDENT .INDENT 7.0 .TP .B property extents: \fI\%BoundingBox\fP Returns the bounding box of the block. .UNINDENT .INDENT 7.0 .TP .B set_content(name: str, color: int | \fI\%RGB\fP = colors.BYBLOCK, scale: float = 1.0, alignment=BlockAlignment.center_extents) Set BLOCK content. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – the block name as string .IP \(bu 2 \fBcolor\fP – block color as \fI\%AutoCAD Color Index (ACI)\fP or RGB tuple .IP \(bu 2 \fBscale\fP – the block scaling, not to be confused with overall scaling .IP \(bu 2 \fBalignment\fP – the block insertion point or the center of extents .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_attribute(tag: str, text: str, width: float = 1.0) Add BLOCK attributes based on an ATTDEF entity in the block definition. All properties of the new created ATTRIB entity are defined by the template ATTDEF entity including the location. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – attribute tag name .IP \(bu 2 \fBtext\fP – attribute content string .IP \(bu 2 \fBwidth\fP – width factor .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Enums .INDENT 0.0 .TP .B class ezdxf.render.LeaderType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The leader type. .INDENT 7.0 .TP .B none .UNINDENT .INDENT 7.0 .TP .B straight_lines .UNINDENT .INDENT 7.0 .TP .B splines .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.ConnectionSide(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The leader connection side. .sp Vertical (top, bottom) and horizontal attachment sides (left, right) can not be mixed in a single entity \- this is a limitation of the MULTILEADER entity. .INDENT 7.0 .TP .B left .UNINDENT .INDENT 7.0 .TP .B right .UNINDENT .INDENT 7.0 .TP .B top .UNINDENT .INDENT 7.0 .TP .B bottom .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.HorizontalConnection(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The horizontal leader connection type. .INDENT 7.0 .TP .B by_style .UNINDENT .INDENT 7.0 .TP .B top_of_top_line .UNINDENT .INDENT 7.0 .TP .B middle_of_top_line .UNINDENT .INDENT 7.0 .TP .B middle_of_text .UNINDENT .INDENT 7.0 .TP .B middle_of_bottom_line .UNINDENT .INDENT 7.0 .TP .B bottom_of_bottom_line .UNINDENT .INDENT 7.0 .TP .B bottom_of_bottom_line_underline .UNINDENT .INDENT 7.0 .TP .B bottom_of_top_line_underline .UNINDENT .INDENT 7.0 .TP .B bottom_of_top_line .UNINDENT .INDENT 7.0 .TP .B bottom_of_top_line_underline_all .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.VerticalConnection(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The vertical leader connection type. .INDENT 7.0 .TP .B by_style .UNINDENT .INDENT 7.0 .TP .B center .UNINDENT .INDENT 7.0 .TP .B center_overline .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.TextAlignment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The \fBMText\fP alignment type. .INDENT 7.0 .TP .B left .UNINDENT .INDENT 7.0 .TP .B center .UNINDENT .INDENT 7.0 .TP .B right .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.BlockAlignment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The \fBBlock\fP alignment type. .INDENT 7.0 .TP .B center_extents .UNINDENT .INDENT 7.0 .TP .B insertion_point .UNINDENT .UNINDENT .SS Arrows .sp This module provides support for the AutoCAD standard arrow heads used in DIMENSION, LEADER and MULTILEADER entities. Library user don’t have to use the \fI\%ARROWS\fP objects directly, but should know the arrow names stored in it as attributes. The arrow names should be accessed that way: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf arrow = ezdxf.ARROWS.closed_filled .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.arrows.ARROWS Single instance of \fI\%_Arrows\fP to work with. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.arrows._Arrows Management object for standard arrows. .INDENT 7.0 .TP .B __acad__ Set of AutoCAD standard arrow names. .UNINDENT .INDENT 7.0 .TP .B __ezdxf__ Set of arrow names special to \fIezdxf\fP\&. .UNINDENT .INDENT 7.0 .TP .B architectural_tick [image] .UNINDENT .INDENT 7.0 .TP .B closed_filled [image] .UNINDENT .INDENT 7.0 .TP .B dot [image] .UNINDENT .INDENT 7.0 .TP .B dot_small [image] .UNINDENT .INDENT 7.0 .TP .B dot_blank [image] .UNINDENT .INDENT 7.0 .TP .B origin_indicator [image] .UNINDENT .INDENT 7.0 .TP .B origin_indicator_2 [image] .UNINDENT .INDENT 7.0 .TP .B open [image] .UNINDENT .INDENT 7.0 .TP .B right_angle [image] .UNINDENT .INDENT 7.0 .TP .B open_30 [image] .UNINDENT .INDENT 7.0 .TP .B closed [image] .UNINDENT .INDENT 7.0 .TP .B dot_smallblank [image] .UNINDENT .INDENT 7.0 .TP .B none [image] .UNINDENT .INDENT 7.0 .TP .B oblique [image] .UNINDENT .INDENT 7.0 .TP .B box_filled [image] .UNINDENT .INDENT 7.0 .TP .B box [image] .UNINDENT .INDENT 7.0 .TP .B closed_blank [image] .UNINDENT .INDENT 7.0 .TP .B datum_triangle_filled [image] .UNINDENT .INDENT 7.0 .TP .B datum_triangle [image] .UNINDENT .INDENT 7.0 .TP .B integral [image] .UNINDENT .INDENT 7.0 .TP .B ez_arrow [image] .UNINDENT .INDENT 7.0 .TP .B ez_arrow_blank [image] .UNINDENT .INDENT 7.0 .TP .B ez_arrow_filled [image] .UNINDENT .INDENT 7.0 .TP .B is_acad_arrow(item: str) -> bool Returns \fBTrue\fP if \fIitem\fP is a standard AutoCAD arrow. .UNINDENT .INDENT 7.0 .TP .B is_ezdxf_arrow(item: str) -> bool Returns \fBTrue\fP if \fIitem\fP is a special \fIezdxf\fP arrow. .UNINDENT .INDENT 7.0 .TP .B insert_arrow(layout: GenericLayoutType, name: str, insert: \fI\%UVec\fP = NULLVEC, size: float = 1.0, rotation: float = 0, *, dxfattribs=None) -> \fI\%Vec2\fP Insert arrow as block reference into \fIlayout\fP\&. .UNINDENT .INDENT 7.0 .TP .B render_arrow(layout: GenericLayoutType, name: str, insert: \fI\%UVec\fP = NULLVEC, size: float = 1.0, rotation: float = 0, *, dxfattribs=None) -> \fI\%Vec2\fP Render arrow as basic DXF entities into \fIlayout\fP\&. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(name: str, insert: \fI\%UVec\fP = NULLVEC, size: float = 0.625, rotation: float = 0, *, dxfattribs=None) -> Iterator[\fI\%DXFGraphic\fP] Returns all arrow components as virtual DXF entities. .UNINDENT .UNINDENT .SS Hatching .sp This module provides rendering support for hatch patterns as used in \fI\%Hatch\fP and \fI\%MPolygon\fP entities. .SS High Level Functions .INDENT 0.0 .TP .B ezdxf.render.hatching.hatch_entity(polygon: DXFPolygon, filter_text_boxes=True, jiggle_origin: bool = True) -> Iterator[tuple[\fI\%Vec3\fP, \fI\%Vec3\fP]] Yields the hatch pattern of the given HATCH or MPOLYGON entity as 3D lines. Each line is a pair of \fI\%Vec3\fP instances as start\- and end vertex, points are represented as lines of zero length, which means the start vertex is equal to the end vertex. .sp The function yields nothing if \fIpolygon\fP has a solid\- or gradient filling or does not have a usable pattern assigned. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpolygon\fP – \fI\%Hatch\fP or \fI\%MPolygon\fP entity .IP \(bu 2 \fBfilter_text_boxes\fP – ignore text boxes if \fBTrue\fP .IP \(bu 2 \fBjiggle_origin\fP – move pattern line origins a small amount to avoid intersections in corner points which causes errors in patterns .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.hatching.hatch_polygons(baseline: \fI\%HatchBaseLine\fP, polygons: Sequence[Sequence[\fI\%Vec2\fP]], terminate: Callable[[], bool] | None = None) -> Iterator[\fI\%Line\fP] Yields all pattern lines for all hatch lines generated by the given \fI\%HatchBaseLine\fP, intersecting the given 2D polygons as \fI\%Line\fP instances. The \fIpolygons\fP should represent a single entity with or without holes, the order of the polygons and their winding orientation (cw or ccw) is not important. Entities which do not intersect or overlap should be handled separately! .sp Each polygon is a sequence of \fI\%Vec2\fP instances, they are treated as closed polygons even if the last vertex is not equal to the first vertex. .sp The hole detection is done by a simple inside/outside counting algorithm and far from perfect, but is able to handle ordinary polygons well. .sp The terminate function WILL BE CALLED PERIODICALLY AND should return \fBTrue\fP to terminate execution. This can be used to implement a timeout, which can be required if using a very small hatching distance, especially if you get the data from untrusted sources. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbaseline\fP – \fI\%HatchBaseLine\fP .IP \(bu 2 \fBpolygons\fP – multiple sequences of \fBVec2\fP instances of a single entity, the order of exterior\- and hole paths and the winding orientation (cw or ccw) of paths is not important .IP \(bu 2 \fBterminate\fP – callback function which is called periodically and should return \fBTrue\fP to terminate the hatching function .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.hatching.hatch_paths(baseline: \fI\%HatchBaseLine\fP, paths: Sequence[Path], terminate: Callable[[], bool] | None = None) -> Iterator[\fI\%Line\fP] Yields all pattern lines for all hatch lines generated by the given \fI\%HatchBaseLine\fP, intersecting the given 2D \fI\%Path\fP instances as \fI\%Line\fP instances. The paths are handled as projected into the xy\-plane the z\-axis of path vertices will be ignored if present. .sp Same as the \fI\%hatch_polygons()\fP function, but for \fI\%Path\fP instances instead of polygons build of vertices. This function \fBdoes not flatten\fP the paths into vertices, instead the real intersections of the Bézier curves and the hatch lines are calculated. .sp For more information see the docs of the \fI\%hatch_polygons()\fP function. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbaseline\fP – \fI\%HatchBaseLine\fP .IP \(bu 2 \fBpaths\fP – sequence of \fI\%Path\fP instances of a single entity, the order of exterior\- and hole paths and the winding orientation (cw or ccw) of the paths is not important .IP \(bu 2 \fBterminate\fP – callback function which is called periodically and should return \fBTrue\fP to terminate the hatching function .UNINDENT .UNINDENT .UNINDENT .SS Classes .INDENT 0.0 .TP .B class ezdxf.render.hatching.HatchBaseLine(origin: \fI\%Vec2\fP, direction: \fI\%Vec2\fP, offset: \fI\%Vec2\fP, line_pattern: list[float] | None = None, min_hatch_line_distance=MIN_HATCH_LINE_DISTANCE) A hatch baseline defines the source line for hatching a geometry. A complete hatch pattern of a DXF entity can consist of one or more hatch baselines. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – the origin of the hatch line as \fI\%Vec2\fP instance .IP \(bu 2 \fBdirection\fP – the hatch line direction as \fI\%Vec2\fP instance, must not (0, 0) .IP \(bu 2 \fBoffset\fP – the offset of the hatch line origin to the next or to the previous hatch line .IP \(bu 2 \fBline_pattern\fP – line pattern as sequence of floats, see also \fI\%PatternRenderer\fP .IP \(bu 2 \fBmin_hatch_line_distance\fP – minimum hatch line distance to render, raises an \fI\%DenseHatchingLinesError\fP exception if the distance between hatch lines is smaller than this value .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%HatchLineDirectionError\fP – hatch baseline has no direction, (0, 0) vector .IP \(bu 2 \fI\%DenseHatchingLinesError\fP – hatching lines are too narrow .UNINDENT .UNINDENT .INDENT 7.0 .TP .B hatch_line(distance: float) -> \fI\%HatchLine\fP Returns the \fI\%HatchLine\fP at the given signed \fIdistance\fP\&. .UNINDENT .INDENT 7.0 .TP .B pattern_renderer(distance: float) -> \fI\%PatternRenderer\fP Returns the \fI\%PatternRenderer\fP for the given signed \fIdistance\fP\&. .UNINDENT .INDENT 7.0 .TP .B signed_distance(point: \fI\%Vec2\fP) -> float Returns the signed normal distance of the given \fIpoint\fP from this hatch baseline. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.hatching.HatchLine(origin: \fI\%Vec2\fP, direction: \fI\%Vec2\fP, distance: float) Represents a single hatch line. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBorigin\fP – the origin of the hatch line as \fI\%Vec2\fP instance .IP \(bu 2 \fBdirection\fP – the hatch line direction as \fI\%Vec2\fP instance, must not (0, 0) .IP \(bu 2 \fBdistance\fP – the normal distance to the base hatch line as float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_line(a: \fI\%Vec2\fP, b: \fI\%Vec2\fP, dist_a: float, dist_b: float) -> \fI\%Intersection\fP Returns the \fI\%Intersection\fP of this hatch line and the line defined by the points \fIa\fP and \fIb\fP\&. The arguments \fIdist_a\fP and \fIdist_b\fP are the signed normal distances of the points \fIa\fP and \fIb\fP from the hatch baseline. The normal distances from the baseline are easy to calculate by the \fI\%HatchBaseLine.signed_distance()\fP method and allow a fast intersection calculation by a simple point interpolation. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBa\fP – start point of the line as \fI\%Vec2\fP instance .IP \(bu 2 \fBb\fP – end point of the line as \fI\%Vec2\fP instance .IP \(bu 2 \fBdist_a\fP – normal distance of point \fIa\fP to the hatch baseline as float .IP \(bu 2 \fBdist_b\fP – normal distance of point \fIb\fP to the hatch baseline as float .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect_cubic_bezier_curve(curve: \fI\%Bezier4P\fP) -> Sequence[\fI\%Intersection\fP] Returns 0 to 3 \fI\%Intersection\fP points of this hatch line with a cubic Bèzier curve. .INDENT 7.0 .TP .B Parameters \fBcurve\fP – the cubic Bèzier curve as \fI\%ezdxf.math.Bezier4P\fP instance .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.hatching.PatternRenderer(hatch_line: \fI\%HatchLine\fP, pattern: Sequence[float]) The hatch pattern of a DXF entity has one or more \fI\%HatchBaseLine\fP instances with an origin, direction, offset and line pattern. The \fI\%PatternRenderer\fP for a certain distance from the baseline has to be acquired from the \fI\%HatchBaseLine\fP by the \fI\%pattern_renderer()\fP method. .sp The origin of the hatch line is the starting point of the line pattern. The offset defines the origin of the adjacent hatch line and doesn’t have to be orthogonal to the hatch line direction. .sp \fBLine Pattern\fP .sp The line pattern is a sequence of floats, where a value > 0.0 is a dash, a value < 0.0 is a gap and value of 0.0 is a point. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBhatch_line\fP – \fI\%HatchLine\fP .IP \(bu 2 \fBpattern\fP – the line pattern as sequence of float values .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render(start: \fI\%Vec2\fP, end: \fI\%Vec2\fP) -> Iterator[tuple[\fI\%Vec2\fP, \fI\%Vec2\fP]] Yields the pattern lines as pairs of \fI\%Vec2\fP instances from the start\- to the end point on the hatch line. For points the start\- and end point are the same \fI\%Vec2\fP instance and can be tested by the \fBis\fP operator. .sp The start\- and end points should be located collinear at the hatch line of this instance, otherwise the points a projected onto this hatch line. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.hatching.Intersection(type: \fI\%IntersectionType\fP = IntersectionType.NONE, p0: \fI\%Vec2\fP = Vec2(nan, nan), p1: \fI\%Vec2\fP = Vec2(nan, nan)) Represents an intersection. .INDENT 7.0 .TP .B type intersection type as \fI\%IntersectionType\fP instance .UNINDENT .INDENT 7.0 .TP .B p0 (first) intersection point as \fI\%Vec2\fP instance .UNINDENT .INDENT 7.0 .TP .B p1 second intersection point as \fI\%Vec2\fP instance, only if \fI\%type\fP is COLLINEAR .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.hatching.IntersectionType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B NONE no intersection .UNINDENT .INDENT 7.0 .TP .B REGULAR regular intersection point at a polygon edge or a Bèzier curve .UNINDENT .INDENT 7.0 .TP .B START intersection point at the start vertex of a polygon edge .UNINDENT .INDENT 7.0 .TP .B END intersection point at the end vertex of a polygon edge .UNINDENT .INDENT 7.0 .TP .B COLLINEAR intersection is collinear to a polygon edge .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.hatching.Line(start: \(aqVec2\(aq, end: \(aqVec2\(aq, distance: \(aqfloat\(aq) .INDENT 7.0 .TP .B start start point as \fI\%Vec2\fP instance .UNINDENT .INDENT 7.0 .TP .B end end point as \fI\%Vec2\fP instance .UNINDENT .INDENT 7.0 .TP .B distance signed normal distance to the \fI\%HatchBaseLine\fP .UNINDENT .UNINDENT .SS Helper Functions .INDENT 0.0 .TP .B ezdxf.render.hatching.hatch_boundary_paths(polygon: DXFPolygon, filter_text_boxes=True) -> list[\fI\%Path\fP] Returns the hatch boundary paths as \fI\%ezdxf.path.Path\fP instances of HATCH and MPOLYGON entities. Ignores text boxes if argument \fIfilter_text_boxes\fP is \fBTrue\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.hatching.hatch_line_distances(point_distances: Sequence[float], normal_distance: float) -> list[float] Returns all hatch line distances in the range of the given point distances. .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.hatching.pattern_baselines(polygon: DXFPolygon, min_hatch_line_distance: float = MIN_HATCH_LINE_DISTANCE, *, jiggle_origin: bool = False) -> Iterator[\fI\%HatchBaseLine\fP] Yields the hatch pattern baselines of HATCH and MPOLYGON entities as \fI\%HatchBaseLine\fP instances. Set \fIjiggle_origin\fP to \fBTrue\fP to move pattern line origins a small amount to avoid intersections in corner points which causes errors in patterns. .UNINDENT .SS Exceptions .INDENT 0.0 .TP .B class ezdxf.render.hatching.HatchingError Base exception class of the \fBhatching\fP module. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.hatching.HatchLineDirectionError Hatching direction is undefined or a (0, 0) vector. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.render.hatching.DenseHatchingLinesError Very small hatching distance which creates too many hatching lines. .UNINDENT .SH ADD-ONS .SS Drawing / Export Add\-on .sp This add\-on provides the functionality to render a DXF document to produce a rasterized or vector\-graphic image which can be saved to a file or viewed interactively depending on the backend being used. .sp The module provides two example scripts in the folder \fBexamples/addons/drawing\fP which can be run to save rendered images to files or view an interactive visualisation. .INDENT 0.0 .INDENT 3.5 .sp .EX $ ./draw_cad.py \-\-supported_formats # will list the file formats supported by the matplotlib backend. # Many formats are supported including vector graphics formats # such as pdf and svg $ ./draw_cad.py \-\-out image.png # draw a layout other than the model space $ ./draw_cad.py \-\-layout Layout1 \-\-out image.png # opens a GUI application to view CAD files $ ./cad_viewer.py .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 How\-to section for the FAQ about the \fI\%Drawing Add\-on\fP\&. .UNINDENT .UNINDENT .SS Design .sp The implementation of the \fBdrawing\fP add\-on is divided into a frontend and multiple backends. The frontend handles the translation of DXF features and properties into simplified structures, which are then processed by the backends. .SS Common Limitations to all Backends .INDENT 0.0 .IP \(bu 2 rich text formatting of the MTEXT entity is close to AutoCAD but not pixel perfect .IP \(bu 2 relative size of POINT entities cannot be replicated exactly .IP \(bu 2 rendering of ACIS entities is not supported .IP \(bu 2 no 3D rendering engine, therefore: .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 3D entities are projected into the xy\-plane and 3D text is not supported .IP \(bu 2 only top view rendering of the modelspace .IP \(bu 2 VIEWPORTS are always rendered as top view .IP \(bu 2 no visual style support .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 only basic support for: .INDENT 2.0 .IP \(bu 2 infinite lines (rendered as lines with a finite length) .IP \(bu 2 OLE2FRAME entities (rendered as rectangles) .IP \(bu 2 vertical text (will render as horizontal text) .IP \(bu 2 rendering of additional MTEXT columns may be incorrect .UNINDENT .UNINDENT .SS MatplotlibBackend .sp The \fBMatplotlibBackend\fP is used by the \fI\%Draw\fP command of the \fIezdxf\fP launcher. .sp Example for the usage of the \fBMatplotlib\fP backend: .INDENT 0.0 .INDENT 3.5 .sp .EX import sys import matplotlib.pyplot as plt from ezdxf import recover from ezdxf.addons.drawing import RenderContext, Frontend from ezdxf.addons.drawing.matplotlib import MatplotlibBackend # Safe loading procedure (requires ezdxf v0.14): try: doc, auditor = recover.readfile(\(aqyour.dxf\(aq) except IOError: print(f\(aqNot a DXF file or a generic I/O error.\(aq) sys.exit(1) except ezdxf.DXFStructureError: print(f\(aqInvalid or corrupted DXF file.\(aq) sys.exit(2) # The auditor.errors attribute stores severe errors, # which may raise exceptions when rendering. if not auditor.has_errors: fig = plt.figure() ax = fig.add_axes([0, 0, 1, 1]) ctx = RenderContext(doc) out = MatplotlibBackend(ax) Frontend(ctx, out).draw_layout(doc.modelspace(), finalize=True) fig.savefig(\(aqyour.png\(aq, dpi=300) .EE .UNINDENT .UNINDENT .sp Simplified render workflow but with less control: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf import recover from ezdxf.addons.drawing import matplotlib # Exception handling left out for compactness: doc, auditor = recover.readfile(\(aqyour.dxf\(aq) if not auditor.has_errors: matplotlib.qsave(doc.modelspace(), \(aqyour.png\(aq) .EE .UNINDENT .UNINDENT .SS PyQtBackend .INDENT 0.0 .TP .B class ezdxf.addons.drawing.pyqt.PyQtBackend(scene=None) Backend which uses the \fBPySide6\fP package to implement an interactive viewer. The \fBPyQt5\fP package can be used as fallback if the \fBPySide6\fP package is not available. .INDENT 7.0 .TP .B Parameters \fBscene\fP \-\- drawing canvas of type \fBQtWidgets.QGraphicsScene\fP, if \fBNone\fP a new canvas will be created .UNINDENT .UNINDENT .sp The \fBPyQtBackend\fP is used by the \fI\%View\fP command of the \fIezdxf\fP launcher. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 The \fI\%qtviewer.py\fP module implements the core of a simple DXF viewer and the \fI\%cad_viewer.py\fP example is a skeleton to show how to launch the \fBCADViewer\fP class. .UNINDENT .UNINDENT .SS Recorder .sp New in version 1.1. .sp This is a special backend which records the output of the \fI\%Frontend\fP class in compact numpy arrays and these recordings and can be played by a \fBPlayer\fP instance on one or more backends. The recorded numpy arrays support measurement of bounding boxes and transformations which is for some backends a requirement to place the DXF content on size limited pages. .INDENT 0.0 .TP .B class ezdxf.addons.drawing.recorder.Recorder Records the output of the Frontend class. .sp The class implements the \fBBackendInterface\fP but does not record \fBenter_entity()\fP, \fBexit_entity()\fP and \fBclear()\fP events. .INDENT 7.0 .TP .B player() -> \fI\%Player\fP Returns a \fI\%Player\fP instance with the original recordings! Make a copy of this player to protect the original recordings from being modified: .INDENT 7.0 .INDENT 3.5 .sp .EX safe_player = recorder.player().copy() .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.recorder.Player Plays the recordings of the \fI\%Recorder\fP backend on another backend. .INDENT 7.0 .TP .B bbox() -> \fI\%BoundingBox2d\fP Returns the bounding box of all records as \fI\%BoundingBox2d\fP\&. .UNINDENT .INDENT 7.0 .TP .B copy() -> Self Returns a copy of the player with non\-shared recordings. .UNINDENT .INDENT 7.0 .TP .B crop_rect(p1: \fI\%UVec\fP, p2: \fI\%UVec\fP, distance: float) -> None Crop recorded shapes inplace by a rectangle defined by two points. .sp The argument \fIdistance\fP defines the approximation precision for paths which have to be approximated as polylines for cropping but only paths which are really get cropped are approximated, paths that are fully inside the crop box will not be approximated. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP \-\- first corner of the clipping rectangle .IP \(bu 2 \fBp2\fP \-\- second corner of the clipping rectangle .IP \(bu 2 \fBdistance\fP \-\- maximum distance from the center of the curve to the center of the line segment between two approximation points to determine if a segment should be subdivided. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B recordings() -> Iterator[tuple[\fI\%RecordType\fP, BackendProperties, Any]] Yields all recordings as \fI(RecordType, BackendProperties, Data)\fP tuples. .sp The content of the \fIData\fP field is determined by the enum \fI\%RecordType\fP: .INDENT 7.0 .IP \(bu 2 \fI\%RecordType.POINTS\fP returns a \fBNumpyPoints2d\fP instance, len() == 1 is a point, len() == 2 is a line, len() > 2 is a filled polygon .IP \(bu 2 \fI\%RecordType.SOLID_LINES\fP returns a \fBNumpyPoints2d\fP instance where each pair (n, n+1) represents the start\- and end point of a line .IP \(bu 2 \fI\%RecordType.PATH\fP: returns a \fBNumpyPath2d\fP instance that represents a linear 2D path .IP \(bu 2 \fI\%RecordType.FILLED_PATHS\fP returns a tuple (exterior_paths, holes), where exterior_paths and holes are tuples of \fBNumpyPath2d\fP\&. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B replay(backend: \fI\%BackendInterface\fP, override: Callable[[BackendProperties], \fI\%Override\fP] | None = None) -> None Replay the recording on another backend that implements the \fBBackendInterface\fP\&. The optional \fIoverride\fP function can be used to override the properties and state of data records, it gets the \fBBackendProperties\fP as input and must return an \fI\%Override\fP instance. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> None Transforms the recordings inplace by a transformation matrix \fIm\fP of type \fI\%Matrix44\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.recorder.Override(properties: BackendProperties, is_visible: bool = True) Represents the override state for a data record. .INDENT 7.0 .TP .B properties original or modified \fBBackendProperties\fP .INDENT 7.0 .TP .B Type ezdxf.addons.drawing.properties.BackendProperties .UNINDENT .UNINDENT .INDENT 7.0 .TP .B is_visible override visibility e.g. switch layers on/off .INDENT 7.0 .TP .B Type bool .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.recorder.RecordType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Enum, determines the data record type. .INDENT 7.0 .TP .B POINTS .UNINDENT .INDENT 7.0 .TP .B SOLID_LINES .UNINDENT .INDENT 7.0 .TP .B PATH .UNINDENT .INDENT 7.0 .TP .B FILLED_PATHS .UNINDENT .UNINDENT .SS Layout .sp New in version 1.1. .sp The \fBLayout\fP class builds the page layout and the matrix to transform the DXF content to page coordinates according to the layout \fBSettings\fP\&. The DXF coordinate transformation is required for PDF and HPGL/2 which expects the output coordinates in the first quadrant and SVG which has an inverted y\-axis. .sp The \fBLayout\fP class uses following classes and enums for configuration: .INDENT 0.0 .IP \(bu 2 \fI\%Page\fP \- page definition .IP \(bu 2 \fI\%Margins\fP \- page margins definition .IP \(bu 2 \fI\%Settings\fP \- configuration settings .IP \(bu 2 \fI\%Units\fP \- enum for page units .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.layout.Page(width: float, height: float, units: \fI\%Units\fP = Units.mm, margins: \fI\%Margins\fP = (0, 0, 0, 0), max_width: float = 0.0, max_height: float = 0.0) Page definition class .INDENT 7.0 .TP .B width page width, 0 for auto\-detect .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B height page height, 0 for auto\-detect .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B units page units as enum \fI\%Units\fP .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.layout.Units\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B margins page margins in page units .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.layout.Margins\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B max_width limit width for auto\-detection, 0 for unlimited .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B max_height limit height for auto\-detection, 0 for unlimited .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property is_landscape: bool Returns \fBTrue\fP if the page has landscape orientation. .UNINDENT .INDENT 7.0 .TP .B property is_portrait: bool Returns \fBTrue\fP if the page has portrait orientation. (square is portrait) .UNINDENT .INDENT 7.0 .TP .B to_landscape() -> None Converts the page to landscape orientation. .UNINDENT .INDENT 7.0 .TP .B to_portrait() -> None Converts the page to portrait orientation. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.layout.Margins(top: float, right: float, bottom: float, left: float) Page margins definition class .INDENT 7.0 .TP .B top .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B left .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B bottom .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B right .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod all(margin: float) -> Self Returns a page margins definition class with four equal margins. .UNINDENT .INDENT 7.0 .TP .B classmethod all2(top_bottom: float, left_right: float) -> Self Returns a page margins definition class with equal top\-bottom and left\-right margins. .UNINDENT .INDENT 7.0 .TP .B scale(factor: float) -> Self .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.layout.PageAlignment(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Page alignment of content as enum. .INDENT 7.0 .TP .B TOP_LEFT .UNINDENT .INDENT 7.0 .TP .B TOP_CENTER .UNINDENT .INDENT 7.0 .TP .B TOP_RIGHT .UNINDENT .INDENT 7.0 .TP .B MIDDLE_LEFT .UNINDENT .INDENT 7.0 .TP .B MIDDLE_CENTER .UNINDENT .INDENT 7.0 .TP .B MIDDLE_RIGHT .UNINDENT .INDENT 7.0 .TP .B BOTTOM_LEFT .UNINDENT .INDENT 7.0 .TP .B BOTTOM_CENTER .UNINDENT .INDENT 7.0 .TP .B BOTTOM_RIGHT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.layout.Settings(content_rotation: int = 0, fit_page: bool = True, scale: float = 1.0, page_alignment: \fI\%PageAlignment\fP = PageAlignment.MIDDLE_CENTER, crop_at_margins: bool = False, max_stroke_width: float = 0.001, min_stroke_width: float = 0.05, fixed_stroke_width: float = 0.15, output_coordinate_space: float = 1000000) The Layout settings. .INDENT 7.0 .TP .B content_rotation Rotate content about 0, 90, 180 or 270 degrees .INDENT 7.0 .TP .B Type int .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fit_page Scale content to fit the page. .INDENT 7.0 .TP .B Type bool .UNINDENT .UNINDENT .INDENT 7.0 .TP .B page_alignment Supported by backends that use the \fI\%Page\fP class to define the size of the output media, default alignment is \fI\%PageAlignment.MIDDLE_CENTER\fP .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.layout.PageAlignment\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B crop_at_margins crops the content at the page margins if \fBTrue\fP, when supported by the backend, default is \fBFalse\fP .INDENT 7.0 .TP .B Type bool .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale Factor to scale the DXF units of model\- or paperspace, to represent 1mm in the rendered output drawing. Only uniform scaling is supported. .sp e.g. scale 1:100 and DXF units are meters, 1m = 1000mm corresponds 10mm in the output drawing = 10 / 1000 = 0.01; .sp e.g. scale 1:1; DXF units are mm = 1 / 1 = 1.0 the default value .sp The value is ignored if the page size is defined and the content fits the page and the value is also used to determine missing page sizes (width or height). .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B max_stroke_width Used for \fBLineweightPolicy.RELATIVE\fP policy, \fI\%max_stroke_width\fP is defined as percentage of the content extents, e.g. 0.001 is 0.1% of max(page\-width, page\-height) .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B min_stroke_width Used for \fBLineweightPolicy.RELATIVE\fP policy, \fI\%min_stroke_width\fP is defined as percentage of \fI\%max_stroke_width\fP, e.g. 0.05 is 5% of \fI\%max_stroke_width\fP .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fixed_stroke_width Used for \fBLineweightPolicy.RELATIVE_FIXED\fP policy, \fI\%fixed_stroke_width\fP is defined as percentage of \fI\%max_stroke_width\fP, e.g. 0.15 is 15% of \fI\%max_stroke_width\fP .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B output_coordinate_space expert feature to map the DXF coordinates to the output coordinate system [0, output_coordinate_space] .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.layout.Units(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Page units as enum. .INDENT 7.0 .TP .B inch 25.4 mm .UNINDENT .INDENT 7.0 .TP .B px 1/96 inch .UNINDENT .INDENT 7.0 .TP .B pt 1/72 inch .UNINDENT .INDENT 7.0 .TP .B mm .UNINDENT .INDENT 7.0 .TP .B cm .UNINDENT .UNINDENT .SS SVGBackend .sp New in version 1.1. .INDENT 0.0 .TP .B class ezdxf.addons.drawing.svg.SVGBackend This is a native SVG rendering backend and does not require any external packages to render SVG images other than the core dependencies. This backend support content cropping at page margins. .INDENT 7.0 .TP .B get_xml_root_element(page: \fI\%Page\fP, *, settings: \fI\%Settings\fP = layout.Settings(), render_box: \fI\%BoundingBox2d\fP | None = None) -> Element .UNINDENT .INDENT 7.0 .TP .B get_string(page: \fI\%Page\fP, *, settings: \fI\%Settings\fP = layout.Settings(), render_box: \fI\%BoundingBox2d\fP | None = None, xml_declaration=True) -> str Returns the XML data as unicode string. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpage\fP \-\- page definition, see \fI\%Page\fP .IP \(bu 2 \fBsettings\fP \-\- layout settings, see \fI\%Settings\fP .IP \(bu 2 \fBrender_box\fP \-\- set explicit region to render, default is content bounding box .IP \(bu 2 \fBxml_declaration\fP \-\- inserts the \(dq\(dq string in front of the element .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp Usage: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons.drawing import Frontend, RenderContext from ezdxf.addons.drawing import layout, svg doc = ezdxf.readfile(\(dqyour.dxf\(dq) msp = doc.modelspace() backend = svg.SVGBackend() Frontend(RenderContext(doc), backend).draw_layout(msp) with open(\(dqyour.svg\(dq, \(dqwt\(dq) as fp: fp.write(backend.get_string(layout.Page(0, 0)) .EE .UNINDENT .UNINDENT .SS PyMuPdfBackend .sp New in version 1.1. .INDENT 0.0 .TP .B class ezdxf.addons.drawing.pymupdf.PyMuPdfBackend This backend uses the \fI\%PyMuPdf\fP package to create PDF, PNG, PPM and PBM output. This backend support content cropping at page margins. .sp PyMuPDF is licensed under the \fI\%AGPL\fP\&. Sorry, but it\(aqs the best package for the job I\(aqve found so far. .sp Install package: .INDENT 7.0 .INDENT 3.5 .sp .EX pip install pymupdf .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_pdf_bytes(page: \fI\%Page\fP, *, settings: \fI\%Settings\fP = layout.Settings(), render_box: \fI\%BoundingBox2d\fP | None = None) -> bytes Returns the PDF document as bytes. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpage\fP \-\- page definition, see \fI\%Page\fP .IP \(bu 2 \fBsettings\fP \-\- layout settings, see \fI\%Settings\fP .IP \(bu 2 \fBrender_box\fP \-\- set explicit region to render, default is content bounding box .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_pixmap_bytes(page: \fI\%Page\fP, *, fmt=\(aqpng\(aq, settings: \fI\%Settings\fP = layout.Settings(), dpi: int = 96, alpha=False, render_box: \fI\%BoundingBox2d\fP | None = None) -> bytes Returns a pixel image as bytes, supported image formats: .TS center; |l|l|. _ T{ png T} T{ Portable Network Graphics T} _ T{ ppm T} T{ Portable Pixmap (no alpha channel) T} _ T{ pbm T} T{ Portable Bitmap (no alpha channel) T} _ .TE .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpage\fP \-\- page definition, see \fI\%Page\fP .IP \(bu 2 \fBfmt\fP \-\- image format .IP \(bu 2 \fBsettings\fP \-\- layout settings, see \fI\%Settings\fP .IP \(bu 2 \fBdpi\fP \-\- output resolution in dots per inch .IP \(bu 2 \fBalpha\fP \-\- add alpha channel (transparency) .IP \(bu 2 \fBrender_box\fP \-\- set explicit region to render, default is content bounding box .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp Usage: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons.drawing import Frontend, RenderContext from ezdxf.addons.drawing import layout, pymupdf doc = ezdxf.readfile(\(dqyour.dxf\(dq) msp = doc.modelspace() backend = pymupdf.PyMuPdfBackend() Frontend(RenderContext(doc), backend).draw_layout(msp) with open(\(dqyour.pdf\(dq, \(dqwb\(dq) as fp: fp.write(backend.get_pdf_bytes(layout.Page(0, 0)) .EE .UNINDENT .UNINDENT .sp Load the output of the \fBPyMuPdfBackend\fP into the \fBImage\fP class of the \fI\%Pillow\fP package for further processing or to output additional image formats: .INDENT 0.0 .INDENT 3.5 .sp .EX import io from PIL import Image \&... # see above # the ppm format is faster to process than png fp = io.BytesIO(backend.get_pixmap_bytes(layout.Page(0, 0), fmt=\(dqppm\(dq, dpi=300)) image = Image.open(fp, formats=[\(dqppm\(dq]) .EE .UNINDENT .UNINDENT .SS PlotterBackend .sp New in version 1.1. .INDENT 0.0 .TP .B class ezdxf.addons.drawing.hpgl2.PlotterBackend The \fI\%PlotterBackend\fP creates HPGL/2 plot files for output on raster plotters. This backend does not need any additional packages. This backend support content cropping at page margins. .sp The plot files are tested by the plot file viewer \fI\%ViewCompanion Standard\fP but not on real hardware \- please use with care and give feedback. .INDENT 7.0 .TP .B get_bytes(page: \fI\%Page\fP, *, settings: \fI\%Settings\fP = layout.Settings(), render_box: \fI\%BoundingBox2d\fP | None = None, curves=True, decimal_places: int = 1, base=64) -> bytes Returns the HPGL/2 data as bytes. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpage\fP \-\- page definition, see \fI\%Page\fP .IP \(bu 2 \fBsettings\fP \-\- layout settings, see \fI\%Settings\fP .IP \(bu 2 \fBrender_box\fP \-\- set explicit region to render, default is content bounding box .IP \(bu 2 \fBcurves\fP \-\- use Bèzier curves for HPGL/2 output .IP \(bu 2 \fBdecimal_places\fP \-\- HPGL/2 output precision, less decimal places creates smaller files but for the price of imprecise curves (text) .IP \(bu 2 \fBbase\fP \-\- base for polyline encoding, 32 for 7 bit encoding or 64 for 8 bit encoding .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B compatible(page: \fI\%Page\fP, settings: \fI\%Settings\fP = layout.Settings()) -> bytes Returns the HPGL/2 data as 7\-bit encoded bytes curves as approximated polylines and coordinates are rounded to integer values. Has often the smallest file size and should be compatible to all output devices but has a low quality text rendering. .UNINDENT .INDENT 7.0 .TP .B low_quality(page: \fI\%Page\fP, settings: \fI\%Settings\fP = layout.Settings()) -> bytes Returns the HPGL/2 data as 8\-bit encoded bytes, curves as Bézier curves and coordinates are rounded to integer values. Has a smaller file size than normal quality and the output device must support 8\-bit encoding and Bèzier curves. .UNINDENT .INDENT 7.0 .TP .B normal_quality(page: \fI\%Page\fP, settings: \fI\%Settings\fP = layout.Settings()) -> bytes Returns the HPGL/2 data as 8\-bit encoded bytes, curves as Bézier curves and coordinates are floats rounded to one decimal place. Has a smaller file size than high quality and the output device must support 8\-bit encoding, Bèzier curves and fractional coordinates. .UNINDENT .INDENT 7.0 .TP .B high_quality(page: \fI\%Page\fP, settings: \fI\%Settings\fP = layout.Settings()) -> bytes Returns the HPGL/2 data as 8\-bit encoded bytes and all curves as Bézier curves and coordinates are floats rounded to two decimal places. Has the largest file size and the output device must support 8\-bit encoding, Bèzier curves and fractional coordinates. .UNINDENT .UNINDENT .sp Usage: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons.drawing import Frontend, RenderContext from ezdxf.addons.drawing import layout, hpgl2 doc = ezdxf.readfile(\(dqyour.dxf\(dq) psp = doc.paperspace(\(dqLayout1\(dq) backend = hpgl2.PlotterBackend() Frontend(RenderContext(doc), backend).draw_layout(psp) page = layout.Page.from_dxf_layout(psp) with open(\(dqyour.plt\(dq, \(dqwb\(dq) as fp: fp.write(backend.normal_quality(page) .EE .UNINDENT .UNINDENT .sp You can check the output by the HPGL/2 viewer: .INDENT 0.0 .INDENT 3.5 .sp .EX ezdxf hpgl your.plt .EE .UNINDENT .UNINDENT .SS DXFBackend .sp New in version 1.1. .INDENT 0.0 .TP .B class ezdxf.addons.drawing.dxf.DXFBackend(layout: BaseLayout, color_mode: \fI\%ColorMode\fP = ColorMode.RGB) The \fI\%DXFBackend\fP creates simple DXF files of POINT, LINE, LWPOLYLINE and HATCH entities. This backend does ot need any additional packages. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP \-\- a DXF \fI\%BaseLayout\fP .IP \(bu 2 \fBcolor_mode\fP \-\- see \fI\%ColorMode\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.dxf.ColorMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) This enum is used to define the color output mode of the \fI\%DXFBackend\fP\&. .INDENT 7.0 .TP .B ACI the color is set as \fI\%AutoCAD Color Index (ACI)\fP and assigned by layer .UNINDENT .INDENT 7.0 .TP .B RGB the color is set as RGB true color value .UNINDENT .UNINDENT .sp Render a paperspace layout into modelspace: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons.drawing import Frontend, RenderContext from ezdxf.addons.drawing import layout, dxf doc = ezdxf.readfile(\(dqyour.dxf\(dq) layout1 = doc.paperspace(\(dqLayout1\(dq) output_doc = ezdxf.new() output_msp = output_doc.modelspace() backend = dxf.DXFBackend(output_msp) Frontend(RenderContext(doc), backend).draw_layout(layout1) output_doc.saveas(\(dqlayout1_in_modelspace.dxf\(dq) .EE .UNINDENT .UNINDENT .SS Configuration .sp Additional options for the drawing add\-on can be passed by the \fIconfig\fP argument of the \fBFrontend\fP constructor \fB__init__()\fP\&. Not every option will be supported by all backends. .sp Usage: .INDENT 0.0 .INDENT 3.5 .sp .EX my_config = Configuration(lineweight_scaling=2) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.drawing.config.Configuration(pdsize: int | None = None, pdmode: int | None = None, measurement: \fI\%Measurement\fP | None = None, show_defpoints: bool = False, proxy_graphic_policy: \fI\%ProxyGraphicPolicy\fP = ProxyGraphicPolicy.SHOW, line_policy: \fI\%LinePolicy\fP = LinePolicy.ACCURATE, hatch_policy: \fI\%HatchPolicy\fP = HatchPolicy.NORMAL, infinite_line_length: float = 20, lineweight_scaling: float = 1.0, min_lineweight: float | None = None, min_dash_length: float = 0.1, max_flattening_distance: float = 0.01, circle_approximation_count: int = 128, hatching_timeout: float = 30.0, min_hatch_line_distance: float = 0.0001, color_policy: \fI\%ColorPolicy\fP = ColorPolicy.COLOR, custom_fg_color: str = \(aq#000000\(aq, background_policy: \fI\%BackgroundPolicy\fP = BackgroundPolicy.DEFAULT, custom_bg_color: str = \(aq#ffffff\(aq, lineweight_policy: \fI\%LineweightPolicy\fP = LineweightPolicy.ABSOLUTE, text_policy: \fI\%TextPolicy\fP = TextPolicy.FILLING) Configuration options for the \fBdrawing\fP add\-on. .INDENT 7.0 .TP .B pdsize the size to draw POINT entities (in drawing units) set to None to use the $PDSIZE value from the dxf document header .TS center; |l|l|. _ T{ 0 T} T{ 5% of draw area height T} _ T{ <0 T} T{ Specifies a percentage of the viewport size T} _ T{ >0 T} T{ Specifies an absolute size T} _ T{ None T} T{ use the $PDMODE value from the dxf document header T} _ .TE .INDENT 7.0 .TP .B Type int | None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B pdmode point styling mode (see POINT documentation) .sp see \fI\%Point\fP class documentation .INDENT 7.0 .TP .B Type int | None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B measurement whether to use metric or imperial units as enum \fI\%ezdxf.enums.Measurement\fP .TS center; |l|l|. _ T{ 0 T} T{ use imperial units (in, ft, yd, ...) T} _ T{ 1 T} T{ use metric units (ISO meters) T} _ T{ None T} T{ use the $MEASUREMENT value from the dxf document header T} _ .TE .INDENT 7.0 .TP .B Type \fI\%ezdxf.enums.Measurement\fP | None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B show_defpoints whether to show or filter out POINT entities on the defpoints layer .INDENT 7.0 .TP .B Type bool .UNINDENT .UNINDENT .INDENT 7.0 .TP .B proxy_graphic_policy the action to take when a proxy graphic is encountered .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.config.ProxyGraphicPolicy\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B line_policy the method to use when drawing styled lines (eg dashed, dotted etc) .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.config.LinePolicy\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B hatch_policy the method to use when drawing HATCH entities .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.config.HatchPolicy\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B infinite_line_length the length to use when drawing infinite lines .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B lineweight_scaling multiplies every lineweight by this factor; set this factor to 0.0 for a constant minimum line width defined by the \fI\%min_lineweight\fP setting for all lineweights; the correct DXF lineweight often looks too thick in SVG, so setting a factor < 1 can improve the visual appearance .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B min_lineweight the minimum line width in 1/300 inch; set to \fBNone\fP for let the backend choose. .INDENT 7.0 .TP .B Type float | None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B min_dash_length the minimum length for a dash when drawing a styled line (default value is arbitrary) .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B max_flattening_distance Max flattening distance in drawing units see Path.flattening documentation. The backend implementation should calculate an appropriate value, like 1 screen\- or paper pixel on the output medium, but converted into drawing units. Sets Path() approximation accuracy .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B circle_approximation_count Approximate a full circle by \fIn\fP segments, arcs have proportional less segments. Only used for approximation of arcs in banded polylines. .INDENT 7.0 .TP .B Type int .UNINDENT .UNINDENT .INDENT 7.0 .TP .B hatching_timeout hatching timeout for a single entity, very dense hatching patterns can cause a very long execution time, the default timeout for a single entity is 30 seconds. .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B min_hatch_line_distance minimum hatch line distance to render, narrower pattern lines are rendered as solid filling .INDENT 7.0 .TP .B Type float .UNINDENT .UNINDENT .INDENT 7.0 .TP .B color_policy .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.config.ColorPolicy\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B custom_fg_color Used for \fBColorPolicy.custom\fP policy, custom foreground color as \(dq#RRGGBBAA\(dq color string (RGB+alpha) .INDENT 7.0 .TP .B Type str .UNINDENT .UNINDENT .INDENT 7.0 .TP .B background_policy .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.config.BackgroundPolicy\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B custom_bg_color Used for \fBBackgroundPolicy.custom\fP policy, custom background color as \(dq#RRGGBBAA\(dq color string (RGB+alpha) .INDENT 7.0 .TP .B Type str .UNINDENT .UNINDENT .INDENT 7.0 .TP .B lineweight_policy .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.config.LineweightPolicy\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B text_policy .INDENT 7.0 .TP .B Type \fI\%ezdxf.addons.drawing.config.TextPolicy\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B with_changes() Returns a new frozen \fI\%Configuration\fP object with modified values. .UNINDENT .UNINDENT .SS BackgroundPolicy .INDENT 0.0 .TP .B class ezdxf.addons.drawing.config.BackgroundPolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) This enum is used to define the background color. .INDENT 7.0 .TP .B DEFAULT as resolved by the \fBFrontend\fP class .UNINDENT .INDENT 7.0 .TP .B WHITE white background .UNINDENT .INDENT 7.0 .TP .B BLACK black background .UNINDENT .INDENT 7.0 .TP .B OFF fully transparent background .UNINDENT .INDENT 7.0 .TP .B CUSTOM custom background color by \fI\%Configuration.custom_bg_color\fP .UNINDENT .UNINDENT .SS ColorPolicy .INDENT 0.0 .TP .B class ezdxf.addons.drawing.config.ColorPolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) This enum is used to define how to determine the line/fill color. .INDENT 7.0 .TP .B COLOR as resolved by the \fBFrontend\fP class .UNINDENT .INDENT 7.0 .TP .B COLOR_SWAP_BW as resolved by the \fBFrontend\fP class but swaps black and white .UNINDENT .INDENT 7.0 .TP .B COLOR_NEGATIVE invert all colors .UNINDENT .INDENT 7.0 .TP .B MONOCHROME maps all colors to gray scale in range [0%, 100%] .UNINDENT .INDENT 7.0 .TP .B MONOCHROME_DARK_BG maps all colors to gray scale in range [30%, 100%], brightens colors for dark backgrounds .UNINDENT .INDENT 7.0 .TP .B MONOCHROME_LIGHT_BG maps all colors to gray scale in range [0%, 70%], darkens colors for light backgrounds .UNINDENT .INDENT 7.0 .TP .B BLACK maps all colors to black .UNINDENT .INDENT 7.0 .TP .B WHITE maps all colors to white .UNINDENT .INDENT 7.0 .TP .B CUSTOM maps all colors to custom color \fI\%Configuration.custom_fg_color\fP .UNINDENT .UNINDENT .SS HatchPolicy .INDENT 0.0 .TP .B class ezdxf.addons.drawing.config.HatchPolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The action to take when a HATCH entity is encountered .INDENT 7.0 .TP .B NORMAL render pattern and solid fillings .UNINDENT .INDENT 7.0 .TP .B IGNORE do not show HATCH entities at all .UNINDENT .INDENT 7.0 .TP .B SHOW_OUTLINE show only the outline of HATCH entities .UNINDENT .INDENT 7.0 .TP .B SHOW_SOLID show HATCH entities as solid filling regardless of the pattern .UNINDENT .UNINDENT .SS LinePolicy .INDENT 0.0 .TP .B class ezdxf.addons.drawing.config.LinePolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B SOLID draw all lines as solid regardless of the linetype style .UNINDENT .INDENT 7.0 .TP .B ACCURATE render styled lines as accurately as possible .UNINDENT .UNINDENT .SS LineweightPolicy .INDENT 0.0 .TP .B class ezdxf.addons.drawing.config.LineweightPolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) This enum is used to define how to determine the lineweight. .INDENT 7.0 .TP .B ABSOLUTE in mm as resolved by the \fBFrontend\fP class .UNINDENT .INDENT 7.0 .TP .B RELATIVE lineweight is relative to page size .UNINDENT .INDENT 7.0 .TP .B RELATIVE_FIXED fixed lineweight relative to page size for all strokes .UNINDENT .UNINDENT .SS ProxyGraphicPolicy .INDENT 0.0 .TP .B class ezdxf.addons.drawing.config.ProxyGraphicPolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The action to take when an entity with a proxy graphic is encountered .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 To get proxy graphics support proxy graphics have to be loaded: Set the global option \fI\%ezdxf.options.load_proxy_graphics\fP to \fBTrue\fP, which is the default value. .sp This can not prevent drawing proxy graphic inside of blocks, because this is beyond the domain of the drawing add\-on! .UNINDENT .UNINDENT .INDENT 7.0 .TP .B IGNORE do not display proxy graphics (skip_entity will be called instead) .UNINDENT .INDENT 7.0 .TP .B SHOW if the entity cannot be rendered directly (e.g. if not implemented) but a proxy is present: display the proxy .UNINDENT .INDENT 7.0 .TP .B PREFER display proxy graphics even for entities where direct rendering is available .UNINDENT .UNINDENT .SS TextPolicy .INDENT 0.0 .TP .B class ezdxf.addons.drawing.config.TextPolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) This enum is used to define the text rendering. .INDENT 7.0 .TP .B FILLING text is rendered as solid filling (default) .UNINDENT .INDENT 7.0 .TP .B OUTLINE text is rendered as outline paths .UNINDENT .INDENT 7.0 .TP .B REPLACE_RECT replace text by a rectangle .UNINDENT .INDENT 7.0 .TP .B REPLACE_FILL replace text by a filled rectangle .UNINDENT .INDENT 7.0 .TP .B IGNORE ignore text at all .UNINDENT .UNINDENT .SS Properties .INDENT 0.0 .TP .B class ezdxf.addons.drawing.properties.Properties An implementation agnostic representation of DXF entity properties like color and linetype. These properties represent the actual values after resolving all DXF specific rules like \(dqby layer\(dq, \(dqby block\(dq and so on. .INDENT 7.0 .TP .B color The actual color value of the DXF entity as \(dq#RRGGBB\(dq or \(dq#RRGGBBAA\(dq string. An alpha value of \(dq00\(dq is opaque and \(dqff\(dq is fully transparent. .UNINDENT .INDENT 7.0 .TP .B rgb RGB values extract from the \fI\%color\fP value as tuple of integers. .UNINDENT .INDENT 7.0 .TP .B luminance Perceived luminance calculated from the \fI\%color\fP value as float in the range [0.0, 1.0]. .UNINDENT .INDENT 7.0 .TP .B linetype_name The actual linetype name as string like \(dqCONTINUOUS\(dq .UNINDENT .INDENT 7.0 .TP .B linetype_pattern The simplified DXF linetype pattern as tuple of floats, all line elements and gaps are values greater than 0.0 and 0.0 represents a point. Line or point elements do always alternate with gap elements: line\-gap\-line\-gap\-point\-gap and the pattern always ends with a gap. The continuous line is an empty tuple. .UNINDENT .INDENT 7.0 .TP .B linetype_scale The scaling factor as float to apply to the \fI\%linetype_pattern\fP\&. .UNINDENT .INDENT 7.0 .TP .B lineweight The absolute lineweight to render in mm as float. .UNINDENT .INDENT 7.0 .TP .B is_visible Visibility flag as bool. .UNINDENT .INDENT 7.0 .TP .B layer The actual layer name the entity resides on as UPPERCASE string. .UNINDENT .INDENT 7.0 .TP .B font The \fBFontFace\fP used for text rendering or \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B filling The actual \fBFilling\fP properties of the entity or \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B units The actual drawing units as \fI\%InsertUnits\fP enum. .UNINDENT .UNINDENT .SS LayerProperties .INDENT 0.0 .TP .B class ezdxf.addons.drawing.properties.LayerProperties Actual layer properties, inherits from class \fBProperties\fP\&. .INDENT 7.0 .TP .B is_visible Modified meaning: whether entities belonging to this layer should be drawn .UNINDENT .INDENT 7.0 .TP .B layer Modified meaning: stores real layer name (mixed case) .UNINDENT .UNINDENT .SS LayoutProperties .INDENT 0.0 .TP .B class ezdxf.addons.drawing.properties.LayoutProperties Actual layout properties. .INDENT 7.0 .TP .B name Layout name as string .UNINDENT .INDENT 7.0 .TP .B units Layout units as \fI\%InsertUnits\fP enum. .UNINDENT .INDENT 7.0 .TP .B property LayoutProperties.background_color: str Returns the default layout background color. .UNINDENT .INDENT 7.0 .TP .B property LayoutProperties.default_color: str Returns the default layout foreground color. .UNINDENT .INDENT 7.0 .TP .B property LayoutProperties.has_dark_background: bool Returns \fBTrue\fP if the actual background\-color is \(dqdark\(dq. .UNINDENT .INDENT 7.0 .TP .B LayoutProperties.set_colors(bg: str, fg: str | None = None) -> None Setup default layout colors. .sp Required color format \(dq#RRGGBB\(dq or including alpha transparency \(dq#RRGGBBAA\(dq. .UNINDENT .UNINDENT .SS RenderContext .INDENT 0.0 .TP .B class ezdxf.addons.drawing.properties.RenderContext(doc: \fI\%Drawing\fP | None = None, *, ctb: str = \(aq\(aq, export_mode: bool = False) The render context for the given DXF document. The \fI\%RenderContext\fP resolves the properties of DXF entities from the context they reside in to actual values like RGB colors, transparency, linewidth and so on. .sp A given \fIctb\fP file (plot style file) overrides the default properties for all layouts, which means the plot style table stored in the layout is always ignored. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdoc\fP \-\- DXF document .IP \(bu 2 \fBctb\fP \-\- path to a plot style table .IP \(bu 2 \fBexport_mode\fP \-\- Whether to render the document as it would look when exported (plotted) by a CAD application to a file such as pdf, or whether to render the document as it would appear inside a CAD application. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B resolve_aci_color(aci: int, resolved_layer: str) -> str Resolve the \fIaci\fP color as hex color string: \(dq#RRGGBB\(dq .UNINDENT .INDENT 7.0 .TP .B resolve_all(entity: DXFGraphic) -> \fI\%Properties\fP Resolve all properties of \fIentity\fP\&. .UNINDENT .INDENT 7.0 .TP .B resolve_color(entity: DXFGraphic, *, resolved_layer: str | None = None) -> str Resolve the rgb\-color of \fIentity\fP as hex color string: \(dq#RRGGBB\(dq or \(dq#RRGGBBAA\(dq. .UNINDENT .INDENT 7.0 .TP .B resolve_filling(entity: DXFGraphic) -> Filling | None Resolve filling properties (SOLID, GRADIENT, PATTERN) of \fIentity\fP\&. .UNINDENT .INDENT 7.0 .TP .B resolve_font(entity: DXFGraphic) -> \fI\%FontFace\fP | None Resolve the text style of \fIentity\fP to a font name. Returns \fBNone\fP for the default font. .UNINDENT .INDENT 7.0 .TP .B resolve_layer(entity: DXFGraphic) -> str Resolve the layer of \fIentity\fP, this is only relevant for entities inside of block references. .UNINDENT .INDENT 7.0 .TP .B resolve_layer_properties(layer: Layer) -> \fI\%LayerProperties\fP Resolve layer properties. .UNINDENT .INDENT 7.0 .TP .B resolve_linetype(entity: DXFGraphic, *, resolved_layer: str | None = None) -> tuple[str, Sequence[float]] Resolve the linetype of \fIentity\fP\&. Returns a tuple of the linetype name as upper\-case string and the simplified linetype pattern as tuple of floats. .UNINDENT .INDENT 7.0 .TP .B resolve_lineweight(entity: DXFGraphic, *, resolved_layer: str | None = None) -> float Resolve the lineweight of \fIentity\fP in mm. .sp DXF stores the lineweight in mm times 100 (e.g. 0.13mm = 13). The smallest line weight is 0 and the biggest line weight is 211. The DXF/DWG format is limited to a fixed value table, see: \fBezdxf.lldxf.const.VALID_DXF_LINEWEIGHTS\fP .sp CAD applications draw lineweight 0mm as an undefined small value, to prevent backends to draw nothing for lineweight 0mm the smallest return value is 0.01mm. .UNINDENT .INDENT 7.0 .TP .B resolve_units() -> \fI\%InsertUnits\fP .UNINDENT .INDENT 7.0 .TP .B resolve_visible(entity: DXFGraphic, *, resolved_layer: str | None = None) -> bool Resolve the visibility state of \fIentity\fP\&. Returns \fBTrue\fP if \fIentity\fP is visible. .UNINDENT .INDENT 7.0 .TP .B set_current_layout(layout: \fI\%Layout\fP, ctb: str = \(aq\(aq) Set the current layout and update layout specific properties. .UNINDENT .INDENT 7.0 .TP .B set_layer_properties_override(func: Callable[[Sequence[\fI\%LayerProperties\fP]], None] | None = None) The function \fIfunc\fP is called with the current layer properties as argument after resetting them, so the function can override the layer properties. .UNINDENT .UNINDENT .sp The \fBRenderContext\fP class can be used isolated from the \fBdrawing\fP add\-on to resolve DXF properties. .SS Frontend .INDENT 0.0 .TP .B class ezdxf.addons.drawing.frontend.Frontend(ctx: \fI\%RenderContext\fP, out: \fI\%BackendInterface\fP, config: \fI\%Configuration\fP = Configuration.defaults(), bbox_cache: \fI\%ezdxf.bbox.Cache\fP = None) Drawing frontend for 2D backends, responsible for decomposing entities into graphic primitives and resolving entity properties. .sp By passing the bounding box cache of the modelspace entities can speed up paperspace rendering, because the frontend can filter entities which are not visible in the VIEWPORT. Even passing in an empty cache can speed up rendering time when multiple viewports need to be processed. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBctx\fP \-\- the properties relevant to rendering derived from a DXF document .IP \(bu 2 \fBout\fP \-\- the 2D backend to draw to .IP \(bu 2 \fBconfig\fP \-\- settings to configure the drawing frontend and backend .IP \(bu 2 \fBbbox_cache\fP \-\- bounding box cache of the modelspace entities or an empty cache which will be filled dynamically when rendering multiple viewports or \fBNone\fP to disable bounding box caching at all .UNINDENT .UNINDENT .INDENT 7.0 .TP .B log_message(message: str) Log given message \- override to alter behavior. .UNINDENT .INDENT 7.0 .TP .B skip_entity(entity: DXFEntity, msg: str) -> None Called for skipped entities \- override to alter behavior. .UNINDENT .INDENT 7.0 .TP .B override_properties(entity: DXFGraphic, properties: \fI\%Properties\fP) -> None The \fI\%override_properties()\fP filter can change the properties of an entity independent of the DXF attributes. .sp This filter has access to the DXF attributes by the \fIentity\fP object, the current render context, and the resolved properties by the \fIproperties\fP object. It is recommended to modify only the \fIproperties\fP object in this filter. .UNINDENT .INDENT 7.0 .TP .B draw_layout(layout: Layout, finalize: bool = True, *, filter_func: Callable[[DXFGraphic], bool] | None = None, layout_properties: \fI\%LayoutProperties\fP | None = None) -> None Draw all entities of the given \fIlayout\fP\&. .sp Draws the entities of the layout in the default or redefined redraw\-order and calls the \fBfinalize()\fP method of the backend if requested. The default redraw order is the ascending handle order not the order the entities are stored in the layout. .sp The method skips invisible entities and entities for which the given filter function returns \fBFalse\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP \-\- layout to draw of type \fI\%Layout\fP .IP \(bu 2 \fBfinalize\fP \-\- \fBTrue\fP if the \fBfinalize()\fP method of the backend should be called automatically .IP \(bu 2 \fBfilter_func\fP \-\- function to filter DXf entities, the function should return \fBFalse\fP if a given entity should be ignored .IP \(bu 2 \fBlayout_properties\fP \-\- override the default layout properties .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS BackendInterface .INDENT 0.0 .TP .B class ezdxf.addons.drawing.backend.BackendInterface Public interface definition for 2D rendering backends. .sp For more information read the source code: \fI\%backend.py\fP .UNINDENT .SS Backend .INDENT 0.0 .TP .B class ezdxf.addons.drawing.backend.Backend Abstract base class for concrete backend implementations and implements some default features. .sp For more information read the source code: \fI\%backend.py\fP .UNINDENT .SS Details .sp The rendering is performed in two stages. The frontend traverses the DXF document structure, converting each encountered entity into primitive drawing commands. These commands are fed to a backend which implements the interface: \fI\%Backend\fP\&. .sp Although the resulting images will not be pixel\-perfect with AutoCAD (which was taken as the ground truth when developing this add\-on) great care has been taken to achieve similar behavior in some areas: .INDENT 0.0 .IP \(bu 2 The algorithm for determining color should match AutoCAD. However, the color palette is not stored in the DXF file, so the chosen colors may be different to what is expected. The \fI\%RenderContext\fP class supports passing a plot style table (\fI\%CTB\fP\-file) as custom color palette but uses the same palette as AutoCAD by default. .IP \(bu 2 Text rendering is quite accurate, text positioning, alignment and word wrapping are very faithful. Differences may occur if a different font from what was used by the CAD application but even in that case, for supported backends, measurements are taken of the font being used to match text as closely as possible. .IP \(bu 2 Visibility determination (based on which layers are visible) should match AutoCAD .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%draw_cad.py\fP for a simple use of this module .IP \(bu 2 \fI\%cad_viewer.py\fP for an advanced use of this module .IP \(bu 2 \fI\%Notes on Rendering DXF Content\fP for additional behaviours documented during the development of this add\-on. .UNINDENT .UNINDENT .UNINDENT .SS Geo Interface .SS Intended Usage .sp The intended usage of the \fI\%ezdxf.addons.geo\fP module is as tool to work with geospatial data in conjunction with dedicated geospatial applications and libraries and the module can not and should not replicate their functionality. .sp The only reimplemented feature is the most common WSG84 EPSG:3395 World Mercator projection, for everything else use the dedicated packages like: .INDENT 0.0 .IP \(bu 2 \fI\%pyproj\fP \- Cartographic projections and coordinate transformations library. .IP \(bu 2 \fI\%Shapely\fP \- Manipulation and analysis of geometric objects in the Cartesian plane. .IP \(bu 2 \fI\%PyShp\fP \- The Python Shapefile Library (PyShp) reads and writes ESRI Shapefiles in pure Python. .IP \(bu 2 \fI\%GeoJSON\fP \- GeoJSON interface for Python. .IP \(bu 2 \fI\%GDAL\fP \- Tools for programming and manipulating the GDAL Geospatial Data Abstraction Library. .IP \(bu 2 \fI\%Fiona\fP \- Fiona is GDAL’s neat and nimble vector API for Python programmers. .IP \(bu 2 \fI\%QGIS\fP \- A free and open source geographic information system. .IP \(bu 2 and many more … .UNINDENT .sp This module provides support for the \fB__geo_interface__\fP: \fI\%https://gist.github.com/sgillies/2217756\fP .sp Which is also supported by \fI\%Shapely\fP, for supported types see the \fI\%GeoJSON\fP Standard and examples in \fI\%Appendix\-A\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Tutorial for the Geo Add\-on\fP for loading GPX data into DXF files with an existing geo location reference and exporting DXF entities as GeoJSON data. .UNINDENT .UNINDENT .SS Proxy From Mapping .sp The \fI\%GeoProxy\fP represents a \fB__geo_interface__\fP mapping, create a new proxy by \fI\%GeoProxy.parse()\fP from an external \fB__geo_interface__\fP mapping. \fI\%GeoProxy.to_dxf_entities()\fP returns new DXF entities from this mapping. Returns “Point” as \fI\%Point\fP entity, “LineString” as \fI\%LWPolyline\fP entity and “Polygon” as \fI\%Hatch\fP entity or as separated \fI\%LWPolyline\fP entities (or both) and new in v0.16.6 as \fI\%MPolygon\fP\&. Supports “MultiPoint”, “MultiLineString”, “MultiPolygon”, “GeometryCollection”, “Feature” and “FeatureCollection”. Add new DXF entities to a layout by the \fBLayout.add_entity()\fP method. .SS Proxy From DXF Entity .sp The \fI\%proxy()\fP function or the constructor \fI\%GeoProxy.from_dxf_entities()\fP creates a new \fI\%GeoProxy\fP object from a single DXF entity or from an iterable of DXF entities, entities without a corresponding representation will be approximated. .sp Supported DXF entities are: .INDENT 0.0 .IP \(bu 2 POINT as “Point” .IP \(bu 2 LINE as “LineString” .IP \(bu 2 LWPOLYLINE as “LineString” if open and “Polygon” if closed .IP \(bu 2 POLYLINE as “LineString” if open and “Polygon” if closed, supports only 2D and 3D polylines, POLYMESH and POLYFACE are not supported .IP \(bu 2 SOLID, TRACE, 3DFACE as “Polygon” .IP \(bu 2 CIRCLE, ARC, ELLIPSE and SPLINE by approximation as “LineString” if open and “Polygon” if closed .IP \(bu 2 HATCH and MPOLYGON as “Polygon”, holes are supported .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 This module does no extensive validity checks for “Polygon” objects and because DXF has different requirements for HATCH boundary paths than the \fI\%GeoJSON\fP Standard, it is possible to create invalid “Polygon” objects. It is recommended to check critical objects by a sophisticated geometry library like \fI\%Shapely\fP\&. .UNINDENT .UNINDENT .SS Module Functions .INDENT 0.0 .TP .B ezdxf.addons.geo.proxy(entity: DXFGraphic | Iterable[DXFGraphic], distance: float = MAX_FLATTENING_DISTANCE, force_line_string: bool = False) -> \fI\%GeoProxy\fP Returns a \fI\%GeoProxy\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP – a single DXF entity or iterable of DXF entities .IP \(bu 2 \fBdistance\fP – maximum flattening distance for curve approximations .IP \(bu 2 \fBforce_line_string\fP – by default this function returns Polygon objects for closed geometries like CIRCLE, SOLID, closed POLYLINE and so on, by setting argument \fIforce_line_string\fP to \fBTrue\fP, this entities will be returned as LineString objects. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.geo.dxf_entities(geo_mapping: MutableMapping[str, Any], polygon=PolygonConversion.HATCH, dxfattribs=None, *, post_process: Callable[[DXFGraphic, MutableMapping[str, Any]], None] | None = None) -> Iterator[DXFGraphic] Returns \fB__geo_interface__\fP mappings as DXF entities. .sp The enum \fIpolygon\fP determines the method to convert polygons, use \fI\%PolygonConversion.HATCH\fP for \fI\%Hatch\fP entity, \fI\%PolygonConversion.POLYLINE\fP for \fI\%LWPolyline\fP or \fI\%PolygonConversion.HATCH_AND_POLYLINE\fP for both. Option \fI\%PolygonConversion.POLYLINE\fP returns for the exterior path and each hole a separated \fBLWPolyline\fP entity. The \fBHatch\fP entity supports holes, but has no explicit borderline. .sp Yields \fBHatch\fP always before \fBLWPolyline\fP entities. .sp \fI\%PolygonConversion.MPOLYGON\fP support was added in v0.16.6, which is like a \fI\%Hatch\fP entity with additional borderlines, but the MPOLYGON entity is not a core DXF entity and DXF viewers, applications and libraries my not support this entity. The DXF attribute \fIcolor\fP defines the borderline color and \fIfill_color\fP the color of the solid filling. .sp The returned DXF entities can be added to a layout by the \fBLayout.add_entity()\fP method. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBgeo_mapping\fP – \fB__geo__interface__\fP mapping as \fBdict\fP or a Python object with a \fB__geo__interface__\fP property .IP \(bu 2 \fBpolygon\fP – see \fI\%PolygonConversion\fP .IP \(bu 2 \fBdxfattribs\fP – dict with additional DXF attributes .IP \(bu 2 \fBpost_process\fP – post process function of type \fBPostProcesFunc\fP that get the created DXF entity and the geo mapping as input, see reference implementation \fI\%assign_layers()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.geo.gfilter(entities: Iterable[DXFGraphic]) -> Iterator[DXFGraphic] Filter DXF entities from iterable \fIentities\fP, which are incompatible to the \fB__geo_reference__\fP interface. .UNINDENT .SS GeoProxy Class .INDENT 0.0 .TP .B class ezdxf.addons.geo.GeoProxy(geo_mapping: MutableMapping[str, Any], places: int = 6) Stores the \fB__geo_interface__\fP mapping in a parsed and compiled form. .sp Stores coordinates as \fBVec3\fP objects and represents “Polygon” always as tuple (exterior, holes) even without holes. .sp The GeoJSON specification recommends 6 decimal places for latitude and longitude which equates to roughly 10cm of precision. You may need slightly more for certain applications, 9 decimal places would be sufficient for professional survey\-grade GPS coordinates. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBgeo_mapping\fP – parsed and compiled \fB__geo_interface__\fP mapping .IP \(bu 2 \fBplaces\fP – decimal places to round for \fB__geo_interface__\fP export .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __geo_interface__ Returns the \fB__geo_interface__\fP compatible mapping as \fBdict\fP\&. .UNINDENT .INDENT 7.0 .TP .B geotype Property returns the top level entity type or \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B classmethod parse(geo_mapping: MutableMapping[str, Any]) -> Self Parse and compile a \fB__geo_interface__\fP mapping as \fBdict\fP or a Python object with a \fB__geo_interface__\fP property, does some basic syntax checks, converts all coordinates into \fBVec3\fP objects, represents “Polygon” always as tuple (exterior, holes) even without holes. .UNINDENT .INDENT 7.0 .TP .B classmethod from_dxf_entities(entity: DXFGraphic | Iterable[DXFGraphic], distance: float = MAX_FLATTENING_DISTANCE, force_line_string: bool = False) -> \fI\%GeoProxy\fP Constructor from a single DXF entity or an iterable of DXF entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP – DXF entity or entities .IP \(bu 2 \fBdistance\fP – maximum flattening distance for curve approximations .IP \(bu 2 \fBforce_line_string\fP – by default this function returns Polygon objects for closed geometries like CIRCLE, SOLID, closed POLYLINE and so on, by setting argument \fIforce_line_string\fP to \fBTrue\fP, this entities will be returned as LineString objects. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_dxf_entities(polygon=PolygonConversion.HATCH, dxfattribs=None, *, post_process: Callable[[DXFGraphic, MutableMapping[str, Any]], None] | None = None) -> Iterator[DXFGraphic] Returns stored \fB__geo_interface__\fP mappings as DXF entities. .sp The \fIpolygon\fP argument determines the method to convert polygons, use 1 for \fI\%Hatch\fP entity, 2 for \fI\%LWPolyline\fP or 3 for both. Option 2 returns for the exterior path and each hole a separated \fBLWPolyline\fP entity. The \fBHatch\fP entity supports holes, but has no explicit borderline. .sp Yields \fBHatch\fP always before \fBLWPolyline\fP entities. .sp \fI\%MPolygon\fP support was added in v0.16.6, which is like a \fI\%Hatch\fP entity with additional borderlines, but the MPOLYGON entity is not a core DXF entity and DXF viewers, applications and libraries my not support this entity. The DXF attribute \fIcolor\fP defines the borderline color and \fIfill_color\fP the color of the solid filling. .sp The returned DXF entities can be added to a layout by the \fBLayout.add_entity()\fP method. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpolygon\fP – see \fI\%PolygonConversion\fP .IP \(bu 2 \fBdxfattribs\fP – dict with additional DXF attributes .IP \(bu 2 \fBpost_process\fP – post process function of type \fBPostProcesFunc\fP that get the created DXF entity and the geo mapping as input, see reference implementation \fI\%assign_layers()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B copy() -> \fI\%GeoProxy\fP Returns a deep copy. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[MutableMapping[str, Any]] Iterate over all geometry entities. .sp Yields only “Point”, “LineString”, “Polygon”, “MultiPoint”, “MultiLineString” and “MultiPolygon” objects, returns the content of “GeometryCollection”, “FeatureCollection” and “Feature” as geometry objects (“Point”, …). .UNINDENT .INDENT 7.0 .TP .B wcs_to_crs(crs: \fI\%Matrix44\fP) -> None Transform all coordinates recursive from \fI\%WCS\fP coordinates into Coordinate Reference System (CRS) by transformation matrix \fIcrs\fP inplace. .sp The CRS is defined by the \fI\%GeoData\fP entity, get the \fBGeoData\fP entity from the modelspace by method \fI\%get_geodata()\fP\&. The CRS transformation matrix can be acquired form the \fBGeoData\fP object by \fI\%get_crs_transformation()\fP method: .INDENT 7.0 .INDENT 3.5 .sp .EX doc = ezdxf.readfile(\(aqfile.dxf\(aq) msp = doc.modelspace() geodata = msp.get_geodata() if geodata: matrix, axis_ordering = geodata.get_crs_transformation() .EE .UNINDENT .UNINDENT .sp If \fIaxis_ordering\fP is \fBFalse\fP the CRS is not compatible with the \fB__geo_interface__\fP or GeoJSON (see chapter 3.1.1). .INDENT 7.0 .TP .B Parameters \fBcrs\fP – transformation matrix of type \fI\%Matrix44\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B crs_to_wcs(crs: \fI\%Matrix44\fP) -> None Transform all coordinates recursive from CRS into \fI\%WCS\fP coordinates by transformation matrix \fIcrs\fP inplace, see also \fI\%GeoProxy.wcs_to_crs()\fP\&. .INDENT 7.0 .TP .B Parameters \fBcrs\fP – transformation matrix of type \fI\%Matrix44\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B globe_to_map(func: Callable[[\fI\%Vec3\fP], \fI\%Vec3\fP] | None = None) -> None Transform all coordinates recursive from globe representation in longitude and latitude in decimal degrees into 2D map representation in meters. .sp Default is WGS84 \fI\%EPSG:4326\fP (GPS) to WGS84 \fI\%EPSG:3395\fP World Mercator function \fI\%wgs84_4326_to_3395()\fP\&. .sp Use the \fI\%pyproj\fP package to write a custom projection function as needed. .INDENT 7.0 .TP .B Parameters \fBfunc\fP – custom transformation function, which takes one \fBVec3\fP object as argument and returns the result as a \fBVec3\fP object. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B map_to_globe(func: Callable[[\fI\%Vec3\fP], \fI\%Vec3\fP] | None = None) -> None Transform all coordinates recursive from 2D map representation in meters into globe representation as longitude and latitude in decimal degrees. .sp Default is WGS84 \fI\%EPSG:3395\fP World Mercator to WGS84 \fI\%EPSG:4326\fP GPS function \fI\%wgs84_3395_to_4326()\fP\&. .sp Use the \fI\%pyproj\fP package to write a custom projection function as needed. .INDENT 7.0 .TP .B Parameters \fBfunc\fP – custom transformation function, which takes one \fBVec3\fP object as argument and returns the result as a \fBVec3\fP object. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B apply(func: Callable[[\fI\%Vec3\fP], \fI\%Vec3\fP]) -> None Apply the transformation function \fIfunc\fP recursive to all coordinates. .INDENT 7.0 .TP .B Parameters \fBfunc\fP – transformation function as Callable[[Vec3], Vec3] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B filter(func: Callable[[\fI\%GeoProxy\fP], bool]) -> None Removes all mappings for which \fIfunc()\fP returns \fBFalse\fP\&. The function only has to handle Point, LineString and Polygon entities, other entities like MultiPolygon are divided into separate entities also any collection. .UNINDENT .UNINDENT .SS Helper Functions .INDENT 0.0 .TP .B ezdxf.addons.geo.wgs84_4326_to_3395(location: \fI\%Vec3\fP) -> \fI\%Vec3\fP Transform WGS84 \fI\%EPSG:4326\fP location given as latitude and longitude in decimal degrees as used by GPS into World Mercator cartesian 2D coordinates in meters \fI\%EPSG:3395\fP\&. .INDENT 7.0 .TP .B Parameters \fBlocation\fP – \fBVec3\fP object, x\-attribute represents the longitude value (East\-West) in decimal degrees and the y\-attribute represents the latitude value (North\-South) in decimal degrees. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.geo.wgs84_3395_to_4326(location: \fI\%Vec3\fP, tol: float = 1e\-6) -> \fI\%Vec3\fP Transform WGS84 World Mercator \fI\%EPSG:3395\fP location given as cartesian 2D coordinates x, y in meters into WGS84 decimal degrees as longitude and latitude \fI\%EPSG:4326\fP as used by GPS. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlocation\fP – \fBVec3\fP object, z\-axis is ignored .IP \(bu 2 \fBtol\fP – accuracy for latitude calculation .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.geo.dms2dd(d: float, m: float = 0, s: float = 0) -> float Convert degree, minutes, seconds into decimal degrees. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.geo.dd2dms(dd: float) -> tuple[float, float, float] Convert decimal degrees into degree, minutes, seconds. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.geo.assign_layers(entity: DXFGraphic, mapping: MutableMapping[str, Any]) -> None Reference implementation for a \fBpost_process()\fP function. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 \fI\%dxf_entities()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX def assign_layers(entity: DXFGraphic, mapping: GeoMapping) \-> None: properties = mapping.get(\(dqproperties) if properties is None: return layer = properties.get(\(dqlayer\(dq) if layer: entity.dxf.layer = layer .EE .UNINDENT .UNINDENT .SS Types .INDENT 0.0 .TP .B class ezdxf.addons.geo.PolygonConversion(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Polygon conversion types as \fBIntEnum\fP\&. .INDENT 7.0 .TP .B HATCH .UNINDENT .INDENT 7.0 .TP .B POLYLINE .UNINDENT .INDENT 7.0 .TP .B HATCH_AND_POLYLINE .UNINDENT .INDENT 7.0 .TP .B MPOLYGON .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.geo.GeoMapping alias of \fBMutableMapping\fP[\fBstr\fP, \fBAny\fP] .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.geo.PostProcessFunc alias of \fBCallable\fP[[\fBDXFGraphic\fP, \fBMutableMapping\fP[\fBstr\fP, \fBAny\fP]], \fBNone\fP] .UNINDENT .SS Importer .sp This add\-on is meant to import graphical entities from another DXF drawing and their required table entries like LAYER, LTYPE or STYLE. .sp Because of complex extensibility of the DXF format and the lack of sufficient documentation, I decided to remove most of the possible source drawing dependencies from imported entities, therefore imported entities may not look the same as the original entities in the source drawing, but at least the geometry should be the same and the DXF file does not break. .sp Removed data which could contain source drawing dependencies: Extension Dictionaries, AppData and XDATA. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 DON’T EXPECT PERFECT RESULTS! .UNINDENT .UNINDENT .sp The \fI\%Importer\fP supports following data import: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 entities which are really safe to import: LINE, POINT, CIRCLE, ARC, TEXT, SOLID, TRACE, 3DFACE, SHAPE, POLYLINE, ATTRIB, ATTDEF, INSERT, ELLIPSE, MTEXT, LWPOLYLINE, SPLINE, HATCH, MESH, XLINE, RAY, DIMENSION, LEADER, VIEWPORT .IP \(bu 2 table and table entry import is restricted to LAYER, LTYPE, STYLE, DIMSTYLE .IP \(bu 2 import of BLOCK definitions is supported .IP \(bu 2 import of paper space layouts is supported .UNINDENT .UNINDENT .UNINDENT .sp Import of DXF objects from the OBJECTS section is not supported. .sp DIMSTYLE override for entities DIMENSION and LEADER is not supported. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons import Importer sdoc = ezdxf.readfile(\(aqoriginal.dxf\(aq) tdoc = ezdxf.new() importer = Importer(sdoc, tdoc) # import all entities from source modelspace into modelspace of the target drawing importer.import_modelspace() # import all paperspace layouts from source drawing importer.import_paperspace_layouts() # import all CIRCLE and LINE entities from source modelspace into an arbitrary target layout. # create target layout tblock = tdoc.blocks.new(\(aqSOURCE_ENTS\(aq) # query source entities ents = sdoc.modelspace().query(\(aqCIRCLE LINE\(aq) # import source entities into target block importer.import_entities(ents, tblock) # This is ALWAYS the last & required step, without finalizing the target drawing is maybe invalid! # This step imports all additional required table entries and block definitions. importer.finalize() tdoc.saveas(\(aqimported.dxf\(aq) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.importer.Importer(source: \fI\%Drawing\fP, target: \fI\%Drawing\fP) The \fI\%Importer\fP class is central element for importing data from other DXF documents. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsource\fP – source \fBDrawing\fP .IP \(bu 2 \fBtarget\fP – target \fBDrawing\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B source source DXF document .UNINDENT .INDENT 7.0 .TP .B target target DXF document .UNINDENT .INDENT 7.0 .TP .B used_layers Set of used layer names as string, AutoCAD accepts layer names without a LAYER table entry. .UNINDENT .INDENT 7.0 .TP .B used_linetypes Set of used linetype names as string, these linetypes require a TABLE entry or AutoCAD will crash. .UNINDENT .INDENT 7.0 .TP .B used_styles Set of used text style names, these text styles require a TABLE entry or AutoCAD will crash. .UNINDENT .INDENT 7.0 .TP .B used_dimstyles Set of used dimension style names, these dimension styles require a TABLE entry or AutoCAD will crash. .UNINDENT .INDENT 7.0 .TP .B finalize() -> None Finalize the import by importing required table entries and BLOCK definitions, without finalization the target document is maybe invalid for AutoCAD. Call the \fI\%finalize()\fP method as last step of the import process. .UNINDENT .INDENT 7.0 .TP .B import_block(block_name: str, rename=True) -> str Import one BLOCK definition from source document. .sp If the BLOCK already exist the BLOCK will be renamed if argument \fIrename\fP is \fBTrue\fP, otherwise the existing BLOCK in the target document will be used instead of the BLOCK in the source document. Required name resolving for imported block references (INSERT), will be done in the \fI\%Importer.finalize()\fP method. .sp To replace an existing BLOCK in the target document, just delete it before importing data: \fBtarget.blocks.delete_block(block_name, safe=False)\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBblock_name\fP – name of BLOCK to import .IP \(bu 2 \fBrename\fP – rename BLOCK if a BLOCK with the same name already exist in target document .UNINDENT .UNINDENT .sp Returns: (renamed) BLOCK name .INDENT 7.0 .TP .B Raises \fBValueError\fP – BLOCK in source document not found (defined) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_blocks(block_names: Iterable[str], rename=False) -> None Import all BLOCK definitions from source document. .sp If a BLOCK already exist the BLOCK will be renamed if argument \fIrename\fP is \fBTrue\fP, otherwise the existing BLOCK in the target document will be used instead of the BLOCK from the source document. Required name resolving for imported BLOCK references (INSERT), will be done in the \fI\%Importer.finalize()\fP method. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBblock_names\fP – names of BLOCK definitions to import .IP \(bu 2 \fBrename\fP – rename BLOCK if a BLOCK with the same name already exist in target document .UNINDENT .TP .B Raises \fBValueError\fP – BLOCK in source document not found (defined) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_entities(entities: Iterable[\fI\%DXFEntity\fP], target_layout: \fI\%BaseLayout\fP | None = None) -> None Import all \fIentities\fP into \fItarget_layout\fP or the modelspace of the target document, if \fItarget_layout\fP is \fBNone\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentities\fP – Iterable of DXF entities .IP \(bu 2 \fBtarget_layout\fP – any layout (modelspace, paperspace or block) from the target document .UNINDENT .TP .B Raises \fI\%DXFStructureError\fP – \fItarget_layout\fP is not a layout of target document .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_entity(entity: \fI\%DXFEntity\fP, target_layout: \fI\%BaseLayout\fP | None = None) -> None Imports a single DXF \fIentity\fP into \fItarget_layout\fP or the modelspace of the target document, if \fItarget_layout\fP is \fBNone\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP – DXF entity to import .IP \(bu 2 \fBtarget_layout\fP – any layout (modelspace, paperspace or block) from the target document .UNINDENT .TP .B Raises \fI\%DXFStructureError\fP – \fItarget_layout\fP is not a layout of target document .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_modelspace(target_layout: \fI\%BaseLayout\fP | None = None) -> None Import all entities from source modelspace into \fItarget_layout\fP or the modelspace of the target document, if \fItarget_layout\fP is \fBNone\fP\&. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – any layout (modelspace, paperspace or block) from the target document .TP .B Raises \fI\%DXFStructureError\fP – \fItarget_layout\fP is not a layout of target document .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_paperspace_layout(name: str) -> \fI\%Layout\fP Import paperspace layout \fIname\fP into the target document. .sp Recreates the source paperspace layout in the target document, renames the target paperspace if a paperspace with same \fIname\fP already exist and imports all entities from the source paperspace into the target paperspace. .INDENT 7.0 .TP .B Parameters \fBname\fP – source paper space name as string .UNINDENT .sp Returns: new created target paperspace \fBLayout\fP .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBKeyError\fP – source paperspace does not exist .IP \(bu 2 \fI\%DXFTypeError\fP – invalid modelspace import .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_paperspace_layouts() -> None Import all paperspace layouts and their content into the target document. Target layouts will be renamed if a layout with the same name already exist. Layouts will be imported in original tab order. .UNINDENT .INDENT 7.0 .TP .B import_shape_files(fonts: set[str]) -> None Import shape file table entries from the source document into the target document. Shape file entries are stored in the styles table but without a name. .UNINDENT .INDENT 7.0 .TP .B import_table(name: str, entries: str | Iterable[str] = \(aq*\(aq, replace=False) -> None Import specific table entries from the source document into the target document. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – valid table names are “layers”, “linetypes” and “styles” .IP \(bu 2 \fBentries\fP – Iterable of table names as strings, or a single table name or “*” for all table entries .IP \(bu 2 \fBreplace\fP – \fBTrue\fP to replace the already existing table entry else ignore existing entries .UNINDENT .TP .B Raises \fBTypeError\fP – unsupported table type .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_tables(table_names: str | Iterable[str] = \(aq*\(aq, replace=False) -> None Import DXF tables from the source document into the target document. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtable_names\fP – iterable of tables names as strings, or a single table name as string or “*” for all supported tables .IP \(bu 2 \fBreplace\fP – \fBTrue\fP to replace already existing table entries else ignore existing entries .UNINDENT .TP .B Raises \fBTypeError\fP – unsupported table type .UNINDENT .UNINDENT .INDENT 7.0 .TP .B recreate_source_layout(name: str) -> \fI\%Layout\fP Recreate source paperspace layout \fIname\fP in the target document. The layout will be renamed if \fIname\fP already exist in the target document. Returns target modelspace for layout name “Model”. .INDENT 7.0 .TP .B Parameters \fBname\fP – layout name as string .TP .B Raises \fBKeyError\fP – if source layout \fIname\fP not exist .UNINDENT .UNINDENT .UNINDENT .SS dxf2code .sp Translate DXF entities and structures into Python source code. .sp Short example: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons.dxf2code import entities_to_code, block_to_code doc = ezdxf.readfile(\(aqoriginal.dxf\(aq) msp = doc.modelspace() source = entities_to_code(msp) # create source code for a block definition block_source = block_to_code(doc.blocks[\(aqMyBlock\(aq]) # merge source code objects source.merge(block_source) with open(\(aqsource.py\(aq, mode=\(aqwt\(aq) as f: f.write(source.import_str()) f.write(\(aq\en\en\(aq) f.write(source.code_str()) f.write(\(aq\en\(aq) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.dxf2code.entities_to_code(entities: Iterable[\fI\%DXFEntity\fP], layout: str = \(aqlayout\(aq, ignore: Iterable[str] | None = None) -> \fI\%Code\fP Translates DXF entities into Python source code to recreate this entities by ezdxf. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentities\fP – iterable of DXFEntity .IP \(bu 2 \fBlayout\fP – variable name of the layout (model space or block) as string .IP \(bu 2 \fBignore\fP – iterable of entities types to ignore as strings like \fB[\(aqIMAGE\(aq, \(aqDIMENSION\(aq]\fP .UNINDENT .TP .B Returns \fI\%Code\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.dxf2code.block_to_code(block: \fI\%BlockLayout\fP, drawing: str = \(aqdoc\(aq, ignore: Iterable[str] | None = None) -> \fI\%Code\fP Translates a BLOCK into Python source code to recreate the BLOCK by ezdxf. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBblock\fP – block definition layout .IP \(bu 2 \fBdrawing\fP – variable name of the drawing as string .IP \(bu 2 \fBignore\fP – iterable of entities types to ignore as strings like [‘IMAGE’, ‘DIMENSION’] .UNINDENT .TP .B Returns \fI\%Code\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.dxf2code.table_entries_to_code(entities: Iterable[\fI\%DXFEntity\fP], drawing=\(aqdoc\(aq) -> \fI\%Code\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.dxf2code.black(code: str, line_length=88, fast: bool = True) -> str Returns the source \fIcode\fP as a single string formatted by \fI\%Black\fP .sp Requires the installed \fI\%Black\fP formatter: .INDENT 7.0 .INDENT 3.5 .sp .EX pip3 install black .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcode\fP – source code .IP \(bu 2 \fBline_length\fP – max. source code line length .IP \(bu 2 \fBfast\fP – \fBTrue\fP for fast mode, \fBFalse\fP to check that the reformatted code is valid .UNINDENT .TP .B Raises \fBImportError\fP – Black is not available .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.dxf2code.Code Source code container. .INDENT 7.0 .TP .B code Source code line storage, store lines without line ending \fB\e\en\fP .UNINDENT .INDENT 7.0 .TP .B imports source code line storage for global imports, store lines without line ending \fB\e\en\fP .UNINDENT .INDENT 7.0 .TP .B layers Layers used by the generated source code, AutoCAD accepts layer names without a LAYER table entry. .UNINDENT .INDENT 7.0 .TP .B linetypes Linetypes used by the generated source code, these linetypes require a TABLE entry or AutoCAD will crash. .UNINDENT .INDENT 7.0 .TP .B styles Text styles used by the generated source code, these text styles require a TABLE entry or AutoCAD will crash. .UNINDENT .INDENT 7.0 .TP .B dimstyles Dimension styles used by the generated source code, these dimension styles require a TABLE entry or AutoCAD will crash. .UNINDENT .INDENT 7.0 .TP .B blocks Blocks used by the generated source code, these blocks require a BLOCK definition in the BLOCKS section or AutoCAD will crash. .UNINDENT .INDENT 7.0 .TP .B code_str(indent: int = 0) -> str Returns the source code as a single string. .INDENT 7.0 .TP .B Parameters \fBindent\fP – source code indentation count by spaces .UNINDENT .UNINDENT .INDENT 7.0 .TP .B black_code_str(line_length=88) -> str Returns the source code as a single string formatted by \fI\%Black\fP .INDENT 7.0 .TP .B Parameters \fBline_length\fP – max. source code line length .TP .B Raises \fBImportError\fP – Black is not available .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_str(indent: int = 0) -> str Returns required imports as a single string. .INDENT 7.0 .TP .B Parameters \fBindent\fP – source code indentation count by spaces .UNINDENT .UNINDENT .INDENT 7.0 .TP .B merge(code: \fI\%Code\fP, indent: int = 0) -> None Add another \fI\%Code\fP object. .UNINDENT .INDENT 7.0 .TP .B add_import(statement: str) -> None Add import statement, identical import statements are merged together. .UNINDENT .INDENT 7.0 .TP .B add_line(code: str, indent: int = 0) -> None Add a single source code line without line ending \fB\en\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_lines(code: Iterable[str], indent: int = 0) -> None Add multiple source code lines without line ending \fB\en\fP\&. .UNINDENT .UNINDENT .SS iterdxf .sp This add\-on allows iterating over entities of the modelspace of really big (> 5GB) DXF files which do not fit into memory by only loading one entity at the time. Only ASCII DXF files are supported. .sp The entities are regular \fI\%DXFGraphic\fP objects with access to all supported DXF attributes, this entities can be written to new DXF files created by the \fI\%IterDXF.export()\fP method. The new \fI\%add_foreign_entity()\fP method allows also to add this entities to new regular \fIezdxf\fP drawings (except for the INSERT entity), but resources like linetype and style are removed, only layer will be preserved but only with default attributes like color \fB7\fP and linetype \fBCONTINUOUS\fP\&. .sp The following example shows how to split a big DXF files into several separated DXF files which contains only LINE, TEXT or POLYLINE entities. .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons import iterdxf doc = iterdxf.opendxf(\(aqbig.dxf\(aq) line_exporter = doc.export(\(aqline.dxf\(aq) text_exporter = doc.export(\(aqtext.dxf\(aq) polyline_exporter = doc.export(\(aqpolyline.dxf\(aq) try: for entity in doc.modelspace(): if entity.dxftype() == \(aqLINE\(aq: line_exporter.write(entity) elif entity.dxftype() == \(aqTEXT\(aq: text_exporter.write(entity) elif entity.dxftype() == \(aqPOLYLINE\(aq: polyline_exporter.write(entity) finally: line_exporter.close() text_exporter.close() polyline_exporter.close() doc.close() .EE .UNINDENT .UNINDENT .sp Supported DXF types: .sp 3DFACE, ARC, ATTDEF, ATTRIB, CIRCLE, DIMENSION, ELLIPSE, HATCH, HELIX, IMAGE, INSERT, LEADER, LINE, LWPOLYLINE, MESH, MLEADER, MLINE, MTEXT, POINT, POLYLINE, RAY, SHAPE, SOLID, SPLINE, TEXT, TRACE, VERTEX, WIPEOUT, XLINE .sp Transfer simple entities to another DXF document, this works for some supported entities, except for entities with strong dependencies to the original document like INSERT look at \fI\%add_foreign_entity()\fP for all supported types: .INDENT 0.0 .INDENT 3.5 .sp .EX newdoc = ezdxf.new() msp = newdoc.modelspace() # line is an entity from a big source file msp.add_foreign_entity(line) # and so on ... msp.add_foreign_entity(lwpolyline) msp.add_foreign_entity(mesh) msp.add_foreign_entity(polyface) .EE .UNINDENT .UNINDENT .sp Transfer MESH and POLYFACE (dxftype for POLYFACE and POLYMESH is POLYLINE!) entities into a new DXF document by the \fBMeshTransformer\fP class: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.render import MeshTransformer # mesh is MESH from a big source file t = MeshTransformer.from_mesh(mesh) # create a new MESH entity from MeshTransformer t.render(msp) # polyface is POLYFACE from a big source file t = MeshTransformer.from_polyface(polyface) # create a new POLYMESH entity from MeshTransformer t.render_polyface(msp) .EE .UNINDENT .UNINDENT .sp Another way to import entities from a big source file into new DXF documents is to split the big file into smaller parts and use the \fI\%Importer\fP add\-on for a more safe entity import. .INDENT 0.0 .TP .B ezdxf.addons.iterdxf.opendxf(filename: Path | str, errors: str = \(aqsurrogateescape\(aq) -> \fI\%IterDXF\fP Open DXF file for iterating, be sure to open valid DXF files, no DXF structure checks will be applied. .sp Use this function to split up big DXF files as shown in the example above. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – DXF filename of a seekable DXF file. .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFStructureError\fP – invalid or incomplete DXF file .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.iterdxf.modelspace(filename: Path | str, types: Iterable[str] | None = None, errors: str = \(aqsurrogateescape\(aq) -> Iterable[DXFGraphic] Iterate over all modelspace entities as \fBDXFGraphic\fP objects of a seekable file. .sp Use this function to iterate “quick” over modelspace entities of a DXF file, filtering DXF types may speed up things if many entity types will be skipped. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – filename of a seekable DXF file .IP \(bu 2 \fBtypes\fP – DXF types like \fB[\(aqLINE\(aq, \(aq3DFACE\(aq]\fP which should be returned, \fBNone\fP returns all supported types. .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFStructureError\fP – invalid or incomplete DXF file .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.iterdxf.single_pass_modelspace(stream: BinaryIO, types: Iterable[str] | None = None, errors: str = \(aqsurrogateescape\(aq) -> Iterable[DXFGraphic] Iterate over all modelspace entities as \fBDXFGraphic\fP objects in a single pass. .sp Use this function to ‘quick’ iterate over modelspace entities of a \fBnot\fP seekable binary DXF stream, filtering DXF types may speed up things if many entity types will be skipped. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstream\fP – (not seekable) binary DXF stream .IP \(bu 2 \fBtypes\fP – DXF types like \fB[\(aqLINE\(aq, \(aq3DFACE\(aq]\fP which should be returned, \fBNone\fP returns all supported types. .IP \(bu 2 \fBerrors\fP – .sp specify decoding error handler .INDENT 2.0 .IP \(bu 2 ”surrogateescape” to preserve possible binary data (default) .IP \(bu 2 ”ignore” to use the replacement char U+FFFD “�” for invalid data .IP \(bu 2 ”strict” to raise an \fBUnicodeDecodeError\fP exception for invalid data .UNINDENT .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFStructureError\fP – Invalid or incomplete DXF file .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.iterdxf.IterDXF .INDENT 7.0 .TP .B export(name: Path | str) -> \fI\%IterDXFWriter\fP Returns a companion object to export parts from the source DXF file into another DXF file, the new file will have the same HEADER, CLASSES, TABLES, BLOCKS and OBJECTS sections, which guarantees all necessary dependencies are present in the new file. .INDENT 7.0 .TP .B Parameters \fBname\fP – filename, no special requirements .UNINDENT .UNINDENT .INDENT 7.0 .TP .B modelspace(types: Iterable[str] | None = None) -> Iterable[DXFGraphic] Returns an iterator for all supported DXF entities in the modelspace. These entities are regular \fI\%DXFGraphic\fP objects but without a valid document assigned. It is \fBnot\fP possible to add these entities to other \fIezdxf\fP documents. .sp It is only possible to recreate the objects by factory functions base on attributes of the source entity. For MESH, POLYMESH and POLYFACE it is possible to use the \fI\%MeshTransformer\fP class to render (recreate) this objects as new entities in another document. .INDENT 7.0 .TP .B Parameters \fBtypes\fP – DXF types like \fB[\(aqLINE\(aq, \(aq3DFACE\(aq]\fP which should be returned, \fBNone\fP returns all supported types. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B close() Safe closing source DXF file. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.iterdxf.IterDXFWriter .INDENT 7.0 .TP .B write(entity: DXFGraphic) Write a DXF entity from the source DXF file to the export file. .sp Don’t write entities from different documents than the source DXF file, dependencies and resources will not match, maybe it will work once, but not in a reliable way for different DXF documents. .UNINDENT .INDENT 7.0 .TP .B close() Safe closing of exported DXF file. Copying of OBJECTS section happens only at closing the file, without closing the new DXF file is invalid. .UNINDENT .UNINDENT .SS ODA File Converter Support .sp Use an installed \fI\%ODA File Converter\fP for converting between different versions of \fI\&.dwg\fP, \fI\&.dxb\fP and \fI\&.dxf\fP\&. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Execution of an external application is a big security issue! Especially when the path to the executable can be altered. .sp To avoid this problem delete the \fBezdxf.addons.odafc.py\fP module. .UNINDENT .UNINDENT .SS Install ODA File Converter .sp The \fI\%ODA File Converter\fP has to be installed by the user, the application is available for Windows XP, Windows 7 or later, Mac OS X, and Linux in 32/64\-bit RPM and DEB format. .SS AppImage Support .sp The option “unix_exec_path” defines an executable for Linux and macOS, this executable overrides the default command \fBODAFileConverter\fP\&. Assign an \fBabsolute\fP path to the executable to that key and if the executable is not found the add\-on falls back to the \fBODAFileConverter\fP command. .sp The option “unix_exec_path” also adds support for AppImages provided by the Open Design Alliance. Download the AppImage file and store it in a folder of your choice (e.g. \fB~/Apps\fP) and make the file executable: .INDENT 0.0 .INDENT 3.5 .sp .EX chmod a+x ~/Apps/ODAFileConverter_QT5_lnxX64_8.3dll_23.9.AppImage .EE .UNINDENT .UNINDENT .sp Add the \fBabsolute\fP path as config option “unix_exec_path” to the “odafc\-addon” section: .INDENT 0.0 .INDENT 3.5 .sp .EX [odafc\-addon] win_exec_path = \(dqC:\eProgram Files\eODA\eODAFileConverter\eODAFileConverter.exe\(dq unix_exec_path = \(dq/home//Apps/ODAFileConverter_QT5_lnxX64_8.3dll_23.9.AppImage\(dq .EE .UNINDENT .UNINDENT .sp This overrides the default command \fBODAFileConverter\fP and if the executable is not found the add\-on falls back to the \fBODAFileConverter\fP command. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For more information about config files see section: \fI\%Global Options Object\fP .UNINDENT .UNINDENT .SS Suppressed GUI .sp On Windows the GUI of the ODA File Converter is suppressed, on Linux you may have to install the \fBxvfb\fP package to prevent this, for macOS is no solution known. .SS Supported DXF and DWG Versions .sp ODA File Converter version strings, you can use any of this strings to specify a version, \fB\(aqR..\(aq\fP and \fB\(aqAC....\(aq\fP strings will be automatically mapped to \fB\(aqACAD....\(aq\fP strings: .TS center; |l|l|l|. _ T{ ODAFC T} T{ ezdxf T} T{ Version T} _ T{ ACAD9 T} T{ not supported T} T{ AC1004 T} _ T{ ACAD10 T} T{ not supported T} T{ AC1006 T} _ T{ ACAD12 T} T{ R12 T} T{ AC1009 T} _ T{ ACAD13 T} T{ R13 T} T{ AC1012 T} _ T{ ACAD14 T} T{ R14 T} T{ AC1014 T} _ T{ ACAD2000 T} T{ R2000 T} T{ AC1015 T} _ T{ ACAD2004 T} T{ R2004 T} T{ AC1018 T} _ T{ ACAD2007 T} T{ R2007 T} T{ AC1021 T} _ T{ ACAD2010 T} T{ R2010 T} T{ AC1024 T} _ T{ ACAD2013 T} T{ R2013 T} T{ AC1027 T} _ T{ ACAD2018 T} T{ R2018 T} T{ AC1032 T} _ .TE .SS Config .sp On Windows the path to the \fBODAFileConverter.exe\fP executable is stored in the config file (see \fI\%ezdxf.options\fP) in the “odafc\-addon” section as key “win_exec_path”, the default entry is: .INDENT 0.0 .INDENT 3.5 .sp .EX [odafc\-addon] win_exec_path = \(dqC:\eProgram Files\eODA\eODAFileConverter\eODAFileConverter.exe\(dq unix_exec_path = .EE .UNINDENT .UNINDENT .sp On Linux and macOS the \fBODAFileConverter\fP command is located by the \fBshutil.which()\fP function but can be overridden since version 1.0 by the key “linux_exec_path”. .SS Usage .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons import odafc # Load a DWG file doc = odafc.readfile(\(aqmy.dwg\(aq) # Use loaded document like any other ezdxf document print(f\(aqDocument loaded as DXF version: {doc.dxfversion}.\(aq) msp = doc.modelspace() \&... # Export document as DWG file for AutoCAD R2018 odafc.export_dwg(doc, \(aqmy_R2018.dwg\(aq, version=\(aqR2018\(aq) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.win_exec_path Path to installed \fIODA File Converter\fP executable on Windows systems, default is \fB\(dqC:\eProgram Files\eODA\eODAFileConverter\eODAFileConverter.exe\(dq\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.unix_exec_path Absolute path to a Linux or macOS executable if set, otherwise an empty string and the default command \fBODAFileConverter\fP is used. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.is_installed() -> bool Returns \fBTrue\fP if the ODAFileConverter is installed. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.readfile(filename: str | PathLike, version: str | None = None, *, audit: bool = False) -> \fI\%Drawing\fP | None Uses an installed \fI\%ODA File Converter\fP to convert a DWG/DXB/DXF file into a temporary DXF file and load this file by \fIezdxf\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – file to load by ODA File Converter .IP \(bu 2 \fBversion\fP – load file as specific DXF version, by default the same version as the source file or if not detectable the latest by \fIezdxf\fP supported version. .IP \(bu 2 \fBaudit\fP – audit source file before loading .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBFileNotFoundError\fP – source file not found .IP \(bu 2 \fBodafc.UnknownODAFCError\fP – conversion failed for unknown reasons .IP \(bu 2 \fBodafc.UnsupportedVersion\fP – invalid DWG version specified .IP \(bu 2 \fBodafc.UnsupportedFileFormat\fP – unsupported file extension .IP \(bu 2 \fBodafc.ODAFCNotInstalledError\fP – ODA File Converter not installed .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.export_dwg(doc: \fI\%Drawing\fP, filename: str | PathLike, version: str | None = None, *, audit: bool = False, replace: bool = False) -> None Uses an installed \fI\%ODA File Converter\fP to export the DXF document \fIdoc\fP as a DWG file. .sp A temporary DXF file will be created and converted to DWG by the ODA File Converter. If \fIversion\fP is not specified the DXF version of the source document is used. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdoc\fP – \fIezdxf\fP DXF document as \fBDrawing\fP object .IP \(bu 2 \fBfilename\fP – output DWG filename, the extension will be set to “.dwg” .IP \(bu 2 \fBversion\fP – DWG version to export, by default the same version as the source document. .IP \(bu 2 \fBaudit\fP – audit source file by ODA File Converter at exporting .IP \(bu 2 \fBreplace\fP – replace existing DWG file if \fBTrue\fP .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBFileExistsError\fP – target file already exists, and argument \fIreplace\fP is \fBFalse\fP .IP \(bu 2 \fBFileNotFoundError\fP – parent directory of target file does not exist .IP \(bu 2 \fBodafc.UnknownODAFCError\fP – exporting DWG failed for unknown reasons .IP \(bu 2 \fBodafc.ODAFCNotInstalledError\fP – ODA File Converter not installed .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.convert(source: str | PathLike, dest: str | PathLike = \(aq\(aq, *, version=\(aqR2018\(aq, audit=True, replace=False) Convert \fIsource\fP file to \fIdest\fP file. .sp The file extension defines the target format e.g. \fBconvert(\(dqtest.dxf\(dq, \(dqTest.dwg\(dq)\fP converts the source file to a DWG file. If \fIdest\fP is an empty string the conversion depends on the source file format and is DXF to DWG or DWG to DXF. To convert DXF to DXF an explicit destination filename is required: \fBconvert(\(dqr12.dxf\(dq, \(dqr2013.dxf\(dq, version=\(dqR2013\(dq)\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsource\fP – source file .IP \(bu 2 \fBdest\fP – destination file, an empty string uses the source filename with the extension of the target format e.g. “test.dxf” \-> “test.dwg” .IP \(bu 2 \fBversion\fP – output DXF/DWG version e.g. “ACAD2018”, “R2018”, “AC1032” .IP \(bu 2 \fBaudit\fP – audit files .IP \(bu 2 \fBreplace\fP – replace existing destination file .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBFileNotFoundError\fP – source file or destination folder does not exist .IP \(bu 2 \fBFileExistsError\fP – destination file already exists and argument \fIreplace\fP is \fBFalse\fP .IP \(bu 2 \fBodafc.UnsupportedVersion\fP – invalid DXF version specified .IP \(bu 2 \fBodafc.UnsupportedFileFormat\fP – unsupported file extension .IP \(bu 2 \fBodafc.UnknownODAFCError\fP – conversion failed for unknown reasons .IP \(bu 2 \fBodafc.ODAFCNotInstalledError\fP – ODA File Converter not installed .UNINDENT .UNINDENT .UNINDENT .SS R12 Export .sp New in version 1.1. .sp This module exports any DXF file as a simple DXF R12 file. Many complex entities will be converted into DXF primitives. This exporter is intended for creating a simple file format as an input format for other software such as laser cutters. In order to get a file that can be edited well in a CAD application, the results of the ODA file converter are much better. .SS Usage .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons import r12export doc = ezdxf.readfile(\(dqany.dxf\(dq) r12export.saveas(doc, \(dqr12.dxf\(dq) .EE .UNINDENT .UNINDENT .SS Converted Entity Types .TS center; |l|l|. _ T{ LWPOLYLINE T} T{ translated to POLYLINE T} _ T{ MESH T} T{ translated to POLYLINE (PolyfaceMesh) T} _ T{ SPLINE T} T{ flattened to POLYLINE T} _ T{ ELLIPSE T} T{ flattened to POLYLINE T} _ T{ MTEXT T} T{ exploded into DXF primitives T} _ T{ LEADER T} T{ exploded into DXF primitives T} _ T{ MLEADER T} T{ exploded into DXF primitives T} _ T{ MULTILEADER T} T{ exploded into DXF primitives T} _ T{ MLINE T} T{ exploded into DXF primitives T} _ T{ HATCH T} T{ exploded into DXF primitives T} _ T{ MPOLYGON T} T{ exploded into DXF primitives T} _ T{ ACAD_TABLE T} T{ export of pre\-rendered BLOCK content T} _ .TE .sp For proxy\- or unknown entities the available proxy graphic will be exported as DXF primitives. .SS Limitations .INDENT 0.0 .IP \(bu 2 Explosion of MTEXT into DXF primitives is not perfect .IP \(bu 2 Pattern rendering for complex HATCH entities has issues .IP \(bu 2 Solid fill rendering for complex HATCH entities has issues .UNINDENT .SS ODA File Converter .sp The advantage of the \fI\%r12export\fP module is that the ODA file converter isn’t needed, but the ODA file converter will produce a much better result: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons import odafc odafc.convert(\(dqany.dxf\(dq, \(dqr12.dxf\(dq, version=\(dqR12\(dq) .EE .UNINDENT .UNINDENT .SS Functions .TS center; |l|l|. _ T{ \fI\%write\fP T} T{ Write a DXF document as DXF version R12 to a text stream. T} _ T{ \fI\%saveas\fP T} T{ Write a DXF document as DXF version R12 to a file. T} _ T{ \fI\%convert\fP T} T{ Export and reload DXF document as DXF version R12. T} _ .TE .INDENT 0.0 .TP .B ezdxf.addons.r12export.write(doc: \fI\%Drawing\fP, stream: TextIO, *, max_sagitta: float = MAX_SAGITTA) -> None Write a DXF document as DXF version R12 to a text stream. The \fImax_sagitta\fP argument determines the accuracy of the curve flatting for SPLINE and ELLIPSE entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdoc\fP – DXF document to export .IP \(bu 2 \fBstream\fP – output stream, use \fBdoc.encoding\fP as encoding .IP \(bu 2 \fBmax_sagitta\fP – maximum distance from the center of the curve to the center of the line segment between two approximation points to determine if a segment should be subdivided. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.r12export.saveas(doc: \fI\%Drawing\fP, filepath: str | PathLike, *, max_sagitta: float = MAX_SAGITTA) -> None Write a DXF document as DXF version R12 to a file. The \fImax_sagitta\fP argument determines the accuracy of the curve flatting for SPLINE and ELLIPSE entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdoc\fP – DXF document to export .IP \(bu 2 \fBfilepath\fP – output filename .IP \(bu 2 \fBmax_sagitta\fP – maximum distance from the center of the curve to the center of the line segment between two approximation points to determine if a segment should be subdivided. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.r12export.convert(doc: \fI\%Drawing\fP, *, max_sagitta: float = MAX_SAGITTA) -> \fI\%Drawing\fP Export and reload DXF document as DXF version R12. .sp Writes the DXF document into a temporary file at the file\-system and reloads this file by the \fI\%ezdxf.readfile()\fP function. .UNINDENT .SS r12writer .sp The fast file/stream writer creates simple DXF R12 drawings with just an ENTITIES section. The HEADER, TABLES and BLOCKS sections are not present except FIXED\-TABLES are written. Only LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE and POLYLINE entities are supported. FIXED\-TABLES is a predefined TABLES section, which will be written, if the init argument \fIfixed_tables\fP of \fI\%R12FastStreamWriter\fP is \fBTrue\fP\&. .sp The \fI\%R12FastStreamWriter\fP writes the DXF entities as strings direct to the stream without creating an in\-memory drawing and therefore the processing is very fast. .sp Because of the lack of a BLOCKS section, BLOCK/INSERT can not be used. Layers can be used, but this layers have a default setting color = \fB7\fP (black/white) and linetype = \fB\(aqContinuous\(aq\fP\&. If writing the FIXED\-TABLES, some predefined text styles and line types are available, else text style is always \fB\(aqSTANDARD\(aq\fP and line type is always \fB\(aqByLayer\(aq\fP\&. .sp If using FIXED\-TABLES, following predefined line types are available: .INDENT 0.0 .IP \(bu 2 CONTINUOUS .IP \(bu 2 CENTER \fB____ _ ____ _ ____ _ ____ _ ____ _ ____\fP .IP \(bu 2 CENTERX2 \fB________ __ ________ __ ________\fP .IP \(bu 2 CENTER2 \fB____ _ ____ _ ____ _ ____ _ ____\fP .IP \(bu 2 DASHED \fB__ __ __ __ __ __ __ __ __ __ __ __ __ _\fP .IP \(bu 2 DASHEDX2 \fB____ ____ ____ ____ ____ ____\fP .IP \(bu 2 DASHED2 \fB_ _ _ _ _ _ _ _ _ _ _ _ _ _\fP .IP \(bu 2 PHANTOM \fB______ __ __ ______ __ __ ______\fP .IP \(bu 2 PHANTOMX2 \fB____________ ____ ____ ____________\fP .IP \(bu 2 PHANTOM2 \fB___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\fP .IP \(bu 2 DASHDOT \fB__ . __ . __ . __ . __ . __ . __ . __\fP .IP \(bu 2 DASHDOTX2 \fB____ . ____ . ____ . ____\fP .IP \(bu 2 DASHDOT2 \fB_ . _ . _ . _ . _ . _ . _ . _\fP .IP \(bu 2 DOT \fB\&. . . . . . . . . . . . . . . .\fP .IP \(bu 2 DOTX2 \fB\&. . . . . . . .\fP .IP \(bu 2 DOT2 \fB\&. . . . . . . . . . . . . . . . . . .\fP .IP \(bu 2 DIVIDE \fB__ . . __ . . __ . . __ . . __ . . __\fP .IP \(bu 2 DIVIDEX2 \fB____ . . ____ . . ____ . . ____\fP .IP \(bu 2 DIVIDE2 \fB_ . _ . _ . _ . _ . _ . _ . _\fP .UNINDENT .sp If using FIXED\-TABLES, following predefined text styles are available: .INDENT 0.0 .IP \(bu 2 OpenSans .IP \(bu 2 OpenSansCondensed\-Light .UNINDENT .SS Tutorial .sp A simple example with different DXF entities: .INDENT 0.0 .INDENT 3.5 .sp .EX from random import random from ezdxf.addons import r12writer with r12writer(\(dqquick_and_dirty_dxf_r12.dxf\(dq) as dxf: dxf.add_line((0, 0), (17, 23)) dxf.add_circle((0, 0), radius=2) dxf.add_arc((0, 0), radius=3, start=0, end=175) dxf.add_solid([(0, 0), (1, 0), (0, 1), (1, 1)]) dxf.add_point((1.5, 1.5)) # 2d polyline, new in v0.12 dxf.add_polyline_2d([(5, 5), (7, 3), (7, 6)]) # 2d polyline with bulge value, new in v0.12 dxf.add_polyline_2d([(5, 5), (7, 3, 0.5), (7, 6)], format=\(aqxyb\(aq) # 3d polyline only, changed in v0.12 dxf.add_polyline([(4, 3, 2), (8, 5, 0), (2, 4, 9)]) dxf.add_text(\(dqtest the text entity\(dq, align=\(dqMIDDLE_CENTER\(dq) .EE .UNINDENT .UNINDENT .sp A simple example of writing really many entities in a short time: .INDENT 0.0 .INDENT 3.5 .sp .EX from random import random from ezdxf.addons import r12writer MAX_X_COORD = 1000.0 MAX_Y_COORD = 1000.0 CIRCLE_COUNT = 1000000 with r12writer(\(dqmany_circles.dxf\(dq) as dxf: for i in range(CIRCLE_COUNT): dxf.add_circle((MAX_X_COORD*random(), MAX_Y_COORD*random()), radius=2) .EE .UNINDENT .UNINDENT .sp Show all available line types: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf LINETYPES = [ \(aqCONTINUOUS\(aq, \(aqCENTER\(aq, \(aqCENTERX2\(aq, \(aqCENTER2\(aq, \(aqDASHED\(aq, \(aqDASHEDX2\(aq, \(aqDASHED2\(aq, \(aqPHANTOM\(aq, \(aqPHANTOMX2\(aq, \(aqPHANTOM2\(aq, \(aqDASHDOT\(aq, \(aqDASHDOTX2\(aq, \(aqDASHDOT2\(aq, \(aqDOT\(aq, \(aqDOTX2\(aq, \(aqDOT2\(aq, \(aqDIVIDE\(aq, \(aqDIVIDEX2\(aq, \(aqDIVIDE2\(aq, ] with r12writer(\(aqr12_linetypes.dxf\(aq, fixed_tables=True) as dxf: for n, ltype in enumerate(LINETYPES): dxf.add_line((0, n), (10, n), linetype=ltype) dxf.add_text(ltype, (0, n+0.1), height=0.25, style=\(aqOpenSansCondensed\-Light\(aq) .EE .UNINDENT .UNINDENT .SS Reference .INDENT 0.0 .TP .B ezdxf.addons.r12writer.r12writer(stream: TextIO | BinaryIO | str, fixed_tables=False, fmt=\(aqasc\(aq) -> \fI\%R12FastStreamWriter\fP Context manager for writing DXF entities to a stream/file. \fIstream\fP can be any file like object with a \fBwrite()\fP method or just a string for writing DXF entities to the file system. If \fIfixed_tables\fP is \fBTrue\fP, a standard TABLES section is written in front of the ENTITIES section and some predefined text styles and line types can be used. .sp Set argument \fIfmt\fP to “asc” to write ASCII DXF file (default) or “bin” to write Binary DXF files. ASCII DXF require a \fBTextIO\fP stream and Binary DXF require a \fBBinaryIO\fP stream. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.r12writer.R12FastStreamWriter(stream: TextIO, fixed_tables=False) Fast stream writer to create simple DXF R12 drawings. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstream\fP – a file like object with a \fBwrite()\fP method. .IP \(bu 2 \fBfixed_tables\fP – if \fIfixed_tables\fP is \fBTrue\fP, a standard TABLES section is written in front of the ENTITIES section and some predefined text styles and line types can be used. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B close() -> None Writes the DXF tail. Call is not necessary when using the context manager \fI\%r12writer()\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_line(start: Sequence[float], end: Sequence[float], layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a LINE entity from \fIstart\fP to \fIend\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart\fP – start vertex as \fB(x, y[, z])\fP tuple .IP \(bu 2 \fBend\fP – end vertex as as \fB(x, y[, z])\fP tuple .IP \(bu 2 \fBlayer\fP – layer name as string, without a layer definition the assigned color = \fB7\fP (black/white) and line type is \fB\(aqContinuous\(aq\fP\&. .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP in the range from \fB0\fP to \fB256\fP, \fB0\fP is \fIByBlock\fP and \fB256\fP is \fIByLayer\fP, default is \fIByLayer\fP which is always color = \fB7\fP (black/white) without a layer definition. .IP \(bu 2 \fBlinetype\fP – line type as string, if FIXED\-TABLES are written some predefined line types are available, else line type is always \fIByLayer\fP, which is always \fB\(aqContinuous\(aq\fP without a LAYERS table. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_circle(center: Sequence[float], radius: float, layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a CIRCLE entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – circle center point as \fB(x, y)\fP tuple .IP \(bu 2 \fBradius\fP – circle radius as float .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_arc(center: Sequence[float], radius: float, start: float = 0, end: float = 360, layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add an ARC entity. The arc goes counter\-clockwise from \fIstart\fP angle to \fIend\fP angle. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – arc center point as \fB(x, y)\fP tuple .IP \(bu 2 \fBradius\fP – arc radius as float .IP \(bu 2 \fBstart\fP – arc start angle in degrees as float .IP \(bu 2 \fBend\fP – arc end angle in degrees as float .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_point(location: Sequence[float], layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a POINT entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlocation\fP – point location as \fB(x, y [,z])\fP tuple .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_3dface(vertices: Iterable[Sequence[float]], invisible: int = 0, layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a 3DFACE entity. 3DFACE is a spatial area with 3 or 4 vertices, all vertices have to be in the same plane. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – iterable of 3 or 4 \fB(x, y, z)\fP vertices. .IP \(bu 2 \fBinvisible\fP – .sp bit coded flag to define the invisible edges, .INDENT 2.0 .IP 1. 3 edge = 1 .IP 2. 3 edge = 2 .IP 3. 3 edge = 4 .IP 4. 3 edge = 8 .UNINDENT .sp Add edge values to set multiple edges invisible, 1. edge + 3. edge = 1 + 4 = 5, all edges = 15 .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_solid(vertices: Iterable[Sequence[float]], layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a SOLID entity. SOLID is a solid filled area with 3 or 4 edges and SOLID is a 2D entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – iterable of 3 or 4 \fB(x, y[, z])\fP tuples, z\-axis will be ignored. .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polyline_2d(points: Iterable[Sequence], format: str = \(aqxy\(aq, closed: bool = False, start_width: float = 0, end_width: float = 0, layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a 2D POLYLINE entity with start width, end width and bulge value support. .sp Format codes: .TS center; |l|l|. _ T{ x T} T{ x\-coordinate T} _ T{ y T} T{ y\-coordinate T} _ T{ s T} T{ start width T} _ T{ e T} T{ end width T} _ T{ b T} T{ bulge value T} _ T{ v T} T{ (x, y) tuple (z\-axis is ignored) T} _ .TE .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of (x, y, [start_width, [end_width, [bulge]]]) tuple, value order according to the \fIformat\fP string, unset values default to \fB0\fP .IP \(bu 2 \fBformat\fP – format: format string, default is \fB\(aqxy\(aq\fP .IP \(bu 2 \fBclosed\fP – \fBTrue\fP creates a closed polyline .IP \(bu 2 \fBstart_width\fP – default start width, default is \fB0\fP .IP \(bu 2 \fBend_width\fP – default end width, default is \fB0\fP .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polyline(vertices: Iterable[Sequence[float]], closed: bool = False, layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a 3D POLYLINE entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – iterable of \fB(x, y[, z])\fP tuples, z\-axis is \fB0\fP by default .IP \(bu 2 \fBclosed\fP – \fBTrue\fP creates a closed polyline .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polyface(vertices: Iterable[Sequence[float]], faces: Iterable[Sequence[int]], layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a POLYFACE entity. The POLYFACE entity supports only faces of maximum 4 vertices, more indices will be ignored. A simple square would be: .INDENT 7.0 .INDENT 3.5 .sp .EX v0 = (0, 0, 0) v1 = (1, 0, 0) v2 = (1, 1, 0) v3 = (0, 1, 0) dxf.add_polyface(vertices=[v0, v1, v2, v3], faces=[(0, 1, 2, 3)]) .EE .UNINDENT .UNINDENT .sp All 3D form functions of the \fI\%ezdxf.render.forms\fP module return \fI\%MeshBuilder\fP objects, which provide the required vertex and face lists. .sp See sphere example: \fI\%https://github.com/mozman/ezdxf/blob/master/examples/r12writer.py\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – iterable of \fB(x, y, z)\fP tuples .IP \(bu 2 \fBfaces\fP – iterable of 3 or 4 vertex indices, indices have to be 0\-based .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polymesh(vertices: Iterable[Sequence[float]], size: tuple[int, int], closed=(False, False), layer: str = \(aq0\(aq, color: int | None = None, linetype: str | None = None) -> None Add a POLYMESH entity. A POLYMESH is a mesh of m rows and n columns, each mesh vertex has its own x\-, y\- and z coordinates. The mesh can be closed in m\- and/or n\-direction. The vertices have to be in column order: (m0, n0), (m0, n1), (m0, n2), (m1, n0), (m1, n1), (m1, n2), … .sp See example: \fI\%https://github.com/mozman/ezdxf/blob/master/examples/r12writer.py\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBvertices\fP – iterable of \fB(x, y, z)\fP tuples, in column order .IP \(bu 2 \fBsize\fP – mesh dimension as (m, n)\-tuple, requirement: \fBlen(vertices) == m*n\fP .IP \(bu 2 \fBclosed\fP – (m_closed, n_closed) tuple, for closed mesh in m and/or n direction .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_text(text: str, insert: Sequence[float] = (0, 0), height: float = 1.0, width: float = 1.0, align: str = \(aqLEFT\(aq, rotation: float = 0.0, oblique: float = 0.0, style: str = \(aqSTANDARD\(aq, layer: str = \(aq0\(aq, color: int | None = None) -> None Add a one line TEXT entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – the text as string .IP \(bu 2 \fBinsert\fP – insert location as \fB(x, y)\fP tuple .IP \(bu 2 \fBheight\fP – text height in drawing units .IP \(bu 2 \fBwidth\fP – text width as factor .IP \(bu 2 \fBalign\fP – text alignment, see table below .IP \(bu 2 \fBrotation\fP – text rotation in degrees as float .IP \(bu 2 \fBoblique\fP – oblique in degrees as float, vertical = \fB0\fP (default) .IP \(bu 2 \fBstyle\fP – text style name as string, if FIXED\-TABLES are written some predefined text styles are available, else text style is always \fB\(aqSTANDARD\(aq\fP\&. .IP \(bu 2 \fBlayer\fP – layer name as string see \fI\%add_line()\fP .IP \(bu 2 \fBcolor\fP – color as \fI\%AutoCAD Color Index (ACI)\fP see \fI\%add_line()\fP .UNINDENT .UNINDENT .TS center; |l|l|l|l|. _ T{ Vert/Horiz T} T{ Left T} T{ Center T} T{ Right T} _ T{ Top T} T{ \fBTOP_LEFT\fP T} T{ \fBTOP_CENTER\fP T} T{ \fBTOP_RIGHT\fP T} _ T{ Middle T} T{ \fBMIDDLE_LEFT\fP T} T{ \fBMIDDLE_CENTER\fP T} T{ \fBMIDDLE_RIGHT\fP T} _ T{ Bottom T} T{ \fBBOTTOM_LEFT\fP T} T{ \fBBOTTOM_CENTER\fP T} T{ \fBBOTTOM_RIGHT\fP T} _ T{ Baseline T} T{ \fBLEFT\fP T} T{ \fBCENTER\fP T} T{ \fBRIGHT\fP T} _ .TE .sp The special alignments \fBALIGNED\fP and \fBFIT\fP are not available. .UNINDENT .UNINDENT .SS text2path .sp Tools to convert text strings and text based DXF entities into outer\- and inner linear paths as \fI\%Path\fP objects. At the moment only the TEXT and the ATTRIB entity can be converted into paths and hatches. .sp New in version 1.1: Text rendering is done by the \fI\%fontTools\fP package, which is a hard dependency of \fIezdxf\fP\&. Support for stroke fonts, these are the basic vector fonts included in CAD applications, like .shx, .shp or .lff fonts was added but these fonts cannot be rendered as HATCH entities. .sp The required font files are not included with \fIezdxf\fP as they are copyrighted or, in the case of the LibreCAD font format, licensed under the “GPL v2 and later”. Set the paths to such stroke fonts in the config file, see option \fI\%ezdxf.options.support_dirs\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX [core] support_dirs = \(dqC:\eProgram Files\eBricsys\eBricsCAD V23 en_US\eFonts\(dq, ~/shx_fonts, ~/shp_fonts, ~/lff_fonts, .EE .UNINDENT .UNINDENT .sp Don’t expect a 100% match compared to CAD applications but the results with \fIfontTools\fP are better than the previous \fIMatplotlib\fP renderings. .SS Text Alignments .sp The text alignments are enums of type \fI\%ezdxf.enums.TextEntityAlignment\fP .TS center; |l|l|l|l|. _ T{ Vertical T} T{ Left T} T{ Center T} T{ Right T} _ T{ Top T} T{ TOP_LEFT T} T{ TOP_CENTER T} T{ TOP_RIGHT T} _ T{ Middle T} T{ MIDDLE_LEFT T} T{ MIDDLE_CENTER T} T{ MIDDLE_RIGHT T} _ T{ Bottom T} T{ BOTTOM_LEFT T} T{ BOTTOM_CENTER T} T{ BOTTOM_RIGHT T} _ T{ Baseline T} T{ LEFT T} T{ CENTER T} T{ RIGHT T} _ .TE .sp The vertical middle alignments (MIDDLE_XXX), center the text vertically in the middle of the uppercase letter “X” (cap height). .sp Special alignments, where the horizontal alignment is always in the center of the text: .INDENT 0.0 .IP \(bu 2 ALIGNED: text is scaled to match the given \fIlength\fP, scales x\- and y\-direction by the same factor. .IP \(bu 2 FIT: text is scaled to match the given \fIlength\fP, but scales only in x\-direction. .IP \(bu 2 MIDDLE: insertion point is the center of the total height (cap height + descender height) without scaling, the \fIlength\fP argument is ignored. .UNINDENT .SS Font Face Definition .sp A font face is defined by the Matplotlib compatible \fBFontFace\fP object by \fBfont\-family\fP, \fBfont\-style\fP, \fBfont\-stretch\fP and \fBfont\-weight\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Font Anatomy\fP .IP \(bu 2 \fI\%Font Properties\fP .UNINDENT .UNINDENT .UNINDENT .SS String Functions .INDENT 0.0 .TP .B ezdxf.addons.text2path.make_path_from_str(s: str, font: \fI\%FontFace\fP, size: float = 1.0, align=TextEntityAlignment.LEFT, length: float = 0, m: \fI\%Matrix44\fP = None) -> Path Convert a single line string \fIs\fP into a \fI\%Multi\-Path\fP object. The text \fIsize\fP is the height of the uppercase letter “X” (cap height). The paths are aligned about the insertion point at (0, 0). BASELINE means the bottom of the letter “X”. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBs\fP – text to convert .IP \(bu 2 \fBfont\fP – font face definition as \fBFontFace\fP object .IP \(bu 2 \fBsize\fP – text size (cap height) in drawing units .IP \(bu 2 \fBalign\fP – alignment as \fI\%ezdxf.enums.TextEntityAlignment\fP, default is \fBLEFT\fP .IP \(bu 2 \fBlength\fP – target length for the \fBALIGNED\fP and \fBFIT\fP alignments .IP \(bu 2 \fBm\fP – transformation \fI\%Matrix44\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.text2path.make_paths_from_str(s: str, font: \fI\%FontFace\fP, size: float = 1.0, align=TextEntityAlignment.LEFT, length: float = 0, m: \fI\%Matrix44\fP = None) -> list[Path] Convert a single line string \fIs\fP into a list of \fI\%Path\fP objects. All paths are returned as a list of \fI\%Single\-Path\fP objects. The text \fIsize\fP is the height of the uppercase letter “X” (cap height). The paths are aligned about the insertion point at (0, 0). BASELINE means the bottom of the letter “X”. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBs\fP – text to convert .IP \(bu 2 \fBfont\fP – font face definition as \fBFontFace\fP object .IP \(bu 2 \fBsize\fP – text size (cap height) in drawing units .IP \(bu 2 \fBalign\fP – alignment as \fI\%ezdxf.enums.TextEntityAlignment\fP, default is \fBLEFT\fP .IP \(bu 2 \fBlength\fP – target length for the \fBALIGNED\fP and \fBFIT\fP alignments .IP \(bu 2 \fBm\fP – transformation \fI\%Matrix44\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.text2path.make_hatches_from_str(s: str, font: \fI\%FontFace\fP, size: float = 1.0, align=TextEntityAlignment.LEFT, length: float = 0, dxfattribs=None, m: \fI\%Matrix44\fP = None) -> list[Hatch] Convert a single line string \fIs\fP into a list of virtual \fI\%Hatch\fP entities. The text \fIsize\fP is the height of the uppercase letter “X” (cap height). The paths are aligned about the insertion point at (0, 0). The HATCH entities are aligned to this insertion point. BASELINE means the bottom of the letter “X”. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 Returns an empty list for .shx, .shp and .lff fonts a.k.a. stroke fonts. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBs\fP – text to convert .IP \(bu 2 \fBfont\fP – font face definition as \fBFontFace\fP object .IP \(bu 2 \fBsize\fP – text size (cap height) in drawing units .IP \(bu 2 \fBalign\fP – alignment as \fI\%ezdxf.enums.TextEntityAlignment\fP, default is \fBLEFT\fP .IP \(bu 2 \fBlength\fP – target length for the \fBALIGNED\fP and \fBFIT\fP alignments .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .IP \(bu 2 \fBm\fP – transformation \fI\%Matrix44\fP .UNINDENT .UNINDENT .UNINDENT .SS Entity Functions .INDENT 0.0 .TP .B class ezdxf.addons.text2path.Kind(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) The \fI\%Kind\fP enum defines the DXF types to create as bit flags, e.g. 1+2 to get HATCHES as filling and SPLINES and POLYLINES as outline: .TS center; |l|l|l|. _ T{ Int T} T{ Enum T} T{ Description T} _ T{ 1 T} T{ HATCHES T} T{ \fI\%Hatch\fP entities as filling T} _ T{ 2 T} T{ SPLINES T} T{ \fI\%Spline\fP and 3D \fI\%Polyline\fP entities as outline T} _ T{ 4 T} T{ LWPOLYLINES T} T{ \fI\%LWPolyline\fP entities as approximated (flattened) outline T} _ .TE .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.text2path.virtual_entities(entity: Text | Attrib, kind: int = Kind.HATCHES) -> \fI\%EntityQuery\fP Convert the text content of DXF entities TEXT and ATTRIB into virtual SPLINE and 3D POLYLINE entities or approximated LWPOLYLINE entities as outlines, or as HATCH entities as fillings. .sp Returns the virtual DXF entities as an \fI\%EntityQuery\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP – TEXT or ATTRIB entity .IP \(bu 2 \fBkind\fP – kind of entities to create as bit flags, see enum \fI\%Kind\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.text2path.explode(entity: Text | Attrib, kind: int = Kind.HATCHES, target=None) -> \fI\%EntityQuery\fP Explode the text \fIentity\fP into virtual entities, see \fI\%virtual_entities()\fP\&. The source entity will be destroyed. .sp The target layout is given by the \fItarget\fP argument, if \fItarget\fP is \fBNone\fP, the target layout is the source layout of the text entity. .sp Returns the created DXF entities as an \fI\%EntityQuery\fP object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBentity\fP – TEXT or ATTRIB entity to explode .IP \(bu 2 \fBkind\fP – kind of entities to create as bit flags, see enum \fI\%Kind\fP .IP \(bu 2 \fBtarget\fP – target layout for new created DXF entities, \fBNone\fP for the same layout as the source entity. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.text2path.make_path_from_entity(entity: Text | Attrib) -> Path Convert text content from DXF entities TEXT and ATTRIB into a \fI\%Multi\-Path\fP object. The paths are located at the location of the source entity. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.text2path.make_paths_from_entity(entity: Text | Attrib) -> list[Path] Convert text content from DXF entities TEXT and ATTRIB into a list of \fI\%Path\fP objects. All paths are returned as a list of \fI\%Single\-Path\fP objects. The paths are located at the location of the source entity. .UNINDENT .SS MTextExplode .sp This tool is meant to explode MTEXT entities into single line TEXT entities by replicating the MTEXT layout as close as possible. This tool requires the optional Matplotlib package to create usable results, nonetheless it also works without Matplotlib, but then uses a mono\-spaced replacement font for text size measuring which leads to very inaccurate results. .sp The supported MTEXT features are: .INDENT 0.0 .IP \(bu 2 changing text color .IP \(bu 2 text strokes: underline, overline and strike through .IP \(bu 2 changing text size, width and oblique .IP \(bu 2 changing font faces .IP \(bu 2 stacked text (fractions) .IP \(bu 2 multi\-column support .IP \(bu 2 background color .IP \(bu 2 text frame .UNINDENT .sp The tool requires an initialized DXF document io implement all these features by creating additional text styles. When exploding multiple MTEXT entities, they can share this new text styles. Call the \fBMTextExplode.finalize()\fP method just once after all MTEXT entities are processed to create the required text styles, or use \fBMTextExplode\fP as context manager by using the \fBwith\fP statement, see examples below. .sp There are also many limitations: .INDENT 0.0 .IP \(bu 2 A 100% accurate result cannot be achieved. .IP \(bu 2 Character tracking is not supported. .IP \(bu 2 Tabulator stops have only limited support for LEFT and JUSTIFIED aligned paragraphs to support numbered and bullet lists. An excessive use of tabs will lead to incorrect results. .IP \(bu 2 The DISTRIBUTED alignment will be replaced by the JUSTIFIED alignment. .IP \(bu 2 Text flow is always “left to right”. .IP \(bu 2 The line spacing mostly corresponds to the “EXACT” style, except for stacked text (fractions), which corresponds more to the “AT LEAST” style, but not precisely. This behavior maybe will improve in the future. .IP \(bu 2 FIELDS are not evaluated by \fIezdxf\fP\&. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.MTextExplode(layout, doc=None, spacing_factor=1.0) The \fI\%MTextExplode\fP class is a tool to disassemble MTEXT entities into single line TEXT entities and additional LINE entities if required to emulate strokes. .sp The \fIlayout\fP argument defines the target layout for “exploded” parts of the MTEXT entity. Use argument \fIdoc\fP if the target layout has no DXF document assigned like virtual layouts. The \fIspacing_factor\fP argument is an advanced tuning parameter to scale the size of space chars. .INDENT 7.0 .TP .B explode(mtext: MText, destroy=True) Explode \fImtext\fP and destroy the source entity if argument \fIdestroy\fP is \fBTrue\fP\&. .UNINDENT .INDENT 7.0 .TP .B finalize() Create required text styles. This method is called automatically if the class is used as context manager. This method does not work with virtual layouts if no document was assigned at initialization! .UNINDENT .UNINDENT .sp Example to explode all MTEXT entities in the DXF file “mtext.dxf”: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons import MTextExplode doc = ezdxf.readfile(\(dqmtext.dxf\(dq) msp = doc.modelspace() with MTextExplode(msp) as xpl: for mtext in msp.query(\(dqMTEXT\(dq): xpl.explode(mtext) doc.saveas(\(dqxpl_mtext.dxf\(dq) .EE .UNINDENT .UNINDENT .sp Explode all MTEXT entities into the block “EXPLODE”: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons import MTextExplode doc = ezdxf.readfile(\(dqmtext.dxf\(dq) msp = doc.modelspace() blk = doc.blocks.new(\(dqEXPLODE\(dq) with MTextExplode(blk) as xpl: for mtext in msp.query(\(dqMTEXT\(dq): xpl.explode(mtext) msp.add_block_ref(\(dqEXPLODE\(dq, (0, 0)) doc.saveas(\(dqxpl_into_block.dxf\(dq) .EE .UNINDENT .UNINDENT .SS HPGL/2 Converter Add\-on .sp New in version 1.1. .sp The \fBhpgl2\fP add\-on provides tools to process and convert HPGL/2 plot files. .SS What are HPGL/2 Plot Files? .sp The Hewlett\-Packard Graphics Language (HPGL) is a vector graphics language originally developed by Hewlett\-Packard in the 1970s. HPGL is widely used for controlling pen plotters and other output devices, and it has become a de facto standard for communicating between computers and output devices in the field of computer\-aided design (CAD) and drafting. .sp HPGL is a command\-driven language that consists of a series of commands that control the movement of the plotter pen, the selection of pens and other output parameters, and the drawing of geometric shapes such as lines, arcs, circles, and text. The language is interpreted by the plotter or other output device and translated into physical pen movements on the drawing surface. .sp HPGL has evolved over the years, and various extensions have been added to support more complex graphics operations and to improve compatibility with other graphics languages. Despite the development of newer graphics languages and file formats, HPGL remains a widely used format for vector\-based graphics, particularly in the engineering and architectural fields. .SS The Goal of This Add\-on .sp An HPGL/2 plot file contains all of the data generated by a CAD application that has been sent to a plotter to print an engineering drawing. In the past, the only way to access this data was to view it on a plotter or an specialized application, which could be expensive and impractical for many people. However, this module provides functions and classes to convert HPGL/2 plot files into modern vector graphic formats such as \fI\%PDF\fP and \fI\%SVG\fP and of course DXF, allowing the data to be viewed and processed using a wide range of software tools. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 The Python module PyMuPDF is required for the PDF export: \fI\%https://pypi.org/project/PyMuPDF/\fP .UNINDENT .UNINDENT .sp The \fI\%Plotter\fP class in the \fBhpgl2\fP add\-on supports only the most commonly used commands of HPGL/2. This is because many CAD applications use only a small subset of HPGL/2 to create their output, typically consisting of polylines and filled polygons. For more information on the supported commands, please refer to the documentation for the \fI\%Plotter\fP class. .sp To use the HPGL2 add\-on, the entry point is the \fI\%ezdxf.addons.hpgl2.api\fP module. This module contains the public interface of the add\-on and should be imported in the following way: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons.hpgl2 import api as hpgl2 with open(\(dqhpgl2.plt\(dq, \(dqrb\(dq) as fp: data = fp.read() doc = hpgl2.to_dxf(data, color_mode=hpgl2.ColorMode.ACI) doc.saveas(\(dqhpgl2_as.dxf\(dq) .EE .UNINDENT .UNINDENT .SS High Level Functions .TS center; |l|l|. _ T{ \fI\%to_dxf\fP T} T{ Exports the HPGL/2 commands of the byte stream \fIb\fP as a DXF document. T} _ T{ \fI\%to_svg\fP T} T{ Exports the HPGL/2 commands of the byte stream \fIb\fP as SVG string. T} _ T{ \fI\%to_pdf\fP T} T{ Exports the HPGL/2 commands of the byte stream \fIb\fP as PDF data. T} _ T{ \fI\%to_pixmap\fP T} T{ Exports the HPGL/2 commands of the byte stream \fIb\fP as pixel image. T} _ .TE .INDENT 0.0 .TP .B ezdxf.addons.hpgl2.api.to_dxf(b: bytes, *, rotation: int = 0, mirror_x: bool = False, mirror_y: bool = False, color_mode=ColorMode.RGB, merge_control: \fI\%MergeControl\fP = MergeControl.AUTO) -> \fI\%Drawing\fP Exports the HPGL/2 commands of the byte stream \fIb\fP as a DXF document. .sp The page content is created at the origin of the modelspace and 1 drawing unit is 1 plot unit (1 plu = 0.025mm) unless scaling values are provided. .sp The content of HPGL files is intended to be plotted on white paper, therefore a white filling will be added as background in color mode \fBRGB\fP\&. .sp All entities are assigned to a layer according to the pen number with the name scheme \fBPEN_<###>\fP\&. In order to be able to process the file better, it is also possible to assign the \fI\%ACI\fP color by layer by setting the argument \fIcolor_mode\fP to \fI\%ColorMode.ACI\fP, but then the RGB color is lost because the RGB color has always the higher priority over the \fI\%ACI\fP\&. .sp The first paperspace layout “Layout1” of the DXF document is set up to print the entire modelspace on one sheet, the size of the page is the size of the original plot file in millimeters. .sp HPGL/2’s merge control works at the pixel level and cannot be replicated by DXF, but to prevent fillings from obscuring text, the filled polygons are sorted by luminance \- this can be forced or disabled by the argument \fImerge_control\fP, see also \fI\%MergeControl\fP enum. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBb\fP – plot file content as bytes .IP \(bu 2 \fBrotation\fP – rotation angle of 0, 90, 180 or 270 degrees .IP \(bu 2 \fBmirror_x\fP – mirror in x\-axis direction .IP \(bu 2 \fBmirror_y\fP – mirror in y\-axis direction .IP \(bu 2 \fBcolor_mode\fP – the color mode controls how color values are assigned to DXF entities, see \fI\%ColorMode\fP .IP \(bu 2 \fBmerge_control\fP – how to order filled polygons, see \fI\%MergeControl\fP .UNINDENT .UNINDENT .sp Returns: DXF document as instance of class \fI\%Drawing\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.hpgl2.api.to_svg(b: bytes, *, rotation: int = 0, mirror_x: bool = False, mirror_y: bool = False, merge_control=MergeControl.AUTO) -> str Exports the HPGL/2 commands of the byte stream \fIb\fP as SVG string. .sp The plot units are mapped 1:1 to \fBviewBox\fP units and the size of image is the size of the original plot file in millimeters. .sp HPGL/2’s merge control works at the pixel level and cannot be replicated by the backend, but to prevent fillings from obscuring text, the filled polygons are sorted by luminance \- this can be forced or disabled by the argument \fImerge_control\fP, see also \fI\%MergeControl\fP enum. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBb\fP – plot file content as bytes .IP \(bu 2 \fBrotation\fP – rotation angle of 0, 90, 180 or 270 degrees .IP \(bu 2 \fBmirror_x\fP – mirror in x\-axis direction .IP \(bu 2 \fBmirror_y\fP – mirror in y\-axis direction .IP \(bu 2 \fBmerge_control\fP – how to order filled polygons, see \fI\%MergeControl\fP .UNINDENT .UNINDENT .sp Returns: SVG content as \fBstr\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.hpgl2.api.to_pdf(b: bytes, *, rotation: int = 0, mirror_x: bool = False, mirror_y: bool = False, merge_control=MergeControl.AUTO) -> bytes Exports the HPGL/2 commands of the byte stream \fIb\fP as PDF data. .sp The plot units (1 plu = 0.025mm) are converted to PDF units (1/72 inch) so the image has the size of the original plot file. .sp HPGL/2’s merge control works at the pixel level and cannot be replicated by the backend, but to prevent fillings from obscuring text, the filled polygons are sorted by luminance \- this can be forced or disabled by the argument \fImerge_control\fP, see also \fI\%MergeControl\fP enum. .sp Python module PyMuPDF is required: \fI\%https://pypi.org/project/PyMuPDF/\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBb\fP – plot file content as bytes .IP \(bu 2 \fBrotation\fP – rotation angle of 0, 90, 180 or 270 degrees .IP \(bu 2 \fBmirror_x\fP – mirror in x\-axis direction .IP \(bu 2 \fBmirror_y\fP – mirror in y\-axis direction .IP \(bu 2 \fBmerge_control\fP – how to order filled polygons, see \fI\%MergeControl\fP .UNINDENT .UNINDENT .sp Returns: PDF content as \fBbytes\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.hpgl2.api.to_pixmap(b: bytes, *, rotation: int = 0, mirror_x: bool = False, mirror_y: bool = False, merge_control=MergeControl.AUTO, fmt: str = \(aqpng\(aq, dpi: int = 96) -> bytes Exports the HPGL/2 commands of the byte stream \fIb\fP as pixel image. .sp Supported image formats: .INDENT 7.0 .INDENT 3.5 .TS center; |l|l|. _ T{ png T} T{ Portable Network Graphics T} _ T{ ppm T} T{ Portable Pixmap T} _ T{ pbm T} T{ Portable Bitmap T} _ .TE .UNINDENT .UNINDENT .sp The plot units (1 plu = 0.025mm) are converted to dot per inch (dpi) so the image has the size of the original plot file. .sp HPGL/2’s merge control works at the pixel level and cannot be replicated by the backend, but to prevent fillings from obscuring text, the filled polygons are sorted by luminance \- this can be forced or disabled by the argument \fImerge_control\fP, see also \fI\%MergeControl\fP enum. .sp Python module PyMuPDF is required: \fI\%https://pypi.org/project/PyMuPDF/\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBb\fP – plot file content as bytes .IP \(bu 2 \fBrotation\fP – rotation angle of 0, 90, 180 or 270 degrees .IP \(bu 2 \fBmirror_x\fP – mirror in x\-axis direction .IP \(bu 2 \fBmirror_y\fP – mirror in y\-axis direction .IP \(bu 2 \fBmerge_control\fP – how to order filled polygons, see \fI\%MergeControl\fP .IP \(bu 2 \fBfmt\fP – image format .IP \(bu 2 \fBdpi\fP – output resolution in dots per inch .UNINDENT .UNINDENT .sp Returns: image content as \fBbytes\fP .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.ColorMode The color mode controls how color values are assigned to DXF entities .INDENT 7.0 .TP .B ACI Use the pen number as \fI\%AutoCAD Color Index (ACI)\fP for DXF entities, ignores the RGB color values .UNINDENT .INDENT 7.0 .TP .B RGB Use the pen number as \fI\%AutoCAD Color Index (ACI)\fP but also set the RGB color for DXF entities, RGB color values have always higher priority than the ACI when displaying DXF content. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.MergeControl Merge control enumeration. .INDENT 7.0 .TP .B NONE export filled polygons in print order .UNINDENT .INDENT 7.0 .TP .B LUMINANCE sort filled polygons by luminance .UNINDENT .INDENT 7.0 .TP .B AUTO guess best order of filled polygons .UNINDENT .UNINDENT .SS The Low Level Functions and Classes .INDENT 0.0 .TP .B ezdxf.addons.hpgl2.api.hpgl2_commands(s: bytes) -> list[Command] Low level plot file parser, extracts the HPGL/2 from the byte stream \fIb\fP\&. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 This parser expects the “Enter HPGL/2 mode” escape sequence to recognize HPGL/2 commands. The sequence looks like this: \fB[ESC]%1B\fP, multiple variants of this sequence are supported. .UNINDENT .UNINDENT .UNINDENT .sp The HPGL/2 commands are often mixed with the Printer Command Language (\fI\%PCL\fP) and/or the Raster Transfer Language (\fI\%RTL\fP) commands in a single plot file. .sp Some plot files that contain pure HPGL/2 code do not contain the escape sequence “Enter HPGL/2 mode”, without this sequence the HPGL/2 parser cannot recognize the beginning of the HPGL/2 code. Add the \fBENTER_HPGL2_MODE\fP sequence in front of the bytes stream to switch on the HPGL/2 manually, regardless of whether the file is an HPGL/2 plot file or not, so be careful: .INDENT 0.0 .INDENT 3.5 .sp .EX commands = hpgl2_commands(hpgl2.ENTER_HPGL2_MODE + data) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.Interpreter(plotter: \fI\%Plotter\fP) The \fI\%Interpreter\fP is the frontend for the \fI\%Plotter\fP class. The \fI\%run()\fP methods interprets the low level HPGL commands from the \fI\%hpgl2_commands()\fP parser and sends the commands to the virtual plotter device, which sends his output to a low level \fBBackend\fP class. .sp Most CAD application send a very restricted subset of commands to plotters, mostly just polylines and filled polygons. Implementing the whole HPGL/2 command set is not worth the effort \- unless reality proofs otherwise. .sp Not implemented commands: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 the whole character group \- text is send as filled polygons or polylines .IP \(bu 2 configuration group: IN, DF, RO, IW \- the plotter is initialized by creating a new plotter and page rotation is handled by the add\-on itself .IP \(bu 2 polygon group: EA, ER, EW, FA, RR, WG, the rectangle and wedge commands .IP \(bu 2 line and fill attributes group: LA, RF, SM, SV, TR, UL, WU, linetypes and hatch patterns are decomposed into simple lines by CAD applications .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters \fBplotter\fP – virtual \fI\%Plotter\fP device .UNINDENT .INDENT 7.0 .TP .B errors List of error messages occurred during the interpretation of the HPGL/2 commands. .UNINDENT .INDENT 7.0 .TP .B not_implemented_commands List of all unsupported/ignored commands from the input stream. .UNINDENT .INDENT 7.0 .TP .B run(commands: list[Command]) -> None Interprets the low level HPGL commands from the \fI\%hpgl2_commands()\fP parser and sends the commands to the virtual plotter device. .UNINDENT .INDENT 7.0 .TP .B disable_commands(commands: Iterable[str]) -> None Disable commands manually, like the scaling command [“SC”, “IP”, “IR”]. This is a feature for experts, because disabling commands which changes the pen location may distort or destroy the plotter output. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.Plotter(backend: Backend) The \fI\%Plotter\fP class represents a virtual plotter device. .sp The HPGL/2 commands send by the \fI\%Interpreter\fP are processed into simple polylines and filled polygons and send to low level \fBBackend\fP\&. .sp HPGL/2 uses a units system called “Plot Units”: .INDENT 7.0 .IP \(bu 2 1 plot unit (plu) = 0.025mm .IP \(bu 2 40 plu = 1 mm .IP \(bu 2 1016 plu = 1 inch .UNINDENT .sp The Plotter device does not support font rendering and page rotation (RO). The scaling commands IP, RP, SC are supported. .UNINDENT .SS Recorder .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.Recorder The \fI\%Recorder\fP class records the output of the \fI\%Plotter\fP class. .sp All input coordinates are page coordinates: .INDENT 7.0 .IP \(bu 2 1 plot unit (plu) = 0.025mm .IP \(bu 2 40 plu = 1 mm .IP \(bu 2 1016 plu = 1 inch .UNINDENT .INDENT 7.0 .TP .B player() -> \fI\%Player\fP Returns a \fI\%Player\fP instance with the original recordings. Make a copy of this player to protect the original recordings from being modified: .INDENT 7.0 .INDENT 3.5 .sp .EX safe_player = recorder.player().copy() .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B draw_polyline(properties: \fI\%Properties\fP, points: Sequence[\fI\%Vec2\fP]) -> None Draws a polyline from a sequence \fIpoints\fP\&. The input coordinates are page coordinates in plot units. The \fIpoints\fP sequence can contain 0 or more points! .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBproperties\fP – display \fBProperties\fP for the polyline .IP \(bu 2 \fBpoints\fP – sequence of \fI\%ezdxf.math.Vec2\fP instances .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B draw_paths(properties: \fI\%Properties\fP, paths: Sequence[Path], filled: bool) -> None Draws filled or outline paths from the sequence of \fIpaths\fP\&. The input coordinates are page coordinates in plot units. The \fIpaths\fP sequence can contain 0 or more single \fI\%Path\fP instances. Draws outline paths if Properties.FillType is NONE and filled paths otherwise. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBproperties\fP – display \fBProperties\fP for the filled polygon .IP \(bu 2 \fBpaths\fP – sequence of single \fI\%ezdxf.path.Path\fP instances .IP \(bu 2 \fBfilled\fP – draw filled paths if \fBTrue\fP otherwise outline paths .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Player .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.Player(records: list[DataRecord], properties: dict[int, \fI\%Properties\fP]) This class replays the recordings of the \fI\%Recorder\fP class on another backend. The class can modify the recorded output. .INDENT 7.0 .TP .B copy() -> Self Returns a new \fI\%Player\fP instance with a copy of recordings. .UNINDENT .INDENT 7.0 .TP .B recordings() -> Iterator[tuple[RecordType, \fI\%Properties\fP, Any]] Yields all recordings as \fI(RecordType, Properties, Data)\fP tuples. .sp The content of the \fIData\fP field is determined by the enum \fBRecordType\fP: .INDENT 7.0 .IP \(bu 2 \fBRecordType.POLYLINE\fP returns a \fBNumpyPoints2d\fP instance .IP \(bu 2 \fBRecordType.FILLED_POLYGON\fP returns a tuple of \fBNumpyPath2d\fP instances .UNINDENT .UNINDENT .INDENT 7.0 .TP .B replay(backend: Backend) -> None Replay the recording on another backend. .UNINDENT .INDENT 7.0 .TP .B bbox() -> \fI\%BoundingBox2d\fP Returns the bounding box of all recorded polylines and polygons as \fI\%BoundingBox2d\fP\&. .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> None Transforms the recordings by a transformation matrix \fIm\fP of type \fI\%Matrix44\fP\&. .UNINDENT .INDENT 7.0 .TP .B sort_filled_paths() -> None Sort filled paths by descending luminance (from light to dark). .sp This also changes the plot order in the way that all filled paths are plotted before polylines and outline paths. .UNINDENT .UNINDENT .SS Properties .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.properties.Properties Consolidated display properties. .INDENT 7.0 .TP .B pen_index pen index as int .UNINDENT .INDENT 7.0 .TP .B pen_color pen color as \fBRGB\fP tuple .UNINDENT .INDENT 7.0 .TP .B pen_width pen width in millimeters (float) .UNINDENT .INDENT 7.0 .TP .B fill_type \fI\%FillType\fP of filled polygons .UNINDENT .INDENT 7.0 .TP .B fill_method \fI\%FillMethod\fP of filled polygons .UNINDENT .INDENT 7.0 .TP .B fill_hatch_line_angle fill hatch line angle in degrees .UNINDENT .INDENT 7.0 .TP .B fill_hatch_line_spacing fill hatch line distance in plotter units .UNINDENT .INDENT 7.0 .TP .B fill_shading_density fill shading density in percent from 0 to 100. .UNINDENT .INDENT 7.0 .TP .B resolve_pen_color() -> \fI\%RGB\fP Returns the final RGB pen color. .UNINDENT .INDENT 7.0 .TP .B resolve_fill_color() -> \fI\%RGB\fP Returns the final RGB fill color. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.properties.FillType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Fill type enumeration. .INDENT 7.0 .TP .B NONE .UNINDENT .INDENT 7.0 .TP .B SOLID .UNINDENT .INDENT 7.0 .TP .B HATCHING .UNINDENT .INDENT 7.0 .TP .B CROSS_HATCHING .UNINDENT .INDENT 7.0 .TP .B SHADING .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.properties.FillMethod(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Fill method enumeration. .INDENT 7.0 .TP .B EVEN_ODD .UNINDENT .INDENT 7.0 .TP .B NONE_ZERO_WINDING .UNINDENT .UNINDENT .SS Exceptions .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.Hpgl2Error Base exception for the \fBhpgl2\fP add\-on. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.Hpgl2DataNotFound No HPGL/2 data was found, maybe the “Enter HPGL/2 mode” escape sequence is missing. .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.hpgl2.api.EmptyDrawing The HPGL/2 commands do not produce any content. .UNINDENT .SS PyCSG .sp Constructive Solid Geometry (CSG) is a modeling technique that uses Boolean operations like union and intersection to combine 3D solids. This library implements CSG operations on meshes elegantly and concisely using BSP trees, and is meant to serve as an easily understandable implementation of the algorithm. All edge cases involving overlapping coplanar polygons in both solids are correctly handled. .sp Example for usage: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.render.forms import cube, cylinder_2p from ezdxf.addons.pycsg import CSG # create new DXF document doc = ezdxf.new() msp = doc.modelspace() # create same geometric primitives as MeshTransformer() objects cube1 = cube() cylinder1 = cylinder_2p(count=32, base_center=(0, \-1, 0), top_center=(0, 1, 0), radius=.25) # build solid union union = CSG(cube1) + CSG(cylinder1) # convert to mesh and render mesh to modelspace union.mesh().render(msp, dxfattribs={\(aqcolor\(aq: 1}) # build solid difference difference = CSG(cube1) \- CSG(cylinder1) # convert to mesh, translate mesh and render mesh to modelspace difference.mesh().translate(1.5).render(msp, dxfattribs={\(aqcolor\(aq: 3}) # build solid intersection intersection = CSG(cube1) * CSG(cylinder1) # convert to mesh, translate mesh and render mesh to modelspace intersection.mesh().translate(2.75).render(msp, dxfattribs={\(aqcolor\(aq: 5}) doc.saveas(\(aqcsg.dxf\(aq) .EE .UNINDENT .UNINDENT [image: Cube vs Cylinder] [image] .sp This CSG kernel supports only meshes as \fI\%MeshBuilder\fP objects, which can be created from and converted to DXF \fI\%Mesh\fP entities. .sp This CSG kernel is \fBnot\fP compatible with ACIS objects like \fI\%Solid3d\fP, \fI\%Body\fP, \fI\%Surface\fP or \fI\%Region\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This is a pure Python implementation, don’t expect great performance and the implementation is based on an unbalanced \fI\%BSP tree\fP, so in the case of \fBRecursionError\fP, increase the recursion limit: .INDENT 0.0 .INDENT 3.5 .sp .EX import sys actual_limit = sys.getrecursionlimit() # default is 1000, increasing too much may cause a seg fault sys.setrecursionlimit(10000) \&... # do the CSG stuff sys.setrecursionlimit(actual_limit) .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp CSG works also with spheres, but with really bad runtime behavior and most likely \fBRecursionError\fP exceptions, and use \fI\%quadrilaterals\fP as body faces to reduce face count by setting argument \fIquads\fP to \fBTrue\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.render.forms import sphere, cube from ezdxf.addons.pycsg import CSG doc = ezdxf.new() doc.set_modelspace_vport(6, center=(5, 0)) msp = doc.modelspace() cube1 = cube().translate(\-.5, \-.5, \-.5) sphere1 = sphere(count=32, stacks=16, radius=.5, quads=True) union = (CSG(cube1) + CSG(sphere1)).mesh() union.render(msp, dxfattribs={\(aqcolor\(aq: 1}) subtract = (CSG(cube1) \- CSG(sphere1)).mesh().translate(2.5) subtract.render(msp, dxfattribs={\(aqcolor\(aq: 3}) intersection = (CSG(cube1) * CSG(sphere1)).mesh().translate(4) intersection.render(msp, dxfattribs={\(aqcolor\(aq: 5}) .EE .UNINDENT .UNINDENT [image: Cube vs Sphere] [image] .sp Hard Core CSG \- Menger Sponge Level 3 vs Sphere .sp Required runtime on an old Xeon E5\-1620 Workstation @ 3.60GHz, with default recursion limit of 1000 on Windows 10: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 CPython 3.8.1 64bit: ~60 seconds, .IP \(bu 2 pypy3 [PyPy 7.2.0] 32bit: ~6 seconds, and using \fB__slots__\fP reduced runtime below 5 seconds, yes \- pypy is worth a look for long running scripts! .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.render.forms import sphere from ezdxf.addons import MengerSponge from ezdxf.addons.pycsg import CSG doc = ezdxf.new() doc.layers.new(\(aqsponge\(aq, dxfattribs={\(aqcolor\(aq: 5}) doc.layers.new(\(aqsphere\(aq, dxfattribs={\(aqcolor\(aq: 6}) doc.set_modelspace_vport(6, center=(5, 0)) msp = doc.modelspace() sponge1 = MengerSponge(level=3).mesh() sphere1 = sphere(count=32, stacks=16, radius=.5, quads=True).translate(.25, .25, 1) subtract = (CSG(sponge1, meshid=1) \- CSG(sphere1, meshid=2)) # get mesh result by id subtract.mesh(1).render(msp, dxfattribs={\(aqlayer\(aq: \(aqsponge\(aq}) subtract.mesh(2).render(msp, dxfattribs={\(aqlayer\(aq: \(aqsphere\(aq}) .EE .UNINDENT .UNINDENT [image: Menger Sponge vs Sphere] [image] .SS CSG Class .INDENT 0.0 .TP .B class ezdxf.addons.pycsg.CSG(mesh: \fI\%MeshBuilder\fP, meshid: int = 0) Constructive Solid Geometry (CSG) is a modeling technique that uses Boolean operations like union and intersection to combine 3D solids. This class implements CSG operations on meshes. .sp New 3D solids are created from \fI\%MeshBuilder\fP objects and results can be exported as \fI\%MeshTransformer\fP objects to \fIezdxf\fP by method \fI\%mesh()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmesh\fP – \fI\%ezdxf.render.MeshBuilder\fP or inherited object .IP \(bu 2 \fBmeshid\fP – individual mesh ID to separate result meshes, \fB0\fP is default .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mesh(meshid: int = 0) -> MeshTransformer Returns a \fI\%ezdxf.render.MeshTransformer\fP object. .INDENT 7.0 .TP .B Parameters \fBmeshid\fP – individual mesh ID, \fB0\fP is default .UNINDENT .UNINDENT .INDENT 7.0 .TP .B union(other: \fI\%CSG\fP) -> \fI\%CSG\fP Return a new CSG solid representing space in either this solid or in the solid \fIother\fP\&. Neither this solid nor the solid \fIother\fP are modified: .INDENT 7.0 .INDENT 3.5 .sp .EX A.union(B) +\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-+ | | | | | A | | | | +\-\-+\-\-\-\-+ = | +\-\-\-\-+ +\-\-\-\-+\-\-+ | +\-\-\-\-+ | | B | | | | | | | +\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-+ .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __add__() .INDENT 7.0 .INDENT 3.5 .sp .EX union = A + B .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B subtract(other: \fI\%CSG\fP) -> \fI\%CSG\fP Return a new CSG solid representing space in this solid but not in the solid \fIother\fP\&. Neither this solid nor the solid \fIother\fP are modified: .INDENT 7.0 .INDENT 3.5 .sp .EX A.subtract(B) +\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-+ | | | | | A | | | | +\-\-+\-\-\-\-+ = | +\-\-+ +\-\-\-\-+\-\-+ | +\-\-\-\-+ | B | | | +\-\-\-\-\-\-\-+ .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __sub__() .INDENT 7.0 .INDENT 3.5 .sp .EX difference = A \- B .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect(other: \fI\%CSG\fP) -> \fI\%CSG\fP Return a new CSG solid representing space both this solid and in the solid \fIother\fP\&. Neither this solid nor the solid \fIother\fP are modified: .INDENT 7.0 .INDENT 3.5 .sp .EX A.intersect(B) +\-\-\-\-\-\-\-+ | | | A | | +\-\-+\-\-\-\-+ = +\-\-+ +\-\-\-\-+\-\-+ | +\-\-+ | B | | | +\-\-\-\-\-\-\-+ .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __mul__() .INDENT 7.0 .INDENT 3.5 .sp .EX intersection = A * B .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B inverse() -> \fI\%CSG\fP Return a new CSG solid with solid and empty space switched. This solid is not modified. .UNINDENT .UNINDENT .SS License .INDENT 0.0 .IP \(bu 2 Original implementation \fI\%csg.js\fP, Copyright (c) 2011 Evan Wallace (\fI\%http://madebyevan.com/\fP), under the MIT license. .IP \(bu 2 Python port \fI\%pycsg\fP, Copyright (c) 2012 Tim Knip (\fI\%http://www.floorplanner.com\fP), under the MIT license. .IP \(bu 2 Additions by Alex Pletzer (Pennsylvania State University) .IP \(bu 2 Integration as \fIezdxf\fP add\-on, Copyright (c) 2020, Manfred Moitzi, MIT License. .UNINDENT .SS Plot Style Files (CTB/STB) .sp CTB and STB files store plot styles used by AutoCAD and BricsCAD for printing and plotting. .sp If the plot style table is attached to a \fI\%Paperspace\fP or the \fI\%Modelspace\fP, a change of a plot style affects any object that uses that plot style. CTB files contain color dependent plot style tables, STB files contain named plot style tables. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%Using plot style tables in AutoCAD\fP .IP \(bu 2 \fI\%AutoCAD Plot Style Table Editor\fP .IP \(bu 2 \fI\%BricsCAD Plot Style Table Editor\fP .IP \(bu 2 AUTODESK KNOWLEDGE NETWORK: How to \fI\%install\fP CTB files in AutoCAD .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.load(filename: str | PathLike) -> \fI\%ColorDependentPlotStyles\fP | \fI\%NamedPlotStyles\fP Load the CTB or STB file \fIfilename\fP from file system. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.new_ctb() -> \fI\%ColorDependentPlotStyles\fP Create a new CTB file. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.new_stb() -> \fI\%NamedPlotStyles\fP Create a new STB file. .UNINDENT .SS ColorDependentPlotStyles .sp Color dependent plot style table (CTB file), table entries are \fI\%PlotStyle\fP objects. .INDENT 0.0 .TP .B class ezdxf.addons.acadctb.ColorDependentPlotStyles .INDENT 7.0 .TP .B description Custom description of plot style file. .UNINDENT .INDENT 7.0 .TP .B scale_factor Specifies the factor by which to scale non\-ISO linetypes and fill patterns. .UNINDENT .INDENT 7.0 .TP .B apply_factor Specifies whether or not you want to apply the \fI\%scale_factor\fP\&. .UNINDENT .INDENT 7.0 .TP .B custom_lineweight_display_units Set \fB1\fP for showing lineweight in inch in AutoCAD CTB editor window, but lineweights are always defined in millimeters. .UNINDENT .INDENT 7.0 .TP .B lineweights Lineweights table as \fBarray.array\fP .UNINDENT .INDENT 7.0 .TP .B __getitem__(aci: int) -> \fI\%PlotStyle\fP Returns \fI\%PlotStyle\fP for \fI\%AutoCAD Color Index (ACI)\fP \fIaci\fP\&. .UNINDENT .INDENT 7.0 .TP .B __iter__() Iterable of all plot styles. .UNINDENT .INDENT 7.0 .TP .B new_style(aci: int, data: dict | None = None) -> \fI\%PlotStyle\fP Set \fIaci\fP to new attributes defined by \fIdata\fP dict. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBaci\fP – \fI\%AutoCAD Color Index (ACI)\fP .IP \(bu 2 \fBdata\fP – \fBdict\fP of \fI\%PlotStyle\fP attributes: description, color, physical_pen_number, virtual_pen_number, screen, linepattern_size, linetype, adaptive_linetype, lineweight, end_style, join_style, fill_style .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_lineweight(aci: int) Returns the assigned lineweight for \fI\%PlotStyle\fP \fIaci\fP in millimeter. .UNINDENT .INDENT 7.0 .TP .B get_lineweight_index(lineweight: float) -> int Get index of \fIlineweight\fP in the lineweight table or append \fIlineweight\fP to lineweight table. .UNINDENT .INDENT 7.0 .TP .B get_table_lineweight(index: int) -> float Returns lineweight in millimeters of lineweight table entry \fIindex\fP\&. .INDENT 7.0 .TP .B Parameters \fBindex\fP – lineweight table index = \fI\%PlotStyle.lineweight\fP .TP .B Returns lineweight in mm or \fB0.0\fP for use entity lineweight .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_table_lineweight(index: int, lineweight: float) -> int Argument \fIindex\fP is the lineweight table index, not the \fI\%AutoCAD Color Index (ACI)\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBindex\fP – lineweight table index = \fI\%PlotStyle.lineweight\fP .IP \(bu 2 \fBlineweight\fP – in millimeters .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B save() Save CTB file as \fIfilename\fP to the file system. .UNINDENT .INDENT 7.0 .TP .B write(stream: BinaryIO) -> None Compress and write CTB file to binary \fIstream\fP\&. .UNINDENT .UNINDENT .SS NamedPlotStyles .sp Named plot style table (STB file), table entries are \fI\%PlotStyle\fP objects. .INDENT 0.0 .TP .B class ezdxf.addons.acadctb.NamedPlotStyles .INDENT 7.0 .TP .B description Custom description of plot style file. .UNINDENT .INDENT 7.0 .TP .B scale_factor Specifies the factor by which to scale non\-ISO linetypes and fill patterns. .UNINDENT .INDENT 7.0 .TP .B apply_factor Specifies whether or not you want to apply the \fI\%scale_factor\fP\&. .UNINDENT .INDENT 7.0 .TP .B custom_lineweight_display_units Set \fB1\fP for showing lineweight in inch in AutoCAD CTB editor window, but lineweights are always defined in millimeters. .UNINDENT .INDENT 7.0 .TP .B lineweights Lineweights table as \fBarray.array\fP .UNINDENT .INDENT 7.0 .TP .B __getitem__(name: str) -> \fI\%PlotStyle\fP Returns \fI\%PlotStyle\fP by \fIname\fP\&. .UNINDENT .INDENT 7.0 .TP .B __delitem__(name: str) -> None Delete plot style \fIname\fP\&. Plot style \fB\(aqNormal\(aq\fP is not deletable. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[str] Iterable of all plot style names. .UNINDENT .INDENT 7.0 .TP .B new_style(name: str, data: dict | None = None, localized_name: str | None = None) -> \fI\%PlotStyle\fP Create new class:\fIPlotStyle\fP \fIname\fP by attribute dict \fIdata\fP, replaces existing class:\fIPlotStyle\fP objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – plot style name .IP \(bu 2 \fBlocalized_name\fP – name shown in plot style editor, uses \fIname\fP if \fBNone\fP .IP \(bu 2 \fBdata\fP – \fBdict\fP of \fI\%PlotStyle\fP attributes: description, color, physical_pen_number, virtual_pen_number, screen, linepattern_size, linetype, adaptive_linetype, lineweight, end_style, join_style, fill_style .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_lineweight(name: str) Returns the assigned lineweight for \fI\%PlotStyle\fP \fIname\fP in millimeter. .UNINDENT .INDENT 7.0 .TP .B get_lineweight_index(lineweight: float) -> int Get index of \fIlineweight\fP in the lineweight table or append \fIlineweight\fP to lineweight table. .UNINDENT .INDENT 7.0 .TP .B get_table_lineweight(index: int) -> float Returns lineweight in millimeters of lineweight table entry \fIindex\fP\&. .INDENT 7.0 .TP .B Parameters \fBindex\fP – lineweight table index = \fI\%PlotStyle.lineweight\fP .TP .B Returns lineweight in mm or \fB0.0\fP for use entity lineweight .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_table_lineweight(index: int, lineweight: float) -> int Argument \fIindex\fP is the lineweight table index, not the \fI\%AutoCAD Color Index (ACI)\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBindex\fP – lineweight table index = \fI\%PlotStyle.lineweight\fP .IP \(bu 2 \fBlineweight\fP – in millimeters .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B save() Save STB file as \fIfilename\fP to the file system. .UNINDENT .INDENT 7.0 .TP .B write() Compress and write STB file to binary \fIstream\fP\&. .UNINDENT .UNINDENT .SS PlotStyle .INDENT 0.0 .TP .B class ezdxf.addons.acadctb.PlotStyle .INDENT 7.0 .TP .B index Table index (0\-based). (int) .UNINDENT .INDENT 7.0 .TP .B aci \fI\%AutoCAD Color Index (ACI)\fP in range from \fB1\fP to \fB255\fP\&. Has no meaning for named plot styles. (int) .UNINDENT .INDENT 7.0 .TP .B description Custom description of plot style. (str) .UNINDENT .INDENT 7.0 .TP .B physical_pen_number Specifies physical plotter pen, valid range from \fB1\fP to \fB32\fP or \fI\%AUTOMATIC\fP\&. (int) .UNINDENT .INDENT 7.0 .TP .B virtual_pen_number Only used by non\-pen plotters and only if they are configured for virtual pens. valid range from \fB1\fP to \fB255\fP or \fI\%AUTOMATIC\fP\&. (int) .UNINDENT .INDENT 7.0 .TP .B screen Specifies the color intensity of the plot on the paper, valid range is from \fB0\fP to \fB100\fP\&. (int) .sp If you select \fB100\fP the drawing will plotted with its full color intensity. In order for screening to work, the \fI\%dithering\fP option must be active. .UNINDENT .INDENT 7.0 .TP .B linetype Overrides the entity linetype, default value is \fI\%OBJECT_LINETYPE\fP\&. (bool) .UNINDENT .INDENT 7.0 .TP .B adaptive_linetype \fBTrue\fP if a complete linetype pattern is more important than a correct linetype scaling, default is \fBTrue\fP\&. (bool) .UNINDENT .INDENT 7.0 .TP .B linepattern_size Line pattern size, default = \fB0.5\fP\&. (float) .UNINDENT .INDENT 7.0 .TP .B lineweight Overrides the entity lineWEIGHT, default value is \fI\%OBJECT_LINEWEIGHT\fP\&. This is an index into the \fBUserStyles.lineweights\fP table. (int) .UNINDENT .INDENT 7.0 .TP .B end_style Line end cap style, see table below, default is \fBEND_STYLE_OBJECT\fP (int) .UNINDENT .INDENT 7.0 .TP .B join_style Line join style, see table below, default is \fBJOIN_STYLE_OBJECT\fP (int) .UNINDENT .INDENT 7.0 .TP .B fill_style Line fill style, see table below, default is \fBFILL_STYLE_OBJECT\fP (int) .UNINDENT .INDENT 7.0 .TP .B dithering Depending on the capabilities of your plotter, dithering approximates the colors with dot patterns. When this option is \fBFalse\fP, the colors are mapped to the nearest color, resulting in a smaller range of colors when plotting. .sp Dithering is available only whether you select the object’s color or assign a plot style color. .UNINDENT .INDENT 7.0 .TP .B grayscale Plot colors in grayscale. (bool) .UNINDENT .UNINDENT .SS Default Line Weights .TS center; |l|l|. _ T{ # T} T{ [mm] T} _ T{ 0 T} T{ 0.00 T} _ T{ 1 T} T{ 0.05 T} _ T{ 2 T} T{ 0.09 T} _ T{ 3 T} T{ 0.10 T} _ T{ 4 T} T{ 0.13 T} _ T{ 5 T} T{ 0.15 T} _ T{ 6 T} T{ 0.18 T} _ T{ 7 T} T{ 0.20 T} _ T{ 8 T} T{ 0.25 T} _ T{ 9 T} T{ 0.30 T} _ T{ 10 T} T{ 0.35 T} _ T{ 11 T} T{ 0.40 T} _ T{ 12 T} T{ 0.45 T} _ T{ 13 T} T{ 0.50 T} _ T{ 14 T} T{ 0.53 T} _ T{ 15 T} T{ 0.60 T} _ T{ 16 T} T{ 0.65 T} _ T{ 17 T} T{ 0.70 T} _ T{ 18 T} T{ 0.80 T} _ T{ 19 T} T{ 0.90 T} _ T{ 20 T} T{ 1.00 T} _ T{ 21 T} T{ 1.06 T} _ T{ 22 T} T{ 1.20 T} _ T{ 23 T} T{ 1.40 T} _ T{ 24 T} T{ 1.58 T} _ T{ 25 T} T{ 2.00 T} _ T{ 26 T} T{ 2.11 T} _ .TE .SS Predefined Values .INDENT 0.0 .TP .B ezdxf.addons.acadctb.AUTOMATIC .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.OBJECT_LINEWEIGHT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.OBJECT_LINETYPE .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.OBJECT_COLOR .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.OBJECT_COLOR2 .UNINDENT .SS Line End Style [image] .TS center; |l|l|. _ T{ END_STYLE_BUTT T} T{ \fB0\fP T} _ T{ END_STYLE_SQUARE T} T{ \fB1\fP T} _ T{ END_STYLE_ROUND T} T{ \fB2\fP T} _ T{ END_STYLE_DIAMOND T} T{ \fB3\fP T} _ T{ END_STYLE_OBJECT T} T{ \fB4\fP T} _ .TE .SS Line Join Style [image] .TS center; |l|l|. _ T{ JOIN_STYLE_MITER T} T{ \fB0\fP T} _ T{ JOIN_STYLE_BEVEL T} T{ \fB1\fP T} _ T{ JOIN_STYLE_ROUND T} T{ \fB2\fP T} _ T{ JOIN_STYLE_DIAMOND T} T{ \fB3\fP T} _ T{ JOIN_STYLE_OBJECT T} T{ \fB5\fP T} _ .TE .SS Fill Style [image] .TS center; |l|l|. _ T{ FILL_STYLE_SOLID T} T{ \fB64\fP T} _ T{ FILL_STYLE_CHECKERBOARD T} T{ \fB65\fP T} _ T{ FILL_STYLE_CROSSHATCH T} T{ \fB66\fP T} _ T{ FILL_STYLE_DIAMONDS T} T{ \fB67\fP T} _ T{ FILL_STYLE_HORIZONTAL_BARS T} T{ \fB68\fP T} _ T{ FILL_STYLE_SLANT_LEFT T} T{ \fB69\fP T} _ T{ FILL_STYLE_SLANT_RIGHT T} T{ \fB70\fP T} _ T{ FILL_STYLE_SQUARE_DOTS T} T{ \fB71\fP T} _ T{ FILL_STYLE_VERICAL_BARS T} T{ \fB72\fP T} _ T{ FILL_STYLE_OBJECT T} T{ \fB73\fP T} _ .TE .SS Linetypes [image] [image] .TS center; |l|l|. _ T{ Linetype name T} T{ Value T} _ T{ Solid T} T{ 0 T} _ T{ Dashed T} T{ 1 T} _ T{ Dotted T} T{ 2 T} _ T{ Dash Dot T} T{ 3 T} _ T{ Short Dash T} T{ 4 T} _ T{ Medium Dash T} T{ 5 T} _ T{ Long Dash T} T{ 6 T} _ T{ Short Dash x2 T} T{ 7 T} _ T{ Medium Dash x2 T} T{ 8 T} _ T{ Long Dash x2 T} T{ 9 T} _ T{ Medium Lang Dash T} T{ 10 T} _ T{ Medium Dash Short Dash Short Dash T} T{ 11 T} _ T{ Long Dash Short Dash T} T{ 12 T} _ T{ Long Dash Dot Dot T} T{ 13 T} _ T{ Long Dash Dot T} T{ 14 T} _ T{ Medium Dash Dot Short Dash Dot T} T{ 15 T} _ T{ Sparse Dot T} T{ 16 T} _ T{ ISO Dash T} T{ 17 T} _ T{ ISO Dash Space T} T{ 18 T} _ T{ ISO Long Dash Dot T} T{ 19 T} _ T{ ISO Long Dash Double Dot T} T{ 20 T} _ T{ ISO Long Dash Triple Dot T} T{ 21 T} _ T{ ISO Dot T} T{ 22 T} _ T{ ISO Long Dash Short Dash T} T{ 23 T} _ T{ ISO Long Dash Double Short Dash T} T{ 24 T} _ T{ ISO Dash Dot T} T{ 25 T} _ T{ ISO Double Dash Dot T} T{ 26 T} _ T{ ISO Dash Double Dot T} T{ 27 T} _ T{ ISO Double Dash Double Dot T} T{ 28 T} _ T{ ISO Dash Triple Dot T} T{ 29 T} _ T{ ISO Double Dash Triple Dot T} T{ 30 T} _ T{ Use entity linetype T} T{ 31 T} _ .TE .SS Showcase Forms .SS MengerSponge .sp Build a 3D \fI\%Menger sponge\fP\&. .INDENT 0.0 .TP .B class ezdxf.addons.MengerSponge(location: \fI\%UVec\fP = (0.0, 0.0, 0.0), length: float = 1.0, level: int = 1, kind: int = 0) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlocation\fP – location of lower left corner as (x, y, z) tuple .IP \(bu 2 \fBlength\fP – side length .IP \(bu 2 \fBlevel\fP – subdivide level .IP \(bu 2 \fBkind\fP – type of menger sponge .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ 0 T} T{ Original Menger Sponge T} _ T{ 1 T} T{ Variant XOX T} _ T{ 2 T} T{ Variant OXO T} _ T{ 3 T} T{ Jerusalem Cube T} _ .TE .INDENT 7.0 .TP .B render(layout: GenericLayoutType, merge: bool = False, dxfattribs=None, matrix: \fI\%Matrix44\fP | None = None, ucs: \fI\%UCS\fP | None = None) -> None Renders the menger sponge into layout, set \fImerge\fP to \fBTrue\fP for rendering the whole menger sponge into one MESH entity, set \fImerge\fP to \fBFalse\fP for rendering the individual cubes of the menger sponge as MESH entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – DXF target layout .IP \(bu 2 \fBmerge\fP – \fBTrue\fP for one MESH entity, \fBFalse\fP for individual MESH entities per cube .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for the MESH entities .IP \(bu 2 \fBmatrix\fP – apply transformation matrix at rendering .IP \(bu 2 \fBucs\fP – apply UCS transformation at rendering .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B cubes() -> Iterator[MeshTransformer] Yields all cubes of the menger sponge as individual \fBMeshTransformer\fP objects. .UNINDENT .INDENT 7.0 .TP .B mesh() -> MeshTransformer Returns geometry as one \fBMeshTransformer\fP object. .UNINDENT .UNINDENT .sp Menger Sponge \fBkind=0\fP: [image] .sp Menger Sponge \fBkind=1\fP: [image] .sp Menger Sponge \fBkind=2\fP: [image] .sp Jerusalem Cube \fBkind=3\fP: [image] .SS SierpinskyPyramid .sp Build a 3D \fI\%Sierpinsky Pyramid\fP\&. .INDENT 0.0 .TP .B class ezdxf.addons.SierpinskyPyramid(location: \fI\%UVec\fP = (0.0, 0.0, 0.0), length: float = 1.0, level: int = 1, sides: int = 4) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlocation\fP – location of base center as (x, y, z) tuple .IP \(bu 2 \fBlength\fP – side length .IP \(bu 2 \fBlevel\fP – subdivide level .IP \(bu 2 \fBsides\fP – sides of base geometry .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render(layout: GenericLayoutType, merge: bool = False, dxfattribs=None, matrix: \fI\%Matrix44\fP | None = None, ucs: \fI\%UCS\fP | None = None) -> None Renders the sierpinsky pyramid into layout, set \fImerge\fP to \fBTrue\fP for rendering the whole sierpinsky pyramid into one MESH entity, set \fImerge\fP to \fBFalse\fP for individual pyramids as MESH entities. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – DXF target layout .IP \(bu 2 \fBmerge\fP – \fBTrue\fP for one MESH entity, \fBFalse\fP for individual MESH entities per pyramid .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for the MESH entities .IP \(bu 2 \fBmatrix\fP – apply transformation matrix at rendering .IP \(bu 2 \fBucs\fP – apply UCS at rendering .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B pyramids() -> Iterable[MeshTransformer] Yields all pyramids of the sierpinsky pyramid as individual \fBMeshTransformer\fP objects. .UNINDENT .INDENT 7.0 .TP .B mesh() -> MeshTransformer Returns geometry as one \fBMeshTransformer\fP object. .UNINDENT .UNINDENT .sp Sierpinsky Pyramid with triangle base: [image] .sp Sierpinsky Pyramid with square base: [image] .SS Bin\-Packing Add\-on .sp This add\-on is based on the 3D bin packing module \fI\%py3dbp\fP hosted on \fI\%PyPI\fP\&. Both sources of this package are MIT licensed like \fIezdxf\fP itself. .SS The Bin Packing Problem .sp Quote from the \fI\%Wikipedia\fP article: .INDENT 0.0 .INDENT 3.5 The bin packing problem is an optimization problem, in which items of different sizes must be packed into a finite number of bins or containers, each of a fixed given capacity, in a way that minimizes the number of bins used. .UNINDENT .UNINDENT .SS Example .sp This code replicates the example used by the \fI\%py3dbp\fP package: .INDENT 0.0 .INDENT 3.5 .sp .EX from typing import List import ezdxf from ezdxf import colors from ezdxf.addons import binpacking as bp SMALL_ENVELOPE = (\(dqsmall\-envelope\(dq, 11.5, 6.125, 0.25, 10) LARGE_ENVELOPE = (\(dqlarge\-envelope\(dq, 15.0, 12.0, 0.75, 15) SMALL_BOX = (\(dqsmall\-box\(dq, 8.625, 5.375, 1.625, 70.0) MEDIUM_BOX = (\(dqmedium\-box\(dq, 11.0, 8.5, 5.5, 70.0) MEDIUM_BOX2 = (\(dqmedium\-box\-2\(dq, 13.625, 11.875, 3.375, 70.0) LARGE_BOX = (\(dqlarge\-box\(dq, 12.0, 12.0, 5.5, 70.0) LARGE_BOX2 = (\(dqlarge\-box\-2\(dq, 23.6875, 11.75, 3.0, 70.0) ALL_BINS = [ SMALL_ENVELOPE, LARGE_ENVELOPE, SMALL_BOX, MEDIUM_BOX, MEDIUM_BOX2, LARGE_BOX, LARGE_BOX2, ] def build_packer(): packer = bp.Packer() packer.add_item(\(dq50g [powder 1]\(dq, 3.9370, 1.9685, 1.9685, 1) packer.add_item(\(dq50g [powder 2]\(dq, 3.9370, 1.9685, 1.9685, 2) packer.add_item(\(dq50g [powder 3]\(dq, 3.9370, 1.9685, 1.9685, 3) packer.add_item(\(dq250g [powder 4]\(dq, 7.8740, 3.9370, 1.9685, 4) packer.add_item(\(dq250g [powder 5]\(dq, 7.8740, 3.9370, 1.9685, 5) packer.add_item(\(dq250g [powder 6]\(dq, 7.8740, 3.9370, 1.9685, 6) packer.add_item(\(dq250g [powder 7]\(dq, 7.8740, 3.9370, 1.9685, 7) packer.add_item(\(dq250g [powder 8]\(dq, 7.8740, 3.9370, 1.9685, 8) packer.add_item(\(dq250g [powder 9]\(dq, 7.8740, 3.9370, 1.9685, 9) return packer def make_doc(): doc = ezdxf.new() doc.layers.add(\(dqFRAME\(dq, color=colors.YELLOW) doc.layers.add(\(dqITEMS\(dq) doc.layers.add(\(dqTEXT\(dq) return doc def main(filename): bins: List[bp.Bin] = [] for box in ALL_BINS: packer = build_packer() packer.add_bin(*box) packer.pack(bp.PickStrategy.BIGGER_FIRST) bins.extend(packer.bins) doc = make_doc() bp.export_dxf(doc.modelspace(), bins, offset=(0, 20, 0)) doc.saveas(filename) if __name__ == \(dq__main__\(dq: main(\(dqpy3dbp_example.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%example1\fP script .IP \(bu 2 \fI\%example2\fP script .UNINDENT .UNINDENT .UNINDENT .SS Packer Classes .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.AbstractPacker .INDENT 7.0 .TP .B bins List of containers to fill. .UNINDENT .INDENT 7.0 .TP .B items List of items to pack into the \fI\%bins\fP\&. .UNINDENT .INDENT 7.0 .TP .B property is_packed: bool Returns \fBTrue\fP if packer is packed, each packer can only be used once. .UNINDENT .INDENT 7.0 .TP .B property unfitted_items: list[\fI\%Item\fP] Returns the unfitted items. .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Return str(self). .UNINDENT .INDENT 7.0 .TP .B append_bin(box: \fI\%Bin\fP) -> None Append a container. .UNINDENT .INDENT 7.0 .TP .B append_item(item: \fI\%Item\fP) -> None Append a item. .UNINDENT .INDENT 7.0 .TP .B get_fill_ratio() -> float Return the fill ratio of all bins. .UNINDENT .INDENT 7.0 .TP .B get_capacity() -> float Returns the maximum fill volume of all bins. .UNINDENT .INDENT 7.0 .TP .B get_total_weight() -> float Returns the total weight of all fitted items in all bins. .UNINDENT .INDENT 7.0 .TP .B get_total_volume() -> float Returns the total volume of all fitted items in all bins. .UNINDENT .INDENT 7.0 .TP .B pack(pick=PickStrategy.BIGGER_FIRST) -> None Pack items into bins. Distributes all items across all bins. .UNINDENT .UNINDENT .SS Packer .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.Packer 3D Packer inherited from \fI\%AbstractPacker\fP\&. .INDENT 7.0 .TP .B add_bin(name: str, width: float, height: float, depth: float, max_weight: float = UNLIMITED_WEIGHT) -> \fI\%Box\fP Add a 3D \fI\%Box\fP container. .UNINDENT .INDENT 7.0 .TP .B add_item(payload, width: float, height: float, depth: float, weight: float = 0.0) -> \fI\%Item\fP Add a 3D \fI\%Item\fP to pack. .UNINDENT .UNINDENT .SS FlatPacker .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.FlatPacker 2D Packer inherited from \fI\%AbstractPacker\fP\&. All containers and items used by this packer must have a depth of 1. .INDENT 7.0 .TP .B add_bin(name: str, width: float, height: float, max_weight: float = UNLIMITED_WEIGHT) -> \fI\%Envelope\fP Add a 2D \fI\%Envelope\fP container. .UNINDENT .INDENT 7.0 .TP .B add_item(payload, width: float, height: float, weight: float = 0.0) -> \fI\%Item\fP Add a 2D \fI\%FlatItem\fP to pack. .UNINDENT .UNINDENT .SS Bin Classes .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.Bin(name, width: float, height: float, depth: float, max_weight: float = UNLIMITED_WEIGHT) .INDENT 7.0 .TP .B name Name of then container as string. .UNINDENT .INDENT 7.0 .TP .B width .UNINDENT .INDENT 7.0 .TP .B height .UNINDENT .INDENT 7.0 .TP .B depth .UNINDENT .INDENT 7.0 .TP .B max_weight .UNINDENT .INDENT 7.0 .TP .B property is_empty: bool .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Return str(self). .UNINDENT .INDENT 7.0 .TP .B copy() Returns a copy. .UNINDENT .INDENT 7.0 .TP .B reset() Reset the container to empty state. .UNINDENT .INDENT 7.0 .TP .B put_item(item: \fI\%Item\fP, pivot: tuple[float, float, float]) -> bool .UNINDENT .INDENT 7.0 .TP .B get_capacity() -> float Returns the maximum fill volume of the bin. .UNINDENT .INDENT 7.0 .TP .B get_total_weight() -> float Returns the total weight of all fitted items. .UNINDENT .INDENT 7.0 .TP .B get_total_volume() -> float Returns the total volume of all fitted items. .UNINDENT .INDENT 7.0 .TP .B get_fill_ratio() -> float Return the fill ratio. .UNINDENT .UNINDENT .SS Box Class .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.Box(name, width: float, height: float, depth: float, max_weight: float = UNLIMITED_WEIGHT) 3D container inherited from \fI\%Bin\fP\&. .UNINDENT .SS Envelope Class .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.Envelope(name, width: float, height: float, max_weight: float = UNLIMITED_WEIGHT) 2D container inherited from \fI\%Bin\fP\&. .UNINDENT .SS Item Class .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.Item(payload, width: float, height: float, depth: float, weight: float = 0.0) 3D container item. .INDENT 7.0 .TP .B payload Arbitrary Python object. .UNINDENT .INDENT 7.0 .TP .B width .UNINDENT .INDENT 7.0 .TP .B height .UNINDENT .INDENT 7.0 .TP .B depth .UNINDENT .INDENT 7.0 .TP .B weight .UNINDENT .INDENT 7.0 .TP .B property bbox: AbstractBoundingBox .UNINDENT .INDENT 7.0 .TP .B property rotation_type: \fI\%RotationType\fP .UNINDENT .INDENT 7.0 .TP .B property position: tuple[float, float, float] Returns the position of then lower left corner of the item in the container, the lower left corner is the origin (0, 0, 0). .UNINDENT .INDENT 7.0 .TP .B copy() Returns a copy, all copies have a reference to the same payload object. .UNINDENT .INDENT 7.0 .TP .B __str__() Return str(self). .UNINDENT .INDENT 7.0 .TP .B get_volume() -> float Returns the volume of the item. .UNINDENT .INDENT 7.0 .TP .B get_dimension() -> tuple[float, float, float] Returns the item dimension according the \fI\%rotation_type\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_transformation() -> \fI\%Matrix44\fP Returns the transformation matrix to transform the source entity located with the minimum extension corner of its bounding box in (0, 0, 0) to the final location including the required rotation. .UNINDENT .UNINDENT .SS FlatItem Class .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.FlatItem(payload, width: float, height: float, weight: float = 0.0) 2D container item, inherited from \fI\%Item\fP\&. Has a default depth of 1.0. .UNINDENT .SS Functions .INDENT 0.0 .TP .B ezdxf.addons.binpacking.shuffle_pack(packer: \fI\%AbstractPacker\fP, attempts: int) -> \fI\%AbstractPacker\fP Random shuffle packing. Returns a new packer with the best packing result, the input packer is unchanged. .UNINDENT .SS Enums .SS RotationType .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.RotationType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Rotation type of an item: .INDENT 7.0 .IP \(bu 2 W = width .IP \(bu 2 H = height .IP \(bu 2 D = depth .UNINDENT .INDENT 7.0 .TP .B WHD .UNINDENT .INDENT 7.0 .TP .B HWD .UNINDENT .INDENT 7.0 .TP .B HDW .UNINDENT .INDENT 7.0 .TP .B DHW .UNINDENT .INDENT 7.0 .TP .B DWH .UNINDENT .INDENT 7.0 .TP .B WDH .UNINDENT .UNINDENT .SS PickStrategy .INDENT 0.0 .TP .B class ezdxf.addons.binpacking.PickStrategy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) Order of how to pick items for placement. .INDENT 7.0 .TP .B BIGGER_FIRST .UNINDENT .INDENT 7.0 .TP .B SMALLER_FIRST .UNINDENT .INDENT 7.0 .TP .B SHUFFLE .UNINDENT .UNINDENT .SS Credits .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%py3dbp\fP package by Enzo Ruiz Pelaez .IP \(bu 2 \fI\%bp3d\fP by \fIgedex\fP \- github repository on which \fI\%py3dbp\fP is based, written in Go .IP \(bu 2 Optimizing three\-dimensional bin packing through simulation (\fI\%PDF\fP) .UNINDENT .UNINDENT .UNINDENT .SS MeshExchange .sp The \fI\%ezdxf.addons.meshex\fP module provides functions to exchange meshes with other tools in the following file formats: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%STL\fP: import/export, supports only triangles as faces .IP \(bu 2 \fI\%OFF\fP: import/export, supports ngons as faces and is more compact than STL .IP \(bu 2 \fI\%OBJ\fP: import/export, supports ngons as faces and can contain multiple meshes in one file .IP \(bu 2 \fI\%PLY\fP: export only, supports ngons as faces .IP \(bu 2 \fI\%OpenSCAD\fP: export as \fI\%polyhedron\fP, supports ngons as faces .IP \(bu 2 \fI\%IFC4\fP: export only, supports ngons as faces .UNINDENT .UNINDENT .UNINDENT .sp The source or target object is always a \fI\%MeshBuilder\fP instance and therefore the supported features are also limited by this class. Only vertices and faces are exchanged, colors, textures and explicit face\- and vertex normals are lost. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This add\-on is not a replacement for a proper file format interface for this data formats! It’s just a simple way to exchange meshes with other tools like \fI\%OpenSCAD\fP or \fI\%MeshLab\fP\&. .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The meshes created by the \fI\%ezdxf.addons.pycsg\fP add\-on are usually not suitable for export because they often violate the vertex\-to\-vertex rule: A vertex of a face cannot lie on the edge of another face. This was one of the reasons to create this addon to get an interface to \fI\%OpenSCAD\fP\&. .UNINDENT .UNINDENT .sp Example for a simple STL to DXF converter: .INDENT 0.0 .INDENT 3.5 .sp .EX import sys import ezdxf from ezdxf.addons import meshex try: mesh = meshex.stl_readfile(\(dqyour.stl\(dq) except (meshex.ParsingError, IOError) as e: print(str(e)) sys.exit(1) doc = ezdxf.new() mesh.render_mesh(doc.modelspace()) doc.saveas(\(dqyour.dxf\(dq) .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Example script \fI\%meshex_export.py\fP at github. .UNINDENT .UNINDENT .SS Import .INDENT 0.0 .TP .B ezdxf.addons.meshex.stl_readfile(filename: str | PathLike) -> MeshTransformer Read ascii or binary \fI\%STL\fP file content as \fI\%ezdxf.render.MeshTransformer\fP instance. .INDENT 7.0 .TP .B Raises \fI\%ParsingError\fP – vertex parsing error or invalid/corrupt data .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.stl_loads(content: str) -> MeshTransformer Load a mesh from an ascii \fI\%STL\fP content string as \fI\%ezdxf.render.MeshTransformer\fP instance. .INDENT 7.0 .TP .B Raises \fI\%ParsingError\fP – vertex parsing error .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.stl_loadb(buffer: bytes) -> MeshTransformer Load a mesh from a binary \fI\%STL\fP data \fI\%ezdxf.render.MeshTransformer\fP instance. .INDENT 7.0 .TP .B Raises \fI\%ParsingError\fP – invalid/corrupt data or not a binary STL file .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.off_readfile(filename: str | PathLike) -> MeshTransformer Read \fI\%OFF\fP file content as \fI\%ezdxf.render.MeshTransformer\fP instance. .INDENT 7.0 .TP .B Raises \fI\%ParsingError\fP – vertex or face parsing error .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.off_loads(content: str) -> MeshTransformer Load a mesh from a \fI\%OFF\fP content string as \fI\%ezdxf.render.MeshTransformer\fP instance. .INDENT 7.0 .TP .B Raises \fI\%ParsingError\fP – vertex or face parsing error .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.obj_readfile(filename: str | PathLike) -> list[MeshTransformer] Read \fI\%OBJ\fP file content as list of \fI\%ezdxf.render.MeshTransformer\fP instances. .INDENT 7.0 .TP .B Raises \fI\%ParsingError\fP – vertex or face parsing error .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.obj_loads(content: str) -> list[MeshTransformer] Load one or more meshes from an \fI\%OBJ\fP content string as list of \fI\%ezdxf.render.MeshTransformer\fP instances. .INDENT 7.0 .TP .B Raises \fI\%ParsingError\fP – vertex parsing error .UNINDENT .UNINDENT .SS Export .INDENT 0.0 .TP .B ezdxf.addons.meshex.stl_dumps(mesh: MeshBuilder) -> str Returns the \fI\%STL\fP data as string for the given \fImesh\fP\&. This function triangulates the meshes automatically because the \fI\%STL\fP format supports only triangles as faces. .sp This function does not check if the mesh obey the \fI\%STL\fP format \fI\%rules\fP: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 The direction of the face normal is outward. .IP \(bu 2 The face vertices are listed in counter\-clockwise order when looking at the object from the outside (right\-hand rule). .IP \(bu 2 Each triangle must share two vertices with each of its adjacent triangles. .IP \(bu 2 The object represented must be located in the all\-positive octant (non\-negative and nonzero). .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.stl_dumpb(mesh: MeshBuilder) -> bytes Returns the \fI\%STL\fP binary data as bytes for the given \fImesh\fP\&. .sp For more information see function: \fI\%stl_dumps()\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.off_dumps(mesh: MeshBuilder) -> str Returns the \fI\%OFF\fP data as string for the given \fImesh\fP\&. The \fI\%OFF\fP format supports ngons as faces. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.obj_dumps(mesh: MeshBuilder) -> str Returns the \fI\%OBJ\fP data as string for the given \fImesh\fP\&. The \fI\%OBJ\fP format supports ngons as faces. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.ply_dumpb(mesh: MeshBuilder) -> bytes Returns the \fI\%PLY\fP binary data as bytes for the given \fImesh\fP\&. The \fI\%PLY\fP format supports ngons as faces. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.scad_dumps(mesh: MeshBuilder) -> str Returns the \fI\%OpenSCAD\fP \fI\%polyhedron\fP definition as string for the given \fImesh\fP\&. \fI\%OpenSCAD\fP supports ngons as faces. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 \fI\%OpenSCAD\fP requires the face normals pointing inwards, the method \fI\%flip_normals()\fP of the \fI\%MeshBuilder\fP class can flip the normals inplace. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.ifc4_dumps(mesh: MeshBuilder, entity_type=IfcEntityType.POLYGON_FACE_SET, *, layer: str = \(aqMeshExport\(aq, color: tuple[float, float, float] = (1.0, 1.0, 1.0)) -> str Returns the \fI\%IFC4\fP string for the given \fImesh\fP\&. The caller is responsible for checking if the mesh is a closed or open surface (e.g. \fBmesh.diagnose().euler_characteristic == 2\fP) and using the appropriate entity type. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmesh\fP – \fI\%MeshBuilder\fP .IP \(bu 2 \fBentity_type\fP – \fI\%IfcEntityType\fP .IP \(bu 2 \fBlayer\fP – layer name as string .IP \(bu 2 \fBcolor\fP – entity color as RGB tuple, values in the range [0,1] .UNINDENT .UNINDENT .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 \fI\%IFC4\fP is a very complex data format and this is a minimal effort exporter, so the exported data may not be importable by all CAD applications. .sp The exported \fI\%IFC4\fP data can be imported by the following applications: .INDENT 0.0 .IP \(bu 2 BricsCAD .IP \(bu 2 FreeCAD (IfcOpenShell) .IP \(bu 2 Allplan .IP \(bu 2 Tekla BIMsight .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.meshex.export_ifcZIP(filename: str | PathLike, mesh: MeshBuilder, entity_type=IfcEntityType.POLYGON_FACE_SET, *, layer: str = \(aqMeshExport\(aq, color: tuple[float, float, float] = (1.0, 1.0, 1.0)) Export the given \fImesh\fP as zip\-compressed \fI\%IFC4\fP file. The filename suffix should be \fB\&.ifcZIP\fP\&. For more information see function \fI\%ifc4_dumps()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP – zip filename, the data file has the same name with suffix \fB\&.ifc\fP .IP \(bu 2 \fBmesh\fP – \fI\%MeshBuilder\fP .IP \(bu 2 \fBentity_type\fP – \fI\%IfcEntityType\fP .IP \(bu 2 \fBlayer\fP – layer name as string .IP \(bu 2 \fBcolor\fP – entity color as RGB tuple, values in the range [0,1] .UNINDENT .TP .B Raises \fBIOError\fP – IO error when opening the zip\-file for writing .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.meshex.IfcEntityType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None) .INDENT 7.0 .TP .B POLYGON_FACE_SET “SurfaceModel” representation usable for open or closed surfaces. .UNINDENT .INDENT 7.0 .TP .B CLOSED_SHELL “Brep” representation usable for closed surfaces. .UNINDENT .INDENT 7.0 .TP .B OPEN_SHELL “SurfaceModel” representation usable for open surfaces. .UNINDENT .UNINDENT .SS OpenSCAD .sp Interface to the \fI\%OpenSCAD\fP application to apply boolean operations to \fI\%MeshBuilder\fP objects. For more information about boolean operations read the documentation of \fI\%OpenSCAD\fP\&. The \fI\%OpenSCAD\fP application is not bundled with \fIezdxf\fP, you need to install the application yourself. .sp On Windows the path to the \fBopenscad.exe\fP executable is stored in the config file (see \fI\%ezdxf.options\fP) in the “openscad\-addon” section as key “win_exec_path”, the default entry is: .INDENT 0.0 .INDENT 3.5 .sp .EX [openscad\-addon] win_exec_path = \(dqC:\eProgram Files\eOpenSCAD\eopenscad.exe\(dq .EE .UNINDENT .UNINDENT .sp On Linux and macOS the \fBopenscad\fP command is located by the \fBshutil.which()\fP function. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.render import forms from ezdxf.addons import MengerSponge, openscad doc = ezdxf.new() msp = doc.modelspace() # 1. create the meshes: sponge = MengerSponge(level=3).mesh() sponge.flip_normals() # important for OpenSCAD sphere = forms.sphere( count=32, stacks=16, radius=0.5, quads=True ).translate(0.25, 0.25, 1) sphere.flip_normals() # important for OpenSCAD # 2. create the script: script = openscad.boolean_operation(openscad.DIFFERENCE, sponge, sphere) # 3. execute the script by OpenSCAD: result = openscad.run(script) # 4. render the MESH entity: result.render_mesh(msp) doc.set_modelspace_vport(6, center=(5, 0)) doc.saveas(\(dqOpenSCAD.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .SS Functions .INDENT 0.0 .TP .B ezdxf.addons.openscad.run(script: str, exec_path: str | None = None) -> MeshTransformer Executes the given \fIscript\fP by OpenSCAD and returns the result mesh as \fI\%MeshTransformer\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscript\fP – the OpenSCAD script as string .IP \(bu 2 \fBexec_path\fP – path to the executable as string or \fBNone\fP to use the default installation path .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.openscad.boolean_operation(op: Operation, mesh1: MeshBuilder, mesh2: MeshBuilder) -> str Returns an \fI\%OpenSCAD\fP script to apply the given boolean operation to the given meshes. .sp The supported operations are: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 UNION .IP \(bu 2 DIFFERENCE .IP \(bu 2 INTERSECTION .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.openscad.is_installed() -> bool Returns \fBTrue\fP if OpenSCAD is installed. On Windows only the default install path ‘C:\eProgram Files\eOpenSCAD\eopenscad.exe’ is checked. .UNINDENT .SS Script Class .INDENT 0.0 .TP .B class ezdxf.addons.openscad.Script Helper class to build OpenSCAD scripts. This is a very simple string building class and does no checks at all! If you need more advanced features to build OpenSCAD scripts look at the packages \fI\%pysolid\fP and \fI\%openpyscad\fP\&. .INDENT 7.0 .TP .B add(data: str) -> None Add a string. .UNINDENT .INDENT 7.0 .TP .B add_mirror(v: \fI\%UVec\fP) -> None Add a \fBmirror()\fP operation. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#mirror\fP .INDENT 7.0 .TP .B Parameters \fBv\fP – the normal vector of a plane intersecting the origin through which to mirror the object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_multmatrix(m: \fI\%Matrix44\fP) -> None Add a transformation matrix of type \fI\%Matrix44\fP as \fBmultmatrix()\fP operation. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#multmatrix\fP .UNINDENT .INDENT 7.0 .TP .B add_polyhedron(mesh: MeshBuilder) -> None Add \fImesh\fP as \fBpolyhedron()\fP command. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron\fP .UNINDENT .INDENT 7.0 .TP .B add_polygon(path: Iterable[\fI\%UVec\fP], holes: Sequence[Iterable[\fI\%UVec\fP]] | None = None) -> None Add a \fBpolygon()\fP command. This is a 2D command, all z\-axis values of the input vertices are ignored and all paths and holes are closed automatically. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#polygon\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpath\fP – exterior path .IP \(bu 2 \fBholes\fP – a sequence of one or more holes as vertices, or \fBNone\fP for no holes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_resize(nx: float, ny: float, nz: float, auto: bool | tuple[bool, bool, bool] | None = None) -> None Add a \fBresize()\fP operation. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#resize\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBnx\fP – new size in x\-axis .IP \(bu 2 \fBny\fP – new size in y\-axis .IP \(bu 2 \fBnz\fP – new size in z\-axis .IP \(bu 2 \fBauto\fP – If the \fIauto\fP argument is set to \fBTrue\fP, the operation auto\-scales any 0\-dimensions to match. Set the \fIauto\fP argument as a 3\-tuple of bool values to auto\-scale individual axis. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_rotate(ax: float, ay: float, az: float) -> None Add a \fBrotation()\fP operation. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#rotate\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBax\fP – rotation about the x\-axis in degrees .IP \(bu 2 \fBay\fP – rotation about the y\-axis in degrees .IP \(bu 2 \fBaz\fP – rotation about the z\-axis in degrees .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_rotate_about_axis(a: float, v: \fI\%UVec\fP) -> None Add a \fBrotation()\fP operation about the given axis \fIv\fP\&. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#rotate\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBa\fP – rotation angle about axis \fIv\fP in degrees .IP \(bu 2 \fBv\fP – rotation axis as \fI\%ezdxf.math.UVec\fP object .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_scale(sx: float, sy: float, sz: float) -> None Add a \fBscale()\fP operation. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#scale\fP .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsx\fP – scaling factor for the x\-axis .IP \(bu 2 \fBsy\fP – scaling factor for the y\-axis .IP \(bu 2 \fBsz\fP – scaling factor for the z\-axis .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_translate(v: \fI\%UVec\fP) -> None Add a \fBtranslate()\fP operation. .sp OpenSCAD docs: \fI\%https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#translate\fP .INDENT 7.0 .TP .B Parameters \fBv\fP – translation vector .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_string() -> str Returns the OpenSCAD build script. .UNINDENT .UNINDENT .SS Boolean Operation Constants .INDENT 0.0 .TP .B ezdxf.addons.openscad.UNION .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.openscad.DIFFERENCE .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.openscad.INTERSECTION .UNINDENT .SS openpyscad .sp This add\-on is not a complete wrapper around \fI\%OpenSCAD\fP, if you need such a tool look at the \fI\%openpyscad\fP or \fI\%pysolid\fP packages at PyPI. .sp Not sure if the \fI\%openpyscad\fP package is still maintained, the last commit at \fI\%github\fP is more than a year old and did not pass the CI process! (state June 2022) .sp This code snippet shows how to get the \fI\%MeshTransformer\fP object from the basic \fI\%openpyscad\fP example: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons import openscad import openpyscad as ops c1 = ops.Cube([10, 20, 10]) c2 = ops.Cube([20, 10, 10]) # dump OpenSCAD script as string: script = (c1 + c2).dumps() # execute script and load the result as MeshTransformer instance: mesh = openscad.run(script) .EE .UNINDENT .UNINDENT .sp Create an \fI\%openpyscad\fP \fBPolyhedron\fP object from an \fIezdxf\fP \fI\%MeshBuilder\fP object: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.render import forms import openpyscad as ops # create an ezdxf MeshBuilder() object sphere = forms.sphere() sphere.flip_normals() # required for OpenSCAD # create an openpyscad Polyhedron() object polyhedron = ops.Polyhedron( points=[list(p) for p in sphere.vertices], # convert Vec3 objects to lists! faces=[list(f) for f in sphere.faces], # convert face tuples to face lists! ) # create the OpenSCAD script: script = polyhedron.dumps() .EE .UNINDENT .UNINDENT .sp The type conversion is needed to get valid \fI\%OpenSCAD\fP code from \fI\%openpyscad\fP! .SS pysolid .sp The \fI\%pysolid\fP package seems to be better maintained than the \fI\%openpyscad\fP package, but this is just an opinion based on newer commits at github (\fI\%link\fP) for the \fI\%pysolid\fP package. .sp Same example for \fI\%pysolid\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.addons import openscad from solid import cube, render_scad c1 = cube([10, 20, 10]) c2 = cube([20, 10, 10]) # dump OpenSCAD script as string: script = render_scad(c1 + c2) # execute script and load the result as MeshTransformer instance: mesh = openscad.run(script) .EE .UNINDENT .UNINDENT .sp Create a \fI\%pysolid\fP \fBpolyhedron\fP object from an \fIezdxf\fP \fI\%MeshBuilder\fP object: .INDENT 0.0 .INDENT 3.5 .sp .EX from ezdxf.render import forms from solid import polyhedron, scad_render # create an ezdxf MeshBuilder() object sphere = forms.sphere() sphere.flip_normals() # required for OpenSCAD # create a pysolid polyhedron() object ph = polyhedron( points=[v.xyz for v in sphere.vertices], # convert Vec3 objects to tuples! faces=sphere.faces, # types are compatible ) # create the OpenSCAD script: script = scad_render(ph) .EE .UNINDENT .UNINDENT .SS TablePainter .sp This is an add\-on for drawing tables build from DXF primitives. .sp This add\-on was created for porting \fBdxfwrite\fP projects to \fBezdxf\fP and was not officially documented for \fBezdxf\fP versions prior the 1.0 release. For the 1.0 version of \fBezdxf\fP, this class was added as an officially documented add\-on because full support for the ACAD_TABLE entity is very unlikely due to the enormous complexity for both the entity itself, and for the required infrastructure and also the lack of a usable documentation to implement all that features. .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 This add\-on is not related to the ACAD_TABLE entity at all and and does not create ACAD_TABLE entities! .UNINDENT .UNINDENT .sp The table cells can contain multi\-line text or BLOCK references. You can create your own cell types by extending the \fI\%CustomCell\fP class. The cells are addressed by zero\-based row and column indices. A table cell can span over multiple columns and/or rows. .sp A \fI\%TextCell\fP can contain multi\-line text with an arbitrary rotation angle or letters stacked from top to bottom. The \fI\%MTextSurrogate\fP add\-on is used to create multi\-line text compatible to DXF version R12. .sp A \fI\%BlockCell\fP contains block references (INSERT entities), if the block definition contains attribute definitions as ATTDEF entities, these attributes can be added automatically to the block reference as ATTRIB entities. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The DXF format does not support clipping boxes ot paths, therefore the render method of any cell can render beyond the borders of the cell! .UNINDENT .UNINDENT .SS Tutorial .sp Set up a new DXF document: .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.enums import MTextEntityAlignment from ezdxf.addons import TablePainter doc = ezdxf.new(\(dqR2000\(dq) # required for lineweight support doc.header[\(dq$LWDISPLAY\(dq] = 1 # show lineweights doc.styles.add(\(dqHEAD\(dq, font=\(dqOpenSans\-ExtraBold.ttf\(dq) doc.styles.add(\(dqCELL\(dq, font=\(dqOpenSans\-Regular.ttf\(dq) .EE .UNINDENT .UNINDENT .sp Create a new \fI\%TablePainter\fP object with four rows and four columns, the insert location is the default render location but can be overriden in the \fBrender()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .EX table = TablePainter( insert=(0, 0), nrows=4, ncols=4, cell_width=6.0, cell_height=2.0 ) .EE .UNINDENT .UNINDENT .sp Create a new \fI\%CellStyle\fP object for the table\-header called “head”: .INDENT 0.0 .INDENT 3.5 .sp .EX table.new_cell_style( \(dqhead\(dq, text_style=\(dqHEAD\(dq, text_color=ezdxf.colors.BLUE, char_height=0.7, bg_color=ezdxf.colors.LIGHT_GRAY, align=MTextEntityAlignment.MIDDLE_CENTER, ) .EE .UNINDENT .UNINDENT .sp Redefine the default \fI\%CellStyle\fP for the content cells: .INDENT 0.0 .INDENT 3.5 .sp .EX # reset default cell style default_style = table.get_cell_style(\(dqdefault\(dq) default_style.text_style = \(dqCELL\(dq default_style.char_height = 0.5 default_style.align = MTextEntityAlignment.BOTTOM_LEFT .EE .UNINDENT .UNINDENT .sp Set the table\-header content: .INDENT 0.0 .INDENT 3.5 .sp .EX for col in range(4): table.text_cell(0, col, f\(dqHead[{col}]\(dq, style=\(dqhead\(dq) .EE .UNINDENT .UNINDENT .sp Set the cell content: .INDENT 0.0 .INDENT 3.5 .sp .EX for row in range(1, 4): for col in range(4): # cell style is \(dqdefault\(dq table.text_cell(row, col, f\(dqCell[{row}, {col}]\(dq) .EE .UNINDENT .UNINDENT .sp Add a red frame around the table\-header: .INDENT 0.0 .INDENT 3.5 .sp .EX # new cell style is required red_frame = table.new_cell_style(\(dqred\-frame\(dq) red_borderline = table.new_border_style(color=ezdxf.colors.RED, lineweight=35) # set the red borderline style for all cell borders red_frame.set_border_style(red_borderline) # create the frame object table.frame(0, 0, 4, style=\(dqred\-frame\(dq) .EE .UNINDENT .UNINDENT .sp Render the table into the modelspace and export the DXF file: .INDENT 0.0 .INDENT 3.5 .sp .EX # render the table, shifting the left\-bottom of the table to the origin: table.render(doc.modelspace(), insert=(0, table.table_height)) th = table.table_height tw = table.table_width doc.set_modelspace_vport(height=th * 1.5, center=(tw/2, th/2)) doc.saveas(\(dqtable_tutorial.dxf\(dq) .EE .UNINDENT .UNINDENT [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Example script: \fI\%table_painter_addon.py\fP .UNINDENT .UNINDENT .UNINDENT .SS TablePainter .INDENT 0.0 .TP .B class ezdxf.addons.tablepainter.TablePainter(insert: \fI\%UVec\fP, nrows: int, ncols: int, cell_width=DEFAULT_CELL_WIDTH, cell_height=DEFAULT_CELL_HEIGHT, default_grid=True) The TablePainter class renders tables build from DXF primitives. .sp The TablePainter instance contains all the data cells. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinsert\fP – insert location as or \fI\%UVec\fP .IP \(bu 2 \fBnrows\fP – row count .IP \(bu 2 \fBncols\fP – column count .IP \(bu 2 \fBcell_width\fP – default cell width in drawing units .IP \(bu 2 \fBcell_height\fP – default cell height in drawing units .IP \(bu 2 \fBdefault_grid\fP – draw a grid of solid lines if \fBTrue\fP, otherwise draw only explicit defined borders, the default grid has a priority of 50. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B bg_layer_name: str background layer name, layer for the background SOLID entities, default is “TABLEBACKGROUND” .UNINDENT .INDENT 7.0 .TP .B fg_layer_name: str foreground layer name, layer for the cell content, default is “TABLECONTENT” .UNINDENT .INDENT 7.0 .TP .B grid_layer_name: str table grid layer name, layer for the cell border lines, default is “TABLEGRID” .UNINDENT .INDENT 7.0 .TP .B property table_width: float Returns the total table width. .UNINDENT .INDENT 7.0 .TP .B property table_height: float Returns the total table height. .UNINDENT .INDENT 7.0 .TP .B set_col_width(index: int, value: float) Set column width in drawing units of the given column index. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBindex\fP – zero based column index .IP \(bu 2 \fBvalue\fP – new column width in drawing units .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_row_height(index: int, value: float) Set row height in drawing units of the given row index. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBindex\fP – zero based row index .IP \(bu 2 \fBvalue\fP – new row height in drawing units .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B text_cell(row: int, col: int, text: str, span: tuple[int, int] = (1, 1), style=\(aqdefault\(aq) -> \fI\%TextCell\fP Factory method to create a new text cell at location (row, col), with \fItext\fP as content, the \fItext\fP can be a line breaks \fB\(aq\en\(aq\fP\&. The final cell can spread over several cells defined by the argument \fIspan\fP\&. .UNINDENT .INDENT 7.0 .TP .B block_cell(row: int, col: int, blockdef: \fI\%BlockLayout\fP, span: tuple[int, int] = (1, 1), attribs=None, style=\(aqdefault\(aq) -> \fI\%BlockCell\fP Factory method to Create a new block cell at position (row, col). .sp Content is a block reference inserted by an INSERT entity, attributes will be added if the block definition contains ATTDEF. Assignments are defined by attribs\-key to attdef\-tag association. .sp Example: attribs = {‘num’: 1} if an ATTDEF with tag==’num’ in the block definition exists, an attrib with text=str(1) will be created and added to the insert entity. .sp The cell spans over ‘span’ cells and has the cell style with the name ‘style’. .UNINDENT .INDENT 7.0 .TP .B set_cell(row: int, col: int, cell: T) -> T Insert a cell at position (row, col). .UNINDENT .INDENT 7.0 .TP .B get_cell(row: int, col: int) -> \fI\%Cell\fP Get cell at location (row, col). .UNINDENT .INDENT 7.0 .TP .B new_cell_style(name: str, **kwargs) -> \fI\%CellStyle\fP Factory method to create a new \fI\%CellStyle\fP object, overwrites an already existing cell style. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – style name as string .IP \(bu 2 \fBkwargs\fP – see attributes of class \fI\%CellStyle\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_cell_style(name: str) -> \fI\%CellStyle\fP Get cell style by name. .UNINDENT .INDENT 7.0 .TP .B static new_border_style(color: int = const.BYLAYER, status=True, priority: int = 100, linetype: str = \(aqBYLAYER\(aq, lineweight: int = const.LINEWEIGHT_BYLAYER) -> \fI\%BorderStyle\fP Factory method to create a new border style. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstatus\fP – \fBTrue\fP for visible, \fBFalse\fP for invisible .IP \(bu 2 \fBcolor\fP – \fI\%AutoCAD Color Index (ACI)\fP .IP \(bu 2 \fBlinetype\fP – linetype name, default is “BYLAYER” .IP \(bu 2 \fBlineweight\fP – lineweight as int, default is by layer .IP \(bu 2 \fBpriority\fP – drawing priority, higher priorities cover lower priorities .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B frame(row: int, col: int, width: int = 1, height: int = 1, style=\(aqdefault\(aq) -> Frame Creates a frame around the give cell area, starting at (row, col) and covering \fIwidth\fP columns and \fIheight\fP rows. The \fIstyle\fP argument is the name of a \fI\%CellStyle\fP\&. .UNINDENT .INDENT 7.0 .TP .B render(layout: GenericLayoutType, insert: \fI\%UVec\fP | None = None) Render table to layout. .UNINDENT .UNINDENT .SS Cell .INDENT 0.0 .TP .B class ezdxf.addons.tablepainter.Cell Abstract base class for table cells. .UNINDENT .SS TextCell .INDENT 0.0 .TP .B class ezdxf.addons.tablepainter.TextCell Implements a cell type containing a multi\-line text. Uses the \fI\%MTextSurrogate\fP add\-on to render the multi\-line text, therefore the content of these cells is compatible to DXF R12. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 Use the factory method \fI\%TablePainter.text_cell()\fP to instantiate text cells. .UNINDENT .UNINDENT .UNINDENT .SS BlockCell .INDENT 0.0 .TP .B class ezdxf.addons.tablepainter.BlockCell(table: \fI\%TablePainter\fP, blockdef: \fI\%BlockLayout\fP, style=\(aqdefault\(aq, attribs=None, span: tuple[int, int] = (1, 1)) Implements a cell type containing a block reference. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtable\fP – table object .IP \(bu 2 \fBblockdef\fP – \fI\%ezdxf.layouts.BlockLayout\fP instance .IP \(bu 2 \fBattribs\fP – BLOCK attributes as (tag, value) dictionary .IP \(bu 2 \fBstyle\fP – cell style name as string .IP \(bu 2 \fBspan\fP – tuple(rows, cols) area of cells to cover .UNINDENT .UNINDENT .sp Implements a cell type containing a block reference. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 Use the factory method \fI\%TablePainter.block_cell()\fP to instantiate block cells. .UNINDENT .UNINDENT .UNINDENT .SS CustomCell .INDENT 0.0 .TP .B class ezdxf.addons.tablepainter.CustomCell Base class to implement custom cells. Overwrite the \fI\%render()\fP method to render the cell. The custom cell type has to be instantiated by the user and added to the table by the \fI\%TablePainter.set_cell()\fP method. .INDENT 7.0 .TP .B render(layout: GenericLayoutType, coords: Sequence[float], layer: str) Renders the cell content into the given \fIlayout\fP\&. .sp The render space is defined by the argument \fIcoords\fP which is a tuple of 4 float values in the order: left, right, top, bottom. These values are layout coordinates in drawing units. The DXF format does not support clipping boxes, therefore the render method can render beyond these borders! .UNINDENT .UNINDENT .SS CellStyle .INDENT 0.0 .TP .B class ezdxf.addons.tablepainter.CellStyle(data: dict[str, Any] | None = None) Cell style object. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 Always instantiate new styles by the factory method: \fI\%TablePainter.new_cell_style()\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B text_style: str \fI\%Textstyle\fP name as string, ignored by \fI\%BlockCell\fP .UNINDENT .INDENT 7.0 .TP .B char_height: float text height in drawing units, ignored by \fI\%BlockCell\fP .UNINDENT .INDENT 7.0 .TP .B line_spacing: float line spacing in percent, distance of line base points = \fBchar_height\fP * \fBline_spacing\fP, ignored by \fI\%BlockCell\fP .UNINDENT .INDENT 7.0 .TP .B scale_x: float text stretching factor (width factor) or block reference x\-scaling factor .UNINDENT .INDENT 7.0 .TP .B scale_y: float block reference y\-scaling factor, ignored by \fI\%TextCell\fP .UNINDENT .INDENT 7.0 .TP .B text_color: int \fI\%AutoCAD Color Index (ACI)\fP for text, ignored by \fI\%BlockCell\fP .UNINDENT .INDENT 7.0 .TP .B rotation: float text or block rotation in degrees .UNINDENT .INDENT 7.0 .TP .B stacked: bool Stacks letters of \fI\%TextCell\fP instances from top to bottom without rotating the characters if \fBTrue\fP, ignored by \fI\%BlockCell\fP .UNINDENT .INDENT 7.0 .TP .B align: MTextEntityAlignment text and block alignment, see \fI\%ezdxf.enums.MTextEntityAlignment\fP .UNINDENT .INDENT 7.0 .TP .B margin_x: float left and right cell margin in drawing units .UNINDENT .INDENT 7.0 .TP .B margin_y: float top and bottom cell margin in drawing units .UNINDENT .INDENT 7.0 .TP .B bg_color: int cell background color as \fI\%AutoCAD Color Index (ACI)\fP, ignored by \fI\%BlockCell\fP .UNINDENT .INDENT 7.0 .TP .B left: BorderStyle left cell border style .UNINDENT .INDENT 7.0 .TP .B top: BorderStyle top cell border style .UNINDENT .INDENT 7.0 .TP .B right: BorderStyle right cell border style .UNINDENT .INDENT 7.0 .TP .B bottom: BorderStyle bottom cell border style .UNINDENT .INDENT 7.0 .TP .B set_border_status(left=True, right=True, top=True, bottom=True) Set status of all cell borders at once. .UNINDENT .INDENT 7.0 .TP .B set_border_style(style: \fI\%BorderStyle\fP, left=True, right=True, top=True, bottom=True) Set border styles of all cell borders at once. .UNINDENT .INDENT 7.0 .TP .B static get_default_border_style() -> \fI\%BorderStyle\fP .UNINDENT .UNINDENT .SS BorderStyle .INDENT 0.0 .TP .B class ezdxf.addons.tablepainter.BorderStyle(status: bool = DEFAULT_BORDER_STATUS, color: int = DEFAULT_BORDER_COLOR, linetype: str = DEFAULT_BORDER_LINETYPE, lineweight=const.LINEWEIGHT_BYLAYER, priority: int = DEFAULT_BORDER_PRIORITY) Border style class. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 Always instantiate new border styles by the factory method: \fI\%TablePainter.new_border_style()\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B status: bool border status, \fBTrue\fP for visible, \fBFalse\fP for hidden .UNINDENT .INDENT 7.0 .TP .B color: int \fI\%AutoCAD Color Index (ACI)\fP .UNINDENT .INDENT 7.0 .TP .B linetype: str linetype name as string, default is “BYLAYER” .UNINDENT .INDENT 7.0 .TP .B lineweight: int lineweight as int, default is by layer .UNINDENT .INDENT 7.0 .TP .B priority: int drawing priority, higher values cover lower values .UNINDENT .UNINDENT .SS MTextSurrogate for DXF R12 .INDENT 0.0 .TP .B class ezdxf.addons.MTextSurrogate(text: str, insert: \fI\%UVec\fP, line_spacing: float = 1.5, align=MTextEntityAlignment.TOP_LEFT, char_height: float = 1.0, style=\(aqSTANDARD\(aq, oblique: float = 0.0, rotation: float = 0.0, width_factor: float = 1.0, mirror=Mirror.NONE, layer=\(aq0\(aq, color: int = const.BYLAYER) MTEXT surrogate for DXF R12 build up by TEXT Entities. This add\-on was added to simplify the transition from \fBdxfwrite\fP to \fBezdxf\fP\&. .sp The rich\-text formatting capabilities for the regular MTEXT entity are not supported, if these features are required use the regular MTEXT entity and the \fI\%MTextExplode\fP add\-on to explode the MTEXT entity into DXF primitives. .sp \fBIMPORTANT:\fP .INDENT 7.0 .INDENT 3.5 The align\-point is always the insert\-point, there is no need for a second align\-point because the horizontal alignments FIT, ALIGN, BASELINE_MIDDLE are not supported. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – content as string .IP \(bu 2 \fBinsert\fP – insert location in drawing units .IP \(bu 2 \fBline_spacing\fP – line spacing in percent of height, 1.5 = 150% = 1+1/2 lines .IP \(bu 2 \fBalign\fP – text alignment as \fI\%MTextEntityAlignment\fP enum .IP \(bu 2 \fBchar_height\fP – text height in drawing units .IP \(bu 2 \fBstyle\fP – \fI\%Textstyle\fP name as string .IP \(bu 2 \fBoblique\fP – oblique angle in degrees, where 0 is vertical .IP \(bu 2 \fBrotation\fP – text rotation angle in degrees .IP \(bu 2 \fBwidth_factor\fP – text width factor as float .IP \(bu 2 \fBmirror\fP – \fBMTextSurrogate.MIRROR_X\fP to mirror the text horizontal or \fBMTextSurrogate.MIRROR_Y\fP to mirror the text vertical .IP \(bu 2 \fBlayer\fP – layer name as string .IP \(bu 2 \fBcolor\fP – \fI\%AutoCAD Color Index (ACI)\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render(layout: GenericLayoutType) -> None Render the multi\-line content as separated TEXT entities into the given \fIlayout\fP instance. .UNINDENT .UNINDENT .SS ASTM\-D6673\-10 Exporter .sp This add\-on creates special DXF files for use by Gerber Technology applications which have a low quality DXF parser and cannot parse/ignore BLOCKS which do not contain data according the ASTM\-D6673\-10 standard. The function \fI\%export_file()\fP exports DXF R12 and only DXF R12 files which do not contain the default “$MODEL_SPACE” and “$PAPER_SPACE” layout block definitions, have an empty HEADER section and no TABLES section. These special requirements of the Gerber Technology parser are annoying, but correspond to the DXF R12 standard. .sp Autodesk applications maybe complain about invalid BLOCK names such as “Shape 0_M”, which in my opinion are valid, maybe spaces were not allowed in the original R12 version, but this is just a minor issue and is more a problem of the picky Autodesk DXF parser, which is otherwise very forgiving for DXF R12 files. .INDENT 0.0 .INDENT 3.5 .sp .EX import ezdxf from ezdxf.addons import gerber_D6673 doc = ezdxf.new(\(dqR12\(dq) # the export function rejects other DXF versions msp = doc.modelspace() # Create your content according the ASTM\-D6673\-10 standard # Do not use any linetypes or text styles, the TABLES section will not be exported. # The ASTM\-D6673\-10 standard supports only 7\-bit ASCII characters. gerber_D6673.export_file(doc, \(dqgerber_file.dxf\(dq) .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.gerber_D6673.export_file(doc: \fI\%Drawing\fP, filename: str | PathLike) -> None Exports the specified DXF R12 document, which should contain content conforming to the ASTM\-D6673\-10 standard, in a special way so that Gerber Technology applications can parse it by their low\-quality DXF parser. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.gerber_D6673.export_stream(doc: \fI\%Drawing\fP, stream: TextIO) -> None Exports the specified DXF R12 document into a \fIstream\fP object. .UNINDENT .SH DXF INTERNALS .INDENT 0.0 .IP \(bu 2 \fI\%DXF Reference\fP provided by Autodesk. .IP \(bu 2 \fI\%DXF Developer Documentation\fP provided by Autodesk. .UNINDENT .SS Basic DXF Structures .SS DXF File Encoding .SS DXF R2004 and prior .sp Drawing files of DXF R2004 (AC1018) and prior are saved as ASCII files with the encoding set by the header variable $DWGCODEPAGE, which is \fBANSI_1252\fP by default if $DWGCODEPAGE is not set. .sp Characters used in the drawing which do not exist in the chosen ASCII encoding are encoded as unicode characters with the schema \fB\eU+nnnn\fP\&. see \fI\%Unicode table\fP .SS Known $DWGCODEPAGE encodings .TS center; |l|l|l|. _ T{ DXF T} T{ Python T} T{ Name T} _ T{ ANSI_874 T} T{ cp874 T} T{ Thai T} _ T{ ANSI_932 T} T{ cp932 T} T{ Japanese T} _ T{ ANSI_936 T} T{ gbk T} T{ UnifiedChinese T} _ T{ ANSI_949 T} T{ cp949 T} T{ Korean T} _ T{ ANSI_950 T} T{ cp950 T} T{ TradChinese T} _ T{ ANSI_1250 T} T{ cp1250 T} T{ CentralEurope T} _ T{ ANSI_1251 T} T{ cp1251 T} T{ Cyrillic T} _ T{ ANSI_1252 T} T{ cp1252 T} T{ WesternEurope T} _ T{ ANSI_1253 T} T{ cp1253 T} T{ Greek T} _ T{ ANSI_1254 T} T{ cp1254 T} T{ Turkish T} _ T{ ANSI_1255 T} T{ cp1255 T} T{ Hebrew T} _ T{ ANSI_1256 T} T{ cp1256 T} T{ Arabic T} _ T{ ANSI_1257 T} T{ cp1257 T} T{ Baltic T} _ T{ ANSI_1258 T} T{ cp1258 T} T{ Vietnam T} _ .TE .SS DXF R2007 and later .sp Starting with DXF R2007 (AC1021) the drawing file is UTF\-8 encoded, the header variable $DWGCODEPAGE is still in use, but I don’t know, if the setting still has any meaning. .sp Encoding characters in the unicode schema \fB\eU+nnnn\fP is still functional. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%String value encoding\fP .UNINDENT .UNINDENT .SS DXF Tags .sp A Drawing Interchange File is simply an ASCII text file with a file type of .dxf and special formatted text. The basic file structure are DXF tags, a DXF tag consist of a DXF group code as an integer value on its own line and a the DXF value on the following line. In the ezdxf documentation DXF tags will be written as (group code, value). .sp With the introduction of extended symbol names in DXF R2000, the 255\-character limit for strings has been increased to 2049 single\-byte characters not including the newline at the end of the line. Nonetheless its safer to use only strings with 255 and less characters, because its not clear if this fact is true for ALL string group codes or only for symbols like layer\- or text style names and not all 3rd party libraries may handle this fact correct. The MTEXT content and binary data is still divided into chunks with less than 255 characters. .sp Group codes are indicating the value type: .TS center; |l|l|. _ T{ Group Code T} T{ Value Type T} _ T{ 0\-9 T} T{ String T} _ T{ 10\-39 T} T{ Double precision 3D point value T} _ T{ 40\-59 T} T{ Double\-precision floating\-point value T} _ T{ 60\-79 T} T{ 16\-bit integer value T} _ T{ 90\-99 T} T{ 32\-bit integer value T} _ T{ 100 T} T{ String T} _ T{ 102 T} T{ String T} _ T{ 105 T} T{ String representing hexadecimal (hex) handle value T} _ T{ 110\-119 T} T{ Double precision floating\-point value T} _ T{ 120\-129 T} T{ Double precision floating\-point value T} _ T{ 130\-139 T} T{ Double precision floating\-point value T} _ T{ 140\-149 T} T{ Double precision scalar floating\-point value T} _ T{ 160\-169 T} T{ 64\-bit integer value T} _ T{ 170\-179 T} T{ 16\-bit integer value T} _ T{ 210\-239 T} T{ Double\-precision floating\-point value T} _ T{ 270\-279 T} T{ 16\-bit integer value T} _ T{ 280\-289 T} T{ 16\-bit integer value T} _ T{ 290\-299 T} T{ Boolean flag value T} _ T{ 300\-309 T} T{ Arbitrary text string T} _ T{ 310\-319 T} T{ String representing hex value of binary chunk T} _ T{ 320\-329 T} T{ Arbitrary pointer, hex object ID, not translated during INSERT and XREF operations T} _ T{ 330\-339 T} T{ Soft\-pointer, hex object ID, translated during INSERT and XREF operations T} _ T{ 340\-349 T} T{ Hard\-pointer, hex object ID, translated during INSERT and XREF operations T} _ T{ 350\-359 T} T{ Soft\-owner, hex object ID, translated during INSERT and XREF operations T} _ T{ 360\-369 T} T{ Hard\-owner, hex object ID, translated during INSERT and XREF operations T} _ T{ 370\-379 T} T{ 16\-bit integer value T} _ T{ 380\-389 T} T{ 16\-bit integer value T} _ T{ 390\-399 T} T{ String representing hex handle value T} _ T{ 400\-409 T} T{ 16\-bit integer value T} _ T{ 410\-419 T} T{ String T} _ T{ 420\-429 T} T{ 32\-bit integer value T} _ T{ 430\-439 T} T{ String T} _ T{ 440\-449 T} T{ 32\-bit integer value T} _ T{ 450\-459 T} T{ Long T} _ T{ 460\-469 T} T{ Double\-precision floating\-point value T} _ T{ 470\-479 T} T{ String T} _ T{ 480\-481 T} T{ Hard\-pointer, hex object ID, translated during INSERT and XREF operations T} _ T{ 999 T} T{ Comment (string) T} _ T{ 1000\-1009 T} T{ String T} _ T{ 1010\-1059 T} T{ Double\-precision floating\-point value T} _ T{ 1060\-1070 T} T{ 16\-bit integer value T} _ T{ 1071 T} T{ 32\-bit integer value T} _ .TE .sp Explanation for some important group codes: .TS center; |l|l|. _ T{ Group Code T} T{ Meaning T} _ T{ 0 T} T{ DXF structure tag, entity start/end or table entries T} _ T{ 1 T} T{ The primary text value for an entity T} _ T{ 2 T} T{ A name: Attribute tag, Block name, and so on. Also used to identify a DXF section or table name. T} _ T{ 3\-4 T} T{ Other textual or name values T} _ T{ 5 T} T{ Entity handle as hex string (fixed) T} _ T{ 6 T} T{ Line type name (fixed) T} _ T{ 7 T} T{ Text style name (fixed) T} _ T{ 8 T} T{ Layer name (fixed) T} _ T{ 9 T} T{ Variable name identifier (used only in HEADER section of the DXF file) T} _ T{ 10 T} T{ Primary X coordinate (start point of a Line or Text entity, center of a Circle, etc.) T} _ T{ 11\-18 T} T{ Other X coordinates T} _ T{ 20 T} T{ Primary Y coordinate. 2n values always correspond to 1n values and immediately follow them in the file (expected by ezdxf!) T} _ T{ 21\-28 T} T{ Other Y coordinates T} _ T{ 30 T} T{ Primary Z coordinate. 3n values always correspond to 1n and 2n values and immediately follow them in the file (expected by ezdxf!) T} _ T{ 31\-38 T} T{ Other Z coordinates T} _ T{ 39 T} T{ This entity’s thickness if nonzero (fixed) T} _ T{ 40\-48 T} T{ Float values (text height, scale factors, etc.) T} _ T{ 49 T} T{ Repeated value \- multiple 49 groups may appear in one entity for variable length tables (such as the dash lengths in the LTYPE table). A 7x group always appears before the first 49 group to specify the table length T} _ T{ 50\-58 T} T{ Angles in degree T} _ T{ 62 T} T{ Color number (fixed) T} _ T{ 66 T} T{ “Entities follow” flag (fixed), only in INSERT and POLYLINE entities T} _ T{ 67 T} T{ Identifies whether entity is in modelspace (0) or paperspace (1) T} _ T{ 68 T} T{ Identifies whether viewport is on but fully off screen, is not active, or is off T} _ T{ 69 T} T{ Viewport identification number T} _ T{ 70\-78 T} T{ Integer values such as repeat counts, flag bits, or modes T} _ T{ 105 T} T{ DIMSTYLE entity handle as hex string (fixed) T} _ T{ 210, 220, 230 T} T{ X, Y, and Z components of extrusion direction (fixed) T} _ T{ 310 T} T{ Proxy entity graphics as binary encoded data T} _ T{ 330 T} T{ Owner handle as hex string T} _ T{ 347 T} T{ MATERIAL handle as hex string T} _ T{ 348 T} T{ VISUALSTYLE handle as hex string T} _ T{ 370 T} T{ Lineweight in mm times 100 (e.g. 0.13mm = 13). T} _ T{ 390 T} T{ PLOTSTYLE handle as hex string T} _ T{ 420 T} T{ True color value as 0x00RRGGBB 24\-bit value T} _ T{ 430 T} T{ Color name as string T} _ T{ 440 T} T{ Transparency value 0x020000TT 0 = fully transparent / 255 = opaque T} _ T{ 999 T} T{ Comments T} _ .TE .sp For explanation of all group codes see: \fI\%DXF Group Codes in Numerical Order Reference\fP provided by Autodesk .SS Extended Data .sp \fI\%DXF R2018 Reference\fP .sp Extended data (XDATA) is created by AutoLISP or ObjectARX applications but any other application like \fIezdxf\fP can also define XDATA. If an entity contains extended data, it \fBfollows\fP the entity’s normal definition. .sp But extended group codes (>=1000) can appear \fBbefore\fP the XDATA section, an example is the BLOCKBASEPOINTPARAMETER entity in AutoCAD Civil 3D or AutoCAD Map 3D. .TS center; |l|l|. _ T{ Group Code T} T{ Description T} _ T{ 1000 T} T{ Strings in extended data can be up to 255 bytes long (with the 256th byte reserved for the null character) T} _ T{ 1001 T} T{ (fixed) Registered application name (ASCII string up to 31 bytes long) for XDATA T} _ T{ 1002 T} T{ (fixed) An extended data control string can be either \fB\(aq{\(aq\fP or \fB\(aq}\(aq\fP\&. These braces enable applications to organize their data by subdividing the data into lists. Lists can be nested. T} _ T{ 1003 T} T{ Name of the layer associated with the extended data T} _ T{ 1004 T} T{ Binary data is organized into variable\-length chunks. The maximum length of each chunk is 127 bytes. In ASCII DXF files, binary data is represented as a string of hexadecimal digits, two per binary byte T} _ T{ 1005 T} T{ Database Handle of entities in the drawing database, see also: \fI\%About 1005 Group Codes\fP T} _ T{ 1010, 1020, 1030 T} T{ Three real values, in the order X, Y, Z. They can be used as a point or vector record that will not be modified at any transformation of the entity. T} _ T{ 1011, 1021, 1031 T} T{ a WCS point that is moved, scaled, rotated and mirrored along with the entity T} _ T{ 1012, 1012, 1022 T} T{ a WCS displacement that is scaled, rotated and mirrored along with the entity, but is not moved T} _ T{ 1013, 1023, 1033 T} T{ a WCS direction that is rotated and mirrored along with the entity, but is not moved or scaled T} _ T{ 1040 T} T{ A real value T} _ T{ 1041 T} T{ Distance, a real value that is scaled along with the parent entity T} _ T{ 1042 T} T{ Scale Factor, also a real value that is scaled along with the parent. The difference between a distance and a scale factor is application\-defined T} _ T{ 1070 T} T{ A 16\-bit integer (signed or unsigned) T} _ T{ 1071 T} T{ A 32\-bit signed (long) integer T} _ .TE .sp The (1001, …) tag indicates the beginning of extended data. In contrast to normal entity data, with extended data the same group code can appear multiple times, and \fBorder is important\fP\&. .sp Extended data is grouped by registered application name. Each registered application group begins with a (1001, APPID) tag, with the application name as APPID string value. Registered application names correspond to APPID symbol table entries. .sp An application can use as many APPID names as needed. APPID names are permanent, although they can be purged if they aren’t currently used in the drawing. Each APPID name can have \fBno more than one data group\fP attached to each entity. Within an application group, the sequence of extended data groups and their meaning is defined by the application. .SS String value encoding .sp String values stored in a DXF file is plain ASCII or UTF\-8, AutoCAD also supports CIF (Common Interchange Format) and MIF (Maker Interchange Format) encoding. The UTF\-8 format is only supported in DXF R2007 and later. .sp Ezdxf on import converts all strings into Python unicode strings without encoding or decoding CIF/MIF. .sp String values containing Unicode characters are represented with control character sequences \fB\eU+nnnn\fP\&. (e.g. \fBr\(aqTEST\eU+7F3A\eU+4E4F\eU+89E3\eU+91CA\eU+6B63THIS\eU+56FE\(aq\fP) .sp To support the DXF unicode encoding ezdxf registers an encoding codec \fIdxf_backslash_replace\fP, defined in \fBezdxf.lldxf.encoding()\fP\&. .sp String values can be stored with these dxf group codes: .INDENT 0.0 .IP \(bu 2 0 \- 9 .IP \(bu 2 100 \- 101 .IP \(bu 2 300 \- 309 .IP \(bu 2 410 \- 419 .IP \(bu 2 430 \- 439 .IP \(bu 2 470 \- 479 .IP \(bu 2 999 \- 1003 .UNINDENT .SS Multi tag text (MTEXT) .sp If the text string is less than 250 characters, all characters appear in tag (1, …). If the text string is longer than 250 characters, the string is divided into 250\-character chunks, which appear in one or more (3, …) tags. If (3, …) tags are used, the last group is a (1, …) tag and has fewer than 250 characters: .INDENT 0.0 .INDENT 3.5 .sp .EX 3 \&... TwoHundredAndFifty Characters .... 3 \&... TwoHundredAndFifty Characters .... 1 less than TwoHundredAndFifty Characters .EE .UNINDENT .UNINDENT .sp As far I know this is only supported by the MTEXT entity. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%DXF File Encoding\fP .UNINDENT .UNINDENT .SS DXF R13 and later tag structure .sp With the introduction of DXF R13 Autodesk added additional group codes and DXF tag structures to the DXF Standard. .SS Subclass Markers .sp Subclass markers (100, Subclass Name) divides DXF objects into several sections. Group codes can be reused in different sections. A subclass ends with the following subclass marker or at the beginning of xdata or the end of the object. See \fI\%Subclass Marker Example\fP in the DXF Reference. .SS Quote about group codes from the DXF reference .INDENT 0.0 .INDENT 3.5 Some group codes that define an entity always appear; others are optional and appear only if their values differ from the defaults. .sp \fBDo not\fP write programs that \fBrely on the order given here\fP\&. The end of an entity is indicated by the next 0 group, which begins the next entity or indicates the end of the section. .sp \fBNote:\fP Accommodating DXF files from future releases of AutoCAD will be easier if you write your DXF processing program in a table\-driven way, ignore undefined group codes, and make no assumptions about the order of group codes in an entity. With each new AutoCAD release, new group codes will be added to entities to accommodate additional features. .UNINDENT .UNINDENT .SS Usage of group codes in subclasses twice .sp Some later entities entities contains the same group code twice for different purposes, so order in the sense of which one comes first is important. (e.g. ATTDEF group code 280) .SS Tag order is sometimes important especially for AutoCAD .sp In LWPOLYLINE the order of tags is important, if the \fIcount\fP tag is not the first tag in the AcDbPolyline subclass, AutoCAD will not close the polyline when the \fIclose\fP flag is set, by the way other applications like BricsCAD ignores the tag order and renders the polyline always correct. .SS Extension Dictionary .sp The extension dictionary is an optional sequence that stores the handle of a DICTIONARY object that belongs to the current object, which in turn may contain entries. This facility allows attachment of arbitrary database objects to any database object. Any object or entity may have this section. .sp The extension dictionary tag sequence: .INDENT 0.0 .INDENT 3.5 .sp .EX 102 {ACAD_XDICTIONARY 360 Hard\-owner ID/handle to owner dictionary 102 } .EE .UNINDENT .UNINDENT .SS Persistent Reactors .sp Persistent reactors are an optional sequence that stores object handles of objects registering themselves as reactors on the current object. Any object or entity may have this section. .sp The persistent reactors tag sequence: .INDENT 0.0 .INDENT 3.5 .sp .EX 102 {ACAD_REACTORS 330 first Soft\-pointer ID/handle to owner dictionary 330 second Soft\-pointer ID/handle to owner dictionary \&... 102 } .EE .UNINDENT .UNINDENT .SS Application\-Defined Codes .sp Starting at DXF R13, DXF objects can contain application\-defined codes outside of XDATA. This application\-defined codes can contain any tag except (0, …) and (102, ‘{…’). “{YOURAPPID” means the APPID string with an preceding “{”. The application defined data tag sequence: .INDENT 0.0 .INDENT 3.5 .sp .EX 102 {YOURAPPID \&... 102 } .EE .UNINDENT .UNINDENT .sp \fB(102, \(aqYOURAPPID}\(aq)\fP is also a valid closing tag: .INDENT 0.0 .INDENT 3.5 .sp .EX 102 {YOURAPPID \&... 102 YOURAPPID} .EE .UNINDENT .UNINDENT .sp All groups defined with a beginning (102, …) appear in the DXF reference before the first subclass marker, I don’t know if these groups can appear after the first or any subclass marker. Ezdxf accepts them at any position, and by default ezdxf adds new app data in front of the first subclass marker to the first tag section of an DXF object. .sp \fBException XRECORD:\fP Tags with group code 102 and a value string without a preceding “{” or the scheme “YOURAPPID}”, should be treated as usual group codes. .SS Embedded Objects .sp The concept of embedded objects was introduced with AutoCAD 2018 (DXF version AC1032) and this is the only information I found about it at the Autodesk knowledge base: \fI\%Embedded and Encapsulated Objects\fP .sp Quote from \fI\%Embedded and Encapsulated Objects\fP: .INDENT 0.0 .INDENT 3.5 For DXF filing, the embedded object must be filed out and in after all the data of the encapsulating object has been filed out and in. .sp A separator is needed between the encapsulating object’s data and the subsequent embedded object’s data. The separator must be similar in function to the group 0 or 100 in that it must cause the filer to stop reading data. The normal DXF group code 0 cannot be used because DXF proxies use it to determine when to stop reading data. The group code 100 could have been used, but it might have caused confusion when manually reading a DXF file, and there was a need to distinguish when an embedded object is about to be written out in order to do some internal bookkeeping. Therefore, the DXF group code 101 was introduced. .UNINDENT .UNINDENT .sp \fBHard facts:\fP .INDENT 0.0 .IP \(bu 2 Only used in ATTRIB, ATTDEF (embedded MTEXT) and MTEXT (columns) in DXF R2018. .IP \(bu 2 Embedded object start with (101, “Embedded Object”) tag .IP \(bu 2 Embedded object is appended to the encapsulated object .IP \(bu 2 Embedded object tags can contain any group code except the DXF structure tag (0, …) .UNINDENT .sp \fBUnconfirmed assumptions:\fP .INDENT 0.0 .IP \(bu 2 The embedded object is written before the \fI\%Extended Data\fP\&. No examples for entities including embedded objects and XDATA at the same time. .IP \(bu 2 XDATA sections replaced by embedded objects, at least for the MTEXT entity .IP \(bu 2 The encapsulating object can contain more than one embedded object. .IP \(bu 2 Embedded objects separated by (101, “Embedded Object”) tags .IP \(bu 2 every entity can contain embedded objects .UNINDENT .sp Real world example from an AutoCAD 2018 file: .INDENT 0.0 .INDENT 3.5 .sp .EX 100 <<< start of encapsulating object AcDbMText 10 2762.148 20 2327.073 30 0.0 40 2.5 41 18.852 46 0.0 71 1 72 5 1 {\efArial|b0|i0|c162|p34;CHANGE;\eP\eP\ePTEXT} 73 1 44 1.0 101 <<< start of embedded object Embedded Object 70 1 10 1.0 20 0.0 30 0.0 11 2762.148 21 2327.073 31 0.0 40 18.852 41 0.0 42 15.428 43 15.043 71 2 72 1 44 18.852 45 12.5 73 0 74 0 46 0.0 .EE .UNINDENT .UNINDENT .SS Handles .sp A handle is an arbitrary but in your DXF file unique hex value as string like ‘10FF’. It is common to to use uppercase letters for hex numbers. Handle can have up to 16 hexadecimal digits (8 bytes). .sp For DXF R10 until R12 the usage of handles was optional. The header variable $HANDLING set to 1 indicate the usage of handles, else $HANDLING is 0 or missing. .sp For DXF R13 and later the usage of handles is mandatory and the header variable $HANDLING was removed. .sp The $HANDSEED variable in the header section should be greater than the biggest handle used in the DXF file, so a CAD application can assign handle values starting with the $HANDSEED value. But as always, don’t rely on the header variable it could be wrong, AutoCAD ignores this value. .SS Handle Definition .sp Entity handle definition is always the \fB(5, ...)\fP, except for entities of the DIMSTYLE table \fB(105, ...)\fP, because the DIMSTYLE entity has also a group code 5 tag for DIMBLK. .SS Handle Pointer .sp A pointer is a reference to a DXF object in the same DXF file. There are four types of pointers: .INDENT 0.0 .IP \(bu 2 Soft\-pointer handle .IP \(bu 2 Hard\-pointer handle .IP \(bu 2 Soft\-owner handle .IP \(bu 2 Hard\-owner handle .UNINDENT .sp Also, a group code range for “arbitrary” handles is defined to allow convenient storage of handle values that are unchanged at any operation (AutoCAD). .SS Pointer and Ownership .sp A pointer is a reference that indicates usage, but not possession or responsibility, for another object. A pointer reference means that the object uses the other object in some way, and shares access to it. An ownership reference means that an owner object is responsible for the objects for which it has an owner handle. An object can have any number of pointer references associated with it, but it can have only one owner. .SS Hard and Soft References .sp Hard references, whether they are pointer or owner, protect an object from being purged. Soft references do not. .sp In AutoCAD, block definitions and complex entities are hard owners of their elements. A symbol table and dictionaries are soft owners of their elements. Polyline entities are hard owners of their vertex and seqend entities. Insert entities are hard owners of their attrib and seqend entities. .sp When establishing a reference to another object, it is recommended that you think about whether the reference should protect an object from the PURGE command. .sp A hard\- and soft pointers will be translated during INSERT and XREF operations. .SS Arbitrary Handles .sp Arbitrary handles are distinct in that they are not translated to session\-persistent identifiers internally, or to entity names in AutoLISP, and so on. They are stored as handles. When handle values are translated in drawing\-merge operations, arbitrary handles are ignored. .sp In all environments, arbitrary handles can be exchanged for entity names of the current drawing by means of the handent functions. A common usage of arbitrary handles is to refer to objects in external DXF and DWG files. .SS About 1005 Group Codes .sp \fB(1005, ...)\fP xdata have the same behavior and semantics as soft pointers, which means that they are translated whenever the host object is merged into a different drawing. However, 1005 items are not translated to session\-persistent identifiers or internal entity names in AutoLISP and ObjectARX. They are stored as handles. .sp When a drawing with handles and extended data handles is imported into another drawing using INSERT, INSERT \fI, XREF Bind, XBIND, or partial OPEN, the extended data handles are **translated*\fP in the same manner as their corresponding entity handles, thus maintaining their binding. This is also done in the EXPLODE block operation or for any other AutoCAD operation. When AUDIT detects an extended data handle that doesn’t match the handle of an entity in the drawing file, it is considered an error. If AUDIT is fixing entities, it sets the handle to “0” .SS DXF File Structure .sp A DXF File is simply an ASCII text file with a file type of .dxf and special formatted text. The basic file structure are DXF tags, a DXF tag consist of a DXF group code as an integer value on its own line and a the DXF value on the following line. In the ezdxf documentation DXF tags will be written as \fB(group code, value)\fP\&. There exist a binary DXF format, but it seems that it is not often used and for reducing file size, zipping is much more efficient. \fIezdxf\fP does support reading binary encoded DXF files. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For more information about DXF tags see: \fI\%DXF Tags\fP .UNINDENT .UNINDENT .sp A usual DXF file is organized in sections, starting with the DXF tag (0, ‘SECTION’) and ending with the DXF tag (0, ‘ENDSEC’). The (0, ‘EOF’) tag signals the end of file. .INDENT 0.0 .IP 1. 3 \fBHEADER:\fP General information about the drawing is found in this section of the DXF file. Each parameter has a variable name starting with ‘$’ and an associated value. Has to be the first section. .IP 2. 3 \fBCLASSES:\fP Holds the information for application defined classes. (DXF R13 and later) .IP 3. 3 \fBTABLES:\fP: Contains several tables for style and property definitions. .INDENT 3.0 .IP \(bu 2 Linetype table (LTYPE) .IP \(bu 2 Layer table (LAYER) .IP \(bu 2 Text Style table (STYLE) .IP \(bu 2 View table (VIEW): (IMHO) layout of the CAD working space, only interesting for interactive CAD applications .IP \(bu 2 Viewport configuration table (VPORT): The VPORT table is unique in that it may contain several entries with the same name (indicating a multiple\-viewport configuration). The entries corresponding to the active viewport configuration all have the name *ACTIVE. The first such entry describes the current viewport. .IP \(bu 2 Dimension Style table (DIMSTYLE) .IP \(bu 2 User Coordinate System table (UCS) (IMHO) only interesting for interactive CAD applications .IP \(bu 2 Application Identification table (APPID): Table of names for all applications registered with a drawing. .IP \(bu 2 Block Record table (BLOCK_RECORD) (DXF R13 and Later) .UNINDENT .IP 4. 3 \fBBLOCKS:\fP Contains all block definitions. The block name *Model_Space or *MODEL_SPACE is reserved for the drawing modelspace and the block name *Paper_Space or *PAPER_SPACE is reserved for the \fIactive\fP paperspace layout. Both block definitions are empty, the content of the modelspace and the \fIactive\fP paperspace is stored in the ENTITIES section. The entities of other layouts are stored in special block definitions called *Paper_Spacennn, nnn is an arbitrary but unique number. .IP 5. 3 \fBENTITIES:\fP Contains all graphical entities of the modelspace and the \fIactive\fP paperspace layout. Entities of other layouts are stored in the BLOCKS sections. .IP 6. 3 \fBOBJECTS:\fP Contains all non\-graphical objects of the drawing (DXF R13 and later) .IP 7. 3 \fBTHUMBNAILIMAGE:\fP Contains a preview image of the DXF file, it is optional and can usually be ignored. (DXF R13 and later) .IP 8. 3 \fBACDSDATA:\fP (DXF R2013 and later) No information in the DXF reference about this section .IP 9. 3 \fBEND OF FILE\fP .UNINDENT .sp For further information read the original \fI\%DXF Reference\fP\&. .sp Structure of a usual DXF R12 file: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< Begin HEADER section, has to be the first section SECTION 2 HEADER <<< Header variable items go here 0 <<< End HEADER section ENDSEC 0 <<< Begin TABLES section SECTION 2 TABLES 0 TABLE 2 VPORT 70 <<< viewport table maximum item count <<< viewport table items go here 0 ENDTAB 0 TABLE 2 APPID, DIMSTYLE, LTYPE, LAYER, STYLE, UCS, VIEW, or VPORT 70 <<< Table maximum item count, a not reliable value and ignored by AutoCAD <<< Table items go here 0 ENDTAB 0 <<< End TABLES section ENDSEC 0 <<< Begin BLOCKS section SECTION 2 BLOCKS <<< Block definition entities go here 0 <<< End BLOCKS section ENDSEC 0 <<< Begin ENTITIES section SECTION 2 ENTITIES <<< Drawing entities go here 0 <<< End ENTITIES section ENDSEC 0 <<< End of file marker (required) EOF .EE .UNINDENT .UNINDENT .SS Minimal DXF Content .SS DXF R12 .sp Contrary to the previous chapter, the DXF R12 format (AC1009) and prior requires just the ENTITIES section: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 SECTION 2 ENTITIES 0 ENDSEC 0 EOF .EE .UNINDENT .UNINDENT .SS DXF R13/R14 and later .sp DXF version R13/14 and later needs much more DXF content than DXF R12. .sp Required sections: HEADER, CLASSES, TABLES, ENTITIES, OBJECTS .sp The HEADER section requires two entries: .INDENT 0.0 .IP \(bu 2 $ACADVER .IP \(bu 2 $HANDSEED .UNINDENT .sp The CLASSES section can be empty, but some DXF entities requires class definitions to work in AutoCAD. .sp The TABLES section requires following tables: .INDENT 0.0 .IP \(bu 2 VPORT entry *ACTIVE is not required! Empty table is ok for AutoCAD. .IP \(bu 2 LTYPE with at least the following line types defined: .INDENT 2.0 .IP \(bu 2 BYBLOCK .IP \(bu 2 BYLAYER .IP \(bu 2 CONTINUOUS .UNINDENT .IP \(bu 2 LAYER with at least an entry for layer ‘0’ .IP \(bu 2 STYLE with at least an entry for style STANDARD .IP \(bu 2 VIEW can be empty .IP \(bu 2 UCS can be empty .IP \(bu 2 APPID with at least an entry for ACAD .IP \(bu 2 DIMSTYLE with at least an entry for style STANDARD .IP \(bu 2 BLOCK_RECORDS with two entries: .INDENT 2.0 .IP \(bu 2 *MODEL_SPACE .IP \(bu 2 *PAPER_SPACE .UNINDENT .UNINDENT .sp The BLOCKS section requires two BLOCKS: .INDENT 0.0 .IP \(bu 2 *MODEL_SPACE .IP \(bu 2 *PAPER_SPACE .UNINDENT .sp The ENTITIES section can be empty. .sp The OBJECTS section requires following entities: .INDENT 0.0 .IP \(bu 2 DICTIONARY \- the root dict \- one entry named ACAD_GROUP .IP \(bu 2 DICTIONARY ACAD_GROUP can be empty .UNINDENT .sp Minimal DXF to download: \fI\%https://github.com/mozman/ezdxf/tree/master/examples_dxf\fP .SS Data Model .SS Database Objects .sp (from the DXF Reference) .sp AutoCAD drawings consist largely of structured containers for database objects. Database objects each have the following features: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 A handle whose value is unique to the drawing/DXF file, and is constant for the lifetime of the drawing. This format has existed since AutoCAD Release 10, and as of AutoCAD Release 13, handles are always enabled. .IP \(bu 2 An optional XDATA table, as entities have had since AutoCAD Release 11. .IP \(bu 2 An optional persistent reactor table. .IP \(bu 2 An optional ownership pointer to an extension dictionary which, in turn, owns subobjects placed in it by an application. .UNINDENT .UNINDENT .UNINDENT .sp Symbol tables and symbol table records are database objects and, thus, have a handle. They can also have xdata and persistent reactors in their DXF records. .SS DXF R12 Data Model .sp The DXF R12 data model is identical to the file structure: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 HEADER section: common settings for the DXF drawing .IP \(bu 2 TABLES section: definitions for LAYERS, LINETYPE, STYLES …. .IP \(bu 2 BLOCKS section: block definitions and its content .IP \(bu 2 ENTITIES section: modelspace and paperspace content .UNINDENT .UNINDENT .UNINDENT .sp References are realized by simple names. The INSERT entity references the BLOCK definition by the BLOCK name, a TEXT entity defines the associated STYLE and LAYER by its name and so on, handles are not needed. Layout association of graphical entities in the ENTITIES section by the paper_space tag \fB(67, 0 or 1)\fP, 0 or missing tag means modelspace, 1 means paperspace. The content of BLOCK definitions is enclosed by the BLOCK and the ENDBLK entity, no additional references are needed. .sp A clean and simple file structure and data model, which seems to be the reason why the DXF R12 Reference (released 1992) is still a widely used file format and Autodesk/AutoCAD supports the format by reading and writing DXF R12 files until today (DXF R13/R14 has no writing support by AutoCAD!). .sp \fBTODO: list of available entities\fP .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 More information about the DXF \fI\%DXF File Structure\fP .UNINDENT .UNINDENT .SS DXF R13+ Data Model .sp With the DXF R13 file format, handles are mandatory and they are really used for organizing the new data structures introduced with DXF R13. .sp The HEADER section is still the same with just more available settings. .sp The new CLASSES section contains AutoCAD specific data, has to be written like AutoCAD it does, but must not be understood. .sp The TABLES section got a new BLOCK_RECORD table \- see \fI\%Block Management Structures\fP for more information. .sp The BLOCKS sections is mostly the same, but with handles, owner tags and new ENTITY types. Not active paperspace layouts store their content also in the BLOCKS section \- see \fI\%Layout Management Structures\fP for more information. .sp The ENTITIES section is also mostly same, but with handles, owner tags and new ENTITY types. .sp \fBTODO: list of new available entities\fP .sp And the new OBJECTS section \- now its getting complicated! .sp Most information about the OBJECTS section is just guessed or gathered by trail and error, because the documentation of the OBJECTS section and its objects in the DXF reference provided by Autodesk is very shallow. This is also the reason why I started the DXF Internals section, may be it helps other developers to start one or two steps above level zero. .sp The OBJECTS sections stores all the non\-graphical entities of the DXF drawing. Non\-graphical entities from now on just called ‘DXF objects’ to differentiate them from graphical entities, just called ‘entities’. The OBJECTS section follows commonly the ENTITIES section, but this is not mandatory. .sp DXF R13 introduces several new DXF objects, which resides exclusive in the OBJECTS section, taken from the DXF R14 reference, because I have no access to the DXF R13 reference, the DXF R13 reference is a compiled .hlp file which can’t be read on Windows 10 or later, this a perfect example for not using closed (proprietary) data formats ;): .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DICTIONARY: a general structural entity as a container .IP \(bu 2 ACDBDICTIONARYWDFLT: a DICTIONARY with a default value .IP \(bu 2 DICTIONARYVAR: used by AutoCAD to store named values in the database .IP \(bu 2 ACAD_PROXY_OBJECT: proxy object for entities created by other applications than AutoCAD .IP \(bu 2 GROUP: groups graphical entities without the need of a BLOCK definition .IP \(bu 2 IDBUFFER: just a list of references to objects .IP \(bu 2 IMAGEDEF: IMAGE definition structure, required by the IMAGE entity .IP \(bu 2 IMAGEDEF_REACTOR: also required by the IMAGE entity .IP \(bu 2 LAYER_INDEX: container for LAYER names .IP \(bu 2 MLINESTYLE .IP \(bu 2 OBJECT_PTR .IP \(bu 2 RASTERVARIABLES .IP \(bu 2 SPATIAL_INDEX: is always written out empty to a DXF file. This object can be ignored. .IP \(bu 2 SPATIAL_FILTER .IP \(bu 2 SORTENTSTABLE: control for regeneration/redraw order of entities .IP \(bu 2 XRECORD: used to store and manage arbitrary data. This object is similar in concept to XDATA but is not limited by size or order. Not supported by R13c0 through R13c3. .UNINDENT .UNINDENT .UNINDENT .sp Still missing the LAYOUT object, which is mandatory in DXF R2000 to manage multiple paperspace layouts. I don’t know how DXF R13/R14 manages multiple layouts or if they even support this feature, but I don’t care much about DXF R13/R14, because AutoCAD has no write support for this two formats anymore. Ezdxf tries to upgrade this two DXF versions to DXF R2000 with the advantage of only two different data models to support: DXF R12 and DXF R2000+ .sp New objects introduced by DXF R2000: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 LAYOUT: management object for modelspace and multiple paperspace layouts .IP \(bu 2 ACDBPLACEHOLDER: surprise \- just a place holder .UNINDENT .UNINDENT .UNINDENT .sp New objects in DXF R2004: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DIMASSOC .IP \(bu 2 LAYER_FILTER .IP \(bu 2 MATERIAL .IP \(bu 2 PLOTSETTINGS .IP \(bu 2 VBA_PROJECT .UNINDENT .UNINDENT .UNINDENT .sp New objects in DXF R2007: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DATATABLE .IP \(bu 2 FIELD .IP \(bu 2 LIGHTLIST .IP \(bu 2 RENDER .IP \(bu 2 RENDERENVIRONMENT .IP \(bu 2 MENTALRAYRENDERSETTINGS .IP \(bu 2 RENDERGLOBAL .IP \(bu 2 SECTION .IP \(bu 2 SUNSTUDY .IP \(bu 2 TABLESTYLE .IP \(bu 2 UNDERLAYDEFINITION .IP \(bu 2 VISUALSTYLE .IP \(bu 2 WIPEOUTVARIABLES .UNINDENT .UNINDENT .UNINDENT .sp New objects in DXF R2013: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 GEODATA .UNINDENT .UNINDENT .UNINDENT .sp New objects in DXF R2018: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 ACDBNAVISWORKSMODELDEF .UNINDENT .UNINDENT .UNINDENT .sp Undocumented objects: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 SCALE .IP \(bu 2 ACDBSECTIONVIEWSTYLE .IP \(bu 2 FIELDLIST .UNINDENT .UNINDENT .UNINDENT .SS Objects Organisation .sp Many objects in the OBJECTS section are organized in a tree\-like structure of DICTIONARY objects. .sp Starting point for this data structure is the ‘root’ DICTIONARY with several entries to other DICTIONARY objects. The root DICTIONARY has to be the first object in the OBJECTS section. The management dicts for GROUP and LAYOUT objects are really important, but IMHO most of the other management tables are optional and for the most use cases not necessary. Ezdxf creates only these entries in the root dict and most of them pointing to an empty DICTIONARY: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 ACAD_COLOR: points to an empty DICTIONARY .IP \(bu 2 ACAD_GROUP: required .IP \(bu 2 ACAD_LAYOUT: required .IP \(bu 2 ACAD_MATERIAL: points to an empty DICTIONARY .IP \(bu 2 ACAD_MLEADERSTYLE: points to an empty DICTIONARY .IP \(bu 2 ACAD_MLINESTYLE: points to an empty DICTIONARY .IP \(bu 2 ACAD_PLOTSETTINGS: points to an empty DICTIONARY .IP \(bu 2 ACAD_PLOTSTYLENAME: required, points to ACDBDICTIONARYWDFLT with one entry: ‘Normal’ .IP \(bu 2 ACAD_SCALELIST: points to an empty DICTIONARY .IP \(bu 2 ACAD_TABLESTYLE: points to an empty DICTIONARY .IP \(bu 2 ACAD_VISUALSTYLE: points to an empty DICTIONARY .UNINDENT .UNINDENT .UNINDENT .SS Root DICTIONARY content for DXF R2018 .INDENT 0.0 .INDENT 3.5 .sp .EX 0 SECTION 2 <<< start of the OBJECTS section OBJECTS 0 <<< root DICTIONARY has to be the first object in the OBJECTS section DICTIONARY 5 <<< handle C 330 <<< owner tag 0 <<< always #0, has no owner 100 AcDbDictionary 281 <<< hard owner flag 1 3 <<< first entry ACAD_CIP_PREVIOUS_PRODUCT_INFO 350 <<< handle to target (pointer) 78B <<< points to a XRECORD with product info about the creator application 3 <<< entry with unknown meaning, if I should guess: something with about colors ... ACAD_COLOR 350 4FB <<< points to a DICTIONARY 3 <<< entry with unknown meaning ACAD_DETAILVIEWSTYLE 350 7ED <<< points to a DICTIONARY 3 <<< GROUP management, mandatory in all DXF versions ACAD_GROUP 350 4FC <<< points to a DICTIONARY 3 <<< LAYOUT management, mandatory if more than the *active* paperspace is used ACAD_LAYOUT 350 4FD <<< points to a DICTIONARY 3 <<< MATERIAL management ACAD_MATERIAL 350 4FE <<< points to a DICTIONARY 3 <<< MLEADERSTYLE management ACAD_MLEADERSTYLE 350 4FF <<< points to a DICTIONARY 3 <<< MLINESTYLE management ACAD_MLINESTYLE 350 500 <<< points to a DICTIONARY 3 <<< PLOTSETTINGS management ACAD_PLOTSETTINGS 350 501 <<< points to a DICTIONARY 3 <<< plot style name management ACAD_PLOTSTYLENAME 350 503 <<< points to a ACDBDICTIONARYWDFLT 3 <<< SCALE management ACAD_SCALELIST 350 504 <<< points to a DICTIONARY 3 <<< entry with unknown meaning ACAD_SECTIONVIEWSTYLE 350 7EB <<< points to a DICTIONARY 3 <<< TABLESTYLE management ACAD_TABLESTYLE 350 505 <<< points to a DICTIONARY 3 <<< VISUALSTYLE management ACAD_VISUALSTYLE 350 506 <<< points to a DICTIONARY 3 <<< entry with unknown meaning ACDB_RECOMPOSE_DATA 350 7F3 3 <<< entry with unknown meaning AcDbVariableDictionary 350 7AE <<< points to a DICTIONARY with handles to DICTIONARYVAR objects 0 DICTIONARY \&... \&... 0 ENDSEC .EE .UNINDENT .UNINDENT .SS DXF Structures .SS DXF Sections .SS HEADER Section .sp In DXF R12 and prior the HEADER section was optional, but since DXF R13 the HEADER section is mandatory. The overall structure is: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< Begin HEADER section SECTION 2 HEADER 9 $ACADVER <<< Header variable items go here 1 AC1009 \&... 0 ENDSEC <<< End HEADER section .EE .UNINDENT .UNINDENT .sp A header variable has a name defined by a \fB(9, Name)\fP tag and following value tags. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Documentation of \fIezdxf\fP \fI\%HeaderSection\fP class. .sp DXF Reference: \fI\%Header Variables\fP .UNINDENT .UNINDENT .SS CLASSES Section .sp The CLASSES section contains CLASS definitions which are only important for Autodesk products, some DXF entities require a class definition or AutoCAD will not open the DXF file. .sp The CLASSES sections was introduced with DXF AC1015 (AutoCAD Release R13). .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Reference: \fI\%About the DXF CLASSES Section\fP .sp Documentation of \fIezdxf\fP \fI\%ClassesSection\fP class. .UNINDENT .UNINDENT .sp The CLASSES section in DXF files holds the information for application\-defined classes whose instances appear in the BLOCKS, ENTITIES, and OBJECTS sections of the database. It is assumed that a class definition is permanently fixed in the class hierarchy. All fields are required. .sp \fBUpdate 2019\-03\-03:\fP .sp Class names are not unique, Autodesk Architectural Desktop 2007 uses the same name, but with different CPP class names in the CLASS section, so storing classes in a dictionary by name as key caused loss of class entries in ezdxf, using a tuple of (name, cpp_class_name) as storage key solved the problem. .SS CLASS Entities .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Reference: \fI\%Group Codes for the CLASS entity\fP .UNINDENT .UNINDENT .sp CLASS entities have no handle and therefore ezdxf does not store the CLASS entity in the drawing entities database! .INDENT 0.0 .INDENT 3.5 .sp .EX 0 SECTION 2 <<< begin CLASSES section CLASSES 0 <<< first CLASS entity CLASS 1 <<< class DXF entity name; THIS ENTRY IS MAYBE NOT UNIQUE ACDBDICTIONARYWDFLT 2 <<< C++ class name; always unique AcDbDictionaryWithDefault 3 <<< application name ObjectDBX Classes 90 <<< proxy capabilities flags 0 91 <<< instance counter for custom class, since DXF version AC1018 (R2004) 0 <<< no problem if the counter is wrong, AutoCAD doesn\(aqt care about 280 <<< was\-a\-proxy flag: 1= class was not loaded when this DXF file was created 0 <<< 0= otherwise 281 <<< is\-an\-entity flag: 1= instances reside in the BLOCKS or ENTITIES section 0 <<< 0= instances may appear only in the OBJECTS section 0 <<< next CLASS entity CLASS \&... 0 <<< end of CLASSES section ENDSEC .EE .UNINDENT .UNINDENT .SS TABLES Section .sp The TABLES section contains the resource tables of a DXF document. .SS APPID Table .sp The \fI\%APPID\fP table stores unique application identifiers. These identifiers are used to mark sub\-sections in the XDATA section of DXF entities. AutoCAD will not load DXF files which uses AppIDs without an entry in the AppIDs table and the “ACAD” entry must always exist. .sp Some known AppIDs: .TS center; |l|l|l|. _ T{ APPID T} T{ Used by T} T{ Description T} _ T{ ACAD T} T{ Autodesk T} T{ various use cases T} _ T{ AcAecLayerStandard T} T{ Autodesk T} T{ layer description T} _ T{ AcCmTransparency T} T{ Autodesk T} T{ layer transparency T} _ T{ HATCHBACKGROUNDCOLOR T} T{ Autodesk T} T{ background color for pattern fillings T} _ T{ EZDXF T} T{ ezdxf T} T{ meta data T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DXF Reference: \fI\%TABLES Section\fP .IP \(bu 2 DXF Reference: \fI\%APPID\fP Table .IP \(bu 2 \fI\%AppID\fP class .UNINDENT .UNINDENT .UNINDENT .SS Table Structure DXF R12 .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< table type APPID 70 <<< count of table entries, AutoCAD ignores this value 3 0 <<< 1. table entry APPID 2 <<< unique application identifier ACAD 70 <<< flags, see \(gaAPPID\(ga_ reference 0 <<< in common cases always 0 0 <<< next table entry APPID \&... 0 <<< end of APPID table ENDTAB .EE .UNINDENT .UNINDENT .SS Table Structure DXF R2000+ .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< table type APPID 5 <<< table handle 3 330 <<< owner tag, tables have no owner 0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of table entries, AutoCAD ignores this value 3 0 <<< first table entry APPID 5 <<< handle of appid 2A 330 <<< owner handle, handle of APPID table 3 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbRegAppTableRecord 2 <<< unique application identifier ACAD 70 <<< flags, see \(gaAPPID\(ga_ reference 0 <<< in common cases always 0 0 <<< next table entry APPID \&... 0 <<< end of APPID table ENDTAB .EE .UNINDENT .UNINDENT .SS Name References .sp APPID table entries are referenced by name: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 XDATA section of DXF entities .UNINDENT .UNINDENT .UNINDENT .SS BLOCK_RECORD Table .sp Block records are essential elements for the entities management, each layout (modelspace and paperspace) and every block definition has a block record entry. This block record is the hard \fIowner\fP of the entities of layouts, each entity has an owner handle which points to a block record of the layout. .SS DIMSTYLE Table .sp The \fI\%DIMSTYLE\fP table stores all dimension style definitions of a DXF drawing. .sp You have access to the dimension styles table by the attribute \fBDrawing.dimstyles\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DXF Reference: \fI\%TABLES Section\fP .IP \(bu 2 DXF Reference: \fI\%DIMSTYLE\fP Table .UNINDENT .UNINDENT .UNINDENT .SS Table Structure DXF R12 .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< set table type DIMSTYLE 70 <<< count of line types defined in this table, AutoCAD ignores this value 9 0 <<< 1. DIMSTYLE table entry DIMSTYLE <<< DIMSTYLE data tags 0 <<< 2. DIMSTYLE table entry DIMSTYLE <<< DIMSTYLE data tags and so on 0 <<< end of DIMSTYLE table ENDTAB .EE .UNINDENT .UNINDENT .SS DIMSTYLE Entry DXF R12 .SS DIMSTYLE Variables DXF R12 .sp Source: \fI\%CADDManager Blog\fP [image] [image] .TS center; |l|l|l|. _ T{ DIMVAR T} T{ Code T} T{ Description T} _ T{ DIMALT T} T{ 170 T} T{ Controls the display of alternate units in dimensions. T} _ T{ DIMALTD T} T{ 171 T} T{ Controls the number of decimal places in alternate units. If DIMALT is turned on, DIMALTD sets the number of digits displayed to the right of the decimal point in the alternate measurement. T} _ T{ DIMALTF T} T{ 143 T} T{ Controls the multiplier for alternate units. If DIMALT is turned on, DIMALTF multiplies linear dimensions by a factor to produce a value in an alternate system of measurement. The initial value represents the number of millimeters in an inch. T} _ T{ DIMAPOST T} T{ 4 T} T{ Specifies a text prefix or suffix (or both) to the alternate dimension measurement for all types of dimensions except angular. For instance, if the current units are Architectural, DIMALT is on, DIMALTF is 25.4 (the number of millimeters per inch), DIMALTD is 2, and DIMPOST is set to “mm”, a distance of 10 units would be displayed as 10”[254.00mm]. T} _ T{ DIMASZ T} T{ 41 T} T{ Controls the size of dimension line and leader line arrowheads. Also controls the size of hook lines. Multiples of the arrowhead size determine whether dimension lines and text should fit between the extension lines. DIMASZ is also used to scale arrowhead blocks if set by DIMBLK. DIMASZ has no effect when DIMTSZ is other than zero. T} _ T{ DIMBLK T} T{ 5 T} T{ Sets the arrowhead block displayed at the ends of dimension lines. T} _ T{ DIMBLK1 T} T{ 6 T} T{ Sets the arrowhead for the first end of the dimension line when DIMSAH is 1. T} _ T{ DIMBLK2 T} T{ 7 T} T{ Sets the arrowhead for the second end of the dimension line when DIMSAH is 1. T} _ T{ DIMCEN T} T{ 141 T} T{ Controls drawing of circle or arc center marks and centerlines by the DIMCENTER, DIMDIAMETER, and DIMRADIUS commands. For DIMDIAMETER and DIMRADIUS, the center mark is drawn only if you place the dimension line outside the circle or arc. .INDENT 0.0 .IP \(bu 2 0 = No center marks or lines are drawn .IP \(bu 2 <0 = Centerlines are drawn .IP \(bu 2 >0 = Center marks are drawn .UNINDENT T} _ T{ DIMCLRD T} T{ 176 T} T{ Assigns colors to dimension lines, arrowheads, and dimension leader lines. .INDENT 0.0 .IP \(bu 2 0 = BYBLOCK .IP \(bu 2 1\-255 = ACI AutoCAD Color Index .IP \(bu 2 256 = BYLAYER .UNINDENT T} _ T{ DIMCLRE T} T{ 177 T} T{ Assigns colors to dimension extension lines, values like DIMCLRD T} _ T{ DIMCLRT T} T{ 178 T} T{ Assigns colors to dimension text, values like DIMCLRD T} _ T{ DIMDLE T} T{ 46 T} T{ Sets the distance the dimension line extends beyond the extension line when oblique strokes are drawn instead of arrowheads. T} _ T{ DIMDLI T} T{ 43 T} T{ Controls the spacing of the dimension lines in baseline dimensions. Each dimension line is offset from the previous one by this amount, if necessary, to avoid drawing over it. Changes made with DIMDLI are not applied to existing dimensions. T} _ T{ DIMEXE T} T{ 44 T} T{ Specifies how far to extend the extension line beyond the dimension line. T} _ T{ DIMEXO T} T{ 42 T} T{ Specifies how far extension lines are offset from origin points. With fixed\-length extension lines, this value determines the minimum offset. T} _ T{ DIMGAP T} T{ 147 T} T{ Sets the distance around the dimension text when the dimension line breaks to accommodate dimension text. Also sets the gap between annotation and a hook line created with the LEADER command. If you enter a negative value, DIMGAP places a box around the dimension text. .sp DIMGAP is also used as the minimum length for pieces of the dimension line. When the default position for the dimension text is calculated, text is positioned inside the extension lines only if doing so breaks the dimension lines into two segments at least as long as DIMGAP. Text placed above or below the dimension line is moved inside only if there is room for the arrowheads, dimension text, and a margin between them at least as large as DIMGAP: 2 * (DIMASZ + DIMGAP). T} _ T{ DIMLFAC T} T{ 144 T} T{ Sets a scale factor for linear dimension measurements. All linear dimension distances, including radii, diameters, and coordinates, are multiplied by DIMLFAC before being converted to dimension text. Positive values of DIMLFAC are applied to dimensions in both modelspace and paperspace; negative values are applied to paperspace only. .sp DIMLFAC applies primarily to nonassociative dimensions (DIMASSOC set 0 or 1). For nonassociative dimensions in paperspace, DIMLFAC must be set individually for each layout viewport to accommodate viewport scaling. .sp DIMLFAC has no effect on angular dimensions, and is not applied to the values held in DIMRND, DIMTM, or DIMTP. T} _ T{ DIMLIM T} T{ 72 T} T{ Generates dimension limits as the default text. Setting DIMLIM to On turns DIMTOL off. .INDENT 0.0 .IP \(bu 2 0 = Dimension limits are not generated as default text .IP \(bu 2 1 = Dimension limits are generated as default text .UNINDENT T} _ T{ DIMPOST T} T{ 3 T} T{ Specifies a text prefix or suffix (or both) to the dimension measurement. .sp For example, to establish a suffix for millimeters, set DIMPOST to mm; a distance of 19.2 units would be displayed as 19.2 mm. If tolerances are turned on, the suffix is applied to the tolerances as well as to the main dimension. .sp Use “<>” to indicate placement of the text in relation to the dimension value. For example, enter “<>mm” to display a 5.0 millimeter radial dimension as “5.0mm”. If you entered mm “<>”, the dimension would be displayed as “mm 5.0”. T} _ T{ DIMRND T} T{ 45 T} T{ Rounds all dimensioning distances to the specified value. .sp For instance, if DIMRND is set to 0.25, all distances round to the nearest 0.25 unit. If you set DIMRND to 1.0, all distances round to the nearest integer. Note that the number of digits edited after the decimal point depends on the precision set by DIMDEC. DIMRND does not apply to angular dimensions. T} _ T{ DIMSAH T} T{ 173 T} T{ Controls the display of dimension line arrowhead blocks. .INDENT 0.0 .IP \(bu 2 0 = Use arrowhead blocks set by DIMBLK .IP \(bu 2 1 = Use arrowhead blocks set by DIMBLK1 and DIMBLK2 .UNINDENT T} _ T{ DIMSCALE T} T{ 40 T} T{ Sets the overall scale factor applied to dimensioning variables that specify sizes, distances, or offsets. Also affects the leader objects with the LEADER command. .sp Use MLEADERSCALE to scale multileader objects created with the MLEADER command. .INDENT 0.0 .IP \(bu 2 0.0 = A reasonable default value is computed based on the scaling between the current model space viewport and paperspace. If you are in paperspace or modelspace and not using the paperspace feature, the scale factor is 1.0. .IP \(bu 2 >0 = A scale factor is computed that leads text sizes, arrowhead sizes, and other scaled distances to plot at their face values. .UNINDENT .sp DIMSCALE does not affect measured lengths, coordinates, or angles. .sp Use DIMSCALE to control the overall scale of dimensions. However, if the current dimension style is annotative, DIMSCALE is automatically set to zero and the dimension scale is controlled by the CANNOSCALE system variable. DIMSCALE cannot be set to a non\-zero value when using annotative dimensions. T} _ T{ DIMSE1 T} T{ 75 T} T{ Suppresses display of the first extension line. .INDENT 0.0 .IP \(bu 2 0 = Extension line is not suppressed .IP \(bu 2 1 = Extension line is suppressed .UNINDENT T} _ T{ DIMSE2 T} T{ 76 T} T{ Suppresses display of the second extension line. .INDENT 0.0 .IP \(bu 2 0 = Extension line is not suppressed .IP \(bu 2 1 = Extension line is suppressed .UNINDENT T} _ T{ DIMSOXD T} T{ 175 T} T{ Suppresses arrowheads if not enough space is available inside the extension lines. .INDENT 0.0 .IP \(bu 2 0 = Arrowheads are not suppressed .IP \(bu 2 1 = Arrowheads are suppressed .UNINDENT .sp If not enough space is available inside the extension lines and DIMTIX is on, setting DIMSOXD to On suppresses the arrowheads. If DIMTIX is off, DIMSOXD has no effect. T} _ T{ DIMTAD T} T{ 77 T} T{ Controls the vertical position of text in relation to the dimension line. .INDENT 0.0 .IP \(bu 2 0 = Centers the dimension text between the extension lines. .IP \(bu 2 1 = Places the dimension text above the dimension line except when the dimension line is not horizontal and text inside the extension lines is forced horizontal (DIMTIH = 1). The distance from the dimension line to the baseline of the lowest line of text is the current DIMGAP value. .IP \(bu 2 2 = Places the dimension text on the side of the dimension line farthest away from the defining points. .IP \(bu 2 3 = Places the dimension text to conform to Japanese Industrial Standards (JIS). .IP \(bu 2 4 = Places the dimension text below the dimension line. .UNINDENT T} _ T{ DIMTFAC T} T{ 146 T} T{ Specifies a scale factor for the text height of fractions and tolerance values relative to the dimension text height, as set by DIMTXT. .sp For example, if DIMTFAC is set to 1.0, the text height of fractions and tolerances is the same height as the dimension text. If DIMTFAC is set to 0.7500, the text height of fractions and tolerances is three\-quarters the size of dimension text. T} _ T{ DIMTIH T} T{ 73 T} T{ Controls the position of dimension text inside the extension lines for all dimension types except Ordinate. .INDENT 0.0 .IP \(bu 2 0 = Aligns text with the dimension line .IP \(bu 2 1 = Draws text horizontally .UNINDENT T} _ T{ DIMTIX T} T{ 174 T} T{ Draws text between extension lines. .INDENT 0.0 .IP \(bu 2 0 = Varies with the type of dimension. For linear and angular dimensions, text is placed inside the extension lines if there is sufficient room. For radius and diameter dimensions hat don’t fit inside the circle or arc, DIMTIX has no effect and always forces the text outside the circle or arc. .IP \(bu 2 1 = Draws dimension text between the extension lines even if it would ordinarily be placed outside those lines .UNINDENT T} _ T{ DIMTM T} T{ 48 T} T{ Sets the minimum (or lower) tolerance limit for dimension text when DIMTOL or DIMLIM is on. DIMTM accepts signed values. If DIMTOL is on and DIMTP and DIMTM are set to the same value, a tolerance value is drawn. If DIMTM and DIMTP values differ, the upper tolerance is drawn above the lower, and a plus sign is added to the DIMTP value if it is positive. For DIMTM, the program uses the negative of the value you enter (adding a minus sign if you specify a positive number and a plus sign if you specify a negative number). T} _ T{ DIMTOFL T} T{ 172 T} T{ Controls whether a dimension line is drawn between the extension lines even when the text is placed outside. For radius and diameter dimensions (when DIMTIX is off), draws a dimension line inside the circle or arc and places the text, arrowheads, and leader outside. .INDENT 0.0 .IP \(bu 2 0 = Does not draw dimension lines between the measured points when arrowheads are placed outside the measured points .IP \(bu 2 1 = Draws dimension lines between the measured points even when arrowheads are placed outside the measured points .UNINDENT T} _ T{ DIMTOH T} T{ 74 T} T{ Controls the position of dimension text outside the extension lines. .INDENT 0.0 .IP \(bu 2 0 = Aligns text with the dimension line .IP \(bu 2 1 = Draws text horizontally .UNINDENT T} _ T{ DIMTOL T} T{ 71 T} T{ Appends tolerances to dimension text. Setting DIMTOL to on turns DIMLIM off. T} _ T{ DIMTP T} T{ 47 T} T{ Sets the maximum (or upper) tolerance limit for dimension text when DIMTOL or DIMLIM is on. DIMTP accepts signed values. If DIMTOL is on and DIMTP and DIMTM are set to the same value, a tolerance value is drawn. If DIMTM and DIMTP values differ, the upper tolerance is drawn above the lower and a plus sign is added to the DIMTP value if it is positive. T} _ T{ DIMTSZ T} T{ 142 T} T{ Specifies the size of oblique strokes drawn instead of arrowheads for linear, radius, and diameter dimensioning. .INDENT 0.0 .IP \(bu 2 0 = Draws arrowheads. .IP \(bu 2 >0 = Draws oblique strokes instead of arrowheads. The size of the oblique strokes is determined by this value multiplied by the DIMSCALE value .UNINDENT T} _ T{ DIMTVP T} T{ 145 T} T{ Controls the vertical position of dimension text above or below the dimension line. The DIMTVP value is used when DIMTAD = 0. The magnitude of the vertical offset of text is the product of the text height and DIMTVP. Setting DIMTVP to 1.0 is equivalent to setting DIMTAD = 1. The dimension line splits to accommodate the text only if the absolute value of DIMTVP is less than 0.7. T} _ T{ DIMTXT T} T{ 140 T} T{ Specifies the height of dimension text, unless the current text style has a fixed height. T} _ T{ DIMZIN T} T{ 78 T} T{ Controls the suppression of zeros in the primary unit value. Values 0\-3 affect feet\-and\-inch dimensions only: .INDENT 0.0 .IP \(bu 2 0 = Suppresses zero feet and precisely zero inches .IP \(bu 2 1 = Includes zero feet and precisely zero inches .IP \(bu 2 2 = Includes zero feet and suppresses zero inches .IP \(bu 2 3 = Includes zero inches and suppresses zero feet .IP \(bu 2 4 (Bit 3) = Suppresses leading zeros in decimal dimensions (for example, 0.5000 becomes .5000) .IP \(bu 2 8 (Bit 4) = Suppresses trailing zeros in decimal dimensions (for example, 12.5000 becomes 12.5) .IP \(bu 2 12 (Bit 3+4) = Suppresses both leading and trailing zeros (for example, 0.5000 becomes .5) .UNINDENT T} _ .TE .SS Table Structure DXF R2000+ .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< set table type DIMSTYLE 5 <<< DIMSTYLE table handle 5F 330 <<< owner tag, tables has no owner 0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of dimension styles defined in this table, AutoCAD ignores this value 9 0 <<< 1. DIMSTYLE table entry DIMSTYLE <<< DIMSTYLE data tags 0 <<< 2. DIMSTYLE table entry DIMSTYLE <<< DIMSTYLE data tags and so on 0 <<< end of DIMSTYLE table ENDTAB .EE .UNINDENT .UNINDENT .SS Additional DIMSTYLE Variables DXF R13/14 .sp Source: \fI\%CADDManager Blog\fP .TS center; |l|l|l|. _ T{ DIMVAR T} T{ code T} T{ Description T} _ T{ DIMADEC T} T{ 179 T} T{ Controls the number of precision places displayed in angular dimensions. T} _ T{ DIMALTTD T} T{ 274 T} T{ Sets the number of decimal places for the tolerance values in the alternate units of a dimension. T} _ T{ DIMALTTZ T} T{ 286 T} T{ Controls suppression of zeros in tolerance values. T} _ T{ DIMALTU T} T{ 273 T} T{ Sets the units format for alternate units of all dimension substyles except Angular. T} _ T{ DIMALTZ T} T{ 285 T} T{ Controls the suppression of zeros for alternate unit dimension values. DIMALTZ values 0\-3 affect feet\-and\-inch dimensions only. T} _ T{ DIMAUNIT T} T{ 275 T} T{ Sets the units format for angular dimensions. .INDENT 0.0 .IP \(bu 2 0 = Decimal degrees .IP \(bu 2 1 = Degrees/minutes/seconds .IP \(bu 2 2 = Grad .IP \(bu 2 3 = Radians .UNINDENT T} _ T{ DIMBLK_HANDLE T} T{ 342 T} T{ defines DIMBLK as handle to the BLOCK RECORD entry T} _ T{ DIMBLK1_HANDLE T} T{ 343 T} T{ defines DIMBLK1 as handle to the BLOCK RECORD entry T} _ T{ DIMBLK2_HANDLE T} T{ 344 T} T{ defines DIMBLK2 as handle to the BLOCK RECORD entry T} _ T{ DIMDEC T} T{ 271 T} T{ Sets the number of decimal places displayed for the primary units of a dimension. The precision is based on the units or angle format you have selected. T} _ T{ DIMDSEP T} T{ 278 T} T{ Specifies a single\-character decimal separator to use when creating dimensions whose unit format is decimal. When prompted, enter a single character at the Command prompt. If dimension units is set to Decimal, the DIMDSEP character is used instead of the default decimal point. If DIMDSEP is set to NULL (default value, reset by entering a period), the decimal point is used as the dimension separator. T} _ T{ DIMJUST T} T{ 280 T} T{ Controls the horizontal positioning of dimension text. .INDENT 0.0 .IP \(bu 2 0 = Positions the text above the dimension line and center\-justifies it between the extension lines .IP \(bu 2 1 = Positions the text next to the first extension line .IP \(bu 2 2 = Positions the text next to the second extension line .IP \(bu 2 3 = Positions the text above and aligned with the first extension line .IP \(bu 2 4 = =Positions the text above and aligned with the second extension line .UNINDENT T} _ T{ DIMSD1 T} T{ 281 T} T{ Controls suppression of the first dimension line and arrowhead. When turned on, suppresses the display of the dimension line and arrowhead between the first extension line and the text. .INDENT 0.0 .IP \(bu 2 0 = First dimension line is not suppressed .IP \(bu 2 1 = First dimension line is suppressed .UNINDENT T} _ T{ DIMSD2 T} T{ 282 T} T{ Controls suppression of the second dimension line and arrowhead. When turned on, suppresses the display of the dimension line and arrowhead between the second extension line and the text. .INDENT 0.0 .IP \(bu 2 0 = Second dimension line is not suppressed .IP \(bu 2 1 = Second dimension line is suppressed .UNINDENT T} _ T{ DIMTDEC T} T{ 272 T} T{ Sets the number of decimal places to display in tolerance values for the primary units in a dimension. This system variable has no effect unless DIMTOL is set to On. The default for DIMTOL is Off. T} _ T{ DIMTOLJ T} T{ 283 T} T{ Sets the vertical justification for tolerance values relative to the nominal dimension text. This system variable has no effect unless DIMTOL is set to On. The default for DIMTOL is Off. .INDENT 0.0 .IP \(bu 2 0 = Bottom .IP \(bu 2 1 = Middle .IP \(bu 2 2 = Top .UNINDENT T} _ T{ DIMTXSTY_HANDLE T} T{ 340 T} T{ Specifies the text style of the dimension as handle to STYLE table entry T} _ T{ DIMTZIN T} T{ 284 T} T{ Controls the suppression of zeros in tolerance values. .sp Values 0\-3 affect feet\-and\-inch dimensions only. .INDENT 0.0 .IP \(bu 2 0 = Suppresses zero feet and precisely zero inches .IP \(bu 2 1 = Includes zero feet and precisely zero inches .IP \(bu 2 2 = Includes zero feet and suppresses zero inches .IP \(bu 2 3 = Includes zero inches and suppresses zero feet .IP \(bu 2 4 = Suppresses leading zeros in decimal dimensions (for example, 0.5000 becomes .5000) .IP \(bu 2 8 = Suppresses trailing zeros in decimal dimensions (for example, 12.5000 becomes 12.5) .IP \(bu 2 12 = Suppresses both leading and trailing zeros (for example, 0.5000 becomes .5) .UNINDENT T} _ T{ DIMUPT T} T{ 288 T} T{ Controls options for user\-positioned text. .INDENT 0.0 .IP \(bu 2 0 = Cursor controls only the dimension line location .IP \(bu 2 1 = Cursor controls both the text position and the dimension line location .UNINDENT T} _ .TE .SS Additional DIMSTYLE Variables DXF R2000 .sp Source: \fI\%CADDManager Blog\fP .TS center; |l|l|l|. _ T{ DIMVAR T} T{ Code T} T{ Description T} _ T{ DIMALTRND T} T{ 148 T} T{ Rounds off the alternate dimension units. T} _ T{ DIMATFIT T} T{ 289 T} T{ Determines how dimension text and arrows are arranged when space is not sufficient to place both within the extension lines. .INDENT 0.0 .IP \(bu 2 0 = Places both text and arrows outside extension lines .IP \(bu 2 1 = Moves arrows first, then text .IP \(bu 2 2 = Moves text first, then arrows .IP \(bu 2 3 = Moves either text or arrows, whichever fits best .UNINDENT .sp A leader is added to moved dimension text when DIMTMOVE is set to 1. T} _ T{ DIMAZIN T} T{ 79 T} T{ Suppresses zeros for angular dimensions. .INDENT 0.0 .IP \(bu 2 0 = Displays all leading and trailing zeros .IP \(bu 2 1 = Suppresses leading zeros in decimal dimensions (for example, 0.5000 becomes .5000) .IP \(bu 2 2 = Suppresses trailing zeros in decimal dimensions (for example, 12.5000 becomes 12.5) .IP \(bu 2 3 = Suppresses leading and trailing zeros (for example, 0.5000 becomes .5) .UNINDENT T} _ T{ DIMFRAC T} T{ 276 T} T{ Sets the fraction format when DIMLUNIT is set to 4 (Architectural) or 5 (Fractional). .INDENT 0.0 .IP \(bu 2 0 = Horizontal stacking .IP \(bu 2 1 = Diagonal stacking .IP \(bu 2 2 = Not stacked (for example, 1/2) .UNINDENT T} _ T{ DIMLDRBLK_HANDLE T} T{ 341 T} T{ Specifies the arrow type for leaders. Handle to BLOCK RECORD T} _ T{ DIMLUNIT T} T{ 277 T} T{ Sets units for all dimension types except Angular. .INDENT 0.0 .IP \(bu 2 1 = Scientific .IP \(bu 2 2 = Decimal .IP \(bu 2 3 = Engineering .IP \(bu 2 4 = Architectural (always displayed stacked) .IP \(bu 2 5 = Fractional (always displayed stacked) .IP \(bu 2 6 = Microsoft Windows Desktop (decimal format using Control Panel settings for decimal separator and number grouping symbols) .UNINDENT T} _ T{ DIMLWD T} T{ 371 T} T{ Assigns lineweight to dimension lines. .INDENT 0.0 .IP \(bu 2 \-3 = Default (the LWDEFAULT value) .IP \(bu 2 \-2 = BYBLOCK .IP \(bu 2 \-1 = BYLAYER .UNINDENT T} _ T{ DIMLWE T} T{ 372 T} T{ Assigns lineweight to extension lines. .INDENT 0.0 .IP \(bu 2 \-3 = Default (the LWDEFAULT value) .IP \(bu 2 \-2 = BYBLOCK .IP \(bu 2 \-1 = BYLAYER .UNINDENT T} _ T{ DIMTMOVE T} T{ 279 T} T{ Sets dimension text movement rules. .INDENT 0.0 .IP \(bu 2 0 = Moves the dimension line with dimension text .IP \(bu 2 1 = Adds a leader when dimension text is moved .IP \(bu 2 2 = Allows text to be moved freely without a leader .UNINDENT T} _ .TE .SS Text Location .sp This image shows the default text locations created by \fI\%BricsCAD\fP for dimension variables \fBdimtad\fP and \fBdimjust\fP: [image] .SS Unofficial DIMSTYLE Variables for DXF R2007 and later .sp The following DIMVARS are \fBnot documented\fP in the \fI\%DXF Reference\fP by Autodesk. .TS center; |l|l|l|. _ T{ DIMVAR T} T{ Code T} T{ Description T} _ T{ DIMTFILL T} T{ 69 T} T{ Text fill 0=off; 1=background color; 2=custom color (see DIMTFILLCLR) T} _ T{ DIMTFILLCLR T} T{ 70 T} T{ Text fill custom color as color index T} _ T{ DIMFXLON T} T{ 290 T} T{ Extension line has fixed length if set to 1 T} _ T{ DIMFXL T} T{ 49 T} T{ Length of extension line below dimension line if fixed (DIMFXLON is 1), DIMEXE defines the the length above the dimension line T} _ T{ DIMJOGANG T} T{ 50 T} T{ Angle of oblique dimension line segment in jogged radius dimension T} _ T{ DIMLTYPE_HANDLE T} T{ 345 T} T{ Specifies the LINETYPE of the dimension line. Handle to LTYPE table entry T} _ T{ DIMLTEX1_HANDLE T} T{ 346 T} T{ Specifies the LINETYPE of the extension line 1. Handle to LTYPE table entry T} _ T{ DIMLTEX2_HANDLE T} T{ 347 T} T{ Specifies the LINETYPE of the extension line 2. Handle to LTYPE table entry T} _ .TE .SS Extended Settings as Special XDATA Groups .sp Prior to DXF R2007, some extended settings for the dimension and the extension lines are stored in the XDATA section by following entries, this is not documented by \fI\%Autodesk\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX 1001 ACAD_DSTYLE_DIM_LINETYPE <<< linetype for dimension line 1070 380 <<< group code, which differs from R2007 DIMDLTYPE 1005 FFFF <<< handle to LTYPE entry 1001 ACAD_DSTYLE_DIM_EXT1_LINETYPE <<< linetype for extension line 1 1070 381 <<< group code, which differs from R2007 DIMLTEX1 1005 FFFF <<< handle to LTYPE entry 1001 ACAD_DSTYLE_DIM_EXT2_LINETYPE <<< linetype for extension line 1 1070 382 <<< group code, which differs from R2007 DIMLTEX2 1005 FFFF <<< handle to LTYPE entry 1001 ACAD_DSTYLE_DIMEXT_ENABLED <<< extension line fixed 1070 383 <<< group code, which differs from R2007 DIMEXFIX 1070 1 <<< fixed if 1 else 0 1001 ACAD_DSTYLE_DIMEXT_LENGTH <<< extension line fixed length 1070 378 <<< group code, which differs from R2007 DIMEXLEN 1040 1.33 <<< length of extension line below dimension line .EE .UNINDENT .UNINDENT .sp This XDATA groups requires also an appropriate APPID entry in the APPID table. This feature is not supported by \fIezdxf\fP\&. .SS LAYER Table .sp TODO .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DXF Reference: \fI\%TABLES Section\fP .IP \(bu 2 DXF Reference: \fI\%LAYER\fP Table .IP \(bu 2 \fI\%Layer\fP class .UNINDENT .UNINDENT .UNINDENT .SS Table Structure DXF R2000+ .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< name of table \(dqLAYER\(dq LAYER 5 <<< handle of the TABLE 2 330 <<< owner tag is always \(dq0\(dq 0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of layers defined in this table, AutoCAD ignores this value 5 0 <<< 1. LAYER table entry LAYER \&... <<< LAYER entity tags 0 <<< 2. LAYER table entry LAYER \&... <<< LAYER entity tags 0 <<< end of TABLE ENDTAB .EE .UNINDENT .UNINDENT .SS Layer Entity Tags DXF R2000+ .sp There are some quirks: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 the frozen/thawed state is stored in flags (group code 70) .IP \(bu 2 the locked/unlocked state is stored in flags (group code 70) .IP \(bu 2 the off state is stored as negative color value (group code 6) .IP \(bu 2 the layer description is stored in the XDATA section .IP \(bu 2 the transparency value is stored in the XDATA section .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< LAYER table entry LAYER 5 <<< handle of LAYER 10 330 <<< owner handle, handle of LAYER table 2 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbLayerTableRecord 2 <<< layer name 0 <<< layer \(dq0\(dq 70 <<< flags 0 62 <<< color 7 <<< a negative value switches the layer off 420 <<< optional true color value 0 6 <<< linetype Continuous 290 <<< optional plot flag 1 370 <<< lineweight \-3 390 <<< handle to plot style F 347 <<< material handle 47 348 <<< unknown1 0 1001 <<< XDATA section, APPID AcAecLayerStandard 1000 <<< unknown first value, here an empty string 1000 <<< layer description This layer has a description 1001 <<< APPID AcCmTransparency 1071 <<< layer transparency value 0 .EE .UNINDENT .UNINDENT .SS Layer Viewport Overrides .sp Some layer attributes can be overridden individually for any VIEWPORT entity. This overrides are stored as extension dictionary entries of the LAYER entity pointing to XRECORD entities in the objects section: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 LAYER 5 9F 102 <<< APP data, extension dictionary {ACAD_XDICTIONARY 360 <<< handle to the xdict in the objects section B3 102 } 330 2 100 AcDbSymbolTableRecord 100 AcDbLayerTableRecord 2 LayerA \&... .EE .UNINDENT .UNINDENT .sp The extension DICTIONARY entity: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< entity type DICTIONARY 5 <<< handle B3 330 <<< owner handle 9F <<< the layer owns this dictionary 100 <<< subclass marker AcDbDictionary 280 <<< hard owned flag 1 281 <<< cloning type 1 <<< keep existing 3 <<< transparency override ADSK_XREC_LAYER_ALPHA_OVR 360 <<< handle to XRECORD E5 3 <<< color override ADSK_XREC_LAYER_COLOR_OVR 360 <<< handle to XRECORD B4 3 <<< linetype override ADSK_XREC_LAYER_LINETYPE_OVR 360 <<< handle to XRECORD DD 3 <<< lineweight override ADSK_XREC_LAYER_LINEWT_OVR 360 <<< handle to XRECORD E2 .EE .UNINDENT .UNINDENT .sp Transparency override XRECORD: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< entity type XRECORD 5 <<< handle E5 102 <<< reactors app data {ACAD_REACTORS 330 B3 <<< extension dictionary 102 } 330 <<< owner tag B3 <<< extension dictionary 100 <<< subclass marker AcDbXrecord 280 <<< cloning flag 1 <<< keep existing 102 <<< for each overridden VIEWPORT one entry {ADSK_LYR_ALPHA_OVERRIDE 335 <<< handle to VIEWPORT AC 440 <<< transparency override 33554661 102 } .EE .UNINDENT .UNINDENT .sp Color override XRECORD: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 XRECORD \&... <<< like transparency XRECORD 102 <<< for each overridden VIEWPORT one entry {ADSK_LYR_COLOR_OVERRIDE 335 <<< handle to VIEWPORT AF 420 <<< color override \-1023409925 <<< raw color value 102 } .EE .UNINDENT .UNINDENT .sp Linetype override XRECORD: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 XRECORD \&... <<< like transparency XRECORD 102 <<< for each overridden VIEWPORT one entry {ADSK_LYR_LINETYPE_OVERRIDE 335 <<< handle to VIEWPORT AC 343 <<< linetype override DC <<< handle to LINETYPE table entry 102 } .EE .UNINDENT .UNINDENT .sp Lineweight override XRECORD: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 XRECORD \&... <<< like transparency XRECORD 102 <<< for each overridden VIEWPORT one entry {ADSK_LYR_LINEWT_OVERRIDE 335 <<< handle to VIEWPORT AC 91 <<< lineweight override 13 <<< lineweight value 102 } .EE .UNINDENT .UNINDENT .SS Name References .sp LAYER table entries are referenced by name: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 all graphical DXF entities .IP \(bu 2 VIEWPORT entity, frozen layers .IP \(bu 2 LAYER_FILTER .IP \(bu 2 LAYER_INDEX .UNINDENT .UNINDENT .UNINDENT .SS LTYPE Table .sp The \fI\%LTYPE\fP table stores all line type definitions of a DXF drawing. Every line type used in the drawing has to have a table entry, or the DXF drawing is invalid for AutoCAD. .sp DXF R12 supports just simple line types, DXF R2000+ supports also complex line types with text or shapes included. .sp You have access to the line types table by the attribute \fBDrawing.linetypes\fP\&. The line type table itself is not stored in the entity database, but the table entries are stored in entity database, and can be accessed by its handle. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DXF Reference: \fI\%TABLES Section\fP .IP \(bu 2 DXF Reference: \fI\%LTYPE\fP Table .IP \(bu 2 \fI\%Linetype\fP class .UNINDENT .UNINDENT .UNINDENT .SS Table Structure DXF R12 .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< table type LTYPE 70 <<< count of table entries, AutoCAD ignores this value 9 0 <<< 1. LTYPE table entry LTYPE <<< LTYPE data tags 0 <<< 2. LTYPE table entry LTYPE <<< LTYPE data tags and so on 0 <<< end of LTYPE table ENDTAB .EE .UNINDENT .UNINDENT .SS Table Structure DXF R2000+ .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< table type LTYPE 5 <<< table handle 5F 330 <<< owner tag, tables have no owner 0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of table entiries, AutoCAD ignores this value 9 0 <<< 1. LTYPE table entry LTYPE <<< LTYPE data tags 0 <<< 2. LTYPE table entry LTYPE <<< LTYPE data tags and so on 0 <<< end of LTYPE table ENDTAB .EE .UNINDENT .UNINDENT .SS Simple Line Type .sp \fIezdxf\fP setup for line type “CENTER”: .INDENT 0.0 .INDENT 3.5 .sp .EX dwg.linetypes.add(\(dqCENTER\(dq, description=\(dqCenter ____ _ ____ _ ____ _ ____ _ ____ _ ____\(dq, pattern=[2.0, 1.25, \-0.25, 0.25, \-0.25], ) .EE .UNINDENT .UNINDENT .SS Simple Line Type Tag Structure DXF R2000+ .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< line type table entry LTYPE 5 <<< handle of line type 1B1 330 <<< owner handle, handle of LTYPE table 5F 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbLinetypeTableRecord 2 <<< line type name CENTER 70 <<< flags 0 3 Center ____ _ ____ _ ____ _ ____ _ ____ _ ____ 72 <<< signature tag 65 <<< ascii code for \(dqA\(dq 73 <<< count of pattern groups starting with a code 49 tag 4 <<< 4 pattern groups 40 <<< overall pattern length in drawing units 2.0 49 <<< 1. pattern group 1.25 <<< >0 line, <0 gap, =0 point 74 <<< type marker 0 <<< 0 for line group 49 <<< 2. pattern group \-0.25 74 0 49 <<< 3. pattern group 0.25 74 0 49 <<< 4. pattern group \-0.25 74 0 .EE .UNINDENT .UNINDENT .SS Complex Line Type TEXT .sp \fIezdxf\fP setup for line type “GASLEITUNG”: .INDENT 0.0 .INDENT 3.5 .sp .EX dwg.linetypes.add(\(dqGASLEITUNG\(dq, description=\(dqGasleitung2 \-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\(dq, length=1, pattern=\(aqA,.5,\-.2,[\(dqGAS\(dq,STANDARD,S=.1,U=0.0,X=\-0.1,Y=\-.05],\-.25\(aq, ) .EE .UNINDENT .UNINDENT .SS TEXT Tag Structure .INDENT 0.0 .INDENT 3.5 .sp .EX 0 LTYPE 5 614 330 5F 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbLinetypeTableRecord 2 GASLEITUNG 70 0 3 Gasleitung2 \-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\- 72 <<< signature tag 65 <<< ascii code for \(dqA\(dq 73 <<< count of pattern groups starting with a code 49 tag 3 <<< 3 pattern groups 40 <<< overall pattern length in drawing units 1 49 <<< 1. pattern group 0.5 <<< >0 line, <0 gap, =0 point 74 <<< type marker 0 <<< 0 for line group 49 <<< 2. pattern group \-0.2 74 <<< type marker 2 <<< 2 for text group 75 <<< shape number in shape\-file 0 <<< always 0 for text group 340 <<< handle to text style \(dqSTANDARD\(dq 11 46 <<< scaling factor: \(dqs\(dq in pattern definition 0.1 50 <<< rotation angle: \(dqr\(dq and \(dqu\(dq in pattern definition 0.0 44 <<< shift x units: \(dqx\(dq in pattern definition = parallel to line direction \-0.1 45 <<< shift y units: \(dqy\(dq in pattern definition = normal to line direction \-0.05 9 <<< text GAS 49 <<< 3. pattern group \-0.25 74 0 .EE .UNINDENT .UNINDENT .SS Complex Line Type SHAPE .sp ezdxf setup for line type ‘GRENZE2’: .INDENT 0.0 .INDENT 3.5 .sp .EX dwg.linetypes.new(\(aqGRENZE2\(aq, dxfattribs={ \(aqdescription\(aq: \(aqGrenze eckig \-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\-\(aq, \(aqlength\(aq: 1.45, \(aqpattern\(aq: \(aqA,.25,\-.1,[132,ltypeshp.shx,x=\-.1,s=.1],\-.1,1\(aq, }) .EE .UNINDENT .UNINDENT .SS SHAPE Tag Structure .INDENT 0.0 .INDENT 3.5 .sp .EX 0 LTYPE 5 615 330 5F 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbLinetypeTableRecord 2 GRENZE2 70 0 3 Grenze eckig \-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\- 72 <<< signature tag 65 <<< ascii code for \(dqA\(dq 73 <<< count of pattern groups starting with a code 49 tag 4 <<< 4 pattern groups 40 <<< overall pattern length in drawing units 1.45 49 <<< 1. pattern group 0.25 <<< >0 line, <0 gap, =0 point 74 <<< type marker 0 <<< 0 for line group 49 <<< 2. pattern group \-0.1 74 <<< type marker 4 <<< 4 for shape group 75 <<< shape number in shape\-file 132 340 <<< handle to shape\-file entry \(dqltypeshp.shx\(dq 616 46 <<< scaling factor: \(dqs\(dq in pattern definition 0.1 50 <<< rotation angle: \(dqr\(dq and \(dqu\(dq in pattern definition 0.0 44 <<< shift x units: \(dqx\(dq in pattern definition = parallel to line direction \-0.1 45 <<< shift y units: \(dqy\(dq in pattern definition = normal to line direction 0.0 49 <<< 3. pattern group \-0.1 74 0 49 <<< 4. pattern group 1.0 74 0 .EE .UNINDENT .UNINDENT .SS Name References .sp LTYPE table entries are referenced by name: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 all graphical DXF entities .IP \(bu 2 LAYER table entry .IP \(bu 2 DIMSTYLE table entry .IP \(bu 2 DIMSTYLE override .IP \(bu 2 MLINESTYLE .UNINDENT .UNINDENT .UNINDENT .SS STYLE Table .sp The \fI\%STYLE\fP table stores all text styles and shape\-file definitions. The “STANDARD” entry must always exist. .sp Shape\-files are also defined by a STYLE table entry, the bit 0 of the flags\-tag is set to 1 and the name\-tag is an empty string, the only important data is the font\-tag with group code 3 which stores the associated SHX font file. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DXF Reference: \fI\%TABLES Section\fP .IP \(bu 2 DXF Reference: \fI\%STYLE\fP Table .IP \(bu 2 \fI\%Textstyle\fP class .UNINDENT .UNINDENT .UNINDENT .SS Table Structure DXF R12 .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< table type STYLE 70 <<< count of table entries, AutoCAD ignores this value 1 0 <<< first table entry STYLE 2 <<< text style name Standard 70 <<< flags, see \(gaSTYLE\(ga_ reference 0 40 <<< fixed text height; 0 if not fixed 0.0 41 <<< width factor 1.0 50 <<< oblique angle 0.0 71 <<< text generation flags; 2=backwards (mirror\-x), 4=upside down (mirror\-y) 0 42 <<< last height used 2.5 3 <<< font file name; SHX or TTF file name txt 4 <<< big font name; SHX file with unicode symbols; empty if none 0 <<< next text style STYLE \&... 0 <<< end of STYLE table ENDTAB .EE .UNINDENT .UNINDENT .SS Table Structure DXF R2000+ .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of table TABLE 2 <<< table type STYLE 5 <<< table handle 5 330 <<< owner tag, tables have no owner 0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of table entries, AutoCAD ignores this value 1 0 <<< first table entry STYLE 5 <<< handle of text style 29 330 <<< owner handle, handle of STYLE table 5 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbTextStyleTableRecord 2 <<< text style name Standard 70 <<< flags, see \(gaSTYLE\(ga_ reference 0 40 <<< fixed text height; 0 if not fixed 0.0 41 <<< width factor 1.0 50 <<< oblique angle 0.0 71 <<< text generation flags; 2=backwards (mirror\-x), 4=upside down (mirror\-y) 0 42 <<< last height used 2.5 3 <<< font file name; SHX or TTF file name txt 4 <<< big font name; SHX file with unicode symbols; empty if none 0 <<< next text style STYLE \&... 0 <<< end of STYLE table ENDTAB .EE .UNINDENT .UNINDENT .SS Extended Font Data .sp Additional information of the font\-family, italic and bold style flags are stored in the XDATA section of the STYLE entity by the APPID “ACAD”: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 STYLE \&... 3 Arial.ttf 4 1001 <<< start of the XDATA section ACAD <<< APPID 1000 <<< font family name Arial 1071 <<< style flags, see table below 50331682 .EE .UNINDENT .UNINDENT .TS center; |l|l|l|. _ T{ Flag T} T{ dec T} T{ hex T} _ T{ ITALIC T} T{ 16777216 T} T{ 0x1000000 T} _ T{ BOLD T} T{ 33554432 T} T{ 0x2000000 T} _ .TE .SS Name References .sp STYLE table entries are referenced by name: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 TEXT entity .IP \(bu 2 MTEXT entity .IP \(bu 2 DIMSTYLE table entry .IP \(bu 2 DIMSTYLE override .UNINDENT .UNINDENT .UNINDENT .SS UCS Table .sp TODO .SS VIEW Table .sp The \fI\%VIEW\fP entry stores a named view of the model or a paperspace layout. This stored views makes parts of the drawing or some view points of the model in a CAD applications more accessible. This views have no influence to the drawing content or to the generated output by exporting PDFs or plotting on paper sheets, they are just for the convenience of CAD application users. .sp Using \fIezdxf\fP you have access to the views table by the attribute \fBDrawing.views\fP\&. The views table itself is not stored in the entity database, but the table entries are stored in entity database, and can be accessed by its handle. .SS DXF R12 .INDENT 0.0 .INDENT 3.5 .sp .EX 0 VIEW 2 <<< name of view VIEWNAME 70 <<< flags bit\-coded: 1st bit \-> (0/1 = modelspace/paperspace) 0 <<< modelspace 40 <<< view width in Display Coordinate System (DCS) 20.01 10 <<< view center point in DCS 40.36 <<< x value 20 <<< group code for y value 15.86 <<< y value 41 <<< view height in DCS 17.91 11 <<< view direction from target point, 3D vector 0.0 <<< x value 21 <<< group code for y value 0.0 <<< y value 31 <<< group code for z value 1.0 <<< z value 12 <<< target point in WCS 0.0 <<< x value 22 <<< group code for y value 0.0 <<< y value 32 <<< group code for z value 0.0 <<< z value 42 <<< lens (focal) length 50.0 <<< 50mm 43 <<< front clipping plane, offset from target 0.0 44 <<< back clipping plane, offset from target 0.0 50 <<< twist angle 0.0 71 <<< view mode 0 .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Coordinate Systems\fP .UNINDENT .UNINDENT .SS DXF R2000+ .sp Mostly the same structure as DXF R12, but with handle, owner tag and subclass markers. .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< adding the VIEW table head, just for information TABLE 2 <<< table name VIEW 5 <<< handle of table, see owner tag of VIEW table entry 37C 330 <<< owner tag of table, always #0 0 100 <<< subclass marker AcDbSymbolTable 70 <<< VIEW table (max.) count, not reliable (ignore) 9 0 <<< first VIEW table entry VIEW 5 <<< handle 3EA 330 <<< owner, the VIEW table is the owner of the VIEW entry 37C <<< handle of the VIEW table 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbViewTableRecord 2 <<< view name, from here all the same as DXF R12 VIEWNAME 70 0 40 20.01 10 40.36 20 15.86 41 17.91 11 0.0 21 0.0 31 1.0 12 0.0 22 0.0 32 0.0 42 50.0 43 0.0 44 0.0 50 0.0 71 0 281 <<< render mode 0\-6 (... too much options) 0 <<< 0= 2D optimized (classic 2D) 72 <<< UCS associated (0/1 = no/yes) 0 <<< 0 = no .EE .UNINDENT .UNINDENT .sp DXF R2000+ supports additional features in the VIEW entry, see the \fI\%VIEW\fP table reference provided by Autodesk. .SS VPORT Configuration Table .sp The \fI\%VPORT\fP table stores the modelspace viewport configurations. A viewport configuration is a tiled view of multiple viewports or just one viewport. [image] .sp In contrast to other tables the VPORT table can have multiple entries with the same name, because all VPORT entries of a multi\-viewport configuration are having the same name \- the viewport configuration name. The name of the actual displayed viewport configuration is \fB\(aq*ACTIVE\(aq\fP, as always table entry names are case insensitive (\fB\(aq*ACTIVE\(aq == \(aq*Active\(aq\fP). .sp The available display area in AutoCAD has normalized coordinates, the lower\-left corner is (0, 0) and the upper\-right corner is (1, 1) regardless of the true aspect ratio and available display area in pixels. A single viewport configuration has one VPORT entry \fB\(aq*ACTIVE\(aq\fP with the lower\-left corner (0, 0) and the upper\-right corner (1, 1). .sp The following statements refer to a 2D plan view: the view\-target\-point defines the origin of the DCS (Display Coordinate system), the view\-direction vector defines the z\-axis of the \fI\%DCS\fP, the view\-center\-point (in DCS) defines the point in modelspace translated to the center point of the viewport, the view height and the aspect\-ratio defines how much of the modelspace is displayed. AutoCAD tries to fit the modelspace area into the available viewport space e.g. view height is 15 units and aspect\-ratio is 2.0 the modelspace to display is 30 units wide and 15 units high, if the viewport has an aspect ratio of 1.0, AutoCAD displays 30x30 units of the modelspace in the viewport. If the modelspace aspect\-ratio is 1.0 the modelspace to display is 15x15 units and fits properly into the viewport area. .sp But tests show that the translation of the view\-center\-point to the middle of the viewport not always work as I expected. (still digging…) .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 All floating point values are rounded to 2 decimal places for better readability. .UNINDENT .UNINDENT .SS DXF R12 .sp Multi\-viewport configuration with three viewports. .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< table start TABLE 2 <<< table type VPORT 70 <<< VPORT table (max.) count, not reliable (ignore) 3 0 <<< first VPORT entry VPORT 2 <<< VPORT (configuration) name *ACTIVE 70 <<< standard flags, bit\-coded 0 10 <<< lower\-left corner of viewport 0.45 <<< x value, virtual coordinates in range [0 \- 1] 20 <<< group code for y value 0.0 <<< y value, virtual coordinates in range [0 \- 1] 11 <<< upper\-right corner of viewport 1.0 <<< x value, virtual coordinates in range [0 \- 1] 21 <<< group code for y value 1.0 <<< y value, virtual coordinates in range [0 \- 1] 12 <<< view center point (in DCS), ??? 13.71 <<< x value 22 <<< group code for y value 0.02 <<< y value 13 <<< snap base point (in DCS) 0.0 <<< x value 23 <<< group code for y value 0.0 <<< y value 14 <<< snap spacing X and Y 1.0 <<< x value 24 <<< group code for y value 1.0 <<< y value 15 <<< grid spacing X and Y 0.0 <<< x value 25 <<< group code for y value 0.0 <<< y value 16 <<< view direction from target point (in WCS), defines the z\-axis of the DCS 1.0 <<< x value 26 <<< group code for y value \-1.0 <<< y value 36 <<< group code for z value 1.0 <<< z value 17 <<< view target point (in WCS), defines the origin of the DCS 0.0 <<< x value 27 <<< group code for y value 0.0 <<< y value 37 <<< group code for z value 0.0 <<< z value 40 <<< view height 35.22 41 <<< viewport aspect ratio 0.99 42 <<< lens (focal) length 50.0 <<< 50mm 43 <<< front clipping planes, offsets from target point 0.0 44 <<< back clipping planes, offsets from target point 0.0 50 <<< snap rotation angle 0.0 51 <<< view twist angle 0.0 71 <<< view mode 0 72 <<< circle zoom percent 1000 73 <<< fast zoom setting 1 74 <<< UCSICON setting 3 75 <<< snap on/off 0 76 <<< grid on/off 0 77 <<< snap style 0 78 <<< snap isopair 0 0 <<< next VPORT entry VPORT 2 <<< VPORT (configuration) name *ACTIVE <<< same as first VPORT entry 70 0 10 0.0 20 0.5 11 0.45 21 1.0 12 8.21 22 9.41 \&... \&... 0 <<< next VPORT entry VPORT 2 <<< VPORT (configuration) name *ACTIVE <<< same as first VPORT entry 70 0 10 0.0 20 0.0 11 0.45 21 0.5 12 2.01 22 \-9.33 \&... \&... 0 ENDTAB .EE .UNINDENT .UNINDENT .SS DXF R2000+ .sp Mostly the same structure as DXF R12, but with handle, owner tag and subclass markers. .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< table start TABLE 2 <<< table type VPORT 5 <<< table handle 151F 330 <<< owner, table has no owner \- always #0 0 100 <<< subclass marker AcDbSymbolTable 70 <<< VPORT table (max.) count, not reliable (ignore) 3 0 <<< first VPORT entry VPORT 5 <<< entry handle 158B 330 <<< owner, VPORT table is owner of VPORT entry 151F 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbViewportTableRecord 2 <<< VPORT (configuration) name *ACTIVE 70 <<< standard flags, bit\-coded 0 10 <<< lower\-left corner of viewport 0.45 <<< x value, virtual coordinates in range [0 \- 1] 20 <<< group code for y value 0.0 <<< y value, virtual coordinates in range [0 \- 1] 11 <<< upper\-right corner of viewport 1.0 <<< x value, virtual coordinates in range [0 \- 1] 21 <<< group code for y value 1.0 <<< y value, virtual coordinates in range [0 \- 1] 12 <<< view center point (in DCS) 13.71 <<< x value 22 <<< group code for y value 0.38 <<< y value 13 <<< snap base point (in DCS) 0.0 <<< x value 23 <<< group code for y value 0.0 <<< y value 14 <<< snap spacing X and Y 1.0 <<< x value 24 <<< group code for y value 1.0 <<< y value 15 <<< grid spacing X and Y 0.0 <<< x value 25 <<< group code for y value 0.0 <<< y value 16 <<< view direction from target point (in WCS) 1.0 <<< x value 26 <<< group code for y value \-1.0 <<< y value 36 <<< group code for z value 1.0 <<< z value 17 <<< view target point (in WCS) 0.0 <<< x value 27 <<< group code for y value 0.0 <<< y value 37 <<< group code for z value 0.0 <<< z value 40 <<< view height 35.22 41 <<< viewport aspect ratio 0.99 42 <<< lens (focal) length 50.0 <<< 50mm 43 <<< front clipping planes, offsets from target point 0.0 44 <<< back clipping planes, offsets from target point 0.0 50 <<< snap rotation angle 0.0 51 <<< view twist angle 0.0 71 <<< view mode 0 72 <<< circle zoom percent 1000 73 <<< fast zoom setting 1 74 <<< UCSICON setting 3 75 <<< snap on/off 0 76 <<< grid on/off 0 77 <<< snap style 0 78 <<< snap isopair 0 281 <<< render mode 1\-6 (... too many options) 0 <<< 0 = 2D optimized (classic 2D) 65 <<< Value of UCSVP for this viewport. (0 = UCS will not change when this viewport is activated) 1 <<< 1 = then viewport stores its own UCS which will become the current UCS whenever the viewport is activated. 110 <<< UCS origin (3D point) 0.0 <<< x value 120 <<< group code for y value 0.0 <<< y value 130 <<< group code for z value 0.0 <<< z value 111 <<< UCS X\-axis (3D vector) 1.0 <<< x value 121 <<< group code for y value 0.0 <<< y value 131 <<< group code for z value 0.0 <<< z value 112 <<< UCS Y\-axis (3D vector) 0.0 <<< x value 122 <<< group code for y value 1.0 <<< y value 132 <<< group code for z value 0.0 <<< z value 79 <<< Orthographic type of UCS 0\-6 (... too many options) 0 <<< 0 = UCS is not orthographic 146 <<< elevation 0.0 1001 <<< extended data \- undocumented ACAD_NAV_VCDISPLAY 1070 3 0 <<< next VPORT entry VPORT 5 158C 330 151F 100 AcDbSymbolTableRecord 100 AcDbViewportTableRecord 2 <<< VPORT (configuration) name *ACTIVE <<< same as first VPORT entry 70 0 10 0.0 20 0.5 11 0.45 21 1.0 12 8.21 22 9.72 \&... \&... 0 <<< next VPORT entry VPORT 5 158D 330 151F 100 AcDbSymbolTableRecord 100 AcDbViewportTableRecord 2 <<< VPORT (configuration) name *ACTIVE <<< same as first VPORT entry 70 0 10 0.0 20 0.0 11 0.45 21 0.5 12 2.01 22 \-8.97 \&... \&... 0 ENDTAB .EE .UNINDENT .UNINDENT .sp The TABLES section of DXF R13 and later looks like this: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 SECTION 2 <<< begin TABLES section TABLES 0 <<< first TABLE TABLE 2 <<< name of table \(dqLTYPE\(dq LTYPE 5 <<< handle of the TABLE 8 330 <<< owner handle is always \(dq0\(dq 0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of table entries 4 <<< do not rely on this value! 0 <<< first table entry LTYPE \&... 0 <<< second table entry LTYPE \&... 0 <<< end of TABLE ENDTAB 0 <<< next TABLE TABLE 2 <<< name of table \(dqLAYER\(dq LAYER 5 <<< handle of the TABLE 2 330 <<< owner handle is always \(dq0\(dq 0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of table entries 1 0 <<< first table entry LAYER \&... 0 <<< end of TABLE ENDTAB 0 <<< end of SECTION ENDSEC .EE .UNINDENT .UNINDENT .sp The TABLES section of DXF R12 and prior is a bit simpler and does not contain the BLOCK_RECORD table. The handles in DXF R12 and prior are optional and only present if the HEADER variable $HANDLING is 1. .INDENT 0.0 .INDENT 3.5 .sp .EX 0 SECTION 2 <<< begin TABLES section TABLES 0 <<< first TABLE TABLE 2 <<< name of table \(dqLTYPE\(dq LTYPE 5 <<< optional handle of the TABLE 8 70 <<< count of table entries 4 0 <<< first table entry LTYPE \&... 0 <<< second table entry LTYPE \&... 0 <<< end of TABLE ENDTAB 0 <<< next TABLE TABLE 2 <<< name of table \(dqLAYER\(dq LAYER 5 <<< optional handle of the TABLE 2 70 <<< count of table entries 1 0 <<< first table entry LAYER \&... 0 <<< end of TABLE ENDTAB 0 <<< end of SECTION ENDSEC .EE .UNINDENT .UNINDENT .SS BLOCKS Section .sp The BLOCKS section contains all BLOCK definitions, beside the \fInormal\fP reusable BLOCKS used by the INSERT entity, all layouts, as there are the modelspace and all paperspace layouts, have at least a corresponding BLOCK definition in the BLOCKS section. The name of the modelspace BLOCK is “*Model_Space” (DXF R12: “$MODEL_SPACE”) and the name of the \fIactive\fP paperspace BLOCK is “*Paper_Space” (DXF R12: “$PAPER_SPACE”), the entities of these two layouts are stored in the ENTITIES section, the \fIinactive\fP paperspace layouts are named by the scheme “*Paper_Spacennnn”, and the content of the inactive paperspace layouts are stored in their BLOCK definition in the BLOCKS section. .sp The content entities of blocks are stored between the BLOCK and the ENDBLK entity. .sp BLOCKS section structure: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of a SECTION SECTION 2 <<< start of BLOCKS section BLOCKS 0 <<< start of 1. BLOCK definition BLOCK \&... <<< Block content \&... 0 <<< end of 1. Block definition ENDBLK 0 <<< start of 2. BLOCK definition BLOCK \&... <<< Block content \&... 0 <<< end of 2. Block definition ENDBLK 0 <<< end of BLOCKS section ENDSEC .EE .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fI\%Block Management Structures\fP \fI\%Layout Management Structures\fP .UNINDENT .UNINDENT .SS ENTITIES Section .sp TODO .SS OBJECTS Section .sp Objects in the OBJECTS section are organized in a hierarchical tree order, starting with the \fInamed objects dictionary\fP as the first entity in the OBJECTS section (\fBDrawing.rootdict\fP). .sp Not all entities in the OBJECTS section are included in this tree, \fI\%Extension Dictionary\fP and XRECORD data of graphical entities are also stored in the OBJECTS section. .SS DXF Tables .SS DXF Entities .SS DIMENSION Internals .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DXF Reference: \fI\%DIMENSION\fP .IP \(bu 2 DXFInternals: \fI\%DIMSTYLE Table\fP .UNINDENT .UNINDENT .UNINDENT [image] .SS MESH Internals .sp The MESH entity is the compact version of the PolyFaceMesh implemented by the \fI\%Polyline\fP entity . The entity stores the vertices, edges and faces in a single entity and was introduced in DXF version R13/R14. For more information about the top level stuff go to the \fI\%Mesh\fP class. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DXF Reference: \fI\%MESH\fP .IP \(bu 2 \fI\%ezdxf.entities.Mesh\fP class .UNINDENT .UNINDENT .UNINDENT .sp The following DXF code represents this cube with subdivision level of 0: [image] .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MESH <<< DXF type 5 <<< entity handle 2F 330 <<< block record handle of owner layout 17 100 AcDbEntity 8 0 <<< layer 62 6 <<< color 100 AcDbSubDMesh <<< subclass marker 71 2 <<< version 72 1 <<< blend crease, 1 is \(dqon\(dq, 0 is \(dqoff\(dq 91 0 <<< subdivision level is 0 92 8 <<< vertex count, 8 cube corners 10 <<< 1. vertex, x\-axis 0.0 20 <<< y\-axis 0.0 30 <<< z\-axis 0.0 10 <<< 2. vertex 1.0 20 0.0 30 0.0 10 <<< 3. vertex 1.0 20 1.0 30 0.0 10 <<< 4. vertex 0.0 20 1.0 30 0.0 10 <<< 5. vertex 0.0 20 0.0 30 1.0 10 <<< 6. vertex 1.0 20 0.0 30 1.0 10 <<< 7. vertex 1.0 20 1.0 30 1.0 10 <<< 8. vertex 0.0 20 1.0 30 1.0 93 <<< size of face list 30 <<< size = count of group code 90 tags = 6 x 5 90 <<< vertex count of face 1 4 <<< MESH supports ngons, count = 3, 4, 5, 6 ... 90 0 <<< face 1, index of 1. vertex 90 3 <<< face 1, index of 2. vertex 90 2 <<< face 1, index of 3. vertex 90 1 <<< face 1, index of 4. vertex 90 4 <<< vertex count of face 2 90 4 <<< face 2, index of 1. vertex 90 5 <<< face 2, index of 2. vertex 90 6 <<< face 2, index of 3. vertex 90 7 <<< face 2, index of 4. vertex 90 4 <<< vertex count of face 3 90 0 <<< face 3, index of 1. vertex 90 1 <<< face 3, index of 2. vertex 90 5 <<< face 3, index of 3. vertex 90 4 <<< face 3, index of 4. vertex 90 4 <<< vertex count of face 4 90 1 <<< face 4, index of 1. vertex 90 2 <<< face 4, index of 2. vertex 90 6 <<< face 4, index of 3. vertex 90 5 <<< face 4, index of 4. vertex 90 4 <<< vertex count of face 5 90 3 <<< face 5, index of 1. vertex 90 7 <<< face 5, index of 2. vertex 90 6 <<< face 5, index of 3. vertex 90 2 <<< face 5, index of 4. vertex 90 4 <<< vertex count of face 6 90 0 <<< face 6, index of 1. vertex 90 4 <<< face 6, index of 2. vertex 90 7 <<< face 6, index of 3. vertex 90 3 <<< face 6, index of 4. vertex 94 <<< edge count, each edge has exact two group code 90 tags 4 <<< the real edge count not the group code 90 tags! 90 0 <<< edge 1, vertex 1 90 1 <<< edge 1, vertex 1 90 1 <<< edge 2, vertex 1 90 2 <<< edge 2, vertex 2 90 2 <<< edge 3, vertex 1 90 3 <<< edge 3, vertex 2 90 3 <<< edge 4, vertex 1 90 0 <<< edge 4, vertex 2 95 <<< edge crease count, has to match edge count! 4 140 3.0 <<< crease value for edge 1 140 3.0 <<< crease value for edge 2 140 3.0 <<< crease value for edge 3 140 3.0 <<< crease value for edge 4 90 <<< property overwrite??? 0 .EE .UNINDENT .UNINDENT .sp The edge and crease data have only a meaning if subdivision of the geometry will be applied! A crease value equal to the subdivision level prevents subdividing for the edge completely, a value between 0.0 and the subdivision level applies subdivision partially. .sp The cube with subdivision level of 3 and crease values of 3.0: [image] .sp Front view for better details: [image] .sp The cube with subdivision levels of 3 and crease values of 2.0: [image] .sp The cube with subdivision level of 3 and crease values of 1.0: [image] .sp The property overriding protocol is not documented in the DXF reference and currently I have no access to a CAD application which can created property overriding. .SS MULTILEADER Internals .sp The MULTILEADER leader is a very complex entity and has also some weird and unique properties. .INDENT 0.0 .IP 1. 3 MULTILEADER has the alias name MLEADER which is accepted by any \fI\%reliable CAD application\fP, but all of them create the entity as MULTILEADER .IP 2. 3 uses \fI\%raw\-color\fP values to define colors .IP 3. 3 creates a complex context data structures beyond simple tags inside the subclass \fBAcDbMLeader\fP .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%ezdxf.entities.MultiLeader\fP .IP \(bu 2 \fI\%ezdxf.entities.MLeaderStyle\fP .IP \(bu 2 \fI\%ezdxf.render.MultiLeaderBuilder\fP .IP \(bu 2 \fI\%Tutorial for MultiLeader\fP .IP \(bu 2 DXF Reference: \fI\%MLEADER\fP .UNINDENT .UNINDENT .UNINDENT .sp Example for \fI\%ezdxf.entities.MLeaderContext\fP created by BricsCAD: .INDENT 0.0 .INDENT 3.5 .sp .EX 300 CONTEXT_DATA{ 40 1.0 <<< content scale 10 (x, y, z) <<< content base point 41 4.0 <<< text height 140 4.0 <<< arrowhead size 145 2.0 <<< landing gap size 174 1 <<< doc missing 175 1 <<< doc missing 176 0 <<< doc missing 177 0 <<< doc missing 290 1 <<< has_mtext_content <<< START MText Content tags: 304 MTEXT content string 11 (0.0, 0.0, 1.0) <<< extrusion vector 340 #A0 <<< text style as handle 12 (x, y, z) <<< text location 13 (1.0, 0.0, 0.0) <<< text direction 42 0.0 <<< text rotation 43 0.0 <<< text width 44 0.0 <<< text height 45 1.0 <<< text line space factor 170 1 <<< text line space style 90 \-1056964608 <<< text color (raw value) 171 1 <<< text attachment 172 1 <<< text flow direction 91 \-939524096 <<< text background color (raw value) 141 1.5 <<< text background scale factor 92 0 <<< text background transparency 291 0 <<< has_text_bg_color 292 0 <<< has_text_bg_fill 173 0 <<< text column type 293 0 <<< use text auto height 142 0.0 <<< text column width 143 0.0 <<< text column gutter width 294 0 <<< text column flow reversed 144 missing <<< text column height (optional?) 295 0 <<< text use word break <<< END MText Content tags: 296 0 <<< has_block_content <<< START Block content tags <<< END Block content tags 110 (0.0, 0.0, 0.0) <<< MLEADER plane origin point 111 (1.0, 0.0, 0.0) <<< MLEADER plane x\-axis direction 112 (0.0, 1.0, 0.0) <<< MLEADER plane y\-axis direction 297 0 <<< MLEADER normal reversed 302 LEADER{ \&... 303 } 302 LEADER{ \&... 303 } 272 9 <<< doc missing 273 9 <<< doc missing 301 } <<< BricsCAD example for block content: 300 CONTEXT_DATA{ 40 1.0 10 (x, y, z) 41 4.0 140 4.0 145 2.0 174 1 175 1 176 0 177 0 290 0 <<< has_mtext_content 296 1 <<< has_block_content <<< START Block content tags 341 #94 <<< dxf.block_record_handle 14 (0.0, 0.0, 1.0) <<< Block extrusion vector 15 (x, y, z) <<< Block location 16 (1.0, 1.0, 1.0) <<< Block scale vector, the x\-, y\- and z\-axis scaling factors 46 0.0 <<< Block rotation in radians! 93 \-1056964608 <<< Block color (raw value) 47 1.0 <<< start of transformation matrix (16x47) 47 0.0 47 0.0 47 18.427396871473 47 0.0 47 1.0 47 0.0 47 0.702618780008 47 0.0 47 0.0 47 1.0 47 0.0 47 0.0 47 0.0 47 0.0 47 1.0 <<< end of transformation matrix <<< END Block content tags 110 (0.0, 0.0, 0.0) <<< MLEADER plane origin point 111 (1.0, 0.0, 0.0) <<< MLEADER plane x\-axis direction 112 (0.0, 1.0, 0.0) <<< MLEADER plane y\-axis direction 297 0 <<< MLEADER normal reversed 302 LEADER{ \&... 303 } 272 9 273 9 301 } <<< Attribute content and other redundant block data is stored in the AcDbMLeader <<< subclass: 100 AcDbMLeader 270 2 <<< dxf.version 300 CONTEXT_DATA{ <<< start context data \&... 301 } <<< end context data 340 #6D <<< dxf.style_handle 90 6816768 <<< dxf.property_override_flags \&... <<< property overrides 292 0 <<< dxf.has_frame_text <<< mostly redundant block data: 344 #94 <<< dxf.block_record_handle 93 \-1056964608 <<< dxf.block_color (raw value) 10 (1.0, 1.0, 1.0) <<< dxf.block_scale_vector 43 0.0 <<< dxf.block_rotation in radians! 176 0 <<< dxf.block_connection_type 293 0 <<< dxf.is_annotative <<< REPEAT: (optional) 94 <<< arrow head index? 345 <<< arrow head handle <<< REPEAT: (optional) 330 #A3 <<< ATTDEF handle 177 1 <<< ATTDEF index 44 0.0 <<< ATTDEF width 302 B <<< ATTDEF text (reused group code) \&... common group codes 294, 178, 179, ... .EE .UNINDENT .UNINDENT .SS MTEXT Internals .sp The MTEXT entity stores multiline text in a single entity and was introduced in DXF version R13/R14. For more information about the top level stuff go to the \fI\%MText\fP class. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 DXF Reference: \fI\%MTEXT\fP .IP \(bu 2 \fI\%ezdxf.entities.MText\fP class .UNINDENT .UNINDENT .UNINDENT .SS Orientation .sp The MTEXT entity does not establish an OCS. The entity has a \fBtext_direction\fP attribute, which defines the local x\-axis, the \fBextrusion\fP attribute defines the normal vector and the y\-axis = extrusion cross x\-axis. .sp The MTEXT entity can have also a \fBrotation\fP attribute (in degrees), the x\-axis attribute has higher priority than the \fBrotation\fP attribute, but it is not clear how to convert the \fBrotation\fP attribute into a \fBtext_direction\fP vector, but for most common cases, where only the \fBrotation\fP attribute is present, the \fBextrusion\fP is most likely the WCS z\-axis and the \fBrotation\fP is the direction in the xy\-plane. .SS Text Content .sp The content text is divided across multiple tags of group code 3 and 1, the last line has the group code 1, each line can have a maximum line length of 255 bytes, but BricsCAD (and AutoCAD?) store only 249 bytes in single line and one byte is not always one char. .SS Inline Code Specials .sp The text formatting is done by inline codes, see the \fI\%MText\fP class. .sp Information gathered by implementing the \fBMTextEditor\fP and the \fBMTextParser\fP classes: .INDENT 0.0 .IP \(bu 2 .INDENT 2.0 .TP .B caret encoded characters: .INDENT 7.0 .IP \(bu 2 “^I” tabulator .IP \(bu 2 “^J” (LF) is a valid line break like “\eP” .IP \(bu 2 “^M” (CR) is ignored .IP \(bu 2 other characters render as empty square “▯” .IP \(bu 2 a space “ “ after the caret renders the caret glyph: “1^ 2” renders “1^2” .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B special encoded characters: .INDENT 7.0 .IP \(bu 2 “%%c” and “%%C” renders “Ø” (alt\-0216) .IP \(bu 2 “%%d” and “%%D” renders “°” (alt\-0176) .IP \(bu 2 “%%p” and “%%P” renders “±” (alt\-0177) .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Alignment command “\eA”: argument “0”, “1” or “2” is expected .INDENT 7.0 .IP \(bu 2 the terminator symbol “;” is optional .IP \(bu 2 the arguments “3”, “4”, “5”, “6”, “7”, “8”, “9” and “\-” default to 0 .IP \(bu 2 other characters terminate the command and will be printed: “\eAX”, renders “X” .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B ACI color command “\eC”: int argument is expected .INDENT 7.0 .IP \(bu 2 the terminator symbol “;” is optional .IP \(bu 2 a leading “\-” or “+” terminates the command, “\eC+5” renders “\eC+5” .IP \(bu 2 arguments > 255, are ignored but consumed “\eC1000” renders nothing, not even a “0” .IP \(bu 2 a trailing “;” after integers is always consumed, even for much to big values, “\eC10000;” renders nothing .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B RGB color command “\ec”: int argument is expected .INDENT 7.0 .IP \(bu 2 the terminator symbol “;” is optional .IP \(bu 2 a leading “\-” or “+” terminates the command, “\ec+255” renders “\ec+255” .IP \(bu 2 arguments >= 16777216 are masked by: value & 0xFFFFFF .IP \(bu 2 a trailing “;” after integers is always consumed, even for much to big values, “\ec9999999999;” renders nothing and switches the color to yellow (255, 227, 11) .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Height command “\eH” and “\eH…x”: float argument is expected .INDENT 7.0 .IP \(bu 2 the terminator symbol “;” is optional .IP \(bu 2 a leading “\-” is valid, but negative values are ignored .IP \(bu 2 a leading “+” is valid .IP \(bu 2 a leading “.” is valid like “\eH.5x” for height factor 0.5 .IP \(bu 2 exponential format is valid like “\eH1e2” for height factor 100 and “\eH1e\-2” for 0.01 .IP \(bu 2 an invalid floating point value terminates the command, “\eH1..5” renders “\eH1..5” .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Other commands with floating point arguments like the height command: .INDENT 7.0 .IP \(bu 2 Width commands “\eW” and “\eW…x” .IP \(bu 2 Character tracking commands “\eT” and “\eT…x”, negative values are used .IP \(bu 2 Slanting (oblique) command “\eQ” .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Stacking command “\eS”: .INDENT 7.0 .IP \(bu 2 build fractions: “numerator (upr)” + “stacking type char (t)” + “denominator (lwr)” + “;” .IP \(bu 2 divider chars: “^”, “/” or “#” .IP \(bu 2 a space “ “ after the divider char “^” is mandatory to avoid caret decoding: “\eS1^ 2;” .IP \(bu 2 the terminator symbol “;” is mandatory to end the command, all chars beyond the “\eS” until the next “;” or the end of the string are part of the fraction .IP \(bu 2 backslash escape “\e;” to render the terminator char .IP \(bu 2 a space “ “ after the divider chars “/” and “#” is rendered as space “ ” in front of the denominator .IP \(bu 2 the numerator and denominator can contain spaces .IP \(bu 2 backslashes “\e” inside the stacking command are ignored (except “\e;”) “\eS\eN^ \eP” render “N” over “P”, therefore property changes (color, text height, …) are not possible inside the stacking command .IP \(bu 2 grouping chars “{” and “}” render as simple curly braces .IP \(bu 2 caret encoded chars are decoded “^I”, “^J”, “^M”, but render as a simple space “ “ or as the replacement char “▯” plus a space .IP \(bu 2 a divider char after the first divider char, renders as the char itself: “\eS1/2/3” renders the horizontal fraction “1” / “2/3” .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Font command “\ef” and “\eF”: export only “\ef”, parse both, “\eF” ignores some arguments .INDENT 7.0 .IP \(bu 2 the terminator symbol “;” is mandatory to end the command, all chars beyond the “\ef” until the next “;” or the end of the string are part of the command .IP \(bu 2 the command arguments are separated by the pipe char “|” .IP \(bu 2 arguments: “font family name” | “bold” | “italic” | “codepage” | “pitch”; example “\efArial|b0|i0|c0|p0;” .IP \(bu 2 only the “font family name” argument is required, fonts which are not available on the system are replaced by the “TXT.SHX” shape font .IP \(bu 2 the “font family name” is the font name shown in font selection widgets in desktop applications .IP \(bu 2 “b1” to use the bold font style, any other second char is interpreted as “non bold” .IP \(bu 2 “i1” to use an italic font style, any other second char is interpreted as “non italic” .IP \(bu 2 “c???” change codepage, “c0” use the default codepage, because of the age of unicode no further investigations, also seems to be ignored by AutoCAD and BricsCAD .IP \(bu 2 “p???” change pitch size, “p0” means don’t change, ignored by AutoCAD and BricsCAD, to change the text height use the “\eH” command .IP \(bu 2 the order is not important, but export always in the shown order: “\efArial|b0|i0;” the arguments “c0” and “p0” are not required .UNINDENT .UNINDENT .IP \(bu 2 .INDENT 2.0 .TP .B Paragraph properties command “\ep” .INDENT 7.0 .IP \(bu 2 the terminator symbol “;” is mandatory to end the command, all chars beyond the “\ep” until the next “;” or the end of the string are part of the command .IP \(bu 2 the command arguments are separated by commas “,” .IP \(bu 2 all values are factors for the initial char height of the MTEXT entity, example: char height = 2.5, “\epl1;” set the left paragraph indentation to 1 x 2.5 = 2.5 drawing units. .IP \(bu 2 all values are floating point values, see height command .IP \(bu 2 arguments are “i”, “l”, “r”, “q”, “t” .IP \(bu 2 a “*” as argument value, resets the argument to the initial value: “i0”, “l0”, “r0”, the “q” argument most likely depends on the text direction; I haven’t seen “t*”. The sequence used by BricsCAD to reset all values is \fB\(dq\epi*,l*,r*,q*,t;\(dq\fP .IP \(bu 2 “i” indentation of the first line relative to the “l” argument as floating point value, “\epi1.5” .IP \(bu 2 “l” left paragraph indentation as floating point value, “\epl1.5” .IP \(bu 2 “r” right paragraph indentation as floating point value, “\epr1.5” .IP \(bu 2 “x” is required if a “q” or a “t” argument is present, the placement of the “x” has no obvious rules .IP \(bu 2 “q” paragraph alignment .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 “ql” left paragraph alignment .IP \(bu 2 “qr” right paragraph alignment .IP \(bu 2 “qc” center paragraph alignment .IP \(bu 2 “qj” justified paragraph alignment .IP \(bu 2 “qd” distributed paragraph alignment .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 “t” tabulator stops as comma separated list, the default tabulator stops are located at 4, 8, 12, …, by defining at least one tabulator stop, the default tabulator stops will be ignored. There 3 kind of tabulator stops: left, right and center adjusted stops, e.g. “pxt1,r5,c8”: .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 a left adjusted stop has no leading char, two left adjusted stops “\epxt1,2;” .IP \(bu 2 a right adjusted stop has a preceding “r” char, “\epxtr1,r2;” .IP \(bu 2 a center adjusted stop has a preceding “c” char, “\epxtc1,c2;” .UNINDENT .UNINDENT .UNINDENT .sp complex example to create a numbered list with two items: \fB\(dqpxi\-3,l4t4;1.^Ifirst item\eP2.^Isecond item\(dq\fP .IP \(bu 2 a parser should be very flexible, I have seen several different orders of the arguments and placing the sometimes required “x” has no obvious rules. .IP \(bu 2 exporting seems to be safe to follow these three rules: .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP 1. 3 the command starts with “\epx”, the “x” does no harm, if not required .IP 2. 3 argument order “i”, “l”, “r”, “q”, “t”, any of the arguments can be left off .IP 3. 3 terminate the command with a “;” .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Height Calculation .sp There is no reliable way to calculate the MTEXT height from the existing DXF attributes. The \fBrect_height\fP (group code 43) attribute is not required and seldom present. DXF R2007 introduced the \fBdefined_height\fP attribute to store the defined column height of the MTEXT entity but only in column mode. MTEXT entities without columns, except MTEXT entities created with column type “No Columns”, store always 0.0 as defined column height. Which seems to mean: defined by the rendered text content. .sp The only way to calculate the MTEXT height is to replicate the rendering results of AutoCAD/BricsCAD by implementing a rendering engine for MTEXT. .sp In column mode the MTEXT height is stored for every column for DXF version before R2018. In DXF R2018+ the column heights are only stored if \fBMTextColumns.auto_height\fP is \fBFalse\fP\&. If \fBMTextColumns.auto_height\fP is \fBTrue\fP\&. But DXF R2018+ stores the MTEXT total width and height in explicit attributes. .SS Width Calculation .sp The situation for width calculation is better than for the height calculation, but the attributes \fBwidth\fP and \fBrect_width\fP are not mandatory. .sp There is a difference between MTEXT entities with and without columns: .sp Without columns the attribute \fBwidth\fP (reference column width) contains the true entity width if present. A long word can overshoot this width! The \fBrect_width\fP attribute is seldom present. .sp For MTEXT with columns, the \fBwidth\fP attribute is maybe wrong, the correct width for a column is stored in the \fBcolumn_width\fP attribute and the \fBtotal_width\fP attribute stores the total width of the MTEXT entity overall columns, see also following section “Column Support”. .SS Background Filling .sp The background fill support is available for DXF R2007+. The group code 90 defines the kind of background fill: .TS center; |l|l|. _ T{ 0 T} T{ off T} _ T{ 1 T} T{ color defined by group code 63, 421 or 431 T} _ T{ 2 T} T{ drawing window color T} _ T{ 3 T} T{ background (canvas) color T} _ T{ 16 T} T{ bit\-flag text frame, see Open Design Alliance Specification 20.4.46 T} _ .TE .sp Group codes to define background fill attributes: .TS center; |l|l|. _ T{ 45 T} T{ scaling factor for the border around the text, the value should be in the range of [1, 5], where 1 fits exact the MText entity T} _ T{ 63 T} T{ set the background color by \fI\%ACI\fP\&. T} _ T{ 421 T} T{ set the background color as \fI\%true\-color\fP value. T} _ T{ 431 T} T{ set the background color by color name \- no idea how this works T} _ T{ 441 T} T{ set the transparency of the background fill, not supported by AutoCAD or BricsCAD. T} _ .TE .sp Group codes 45, 90 and 63 are required together if one of them is used. The group code 421 and 431 also requires the group code 63, even this value is ignored. .INDENT 0.0 .INDENT 3.5 .sp .EX \&... 1 eu feugiat nulla facilisis at vero eros et accumsan et iusto ... 73 1 44 1.0 90 1, b00000001 <<< use a color 63 1 <<< ACI color (red) 45 1.5 <<< bg scaling factor, relative to the char height 441 0 <<< ignored (optional) \&... .EE .UNINDENT .UNINDENT [image] .sp The background scaling does not alter the \fBwidth\fP, \fBcolumn_width\fP or \fBtotal_width\fP attributes. The background acquires additional space around the MTEXT entity. .sp Columns with background color: [image] .SS Text Frame .sp The MTEXT entity can have a text frame only, without a background filling, group code 90 has value 16. In this case all other background related tags are removed (45, 63, 421, 431, 441) and the scaling factor is 1.5 by default. .SS XDATA for Text Frame .sp This XDATA exist only if the text frame flag in group code 90 is set and for DXF version < R2018! .INDENT 0.0 .INDENT 3.5 .sp .EX \&... 1001 ACAD 1000 ACAD_MTEXT_TEXT_BORDERS_BEGIN 1070 80 <<< group code for repeated flags 1070 16 <<< repeated group code 90? 1070 46 <<< group code for scaling factor, which is fixed? 1040 1.5 <<< scaling factor 1070 81 <<< group code for repeated flow direction? 1070 1 <<< flow direction? 1070 5 <<< group code for a handle, multiple entries possible 1005 #A8 <<< handle to the LWPOLYLINE text frame 1070 5 <<< group code for next handle 1005 #A9 <<< next handle \&... 1000 ACAD_MTEXT_TEXT_BORDERS_END .EE .UNINDENT .UNINDENT .SS Extra LWPOLYLINE Entity as Text Frame .sp The newer versions of AutoCAD and BricsCAD get all the information they need from the MTEXT entity, but it seems that older versions could not handle the text frame property correct. Therefore AutoCAD and BricsCAD create a separated LWPOLYLINE entity for the text frame for DXF versions < R2018. The handle to this text frame entity is stored in the XDATA as group code 1005, see section above. .sp Because this LWPOLYLINE is not required \fIezdxf\fP does \fBnot\fP create such a text frame entity nor the associated XDATA and \fIezdxf\fP also \fBremoves\fP this data from loaded DXF files at the second loading stage. .SS Column Support .sp CAD applications build multiple columns by linking 2 or more MTEXT entities together. In this case each column is a self\-sufficient entity in DXF version R13 until R2013. The additional columns specifications are stored in the XDATA if the MTEXT which represents the first column. .sp DXF R2018 changed the implementation into a single MTEXT entity which contains all the content text at once and stores the column specification in an embedded object. .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 The \fBwidth\fP attribute for the linked MTEXT entities could be wrong. Always use the \fBcolumn_width\fP and the \fBtotal_width\fP attributes in column mode. .UNINDENT .UNINDENT .sp There are two column types, the \fBstatic\fP type has the same column height for all columns, the \fBdynamic\fP type can have the same (auto) height or an individual height for each column. .sp Common facts about columns for all column types: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 all columns have the same column width .IP \(bu 2 all columns have the same gutter width .IP \(bu 2 the top of the column are at the same height .UNINDENT .UNINDENT .UNINDENT .SS Column Type .sp The column type defines how a CAD application should create the columns, this is not important for the file format, because the result of this calculation, the column count and the column height, is stored the DXF file. .TS center; |l|l|. _ T{ Column Type in BricsCAD T} T{ Description T} _ T{ Static T} T{ All columns have the same height. The “auto height” flag is 0. T} _ T{ Dynamic (auto height) T} T{ Same as the static type, all columns have the same height. The “auto height” flag is 1. The difference to the static type is only important for interactive CAD applications. T} _ T{ Dynamic (manual height) T} T{ same as the dynamic (auto height) type, but each column can have an individual height. T} _ T{ No column T} T{ A regular MTEXT with “defined column height” attribute? T} _ .TE .TS center; |l|l|l|l|. _ T{ Column Type T} T{ Defined Height T} T{ Auto Height T} T{ Column Heights T} _ T{ Static T} T{ stored T} T{ False T} T{ not stored T} _ T{ Dynamic auto T} T{ stored T} T{ True T} T{ not stored T} _ T{ Dynamic manual T} T{ not stored T} T{ False T} T{ stored (last=0) T} _ .TE .SS Column Count .sp For DXF versions < R2018 the column count is always given by the count of linked MTEXT columns. Caution: the column count stored in the XDATA section by group code 76 may not match the count of linked MTEXT entities and AutoCAD is OK with that! In DXF R2018+ this property is not available, because there are no linked MTEXT entities anymore. .sp R2018+: For the column types “static” and “dynamic manual” the correct column count is stored as group code 72. For the column type “dynamic auto” the stored \fIcolumn count is 0\fP\&. It is possible to calculate the column count from the total width and the column width if the total width is correct like in AutoCAD and BricsCAD. .SS Static Columns R2000 .sp Example for a \fBstatic\fP column specification: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Column Type: Static .IP \(bu 2 Number of Columns: 3 .IP \(bu 2 Height: 150.0, manual entered value and all columns have the same height .IP \(bu 2 Width: 50.0 .IP \(bu 2 Gutter Width: 12.5 .UNINDENT .UNINDENT .UNINDENT [image] .sp The column height is stored as the “defined column height” in XDATA (46) or the embedded object (41). .sp DXF R2000 example with a static column specification stored in XDATA: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT 5 <<< entity handle 9D 102 {ACAD_XDICTIONARY 360 9F 102 } 330 <<< block record handle of owner layout 1F 100 AcDbEntity 8 <<< layer 0 100 <<< begin of MTEXT specific data AcDbMText 10 <<< (10, 20, 30) insert location in WCS 285.917876152751 20 276.101821192053 30 0.0 40 <<< character height in drawing units 2.5 41 <<< reference column width, if not in column mode 62.694... <<< in column mode: the real column is defined in XDATA (48) 71 <<< attachment point 1 72 <<< text flow direction 1 3 <<< begin of text Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ... 3 kimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit ... 3 ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ... 3 At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd ... 3 ore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio ... 1 <<< last text line and end of text euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. 73 <<< line spacing style 1 44 <<< line spacing factor 1.0 1001 AcadAnnotative 1000 AnnotativeData 1002 { 1070 1 1070 0 1002 } 1001 <<< AppID \(dqACAD\(dq contains the column specification ACAD 1000 ACAD_MTEXT_COLUMN_INFO_BEGIN 1070 75 <<< group code column type 1070 1 <<< column type: 0=no column; 1=static columns; 2=dynamic columns 1070 79 <<< group code column auto height 1070 0 <<< flag column auto height 1070 76 <<< group code column count 1070 3 <<< column count 1070 78 <<< group code column flow reversed 1070 0 <<< flag column flow reversed 1070 48 <<< group code column width 1040 50.0 <<< column width in column mode 1070 49 <<< group code column gutter 1040 12.5 <<< column gutter width 1000 ACAD_MTEXT_COLUMN_INFO_END 1000 <<< linked MTEXT entities specification ACAD_MTEXT_COLUMNS_BEGIN 1070 47 <<< group code for column count, incl. the 1st column \- this entity 1070 3 <<< column count 1005 1B4 <<< handle to 2nd column as MTEXT entity 1005 1B5 <<< handle to 3rd column as MTEXT entity 1000 ACAD_MTEXT_COLUMNS_END 1000 ACAD_MTEXT_DEFINED_HEIGHT_BEGIN 1070 46 <<< group code for defined column height 1040 150.0 <<< defined column height 1000 ACAD_MTEXT_DEFINED_HEIGHT_END .EE .UNINDENT .UNINDENT .sp The linked column MTEXT \fB#1B4\fP in a compressed representation: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT \&... 100 AcDbMText 10 (348.417876152751, 276.101821192053, 0.0) 40 2.5 41 175.0 <<< invalid reference column width \&... 1001 ACAD 1000 ACAD_MTEXT_DEFINED_HEIGHT_BEGIN 1070 46 <<< defined column height 1040 150.0 1000 ACAD_MTEXT_DEFINED_HEIGHT_END .EE .UNINDENT .UNINDENT .sp The linked MTEXT has no column specification except the “defined column height” in the XDATA. The reference column \fBwidth\fP is not the real value of 50.0, see XDATA group code 48 in the main MTEXT \fB#9D\fP, instead the total width of 175.0 is stored at group code 41. This is problem if a renderer try to render this MTEXT as a standalone entity. The renderer has to fit the content into the column width by itself and without the correct column width, this will produce an incorrect result. .sp There exist no back link to the main MTEXT \fB#9D\fP\&. The linked MTEXT entities appear after the main MTEXT in the layout space, but there can be other entities located between these linked MTEXT entities. .sp The linked column MTEXT \fB#1B5\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT 5 #1B5 \&... 100 AcDbMText 10 (410.917876152751, 276.101821192053, 0.0) 40 2.5 41 175.0 <<< invalid reference column width \&... 1001 ACAD 1000 ACAD_MTEXT_DEFINED_HEIGHT_BEGIN 1070 46 <<< defined column height 1040 150.0 1000 ACAD_MTEXT_DEFINED_HEIGHT_END .EE .UNINDENT .UNINDENT .SS Static Columns R2018 .sp The MTEXT entity in DXF R2018 contains all column information in a single entity. The text content of all three columns are stored in a continuous text string, the separation into columns has to be done by the renderer. The manual column break \fB\eN\fP is \fBnot\fP used to indicate automatic column breaks. The MTEXT renderer has to replicate the AutoCAD/BricsCAD rendering as exact as possible to achieve the same results, which is very hard without rendering guidelines or specifications. .sp The example from above in DXF R2018 with a static column specification stored in an embedded object: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT 5 <<< entity handle 9D 102 {ACAD_XDICTIONARY 360 9F 102 } 330 <<< block record handle of owner layout 1F 100 AcDbEntity 8 <<< layer 0 100 AcDbMText 10 <<< (10, 20, 30) insert location in WCS 285.917876152751 20 276.101821192053 30 0.0 40 <<< character height in drawing units 2.5 41 <<< reference column width, if not in column mode 62.694536423841 46 <<< defined column height 150.0 71 <<< attachment point 1 72 <<< text flow direction 1 3 <<< text content of all three columns Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam n... 3 imata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit... 3 a rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lor... 3 vero eos et accusam et justo duo dolores et ea rebum. Stet clita ka... 3 eu feugiat nulla facilisis at vero eros et accumsan et iusto odio s... 3 od tincidunt ut laoreet dolore magna aliquam erat volutpat. \eP\ePU... 3 e velit esse molestie consequat, vel illum dolore eu feugiat nulla ... 3 obis eleifend option congue nihil imperdiet doming id quod mazim pl... 3 m ad minim veniam, quis nostrud exerci tation ullamcorper suscipit ... 3 lisis. \eP\ePAt vero eos et accusam et justo duo dolores et ea rebu... 3 t labore et dolore magna aliquyam erat, sed diam voluptua. At vero ... 3 litr, At accusam aliquyam diam diam dolore dolores duo eirmod eos e... 1 ipsum dolor sit amet, consetetur 73 <<< line spacing style 1 44 <<< line spacing factor 1.0 101 <<< column specification as embedded object Embedded Object 70 <<< ??? 1 10 <<< (10, 20, 30) text direction vector (local x\-axis) 1.0 20 0.0 30 0.0 11 <<< (11, 21, 31) repeated insert location of AcDbMText 285.917876152751 21 276.101821192053 31 0.0 40 <<< repeated reference column width 62.694536423841 41 <<< repeated defined column height 150.0 42 <<< extents (total) width 175.0 43 <<< extents (total) height, max. height if different column heights 150.0 71 <<< column type: 0=no column; 1=static columns; 2=dynamic columns 1 72 <<< column height count 3 44 <<< column width 50.0 45 <<< column gutter width 12.5 73 <<< flag column auto height 0 74 <<< flag reversed column flow 0 1001 AcadAnnotative 1000 AnnotativeData 1002 { 1070 1 1070 0 1002 } .EE .UNINDENT .UNINDENT .SS Dynamic (auto height) Columns R2000 .sp Example for a \fBdynamic\fP column specification: .INDENT 0.0 .IP \(bu 2 Column Type: Dynamic .IP \(bu 2 Number of Columns: 3 .IP \(bu 2 Height: 158.189… adjusted by widget and all columns have the same height .IP \(bu 2 Width: 50.0 .IP \(bu 2 Gutter Width: 12.5 .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT 5 #A2 <<< entity handle \&... 330 #1F <<< block record handle of owner layout 100 AcDbEntity 8 0 <<< layer 100 AcDbMText 10 (\-133.714579865783, 276.101821192053, 0.0) <<< insert location in WCS 40 2.5 <<< character height in drawing units 41 62.694536423841 <<< reference column width, if not in column mode 71 1 <<< attachment point 72 1 <<< flag text flow direction 3 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed dia... \&... 73 1 <<< line spacing style 44 1.0 <<< line spacing factor 1001 AcadAnnotative \&... 1001 ACAD 1000 ACAD_MTEXT_COLUMN_INFO_BEGIN 1070 75 <<< column type: 2=dynamic columns 1070 2 1070 79 <<< flag column auto height 1070 1 1070 76 <<< column count 1070 3 1070 78 <<< flag column flow reversed 1070 0 1070 48 <<< column width in column mode 1040 50.0 1070 49 <<< column gutter width 1040 12.5 1000 ACAD_MTEXT_COLUMN_INFO_END 1000 ACAD_MTEXT_COLUMNS_BEGIN 1070 47 <<< column count 1070 3 1005 #1B6 <<< handle to 2. column as MTEXT entity 1005 #1B7 <<< handle to 3. column as MTEXT entity 1000 ACAD_MTEXT_COLUMNS_END 1000 ACAD_MTEXT_DEFINED_HEIGHT_BEGIN 1070 46 <<< defined column height 1040 158.189308131867 1000 ACAD_MTEXT_DEFINED_HEIGHT_END .EE .UNINDENT .UNINDENT .sp The linked column MTEXT \fB#1B6\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT \&... 100 AcDbMText 10 (\-71.214579865783, 276.101821192053, 0.0) 40 2.5 41 175.0 <<< invalid column width \&... 1001 ACAD 1000 ACAD_MTEXT_DEFINED_HEIGHT_BEGIN 1070 46 <<< defined column height 1040 158.189308131867 1000 ACAD_MTEXT_DEFINED_HEIGHT_END .EE .UNINDENT .UNINDENT .sp The linked column MTEXT \fB#1B7\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT \&... 100 AcDbMText 10 (\-8.714579865783, 276.101821192053, 0.0) 40 2.5 41 175.0 <<< invalid column width \&... 1001 ACAD 1000 ACAD_MTEXT_DEFINED_HEIGHT_BEGIN 1070 46 <<< defined column height 1040 158.189308131867 1000 ACAD_MTEXT_DEFINED_HEIGHT_END .EE .UNINDENT .UNINDENT .SS Dynamic (auto height) Columns R2018 .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT 5 #A2 <<< entity handle 102 {ACAD_XDICTIONARY 360 #A3 102 } 330 #1F <<< block record handle of owner layout 100 AcDbEntity 8 0 <<< layer 100 AcDbMText 10 (\-133.714579865783, 276.101821192053, 0.0) <<< insert location in WCS 40 2.5 <<< character height in drawing units 41 62.694536423841 <<< reference column width, if not in column mode 46 158.189308131867 <<< defined column height 71 1 <<< attachment point 72 1 <<< text flow direction 3 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam... \&... text content of all three columns 73 1 <<< line spacing style 44 1.0 <<< line spacing factor 101 Embedded Object 70 1, b00000001 <<< ??? 10 (1.0, 0.0, 0.0) <<< text direction vector (local x\-axis) 11 (\-133.714579865783, 276.101821192053, 0.0) <<< repeated insert location 40 62.694536423841 <<< repeated reference column width 41 158.189308131867 <<< repeated defined column height 42 175.0 <<< extents (total) width 43 158.189308131867 <<< extents (total) height, max. height if different column heights 71 2 <<< column type: 2=dynamic columns 72 0 <<< column height count 44 50.0 <<< column width 45 12.5 <<< column gutter width 73 1 <<< flag column auto height 74 0 <<< flag reversed column flow 1001 AcadAnnotative 1000 AnnotativeData 1002 { 1070 1 1070 0 1002 } .EE .UNINDENT .UNINDENT .SS Dynamic (manual height) Columns R2000 .sp Example for a \fBdynamic\fP column specification with manual height definition for three columns with different column heights. None of the (linked) MTEXT entities does contain XDATA for the defined column height. .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 If “content type” is 2 and flag “column auto height” is 0, no defined height in XDATA. .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 Column Type: Dynamic .IP \(bu 2 Number of Columns: 3 .IP \(bu 2 Height: 164.802450331126, max. column height .IP \(bu 2 Width: 50.0 .IP \(bu 2 Gutter Width: 12.5 .UNINDENT [image] .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT 5 #9C <<< entity handle 330 #1F <<< block record handle of owner layout 100 AcDbEntity 8 0 <<< layer 100 AcDbMText 10 (69.806121185863, 276.101821192053, 0.0) <<< insert location in WCS 40 2.5 <<< character height in drawing units 41 62.694536423841 <<< reference column width, if not in column mode 71 1 <<< attachment point 72 1 <<< flag text flow direction 3 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, ... \&... 73 1 <<< line spacing style 44 1.0 <<< line spacing factor 1001 ACAD 1000 ACAD_MTEXT_COLUMN_INFO_BEGIN 1070 75 <<< column type: 2=dynamic columns 1070 2 1070 79 <<< flag column auto height 1070 0 1070 76 <<< column count 1070 3 1070 78 <<< flag column flow reversed 1070 0 1070 48 <<< column width in column mode 1040 50.0 1070 49 <<< column gutter width 1040 12.5 1070 50 <<< column height count 1070 3 1040 164.802450331126 <<< column height 1. column 1040 154.311699779249 <<< column height 2. column 1040 0.0 <<< column height 3. column, takes the rest? 1000 ACAD_MTEXT_COLUMN_INFO_END 1000 ACAD_MTEXT_COLUMNS_BEGIN 1070 47 <<< column count 1070 3 1005 #1B2 <<< handle to 2. column as MTEXT entity 1005 #1B3 <<< handle to 3. column as MTEXT entity 1000 ACAD_MTEXT_COLUMNS_END .EE .UNINDENT .UNINDENT .sp The linked column MTEXT \fB#1B2\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT \&... 100 AcDbMText 10 (132.306121185863, 276.101821192053, 0.0) 40 2.5 41 175.0 <<< invalid reference column width \&... 73 1 44 1.0 .EE .UNINDENT .UNINDENT .sp The linked column MTEXT \fB#1B3\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT \&... 100 AcDbMText 10 (194.806121185863, 276.101821192053, 0.0) 40 2.5 41 175.0 <<< invalid reference column width \&... 73 1 44 1.0 .EE .UNINDENT .UNINDENT .SS Dynamic (manual height) Columns R2018 .sp \fBHINT:\fP .INDENT 0.0 .INDENT 3.5 If “content type” is 2 and flag “column auto height” is 0, the “defined column height” is 0.0. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT 5 #9C <<< entity handle 330 #1F 100 AcDbEntity 8 0 <<< block record handle of owner layout 100 AcDbMText 10 (69.806121185863, 276.101821192053, 0.0) <<< insert location in WCS 40 2.5 <<< character height in drawing units 41 62.694536423841 <<< reference column width, if not in column mode 46 0.0 <<< defined column height 71 1 <<< attachment point 72 1 <<< text flow direction 3 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam... \&... text content of all three columns 73 1 <<< line spacing style 44 1.0 <<< line spacing factor 101 Embedded Object 70 1, b00000001 <<< ??? 10 (1.0, 0.0, 0.0) <<< text direction vector (local x\-axis) 11 (69.806121185863, 276.101821192053, 0.0) <<< repeated insert location 40 62.694536423841 <<< repeated reference column width 41 0.0 <<< repeated defined column height 42 175.0 <<< extents (total) width 43 164.802450331126 <<< extents (total) height, max. height if different column heights 71 2 <<< column type: 2=dynamic columns 72 3 <<< column height count 44 50.0 <<< column width 45 12.5 <<< column gutter width 73 0 <<< flag column auto height 74 0 <<< flag reversed column flow 46 164.802450331126 <<< column height 1. column 46 154.311699779249 <<< column height 2. column 46 0.0 <<< column height 3. column, takes the rest? .EE .UNINDENT .UNINDENT .SS No Columns R2000 .sp I have no idea why this column type exist, but at least provides a reliable value for the MTEXT height by the “defined column height” attribute. The column type is not stored in the MTEXT entity and is therefore not detectable! .INDENT 0.0 .IP \(bu 2 Column Type: No columns .IP \(bu 2 Number of Columns: 1 .IP \(bu 2 Height: 158.189308131867, defined column height .IP \(bu 2 Width: 175.0, reference column width .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT \&... 100 AcDbMText 10 (\-344.497343455795, 276.101821192053, 0.0) <<< insert location in WCS 40 2.5 <<< character height in drawing units 41 175.0 <<< reference column width 71 1 <<< attachment point 72 1 <<< flag text flow direction 3 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam... \&... text content of all three columns 73 1 <<< line spacing style 44 1.0 <<< line spacing factor \&... 1001 ACAD 1000 ACAD_MTEXT_DEFINED_HEIGHT_BEGIN 1070 46 <<< defined column height 1040 158.189308131867 1000 ACAD_MTEXT_DEFINED_HEIGHT_END .EE .UNINDENT .UNINDENT .SS No Columns R2018 .sp Does not contain an embedded object. .INDENT 0.0 .INDENT 3.5 .sp .EX 0 MTEXT \&... 100 AcDbMText 10 (\-334.691900433414, 276.101821192053, 0.0) <<< insert location in WCS 40 2.5 <<< character height in drawing units 41 175.0 <<< reference column width 46 158.189308131867 <<< defined column height 71 1 <<< attachment point 72 1 <<< flag text flow direction 3 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, ... \&... 73 1 <<< line spacing style 44 1.0 <<< line spacing factor 1001 AcadAnnotative \&... .EE .UNINDENT .UNINDENT .SS DXF Objects .sp TODO .SS Management Structures .SS Block Management Structures .sp A BLOCK is a layout like the modelspace or a paperspace layout, with the similarity that all these layouts are containers for graphical DXF entities. This block definition can be referenced in other layouts by the INSERT entity. By using block references, the same set of graphical entities can be located multiple times at different layouts, this block references can be stretched and rotated without modifying the original entities. A block is referenced only by its name defined by the DXF tag \fB(2, name)\fP, there is a second DXF tag \fB(3, name2)\fP for the block name, which is not further documented by Autodesk, just ignore it. .sp The \fB(10, base_point)\fP tag (in BLOCK defines a insertion point of the block, by ‘inserting’ a block by the INSERT entity, this point of the block is placed at the location defined by the \fB(10, insert)\fP tag in the INSERT entity, and it is also the base point for stretching and rotation. .sp A block definition can contain INSERT entities, and it is possible to create cyclic block definitions (a BLOCK contains a INSERT of itself), but this should be avoided, CAD applications will not load the DXF file at all or maybe just crash. This is also the case for all other kinds of cyclic definitions like: BLOCK “A” \-> INSERT BLOCK “B” and BLOCK “B” \-> INSERT BLOCK “A”. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 ezdxf DXF Internals: \fI\%BLOCKS Section\fP .IP \(bu 2 DXF Reference: \fI\%BLOCKS Section\fP .IP \(bu 2 DXF Reference: \fI\%BLOCK Entity\fP .IP \(bu 2 DXF Reference: \fI\%ENDBLK Entity\fP .IP \(bu 2 DXF Reference: \fI\%INSERT Entity\fP .UNINDENT .UNINDENT .UNINDENT .SS Block Names .sp Block names has to be unique and they are case insensitive (“Test” == “TEST”). If there are two or more block definitions with the same name, AutoCAD merges these blocks into a single block with unpredictable properties of all these blocks. In my test with two blocks, the final block has the name of the first block and the base\-point of the second block, and contains all entities of both blocks. .SS Block Definitions in DXF R12 .sp In DXF R12 the definition of a block is located in the BLOCKS section, no additional structures are needed. The definition starts with a BLOCK entity and ends with a ENDBLK entity. All entities between this two entities are the content of the block, the block is the owner of this entities like any layout. .sp As shown in the DXF file below (created by AutoCAD LT 2018), the BLOCK entity has no handle, but ezdxf writes also handles for the BLOCK entity and AutoCAD doesn’t complain. .sp DXF R12 BLOCKS structure: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of a SECTION SECTION 2 <<< start of BLOCKS section BLOCKS \&... <<< modelspace and paperspace block definitions not shown, \&... <<< see layout management \&... 0 <<< start of a BLOCK definition BLOCK 8 <<< layer 0 2 <<< block name ArchTick 70 <<< flags 1 10 <<< base point, x 0.0 20 <<< base point, y 0.0 30 <<< base point, z 0.0 3 <<< second BLOCK name, same as (2, name) ArchTick 1 <<< xref name, if block is an external reference <<< empty string! 0 <<< start of the first entity of the BLOCK LINE 5 28E 8 0 62 0 10 500.0 20 500.0 30 0.0 11 500.0 21 511.0 31 0.0 0 <<< start of the second entity of the BLOCK LINE \&... 0.0 0 <<< ENDBLK entity, marks the end of the BLOCK definition ENDBLK 5 <<< ENDBLK gets a handle by AutoCAD, but BLOCK didn\(aqt 2F2 8 <<< as every entity, also ENDBLK requires a layer (same as BLOCK entity!) 0 0 <<< start of next BLOCK entity BLOCK \&... 0 <<< end BLOCK entity ENDBLK 0 <<< end of BLOCKS section ENDSEC .EE .UNINDENT .UNINDENT .SS Block Definitions in DXF R2000+ .sp The overall organization in the BLOCKS sections remains the same, but additional tags in the BLOCK entity, have to be maintained. .sp Especially the concept of ownership is important. Since DXF R13 every graphic entity is associated to a specific layout and a BLOCK definition is also a layout. So all entities in the BLOCK definition, including the BLOCK and the ENDBLK entities, have an owner tag \fB(330, ...)\fP, which points to a BLOCK_RECORD entry in the BLOCK_RECORD table. This BLOCK_RECORD is the main management structure for all layouts and is the real owner of the layout entities. .sp As you can see in the chapter about \fI\%Layout Management Structures\fP, this concept is also valid for modelspace and paperspace layouts, because these layouts are also BLOCKS, with the special difference, that the entities of the modelspace and the \fIactive\fP paperspace layout are stored in the ENTITIES section. [image] .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fI\%DXF R13 and later tag structure\fP .IP \(bu 2 ezdxf DXF Internals: \fI\%TABLES Section\fP .IP \(bu 2 DXF Reference: \fI\%TABLES Section\fP .IP \(bu 2 DXF Reference: \fI\%BLOCK_RECORD Entity\fP .UNINDENT .UNINDENT .UNINDENT .sp DXF R13 BLOCKS structure: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of a SECTION SECTION 2 <<< start of BLOCKS section BLOCKS \&... <<< modelspace and paperspace block definitions not shown, \&... <<< see layout management 0 <<< start of BLOCK definition BLOCK 5 <<< even BLOCK gets a handle now ;) 23A 330 <<< owner tag, the owner of a BLOCK is a BLOCK_RECORD in the \&... BLOCK_RECORD table 238 100 <<< subclass marker AcDbEntity 8 <<< layer of the BLOCK definition 0 100 <<< subclass marker AcDbBlockBegin 2 <<< BLOCK name ArchTick 70 <<< flags 0 10 <<< base point, x 0.0 20 <<< base point, y 0.0 30 <<< base point, z 0.0 3 <<< second BLOCK name, same as (2, name) ArchTick 1 <<< xref name, if block is an external reference <<< empty string! 0 <<< start of the first entity of the BLOCK LWPOLYLINE 5 239 330 <<< owner tag of LWPOLYLINE 238 <<< handle of the BLOCK_RECORD! 100 AcDbEntity 8 0 6 ByBlock 62 0 100 AcDbPolyline 90 2 70 0 43 0.15 10 \-0.5 20 \-0.5 10 0.5 20 0.5 0 <<< ENDBLK entity, marks the end of the BLOCK definition ENDBLK 5 <<< handle 23B 330 <<< owner tag, same BLOCK_RECORD as for the BLOCK entity 238 100 <<< subclass marker AcDbEntity 8 <<< ENDBLK requires the same layer as the BLOCK entity! 0 100 <<< subclass marker AcDbBlockEnd 0 <<< start of the next BLOCK BLOCK \&... 0 ENDBLK \&... 0 <<< end of the BLOCKS section ENDSEC .EE .UNINDENT .UNINDENT .sp DXF R13 BLOCK_RECORD structure: .INDENT 0.0 .INDENT 3.5 .sp .EX 0 <<< start of a SECTION SECTION 2 <<< start of TABLES section TABLES 0 <<< start of a TABLE TABLE 2 <<< start of the BLOCK_RECORD table BLOCK_RECORD 5 <<< handle of the table 1 330 <<< owner tag of the table 0 <<< is always #0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of table entries, not reliable 4 0 <<< start of first BLOCK_RECORD entry BLOCK_RECORD 5 <<< handle of BLOCK_RECORD, in ezdxf often referred to as \(dqlayout key\(dq 1F 330 <<< owner of the BLOCK_RECORD is the BLOCK_RECORD table 1 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbBlockTableRecord 2 <<< name of the BLOCK or LAYOUT *Model_Space 340 <<< pointer to the associated LAYOUT object 4AF 70 <<< AC1021 (R2007) block insertion units 0 280 <<< AC1021 (R2007) block explodability 1 281 <<< AC1021 (R2007) block scalability 0 \&... <<< paperspace not shown \&... 0 <<< next BLOCK_RECORD BLOCK_RECORD 5 <<< handle of BLOCK_RECORD, in ezdxf often referred to as \(dqlayout key\(dq 238 330 <<< owner of the BLOCK_RECORD is the BLOCK_RECORD table 1 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbBlockTableRecord 2 <<< name of the BLOCK ArchTick 340 <<< pointer to the associated LAYOUT object 0 <<< #0, because BLOCK doesn\(aqt have an associated LAYOUT object 70 <<< AC1021 (R2007) block insertion units 0 280 <<< AC1021 (R2007) block explodability 1 281 <<< AC1021 (R2007) block scalability 0 0 <<< end of BLOCK_RECORD table ENDTAB 0 <<< next TABLE TABLE \&... 0 ENDTAB 0 <<< end of TABLES section ENDESC .EE .UNINDENT .UNINDENT .SS Layout Management Structures .sp Layouts are separated entity spaces, there are three different Layout types: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP 1. 3 modelspace contains the ‘real’ world representation of the drawing subjects in real world units. .IP 2. 3 paperspace layouts are used to create different drawing sheets of the modelspace subjects for printing or PDF export .IP 3. 3 Blocks are reusable sets of graphical entities, inserted/referenced by the INSERT entity. .UNINDENT .UNINDENT .UNINDENT .sp All layouts have at least a BLOCK definition in the BLOCKS section and since DXF R13 exist the BLOCK_RECORD table with an entry for every BLOCK in the BLOCKS section. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Information about \fI\%Block Management Structures\fP .UNINDENT .UNINDENT .sp The name of the modelspace BLOCK is “*Model_Space” (DXF R12: “$MODEL_SPACE”) and the name of the \fIactive\fP paperspace BLOCK is “*Paper_Space” (DXF R12: “$PAPER_SPACE”), the entities of these two layouts are stored in the ENTITIES section, DXF R12 supports just one paperspace layout. .sp DXF R13+ supports multiple paperspace layouts, the \fIactive\fP layout is still called “*Paper_Space”, the additional \fIinactive\fP paperspace layouts are named by the scheme “*Paper_Spacennnn”, where the first inactive paper space is called “*Paper_Space0”, the second “*Paper_Space1” and so on. A none consecutive numbering is tolerated by AutoCAD. The content of the inactive paperspace layouts are stored as BLOCK content in the BLOCKS section. These names are just the DXF internal layout names, each layout has an additional layout name which is displayed to the user by the CAD application. .sp A BLOCK definition and a BLOCK_RECORD is not enough for a proper layout setup, an LAYOUT entity in the OBJECTS section is also required. All LAYOUT entities are managed by a DICTIONARY entity, which is referenced as “ACAD_LAYOUT” entity in the root DICTIONARY of the DXF file. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 All floating point values are rounded to 2 decimal places for better readability. .UNINDENT .UNINDENT .SS LAYOUT Entity .sp Since DXF R2000 modelspace and paperspace layouts require the DXF \fI\%LAYOUT\fP entity. .INDENT 0.0 .INDENT 3.5 .sp .EX 0 LAYOUT 5 <<< handle 59 102 <<< extension dictionary (ignore) {ACAD_XDICTIONARY 360 1C3 102 } 102 <<< reactor (required?) {ACAD_REACTORS 330 1A <<< pointer to \(dqACAD_LAYOUT\(dq DICTIONARY (layout management table) 102 } 330 <<< owner handle 1A <<< pointer to \(dqACAD_LAYOUT\(dq DICTIONARY (same as reactor pointer) 100 <<< PLOTSETTINGS AcDbPlotSettings 1 <<< page setup name 2 <<< name of system printer or plot configuration file none_device 4 <<< paper size, part in braces should follow the schema \&... (width_x_height_unit) unit is \(aqInches\(aq or \(aqMM\(aq \&... Letter\e_(8.50_x_11.00_Inches) the part in front of the braces is \&... ignored by AutoCAD 6 <<< plot view name 40 <<< size of unprintable margin on left side of paper in millimeters, \&... defines also the plot origin\-x 6.35 41 <<< size of unprintable margin on bottom of paper in millimeters, \&... defines also the plot origin\-y 6.35 42 <<< size of unprintable margin on right side of paper in millimeters 6.35 43 <<< size of unprintable margin on top of paper in millimeters 6.35 44 <<< plot paper size: physical paper width in millimeters 215.90 45 <<< plot paper size: physical paper height in millimeters 279.40 46 <<< X value of plot origin offset in millimeters, moves the plot origin\-x 0.0 47 <<< Y value of plot origin offset in millimeters, moves the plot origin\-y 0.0 48 <<< plot window area: X value of lower\-left window corner 0.0 49 <<< plot window area: Y value of lower\-left window corner 0.0 140 <<< plot window area: X value of upper\-right window corner 0.0 141 <<< plot window area: Y value of upper\-right window corner 0.0 142 <<< numerator of custom print scale: real world (paper) units, 1.0 \&... for scale 1:50 1.0 143 <<< denominator of custom print scale: drawing units, 50.0 \&... for scale 1:50 1.0 70 <<< plot layout flags, bit\-coded (... too many options) 688 <<< b1010110000 = UseStandardScale(16)/PlotPlotStyle(32) \&... PrintLineweights(128)/DrawViewportsFirst(512) 72 <<< plot paper units (0/1/2 for inches/millimeters/pixels), are \&... pixels really supported? 0 73 <<< plot rotation (0/1/2/3 for 0deg/90deg counter\-cw/upside\-down/90deg cw) 1 <<< 90deg clockwise 74 <<< plot type 0\-5 (... too many options) 5 <<< 5 = layout information 7 <<< current plot style name, e.g. \(aqacad.ctb\(aq or \(aqacadlt.ctb\(aq 75 <<< standard scale type 0\-31 (... too many options) 16 <<< 16 = 1:1, also 16 if user scale type is used 147 <<< unit conversion factor 1.0 <<< for plot paper units in mm, else 0.03937... (1/25.4) for inches \&... as plot paper units 76 <<< shade plot mode (0/1/2/3 for as displayed/wireframe/hidden/rendered) 0 <<< as displayed 77 <<< shade plot resolution level 1\-5 (... too many options) 2 <<< normal 78 <<< shade plot custom DPI: 100\-32767, Only applied when shade plot \&... resolution level is set to 5 (Custom) 300 148 <<< paper image origin: X value 0.0 149 <<< paper image origin: Y value 0.0 100 <<< LAYOUT settings AcDbLayout 1 <<< layout name Layout1 70 <<< flags bit\-coded 1 <<< 1 = Indicates the PSLTSCALE value for this layout when this \&... layout is current 71 <<< Tab order (\(dqModel\(dq tab always appears as the first tab \&... regardless of its tab order) 1 10 <<< minimum limits for this layout (defined by LIMMIN while this \&... layout is current) \-0.25 <<< x value, distance of the left paper margin from the plot \&... origin\-x, in plot paper units and by scale (e.g. x50 for 1:50) 20 <<< group code for y value \-0.25 <<< y value, distance of the bottom paper margin from the plot \&... origin\-y, in plot paper units and by scale (e.g. x50 for 1:50) 11 <<< maximum limits for this layout (defined by LIMMAX while this \&... layout is current) 10.75 <<< x value, distance of the right paper margin from the plot \&... origin\-x, in plot paper units and by scale (e.g. x50 for 1:50) 21 <<< group code for y value 8.25 <<< y value, distance of the top paper margin from the plot \&... origin\-y, in plot paper units and by scale (e.g. x50 for 1:50) 12 <<< insertion base point for this layout (defined by INSBASE while \&... this layout is current) 0.0 <<< x value 22 <<< group code for y value 0.0 <<< y value 32 <<< group code for z value 0.0 <<< z value 14 <<< minimum extents for this layout (defined by EXTMIN while this \&... layout is current), AutoCAD default is (1e20, 1e20, 1e20) 1.05 <<< x value 24 <<< group code for y value 0.80 <<< y value 34 <<< group code for z value 0.0 <<< z value 15 <<< maximum extents for this layout (defined by EXTMAX while this \&... layout is current), AutoCAD default is (\-1e20, \-1e20, \-1e20) 9.45 <<< x value 25 <<< group code for y value 7.20 <<< y value 35 <<< group code for z value 0.0 <<< z value 146 <<< elevation ??? 0.0 13 <<< UCS origin (3D Point) 0.0 <<< x value 23 <<< group code for y value 0.0 <<< y value 33 <<< group code for z value 0.0 <<< z value 16 <<< UCS X\-axis (3D vector) 1.0 <<< x value 26 <<< group code for y value 0.0 <<< y value 36 <<< group code for z value 0.0 <<< z value 17 <<< UCS Y\-axis (3D vector) 0.0 <<< x value 27 <<< group code for y value 1.0 <<< y value 37 <<< group code for z value 0.0 <<< z value 76 <<< orthographic type of UCS 0\-6 (... too many options) 0 <<< 0 = UCS is not orthographic ??? 330 <<< ID/handle of required block table record 58 331 <<< ID/handle to the viewport that was last active in this layout \&... when the layout was current 1B9 1001 <<< extended data (ignore) \&... .EE .UNINDENT .UNINDENT .sp And as it seems this is also not enough for a well defined LAYOUT, at least a “main” VIEWPORT entity with ID=1 is required for paperspace layouts, located in the entity space of the layout. .sp The modelspace layout requires (?) a VPORT entity in the VPORT table (group code 331 in the AcDbLayout subclass). .SS Main VIEWPORT Entity for LAYOUT .sp The “main” viewport for layout “Layout1” shown above. This viewport is located in the associated BLOCK definition called “*Paper_Space0”. Group code 330 in subclass AcDbLayout points to the BLOCK_RECORD of “*Paper_Space0”. .sp Remember: the entities of the \fIactive\fP paperspace layout are located in the ENTITIES section, therefore “Layout1” is not the active paperspace layout. .sp The “main” VIEWPORT describes, how the application shows the paperspace layout on the screen, and I guess only AutoCAD needs this values. [image] .INDENT 0.0 .INDENT 3.5 .sp .EX 0 VIEWPORT 5 <<< handle 1B4 102 <<< extension dictionary (ignore) {ACAD_XDICTIONARY 360 1B5 102 } 330 <<< owner handle 58 <<< points to BLOCK_RECORD (same as group code 330 in AcDbLayout of \&... \(dqLayout1\(dq) 100 AcDbEntity 67 <<< paperspace flag 1 <<< 0 = modelspace; 1 = paperspace 8 <<< layer, 0 100 AcDbViewport 10 <<< Center point (in WCS) 5.25 <<< x value 20 <<< group code for y value 4.00 <<< y value 30 <<< group code for z value 0.0 <<< z value 40 <<< width in paperspace units 23.55 <<< VIEW size in AutoCAD, depends on the workstation configuration 41 <<< height in paperspace units 9.00 <<< VIEW size in AutoCAD, depends on the workstation configuration 68 <<< viewport status field \-1/0/n 2 <<< >0 On and active. The value indicates the order of stacking for \&... the viewports, where 1 is the active viewport, 2 is the next, and so forth 69 <<< viewport ID 1 <<< \(dqmain\(dq viewport has always ID=1 12 <<< view center point in Drawing Coordinate System (DCS), defines \&... the center point of the VIEW in relation to the LAYOUT origin 5.25 <<< x value 22 <<< group code for y value 4.00 <<< y value 13 <<< snap base point in modelspace 0.0 <<< x value 23 <<< group code for y value 0.0 <<< y value 14 <<< snap spacing in modelspace units 0.5 <<< x value 24 <<< group code for y value 0.5 <<< y value 15 <<< grid spacing in modelspace units 0.5 <<< x value 25 <<< group code for y value 0.5 <<< y value 16 <<< view direction vector from target (in WCS) 0.0 <<< x value 26 <<< group code for y value 0.0 <<< y value 36 <<< group code for z value 1.0 <<< z value 17 <<< view target point 0.0 <<< x value 27 <<< group code for y value 0.0 <<< y value 37 <<< group code for z value 0.0 <<< z value 42 <<< perspective lens length, focal length? 50.0 <<< 50mm 43 <<< front clip plane z value 0.0 <<< z value 44 <<< back clip plane z value 0.0 <<< z value 45 <<< view height (in modelspace units) 9.00 50 <<< snap angle 0.0 51 <<< view twist angle 0.0 72 <<< circle zoom percent 1000 90 <<< Viewport status bit\-coded flags (... too many options) 819232 <<< b11001000000000100000 1 <<< plot style sheet name assigned to this viewport 281 <<< render mode (... too many options) 0 <<< 0 = 2D optimized (classic 2D) 71 <<< UCS per viewport flag 1 <<< 1 = This viewport stores its own UCS which will become the \&... current UCS whenever the viewport is activated 74 <<< Display UCS icon at UCS origin flag 0 <<< this field is currently being ignored and the icon always \&... represents the viewport UCS 110 <<< UCS origin (3D point) 0.0 <<< x value 120 <<< group code for y value 0.0 <<< y value 130 <<< group code for z value 0.0 <<< z value 111 <<< UCS X\-axis (3D vector) 1.0 <<< x value 121 <<< group code for y value 0.0 <<< y value 131 <<< group code for z value 0.0 <<< z value 112 <<< UCS Y\-axis (3D vector) 0.0 <<< x value 122 <<< group code for y value 1.0 <<< y value 132 <<< group code for z value 0.0 <<< z value 79 <<< Orthographic type of UCS (... too many options) 0 <<< 0 = UCS is not orthographic 146 <<< elevation 0.0 170 <<< shade plot mode (0/1/2/3 for as displayed/wireframe/hidden/rendered) 0 <<< as displayed 61 <<< frequency of major grid lines compared to minor grid lines 5 <<< major grid subdivided by 5 348 <<< visual style ID/handle (optional) 9F 292 <<< default lighting flag, on when no user lights are specified. 1 282 <<< Default lighting type (0/1 = one distant light/two distant lights) 1 <<< one distant light 141 <<< view brightness 0.0 142 <<< view contrast 0.0 63 <<< ambient light color (ACI), write only if not black color 250 421 <<< ambient light color (RGB), write only if not black color 3355443 .EE .UNINDENT .UNINDENT .SS Miscellaneous .SS Notes on Rendering DXF Content .sp A collection of AutoCAD behaviors determined experimentally. There may be mistakes and misunderstandings of the inner workings of the algorithms. Not all edge cases may have been considered. .SS Colors .INDENT 0.0 .IP \(bu 2 Most entities are colored contextually, based on the layer or block that they reside in. .IP \(bu 2 Usually entity colors are stored as AutoCAD Color Indices (ACI) as an index into a lookup table. Different CAD applications may use different color palettes making consistent coloring difficult. .IP \(bu 2 If a block insert is placed on layer ‘A’, and the block contains an entity on layer ‘B’ with BYLAYER color: the entity will be drawn with the color of layer ‘B’. .IP \(bu 2 If a block insert is placed on layer ‘A’, and the block contains an entity on layer ‘0’ with BYLAYER color: the entity will be drawn with the color of layer ‘A’, it seems that layer ‘0’ is the only special case for this. .IP \(bu 2 Ff an entity has BYBLOCK color set, and it exists outside a block: it will take on the layout default color which is white in the modelspace and black in the paperspace. .UNINDENT .SS Layers and Draw Order .INDENT 0.0 .IP \(bu 2 Layer names are case\-insensitive, the document layer table keys are stored in lowercase, and in original style in all other use cases (e.g. \fIentity.dxf.layer\fP). .IP \(bu 2 Layers do not play a role in entity draw order, only whether they appear at all based on the visibility of the layer. .IP \(bu 2 It appears that Insert entities have a single element in terms of draw order .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Entities inside a block can overlap each other and so have a draw order inside the block, but two Insert entities cannot interleave the contents of their blocks. One is completely drawn on top of the other. .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 For entities inside a block, the visibility of the layer that the block is inserted does not affect the visibility of the entity \fIunless\fP the entity was created on layer 0 in which case the reverse is true: .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 scenario: block created containing entity A (layer 0) and entity B (layer 1). The block is inserted into layer 2 .IP \(bu 2 entity B visible if and only if layer 1 is visible .IP \(bu 2 entity A visible if and only if layer 2 is visible .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS TEXT .INDENT 0.0 .IP \(bu 2 The anchor of single line TEXT entities (and ATTRIB entities) is \fIalways\fP the left\-baseline regardless of what alignment parameters are stored in the DXF. Those are for re\-adjusting the anchor when the text is edited. .IP \(bu 2 Attrib entities can have formatting commands in them .UNINDENT .SS MTEXT .INDENT 0.0 .IP \(bu 2 The \fIchar_height\fP in DXF corresponds to the cap\-height of the font. .IP \(bu 2 The default line spacing is 5/3 * cap\-height between the previous baseline and the next baseline. The \fIline_space_factor\fP is a factor applied directly to this value, so a factor of 3/5 results in 0 space between lines, because each baseline is 1 * cap\-height apart. .IP \(bu 2 The middle (vertical) justification of MTEXT entities seems to be midpoint between the x\-height of the first line to the baseline of the last line. .IP \(bu 2 MTEXT word wrapping seems to only break on spaces, not underscores or dashes. .IP \(bu 2 MTEXT word wrapping seems to treat multiple spaces between lines as if they were a single space. .IP \(bu 2 Alignment seems to ignore extra spaces at the start or end of lines except for the first line, where spaces at the beginning of the string have an effect. Whitespace at the beginning of the text can trigger word wrapping, which creates a single blank line at the start .IP \(bu 2 If a line ends with an explicit newline character and is shorter than the column width, only one newline is inserted. .IP \(bu 2 If a line is a single word wider than the column width, it will not be broken but will instead spill outside the text box. Placing a space before this word will create an empty line and push the word onto the next line. .UNINDENT .SS POINT .INDENT 0.0 .IP \(bu 2 All POINT entities have the same style defined by the HEADER variable $PDMODE. .IP \(bu 2 POINT entities can be drawn relative to the view scale or in absolute units. .UNINDENT .SH DEVELOPER GUIDES .sp Information about \fIezdxf\fP internals. .SS Source Code Formatting .sp Reformat code by \fI\%Black\fP with the default setting of 88 characters per line: .INDENT 0.0 .INDENT 3.5 .sp .EX C:\e> black .EE .UNINDENT .UNINDENT .SS Type Annotations .sp The use of type annotations is encouraged. New modules should pass \fI\%mypy\fP without errors in non\-strict mode. Using \fB# type: ignore\fP is fine in tricky situations \- type annotations should be helpful in understanding the code and not be a burden. .sp The following global options are required to pass \fI\%mypy\fP without error messages: .INDENT 0.0 .INDENT 3.5 .sp .EX [mypy] python_version = 3.7 ignore_missing_imports = True .EE .UNINDENT .UNINDENT .sp Read \fI\%this\fP to learn where \fI\%mypy\fP searches for config files. .sp Use the \fI\%mypy\fP command line option \fB\-\-ignore\-missing\-imports\fP and \fB\-p\fP to check the whole package from any location in the file system: .INDENT 0.0 .INDENT 3.5 .sp .EX PS D:\eSource\eezdxf.git> mypy \-\-ignore\-missing\-imports \-p ezdxf Success: no issues found in 255 source files .EE .UNINDENT .UNINDENT .SS Design .sp The \fI\%Package Design for Developers\fP section shows the structure of the \fIezdxf\fP package for developers with more experience, which want to have more insight into the package an maybe want to develop add\-ons or want contribute to the \fIezdxf\fP package. \fB!!! UNDER CONSTRUCTION !!!\fP .SS Package Design for Developers .sp A DXF document is divided into several sections, this sections are managed by the \fBDrawing\fP object. For each section exist a corresponding attribute in the \fBDrawing\fP object: .TS center; |l|l|. _ T{ Section T} T{ Attribute T} _ T{ HEADER T} T{ \fBDrawing.header\fP T} _ T{ CLASSES T} T{ \fBDrawing.classes\fP T} _ T{ TABLES T} T{ \fBDrawing.tables\fP T} _ T{ BLOCKS T} T{ \fBDrawing.blocks\fP T} _ T{ ENTITIES T} T{ \fBDrawing.entities\fP T} _ T{ OBJECTS T} T{ \fBDrawing.objects\fP T} _ .TE .sp Resource entities (LAYER, STYLE, LTYPE, …) are stored in tables in the TABLES section. A table owns the table entries, the owner handle of table entry is the handle of the table. Each table has a shortcut in the \fBDrawing\fP object: .TS center; |l|l|. _ T{ Table T} T{ Attribute T} _ T{ APPID T} T{ \fBDrawing.appids\fP T} _ T{ BLOCK_RECORD T} T{ \fBDrawing.block_records\fP T} _ T{ DIMSTYLE T} T{ \fBDrawing.dimstyles\fP T} _ T{ LAYER T} T{ \fBDrawing.layers\fP T} _ T{ LTYPE T} T{ \fBDrawing.linetypes\fP T} _ T{ STYLE T} T{ \fBDrawing.styles\fP T} _ T{ UCS T} T{ \fBDrawing.ucs\fP T} _ T{ VIEW T} T{ \fBDrawing.views\fP T} _ T{ VPORT T} T{ \fBDrawing.viewports\fP T} _ .TE .sp Graphical entities are stored in layouts: \fI\%Modelspace\fP, \fI\%Paperspace\fP layouts and \fI\%BlockLayout\fP\&. The core management object of this layouts is the BLOCK_RECORD entity (\fI\%BlockRecord\fP), the BLOCK_RECORD is the real owner of the entities, the owner handle of the entities is the handle of the BLOCK_RECORD and the BLOCK_RECORD also owns and manages the entity space of the layout which contains all entities of the layout. .sp For more information about layouts see also: \fI\%Layout Management Structures\fP .sp For more information about blocks see also: \fI\%Block Management Structures\fP .sp Non\-graphical entities (objects) are stored in the OBJECTS section. Every object has a parent object in the OBJECTS section, most likely a DICTIONARY object, and is stored in the entity space of the OBJECTS section. .sp For more information about the OBJECTS section see also: \fI\%OBJECTS Section\fP .sp All table entries, DXF entities and DXF objects are stored in the entities database accessible as \fBDrawing.entitydb\fP\&. The entity database is a simple key, value storage, key is the entity handle, value is the DXF object. .sp For more information about the DXF data model see also: \fI\%Data Model\fP .SS Terminology .SS States .sp DXF entities and objects can have different states: .INDENT 0.0 .TP .B UNBOUND Entity is not stored in the \fBDrawing\fP entity database and DXF attribute \fBhandle\fP is \fBNone\fP and attribute \fBdoc\fP can be \fBNone\fP .TP .B BOUND Entity is stored in the \fBDrawing\fP entity database, attribute \fBdoc\fP has a reference to \fBDrawing\fP and DXF attribute \fBhandle\fP is not \fBNone\fP .TP .B UNLINKED Entity is not linked to a layout/owner, DXF attribute \fBowner\fP is \fBNone\fP .TP .B LINKED Entity is linked to a layout/owner, DXF attribute \fBowner\fP is not \fBNone\fP .TP .B Virtual Entity State: UNBOUND & UNLINKED .TP .B Unlinked Entity State: BOUND & UNLINKED .TP .B Bound Entity State: BOUND & LINKED .UNINDENT .SS Actions .INDENT 0.0 .TP .B NEW Create a new DXF document .TP .B LOAD Load a DXF document from an external source .TP .B CREATE Create DXF structures from NEW or LOAD data .TP .B DESTROY Delete DXF structures .TP .B BIND Bind an entity to a \fBDrawing\fP, set entity state to BOUND & UNLINKED and check or create required resources .TP .B UNBIND unbind … .TP .B LINK Link an entity to an owner/layout. This makes an entity to a real DXF entity, which will be exported at the saving process. Any DXF entity can only be linked to \fBone\fP parent entity like DICTIONARY or BLOCK_RECORD. .TP .B UNLINK unlink … .UNINDENT .SS Loading a DXF Document .sp Loading a DXF document from an external source, creates a new \fBDrawing\fP object. This loading process has two stages: .SS First Loading Stage .INDENT 0.0 .IP \(bu 2 LOAD content from external source as \fBSectionDict\fP: \fBloader.load_dxf_structure()\fP .IP \(bu 2 LOAD tag structures as \fBDXFEntity\fP objects: \fBloader.load_dxf_entities()\fP .IP \(bu 2 BIND entities: \fBloader.load_and_bind_dxf_content()\fP; Special handling of the BIND process, because the \fBDrawing\fP is not full initialized, a complete validation is not possible at this stage. .UNINDENT .SS Second Loading Stage .sp Parse \fBSectionDict\fP: .INDENT 0.0 .IP \(bu 2 CREATE sections: HEADER, CLASSES, TABLES, BLOCKS and OBJECTS .IP \(bu 2 CREATE layouts: Blocks, Layouts .IP \(bu 2 LINK entities to a owner/layout .UNINDENT .sp The ENTITIES section is a relict from older DXF versions and has to be exported including the modelspace and active paperspace entities, but all entities reside in a BLOCK definition, even modelspace and paperspace layouts are only BLOCK definitions and ezdxf has no explicit ENTITIES section. .sp Source Code: as developer start your journey at \fBezdxf.document.Drawing.read()\fP, which has no public documentation, because package\-user should use \fI\%ezdxf.read()\fP and \fI\%ezdxf.readfile()\fP\&. .SS New DXF Document .SS Creating New DXF Entities .sp The default constructor of each entity type creates a new virtual entity: .INDENT 0.0 .IP \(bu 2 DXF attribute \fIowner\fP is \fBNone\fP .IP \(bu 2 DXF attribute \fIhandle\fP is \fBNone\fP .IP \(bu 2 Attribute \fIdoc\fP is \fBNone\fP .UNINDENT .sp The \fBDXFEntity.new()\fP constructor creates entities with given \fIowner\fP, \fIhandle\fP and \fIdoc\fP attributes, if \fIdoc\fP is not \fBNone\fP and entity is not already bound to a document, the \fBnew()\fP constructor automatically bind the entity to the given document \fIdoc\fP\&. .sp There exist only two scenarios: .INDENT 0.0 .IP 1. 3 UNBOUND: \fIdoc\fP is \fBNone\fP and \fIhandle\fP is \fBNone\fP .IP 2. 3 BOUND: \fIdoc\fP is not \fBNone\fP and \fIhandle\fP is not \fBNone\fP .UNINDENT .SS Factory functions .INDENT 0.0 .IP \(bu 2 \fBnew()\fP, create a new virtual DXF object/entity .IP \(bu 2 \fBload()\fP, load (create) virtual DXF object/entity from DXF tags .IP \(bu 2 \fBbind()\fP, bind an entity to a document, create required resources if necessary (e.g. ImageDefReactor, SEQEND) and raise exceptions for non\-existing resources. .INDENT 2.0 .IP \(bu 2 Bind entity loaded from an external source to a document, all referenced resources must exist, but try to repair as many flaws as possible because errors were created by another application and are not the responsibility of the package\-user. .IP \(bu 2 Bind an entity from another DXF document, all invalid resources will be removed silently or created (e.g. SEQEND). This is a simple import from another document without resource import, for a more advanced import including resources exist the \fBimporter\fP add\-on. .IP \(bu 2 Bootstrap problem for binding loaded table entries and objects in the OBJECTS section! Can’t use \fBAuditor\fP to repair this objects, because the DXF document is not fully initialized. .UNINDENT .IP \(bu 2 \fBis_bound()\fP returns True if \fIentity\fP is bound to document \fIdoc\fP .IP \(bu 2 \fBunbind()\fP function to remove an entity from a document and set state to a virtual entity, which should also \fIUNLINK\fP the entity from layout, because an layout can not store a virtual entity. .IP \(bu 2 \fBcls()\fP, returns the class .IP \(bu 2 \fBregister_entity()\fP, registration decorator .IP \(bu 2 \fBreplace_entity()\fP, registration decorator .UNINDENT .SS Class Interfaces .SS DXF Entities .INDENT 0.0 .IP \(bu 2 NEW constructor to create an entity from scratch .IP \(bu 2 LOAD constructor to create an entity loaded from an external source .IP \(bu 2 DESTROY interface to kill an entity, set entity state to \fIdead\fP, which means \fBentity.is_alive\fP returns False. All entity iterators like \fBEntitySpace\fP, \fBEntityQuery\fP, and \fBEntityDB\fP must filter (ignore) \fIdead\fP entities. Calling \fBDXFEntity.destroy()\fP is a regular way to delete entities. .IP \(bu 2 LINK an entity to a layout by \fBBlockRecord.link()\fP, which set the \fIowner\fP handle to BLOCK_RECORD handle (= layout key) and add the entity to the entity space of the BLOCK_RECORD and set/clear the paperspace flag. .UNINDENT .SS DXF Objects .INDENT 0.0 .IP \(bu 2 NEW, LOAD, DESTROY see DXF entities .IP \(bu 2 LINK: Linking an DXF object means adding the entity to a parent object in the OBJECTS section, most likely a DICTIONARY object, and adding the object to the entity space of the OBJECTS section, the root\-dict is the only entity in the OBJECTS section which has an invalid owner handle “0”. Any other object with an invalid or destroyed owner is an orphaned entity. The audit process destroys and removes orphaned objects. .IP \(bu 2 Extension dictionaries (ACAD_XDICTIONARY) are DICTIONARY objects located in the OBJECTS sections and can reference/own other entities of the OBJECTS section. .IP \(bu 2 The root\-dictionary is the only entity in the OBJECTS section which has an invalid owner handle “0”. Any other object with an invalid or destroyed owner is an orphaned entity. .UNINDENT .SS Layouts .INDENT 0.0 .IP \(bu 2 LINK interface to link an entity to a layout .IP \(bu 2 UNLINK interface to remove an entity from a layout .UNINDENT .SS Database .INDENT 0.0 .IP \(bu 2 BIND interface to add an entity to the database of a document .IP \(bu 2 \fBdelete_entity()\fP interface, same as UNBIND and DESTROY an entity .UNINDENT .SS Internal Data Structures .SS Entity Database .sp The \fI\%EntityDB\fP is a simple key/value database to store \fI\%DXFEntity\fP objects by it’s handle, every \fI\%Drawing\fP has its own \fI\%EntityDB\fP, stored in the \fBDrawing\fP attribute \fBentitydb\fP\&. .sp Every DXF entity/object, except tables and sections, are represented as \fBDXFEntity\fP or inherited types, this entities are stored in the \fI\%EntityDB\fP, database\-key is the \fBdxf.handle\fP as plain hex string. .sp All iterators like \fBkeys()\fP, \fBvalues()\fP, \fBitems()\fP and \fB__iter__()\fP do not yield destroyed entities. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 The \fBget()\fP method and the index operator \fB[]\fP, return destroyed entities and entities from the trashcan. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entitydb.EntityDB .INDENT 7.0 .TP .B __getitem__(handle: str) -> \fI\%DXFEntity\fP Get entity by \fIhandle\fP, does not filter destroyed entities nor entities in the trashcan. .UNINDENT .INDENT 7.0 .TP .B __setitem__(handle: str, entity: \fI\%DXFEntity\fP) -> None Set \fIentity\fP for \fIhandle\fP\&. .UNINDENT .INDENT 7.0 .TP .B __delitem__(handle: str) -> None Delete entity by \fIhandle\fP\&. Removes entity only from database, does not destroy the entity. .UNINDENT .INDENT 7.0 .TP .B __contains__(item: str | \fI\%DXFEntity\fP) -> bool \fBTrue\fP if database contains \fIhandle\fP\&. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Count of database items. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[str] Iterable of all handles, does filter destroyed entities but not entities in the trashcan. .UNINDENT .INDENT 7.0 .TP .B get(handle: str) -> \fI\%DXFEntity\fP | None Returns entity for \fIhandle\fP or \fBNone\fP if no entry exist, does not filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B next_handle() -> str Returns next unique handle. .UNINDENT .INDENT 7.0 .TP .B keys() -> Iterable[str] Iterable of all handles, does filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B values() -> Iterable[\fI\%DXFEntity\fP] Iterable of all entities, does filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B items() -> Iterable[Tuple[str, \fI\%DXFEntity\fP]] Iterable of all (handle, entities) pairs, does filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B add(entity: \fI\%DXFEntity\fP) -> None Add \fIentity\fP to database, assigns a new handle to the \fIentity\fP if \fBentity.dxf.handle\fP is \fBNone\fP\&. Adding the same entity multiple times is possible and creates only a single database entry. .UNINDENT .INDENT 7.0 .TP .B new_trashcan() -> Trashcan Returns a new trashcan, empty trashcan manually by: : func:\fITrashcan.clear()\fP\&. .UNINDENT .INDENT 7.0 .TP .B trashcan() -> Trashcan Returns a new trashcan in context manager mode, trashcan will be emptied when leaving context. .UNINDENT .INDENT 7.0 .TP .B purge() -> None Remove all destroyed entities from database, but does not empty the trashcan. .UNINDENT .INDENT 7.0 .TP .B query(query: str = \(aq*\(aq) -> \fI\%EntityQuery\fP Entity query over all entities in the DXF document. .INDENT 7.0 .TP .B Parameters \fBquery\fP – query string .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 \fI\%Entity Query String\fP and \fI\%Retrieve entities by query language\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Entity Space .INDENT 0.0 .TP .B class ezdxf.entitydb.EntitySpace(entities: Iterable[DXFEntity] | None = None) An \fI\%EntitySpace\fP is a collection of \fI\%DXFEntity\fP objects, that stores only references to \fBDXFEntity\fP objects. .sp The \fI\%Modelspace\fP, any \fI\%Paperspace\fP layout and \fI\%BlockLayout\fP objects have an \fI\%EntitySpace\fP container to store their entities. .INDENT 7.0 .TP .B __iter__() -> Iterable[\fI\%DXFEntity\fP] Iterable of all entities, filters destroyed entities. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index) -> \fI\%DXFEntity\fP Get entity at index \fIitem\fP .sp \fI\%EntitySpace\fP has a standard Python list like interface, therefore \fIindex\fP can be any valid list indexing or slicing term, like a single index \fBlayout[\-1]\fP to get the last entity, or an index slice \fBlayout[:10]\fP to get the first 10 or fewer entities as \fBlist[DXFEntity]\fP\&. Does not filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Count of entities including destroyed entities. .UNINDENT .INDENT 7.0 .TP .B has_handle(handle: str) -> bool \fBTrue\fP if \fIhandle\fP is present, does filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B purge() Remove all destroyed entities from entity space. .UNINDENT .INDENT 7.0 .TP .B add(entity: \fI\%DXFEntity\fP) -> None Add \fIentity\fP\&. .UNINDENT .INDENT 7.0 .TP .B extend(entities: Iterable[\fI\%DXFEntity\fP]) -> None Add multiple \fIentities\fP\&. .UNINDENT .INDENT 7.0 .TP .B remove(entity: \fI\%DXFEntity\fP) -> None Remove \fIentity\fP\&. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Remove all entities. .UNINDENT .UNINDENT .SS DXF Types .sp Required DXF tag interface: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 property \fBcode\fP: group code as int .IP \(bu 2 property \fBvalue\fP: tag value of unspecific type .IP \(bu 2 \fBdxfstr()\fP: returns the DXF string .IP \(bu 2 \fBclone()\fP: returns a deep copy of tag .UNINDENT .UNINDENT .UNINDENT .SS DXFTag Factory Functions .INDENT 0.0 .TP .B ezdxf.lldxf.types.dxftag(code: int, value: Any) -> \fI\%DXFTag\fP DXF tag factory function. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcode\fP – group code .IP \(bu 2 \fBvalue\fP – tag value .UNINDENT .UNINDENT .sp Returns: \fI\%DXFTag\fP or inherited .UNINDENT .INDENT 0.0 .TP .B ezdxf.lldxf.types.tuples_to_tags(iterable: Iterable[tuple[int, Any]]) -> Iterable[\fI\%DXFTag\fP] Returns an iterable if \fI\%DXFTag\fP or inherited, accepts an iterable of (code, value) tuples as input. .UNINDENT .SS DXFTag .INDENT 0.0 .TP .B class ezdxf.lldxf.types.DXFTag(code: int, value: Any) Immutable DXFTag class. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcode\fP – group code as int .IP \(bu 2 \fBvalue\fP – tag value, type depends on group code .UNINDENT .UNINDENT .INDENT 7.0 .TP .B code group code as int (do not change) .UNINDENT .INDENT 7.0 .TP .B value tag value (read\-only property) .UNINDENT .INDENT 7.0 .TP .B __eq__(other) -> bool \fBTrue\fP if \fIother\fP and \fIself\fP has same content for \fI\%code\fP and \fI\%value\fP\&. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index: int) Returns \fI\%code\fP for index 0 and \fI\%value\fP for index 1, emulates a tuple. .UNINDENT .INDENT 7.0 .TP .B __hash__() Hash support, \fI\%DXFTag\fP can be used in sets and as dict key. .UNINDENT .INDENT 7.0 .TP .B __iter__() Returns (code, value) tuples. .UNINDENT .INDENT 7.0 .TP .B __repr__() -> str Returns representation string \fB\(aqDXFTag(code, value)\(aq\fP\&. .UNINDENT .INDENT 7.0 .TP .B __str__() -> str Returns content string \fB\(aq(code, value)\(aq\fP\&. .UNINDENT .INDENT 7.0 .TP .B clone() -> \fI\%DXFTag\fP Returns a clone of itself, this method is necessary for the more complex (and not immutable) DXF tag types. .UNINDENT .INDENT 7.0 .TP .B dxfstr() -> str Returns the DXF string e.g. \fB\(aq 0\enLINE\en\(aq\fP .UNINDENT .UNINDENT .SS DXFBinaryTag .INDENT 0.0 .TP .B class ezdxf.lldxf.types.DXFBinaryTag(DXFTag) Immutable BinaryTags class \- immutable by design, not by implementation. .INDENT 7.0 .TP .B dxfstr() -> str Returns the DXF string for all vertex components. .UNINDENT .INDENT 7.0 .TP .B tostring() -> str Returns binary value as single hex\-string. .UNINDENT .UNINDENT .SS DXFVertex .INDENT 0.0 .TP .B class ezdxf.lldxf.types.DXFVertex(DXFTag) Represents a 2D or 3D vertex, stores only the group code of the x\-component of the vertex, because the y\-group\-code is x\-group\-code + 10 and z\-group\-code id x\-group\-code+20, this is a rule that ALWAYS applies. This tag is \fIimmutable\fP by design, not by implementation. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcode\fP – group code of x\-component .IP \(bu 2 \fBvalue\fP – sequence of x, y and optional z values .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxfstr() -> str Returns the DXF string for all vertex components. .UNINDENT .INDENT 7.0 .TP .B dxftags() -> Iterable[\fI\%DXFTag\fP] Returns all vertex components as single \fI\%DXFTag\fP objects. .UNINDENT .UNINDENT .SS NONE_TAG .INDENT 0.0 .TP .B ezdxf.lldxf.types.NONE_TAG Special tag representing a none existing tag. .UNINDENT .SS Tags .sp A list of \fI\%DXFTag\fP, inherits from Python standard list. Unlike the statement in the DXF Reference “Do not write programs that rely on the order given here”, tag order is sometimes essential and some group codes may appear multiples times in one entity. At the worst case (\fBMaterial\fP: normal map shares group codes with diffuse map) using same group codes with different meanings. .INDENT 0.0 .TP .B class ezdxf.lldxf.tags.Tags Subclass of \fBlist\fP\&. .sp Collection of \fI\%DXFTag\fP as flat list. Low level tag container, only required for advanced stuff. .INDENT 7.0 .TP .B classmethod from_text(text: str) -> \fI\%Tags\fP Constructor from DXF string. .UNINDENT .INDENT 7.0 .TP .B dxftype() -> str Returns DXF type of entity, e.g. \fB\(aqLINE\(aq\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_handle() -> str Get DXF handle. Raises \fBDXFValueError\fP if handle not exist. .INDENT 7.0 .TP .B Returns handle as plain hex string like \fB\(aqFF00\(aq\fP .TP .B Raises \fI\%DXFValueError\fP – no handle found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B replace_handle(new_handle: str) -> None Replace existing handle. .INDENT 7.0 .TP .B Parameters \fBnew_handle\fP – new handle as plain hex string e.g. \fB\(aqFF00\(aq\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_tag(code: int) -> bool Returns \fBTrue\fP if a \fI\%DXFTag\fP with given group \fIcode\fP is present. .INDENT 7.0 .TP .B Parameters \fBcode\fP – group code as int .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_embedded_objects() -> bool .UNINDENT .INDENT 7.0 .TP .B get_first_tag(code: int, default=DXFValueError) -> \fI\%DXFTag\fP Returns first \fI\%DXFTag\fP with given group code or \fIdefault\fP, if \fIdefault\fP != \fBDXFValueError\fP, else raises \fBDXFValueError\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcode\fP – group code as int .IP \(bu 2 \fBdefault\fP – return value for default case or raises \fBDXFValueError\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_first_value(code: int, default=DXFValueError) -> Any Returns value of first \fI\%DXFTag\fP with given group code or default if \fIdefault\fP != \fBDXFValueError\fP, else raises \fBDXFValueError\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcode\fP – group code as int .IP \(bu 2 \fBdefault\fP – return value for default case or raises \fBDXFValueError\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B find_all(code: int) -> List[\fI\%DXFTag\fP] Returns a list of \fI\%DXFTag\fP with given group code. .INDENT 7.0 .TP .B Parameters \fBcode\fP – group code as int .UNINDENT .UNINDENT .INDENT 7.0 .TP .B filter(codes: Iterable[int]) -> Iterable[\fI\%DXFTag\fP] Iterate and filter tags by group \fIcodes\fP\&. .INDENT 7.0 .TP .B Parameters \fBcodes\fP – group codes to filter .UNINDENT .UNINDENT .INDENT 7.0 .TP .B collect_consecutive_tags(codes: Iterable[int], start: int = 0, end: int = None) -> \fI\%Tags\fP Collect all consecutive tags with group code in \fIcodes\fP, \fIstart\fP and \fIend\fP delimits the search range. A tag code not in codes ends the process. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcodes\fP – iterable of group codes .IP \(bu 2 \fBstart\fP – start index as int .IP \(bu 2 \fBend\fP – end index as int, \fBNone\fP for end index = \fBlen(self)\fP .UNINDENT .TP .B Returns collected tags as \fI\%Tags\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B tag_index(code: int, start: int = 0, end: int | None = None) -> int Return index of first \fI\%DXFTag\fP with given group code. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcode\fP – group code as int .IP \(bu 2 \fBstart\fP – start index as int .IP \(bu 2 \fBend\fP – end index as int, \fBNone\fP for end index = \fBlen(self)\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B update(tag: \fI\%DXFTag\fP) Update first existing tag with same group code as \fItag\fP, raises \fBDXFValueError\fP if tag not exist. .UNINDENT .INDENT 7.0 .TP .B set_first(tag: \fI\%DXFTag\fP) Update first existing tag with group code \fBtag.code\fP or append tag. .UNINDENT .INDENT 7.0 .TP .B remove_tags(codes: Iterable[int]) -> None Remove all tags inplace with group codes specified in \fIcodes\fP\&. .INDENT 7.0 .TP .B Parameters \fBcodes\fP – iterable of group codes as int .UNINDENT .UNINDENT .INDENT 7.0 .TP .B remove_tags_except(codes: Iterable[int]) -> None Remove all tags inplace except those with group codes specified in \fIcodes\fP\&. .INDENT 7.0 .TP .B Parameters \fBcodes\fP – iterable of group codes .UNINDENT .UNINDENT .INDENT 7.0 .TP .B pop_tags(codes: Iterable[int]) -> Iterable[\fI\%DXFTag\fP] Pop tags with group codes specified in \fIcodes\fP\&. .INDENT 7.0 .TP .B Parameters \fBcodes\fP – iterable of group codes .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod strip(tags: \fI\%Tags\fP, codes: Iterable[int]) -> \fI\%Tags\fP Constructor from \fItags\fP, strips all tags with group codes in \fIcodes\fP from tags. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtags\fP – iterable of \fI\%DXFTag\fP .IP \(bu 2 \fBcodes\fP – iterable of group codes as int .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.lldxf.tags.group_tags(tags: Iterable[\fI\%DXFTag\fP], splitcode: int = 0) -> Iterable[\fI\%Tags\fP] Group of tags starts with a SplitTag and ends before the next SplitTag. A SplitTag is a tag with code == splitcode, like (0, ‘SECTION’) for splitcode == 0. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtags\fP – iterable of \fBDXFTag\fP .IP \(bu 2 \fBsplitcode\fP – group code of split tag .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.extendedtags.ExtendedTags(tags: Iterable[\fI\%DXFTag\fP] = None, legacy=False) Represents the extended DXF tag structure introduced with DXF R13. .INDENT 7.0 .TP .B Args: tags: iterable of \fI\%DXFTag\fP legacy: flag for DXF R12 tags .UNINDENT .INDENT 7.0 .TP .B appdata Application defined data as list of \fBTags\fP .UNINDENT .INDENT 7.0 .TP .B subclasses Subclasses as list of \fBTags\fP .UNINDENT .INDENT 7.0 .TP .B xdata XDATA as list of \fBTags\fP .UNINDENT .INDENT 7.0 .TP .B embedded_objects embedded objects as list of \fBTags\fP .UNINDENT .INDENT 7.0 .TP .B noclass Short cut to access first subclass. .UNINDENT .INDENT 7.0 .TP .B get_handle() -> str Returns handle as hex string. .UNINDENT .INDENT 7.0 .TP .B dxftype() -> str Returns DXF type as string like “LINE”. .UNINDENT .INDENT 7.0 .TP .B replace_handle(handle: str) -> None Replace the existing entity handle by a new value. .UNINDENT .INDENT 7.0 .TP .B legacy_repair() Legacy (DXF R12) tags handling and repair. .UNINDENT .INDENT 7.0 .TP .B clone() -> \fI\%ExtendedTags\fP Shallow copy. .UNINDENT .INDENT 7.0 .TP .B flatten_subclasses() Flatten subclasses in legacy mode (DXF R12). .sp There exists DXF R12 with subclass markers, technical incorrect but works if the reader ignore subclass marker tags, unfortunately ezdxf tries to use this subclass markers and therefore R12 parsing by ezdxf does not work without removing these subclass markers. .sp This method removes all subclass markers and flattens all subclasses into ExtendedTags.noclass. .UNINDENT .INDENT 7.0 .TP .B get_subclass(name: str, pos: int = 0) -> \fI\%Tags\fP Get subclass \fIname\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – subclass name as string like “AcDbEntity” .IP \(bu 2 \fBpos\fP – start searching at subclass \fIpos\fP\&. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_xdata(appid: str) -> bool \fBTrue\fP if has XDATA for \fIappid\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_xdata(appid: str) -> \fI\%Tags\fP Returns XDATA for \fIappid\fP as \fBTags\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_xdata(appid: str, tags: IterableTags) -> None Set \fItags\fP as XDATA for \fIappid\fP\&. .UNINDENT .INDENT 7.0 .TP .B new_xdata(appid: str, tags: \(aqIterableTags\(aq = None) -> \fI\%Tags\fP Append a new XDATA block. .sp Assumes that no XDATA block with the same \fIappid\fP already exist: .INDENT 7.0 .INDENT 3.5 .sp .EX try: xdata = tags.get_xdata(\(aqEZDXF\(aq) except ValueError: xdata = tags.new_xdata(\(aqEZDXF\(aq) .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_app_data(appid: str) -> bool \fBTrue\fP if has application defined data for \fIappid\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_app_data(appid: str) -> \fI\%Tags\fP Returns application defined data for \fIappid\fP as \fBTags\fP including marker tags. .UNINDENT .INDENT 7.0 .TP .B get_app_data_content(appid: str) -> \fI\%Tags\fP Returns application defined data for \fIappid\fP as \fBTags\fP without first and last marker tag. .UNINDENT .INDENT 7.0 .TP .B set_app_data_content(appid: str, tags: IterableTags) -> None Set application defined data for \fIappid\fP for already exiting data. .UNINDENT .INDENT 7.0 .TP .B new_app_data(appid: str, tags: \(aqIterableTags\(aq = None, subclass_name: str = None) -> \fI\%Tags\fP Append a new application defined data to subclass \fIsubclass_name\fP\&. .sp Assumes that no app data block with the same \fIappid\fP already exist: .INDENT 7.0 .INDENT 3.5 .sp .EX try: app_data = tags.get_app_data(\(aq{ACAD_REACTORS\(aq, tags) except ValueError: app_data = tags.new_app_data(\(aq{ACAD_REACTORS\(aq, tags) .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_text(text: str, legacy: bool = False) -> \fI\%ExtendedTags\fP Create \fI\%ExtendedTags\fP from DXF text. .UNINDENT .UNINDENT .SS Packed DXF Tags .sp Store DXF tags in compact data structures as \fBlist\fP or \fBarray.array\fP to reduce memory usage. .INDENT 0.0 .TP .B class ezdxf.lldxf.packedtags.TagList(data: Iterable = None) Store data in a standard Python \fBlist\fP\&. .INDENT 7.0 .TP .B Args: data: iterable of DXF tag values. .UNINDENT .INDENT 7.0 .TP .B values Data storage as \fBlist\fP\&. .UNINDENT .INDENT 7.0 .TP .B clone() -> \fI\%TagList\fP Returns a deep copy. .UNINDENT .INDENT 7.0 .TP .B classmethod from_tags(tags: \fI\%Tags\fP, code: int) -> \fI\%TagList\fP Setup list from iterable tags. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtags\fP – tag collection as \fI\%Tags\fP .IP \(bu 2 \fBcode\fP – group code to collect .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B clear() -> None Delete all data values. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.packedtags.TagArray(data: Iterable = None) \fI\%TagArray\fP is a subclass of \fI\%TagList\fP, which store data in an \fBarray.array\fP\&. Array type is defined by class variable \fBDTYPE\fP\&. .INDENT 7.0 .TP .B Args: data: iterable of DXF tag values. .UNINDENT .INDENT 7.0 .TP .B DTYPE \fBarray.array\fP type as string .UNINDENT .INDENT 7.0 .TP .B values Data storage as \fBarray.array\fP .UNINDENT .INDENT 7.0 .TP .B set_values(values: Iterable) -> None Replace data by \fIvalues\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.packedtags.VertexArray(data: Iterable = None) Store vertices in an \fBarray.array(\(aqd\(aq)\fP\&. Vertex size is defined by class variable \fI\%VERTEX_SIZE\fP\&. .INDENT 7.0 .TP .B Args: data: iterable of vertex values as linear list e.g. \fB[x1, y1, x2, y2, x3, y3, ...]\fP\&. .UNINDENT .INDENT 7.0 .TP .B VERTEX_SIZE Size of vertex (2 or 3 axis). .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Count of vertices. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index: int) Get vertex at \fIindex\fP, extended slicing supported. .UNINDENT .INDENT 7.0 .TP .B __setitem__(index: int, point: Sequence[float]) -> None Set vertex \fIpoint\fP at \fIindex\fP, extended slicing not supported. .UNINDENT .INDENT 7.0 .TP .B __delitem__(index: int) -> None Delete vertex at \fIindex\fP, extended slicing supported. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[Sequence[float]] Returns iterable of vertices. .UNINDENT .INDENT 7.0 .TP .B __str__() -> str String representation. .UNINDENT .INDENT 7.0 .TP .B insert(pos: int, point: Sequence[float]) Insert \fIpoint\fP in front of vertex at index \fIpos\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpos\fP – insert position .IP \(bu 2 \fBpoint\fP – point as tuple .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append(point: Sequence[float]) -> None Append \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B extend(points: Iterable[Sequence[float]]) -> None Extend array by \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B set(points: Iterable[Sequence[float]]) -> None Replace all vertices by \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Delete all vertices. .UNINDENT .INDENT 7.0 .TP .B clone() -> \fI\%VertexArray\fP Returns a deep copy. .UNINDENT .INDENT 7.0 .TP .B classmethod from_tags(tags: Iterable[\fI\%DXFTag\fP], code: int = 10) -> \fI\%VertexArray\fP Setup point array from iterable tags. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtags\fP – iterable of \fI\%DXFVertex\fP .IP \(bu 2 \fBcode\fP – group code to collect .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B export_dxf(tagwriter: AbstractTagWriter, code=10) .UNINDENT .UNINDENT .SS XData .INDENT 0.0 .TP .B class ezdxf.entities.xdata.XData Internal management class for XDATA. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 XDATA user reference: \fI\%Extended Data (XDATA)\fP .IP \(bu 2 Wrapper class to store a list in XDATA: \fI\%XDataUserList\fP .IP \(bu 2 Wrapper class to store a dict in XDATA: \fI\%XDataUserDict\fP .IP \(bu 2 Tutorial: \fI\%Storing Custom Data in DXF Files\fP .IP \(bu 2 DXF Internals: \fI\%Extended Data\fP .IP \(bu 2 \fI\%DXF R2018 Reference\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __contains__(appid: str) -> bool Returns \fBTrue\fP if DXF tags for \fIappid\fP exist. .UNINDENT .INDENT 7.0 .TP .B add(appid: str, tags: Iterable[tuple[int, Any] | \fI\%DXFTag\fP]) -> None Add a list of DXF tags for \fIappid\fP\&. The \fItags\fP argument is an iterable of (group code, value) tuples, where the group code has to be an integer value. The mandatory XDATA marker (1001, appid) is added automatically if front of the tags if missing. .sp Each entity can contain only one list of tags for each \fIappid\fP\&. Adding a second list of tags for the same \fIappid\fP replaces the existing list of tags. .sp The valid XDATA group codes are restricted to some specific values in the range from 1000 to 1071, for more information see also the internals about \fI\%Extended Data\fP\&. .UNINDENT .INDENT 7.0 .TP .B get(appid: str) -> \fI\%Tags\fP Returns the DXF tags as \fI\%Tags\fP list stored by \fIappid\fP\&. .INDENT 7.0 .TP .B Raises \fI\%DXFValueError\fP – no data for \fIappid\fP exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B discard(appid) Delete DXF tags for \fIappid\fP\&. None existing appids are silently ignored. .UNINDENT .INDENT 7.0 .TP .B has_xlist(appid: str, name: str) -> bool Returns \fBTrue\fP if list \fIname\fP from XDATA \fIappid\fP exists. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – APPID .IP \(bu 2 \fBname\fP – list name .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_xlist(appid: str, name: str) -> list[tuple] Get list \fIname\fP from XDATA \fIappid\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – APPID .IP \(bu 2 \fBname\fP – list name .UNINDENT .UNINDENT .sp Returns: list of DXFTags including list name and curly braces ‘{’ ‘}’ tags .INDENT 7.0 .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fI\%DXFKeyError\fP – XDATA \fIappid\fP does not exist .IP \(bu 2 \fI\%DXFValueError\fP – list \fIname\fP does not exist .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_xlist(appid: str, name: str, tags: Iterable) -> None Create new list \fIname\fP of XDATA \fIappid\fP with \fIxdata_tags\fP and replaces list \fIname\fP if already exists. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – APPID .IP \(bu 2 \fBname\fP – list name .IP \(bu 2 \fBtags\fP – list content as DXFTags or (code, value) tuples, list name and curly braces ‘{’ ‘}’ tags will be added .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B discard_xlist(appid: str, name: str) -> None Deletes list \fIname\fP from XDATA \fIappid\fP\&. Ignores silently if XDATA \fIappid\fP or list \fIname\fP not exist. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – APPID .IP \(bu 2 \fBname\fP – list name .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B replace_xlist(appid: str, name: str, tags: Iterable) -> None Replaces list \fIname\fP of existing XDATA \fIappid\fP by \fItags\fP\&. Appends new list if list \fIname\fP do not exist, but raises \fIDXFValueError\fP if XDATA \fIappid\fP do not exist. .sp Low level interface, if not sure use \fIset_xdata_list()\fP instead. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBappid\fP – APPID .IP \(bu 2 \fBname\fP – list name .IP \(bu 2 \fBtags\fP – list content as DXFTags or (code, value) tuples, list name and curly braces ‘{’ ‘}’ tags will be added .UNINDENT .TP .B Raises \fI\%DXFValueError\fP – XDATA \fIappid\fP do not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: \fI\%Matrix44\fP) -> None Transform XDATA tags with group codes 1011, 1012, 1013, 1041 and 1042 inplace. For more information see \fI\%Extended Data\fP Internals. .UNINDENT .UNINDENT .SS Application\-Defined Data (AppData) .sp Starting at DXF R13, DXF objects can contain application\-defined codes (AppData) outside of XDATA. .sp All AppData is defined with a beginning (102, “{APPID”) tag and according to the DXF reference appear should appear before the first subclass marker. .sp There are two known use cases of this data structure in Autodesk products: .INDENT 0.0 .IP \(bu 2 \fBACAD_REACTORS\fP, store handles to persistent reactors in a DXF entity .IP \(bu 2 \fBACAD_XDICTIONARY\fP, store handle to the extension dictionary of a DXF entity .UNINDENT .sp Both AppIDs are not defined/stored in the AppID table! .INDENT 0.0 .TP .B class ezdxf.entities.appdata.AppData Internal management class for Application defined data. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 User reference: \fI\%Application\-Defined Data (AppData)\fP .IP \(bu 2 Internals about \fI\%Application\-Defined Codes\fP tags .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __contains__(appid: str) -> bool Returns \fBTrue\fP if application\-defined data exist for \fIappid\fP\&. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns the count of AppData. .UNINDENT .INDENT 7.0 .TP .B add(appid: str, data: Iterable[Sequence]) -> None Add application\-defined tags for \fIappid\fP\&. Adds first tag (102, “{APPID”) if not exist. Adds last tag (102, “}” if not exist. .UNINDENT .INDENT 7.0 .TP .B get(appid: str) -> \fI\%Tags\fP Get application\-defined data for \fIappid\fP as \fI\%Tags\fP container. The first tag is always (102, “{APPID”). The last tag is always (102, “}”). .UNINDENT .INDENT 7.0 .TP .B set(tags: \fI\%Tags\fP) -> None Store raw application\-defined data tags. The first tag has to be (102, “{APPID”). The last tag has to be (102, “}”). .UNINDENT .INDENT 7.0 .TP .B discard(appid: str) Delete application\-defined data for \fIappid\fP without raising and error if \fIappid\fP doesn’t exist. .UNINDENT .UNINDENT .SS Reactors .INDENT 0.0 .TP .B class ezdxf.entities.appdata.Reactors Internal management class for persistent reactor handles. Handles are stored as hex strings like \fB\(dqABBA\(dq\fP\&. .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 User reference: \fI\%Reactors\fP .IP \(bu 2 Internals about \fI\%Persistent Reactors\fP tags .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __contains__(handle: str) -> bool Returns \fBTrue\fP if \fIhandle\fP is registered. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of registered handles. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterator[str] Returns an iterator for all registered handles. .UNINDENT .INDENT 7.0 .TP .B add(handle: str) -> None Add a single \fIhandle\fP\&. .UNINDENT .INDENT 7.0 .TP .B get() -> list[str] Returns all registered handles as sorted list. .UNINDENT .INDENT 7.0 .TP .B set(handles: Iterable[str] | None) -> None Reset all handles. .UNINDENT .INDENT 7.0 .TP .B discard(handle: str) Discard a single \fIhandle\fP\&. .UNINDENT .UNINDENT .SS Documentation Guide .SS Formatting Guide .sp This section is only for \fI\%myself\fP, because of the long pauses between develop iterations, I often forget to be consistent in documentation formatting. .sp Documentation is written with \fI\%Sphinx\fP and \fI\%reSturcturedText\fP\&. .sp Started integration of documentation into source code and using \fI\%autodoc\fP features of \fI\%Sphinx\fP wherever useful. .sp Sphinx theme provided by \fI\%Read the Docs\fP : .INDENT 0.0 .INDENT 3.5 .sp .EX pip install sphinx\-rtd\-theme .EE .UNINDENT .UNINDENT .SS \fI\%guide\fP — Example module .INDENT 0.0 .TP .B guide.example_func(a: int, b: str, test: str = None, flag: bool = True) -> None Parameters \fIa\fP and \fIb\fP are positional arguments, argument \fItest\fP defaults to \fBNone\fP and \fIflag\fP to \fBTrue\fP\&. Set \fIa\fP to 70 and \fIb\fP to “x” as an example. Inline code examples \fBexample_func(70, \(aqx\(aq)\fP or simple \fBexample_func(70, \(dqx\(dq)\fP .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 arguments: \fIa\fP, \fIb\fP, \fItest\fP and \fIflags\fP .IP \(bu 2 literal number values: 1, 2 … 999 .IP \(bu 2 literal string values: “a String” .IP \(bu 2 literal tags: (5, “F000”) .IP \(bu 2 inline code: call a \fBexample_func(x)\fP .IP \(bu 2 Python keywords: \fBNone\fP, \fBTrue\fP, \fBFalse\fP, \fBtuple\fP, \fBlist\fP, \fBdict\fP, \fBstr\fP, \fBint\fP, \fBfloat\fP .IP \(bu 2 Exception classes: \fBDXFAttributeError\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class guide.ExampleCls(**kwargs) The \fI\%ExampleCls\fP constructor accepts a number of optional keyword arguments. Each keyword argument corresponds to an instance attribute, so for example .INDENT 7.0 .INDENT 3.5 .sp .EX e = ExampleCls(flag=True) .EE .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flag This is the attribute \fI\%flag\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_axis(axis) axis as (x, y, z) tuple .INDENT 7.0 .TP .B Args: axis: (x, y, z) tuple .UNINDENT .UNINDENT .INDENT 7.0 .TP .B example_method(flag: bool = False) -> None Method \fI\%example_method()\fP of class \fI\%ExampleCls\fP .UNINDENT .UNINDENT .SS Text Formatting .INDENT 0.0 .TP .B DXF version DXF R12 (AC1009), DXF R2004 (AC1018) .TP .B DXF Types DXF types are always written in uppercase letters but without further formatting: DXF, LINE, CIRCLE .TP .B (internal API) Marks methods as internal API, gets no public documentation. .TP .B (internal class) Marks classes only for internal usage, gets not public documentation. .TP .B Spatial Dimensions 2D and 3D with an uppercase letter D .TP .B Axis x\-axis, y\-axis and z\-axis .TP .B Planes xy\-plane, xz\-plane, yz\-plane .TP .B Layouts modelspace, paperspace [layout], block [layout] .TP .B Extended Entity Data AppData, XDATA, embedded object, APPID .UNINDENT .SH GLOSSARY .INDENT 0.0 .TP .B ACI \fI\%AutoCAD Color Index (ACI)\fP .TP .B ACIS The 3D ACIS Modeler (\fI\%ACIS\fP) is a geometric modeling kernel developed by \fI\%Spatial Corp.\fP ® (formerly \fISpatial Technology\fP) and now part of \fIDassault Systems\fP\&. All ACIS based DXF entities store their geometry as \fI\%SAT\fP or \fI\%SAB\fP data. These are not open data formats and a license has to be purchased to get access to their SDK, therefore \fIezdxf\fP can not provide any support for creating, processing or transforming of ACIS based DXF entities. .TP .B bulge The \fI\%Bulge value\fP is used to create arc shaped line segments in \fI\%Polyline\fP and \fI\%LWPolyline\fP entities. .TP .B CAD Computer\-Assisted Drafting or Computer\-Aided Design .TP .B CTB Color dependent plot style table (\fBColorDependentPlotStyles\fP) .TP .B DWG Proprietary file format of \fI\%AutoCAD\fP ®. Documentation for this format is available from the Open Design Alliance (\fI\%ODA\fP) at their \fI\%Downloads\fP section. This documentation is created by reverse engineering therefore not perfect nor complete. .TP .B DXF Drawing eXchange Format is a file format used by \fI\%AutoCAD\fP ® to interchange data with other \fI\%CAD\fP applications. \fI\%DXF\fP is a trademark of \fI\%Autodesk\fP ®. See also \fI\%What is DXF?\fP .TP .B proxy\-graphic The proxy\-graphic is an internal data format to add a graphical representation to DXF entities which are unknown (custom DXF entities), not documented or very complex so CAD applications can display them without knowledge about the internal structure of these entities. .TP .B raw\-color Raw color value as stored in DWG files, this integer value can represent \fI\%ACI\fP values as well as and \fI\%true\-color\fP values .TP .B reliable CAD application CAD applications which create valid DXF documents in the meaning and interpretation of \fI\%Autodesk\fP\&. See also \fI\%What is DXF?\fP .TP .B SAB ACIS file format (Standard ACIS Binary), binary stored data .TP .B SAT ACIS file format (Standard ACIS Text), data stored as ASCII text .TP .B STB Named plot style table (\fBNamedPlotStyles\fP) .TP .B true\-color RGB color representation, a combination red, green and blue values to define a color. .UNINDENT .SH KNOWLEDGE GRAPH .sp I have started managing notes and documents that are not included in the \fIezdxf\fP documentation in \fI\%Logseq\fP in late 2023. It works like a wiki but does not require a backend server. The Information is edited as Markdown files, which is much more intuitive than reStructured Text, and the content is stored in local files. .sp The notes are included in the source code repository on Github in the \fI\%notes folder\fP\&. .sp A published edition of this Knowledge Graph is included on the \fIezdxf\fP website and is accessible by the link \fI\%https://ezdxf.mozman.at/notes\fP\&. .sp The Knowledge Graph includes: .INDENT 0.0 .IP \(bu 2 \fI\%Release Notes\fP of future releases and some versions back .IP \(bu 2 \fI\%CHANGELOG\fP .IP \(bu 2 \fI\%IDEAS\fP for future releases .IP \(bu 2 \fI\%FAQ\fP and the \fI\%HOWTO\fP sections from this documentation .IP \(bu 2 all my notes to \fIezdxf\fP .IP \(bu 2 In the future the \fIDXF Internals\fP section from this documentation may also move to the Knowledge Graph. .UNINDENT .sp Logseq’s outline structure is not ideal for all the documents I want to include, but I chose \fI\%Logseq\fP over \fI\%Obsidian.md\fP because it is open source and can publish the knowledge graph as a static website, static in the sense of no server\-side code execution. .sp his feature is important to me for hosting the content of the Knowledge Graph on the \fIezdxf\(ga\fP website and cannot be achieved for free with \fI\%Obsidian.md\fP\&. .sp \fI\%Logseq\fP is an \fI\%Electron\fP application that runs on all platforms, with the disadvantage: it’s an \fI\%Electron\fP application. .SH INDICES AND TABLES .INDENT 0.0 .IP \(bu 2 \fI\%Index\fP .IP \(bu 2 \fI\%Search Page\fP .UNINDENT .SH AUTHOR Manfred Moitzi .SH COPYRIGHT 2011-2023, Manfred Moitzi .\" Generated by docutils manpage writer. .