.\" Man page generated from reStructuredText. . .TH "EZDXF" "1" "Nov 27, 2020" "0.14.2" "ezdxf" .SH NAME ezdxf \- ezdxf Documentation . .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 .. [image] .sp Welcome! This is the documentation for ezdxf release 0.14.2, last updated Nov 27, 2020\&. .INDENT 0.0 .IP \(bu 2 \fIezdxf\fP is a Python package to create new DXF files and read/modify/write existing DXF files .IP \(bu 2 the intended audience are developers .IP \(bu 2 requires at least Python 3.6 .IP \(bu 2 OS independent .IP \(bu 2 additional required packages: \fI\%pyparsing\fP .IP \(bu 2 MIT\-License .IP \(bu 2 read/write/new support for DXF versions: R12, R2000, R2004, R2007, R2010, R2013 and R2018 .IP \(bu 2 additional read support for DXF versions R13/R14 (upgraded to R2000) .IP \(bu 2 additional read 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 preserves third\-party DXF content .UNINDENT .SH INCLUDED EXTENSIONS .INDENT 0.0 .IP \(bu 2 \fBdrawing\fP add\-on to visualise and convert DXF files to images which can be saved to various formats such as png, pdf and svg .IP \(bu 2 \fBr12writer\fP add\-on to write basic DXF entities direct and fast into a DXF R12 file or stream .IP \(bu 2 \fBiterdxf\fP add\-on to iterate over entities of the modelspace of really big (> 5GB) DXF files which do not fit into memory .IP \(bu 2 \fBimporter\fP add\-on to import entities, blocks and table entries from another DXF document .IP \(bu 2 \fBdxf2code\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 \fBacadctb\fP add\-on to read/write plot_style_files .IP \(bu 2 \fBpycsg\fP add\-on for Constructive Solid Geometry (CSG) modeling technique .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 .sp Source Code: \fI\%http://github.com/mozman/ezdxf.git\fP .sp Issue Tracker at GitHub: \fI\%http://github.com/mozman/ezdxf/issues\fP .SH QUESTIONS AND FEEDBACK AT GOOGLE GROUPS .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 DXF (drawing interchange file) format developed by \fI\%Autodesk\fP, it allows developers to read and modify existing DXF drawings or create new DXF drawings. .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 DXF format. Nevertheless, a basic understanding of the DXF format is required, also to understand which tasks and goals are possible to accomplish by using the 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 my \fI\%dxfwrite\fP and my \fI\%dxfgrabber\fP packages but with different APIs, for more information see also: faq001 .SS What ezdxf can’t do .INDENT 0.0 .INDENT 3.5 .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 .UNINDENT .UNINDENT .SS Supported Python Versions .sp \fIezdxf\fP requires at least Python 3.6 and will be tested with the latest stable CPython 3 version and the latest stable release of pypy3 during development. .sp \fIezdxf\fP is written in pure Python and requires only \fIpyparser\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 this DXF files. .SS Supported Operating Systems .sp \fIezdxf\fP is OS independent and runs on all platforms which provide an appropriate Python interpreter (>=3.6). .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 reads also 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 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 .nf .ft C import ezdxf .ft P .fi .UNINDENT .UNINDENT .SS Loading DXF Files .sp \fIezdxf\fP supports loading ASCII and binary DXF files from a file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.readfile(filename) .ft P .fi .UNINDENT .UNINDENT .sp or from a zip\-file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.readzip(zipfilename[, filename]) .ft P .fi .UNINDENT .UNINDENT .sp Which loads the DXF file \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 file from a stream by the \fBezdxf.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 files from trusted sources like AutoCAD or BricsCAD, for loading DXF files with minor or major flaws look at the \fBezdxf.recover\fP module. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Documentation for \fBezdxf.readfile()\fP, \fBezdxf.readzip()\fP and \fBezdxf.read()\fP, for more information about file management go to the dwgmanagement section. For loading DXF files with structural errors look at the \fBezdxf.recover\fP module. .UNINDENT .UNINDENT .SS Saving DXF Files .sp Save the DXF document with a new name: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.saveas(\(aqnew_name.dxf\(aq) .ft P .fi .UNINDENT .UNINDENT .sp or with the same name as loaded: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.save() .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Documentation for \fBezdxf.document.Drawing.save()\fP and \fBezdxf.document.Drawing.saveas()\fP, for more information about file management go to the dwgmanagement section. .UNINDENT .UNINDENT .SS Create a New DXF File .sp Create new file for the latest supported DXF version: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.new() .ft P .fi .UNINDENT .UNINDENT .sp Create a new DXF file for a specific DXF version, e.g for DXF R12: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.new(\(aqR12\(aq) .ft P .fi .UNINDENT .UNINDENT .sp To setup some basic DXF resources use the \fIsetup\fP argument: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.new(setup=True) .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Documentation for \fBezdxf.new()\fP, for more information about file management go to the dwgmanagement section. .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 .nf .ft C msp = doc.modelspace() .ft P .fi .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 .nf .ft C psp = doc.layout(\(aqLayout1\(aq) .ft P .fi .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 important concept of the DXF format. .sp Getting a block layout by the block name: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C blk = doc.blocks.get(\(aqNAME\(aq) .ft P .fi .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 Create New Blocks .sp The block definitions of a DXF document are managed by the \fBBlocksSection\fP object: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C my_block = doc.blocks.new(\(aqMyBlock\(aq) .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_blocks .UNINDENT .UNINDENT .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 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 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: \fBquery()\fP and \fBgroupby()\fP\&. .sp Get all lines of layer \fB\(aqMyLayer\(aq\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C lines = msp.query(\(aqLINE[layer=="MyLayer"]\(aq) .ft P .fi .UNINDENT .UNINDENT .sp This returns an \fBEntityQuery\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 .nf .ft C all_lines_by_color = msp.query(\(aqLINE\(aq).groupby(\(aqcolor\(aq) lines_with_color_1 = all_lines_by_color.get(1, []) .ft P .fi .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 \fBEntityQuery\fP container). .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For more information go to the tut_getting_data .UNINDENT .UNINDENT .SS Examine DXF Entities .sp Each DXF entity has a \fBdxf\fP namespace attribute, which stores the named DXF attributes, some DXF attributes are only indirect available like the vertices in the LWPOLYLINE entity. More information about the DXF attributes of each entity can found in the documentation of the \fBezdxf.entities\fP module. .sp Get some basic DXF attributes: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C layer = entity.dxf.layer # default is \(aq0\(aq color = entity.dxf.color # default is 256 = BYLAYER .ft P .fi .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 in the attribute really exist: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C entity.dxf.hasattr(\(aqtrue_color\(aq) .ft P .fi .UNINDENT .UNINDENT .sp or use the \fBget()\fP method and a default value: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C entity.dxf.get(\(aqtrue_color\(aq, 0) .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Common graphical DXF attributes .UNINDENT .UNINDENT .SS Create New DXF Entities .sp The factory functions for creating new graphical DXF entities are located in the \fBBaseLayout\fP class. This means this factory function are available for all entity containers: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBModelspace\fP .IP \(bu 2 \fBPaperspace\fP .IP \(bu 2 \fBBlockLayout\fP .UNINDENT .UNINDENT .UNINDENT .sp The usage is simple: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp = doc.modelspace() msp.add_line((0, 0), (1, 0), dxfattribs={\(aqlayer\(aq: \(aqMyLayer\(aq}) .ft P .fi .UNINDENT .UNINDENT .sp A few important or required DXF attributes are explicit method arguments, most additional and optional DXF attributes are gives as a regular Python \fBdict\fP object. The supported DXF attributes can be found in the documentation of the \fBezdxf.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 function to create new graphical entities, this is the intended way to use \fIezdxf\fP\&. .UNINDENT .UNINDENT .SS Create Block References .sp A block reference is just another DXF entity called INSERT, but the term “Block Reference” is a better choice and so the \fBInsert\fP entity is created by the factory function: \fBadd_blockref()\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp.add_blockref(\(aqMyBlock\(aq) .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 See tut_blocks for more advanced features like using \fBAttrib\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 this entity can inherit some properties from this \fBLayer\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 .nf .ft C my_layer = doc.layer.new(\(aqMyLayer\(aq) .ft P .fi .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 .nf .ft C my_layer.color = 1 .ft P .fi .UNINDENT .UNINDENT .sp To change the state of a layer use the provided methods of the \fBLayer\fP object, like \fBon()\fP, \fBoff()\fP, \fBfreeze()\fP or \fBthaw()\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C my_layer.off() .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 layer_concept .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 .nf .ft C line = msp.add_line((0, 0), (1, 0)) msp.delete_entity(line) .ft P .fi .UNINDENT .UNINDENT .sp This removes the entity immediately from the layout and destroys the entity. The property \fBis_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 \fBdxf\fP attribute anymore. .sp The current version of \fIezdxf\fP also supports also destruction of entities by calling method \fBdestroy()\fP manually: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C line.destroy() .ft P .fi .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 reference documentation .IP \(bu 2 Documentation of package internals: Developer Guides\&. .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 ezdxf internals look at the Reference section or if you want to learn how to use \fIezdxf\fP go to the Tutorials section and for the solution of specific problems go to the Howto section. .SS AutoCAD Color Index (ACI) .sp The \fBcolor\fP attribute represents an \fIACI\fP (AutoCAD Color Index). AutoCAD and many other CAD 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 CTB or STB file. \fIezdxf\fP provides functions to create (\fBnew()\fP) or modify (\fBezdxf.acadctb.load()\fP) plot styles files. .sp DXF R12 and prior are not good in preserving the layout of a drawing, because of the lack of a standard color table defined by the DXF reference and missing DXF structures to define these color tables in the DXF file. So if a CAD user redefined an ACI and do not provide a CTB or STB file, you have no ability to determine which color or lineweight was used. This is better in later DXF versions by providing additional DXF attributes like \fBlineweight\fP and \fBtrue_color\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 plot_style_files .UNINDENT .UNINDENT .SS Layer Concept .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 \fBLayer\fP by \fBDrawing.layers.new()\fP, assign the layer properties such as color and linetype. Then assign those layers to other DXF entities by setting the DXF attribute \fBlayer\fP to the layer name as string. .sp It is possible to use layers without a layer definition but not recommend, just use a layer name without a layer definition, the layer has the default linetype \fB\(aqContinuous\(aq\fP and the default color is \fB7\fP\&. .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\(aqBYLAYER\(aq\fP as linetype string and \fB256\fP as color, both values are default values for new entities. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_layers .UNINDENT .UNINDENT .SS Linetypes .sp The \fBlinetype\fP defines the pattern of a line. 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 line type from the assigned layer by setting \fBlinetype\fP to \fB\(aqBYLAYER\(aq\fP, which is also the default value. CONTINUOUS is the default line type for layers with unspecified line type. .sp \fIezdxf\fP creates several standard linetypes, if the argument \fIsetup\fP is \fBTrue\fP at calling \fBnew()\fP, this simple line types are supported by all DXF versions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.new(\(aqR2007\(aq, setup=True) .ft P .fi .UNINDENT .UNINDENT [image] .sp In DXF R13 Autodesk introduced complex linetypes, containing TEXT or SHAPES in linetypes. \fIezdxf\fP v0.8.4 and later supports complex linetypes. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_linetypes .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 To change the linetype scaling for single entities set scaling factor by DXF attribute \fBltscale\fP, which is supported since DXF version R2000. .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 ezdxf provides a converter class \fBUCS\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 \fBezdxf.math.UCS\fP \- converter between WCS and UCS .UNINDENT .UNINDENT .UNINDENT .SS OCS .sp Object coordinate system \- coordinates relative to the object itself. These points are usually converted into the WCS, current UCS, or current DCS, according to the intended use of the object. Conversely, points must be translated into an OCS before they are written to the database. This is also known as the entity coordinate system. .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. And further more, the main goal of OCS is to place 2D elements in 3D space, this maybe was useful in the early years of CAD, I think nowadays this is an not often used feature, but I am not an AutoCAD user. .sp OCS differ from WCS only if extrusion != (0, 0, 1), convert OCS into WCS: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # circle is an DXF entity with extrusion != (0, 0, 1) ocs = circle.ocs() wcs_center = ocs.to_wcs(circle.dxf.center) .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 Object Coordinate System \- deeper insights into OCS .IP \(bu 2 \fBezdxf.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. .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, and the elevation value. .sp For a given z\-axis (or 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. .UNINDENT .sp These 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 \fBLine\fP .IP \(bu 2 \fBPoint\fP .IP \(bu 2 \fB3DFace\fP .IP \(bu 2 \fBPolyline\fP (3D) .IP \(bu 2 \fBVertex\fP (3D) .IP \(bu 2 \fBPolymesh\fP .IP \(bu 2 \fBPolyface\fP .IP \(bu 2 \fBViewport\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 \fBCircle\fP .IP \(bu 2 \fBArc\fP .IP \(bu 2 \fBSolid\fP .IP \(bu 2 \fBTrace\fP .IP \(bu 2 \fBText\fP .IP \(bu 2 \fBAttrib\fP .IP \(bu 2 \fBAttdef\fP .IP \(bu 2 \fBShape\fP .IP \(bu 2 \fBInsert\fP .IP \(bu 2 \fBPolyline\fP (2D) .IP \(bu 2 \fBVertex\fP (2D) .IP \(bu 2 \fBLWPolyline\fP .IP \(bu 2 \fBHatch\fP .IP \(bu 2 \fBImage\fP .UNINDENT .sp Some of a \fBDimension\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 right\-hand 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 \fBVector\fP): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C Az = Vector(entity.dxf.extrusion).normalize() # normal (extrusion) vector # Extrusion vector normalization should not be necessary, but don\(aqt rely on any DXF content if (abs(Az.x) < 1/64.) and (abs(Az.y) < 1/64.): Ax = Vector(0, 1, 0).cross(Az).normalize() # the cross\-product operator else: Ax = Vector(0, 0, 1).cross(Az).normalize() # the cross\-product operator Ay = Az.cross(Ax).normalize() .ft P .fi .UNINDENT .UNINDENT .SS WCS to OCS .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def wcs_to_ocs(point): px, py, pz = Vector(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 Vector(x, y, z) .ft P .fi .UNINDENT .UNINDENT .SS OCS to WCS .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 = Vector(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 Vector(x, y, z) .ft P .fi .UNINDENT .UNINDENT .SH TUTORIALS .SS Tutorial for getting data from DXF files .sp In this tutorial I show you how to get data from an existing DXF drawing. .sp Loading the DXF file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import sys import ezdxf try: doc = ezdxf.readfile("your_dxf_file.dxf") 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) .ft P .fi .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 \fBezdxf.recover\fP module. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 dwgmanagement .UNINDENT .UNINDENT .SS Layouts .sp I use the term layout as synonym for an arbitrary entity space which can contain DXF entities like LINE, CIRCLE, TEXT and so on. Every DXF entity can only reside in exact one layout. .sp There are three different layout types: .INDENT 0.0 .IP \(bu 2 \fBModelspace\fP: this is the common construction space .IP \(bu 2 \fBPaperspace\fP: used to to create print layouts .IP \(bu 2 \fBBlockLayout\fP: reusable elements, every block has its own entity space .UNINDENT .sp A DXF drawing consist of exact one modelspace and at least of 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 Iterate over DXF entities of a layout .sp Iterate over all DXF entities in modelspace. Although this is a possible way to retrieve DXF entities, I would like to point out that \fI\%entity queries\fP are the better way. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # iterate over all entities in modelspace msp = doc.modelspace() for e in msp: if e.dxftype() == \(aqLINE\(aq: print_entity(e) # entity query for all LINE entities in modelspace for e in msp.query(\(aqLINE\(aq): print_entity(e) def print_entity(e): print("LINE on layer: %s\en" % e.dxf.layer) print("start point: %s\en" % e.dxf.start) print("end point: %s\en" % e.dxf.end) .ft P .fi .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 Check the type of an DXF entity by \fBe.dxftype()\fP\&. The DXF type is always uppercase. All DXF attributes of an entity are grouped in the namespace attribute \fBdxf\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C e.dxf.layer # layer of the entity as string e.dxf.color # color of the entity as integer .ft P .fi .UNINDENT .UNINDENT .sp See Common graphical DXF attributes .sp If a DXF attribute is not set (a valid DXF attribute has no value), a \fBDXFValueError\fP will be raised. To avoid this use the \fBget_dxf_attrib()\fP method with a default value: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # If DXF attribute \(aqpaperspace\(aq does not exist, the entity defaults # to modelspace: p = e.get_dxf_attrib(\(aqpaperspace\(aq, 0) .ft P .fi .UNINDENT .UNINDENT .sp An unsupported DXF attribute raises an \fBDXFAttributeError\fP\&. .SS Getting a paperspace layout .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C paperspace = doc.layout(\(aqlayout0\(aq) .ft P .fi .UNINDENT .UNINDENT .sp Retrieves the paperspace named \fBlayout0\fP, the usage of the \fBLayout\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.layout(\(aqlayout0\(aq)\fP is ignored or can be left off. For the later DXF versions you get a list of the names of the available layouts by \fBlayout_names()\fP\&. .SS Retrieve entities by query language .sp \fIezdxf\fP provides a flexible query language for DXF entities. All layout types have a \fBquery()\fP method to start an entity query or use the \fBezdxf.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\(aqEntityQuery[AttributeQuery]\(aq\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 other DXF names have to be uppercase. The \fB*\fP search can exclude entity types by adding the entity name with a presceding \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 entity query string .UNINDENT .UNINDENT .sp Get all LINE entities from the modelspace: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp = doc.modelspace() lines = msp.query(\(aqLINE\(aq) .ft P .fi .UNINDENT .UNINDENT .sp The result container \fBEntityQuery\fP also provides the \fBquery()\fP method, get all LINE entities at layer \fBconstruction\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C construction_lines = lines.query(\(aq*[layer=="construction"]\(aq) .ft P .fi .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 \fBlines\fP just contains entities of DXF type LINE. .sp All together as one query: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C lines = msp.query(\(aqLINE[layer=="construction"]\(aq) .ft P .fi .UNINDENT .UNINDENT .sp The ENTITIES section also supports the \fBquery()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C lines_and_circles = doc.entities.query(\(aqLINE CIRCLE[layer=="construction"]\(aq) .ft P .fi .UNINDENT .UNINDENT .sp Get all modelspace entities at layer \fBconstruction\fP, but excluding entities with linetype \fBDASHED\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C not_dashed_entities = msp.query(\(aq*[layer=="construction" and linetype!="DASHED"]\(aq) .ft P .fi .UNINDENT .UNINDENT .SS Retrieve entities by groupby() function .sp Search and group entities by a user defined criteria. As example let’s group all entities from modelspace by layer, the result will be a dict with layer names as dict\-key and a list of all entities from modelspace matching this layer as dict\-value. Usage as dedicated function call: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from ezdxf.groupby import groupby group = groupby(entities=msp, dxfattrib=\(aqlayer\(aq) .ft P .fi .UNINDENT .UNINDENT .sp The \fIentities\fP argument can be any container or generator which yields \fBDXFEntity\fP or inherited objects. Shorter and simpler to use as method of \fBBaseLayout\fP (modelspace, paperspace layouts, blocks) and query results as \fBEntityQuery\fP objects: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C group = msp.groupby(dxfattrib=\(aqlayer\(aq) for layer, entities in group.items(): print(f\(aqLayer "{layer}" contains following entities:\(aq) for entity in entities: print(\(aq {}\(aq.format(str(entity))) print(\(aq\-\(aq*40) .ft P .fi .UNINDENT .UNINDENT .sp The previous example shows how to group entities by a single DXF attribute, but it is also possible to group entities by a custom key, to do so 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. The following example shows how to group entities by layer and color, so each result entry has a tuple \fB(layer, color)\fP as key and a list of entities with matching DXF attributes: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def layer_and_color_key(entity): # return None to exclude entities from result container if entity.dxf.layer == \(aq0\(aq: # exclude entities from default layer \(aq0\(aq 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 "{key}" matches following entities:\(aq) for entity in entities: print(\(aq {}\(aq.format(str(entity))) print(\(aq\-\(aq*40) .ft P .fi .UNINDENT .UNINDENT .sp To exclude entities from the result container the \fIkey\fP function should return \fBNone\fP\&. The \fBgroupby()\fP function catches \fBDXFAttributeError\fP exceptions while processing entities and excludes this entities from the result container. So 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 \fBgroupby()\fP documentation .UNINDENT .UNINDENT .SS Tutorial for creating simple DXF drawings .sp r12writer \- create simple DXF R12 drawings with a restricted entities set: LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE and POLYLINE. Advantage of the \fIr12writer\fP is the speed and the low memory footprint, all entities are written direct to the file/stream without building a drawing data structure in memory. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 r12writer .UNINDENT .UNINDENT .sp Create a new DXF drawing with \fBezdxf.new()\fP to use all available DXF entities: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf doc = ezdxf.new(\(aqR2010\(aq) # create a new DXF R2010 drawing, official DXF version name: \(aqAC1024\(aq msp = doc.modelspace() # add new entities to the modelspace msp.add_line((0, 0), (10, 0)) # add a LINE entity doc.saveas(\(aqline.dxf\(aq) .ft P .fi .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 Look at factory methods of the \fBBaseLayout\fP class to see all the available DXF entities. .UNINDENT .UNINDENT .SS Tutorial for Layers .sp If you are not familiar with the concept of layers, please read this first: layer_concept .SS Create a Layer Definition .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf doc = ezdxf.new(setup=True) # setup required line types msp = doc.modelspace() doc.layers.new(name=\(aqMyLines\(aq, dxfattribs={\(aqlinetype\(aq: \(aqDASHED\(aq, \(aqcolor\(aq: 7}) .ft P .fi .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\(aqBYLAYER\(aq\fP as linetype string and \fB256\fP as color, both values are default values for new entities so you can left off this assignments: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp.add_line((0, 0), (10, 0), dxfattribs={\(aqlayer\(aq: \(aqMyLines\(aq}) .ft P .fi .UNINDENT .UNINDENT .sp The new created line will be drawn with color \fB7\fP and linetype \fB\(aqDASHED\(aq\fP\&. .SS Changing Layer State .sp Get the layer definition object: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C my_lines = doc.layers.get(\(aqMyLines\(aq) .ft P .fi .UNINDENT .UNINDENT .sp Check the state of the layer: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp Change the state of the layer: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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() .ft P .fi .UNINDENT .UNINDENT .sp Get/set default 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, layer is off if the color value is negative. .sp Changing the default layer values: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C my_lines.dxf.linetype = \(aqDOTTED\(aq my_lines.color = 13 # preserves on/off state of layer .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For all methods and attributes see class \fBLayer\fP\&. .UNINDENT .UNINDENT .SS Check Available Layers .sp The layers object supports some standard Python protocols: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # iteration for layer in doc.layers: if layer.dxf.name != \(aq0\(aq: layer.off() # switch all layers off except layer \(aq0\(aq # check for existing layer definition if \(aqMyLines\(aq in doc.layers: layer = doc.layers.get(\(aqMyLines\(aq) layer_count = len(doc.layers) # total count of layer definitions .ft P .fi .UNINDENT .UNINDENT .SS Deleting a Layer .sp Delete a layer definition: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.layers.remove(\(aqMyLines\(aq) .ft P .fi .UNINDENT .UNINDENT .sp This just deletes the layer definition, all DXF entities with the DXF attribute layer set to \fB\(aqMyLines\(aq\fP are still there, but if they inherit color and/or linetype from the layer definition they will be drawn now with linetype \fB\(aqContinuous\(aq\fP and color \fB1\fP\&. .SS Tutorial for Blocks .SS What are Blocks? .sp Blocks are collections of DXF entities which can be placed multiply times as block references in different layouts and other block definitions. The block reference (\fBInsert\fP) can be rotated, scaled, placed in 3D by OCS and arranged in a grid like manner, each \fBInsert\fP entity can have individual attributes (\fBAttrib\fP) attached. .SS Create a Block .sp Blocks are managed as \fBBlockLayout\fP by a \fBBlocksSection\fP object, every drawing has only one blocks section stored in the attribute: \fBDrawing.blocks\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf import random # needed for random placing points def get_random_point(): """Returns random x, y coordinates.""" 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 .ft P .fi .UNINDENT .UNINDENT .SS Block References (Insert) .sp A block reference is a DXF \fBInsert\fP entity and can be placed in any layout: \fBModelspace\fP, any \fBPaperspace\fP or \fBBlockLayout\fP (which enables nested block references). Every block reference can be scaled and rotated individually. .sp Lets insert some random flags into the modelspace: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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("blockref_tutorial.dxf") .ft P .fi .UNINDENT .UNINDENT .sp Query all block references of block \fBFLAG\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C for flag_ref in msp.query(\(aqINSERT[name=="FLAG"]\(aq): print(str(flag_ref)) .ft P .fi .UNINDENT .UNINDENT .SS What are Attributes? .sp An attribute (\fBAttrib\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 programs. An attribute can be visible or hidden. The simple way to use attributes is just to add an attribute to a block reference by \fBInsert.add_attrib()\fP, but the attribute is geometrically not related to the block reference, so you have to calculate the insertion point, rotation and scaling of the attribute by yourself. .SS Using Attribute Definitions .sp The second way to use attributes in block references is a two step process, first step is to create an attribute definition (template) in the block definition, the second step is adding the block reference by \fBLayout.add_blockref()\fP and attach and fill attribute automatically by the \fBadd_auto_attribs()\fP method to the block reference. The advantage of this method is that all attributes are placed relative to the block base point with the same rotation and scaling as the block, but has the disadvantage that non uniform scaling is not handled very well. The method \fBLayout.add_auto_blockref()\fP 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 which will create correct graphical representations at least by AutoCAD and BricsCAD. This method has the disadvantage of a more complex evaluation of attached attributes .sp Using attribute definitions (\fBAttdef\fP): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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: "P(%d)" % (number + 1), \(aqXPOS\(aq: "x = %.3f" % point[0], \(aqYPOS\(aq: "y = %.3f" % 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("auto_blockref_tutorial.dxf") .ft P .fi .UNINDENT .UNINDENT .SS Get/Set Attributes of Existing Block References .sp See the howto: howto_get_attribs .SS Evaluate Wrapped Block References .sp As mentioned above evaluation of block references wrapped into anonymous blocks is complex: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Collect all anonymous block references starting with \(aq*U\(aq anonymous_block_refs = modelspace.query(\(aqINSERT[name ? "^\e*U.+"]\(aq) # Collect real references to \(aqFLAG\(aq 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=="FLAG"]\(aq)) # Evaluation example: collect all flag names. flag_numbers = [flag.get_attrib_text(\(aqNAME\(aq) for flag in flag_refs if flag.has_attrib(\(aqNAME\(aq)] print(flag_numbers) .ft P .fi .UNINDENT .UNINDENT .SS Exploding Block References .sp New in version 0.12. .sp This is an advanced and still experimental feature and because \fIezdxf\fP is still not a CAD application, the results may no be perfect. \fBNon uniform scaling\fP lead to incorrect results for text entities (TEXT, MTEXT, ATTRIB) and some other entities like HATCH with arc or ellipse path segments. .sp By default the “exploded” entities are added to the same layout as the block reference is located. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C for flag_ref in msp.query(\(aqINSERT[name=="FLAG"]\(aq): flag_ref.explode() .ft P .fi .UNINDENT .UNINDENT .SS Examine Entities of Block References .sp New in version 0.12. .sp If you just want to examine the entities of a block reference use the \fBvirtual_entities()\fP method. This methods yields “virtual” entities with attributes 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 .nf .ft C for flag_ref in msp.query(\(aqINSERT[name=="FLAG"]\(aq): for entity in flag_ref.virtual_entities(): if entity.dxftype() == \(aqLWPOLYLINE\(aq: print(f\(aqFound {str(entity)}.\(aq) .ft P .fi .UNINDENT .UNINDENT .SS Tutorial for LWPolyline .sp The \fBLWPolyline\fP is defined as a single graphic entity, which differs from the old\-style \fBPolyline\fP entity, which is defined as a group of sub\-entities. \fBLWPolyline\fP display faster (in AutoCAD) and consume less disk space, it is a planar element, therefore all points in OCS as \fB(x, y)\fP tuples (\fBLWPolyline.dxf.elevation\fP is the z\-axis value). .sp Create a simple polyline: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf doc = ezdxf.new(\(aqR2000\(aq) msp = doc.modelspace() points = [(0, 0), (3, 0), (6, 3), (6, 6)] msp.add_lwpolyline(points) doc.saveas("lwpolyline1.dxf") .ft P .fi .UNINDENT .UNINDENT .sp Append multiple points to a polyline: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.readfile("lwpolyline1.dxf") msp = doc.modelspace() line = msp.query(\(aqLWPOLYLINE\(aq)[0] # take first LWPolyline line.append_points([(8, 7), (10, 7)]) doc.saveas("lwpolyline2.dxf") .ft P .fi .UNINDENT .UNINDENT .sp Getting points always returns a 5\-tuple \fB(x, y, start_width, ent_width, bulge)\fP, start_width, end_width and bulge is \fB0\fP if not present: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C first_point = line[0] x, y, start_width, end_width, bulge = first_point .ft P .fi .UNINDENT .UNINDENT .sp Use context manager to edit polyline points, this method was introduced because accessing single points was very slow, but since \fIezdxf\fP v0.8.9, direct access by index operator \fB[]\fP is very fast and using the context manager is not required anymore. Advantage of the context manager is the ability to use a user defined point format: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.readfile("lwpolyline2.dxf") msp = doc.modelspace() line = msp.query(\(aqLWPOLYLINE\(aq).first # take first LWPolyline, \(aqfirst\(aq was introduced with v0.10 with line.points(\(aqxyseb\(aq) 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). del points[\-2:] # delete last 2 points points.extend([(4, 7), (0, 7)]) # adding 2 other points # the same as one command # points[\-2:] = [(4, 7), (0, 7)] doc.saveas("lwpolyline3.dxf") .ft P .fi .UNINDENT .UNINDENT .sp Each line segment can have a different start\- and end\-width, if omitted start\- and end\-width is \fB0\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.new(\(aqR2000\(aq) 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("lwpolyline4.dxf") .ft P .fi .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 polyline is closed else the values are ignored. Start\- and end\-width only works if the DXF attribute \fBdxf.const_width\fP is unset, to be sure delete it: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C del line.dxf.const_width # no exception will be raised if const_width is already unset .ft P .fi .UNINDENT .UNINDENT .sp \fBLWPolyline\fP can also have curved elements, they are defined by the bulge value: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.new(\(aqR2000\(aq) 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("lwpolyline5.dxf") .ft P .fi .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 aa 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 \fB1\fP defines a semicircle. \fIbulge\fP > \fB0\fP the curve is on the right side of the vertex connection line, \fIbulge\fP < \fB0\fP the curve is on the left side. .sp \fIezdxf\fP v0.8.9 supports a user defined points 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 .nf .ft C msp.add_lwpolyline([(0, 0, 0), (10, 0, 1), (20, 0, 0)], format=\(aqxyb\(aq) msp.add_lwpolyline([(0, 10, 0), (10, 10, .5), (20, 10, 0)], format=\(aqxyb\(aq) .ft P .fi .UNINDENT .UNINDENT [image] .SS Tutorial for Text .sp Add a simple one line text entity by factory function \fBadd_text()\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf # TEXT is a basic entity and is supported by every DXF version. # Argument setup=True for adding standard linetypes and text styles. doc = ezdxf.new(\(aqR12\(aq, setup=True) msp = doc.modelspace() # use set_pos() for proper TEXT alignment: # The relations between DXF attributes \(aqhalign\(aq, \(aqvalign\(aq, # \(aqinsert\(aq and \(aqalign_point\(aq are tricky. msp.add_text("A Simple Text").set_pos((2, 3), align=\(aqMIDDLE_RIGHT\(aq) # Using a text style msp.add_text("Text Style Example: Liberation Serif", dxfattribs={ \(aqstyle\(aq: \(aqLiberationSerif\(aq, \(aqheight\(aq: 0.35} ).set_pos((2, 6), align=\(aqLEFT\(aq) doc.saveas("simple_text.dxf") .ft P .fi .UNINDENT .UNINDENT .sp Valid text alignments for argument \fIalign\fP in \fBText.set_pos()\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 .nf .ft C doc = ezdxf.new(\(aqR12\(aq, setup=True) .ft P .fi .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] .SS New Text Style .sp Creating a new text style is simple: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.styles.new(\(aqmyStandard\(aq, dxfattribs={\(aqfont\(aq : \(aqOpenSans\-Regular.ttf\(aq}) .ft P .fi .UNINDENT .UNINDENT .sp But 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, else \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 \fBText\fP entity into 3D space by using the OCS, for further information see: tut_ocs\&. .SS Tutorial for MText .sp The \fBMText\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 Prolog code: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf doc = ezdxf.new(\(aqR2007\(aq, setup=True) msp = doc.modelspace() lorem_ipsum = """ 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. """ .ft P .fi .UNINDENT .UNINDENT .SS Adding a MText entity .sp The MText entity can be added to any layout (modelspace, paperspace or block) by the \fBadd_mtext()\fP function. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # store MText entity for additional manipulations mtext = msp.add_mtext(lorem_ipsum, dxfattribs={\(aqstyle\(aq: \(aqOpenSans\(aq}) .ft P .fi .UNINDENT .UNINDENT .sp This adds a MText entity with text style \fB\(aqOpenSans\(aq\fP\&. 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 .nf .ft C mtext.text += \(aqAppend additional text to the MText entity.\(aq # even shorter with __iadd__() support: mtext += \(aqAppend additional text to the MText entity.\(aq .ft P .fi .UNINDENT .UNINDENT [image] .sp \fBIMPORTANT:\fP .INDENT 0.0 .INDENT 3.5 Line endings \fB\en\fP will be replaced by the MTEXT line endings \fB\eP\fP at DXF export, but \fBnot\fP vice versa \fB\eP\fP by \fB\en\fP 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. The \fBattachment_point\fP defines the text alignment relative to the \fBinsert\fP location, default value is \fB1\fP\&. .sp Attachment point constants defined in \fBezdxf.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: \fBset_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 .nf .ft C mtext.dxf.char_height = 0.5 .ft P .fi .UNINDENT .UNINDENT .sp The character height can be changed inline, see also \fI\%MText formatting\fP and mtext_inline_codes\&. .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 or OCS, if an OCS is defined. 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: \fBget_rotation()\fP returns the rotation angle in degrees independent from definition as angle or direction, and \fBset_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 \fB0\fP) the lines are wrapped only at the regular line endings \fB\eP\fP or \fB\en\fP, 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 .nf .ft C mtext.dxf.width = 60 .ft P .fi .UNINDENT .UNINDENT [image] .SS MText formatting .sp MText supports inline formatting by special codes: mtext_inline_codes .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C mtext.text = "{\e\eC1red text} \- {\e\eC3green text} \- {\e\eC5blue text}" .ft P .fi .UNINDENT .UNINDENT [image] .SS Stacked text .sp MText also supports stacked text: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # the space \(aq \(aq in front of \(aqLower\(aq anr the \(aq;\(aq behind \(aqLower\(aq are necessary # combined with vertical center alignment mtext.text = "\e\eA1\e\eSUpper^ Lower; \- \e\eSUpper/ Lower;} \- \e\eSUpper# Lower;" .ft P .fi .UNINDENT .UNINDENT [image] .sp Available helper function for text formatting: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBset_color()\fP \- append text color change .IP \(bu 2 \fBset_font()\fP \- append text font change .IP \(bu 2 \fBadd_stacked_text()\fP \- append stacked text .UNINDENT .UNINDENT .UNINDENT .SS Background color (filling) .sp The MText entity can have a background filling: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 ACI .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 .UNINDENT .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 .nf .ft C mtext.set_bg_color(2, scale=1.5) .ft P .fi .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 \fB1\fP \- \fB5\fP, where \fB1\fP fits exact the MText entity. [image] .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 goes through 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 .nf .ft C doc = ezdxf.new(\(aqR2000\(aq) fit_points = [(0, 0, 0), (750, 500, 0), (1750, 500, 0), (2250, 1250, 0)] msp = doc.modelspace() spline = msp.add_spline(fit_points) .ft P .fi .UNINDENT .UNINDENT [image] .sp Append a fit point to a spline: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # fit_points, control_points, knots and weights are list\-like containers: spline.fit_points.append((2250, 2500, 0)) .ft P .fi .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. .sp Solve problems of incorrect values after editing a spline generated by AutoCAD: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc = ezdxf.readfile("AutoCAD_generated.dxf") msp = doc.modelspace() spline = msp.query(\(aqSPLINE\(aq).first # fit_points, control_points, knots and weights are list\-like objects: spline.fit_points.append((2250, 2500, 0)) .ft P .fi .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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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 = [] .ft P .fi .UNINDENT .UNINDENT .SS Splines by control points .sp To create splines from fit points is the easiest way to create splines, 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 also) uses an proprietary algorithm to generate control points and knot values from fit points, which differs from the well documented \fI\%Global Curve Interpolation\fP\&. 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 \fBadd_spline_control_frame()\fP adds a spline trough fit points by calculating the control points by the \fI\%Global Curve Interpolation\fP algorithm. There is also a low level function \fBezdxf.math.global_bspline_interpolation()\fP which calculates the control points from fit points. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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}) .ft P .fi .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 \fBadd_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 .nf .ft C control_points = [(0, 0, 0), (1250, 1560, 0), (3130, 610, 0), (2250, 1250, 0)] msp.add_open_spline(control_points) .ft P .fi .UNINDENT .UNINDENT [image] .SS Closed Spline .sp A closed spline is continuous closed curve. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp.add_closed_spline(control_points) .ft P .fi .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 .nf .ft C msp.add_closed_rational_spline(control_points, weights=[3, 1, 1, 1]) .ft P .fi .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 .nf .ft C if spline.closed: # this spline is closed pass # close spline spline.closed = True # open spline spline.closed = False .ft P .fi .UNINDENT .UNINDENT .sp Set start\- and end tangent for splines defined by fit points: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C spline.dxf.start_tangent = (0, 1, 0) # in y\-axis spline.dxf.end_tangent = (1, 0, 0) # in x\-axis .ft P .fi .UNINDENT .UNINDENT .sp Get data count as stored in DXF file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C count = spline.dxf.n_fit_points count = spline.dxf.n_control_points count = spline.dxf.n_knots .ft P .fi .UNINDENT .UNINDENT .sp Get data count of real existing data: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C count = spline.fit_point_count count = spline.control_point_count count = spline.knot_count .ft P .fi .UNINDENT .UNINDENT .SS Tutorial for Polyface .sp coming soon … .SS Tutorial for Mesh .sp Create a cube mesh by direct access to base data structures: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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] ] doc = ezdxf.new(\(aqR2000\(aq) # MESH requires DXF R2000 or later msp = doc.modelspace() mesh = msp.add_mesh() mesh.dxf.subdivision_levels = 0 # do not subdivide cube, 0 is the default value with mesh.edit_data() as mesh_data: mesh_data.vertices = cube_vertices mesh_data.faces = cube_faces doc.saveas("cube_mesh_1.dxf") .ft P .fi .UNINDENT .UNINDENT .sp Create a cube mesh by method calls: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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), ] doc = ezdxf.new(\(aqR2000\(aq) # MESH requires DXF R2000 or later 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]]) mesh_data.optimize() # optional, minimizes vertex count doc.saveas("cube_mesh_2.dxf") .ft P .fi .UNINDENT .UNINDENT .SS Tutorial for Hatch .SS Create hatches with one boundary path .sp The simplest form of the \fBHatch\fP entity has one polyline path with only straight lines as boundary path: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf doc = ezdxf.new(\(aqR2000\(aq) # hatch requires the DXF R2000 (AC1015) format or later msp = doc.modelspace() # adding entities to the model space hatch = msp.add_hatch(color=2) # by default a solid fill hatch with fill color=7 (white/black) # every boundary path is always 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=1) doc.saveas("solid_hatch_polyline_path.dxf") .ft P .fi .UNINDENT .UNINDENT .sp But like all polyline entities the polyline path can also have bulge values: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf doc = ezdxf.new(\(aqR2000\(aq) # hatch requires the DXF R2000 (AC1015) format or later msp = doc.modelspace() # adding entities to the model space hatch = msp.add_hatch(color=2) # by default a solid fill hatch with fill color=7 (white/black) # every boundary path is always 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=1) doc.saveas("solid_hatch_polyline_path_with_bulge.dxf") .ft P .fi .UNINDENT .UNINDENT .sp The most flexible way to define a boundary path is the edge path. An edge path consist of a number of 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 .nf .ft C import ezdxf doc = ezdxf.new(\(aqR2000\(aq) # hatch requires the DXF R2000 (AC1015) format or later msp = doc.modelspace() # adding entities to the model space # 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 always 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("solid_hatch_ellipse.dxf") .ft P .fi .UNINDENT .UNINDENT .SS Create hatches with multiple boundary paths (islands) .sp The DXF atribute \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 .nf .ft C hatch = msp.add_hatch(color=1, dxfattribs={ \(aqhatch_style\(aq: 0, # 0 = nested # 1 = outer # 2 = 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=1, flags=1) .ft P .fi .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 .nf .ft C # The second path has to set flag: 16 = outermost hatch.paths.add_polyline_path([(1, 1), (9, 1), (9, 9), (1, 9)], is_closed=1, flags=16) .ft P .fi .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 .nf .ft C # The third path has to set flag: 0 = default hatch.paths.add_polyline_path([(2, 2), (8, 2), (8, 8), (2, 8)], is_closed=1, flags=0) .ft P .fi .UNINDENT .UNINDENT [image] .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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=1, flags=0) .ft P .fi .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 .nf .ft C hatch = msp.add_hatch(color=1) # 1. polyline path hatch.paths.add_polyline_path([ (240, 210, 0), (0, 210, 0), (0, 0, 0.), (240, 0, 0), ], is_closed=1, flags=1, ) # 2. edge path edge_path = hatch.paths.add_edge_path(flags=16) 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) ) .ft P .fi .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 .nf .ft C # Create base geometry lwpolyline = msp.add_lwpolyline( [(0, 0, 0), (10, 0, .5), (10, 10, 0), (0, 10, 0)], format=\(aqxyb\(aq, dxfattribs={\(aqclosed\(aq: True}, ) hatch = msp.add_hatch(color=1) path = hatch.paths.add_polyline_path( # get path vertices from associated LWPOLYLINE entity lwpolyline.get_points(format=\(aqxyb\(aq), # get closed state also from associated LWPOLYLINE entity is_closed=lwpolyline.closed, ) # Set association between boundary path and LWPOLYLINE hatch.associate(path, [lwpolyline]) .ft P .fi .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 .nf .ft C hatch.set_pattern_fill(\(aqANSI31\(aq, scale=0.5) .ft P .fi .UNINDENT .UNINDENT [image] .SS Create hatches with gradient fill .sp TODO .SS Tutorial for Hatch Pattern Definition .sp TODO .SS Tutorial for Image and ImageDef .sp Insert a raster image into a DXF drawing, the raster image is NOT embedded into the DXF file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf doc = ezdxf.new(\(aqAC1015\(aq) # image requires the DXF R2000 format or later my_image_def = doc.add_image_def(filename=\(aqmycat.jpg\(aq, size_in_pixel=(640, 360)) # The IMAGEDEF entity is like a block definition, it just defines the image msp = doc.modelspace() # add first image msp.add_image(insert=(2, 1), size_in_units=(6.4, 3.6), image_def=my_image_def, rotation=0) # The IMAGE entity is like the INSERT entity, it creates an image reference, # and there can be multiple references to the same picture in a drawing. msp.add_image(insert=(4, 5), size_in_units=(3.2, 1.8), image_def=my_image_def, rotation=30) # get existing image definitions, Important: IMAGEDEFs resides in the objects section image_defs = doc.objects.query(\(aqIMAGEDEF\(aq) # get all image defs in drawing doc.saveas("dxf_with_cat.dxf") .ft P .fi .UNINDENT .UNINDENT .SS Tutorial for Underlay and UnderlayDefinition .sp Insert a PDF, DWF, DWFx or DGN file as drawing underlay, the underlay file is NOT embedded into the DXF file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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("dxf_with_underlay.dxf") .ft P .fi .UNINDENT .UNINDENT .SS Tutorial for Linetypes .sp Simple line type example: [image] .sp You can define your own line types. A DXF linetype definition consists of name, description and elements: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C elements = [total_pattern_length, elem1, elem2, ...] .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .TP .B total_pattern_length Sum of all linetype elements (absolute vaues) .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 .nf .ft C import ezdxf from ezdxf.tools.standards import linetypes # some predefined line types doc = ezdxf.new() msp = modelspace() my_line_types = [ ("DOTTED", "Dotted . . . . . . . . . . . . . . . .", [0.2, 0.0, \-0.2]), ("DOTTEDX2", "Dotted (2x) . . . . . . . . ", [0.4, 0.0, \-0.4]), ("DOTTED2", "Dotted (.5) . . . . . . . . . . . . . . . . . . . ", [0.1, 0.0, \-0.1]), ] for name, desc, pattern in my_line_types: if name not in doc.linetypes: doc.linetypes.new(name=name, dxfattribs={\(aqdescription\(aq: desc, \(aqpattern\(aq: pattern}) .ft P .fi .UNINDENT .UNINDENT .sp Setup some predefined linetypes: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C for name, desc, pattern in linetypes(): if name not in doc.linetypes: doc.linetypes.new(name=name, dxfattribs={\(aqdescription\(aq: desc, \(aqpattern\(aq: pattern}) .ft P .fi .UNINDENT .UNINDENT .SS Check Available Linetypes .sp The linetypes object supports some standard Python protocols: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # iteration print(\(aqavailable line types:\(aq) for linetype in doc.linetypes: print(\(aq{}: {}\(aq.format(linetype.dxf.name, linetype.dxf.description)) # check for existing line type if \(aqDOTTED\(aq in doc.linetypes: pass count = len(doc.linetypes) # total count of linetypes .ft P .fi .UNINDENT .UNINDENT .SS Removing Linetypes .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Deleting of linetypes still in use generates invalid DXF files. .UNINDENT .UNINDENT .sp You can delete a linetype: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.layers.remove(\(aqDASHED\(aq) .ft P .fi .UNINDENT .UNINDENT .sp This just deletes the linetype definition, all DXF entity with the DXF attribute linetype set to \fBDASHED\fP still refers to linetype \fBDASHED\fP and AutoCAD will not open DXF files with undefined line types. .SS Tutorial for Complex Linetypes .sp In DXF R13 Autodesk introduced complex line types, containing TEXT or SHAPES in line types. \fIezdxf\fP v0.8.4 and later supports complex line types. .sp Complex line type example with text: [image] .sp Complex line type example with shapes: [image] .sp For simplicity 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 .nf .ft C doc = ezdxf.new(\(aqR2018\(aq) # DXF R13 or later is required doc.linetypes.new(\(aqGASLEITUNG2\(aq, dxfattribs={ \(aqdescription\(aq: \(aqGasleitung2 \-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\(aq, \(aqlength\(aq: 1, # required for complex line types # line type definition in acadlt.lin: \(aqpattern\(aq: \(aqA,.5,\-.2,["GAS",STANDARD,S=.1,U=0.0,X=\-0.1,Y=\-.05],\-.25\(aq, }) .ft P .fi .UNINDENT .UNINDENT .sp The pattern always starts with an \fBA\fP, the following float values have the same meaning as for simple line types, a value > 0 is a line, a value < 0 is a gap, and a 0 is a point, the \fB[\fP starts the complex part of the line pattern. A following text in quotes defines a TEXT type, a following text without quotes defines a SHAPE type, in .lin files the shape type is a shape name, but ezdxf can not translate this name into the required shape file index, so \fIYOU\fP have to translate this name into the shape file index (e.g. saving the file with AutoCAD as DXF and searching for the line type definition, see also DXF Internals: ltype_table_internals). .sp The second parameter is the text style for a TEXT type and the shape file name for the SHAPE type, the shape file has to be in the same directory as the DXF file. The following parameters in the scheme of \fBS=1.0\fP are: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 S … scaling factor, always > 0, if S=0 the TEXT or SHAPE is not visible .IP \(bu 2 R or U … rotation relative to the line direction .IP \(bu 2 X … x direction offset (along the line) .IP \(bu 2 Y … y direction offset (perpendicular to the line) .UNINDENT .UNINDENT .UNINDENT .sp The parameters are case insensitive. \fB]\fP ends the complex part of the line pattern. .sp The fine tuning of this parameters is still a try an error process for me, for TEXT the scaling factor (STANDARD text style) sets the text height (S=.1 the text is .1 units in height), by shifting in y direction by half of the scaling factor, the center of the text is on 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 .nf .ft C doc.linetypes.new(\(aqGRENZE2\(aq, dxfattribs={ \(aqdescription\(aq: \(aqGrenze eckig \-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\-\(aq, \(aqlength\(aq: 1.45, # required for complex line types # line type definition in acadlt.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 \(aqpattern\(aq: \(aqA,.25,\-.1,[132,ltypeshp.shx,x=\-.1,s=.1],\-.1,1\(aq, }) .ft P .fi .UNINDENT .UNINDENT .sp Complex line types with shapes only work if the associated shape file (ltypeshp.shx) and the DXF file are in the same directory. .SS Tutorial for OCS/UCS Usage .sp For OCS/UCS usage is a basic understanding of vectors required, for a brush up, watch the YouTube tutorials of \fI\%3Blue1Brown\fP about \fI\%Linear Algebra\fP\&. .sp Second read the Coordinate Systems introduction please. .sp For WCS 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 OCS 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 WCS\&. But there are some entities like \fBEllipse\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 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: \fBLWPolyline\fP and \fBHatch\fP have an DXF attribute \fBelevation\fP, where the z\-axis of this point is the elevation height and the x\-axis = y\-axis = \fB0\fP\&. .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: tut_ucs_transform .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 for 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 .nf .ft C 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}) .ft P .fi .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 OCS and 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 \fBUCS\fP class in this example to place a 2D pentagon in 3D space. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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 = [Vector.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 dxfattribs={ \(aqelevation\(aq: elevation, \(aqextrusion\(aq: ucs.uz, \(aqclosed\(aq: True, \(aqcolor\(aq: 1, }) .ft P .fi .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 show the same direction (extrusion direction), and the x\-axis of the UCS and the WCS show 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 UCS, OCS and 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 \fBPolyline\fP to create the 3D pentagon. The \fBUCS\fP class is handy for this example and all kind of 3D operations. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Using an UCS simplifies 3D operations, but UCS definition can happen later # calculating corner points in local (UCS) coordinates without Vector 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, dxfattribs={ \(aqclosed\(aq: True, \(aqcolor\(aq: 1, }) # 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}) .ft P .fi .UNINDENT .UNINDENT [image: 3d poyline with UCS] [image] .SS Placing 2D Text in 3D Space .sp The problem by placing text in 3D space is the text rotation, which is always counter clockwise around the OCS z\-axis, and \fB0\fP degree is in direction of the positive OCS x\-axis, and the OCS x\-axis is calculated by the Arbitrary Axis Algorithm\&. .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 \fBUCS.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 .nf .ft C # 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 = Vector.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="TEXT", 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) .ft P .fi .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 OCS, and this example also shows a shortcut for calculating the OCS angles. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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(Vector.from_deg_angle(45)), dxfattribs={\(aqcolor\(aq: 1}, ) msp.add_line( start=center, end=ucs.to_wcs(Vector.from_deg_angle(270)), dxfattribs={\(aqcolor\(aq: 1}, ) .ft P .fi .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 (\fBInsert\fP) can contain true 3D entities like \fBLine\fP or \fBMesh\fP, the \fBInsert\fP entity uses the same placing principe as \fBText\fP or \fBArc\fP shown in the previous chapters. .sp Simple placing by OCS and rotation about the z\-axis, can be achieved the same way as for generic 2D entity types. 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 .nf .ft C # rotate UCS around an arbitrary axis: def ucs_rotation(ucs: UCS, axis: Vector, 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, }) .ft P .fi .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 .nf .ft C # 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 = Vector(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, }) .ft P .fi .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 .nf .ft C # translate a block references with an established OCS translation = Vector(\-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) .ft P .fi .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 .nf .ft C # 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)) .ft P .fi .UNINDENT .UNINDENT .sp Build transformation matrix and transform extrusion vector and build new UCS: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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) .ft P .fi .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 .nf .ft C # 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) .ft P .fi .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 With \fIezdxf\fP v0.11 a new feature for entity transformation was introduced, which makes working with OCS/UCS much easier, this is a new edition of the older tut_ocs\&. For the basic information read the old tutorial please. In \fIezdxf\fP v0.13 the \fBtransform_to_wcs()\fP interface was replaced by the general transformation interface: \fBtransform()\fP\&. .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 .nf .ft C 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) .ft P .fi .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 .nf .ft C # 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=(Vector.from_deg_angle((360 / 5) * n) for n in range(5)), format=\(aqxy\(aq, # ignore z\-axis dxfattribs={ \(aqclosed\(aq: True, \(aqcolor\(aq: 1, } ).transform(ucs.matrix) .ft P .fi .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 .nf .ft C # using an UCS simplifies 3D operations, but UCS definition can happen later # calculating corner points in local (UCS) coordinates without Vector 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, dxfattribs={ \(aqclosed\(aq: True, \(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) .ft P .fi .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 (or better it is hidden in \fBtransform()\fP) 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 .nf .ft C # 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="TEXT", 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) .ft P .fi .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 .nf .ft C 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=Vector.from_deg_angle(START_ANGLE), dxfattribs={\(aqcolor\(aq: 6}, ).transform(ucs.matrix) msp.add_line( start=CENTER, end=Vector.from_deg_angle(END_ANGLE), dxfattribs={\(aqcolor\(aq: 6}, ).transform(ucs.matrix) .ft P .fi .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 chapters. .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 .nf .ft C 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) .ft P .fi .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. Following example rotates the block reference around the block x\-axis by 15 degrees: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .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 .nf .ft C # 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) .ft P .fi .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 .nf .ft C # 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)) .ft P .fi .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 .nf .ft C # 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) .ft P .fi .UNINDENT .UNINDENT [image] [image] .SS Tutorial for Linear Dimensions .sp The \fBDimension\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 basic DXF entities like LINE and TEXT entities, this representation is called the dimension line \fIrendering\fP in this documentation, beside the fact 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 was not possible to implement all the various combinations of dimension style parameters. .sp Text rendering is another problem, because \fIezdxf\fP has no real rendering engine. Some font properties, like the real text width, are not available to \fIezdxf\fP and may also vary slightly for different CAD applications. The text properties in \fIezdxf\fP are based on the default monospaced standard font, but for TrueType fonts the space around the text is much bigger than needed. .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 are displayed like linetypes, but they disappear if the dimension line is edited in the 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 MTEXT 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: dimstyle_table_internals .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 \fI\%dimension_linear.py\fP for linear dimension examples. .UNINDENT .UNINDENT .UNINDENT .SS Horizontal Dimension .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf # Argument setup=True setups the default dimension styles doc = ezdxf.new(\(aqR2010\(aq, setup=True) # Add new dimension entities to the modelspace msp = doc.modelspace() # Add a LINE entity, not required msp.add_line((0, 0), (3, 0)) # Add a horizontal dimension, default dimension style is \(aqEZDXF\(aq dim = msp.add_linear_dim(base=(3, 2), p1=(0, 0), p2=(3, 0)) # Necessary second step, to create the BLOCK entity with the dimension geometry. # Additional processing of the dimension line could happen between adding and # rendering call. dim.render() doc.saveas(\(aqdim_linear_horiz.dxf\(aq) .ft P .fi .UNINDENT .UNINDENT [image] .sp The example above creates a horizontal \fBDimension\fP entity, the default dimension style \fB\(aqEZDXF\(aq\fP and is defined as 1 drawing unit is 1m in reality, the drawing scale 1:100 and the length factor is 100, which creates a measurement text in cm. .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 \fBDimStyleOverride\fP object is returned, the dimension entity is stored as \fIdim.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 .nf .ft C # 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(\(aqdim_linear_rotated.dxf\(aq) .ft P .fi .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 .nf .ft C msp.add_line((0, 2), (3, 0)) dim = msp.add_aligned_dim(p1=(0, 2), p2=(3, 0), distance=1) doc.saveas(\(aqdim_linear_aligned.dxf\(aq) .ft P .fi .UNINDENT .UNINDENT [image] .SS Dimension Style Override .sp Many dimension styling options are defined by the associated \fBDimStyle\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 = {\(aqdimtad\(aq: 4}\fP, place measurement text below dimension line). .sp The overriding protocol is managed by the \fBDimStyleOverride\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 \fBDimStyle\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 \fBdimjust\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 .nf .ft C msp.add_linear_dim(base=(3, 2), p1=(0, 0), p2=(3, 0), override={\(aqdimjust\(aq: 1}).render() .ft P .fi .UNINDENT .UNINDENT [image] .sp The \fB“vertical”\fP location of the measurement text relative to the dimension line is defined by \fBdimtad\fP: .TS center; |l|l|. _ T{ 0 T} T{ Center, it is possible to adjust the vertical location by \fBdimtvp\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 .nf .ft C msp.add_linear_dim(base=(3, 2), p1=(0, 0), p2=(3, 0), override={\(aqdimtad\(aq: 4}).render() .ft P .fi .UNINDENT .UNINDENT [image] .sp The distance between text and dimension line is defined by \fBdimgap\fP\&. .sp The \fBDimStyleOverride\fP object has a method \fBset_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 .nf .ft C dim = msp.add_linear_dim(base=(3, 2), p1=(0, 0), p2=(3, 0)) dim.set_text_align(halign=\(aqleft\(aq, valign=\(aqcenter\(aq) dim.render() .ft P .fi .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ halign T} T{ \fB\(aqleft\(aq\fP, \fB\(aqright\(aq\fP, \fB\(aqcenter\(aq\fP, \fB\(aqabove1\(aq\fP, \fB\(aqabove2\(aq\fP T} _ T{ valign T} T{ \fB\(aqabove\(aq\fP, \fB\(aqcenter\(aq\fP, \fB\(aqbelow\(aq\fP 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 .nf .ft C msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0), location=(4, 4)).render() .ft P .fi .UNINDENT .UNINDENT [image] .sp The \fIlocation\fP is relative to origin of the active coordinate system or WCS if no UCS is defined in the \fBrender()\fP method, the user defined \fIlocation\fP can also be set by \fBuser_location_override()\fP\&. .SS Location Relative to Center of Dimension Line .sp The method \fBset_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 .nf .ft C 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() .ft P .fi .UNINDENT .UNINDENT [image] .SS Location Relative to Default Location .sp The method \fBshift_text()\fP shifts the measurement text away from the default text location. 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 .nf .ft C dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.shift_text(dh=1, dv=1) dim.render() .ft P .fi .UNINDENT .UNINDENT [image] .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 \fBTextstyle\fP name. T} _ T{ \fBdimtxt\fP T} T{ Text height in drawing units. T} _ T{ \fBdimclrt\fP T} T{ Measurement text color as ACI\&. T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(aqdimtxsty\(aq: \(aqStandard\(aq, \(aqdimtxt\(aq: 0.35, \(aqdimclrt\(aq: 1, }).render() .ft P .fi .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. .sp Set \fBdimtfill\fP to \fB1\fP to use the canvas color as background filling or set \fBdimtfill\fP to \fB2\fP to use \fBdimtfillclr\fP as background filling, color value as ACI\&. Set \fBdimtfill\fP to \fB0\fP to disable background filling. .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimtfill\fP T} T{ Enables background filling if bigger than \fB0\fP T} _ T{ \fBdimtfillclr\fP T} T{ Fill color as ACI, if \fBdimtfill\fP is \fB2\fP T} _ .TE .TS center; |l|l|. _ T{ \fBdimtfill\fP T} T{ Description T} _ T{ \fB0\fP T} T{ disabled T} _ T{ \fB1\fP T} T{ canvas color T} _ T{ \fB2\fP T} T{ color defined by \fBdimtfillclr\fP T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(aqdimtfill\(aq: 2, \(aqdimtfillclr\(aq: 1, }).render() .ft P .fi .UNINDENT .UNINDENT [image] .SS Text Formatting .INDENT 0.0 .IP \(bu 2 Set decimal places: \fBdimdec\fP defines the number of decimal places displayed for the primary units of a dimension. (DXF R2000) .IP \(bu 2 Set decimal point character: \fBdimdsep\fP defines the decimal point as ASCII code, use \fBord(\(aq.\(aq)\fP .IP \(bu 2 Set rounding: \fBdimrnd\fP, rounds all dimensioning distances to the specified value, for instance, if \fBdimrnd\fP is set to \fB0.25\fP, all distances round to the nearest 0.25 unit. If \fBdimrnd\fP is set to \fB1.0\fP, all distances round to the nearest integer. For more information look at the documentation of the \fBezdxf.math.xround()\fP function. .IP \(bu 2 Set zero trimming: \fBdimzin\fP, \fIezdxf\fP supports only: \fB4\fP suppress leading zeros and \fB8\fP: suppress trailing zeros and both as \fB12\fP\&. .IP \(bu 2 Set measurement factor: scale measurement by factor \fBdimlfac\fP, e.g. to get the dimensioning text in cm for a DXF file where 1 drawing unit represents 1m, set \fBdimlfac\fP to \fB100\fP\&. .IP \(bu 2 Text template for measurement text is defined by \fBdimpost\fP, \fB\(aq<>\(aq\fP represents the measurement text, e.g. \fB\(aq~<>cm\(aq\fP produces \fB\(aq~300cm\(aq\fP for measurement in previous example. .UNINDENT .sp To set this values the \fBezdxf.entities.DimStyle.set_text_format()\fP and \fBezdxf.entities.DimStyleOverride.set_text_format()\fP methods are very recommended. .SS Overriding Measurement Text .sp Measurement text overriding is stored in the \fBDimension\fP entity, the content of to DXF attribute \fBtext\fP represents the override value as string. Special values are one space \fB\(aq \(aq\fP to just suppress the measurement text, an empty string \fB\(aq\(aq\fP or \fB\(aq<>\(aq\fP to get the regular 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 .nf .ft C msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0), text=\(aq>1m\(aq).render() .ft P .fi .UNINDENT .UNINDENT [image] .SS Dimension Line Properties .sp The dimension line color is defined by the DIMVAR \fBdimclrd\fP as ACI, \fBdimclrd\fP also defines the color of the arrows. The linetype is defined by \fBdimltype\fP but requires DXF R2007 for full support by CAD Applications and the line weight is defined by \fBdimlwd\fP (DXF R2000), see also the \fBlineweight\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 ACI 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 .nf .ft C msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(aqdimclrd\(aq: 1, # red \(aqdimdle\(aq: 0.25, \(aqdimltype\(aq: \(aqDASHED2\(aq, \(aqdimlwd\(aq: 35, # 0.35mm line weight }).render() .ft P .fi .UNINDENT .UNINDENT [image] .sp \fBDimStyleOverride()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_dimline_format(color=1, linetype=\(aqDASHED2\(aq, lineweight=35, extension=0.25) dim.render() .ft P .fi .UNINDENT .UNINDENT .SS Extension Line Properties .sp The extension line color is defined by the DIMVAR \fBdimclre\fP as ACI\&. The linetype for first and second extension line is defined by \fBdimltex1\fP and \fBdimltex2\fP but requires DXF R2007 for full support by CAD Applications and the line weight is defined by \fBdimlwe\fP (DXF R2000), see also the \fBlineweight\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 ACI 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 \fB1\fP 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 \fB1\fP T} _ T{ \fBdimse2\fP T} T{ suppress second extension line if \fB1\fP T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(aqdimclre\(aq: 1, # red \(aqdimltex1\(aq: \(aqDASHED2\(aq, \(aqdimltex2\(aq: \(aqCENTER2\(aq, \(aqdimlwe\(aq: 35, # 0.35mm line weight \(aqdimexe\(aq: 0.3, # length above dimension line \(aqdimexo\(aq: 0.1, # offset from measurement point }).render() .ft P .fi .UNINDENT .UNINDENT [image] .sp \fBDimStyleOverride()\fP methods: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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=\(aqDASHED2\(aq) dim.set_extline2(linetype=\(aqCENTER2\(aq) dim.render() .ft P .fi .UNINDENT .UNINDENT .sp Fixed length extension lines are supported in DXF R2007+, set \fBdimfxlon\fP to \fB1\fP and \fBdimfxl\fP defines the length of the extension line starting at the dimension line. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(aqdimfxlon\(aq: 1, # fixed length extension lines \(aqdimexe\(aq: 0.2, # length above dimension line \(aqdimfxl\(aq: 0.4, # length below dimension line }).render() .ft P .fi .UNINDENT .UNINDENT [image] .sp \fBDimStyleOverride()\fP method: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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() .ft P .fi .UNINDENT .UNINDENT .sp To suppress extension lines set \fBdimse1\fP = \fB1\fP to suppress the first extension line and \fBdimse2\fP = \fB1\fP to suppress the second extension line. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(aqdimse1\(aq: 1, # suppress first extension line \(aqdimse2\(aq: 1, # suppress second extension line \(aqdimblk\(aq: ezdxf.ARROWS.closed_filled, # arrows just looks better }).render() .ft P .fi .UNINDENT .UNINDENT [image] .sp \fBDimStyleOverride()\fP methods: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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() .ft P .fi .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 and arrows as blocks. .sp Using the simple tick by setting tick size \fBdimtsz\fP != \fB0\fP also disables arrow blocks as side effect: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_tick(size=0.25) dim.render() .ft P .fi .UNINDENT .UNINDENT .sp \fIezdxf\fP uses the \fB"ARCHTICK"\fP 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 .nf .ft C dim = msp.add_linear_dim(base=(3, 2), p1=(3, 0), p2=(6, 0)) dim.set_arrow(blk="OPEN_30", size=0.25) dim.render() .ft P .fi .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimtsz\fP T} T{ tick size in drawing units, set to \fB0\fP 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 .nf .ft C msp.add_linear_dim( base=(3, 2), p1=(3, 0), p2=(6, 0), override={ \(aqdimtsz\(aq: 0, # set tick size to 0 to enable arrow usage \(aqdimasz\(aq: 0.25, # arrow size in drawing units \(aqdimblk\(aq: "OPEN_30", # arrow block name }).render() .ft P .fi .UNINDENT .UNINDENT .sp Dimension line extension (\fBdimdle\fP) works only for a few arrow blocks and the simple tick: .INDENT 0.0 .IP \(bu 2 \fB"ARCHTICK"\fP .IP \(bu 2 \fB"OBLIQUE"\fP .IP \(bu 2 \fB"NONE"\fP .IP \(bu 2 \fB"SMALL"\fP .IP \(bu 2 \fB"DOTSMALL"\fP .IP \(bu 2 \fB"INTEGRAL"\fP .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{ \fB""\fP (empty string) T} _ T{ dot T} T{ \fB"DOT"\fP T} _ T{ dot_small T} T{ \fB"DOTSMALL"\fP T} _ T{ dot_blank T} T{ \fB"DOTBLANK"\fP T} _ T{ origin_indicator T} T{ \fB"ORIGIN"\fP T} _ T{ origin_indicator_2 T} T{ \fB"ORIGIN2"\fP T} _ T{ open T} T{ \fB"OPEN"\fP T} _ T{ right_angle T} T{ \fB"OPEN90"\fP T} _ T{ open_30 T} T{ \fB"OPEN30"\fP T} _ T{ closed T} T{ \fB"CLOSED"\fP T} _ T{ dot_smallblank T} T{ \fB"SMALL"\fP T} _ T{ none T} T{ \fB"NONE"\fP T} _ T{ oblique T} T{ \fB"OBLIQUE"\fP T} _ T{ box_filled T} T{ \fB"BOXFILLED"\fP T} _ T{ box T} T{ \fB"BOXBLANK"\fP T} _ T{ closed_blank T} T{ \fB"CLOSEDBLANK"\fP T} _ T{ datum_triangle_filled T} T{ \fB"DATUMFILLED"\fP T} _ T{ datum_triangle T} T{ \fB"DATUMBLANK"\fP T} _ T{ integral T} T{ \fB"INTEGRAL"\fP T} _ T{ architectural_tick T} T{ \fB"ARCHTICK"\fP T} _ T{ ez_arrow T} T{ \fB"EZ_ARROW"\fP T} _ T{ ez_arrow_blank T} T{ \fB"EZ_ARROW_BLANK"\fP T} _ T{ ez_arrow_filled T} T{ \fB"EZ_ARROW_FILLED"\fP T} _ .TE .SS Tolerances and Limits .sp The tolerances ans limits features are implemented by using the \fBMText\fP entity, therefore DXF R2000+ is required to use these features. 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 \fBset_tolerance()\fP method in \fBDimStyleOverride\fP or \fBDimStyle\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 .nf .ft C dim = msp.add_linear_dim(base=(0, 3), p1=(3, 0), p2=(6.5, 0)) dim.set_tolerance(.1, hfactor=.4, align="top", dec=2) dim.render() .ft P .fi .UNINDENT .UNINDENT [image] .sp Different upper and lower tolerance values: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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="middle", dec=2) dim.render() .ft P .fi .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 \fB1.0\fP, the text height of fractions and tolerances is the same height as the dimension text. If \fBdimtxt\fP is set to \fB0.75\fP, 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{ \fB0\fP T} T{ Align with bottom line of dimension text T} _ T{ \fB1\fP T} T{ Align vertical centered to dimension text T} _ T{ \fB2\fP 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 \fB1\fP 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{ \fB4\fP to suppress leading zeros, \fB8\fP to suppress trailing zeros or \fB12\fP 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 \fBset_limits()\fP method in \fBDimStyleOverride\fP or \fBDimStyle\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 .nf .ft C 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() .ft P .fi .UNINDENT .UNINDENT [image] .TS center; |l|l|. _ T{ DIMVAR T} T{ Description T} _ T{ \fBdimlim\fP T} T{ set to \fB1\fP to enable limits T} _ .TE .SS Alternative Units .sp Alternative units are not supported. .SS Tutorial for Radius Dimensions .sp Please read the tut_linear_dimension before, if you haven’t. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf # DXF R2010 drawing, official DXF version name: \(aqAC1024\(aq, # setup=True setups the default dimension styles doc = ezdxf.new(\(aqR2010\(aq, 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=\(aqEZ_RADIUS\(aq) # necessary second step, to create the BLOCK entity with the dimension geometry. dim.render() doc.saveas(\(aqradius_dimension.dxf\(aq) .ft P .fi .UNINDENT .UNINDENT .sp The example above creates a 45 degrees slanted radius \fBDimension\fP entity, the default dimension style \fB\(aqEZ_RADIUS\(aq\fP is defined as 1 drawing unit is 1m in reality, drawing scale 1:100 and the length factor is 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 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 \fBDimStyleOverride\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 DIMSTYLE \fB\(aqEZ_RADIUS\(aq\fP settings are: 1 drawing unit is 1m, scale 1:100, length_factor is 100 which creates measurement text in cm, and a closed filled arrow with size 0.25 is used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Not all possibles features of DIMSTYLE are supported and especially for radial dimension there are less features supported as for 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: dimstyle_table_internals .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 \fI\%dimension_radius.py\fP for radius dimension examples. .UNINDENT .UNINDENT .UNINDENT .SS Default Text Locations Outside .sp \fB\(aqEZ_RADIUS\(aq\fP default settings for to place text outside: .TS center; |l|l|. _ T{ tmove T} T{ \fB1\fP to keep dim line with text, this is the best setting for text outside to preserve appearance of the DIMENSION entity, if editing afterwards in BricsCAD or AutoCAD. T} _ T{ dimtad T} T{ \fB1\fP to place text vertical above the dimension line T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS\(aq ) dim.render() # required, but not shown in the following examples .ft P .fi .UNINDENT .UNINDENT [image] .sp To force text outside horizontal set \fBdimtoh\fP to \fB1\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS\(aq, override={\(aqdimtoh\(aq: 1} ) .ft P .fi .UNINDENT .UNINDENT [image] .SS Default Text Locations Inside .sp DIMSTYLE \fB\(aqEZ_RADIUS_INSIDE\(aq\fP can be used to place the dimension text inside the circle at a default location. Default DIMSTYLE settings are: 1 drawing unit is 1m, scale 1:100, length_factor is 100 which creates measurement text in cm, and a closed filled arrow with size 0.25 is used. .sp \fB\(aqEZ_RADIUS_INSIDE\(aq\fP default settings: .TS center; |l|l|. _ T{ tmove T} T{ \fB0\fP to keep dim line with text, this is the best setting for text inside to preserve appearance of the DIMENSION entity, if editing afterwards in BricsCAD or AutoCAD. T} _ T{ dimtix T} T{ \fB1\fP to force text inside T} _ T{ dimatfit T} T{ \fB0\fP to force text inside, required by BricsCAD and AutoCAD T} _ T{ dimtad T} T{ \fB0\fP to center text vertical, BricsCAD and AutoCAD always create 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 .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS_INSIDE\(aq ) .ft P .fi .UNINDENT .UNINDENT [image] [image] .sp To force text inside horizontal set \fBdimtih\fP to \fB1\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS_INSIDE\(aq, override={\(aqdimtih\(aq: 1} ) .ft P .fi .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 \fB\(aqEZ_RADIUS\(aq\fP can be used for all this examples. .sp User defined location outside of the circle: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, location=(4, 4), dimstyle=\(aqEZ_RADIUS\(aq ) .ft P .fi .UNINDENT .UNINDENT [image] .sp User defined location outside of the circle and forced horizontal text: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, location=(4, 4), dimstyle=\(aqEZ_RADIUS\(aq, override={\(aqdimtoh\(aq: 1} ) .ft P .fi .UNINDENT .UNINDENT [image] .sp User defined location inside of the circle: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, location=(1, 1), dimstyle=\(aqEZ_RADIUS\(aq ) .ft P .fi .UNINDENT .UNINDENT [image] [image] .sp User defined location inside of the circle and forced horizontal text: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, location=(1, 1), dimstyle=\(aqEZ_RADIUS\(aq, override={\(aqdimtih\(aq: 1}, ) .ft P .fi .UNINDENT .UNINDENT [image] .SS Center Mark/Lines .sp Center mark/lines are controlled by \fBdimcen\fP, default value is \fB0\fP for predefined dimstyles \fB\(aqEZ_RADIUS\(aq\fP and \fB\(aqEZ_RADIUS_INSIDE\(aq\fP : .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 .nf .ft C dim = msp.add_radius_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS\(aq, override={\(aqdimcen\(aq: 0.25}, ) .ft P .fi .UNINDENT .UNINDENT [image] .SS Overriding Measurement Text .sp See Linear Dimension Tutorial: tut_overriding_measurement_text .SS Measurement Text Formatting and Styling .sp See Linear Dimension Tutorial: tut_measurement_text_formatting_and_styling .SS Tutorial for Diameter Dimensions .sp Please read the tut_radius_dimension before, if you haven’t. .sp This is a repetition of the radius tutorial, just with diameter dimensions. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import ezdxf # setup=True setups the default dimension styles doc = ezdxf.new(\(aqR2010\(aq, 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=\(aqEZ_RADIUS\(aq) dim.render() doc.saveas(\(aqdiameter_dimension.dxf\(aq) .ft P .fi .UNINDENT .UNINDENT .sp The example above creates a 45 degrees slanted diameter \fBDimension\fP entity, the default dimension style \fB\(aqEZ_RADIUS\(aq\fP (same as for radius dimensions) is defined as 1 drawing unit is 1m in reality, drawing scale 1:100 and the length factor is 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 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 \fBDimStyleOverride\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 DIMSTYLE \fB\(aqEZ_RADIUS\(aq\fP settings are: 1 drawing unit is 1m, scale 1:100, length_factor is 100 which creates measurement text in cm, and a closed filled arrow with size 0.25 is used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Not all possibles features of DIMSTYLE are supported and especially for diameter dimension there are less features supported as for 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: dimstyle_table_internals .IP \(bu 2 Source code file \fI\%standards.py\fP shows how to create your own DIMSTYLES. .IP \(bu 2 \fI\%dimension_diameter.py\fP for diameter dimension examples. .UNINDENT .UNINDENT .UNINDENT .SS Default Text Locations Outside .sp \fB\(aqEZ_RADIUS\(aq\fP default settings for to place text outside: .TS center; |l|l|. _ T{ tmove T} T{ \fB1\fP to keep dim line with text, this is the best setting for text outside to preserve appearance of the DIMENSION entity, if editing afterwards in BricsCAD or AutoCAD. T} _ T{ dimtad T} T{ \fB1\fP to place text vertical above the dimension line T} _ .TE .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_diameter_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS\(aq) dim.render() # required, but not shown in the following examples .ft P .fi .UNINDENT .UNINDENT [image] .sp To force text outside horizontal set \fBdimtoh\fP to \fB1\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_diameter_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS\(aq, override={\(aqdimtoh\(aq: 1} ) .ft P .fi .UNINDENT .UNINDENT [image] .SS Default Text Locations Inside .sp DIMSTYLE \fB\(aqEZ_RADIUS_INSIDE\(aq\fP can be used to place the dimension text inside the circle at a default location. Default DIMSTYLE settings are: 1 drawing unit is 1m, scale 1:100, length_factor is 100 which creates measurement text in cm, and a closed filled arrow with size 0.25 is used. .sp \fB\(aqEZ_RADIUS_INSIDE\(aq\fP default settings: .TS center; |l|l|. _ T{ tmove T} T{ \fB0\fP to keep dim line with text, this is the best setting for text inside to preserve appearance of the DIMENSION entity, if editing afterwards in BricsCAD or AutoCAD. T} _ T{ dimtix T} T{ \fB1\fP to force text inside T} _ T{ dimatfit T} T{ \fB0\fP to force text inside, required by BricsCAD and AutoCAD T} _ T{ dimtad T} T{ \fB0\fP to center text vertical, BricsCAD and AutoCAD always create 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 .nf .ft C dim = msp.add_diameter_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS_INSIDE\(aq ) .ft P .fi .UNINDENT .UNINDENT [image] .sp To force text inside horizontal set \fBdimtih\fP to \fB1\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_diameter_dim(center=(0, 0), radius=2.5, angle=45, dimstyle=\(aqEZ_RADIUS_INSIDE\(aq, override={\(aqdimtih\(aq: 1} ) .ft P .fi .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 \fB\(aqEZ_RADIUS\(aq\fP can be used for all this examples. .sp User defined location outside of the circle: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_diameter_dim(center=(0, 0), radius=2.5, location=(4, 4), dimstyle=\(aqEZ_RADIUS\(aq ) .ft P .fi .UNINDENT .UNINDENT [image] .sp User defined location outside of the circle and forced horizontal text: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_diameter_dim(center=(0, 0), radius=2.5, location=(4, 4), dimstyle=\(aqEZ_RADIUS\(aq, override={\(aqdimtoh\(aq: 1} ) .ft P .fi .UNINDENT .UNINDENT [image] .sp User defined location inside of the circle: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_diameter_dim(center=(0, 0), radius=2.5, location=(1, 1), dimstyle=\(aqEZ_RADIUS\(aq ) .ft P .fi .UNINDENT .UNINDENT [image] .sp User defined location inside of the circle and forced horizontal text: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dim = msp.add_diameter_dim(center=(0, 0), radius=2.5, location=(1, 1), dimstyle=\(aqEZ_RADIUS\(aq, override={\(aqdimtih\(aq: 1}, ) .ft P .fi .UNINDENT .UNINDENT [image] .SS Center Mark/Lines .sp See Radius Dimension Tutorial: tut_center_mark .SS Overriding Measurement Text .sp See Linear Dimension Tutorial: tut_overriding_measurement_text .SS Measurement Text Formatting and Styling .sp See Linear Dimension Tutorial: tut_measurement_text_formatting_and_styling .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) -> Drawing 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 .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 .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, encoding: str = None, errors: str = \(aqsurrogateescape\(aq) -> Drawing 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 \fBezdxf.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 \fBDXFStructureError\fP – for invalid or corrupted DXF structures .IP \(bu 2 \fBUnicodeDecodeError\fP – if \fIerrors\fP is “strict” and a decoding error occurs .UNINDENT .UNINDENT .sp Deprecated since version v0.14: argument \fIlegacy_mode\fP, use module \fBezdxf.recover\fP to load DXF documents with structural flaws. .UNINDENT .INDENT 0.0 .TP .B ezdxf.read(stream: TextIO) -> Drawing 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 \fBezdxf.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 \fBDXFStructureError\fP – for invalid or corrupted DXF structures .UNINDENT .sp Deprecated since version v0.14: argument \fIlegacy_mode\fP, use module \fBezdxf.recover\fP to load DXF documents with structural flaws. .UNINDENT .INDENT 0.0 .TP .B ezdxf.readzip(zipfile: str, filename: str = None, errors: str = \(aqsurrogateescape\(aq) -> Drawing 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 \fBDXFStructureError\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) -> Drawing 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 \fBDXFStructureError\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 \fBezdxf.recover\fP module. .UNINDENT .UNINDENT .SS Save Drawings .sp Save the DXF document to the file system by \fBDrawing\fP methods \fBsave()\fP or \fBsaveas()\fP\&. Write the DXF document to a text stream with \fBwrite()\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 \fBHeaderSection\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: set/get header variables .IP \(bu 2 Howto: set drawing units .UNINDENT .UNINDENT .UNINDENT .SS Drawing Object .INDENT 0.0 .TP .B class ezdxf.document.Drawing The \fI\%Drawing\fP class manages all entities and tables related to a DXF drawing. .INDENT 7.0 .TP .B dxfversion Actual DXF version like \fB\(aqAC1009\(aq\fP, set by \fBezdxf.new()\fP or \fBezdxf.readfile()\fP\&. .sp For supported DXF versions see dwgmanagement .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\&. Text encoding can be changed to encodings listed below. .sp see also: dxf file encoding .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. .sp New in version 0.11. .UNINDENT .INDENT 7.0 .TP .B filename \fI\%Drawing\fP filename, if loaded by \fBezdxf.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 \fBHeaderSection\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 \fBBlockLayout\fP in the \fBBlocksSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B objects Reference to the objects section, see also \fBObjectsSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B blocks Reference to the blocks section, see also \fBBlocksSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B tables Reference to the tables section, see also \fBTablesSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B classes Reference to the classes section, see also \fBClassesSection\fP\&. .UNINDENT .INDENT 7.0 .TP .B layouts Reference to the layout manager, see also \fBLayouts\fP\&. .UNINDENT .INDENT 7.0 .TP .B groups Collection of all groups, see also \fBGroupCollection\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 \fBTable\fP and \fBLayer\fP .UNINDENT .INDENT 7.0 .TP .B styles Shortcut for \fBDrawing.tables.styles\fP .sp Reference to the styles table, see also \fBStyle\fP\&. .UNINDENT .INDENT 7.0 .TP .B dimstyles Shortcut for \fBDrawing.tables.dimstyles\fP .sp Reference to the dimstyles table, see also \fBDimStyle\fP\&. .UNINDENT .INDENT 7.0 .TP .B linetypes Shortcut for \fBDrawing.tables.linetypes\fP .sp Reference to the linetypes table, see also \fBLinetype\fP\&. .UNINDENT .INDENT 7.0 .TP .B views Shortcut for \fBDrawing.tables.views\fP .sp Reference to the views table, see also \fBView\fP\&. .UNINDENT .INDENT 7.0 .TP .B viewports Shortcut for \fBDrawing.tables.viewports\fP .sp Reference to the viewports table, see also \fBViewport\fP\&. .UNINDENT .INDENT 7.0 .TP .B ucs Shortcut for \fBDrawing.tables.ucs\fP .sp Reference to the ucs table, see also \fBUCS\fP\&. .UNINDENT .INDENT 7.0 .TP .B appids Shortcut for \fBDrawing.tables.appids\fP .sp Reference to the appids table, see also \fBAppID\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 \fBMLineStyle\fP objects. .UNINDENT .INDENT 7.0 .TP .B mleader_styles \fBMLeaderStyleCollection\fP of all \fBMLeaderStyle\fP objects. .UNINDENT .INDENT 7.0 .TP .B save(encoding: str = 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 handles file encoding different than 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: str, encoding: str = 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: Union[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 .nf .ft C binary = doc.encode(stream.get_value()) .ft P .fi .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 – \fB\(aqasc\(aq\fP for ASCII DXF (default) or \fB\(aqbin\(aq\fP 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) -> ezdxf.query.EntityQuery Entity query over all layouts and blocks, excluding the OBJECTS section. .INDENT 7.0 .TP .B Parameters \fBquery\fP – query string .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 entity query string and entity queries .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 \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 .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 \fBgroupby()\fP documentation .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B modelspace() -> ezdxf.layouts.layout.Modelspace Returns the modelspace layout, displayed as \fB\(aqModel\(aq\fP tab in CAD applications, defined by block record named \fB\(aq*Model_Space\(aq\fP\&. .UNINDENT .INDENT 7.0 .TP .B layout(name: str = None) -> Layout Returns paperspace layout \fIname\fP or returns first layout in tab order if \fIname\fP is \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B active_layout() -> Layout Returns the active paperspace layout, defined by block record name \fB\(aq*Paper_Space\(aq\fP\&. .UNINDENT .INDENT 7.0 .TP .B layout_names() -> Iterable[str] Returns all layout names (modelspace \fB\(aqModel\(aq\fP included) in arbitrary order. .UNINDENT .INDENT 7.0 .TP .B layout_names_in_taborder() -> Iterable[str] Returns all layout names (modelspace included, always first name) in tab order. .UNINDENT .INDENT 7.0 .TP .B new_layout(name, dxfattribs=None) -> Layout Create a new paperspace layout \fIname\fP\&. Returns a \fBLayout\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 \fBDXFValueError\fP – \fBLayout\fP \fIname\fP already exist .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 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 .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 tut_image .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 – \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. .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 – \fB0\fP = do not show image frame; \fB1\fP = show image frame .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_underlay_def(filename: str, format: str = \(aqext\(aq, name: str = None) Add an \fBUnderlayDef\fP entity to the drawing (OBJECTS section). \fIfilename\fP is the underlay file name as relative or absolute path and \fIformat\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 \fBformat\fP – file format as string \fB\(aqpdf\(aq|\(aqdwf\(aq|\(aqdgn\(aq\fP or \fB\(aqext\(aq\fP for getting file format from filename extension .IP \(bu 2 \fBname\fP – pdf format = page number to display; dgn format = \fB\(aqdefault\(aq\fP; dwf: ???? .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 7.0 .INDENT 3.5 tut_underlay .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_xref_def(filename: str, name: str, flags: int = 20) 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() -> Iterable[GenericLayoutType] Iterate over all layouts (modelspace and paperspace) and all block definitions. .UNINDENT .INDENT 7.0 .TP .B chain_layouts_and_blocks() -> Iterable[DXFEntity] 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)) -> VPort Set initial view/zoom location for the modelspace, this replaces the current “*Active” viewport configuration. .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. .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, to get more information about not fixable errors use \fI\%audit()\fP method instead. .INDENT 7.0 .TP .B Parameters \fBprint_report\fP – print report to stdout .UNINDENT .sp Returns: \fBTrue\fP if no errors occurred .UNINDENT .UNINDENT .SS Recover .sp New in version v0.14. .sp This module provides functions to “recover” ASCII DXF documents with structural flaws, which prevents the regular \fBezdxf.read()\fP and \fBezdxf.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 .nf .ft C import sys import ezdxf from ezdxf import recover try: doc, auditor = recover.readfile("messy.dxf") 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() .ft P .fi .UNINDENT .UNINDENT .sp This efforts cost some time, loading the DXF document with \fBezdxf.read()\fP or \fBezdxf.readfile()\fP will be 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 .nf .ft C 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) .ft P .fi .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 .nf .ft C 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() .ft P .fi .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 .nf .ft C 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() .ft P .fi .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 .nf .ft C 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() .ft P .fi .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 this files, this works in normal and recover mode: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .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 .nf .ft C 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() .ft P .fi .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, errors: str = \(aqsurrogateescape\(aq) -> Tuple[Drawing, Auditor] Read a DXF document from file system similar to \fBezdxf.readfile()\fP, but this function will repair as much 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 \fBDXFStructureError\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[Drawing, Auditor] Read a DXF document from a binary\-stream similar to \fBezdxf.read()\fP, but this function will detect the text encoding automatically and repair as much 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 \fBDXFStructureError\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 DXF Structures .SS Sections .SS Header Section .sp The drawing settings are stored in the HEADER section, which is accessible by the \fBheader\fP attribute of the \fBDrawing\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: header_section_internals .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 .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.header.CustomVars Stores custom properties in the DXF header as $CUSTOMPROPERTYTAG and $CUSTOMPROPERTY values. Custom properties are just supported by DXF R2004 (AC1018) or later. \fIezdxf\fP can create custom properties at older DXF versions, but AutoCAD will not show this properties. .INDENT 7.0 .TP .B properties List of custom drawing 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 is save to change this list as long you store just tuples of strings in the format \fB(tag, value)\fP\&. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Count of custom properties. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[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) 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\&. 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\&. 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 \fBLayout\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: classes_section_internals .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 has no handle attribute. .UNINDENT .INDENT 7.0 .TP .B register(classes: Iterable[DXFClass]) .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(name: str) -> DXFClass Add all required CLASS definitions for \fIdxfversion\fP\&. .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 \fBDXFGraphic\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: tables_section_internals .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.tables.TablesSection .INDENT 7.0 .TP .B layers \fBLayerTable\fP object for \fBLayer\fP objects .UNINDENT .INDENT 7.0 .TP .B linetypes Generic \fBTable\fP object for \fBLinetype\fP objects .UNINDENT .INDENT 7.0 .TP .B styles \fBStyleTable\fP object for \fBTextstyle\fP objects .UNINDENT .INDENT 7.0 .TP .B dimstyles Generic \fBTable\fP object for \fBDimStyle\fP objects .UNINDENT .INDENT 7.0 .TP .B appids Generic \fBTable\fP object for \fBAppID\fP objects .UNINDENT .INDENT 7.0 .TP .B ucs Generic \fBTable\fP object for \fBUCSTable\fP objects .UNINDENT .INDENT 7.0 .TP .B views Generic \fBTable\fP object for \fBView\fP objects .UNINDENT .INDENT 7.0 .TP .B viewports \fBViewportTable\fP object for \fBVPort\fP objects .UNINDENT .INDENT 7.0 .TP .B block_records Generic \fBTable\fP object for \fBBlockRecord\fP objects .UNINDENT .UNINDENT .SS Blocks Section .sp The BLOCKS section is the home all block definitions (\fBBlockLayout\fP) of a DXF document. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: blocks_section_internals and Block Management Structures .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.blocks.BlocksSection .INDENT 7.0 .TP .B __iter__() -> Iterable[BlockLayout] Iterable of all \fBBlockLayout\fP objects. .UNINDENT .INDENT 7.0 .TP .B __contains__(name: str) -> bool Returns \fBTrue\fP if \fBBlockLayout\fP \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B __getitem__(name: str) -> BlockLayout Returns \fBBlockLayout\fP \fIname\fP, raises \fBDXFKeyError\fP if \fIname\fP not exist. .UNINDENT .INDENT 7.0 .TP .B __delitem__(name: str) -> None Deletes \fBBlockLayout\fP \fIname\fP and all of its content, raises \fBDXFKeyError\fP if \fIname\fP not exist. .UNINDENT .INDENT 7.0 .TP .B get(self, name: str, default=None) -> BlockLayout Returns \fBBlockLayout\fP \fIname\fP, returns \fIdefault\fP if \fIname\fP not exist. .UNINDENT .INDENT 7.0 .TP .B new(name: str, base_point: Sequence[float] = (0, 0), dxfattribs: dict = None) -> BlockLayout Create and add a new \fBBlockLayout\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: Sequence[float] = (0, 0)) -> BlockLayout Create and add a new anonymous \fBBlockLayout\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 \fBBlockLayout\fP \fIold_name\fP to \fInew_name\fP .UNINDENT .INDENT 7.0 .TP .B delete_block(name: str, safe: bool = True) -> None Delete block. If \fIsave\fP is \fBTrue\fP, check if block is still referenced. .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 block is still referenced or special block without explicit references .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBDXFKeyError\fP – if block not exists .IP \(bu 2 \fBDXFBlockInUseError\fP – if block is still referenced, and save is True .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete_all_blocks() 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 undiscovered references to blocks which are not documented in the DXF reference, hidden in extended data sections or application defined data, which could produce invalid DXF documents if such referenced blocks will be deleted. .UNINDENT .UNINDENT .sp Changed in version 0.14: removed unsafe mode .UNINDENT .INDENT 7.0 .TP .B purge() Delete all unused blocks like \fI\%delete_all_blocks()\fP, but also removes unused anonymous blocks. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 There could exist undiscovered references to blocks which are not documented in the DXF reference, hidden in extended data sections or application defined data, which could produce invalid DXF documents if such referenced blocks will be deleted. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Entities Section .sp The ENTITIES section is the home of all \fBModelspace\fP and active \fBPaperspace\fP layout entities. This is a real section in the DXF file, for \fIezdxf\fP the \fI\%EntitySection\fP is just a proxy for modelspace and the active paperspace linked together. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: entities_section_internals .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.entities.EntitySection .INDENT 7.0 .TP .B __iter__() -> Iterable[DXFEntity] Iterable for all entities of modelspace and active paperspace. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of all entities of modelspace and 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 \fBDrawing.objects\fP\&. .sp Convenience methods of the \fBDrawing\fP object to create required structures in the OBJECTS section: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 IMAGEDEF: \fBadd_image_def()\fP .IP \(bu 2 UNDERLAYDEF: \fBadd_underlay_def()\fP .IP \(bu 2 RASTERVARIABLES: \fBset_raster_variables()\fP .IP \(bu 2 WIPEOUTVARIABLES: \fBset_wipeout_variables()\fP .UNINDENT .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 DXF Internals: objects_section_internals .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.sections.objects.ObjectsSection .INDENT 7.0 .TP .B rootdict Root dictionary. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Returns count of DXF objects. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[DXFObject] Returns iterable of all DXF objects in the OBJECTS section. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index) -> DXFObject 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 less objects as \fBList[DXFObject]\fP\&. .UNINDENT .INDENT 7.0 .TP .B __contains__(entity: Union[DXFObject, str]) -> bool 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) -> ezdxf.query.EntityQuery Get all DXF objects matching the entity query string\&. .UNINDENT .INDENT 7.0 .TP .B add_dictionary(owner: str = \(aq0\(aq, hard_owned: bool = False) -> ezdxf.entities.dictionary.Dictionary Add new \fBDictionary\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 = False) -> DictionaryWithDefault Add new \fBDictionaryWithDefault\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) -> DictionaryVar Add a new \fBDictionaryVar\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: dict = None) -> GeoData 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 \fBGeoData\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_image_def(filename: str, size_in_pixel: Tuple[int, int], name=None) -> ImageDef 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) -> Placeholder Add a new \fBPlaceholder\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, format: str = \(aqpdf\(aq, name: str = None) -> UnderlayDef Add an \fBUnderlayDef\fP entity to the drawing (OBJECTS section). \fIfilename\fP is the underlay file name as relative or absolute path and \fIformat\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 \fBformat\fP – file format as string \fB\(aqpdf\(aq|\(aqdwf\(aq|\(aqdgn\(aq\fP or \fB\(aqext\(aq\fP for getting file format from filename extension .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) -> XRecord Add a new \fBXRecord\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. .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 .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), public interface \fBset_wipeout_variables()\fP .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: \fB\(aqTest\(aq == \(aqTEST\(aq\fP\&. .INDENT 7.0 .TP .B static key(entity: Union[str, DXFEntity]) -> str Unified table entry key. .UNINDENT .INDENT 7.0 .TP .B has_entry(name: Union[str, DXFEntity]) -> bool Returns \fBTrue\fP if an table entry \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B __contains__(name: Union[str, DXFEntity]) -> bool Returns \fBTrue\fP if an table entry \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Count of table entries. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[DXFEntity] Iterable of all table entries. .UNINDENT .INDENT 7.0 .TP .B new(name: str, dxfattribs: dict = None) -> DXFEntity 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, case insensitive .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for table entry .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get(name: str) -> DXFEntity Get table entry \fIname\fP (case insensitive). Raises \fBDXFValueError\fP if table entry does not exist. .UNINDENT .INDENT 7.0 .TP .B remove(name: str) -> None Removes table entry \fIname\fP\&. Raises \fBDXFValueError\fP if table\-entry does not exist. .UNINDENT .INDENT 7.0 .TP .B duplicate_entry(name: str, new_name: str) -> DXFEntity 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 Raises \fBDXFValueError\fP – \fIname\fP 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 \fBLayer\fP objects. .UNINDENT .SS Linetype Table .sp Generic table class of \fI\%Table\fP\&. .sp Collection of \fBLinetype\fP objects. .SS Style Table .INDENT 0.0 .TP .B class ezdxf.sections.table.StyleTable Subclass of \fI\%Table\fP\&. .sp Collection of \fBTextstyle\fP objects. .INDENT 7.0 .TP .B get_shx(shxname: str) -> Textstyle Get existing shx entry, or create a new entry. .INDENT 7.0 .TP .B Parameters \fBshxname\fP – shape file name like ‘ltypeshp.lin’ .UNINDENT .UNINDENT .INDENT 7.0 .TP .B find_shx(shxname: str) -> Optional[Textstyle] Find .shx shape file table entry, by a case insensitive search. .sp A .shx shape file table entry has no name, so you have to search by the font attribute. .INDENT 7.0 .TP .B Parameters \fBshxname\fP – \&.shx shape file name .UNINDENT .UNINDENT .UNINDENT .SS DimStyle Table .sp Generic table class of \fI\%Table\fP\&. .sp Collection of \fBDimStyle\fP objects. .SS AppID Table .sp Generic table class of \fI\%Table\fP\&. .sp Collection of \fBAppID\fP objects. .SS UCS Table .sp Generic table class of \fI\%Table\fP\&. .sp Collection of \fBUCSTable\fP objects. .SS View Table .sp Generic table class of \fI\%Table\fP\&. .sp Collection of \fBView\fP objects. .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 \fB\(aq*ACTIVE\(aq\fP\&. .sp Duplication of table entries is not supported: \fBduplicate_entry()\fP raises \fBNotImplementedError\fP .INDENT 7.0 .TP .B get_config(self, name: str) -> List[Viewport] Returns a list of \fBViewport\fP objects, for the multi\-viewport configuration \fIname\fP\&. .UNINDENT .INDENT 7.0 .TP .B delete_config(name: str) -> None Delete all \fBViewport\fP objects of the multi\-viewport configuration \fIname\fP\&. .UNINDENT .UNINDENT .SS Block Record Table .sp Generic table class of \fI\%Table\fP\&. .sp Collection of \fBBlockRecord\fP objects. .SS Layer .sp LAYER (\fI\%DXF Reference\fP) definition, defines attribute values for entities on this layer for their attributes set to \fBBYLAYER\fP\&. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 layer_concept and tut_layers .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 (\fBLayerTable\fP). .UNINDENT .INDENT 7.0 .TP .B dxf.name Layer name, case insensitive and can not contain any of this characters: \fB<>/\e":;?*|=\(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 \fB(r, g, b)\fP 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 \fB(r, g, b)\fP tuple, returns \fBNone\fP if attribute \fI\%dxf.true_color\fP is not set. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C layer.rgb = (30, 40, 50) r, g, b = layer.rgb .ft P .fi .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\&. .sp New in version 0.10. .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\&. .sp New in version 0.10. .UNINDENT .INDENT 7.0 .TP .B description Get/set layer description as string .sp New in version 0.10. .UNINDENT .INDENT 7.0 .TP .B transparency Get/set layer transparency as float value in the range from \fB0\fP to \fB1\fP\&. \fB0\fP for no transparency (opaque) and \fB1\fP for 100% transparency. .sp New in version 0.10. .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 Renaming layers may damage the DXF file in some circumstances! .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: <>/":;?*|=\(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 .UNINDENT .SS Style .sp Defines a text style (\fI\%DXF Reference\fP), can be used by entities: \fBText\fP, \fBAttrib\fP and \fBAttdef\fP\&. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 tut_text and DXF internals for dimstyle_table_internals\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Textstyle .INDENT 7.0 .TP .B dxf.handle DXF handle (feature for experts). .UNINDENT .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fBStyleTable\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, \fB0\fP for not fixed (float). .UNINDENT .INDENT 7.0 .TP .B dxf.width Width factor (float), default is \fB1\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.oblique Oblique angle in degrees, \fB0\fP is vertical (float). .UNINDENT .INDENT 7.0 .TP .B dxf.generation_flags Text generations flags (int) .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 dxf.last_height Last height used in drawing units (float). .UNINDENT .INDENT 7.0 .TP .B dxf.font Primary font file name (str). .UNINDENT .INDENT 7.0 .TP .B dxf.bigfont Big font name, blank if none (str) .UNINDENT .UNINDENT .SS Linetype .sp Defines a linetype (\fI\%DXF Reference\fP). .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 tut_linetypes .sp DXF Internals: ltype_table_internals .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 (\fBTable\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 \fBDimension\fP entities. Each of this dimension variables starting with \fBdim...\fP can be overridden for any \fBDimension\fP entity individually. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 (\fBTable\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 = \fB\(aq.\(aq\fP, default metric = \fB\(aq,\(aq\fP) This is an integer value, use \fBord(\(aq.\(aq)\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 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 copy_to_header(dwg: Drawing) -> None 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, valign: str = None, vshift: float = 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, dec: int = None, sep: str = 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, linetype: str = None, lineweight: int = None, extension: float = None, disable1: bool = None, disable2: bool = 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, lineweight: int = None, extension: float = None, offset: float = None, fixed_length: float = 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, 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, 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, hfactor: float = 1.0, align: str = None, dec: int = None, leading_zeros: bool = None, trailing_zeros: bool = 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 “TOP”, “MIDDLE”, “BOTTOM”, 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, leading_zeros: bool = None, trailing_zeros: bool = 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 lower 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 \fBViewport\fP entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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: vport_table_internals .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.VPort Subclass of \fBDXFEntity\fP .sp Defines a viewport configurations for the modelspace. .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fBViewportTable\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 DCS) .UNINDENT .INDENT 7.0 .TP .B dxf.snap_base Snap base point (in DCS) .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 WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.target_point View target point (in WCS) .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 .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 .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{ \fBezdxf.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: view_table_internals .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.View .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fBTable\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 \fB1\fP if there is a UCS associated to this view; \fB0\fP 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 \fB1\fP) .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 \fB1\fP) .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 \fB1\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.ucs_ortho_type Orthographic type of UCS (appears only if \fBucs\fP is set to \fB1\fP) .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 \fB1\fP) .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 \fB1\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.camera_plottable \fB1\fP 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{ \fBezdxf.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 (\fBTable\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 \fBezdxf.math.UCS\fP class. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 ucs and ocs .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.UCSTable .INDENT 7.0 .TP .B dxf.owner Handle to owner (\fBTable\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 \fB(x, y, z)\fP tuple .UNINDENT .INDENT 7.0 .TP .B dxf.xaxis X\-axis direction as \fB(x, y, z)\fP tuple .UNINDENT .INDENT 7.0 .TP .B dxf.yaxis Y\-axis direction as \fB(x, y, z)\fP tuple .UNINDENT .INDENT 7.0 .TP .B ucs() -> UCS Returns an \fBezdxf.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 \fBBlockLayout\fP and \fBLayout\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{ \fBezdxf.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 (\fBTable\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 \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.explode \fB1\fP for BLOCK references can be exploded else \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.scale \fB1\fP for BLOCK references can be scaled else \fB0\fP .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 is_active_paperspace \fBTrue\fP if is “active” paperspace 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_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 is_modelspace \fBTrue\fP if is the modelspace layout. .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 \fBEntitySpace\fP object (\fBBlockRecord.entity_space\fP). For each layout exist a BLOCK definition in the BLOCKS section, a reference to the \fBBlock\fP entity is stored in \fBBlockRecord.block\fP\&. .sp \fBModelspace\fP and \fBPaperspace\fP layouts require an additional \fBDXFLayout\fP object in the OBJECTS section. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 More information about Block Management Structures and Layout Management Structures\&. .UNINDENT .UNINDENT .SS Blocks .sp A block definition (\fBBlockLayout\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. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_blocks and DXF Internals: Block Management Structures .UNINDENT .UNINDENT .SS Block .sp BLOCK (\fI\%DXF Reference\fP) entity is embedded into the \fBBlockLayout\fP object. The BLOCK entity is accessible by the \fBBlockLayout.block\fP attribute. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 \fBBlockLayout\fP) T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_blocks and DXF Internals: Block Management Structures .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 \fBInsert\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 \fBModelspace\fP or \fBPaperspace\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 \fBBlockLayout\fP object. The ENDBLK entity is accessible by the \fBBlockLayout.endblk\fP attribute. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 Block reference (\fI\%DXF Reference\fP) with maybe attached attributes (\fBAttrib\fP). .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqINSERT\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_blockref()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_blocks .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 .sp TODO: influence of layer, linetype, color DXF attributes to block entities .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 OCS) .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 \fBlist\fP of all attached \fBAttrib\fP entities. .UNINDENT .INDENT 7.0 .TP .B has_scaling Returns \fBTrue\fP if any axis scaling is applied. .sp New in version 0.12. .UNINDENT .INDENT 7.0 .TP .B has_uniform_scaling Returns \fBTrue\fP if scaling is uniform in 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. .sp New in version 0.14. .UNINDENT .INDENT 7.0 .TP .B set_scale(factor: float) Set uniform scaling. .UNINDENT .INDENT 7.0 .TP .B block() -> Optional[BlockLayout] Returns associated \fBBlockLayout\fP\&. .UNINDENT .INDENT 7.0 .TP .B place(insert: Vertex = None, scale: Tuple[float, float, float] = None, rotation: float = None) -> Insert Set block reference placing location \fIinsert\fP, scaling and rotation attributes. Parameters which are \fBNone\fP will not be altered. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinsert\fP – insert location as \fB(x, y [,z])\fP tuple .IP \(bu 2 \fBscale\fP – \fB(x\-scale, y\-scale, z\-scale)\fP 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 \fB(row_count, column_count)\fP tuple .IP \(bu 2 \fBspacing\fP – distance between placing as \fB(row_spacing, column_spacing)\fP tuple .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_attrib(tag: str, search_const: bool = False) -> bool Returns \fBTrue\fP if ATTRIB \fItag\fP exist, for \fIsearch_const\fP doc see \fI\%get_attrib()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name as string .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) -> Optional[Union[Attrib, AttDef]] Get attached \fBAttrib\fP entity with \fBdxf.tag == tag\fP, returns \fBNone\fP if not found. Some applications may not attach constant ATTRIB entities, set \fIsearch_const\fP to \fBTrue\fP, to get at least the associated \fBAttDef\fP entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name .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 = None, search_const: bool = False) -> str Get content text of attached \fBAttrib\fP entity with \fBdxf.tag == tag\fP, returns \fIdefault\fP if not found. Some applications may not attach constant ATTRIB entities, set \fIsearch_const\fP to \fBTrue\fP, to get content text of the associated \fBAttDef\fP entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name .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: Vertex = (0, 0), dxfattribs: dict = None) -> Attrib Attach an \fBAttrib\fP entity to the block reference. .sp Example for appending an attribute to an INSERT entity with none standard alignment: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C e.add_attrib(\(aqEXAMPLETAG\(aq, \(aqexample text\(aq).set_pos( (3, 7), align=\(aqMIDDLE_CENTER\(aq ) .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name as string .IP \(bu 2 \fBtext\fP – content text as string .IP \(bu 2 \fBinsert\fP – insert location as tuple \fB(x, y[, z])\fP in WCS .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]) -> ezdxf.entities.insert.Insert Attach for each \fBAttdef\fP entity, defined in the block definition, automatically an \fBAttrib\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 \fBadd_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 – \fBAttrib\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 \fBAttrib\fP entity from INSERT. If \fIignore\fP is \fBFalse\fP, an \fBDXFKeyError\fP exception is raised, if ATTRIB \fItag\fP does not exist. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – ATTRIB name .IP \(bu 2 \fBignore\fP – \fBFalse\fP for raising \fBDXFKeyError\fP if ATTRIB \fItag\fP does not exist. .UNINDENT .TP .B Raises \fBDXFKeyError\fP – if ATTRIB \fItag\fP does not exist. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B delete_all_attribs() -> None Delete all \fBAttrib\fP entities attached to the INSERT entity. .UNINDENT .INDENT 7.0 .TP .B reset_transformation() -> None Reset block reference parameters \fIlocation\fP, \fIrotation\fP and \fIextrusion\fP vector. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> 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, for this case an \fBInsertTransformationError\fP will be raised. .sp New in version 0.13. .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. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(skipped_entity_callback: Callable[[DXFGraphic, str], None] = None) -> Iterable[DXFGraphic] Yields “virtual” entities of a block reference. This method is meant to examine the block reference entities at the “exploded” location without really “exploding” the block reference. The\(gaskipped_entity_callback()\(ga 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. .sp This entities are not stored in the entity database, have no handle and are not assigned to any layout. It is possible to convert this 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 .nf .ft C doc.entitydb.add(entity) msp = doc.modelspace() msp.add_entity(entity) .ft P .fi .UNINDENT .UNINDENT .sp This method does not resolve the MINSERT attributes, only the sub\-entities of the base INSERT will be returned. To resolve MINSERT entities check if multi insert processing is required, that’s the case if property \fI\%Insert.mcount\fP > 1, use the \fI\%Insert.multi_insert()\fP method to resolve the MINSERT entity into single INSERT entities. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 \fBNon uniform scaling\fP may return incorrect results for text entities (TEXT, MTEXT, ATTRIB) and maybe some other entities. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters \fBskipped_entity_callback\fP – called whenever the transformation of an entity is not supported and so was skipped .UNINDENT .sp Changed in version 0.13: deprecated \fInon_uniform_scaling\fP argument .UNINDENT .INDENT 7.0 .TP .B multi_insert() -> Iterable[Insert] Yields a virtual INSERT entity for each grid element of a MINSERT entity (multi\-insert). .sp New in version 0.14. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: BaseLayout = None) -> EntityQuery Explode block reference entities into target layout, if target layout is \fBNone\fP, the target layout is the layout of the block reference. This method destroys the source block reference entity. .sp Transforms the block entities into the required WCS location by applying the block reference attributes \fIinsert\fP, \fIextrusion\fP, \fIrotation\fP and the scaling values \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 Returns an \fBEntityQuery\fP container with all “exploded” DXF entities. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 \fBNon uniform scaling\fP may lead to incorrect results for text entities (TEXT, MTEXT, ATTRIB) and maybe some other entities. .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 .IP \(bu 2 \fBlayout as source entity.\fP (\fIsame\fP) – .UNINDENT .UNINDENT .sp Changed in version 0.13: deprecated \fInon_uniform_scaling\fP argument .UNINDENT .INDENT 7.0 .TP .B ucs() -> UCS Returns the block reference coordinate system as \fBezdxf.math.UCS\fP object. .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 \fBInsert\fP entity, but it can also appear as standalone entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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{ \fBInsert.add_attrib()\fP (attached to \fBInsert\fP) T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_blocks .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 \fBText\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 is_invisible Attribute is invisible (does not appear). .UNINDENT .INDENT 7.0 .TP .B is_const This is a constant attribute. .UNINDENT .INDENT 7.0 .TP .B is_verify Verification is required on input of this attribute. (CAD application feature) .UNINDENT .INDENT 7.0 .TP .B is_preset No prompt during insertion. (CAD application feature) .UNINDENT .UNINDENT .SS AttDef .sp The ATTDEF (\fI\%DXF Reference\fP) entity is a template in a \fBBlockLayout\fP, which will be used to create an attached \fBAttrib\fP entity for an \fBInsert\fP entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.Text\fP T} _ T{ DXF type T} T{ \fB\(aqATTDEF\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_attdef()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_blocks .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 \fBText\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 is_invisibe Attribute is invisible (does not appear). .UNINDENT .INDENT 7.0 .TP .B is_const This is a constant attribute. .UNINDENT .INDENT 7.0 .TP .B is_verify Verification is required on input of this attribute. (CAD application feature) .UNINDENT .INDENT 7.0 .TP .B is_preset No prompt during insertion. (CAD application feature) .UNINDENT .UNINDENT .SS Layouts .SS Layout Manager .sp The layout manager is unique to each DXF drawing, access the layout manager as \fBlayouts\fP attribute of the \fBDrawing\fP object. .INDENT 0.0 .TP .B class ezdxf.layouts.Layouts The \fI\%Layouts\fP class manages \fBPaperspace\fP layouts and the \fBModelspace\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__() -> Iterable[Layout] Returns iterable of all layouts as \fBLayout\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 CAD applications. .UNINDENT .INDENT 7.0 .TP .B modelspace() -> Modelspace Returns the \fBModelspace\fP layout. .UNINDENT .INDENT 7.0 .TP .B get(name: str) -> Layout Returns \fBLayout\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: dict = None) -> Paperspace Returns a new \fBPaperspace\fP layout. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – layout name as shown in tabs in CAD applications .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for the \fBDXFLayout\fP entity .UNINDENT .TP .B Raises .INDENT 7.0 .IP \(bu 2 \fBDXFValueError\fP – Invalid characters in layout name. .IP \(bu 2 \fBDXFValueError\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 \fBDXFValueError\fP – try to rename \fB\(aqModel\(aq\fP .IP \(bu 2 \fBDXFValueError\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 \fBDXFKeyError\fP – if layout \fIname\fP do not exists .IP \(bu 2 \fBDXFValueError\fP – deleting modelspace layout is not possible .IP \(bu 2 \fBDXFValueError\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 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 drawing 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, this means the \fBdxf.owner\fP attribute of any \fBDXFGraphic\fP 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 \fBEntityDB\fP\&. But it is possible to just unlink an entity from a layout, so it can be assigned 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__() -> Iterable[DXFGraphic] 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() -> ExtensionDict Returns the associated extension dictionary, creates a new one if necessary. .UNINDENT .INDENT 7.0 .TP .B delete_entity(entity: DXFGraphic) -> 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: DXFGraphic) -> 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 query(query: str = \(aq*\(aq) -> EntityQuery Get all DXF entities matching the entity query string\&. .UNINDENT .INDENT 7.0 .TP .B groupby(dxfattrib: str = \(aq\(aq, key: KeyFunc = 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: DXFGraphic, layout: BaseLayout) -> 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 add_entity(entity: DXFGraphic) -> 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: DXFGraphic, 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 \fBimporter\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: Vertex, dxfattribs: dict = None) -> Point Add a \fBPoint\fP entity at \fIlocation\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlocation\fP – 2D/3D point in WCS .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_line(start: Vertex, end: Vertex, dxfattribs: dict = None) -> Line Add a \fBLine\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 WCS .IP \(bu 2 \fBend\fP – 2D/3D point in WCS .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_circle(center: Vertex, radius: float, dxfattribs: dict = None) -> Circle Add a \fBCircle\fP entity. This is an 2D element, which can be placed in space by using OCS\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – 2D/3D point in WCS .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: Vertex, major_axis: Vertex = (1, 0, 0), ratio: float = 1, start_param: float = 0, end_param: float = 6.283185307179586, dxfattribs: dict = None) -> Ellipse Add an \fBEllipse\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*pi. 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 WCS .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: Vertex, radius: float, start_angle: float, end_angle: float, is_counter_clockwise: bool = True, dxfattribs: dict = None) -> Arc Add an \fBArc\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 False 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 WCS .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 – False for clockwise orientation .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_solid(points: Iterable[Vertex], dxfattribs: dict = None) -> Solid Add a \fBSolid\fP entity, \fIpoints\fP is an iterable of 3 or 4 points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 3 or 4 2D/3D points in WCS .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBSolid\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_trace(points: Iterable[Vertex], dxfattribs: dict = None) -> Trace Add a \fBTrace\fP entity, \fIpoints\fP is an iterable of 3 or 4 points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 3 or 4 2D/3D points in WCS .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBTrace\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_3dface(points: Iterable[Vertex], dxfattribs: dict = None) -> Face3d Add a \fB3DFace\fP entity, \fIpoints\fP is an iterable 3 or 4 2D/3D points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 3 or 4 2D/3D points in WCS .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fB3DFace\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_text(text: str, dxfattribs: dict = None) -> Text Add a \fBText\fP entity, see also \fBStyle\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP – content string .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBText\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_blockref(name: str, insert: Vertex, dxfattribs: dict = None) -> Insert Add an \fBInsert\fP entity. .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 WCS .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBInsert\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_auto_blockref(name: str, insert: Vertex, values: Dict[str, str], dxfattribs: dict = None) -> Insert Add an \fBInsert\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 \fBtag/value\fP DXF attributes of the ATTRIB entities by the \fBkey/value\fP 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 WCS .IP \(bu 2 \fBvalues\fP – \fBAttrib\fP tag values as \fBtag/value\fP pairs .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBInsert\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_attrib(tag: str, text: str, insert: Vertex = (0, 0), dxfattribs: dict = None) -> Attrib Add an \fBAttrib\fP as stand alone DXF entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtag\fP – tag name as string .IP \(bu 2 \fBtext\fP – tag value as string .IP \(bu 2 \fBinsert\fP – insert location as 2D/3D point in WCS .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBAttrib\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_attdef(tag: str, insert: Vertex = (0, 0), text: str = \(aq\(aq, dxfattribs: dict = None) -> AttDef Add an \fBAttDef\fP as stand alone DXF entity. .sp Set position and alignment by the idiom: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C layout.add_attdef(\(aqNAME\(aq).set_pos((2, 3), align=\(aqMIDDLE_CENTER\(aq) .ft P .fi .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 WCS .IP \(bu 2 \fBtext\fP – tag value as string .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polyline2d(points: Iterable[Vertex], dxfattribs: dict = None, format: str = None) -> Polyline Add a 2D \fBPolyline\fP entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 2D points in WCS .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .IP \(bu 2 \fBformat\fP – user defined point format like \fI\%add_lwpolyline()\fP, default is \fBNone\fP .UNINDENT .UNINDENT .sp New in version 0.11: user defined point format .UNINDENT .INDENT 7.0 .TP .B add_polyline3d(points: Iterable[Vertex], dxfattribs: dict = None) -> Polyline Add a 3D \fBPolyline\fP entity. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – iterable of 3D points in WCS .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: dict = None) -> Polymesh Add a \fBPolymesh\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 for \fBPolyline\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_polyface(dxfattribs: dict = None) -> Polyface Add a \fBPolyface\fP entity, which is a wrapper class for the POLYLINE entity. .INDENT 7.0 .TP .B Parameters \fBdxfattribs\fP – additional DXF attributes for \fBPolyline\fP entity .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_shape(name: str, insert: Vertex = (0, 0), size: float = 1.0, dxfattribs: dict = None) -> Shape Add a \fBShape\fP reference to a 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 WCS .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[Vertex], format: str = \(aqxyseb\(aq, dxfattribs: dict = None) -> LWPolyline Add a 2D polyline as \fBLWPolyline\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 \fB0\fP to be ignored like (x, y, 0, 0, bulge). .sp The \fBLWPolyline\fP is defined as a single DXF entity and needs less disk space than a \fBPolyline\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 \fB"xyseb"\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mtext(text: str, dxfattribs: dict = None) -> MText Add a multiline text entity with automatic text wrapping at boundaries as \fBMText\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_ray(start: Vertex, unit_vector: Vertex, dxfattribs: dict = None) -> Ray Add a \fBRay\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 WCS .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: Vertex, unit_vector: Vertex, dxfattribs: dict = None) -> XLine Add an infinity \fBXLine\fP (construction line). (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBstart\fP – location 3D point in WCS .IP \(bu 2 \fBunit_vector\fP – 3D vector \fB(x, y, z)\fP .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_spline(fit_points: Iterable[Vertex] = None, degree: int = 3, dxfattribs: dict = None) -> Spline Add a B\-spline (\fBSpline\fP entity) defined by fit points \- 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. If \fIfit_points\fP is \fBNone\fP, an ‘empty’ spline will be created, all data has to be set by the user. (requires DXF R2000) .sp AutoCAD creates a spline through fit points by a proprietary algorithm. \fIezdxf\fP can not reproduce the control point calculation. See also: tut_spline\&. .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 WCS, create ‘empty’ \fBSpline\fP if \fBNone\fP .IP \(bu 2 \fBdegree\fP – degree of B\-spline .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_spline_control_frame(fit_points: Iterable[Vertex], degree: int = 3, method: str = \(aqchord\(aq, dxfattribs: dict = None) -> Spline Add a \fBSpline\fP entity passing through given fit points by global B\-spline interpolation, the new SPLINE entity is defined by a control frame and not by the fit points. .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 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – iterable of fit points as (x, y[, z]) in WCS .IP \(bu 2 \fBdegree\fP – degree of B\-spline .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[Vertex], degree: int = 3, knots: Iterable[float] = None, dxfattribs: dict = None) -> Spline Add an open uniform \fBSpline\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 WCS .IP \(bu 2 \fBdegree\fP – degree of B\-spline .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_closed_spline(control_points: Iterable[Vertex], degree: int = 3, knots: Iterable[float] = None, dxfattribs: dict = None) -> Spline Add a closed uniform \fBSpline\fP defined by \fIcontrol_points\fP\&. (requires DXF R2000) .sp Closed uniform B\-splines is a closed curve start and end at the first control point. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – iterable of 3D points in WCS .IP \(bu 2 \fBdegree\fP – degree of B\-spline .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[Vertex], weights: Sequence[float], degree: int = 3, knots: Iterable[float] = None, dxfattribs: dict = None) -> Spline Add an open rational uniform \fBSpline\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 WCS .IP \(bu 2 \fBweights\fP – weight values as iterable of floats .IP \(bu 2 \fBdegree\fP – degree of B\-spline .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_closed_rational_spline(control_points: Iterable[Vertex], weights: Sequence[float], degree: int = 3, knots: Iterable[float] = None, dxfattribs: dict = None) -> Spline Add a closed rational uniform \fBSpline\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 Closed rational uniform B\-splines start and end at the first control point. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – iterable of 3D points in WCS .IP \(bu 2 \fBweights\fP – weight values as iterable of floats .IP \(bu 2 \fBdegree\fP – degree of B\-spline .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: dict = None) -> Hatch Add a \fBHatch\fP entity. (requires DXF R2007) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – ACI (AutoCAD Color Index), default is \fB7\fP (black/white). .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_mesh(dxfattribs: dict = None) -> Mesh Add a \fBMesh\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: ImageDef, insert: Vertex, size_in_units: Tuple[float, float], rotation: float = 0.0, dxfattribs: dict = None) -> Image Add an \fBImage\fP entity, requires a \fBImageDef\fP entity, see tut_image\&. (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBimage_def\fP – required image definition as \fBImageDef\fP .IP \(bu 2 \fBinsert\fP – insertion point as 3D point in WCS .IP \(bu 2 \fBsize_in_units\fP – size as \fB(x, y)\fP 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[Vertex], dxfattribs: dict = None) -> Wipeout Add a \fBezdxf.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: UnderlayDef, insert: Vertex = (0, 0, 0), scale=(1, 1, 1), rotation: float = 0.0, dxfattribs: dict = None) -> Underlay Add an \fBUnderlay\fP entity, requires a \fBUnderlayDef\fP entity, see tut_underlay\&. (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBunderlay_def\fP – required underlay definition as \fBUnderlayDef\fP .IP \(bu 2 \fBinsert\fP – insertion point as 3D point in WCS .IP \(bu 2 \fBscale\fP – underlay scaling factor as \fB(x, y, z)\fP 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: Vertex, p1: Vertex, p2: Vertex, location: Vertex = None, text: str = \(aq<>\(aq, angle: float = 0, text_rotation: float = None, dimstyle: str = \(aqEZDXF\(aq, override: dict = None, dxfattribs: dict = None) -> DimStyleOverride Add horizontal, vertical and rotated \fBDimension\fP line. If an \fBUCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into WCS and OCS is done by the rendering function. Extrusion vector is defined by UCS or \fB(0, 0, 1)\fP by default. See also: tut_linear_dimension .sp This method returns a \fBDimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fBrender()\fP manually, this two step process allows additional processing steps on the \fBDimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIezdxf\fP ignores some DIMSTYLE variables, so render results may differ from BricsCAD or AutoCAD. .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 text mid point (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or \fB"<>"\fP the measurement is drawn as text, \fB" "\fP (one space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fBDimStyle\fP table entry), default is \fB\(aqEZDXF\(aq\fP .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 – \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBDimension\fP entity .UNINDENT .UNINDENT .sp Returns: \fBDimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_multi_point_linear_dim(base: Vertex, points: Iterable[Vertex], angle: float = 0, ucs: UCS = None, avoid_double_rendering: bool = True, dimstyle: str = \(aqEZDXF\(aq, override: dict = None, dxfattribs: dict = None, discard=False) -> None Add multiple linear dimensions for iterable \fIpoints\fP\&. If an \fBUCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into WCS and OCS is done by the rendering function. Extrusion vector is defined by UCS or \fB(0, 0, 1)\fP by default. See also: tut_linear_dimension .sp This method sets many design decisions by itself, the necessary geometry will be generated automatically, no required nor possible \fBrender()\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 ignores some DIMSTYLE variables, so render results may differ from BricsCAD or AutoCAD. .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 (\fB0\fP = horizontal, \fB90\fP = 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 \fB\(aqEZDXF\(aq\fP .IP \(bu 2 \fBoverride\fP – \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBDimension\fP 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: Vertex, p2: Vertex, distance: float, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZDXF\(aq, override: dict = None, dxfattribs: dict = None) -> DimStyleOverride Add linear dimension aligned with measurement points \fIp1\fP and \fIp2\fP\&. If an \fBUCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into WCS and OCS is done by the rendering function. Extrusion vector is defined by UCS or \fB(0, 0, 1)\fP by default. See also: tut_linear_dimension .sp This method returns a \fBDimStyleOverride\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 \fBDimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIezdxf\fP ignores some DIMSTYLE variables, so render results may differ from BricsCAD or AutoCAD. .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 – None or “<>” the measurement is drawn as text, ” ” (one space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fBDimStyle\fP table entry), default is \fB\(aqEZDXF\(aq\fP .IP \(bu 2 \fBoverride\fP – \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fBDimension\fP entity .UNINDENT .UNINDENT .sp Returns: \fBDimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_radius_dim(center: Vertex, mpoint: Vertex = None, radius: float = None, angle: float = None, location: Vertex = None, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict = None, dxfattribs: dict = None) -> DimStyleOverride Add a radius \fBDimension\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: tut_radius_dimension .sp If an \fBUCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into WCS and OCS is done by the rendering function. Extrusion vector is defined by UCS or \fB(0, 0, 1)\fP by default. .sp This method returns a \fBDimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fBrender()\fP manually, this two step process allows additional processing steps on the \fBDimension\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: \fB\(aqEZ_RADIUS\(aq\fP .IP \(bu 2 Default text location outside horizontal: \fB\(aqEZ_RADIUS\(aq\fP + dimtoh=1 .IP \(bu 2 Default text location inside: text aligned with dimension line; dimension style: \fB\(aqEZ_RADIUS_INSIDE\(aq\fP .IP \(bu 2 Default text location inside horizontal:\fB\(aqEZ_RADIUS_INSIDE\(aq\fP + dimtih=1 .IP \(bu 2 User defined text location: argument \fIlocation\fP != \fBNone\fP, text aligned with dimension line; dimension style: \fB\(aqEZ_RADIUS\(aq\fP .IP \(bu 2 User defined text location horizontal: argument \fIlocation\fP != \fBNone\fP, \fB\(aqEZ_RADIUS\(aq\fP + dimtoh=1 for text outside horizontal, \fB\(aqEZ_RADIUS\(aq\fP + 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 ignores some DIMSTYLE variables, so render results may differ from BricsCAD or AutoCAD. .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 \fB"<>"\fP the measurement is drawn as text, \fB" "\fP (one space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fBDimStyle\fP table entry), default is \fB\(aqEZ_RADIUS\(aq\fP .IP \(bu 2 \fBoverride\fP – \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBDimension\fP entity .UNINDENT .UNINDENT .sp Returns: \fBDimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_radius_dim_2p(center: Vertex, mpoint: Vertex, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict = None, dxfattribs: dict = 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 \fB\(aqEZ_RADIUS\(aq\fP: places the dimension text outside .IP \(bu 2 dimstyle \fB\(aqEZ_RADIUS_INSIDE\(aq\fP: 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 \fB"<>"\fP the measurement is drawn as text, \fB" "\fP (one space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fBDimStyle\fP table entry), default is \fB\(aqEZ_RADIUS\(aq\fP .IP \(bu 2 \fBoverride\fP – \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBDimension\fP entity .UNINDENT .UNINDENT .sp Returns: \fBDimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_radius_dim_cra(center: Vertex, radius: float, angle: float, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict = None, dxfattribs: dict = 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 \fB\(aqEZ_RADIUS\(aq\fP: places the dimension text outside .IP \(bu 2 dimstyle \fB\(aqEZ_RADIUS_INSIDE\(aq\fP: 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 \fB"<>"\fP the measurement is drawn as text, \fB" "\fP (one space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fBDimStyle\fP table entry), default is \fB\(aqEZ_RADIUS\(aq\fP .IP \(bu 2 \fBoverride\fP – \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBDimension\fP entity .UNINDENT .UNINDENT .sp Returns: \fBDimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_diameter_dim(center: Vertex, mpoint: Vertex = None, radius: float = None, angle: float = None, location: Vertex = None, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict = None, dxfattribs: dict = None) -> DimStyleOverride Add a diameter \fBDimension\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 \fBUCS\fP is used for dimension line rendering, all point definitions in UCS coordinates, translation into WCS and OCS is done by the rendering function. Extrusion vector is defined by UCS or \fB(0, 0, 1)\fP by default. .sp This method returns a \fBDimStyleOverride\fP object \- to create the necessary dimension geometry, you have to call \fBrender()\fP manually, this two step process allows additional processing steps on the \fBDimension\fP entity between creation and rendering. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fIezdxf\fP ignores some DIMSTYLE variables, so render results may differ from BricsCAD or AutoCAD. .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 text mid point (in UCS) .IP \(bu 2 \fBtext\fP – \fBNone\fP or \fB"<>"\fP the measurement is drawn as text, \fB" "\fP (one space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fBDimStyle\fP table entry), default is \fB\(aqEZ_RADIUS\(aq\fP .IP \(bu 2 \fBoverride\fP – \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBDimension\fP entity .UNINDENT .UNINDENT .sp Returns: \fBDimStyleOverride\fP .sp (not implemented yet!) .UNINDENT .INDENT 7.0 .TP .B add_diameter_dim_2p(p1: Vertex, p2: Vertex, text: str = \(aq<>\(aq, dimstyle: str = \(aqEZ_RADIUS\(aq, override: dict = None, dxfattribs: dict = 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 mid point between \fIp1\fP and \fIp2\fP\&. .INDENT 7.0 .IP \(bu 2 dimstyle \fB\(aqEZ_RADIUS\(aq\fP: places the dimension text outside .IP \(bu 2 dimstyle \fB\(aqEZ_RADIUS_INSIDE\(aq\fP: 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 \fB"<>"\fP the measurement is drawn as text, \fB" "\fP (one space) suppresses the dimension text, everything else \fItext\fP is drawn as dimension text .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fBDimStyle\fP table entry), default is \fB\(aqEZ_RADIUS\(aq\fP .IP \(bu 2 \fBoverride\fP – \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBDimension\fP entity .UNINDENT .UNINDENT .sp Returns: \fBDimStyleOverride\fP .UNINDENT .INDENT 7.0 .TP .B add_leader(vertices: Iterable[Vertex], dimstyle: str = \(aqEZDXF\(aq, override: dict = None, dxfattribs: dict = None) -> Leader The \fBLeader\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 \fBLeader\fP is attached is stored as a separate entity, and is not part of the \fBLeader\fP itself. (requires DXF R2000) .sp \fBLeader\fP shares its styling infrastructure with \fBDimension\fP\&. .sp By default a \fBLeader\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 WCS) .IP \(bu 2 \fBdimstyle\fP – dimension style name (\fBDimStyle\fP table entry), default is \fB\(aqEZDXF\(aq\fP .IP \(bu 2 \fBoverride\fP – override \fBDimStyleOverride\fP attributes .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for \fBLeader\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_body(acis_data: str = None, dxfattribs: dict = None) -> Body Add a \fBBody\fP entity. (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBacis_data\fP – ACIS data as iterable of text lines as strings, no interpretation by ezdxf possible .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_region(acis_data: str = None, dxfattribs: dict = None) -> Region Add a \fBRegion\fP entity. (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBacis_data\fP – ACIS data as iterable of text lines as strings, no interpretation by ezdxf possible .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_3dsolid(acis_data: str = None, dxfattribs: dict = None) -> Solid3d Add a 3DSOLID entity (\fBSolid3d\fP). (requires DXF R2000) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBacis_data\fP – ACIS data as iterable of text lines as strings, no interpretation by ezdxf possible .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_surface(acis_data: str = None, dxfattribs: dict = None) -> Surface Add a \fBSurface\fP entity. (requires DXF R2007) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBacis_data\fP – ACIS data as iterable of text lines as strings, no interpretation by ezdxf possible .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_extruded_surface(acis_data: str = None, dxfattribs: dict = None) -> ExtrudedSurface Add a \fBExtrudedSurface\fP entity. (requires DXF R2007) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBacis_data\fP – ACIS data as iterable of text lines as strings, no interpretation by ezdxf possible .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_lofted_surface(acis_data: str = None, dxfattribs: dict = None) -> LoftedSurface Add a \fBLoftedSurface\fP entity. (requires DXF R2007) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBacis_data\fP – ACIS data as iterable of text lines as strings, no interpretation by ezdxf possible .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_revolved_surface(acis_data: str = None, dxfattribs: dict = None) -> RevolvedSurface Add a \fBRevolvedSurface\fP entity. (requires DXF R2007) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBacis_data\fP – ACIS data as iterable of text lines as strings, no interpretation by ezdxf possible .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_swept_surface(acis_data: str = None, dxfattribs: dict = None) -> SweptSurface Add a \fBSweptSurface\fP entity. (requires DXF R2007) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBacis_data\fP – ACIS data as iterable of text lines as strings, no interpretation by ezdxf possible .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes .UNINDENT .UNINDENT .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 CAD applications. .UNINDENT .INDENT 7.0 .TP .B dxf Returns the DXF name space attribute of the associated \fBDXFLayout\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: Union[DXFGraphic, 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_extends() -> None Reset extends. .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 \fBDXFValueError\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 set_redraw_order(handles: Union[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. \fIhandles\fP 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 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: dict = None) -> GeoData 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 \fBGeoData\fP entity .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_geodata() -> Optional[GeoData] Returns the \fBGeoData\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 CAD 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, extends 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 rename(name: str) -> None Rename layout to \fIname\fP, changes the name displayed in tabs by CAD applications, not the internal BLOCK name. .UNINDENT .INDENT 7.0 .TP .B viewports() -> List[DXFGraphic] Get all VIEWPORT entities defined in the paperspace layout. Returns a list of \fBViewport\fP objects, sorted by id, the first entity is always the paperspace view with an id of 1. .UNINDENT .INDENT 7.0 .TP .B add_viewport(center: Vertex, size: Tuple[float, float], view_center_point: Vertex, view_height: float, dxfattribs: dict = None) -> Viewport Add a new \fBViewport\fP entity. .UNINDENT .INDENT 7.0 .TP .B reset_viewports() -> None Delete all existing viewports, and add a new main viewport. .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[Tuple[float, float], Tuple[float, float]] 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 ((x1, y1), (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 \fBInsert\fP entities. Each reference can be placed, scaled and rotated individually and can have it’s own set of DXF \fBAttrib\fP entities attached. .INDENT 7.0 .TP .B name name of the associated BLOCK and BLOCK_RECORD entities. .UNINDENT .INDENT 7.0 .TP .B block the associated \fBBlock\fP entity. .UNINDENT .INDENT 7.0 .TP .B endblk the associated \fBEndBlk\fP entity. .UNINDENT .INDENT 7.0 .TP .B dxf DXF name space of associated \fBBlockRecord\fP table entry. .UNINDENT .INDENT 7.0 .TP .B can_explode Set property to \fBTrue\fP to allow exploding block references of this block. .UNINDENT .INDENT 7.0 .TP .B scale_uniformly Set property to \fBTrue\fP to allow block references of this block only scale uniformly. .UNINDENT .INDENT 7.0 .TP .B __contains__(entity: Union[DXFGraphic, str]) -> 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) -> Optional[DXFGraphic] Returns attached \fBAttdef\fP entity by \fItag\fP name. .UNINDENT .INDENT 7.0 .TP .B get_attdef_text(tag: str, default: str = None) -> 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 on the same layout (modelspace or any paper 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 main group table, which is stored as attribute \fBgroups\fP in the \fBDrawing\fP object. .sp Group entities have to be in modelspace or any paperspace layout but not in a block definition! .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 \fB1\fP for unnamed, \fB0\fP for named group (int) .UNINDENT .INDENT 7.0 .TP .B dxf.selectable \fB1\fP for selectable, \fB0\fP for not selectable group (int) .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[ezdxf.entities.dxfentity.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: Union[str, ezdxf.entities.dxfentity.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[ezdxf.entities.dxfentity.DXFEntity] Context manager which yields all the group entities as standard Python list: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C 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() .ft P .fi .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\&. .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 handles from \fI\%DXFGroup\fP\&. .sp Invalid handles are: deleted entities, not all entities in the same layout or entities in a block layout. .UNINDENT .UNINDENT .SS GroupCollection .sp Each \fBDrawing\fP has one group table, which is accessible by the attribute \fBgroups\fP\&. .INDENT 0.0 .TP .B class ezdxf.entities.dxfgroups.GroupCollection Manages all \fI\%DXFGroup\fP objects of a \fBDrawing\fP\&. .INDENT 7.0 .TP .B __len__() -> int 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__(name: str) -> bool Returns \fBTrue\fP if a group \fIname\fP exist. .UNINDENT .INDENT 7.0 .TP .B get(name: str) -> DXFGroup Returns the group \fIname\fP\&. Raises \fBDXFKeyError\fP if group \fIname\fP does not exist. .UNINDENT .INDENT 7.0 .TP .B groups() -> DXFGroup Iterable of all existing groups. .UNINDENT .INDENT 7.0 .TP .B new(name: str = None, description: str = \(aq\(aq, selectable: bool = True) -> DXFGroup Creates a new group. If \fIname\fP is \fBNone\fP an unnamed group is created, which has an automatically generated name like “*Annnn”. .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: Union[DXFGroup, 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 \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 .nf .ft C # set attribute value entity.dxf.layer = \(aqMyLayer\(aq # get attribute value linetype = entity.dxf.linetype # delete attribute del entity.dxf.linetype .ft P .fi .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 \fBDrawing\fP instance. .UNINDENT .INDENT 7.0 .TP .B is_alive Returns \fBFalse\fP if entity has been deleted. .UNINDENT .INDENT 7.0 .TP .B is_virtual Returns \fBTrue\fP if entity is a virtual entity. .UNINDENT .INDENT 7.0 .TP .B is_bound Returns \fBTrue\fP if entity is bound to DXF document. .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 .nf .ft C layer = entity.get_dxf_attrib("layer") # same as layer = entity.dxf.layer .ft P .fi .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 .nf .ft C entity.set_dxf_attrib("layer", "MyLayer") # same as entity.dxf.layer = "MyLayer" .ft P .fi .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) -> Dict Returns a \fBdict\fP with all existing DXF attributes and their values and exclude all DXF attributes listed in set \fIdrop\fP\&. .sp Changed in version 0.12: added \fIdrop\fP argument .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 \fB1\fP (on) if \fIstate\fP is \fBTrue\fP, set \fIflag\fP to \fB0\fP (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 \fB1\fP (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 \fBExtensionDict\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_extension_dict() -> ExtensionDict Returns the existing \fBExtensionDict\fP\&. .INDENT 7.0 .TP .B Raises \fBAttributeError\fP – extension dict does not exist .UNINDENT .UNINDENT .INDENT 7.0 .TP .B new_extension_dict() -> ExtensionDict .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) -> Tags 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 \fBDXFValueError\fP – no data for \fIappid\fP found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_app_data(appid: str, tags: Iterable) 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 \fBDXFTag\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) -> Tags 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 \fBDXFValueError\fP – no extended data for \fIappid\fP found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_xdata(appid: str, tags: Iterable) 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 \fBDXFTag\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) -> Tags 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 \fBDXFValueError\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) 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 \fBDXFTag\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) 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 \fBDXFTag\fP .UNINDENT .TP .B Raises \fBDXFValueError\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 This entities resides in entity spaces like \fBModelspace\fP, any \fBPaperspace\fP or \fBBlockLayout\fP\&. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 \fB(r, g, b)\fP tuple, returns \fBNone\fP if attribute \fI\%dxf.true_color\fP is not set. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C entity.rgb = (30, 40, 50) r, g, b = entity.rgb .ft P .fi .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 transparency value as float. Value range \fB0\fP to \fB1\fP, where \fB0\fP means entity is opaque and \fB1\fP means entity is 100% transparent (invisible). This is the recommend method to get/set transparency values, 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 \fB0\fP for prior DXF versions and raises \fBDXFAttributeError\fP for setting \fItransparency\fP in older DXF versions. .UNINDENT .INDENT 7.0 .TP .B ocs() -> OCS Returns object coordinate system (ocs) for 2D entities like \fBText\fP or \fBCircle\fP, returns \fBNone\fP for entities without OCS support. .UNINDENT .INDENT 7.0 .TP .B get_layout() -> BaseLayout 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 \fBunlink_entity()\fP method of the associated layout, especially if you have to unlink more than one entity. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B copy_to_layout(layout: BaseLayout) -> DXFEntity Copy entity to another \fIlayout\fP, returns new created entity as \fBDXFEntity\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 \fBDXFStructureError\fP – for copying between different DXF drawings .UNINDENT .UNINDENT .INDENT 7.0 .TP .B move_to_layout(layout: BaseLayout, source: BaseLayout = 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 \fBDXFStructureError\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. .sp New in version 0.12. .UNINDENT .INDENT 7.0 .TP .B has_hyperlink() -> bool Returns \fBTrue\fP if entity has an attached hyperlink. .sp New in version 0.12. .UNINDENT .INDENT 7.0 .TP .B get_hyperlink() -> Tuple[str, str, str] Returns hyperlink, description and location. .sp New in version 0.12. .UNINDENT .INDENT 7.0 .TP .B set_hyperlink(link: str, description: str = None, location: str = None) Set hyperlink of an entity. .sp New in version 0.12. .UNINDENT .INDENT 7.0 .TP .B transform(t: Matrix44) -> DXFGraphic Inplace transformation interface, returns \fIself\fP (floating interface). .INDENT 7.0 .TP .B Parameters \fBm\fP – 4x4 transformation matrix (\fBezdxf.math.Matrix44\fP) .UNINDENT .sp New in version 0.13. .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. .sp New in version 0.13. .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). .sp New in version 0.13. .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). .sp New in version 0.13. .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 .sp New in version 0.13. .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 .sp New in version 0.13. .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 .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B rotate_axis(axis: Vector, 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 \fBVector\fP .IP \(bu 2 \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .sp New in version 0.13. .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 = \fB\(aq0\(aq\fP .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.linetype Linetype as string, special names \fB\(aqBYLAYER\(aq\fP, \fB\(aqBYBLOCK\(aq\fP; default value is \fB\(aqBYLAYER\(aq\fP .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.color aci, default = \fB256\fP .sp Constants defined in \fBezdxf.lldxf.const\fP .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 \fBezdxf.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 = \fB1.0\fP (requires DXF R2000) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.invisible \fB1\fP for invisible, \fB0\fP for visible; default = \fB0\fP (requires DXF R2000) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.paperspace \fB0\fP for entity resides in modelspace or a block, \fB1\fP for paperspace, this attribute is set automatically by adding an entity to a layout (feature for experts); default = \fB0\fP .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.extrusion Extrusion direction as 3D vector; default = \fB(0, 0, 1)\fP .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.thickness Entity thickness as float; default = \fB0.0\fP (requires DXF R2000) .UNINDENT .INDENT 0.0 .TP .B DXFGraphic.dxf.true_color True color value as int \fB0x00RRGGBB\fP, use \fI\%DXFGraphic.rgb\fP to get/set true color values as \fB(r, g, b)\fP 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, \fB0x020000TT\fP \fB0x00\fP = 100% transparent / \fB0xFF\fP = opaque, use \fI\%DXFGraphic.transparency\fP to get/set transparency as float value. .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 .SS Face3d .sp A 3DFACE (\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). .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aq3DFACE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_3dface()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 \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 WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx1 Location of 2. vertex (3D Point in WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx2 Location of 3. vertex (3D Point in WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx3 Location of 4. vertex (3D Point in WCS) .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: Matrix44) -> Face3d Transform 3DFACE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .UNINDENT .SS Solid3d .sp 3DSOLID (\fI\%DXF Reference\fP) created by an ACIS based geometry kernel provided by the \fI\%Spatial Corp.\fP .sp \fIezdxf\fP will never interpret ACIS source code, don’t ask me for this feature. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.Body\fP T} _ T{ DXF type T} T{ \fB\(aq3DSOLID\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_3dsolid()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 \fBBody\fP\&. .INDENT 7.0 .TP .B dxf.history_handle Handle to history object. .UNINDENT .UNINDENT .SS Arc .sp ARC (\fI\%DXF Reference\fP) center at location \fBdxf.center\fP and radius of \fBdxf.radius\fP from \fBdxf.start_angle\fP to \fBdxf.end_angle\fP\&. ARC goes always from \fBdxf.start_angle\fP to \fBdxf.end_angle\fP in counter clockwise orientation around the \fBdxf.extrusion\fP vector, which is \fB(0, 0, 1)\fP by default and the usual case for 2D arcs. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.Circle\fP T} _ T{ DXF type T} T{ \fB\(aqARC\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_arc()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 OCS) .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 WCS, takes OCS into account. .sp New in version 0.11. .UNINDENT .INDENT 7.0 .TP .B end_point Returns the end point of the arc in WCS, takes OCS into account. .sp New in version 0.11. .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 transform(m: Matrix44) -> Arc Transform ARC entity by transformation matrix \fIm\fP inplace. .sp Raises \fBNonUniformScalingError()\fP for non uniform scaling. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B to_ellipse(replace=True) -> Ellipse Convert CIRCLE/ARC to an \fBEllipse\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 .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B to_spline(replace=True) -> Spline Convert CIRCLE/ARC to a \fBSpline\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 .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B construction_tool() -> ConstructionArc Returns 2D construction tool \fBezdxf.math.ConstructionArc\fP, ignoring the extrusion vector. .sp New in version 0.14. .UNINDENT .INDENT 7.0 .TP .B apply_construction_tool(arc: ConstructionArc) -> Arc Set ARC data from construction tool \fBezdxf.math.ConstructionArc\fP, will not change the extrusion vector. .sp New in version 0.14. .UNINDENT .UNINDENT .SS Body .sp BODY (\fI\%DXF Reference\fP) created by an ACIS based geometry kernel provided by the \fI\%Spatial Corp.\fP .sp \fIezdxf\fP will never interpret ACIS source code, don’t ask me for this feature. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqBODY\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_body()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 \fB1\fP .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 acis_data Get/Set ACIS text data as list of strings for DXF R2000 to R2010 and binary encoded ACIS data for DXF R2013 and later as list of bytes. .UNINDENT .INDENT 7.0 .TP .B has_binary_data Returns \fBTrue\fP if ACIS data is of type \fBList[bytes]\fP, \fBFalse\fP if data is of type \fBList[str]\fP\&. .UNINDENT .INDENT 7.0 .TP .B tostring() -> str Returns ACIS data as one string for DXF R2000 to R2010. .UNINDENT .INDENT 7.0 .TP .B tobytes() -> bytes Returns ACIS data as joined bytes for DXF R2013 and later. .UNINDENT .INDENT 7.0 .TP .B set_text(text: str, sep: str = \(aq\en\(aq) -> None Set ACIS data from one string. .UNINDENT .UNINDENT .SS Circle .sp CIRCLE (\fI\%DXF Reference\fP) center at location \fBdxf.center\fP and radius of \fBdxf.radius\fP\&. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqCIRCLE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_circle()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.radius Radius of circle (float) .UNINDENT .INDENT 7.0 .TP .B vertices(angle: Iterable[float]) -> Iterable[Vector] Yields vertices of the circle for iterable \fIangles\fP in WCS. This method takes into account a local OCS. .INDENT 7.0 .TP .B Parameters \fBangles\fP – iterable of angles in OCS as degrees, angle goes counter clockwise around the extrusion vector, ocs x\-axis = 0 deg. .UNINDENT .sp New in version 0.11. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Circle Transform CIRCLE entity by transformation matrix \fIm\fP inplace. .sp Raises \fBNonUniformScalingError()\fP for non uniform scaling. .sp New in version 0.13. .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). .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B to_ellipse(replace=True) -> Ellipse Convert CIRCLE/ARC to an \fBEllipse\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 .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B to_spline(replace=True) -> Spline Convert CIRCLE/ARC to a \fBSpline\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 .sp New in version 0.13. .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 .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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{ Common graphical DXF attributes T} _ .TE .SS Factory Functions .TS center; |l|l|. _ T{ \fI\%Linear and Rotated Dimension (DXF)\fP T} T{ \fBadd_linear_dim()\fP T} _ T{ \fI\%Aligned Dimension (DXF)\fP T} T{ \fBadd_aligned_dim()\fP T} _ T{ \fI\%Angular Dimension (DXF)\fP T} T{ \fBadd_angular_dim()\fP (not implemented) T} _ T{ \fI\%Angular 3P Dimension (DXF)\fP T} T{ \fBadd_angular_3p_dim()\fP (not implemented) T} _ T{ \fI\%Diameter Dimension (DXF)\fP T} T{ \fBadd_diameter_dim()\fP T} _ T{ \fI\%Radius Dimension (DXF)\fP T} T{ \fBadd_radius_dim()\fP T} _ T{ \fI\%Ordinate Dimension (DXF)\fP T} T{ \fBadd_ordinate_dim()\fP (not implemented) 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, else AutoCAD will not open the DXF drawing. BricsCAD will render the DIMENSION entity by itself, if the graphical representation is not present, but uses the BLOCK instead of rendering, if it is present. .UNINDENT .INDENT 7.0 .TP .B dxf.dimstyle Dimension style (\fBDimStyle\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 \fBezdxf.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 WCS) .sp Linear and rotated dimension: \fBdxf.defpoint\fP specifies the dimension line location. .sp Arc and angular dimension: \fBdxf.defpoint\fP and \fBdxfdefpoint4\fP specify the endpoints of the line used to determine the second extension line. .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint2 Definition point for linear and angular dimensions. (3D Point in WCS) .sp Linear and rotated dimension: The \fBdxf.defpoint2\fP specifies the start point of the first extension line. .sp 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 .INDENT 7.0 .TP .B dxf.defpoint3 Definition point for linear and angular dimensions. (3D Point in WCS) .sp Linear and rotated dimension: The \fBdxf.defpoint3\fP specifies the start point of the second extension line. .sp 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 .INDENT 7.0 .TP .B dxf.defpoint4 Definition point for diameter, radius, and angular dimensions. (3D Point in WCS) .sp Arc and angular dimension: \fBdxf.defpoint\fP and \fBdxf.defpoint4\fP specify the endpoints of the line used to determine the second extension line. .UNINDENT .INDENT 7.0 .TP .B dxf.defpoint5 Point defining dimension arc for angular dimensions, specifies the location of the dimension line arc. (3D Point in OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.angle 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 OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.insert Insertion point for clones of a linear dimensions—Baseline and Continue. (3D Point in OCS) .sp This value is used by CAD application (Baseline and Continue) and ignored by \fIezdxf\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.attachment_point Text attachment point (int, DXF R2000), default value is \fB5\fP\&. .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 \fB1\fP\&. .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 \fB0.25\fP to \fB4.00\fP\&. .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 \fB\(aq<>\(aq\fP, the dimension measurement is drawn as the text, if \fB\(aq \(aq\fP (one blank space), the text is suppressed. Anything else is drawn as the text. .UNINDENT .INDENT 7.0 .TP .B dxf.oblique_angle Linear dimension types with an oblique angle have an optional \fBdxf.oblique_angle\fP\&. .sp When added to the rotation \fBdxf.angle\fP of the linear dimension, it gives the angle of the extension lines. .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 dimtype \fI\%dxf.dimtype\fP without binary flags (32, 62, 128). .UNINDENT .INDENT 7.0 .TP .B get_dim_style() -> DimStyle Returns the associated \fBDimStyle\fP entity. .UNINDENT .INDENT 7.0 .TP .B get_geometry_block() -> Optional[BlockLayout] Returns \fBBlockLayout\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() -> Union[float, ezdxf.math.vector.Vector] Returns the actual dimension measurement in WCS 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() Render graphical representation as anonymous block. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Dimension Transform DIMENSION entity by transformation matrix \fIm\fP inplace. .sp Raises \fBNonUniformScalingError()\fP for non uniform scaling. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterable[DXFGraphic] Yields ‘virtual’ parts of DIMENSION as basic DXF entities like LINE, ARC or TEXT. .sp This 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: BaseLayout = None) -> EntityQuery Explode parts of DIMENSION as basic DXF entities like LINE, ARC or TEXT into target layout, if target layout is \fBNone\fP, the target layout is the layout of the DIMENSION. .sp Returns an \fBEntityQuery\fP container with all DXF primitives. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for DXF parts, \fBNone\fP for same layout as source entity. .UNINDENT .UNINDENT .UNINDENT .SS DimStyleOverride .sp All of the \fBDimStyle\fP attributes can be overridden for each \fI\%Dimension\fP entity individually. .sp The \fI\%DimStyleOverride\fP class manages all the complex dependencies between \fBDimStyle\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 \fBDimStyle\fP entity. .UNINDENT .INDENT 7.0 .TP .B dimstyle_attribs Contains all overridden attributes of \fI\%dimension\fP, as a \fBdict\fP with \fBDimStyle\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 \fBDimStyle\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! Does not catch invalid attributes names! Look into 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’. .INDENT 7.0 .TP .B Returns tuple of [dimblk1, dimblk2] .TP .B Return type Tuple[str, str] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_arrows(blk: str = None, blk1: str = None, blk2: str = None, ldrblk: str = None, size: float = 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, valign: str = None, vshift: float = 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, hfactor: float = None, align: str = None, dec: int = None, leading_zeros: bool = None, trailing_zeros: bool = 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 “TOP”, “MIDDLE”, “BOTTOM” .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 False .IP \(bu 2 \fBtrailing_zeros\fP – suppress trailing zeros for decimal dimensions if False .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_limits(upper: float, lower: float, hfactor: float = None, dec: int = None, leading_zeros: bool = None, trailing_zeros: bool = 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 lower 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, required DXF R2000+ .IP \(bu 2 \fBleading_zeros\fP – suppress leading zeros for decimal dimensions if False, required DXF R2000+ .IP \(bu 2 \fBtrailing_zeros\fP – suppress trailing zeros for decimal dimensions if False, required DXF R2000+ .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_text_format(prefix: str = \(aq\(aq, postfix: str = \(aq\(aq, rnd: float = None, dec: int = None, sep: str = None, leading_zeros: bool = None, trailing_zeros: bool = 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 False .IP \(bu 2 \fBtrailing_zeros\fP – suppress trailing zeros for decimal dimensions if False .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_dimline_format(color: int = None, linetype: str = None, lineweight: int = None, extension: float = None, disable1: bool = None, disable2: bool = 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, lineweight: int = None, extension: float = None, offset: float = None, fixed_length: float = 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, 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 .IP \(bu 2 \fBdisable\fP – disable extension line 1 if True .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_extline2(linetype: str = 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 .IP \(bu 2 \fBdisable\fP – disable extension line 2 if True .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_text(text: str = \(aq<>\(aq) -> None Set dimension text. .INDENT 7.0 .INDENT 3.5 .INDENT 0.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 else use “text” literally .UNINDENT .UNINDENT .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: Vertex, 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 (Vertex) .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: Vertex) -> 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: UCS = None, discard=False) -> BaseDimensionRenderer Initiate dimension line rendering process and also writes overridden dimension style attributes into the DSTYLE XDATA section. .sp For a friendly CAD applications like BricsCAD you can discard the dimension line rendering, because it is done automatically by BricsCAD, if no dimension rendering BLOCK is available and it is likely to get better results as by \fIezdxf\fP\&. .sp AutoCAD does not render DIMENSION entities automatically, so I rate 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 rendering done by \fIezdxf\fP (works with BricsCAD, but not tolerated by AutoCAD) .UNINDENT .TP .B Returns Rendering object used to render the DIMENSION entity for analytics .TP .B Return type BaseDimensionRenderer .UNINDENT .UNINDENT .UNINDENT .SS ArcDimension .sp The ARC_DIMENSION entity was introduced in DXF R2004 and is \fBnot\fP documented in the DXF reference. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.Dimension\fP T} _ T{ DXF type T} T{ \fB\(aqARC_DIMENSION\(aq\fP T} _ T{ factory function T} T{ \fBadd_arc_dim()\fP (not implemented) T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes T} _ T{ Required DXF version T} T{ DXF R2004 (\fB\(aqAC1018\(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.ArcDimension .INDENT 7.0 .TP .B dxf.ext_line1_point .UNINDENT .INDENT 7.0 .TP .B dxf.ext_line2_point .UNINDENT .INDENT 7.0 .TP .B dxf.arc_center .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 ELLIPSE (\fI\%DXF Reference\fP) with center point at location \fBdxf.center\fP and a major axis \fBdxf.major_axis\fP as vector. \fBdxf.ratio\fP is the ratio of minor axis to major axis. \fBdxf.start_param\fP and \fBdxf.end_param\fP defines the starting\- and the end point of the ellipse, a full ellipse goes from \fB0\fP to \fB2*pi\fP\&. The ellipse goes from starting\- to end param in counter clockwise direction. .sp \fBdxf.extrusion\fP is supported, but does not establish an OCS, but creates an 3D entity by extruding the base ellipse in direction of the \fBdxf.extrusion\fP vector. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqELLIPSE\(aq\fP T} _ T{ factory function T} T{ \fBadd_ellipse()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.major_axis Endpoint of major axis, relative to the \fBdxf.center\fP (Vector), default value is \fB(1, 0, 0)\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.ratio Ratio of minor axis to major axis (float), has to be in range from \fB0.000001\fP to \fB1\fP, default value is \fB1\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.start_param Start parameter (float), default value is \fB0\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.end_param End parameter (float), default value is \fB2*pi\fP\&. .UNINDENT .INDENT 7.0 .TP .B start_point Returns the start point of the ellipse in WCS. .sp New in version 0.11. .UNINDENT .INDENT 7.0 .TP .B end_point Returns the end point of the ellipse in WCS. .sp New in version 0.11. .UNINDENT .INDENT 7.0 .TP .B minor_axis Returns the minor axis of the ellipse as \fBVector\fP in WCS. .sp New in version 0.12. .UNINDENT .INDENT 7.0 .TP .B construction_tool() -> ConstructionEllipse Returns construction tool \fBezdxf.math.ConstructionEllipse\fP\&. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B apply_construction_tool(e: ConstructionEllipse) -> Ellipse Set ELLIPSE data from construction tool \fBezdxf.math.ConstructionEllipse\fP\&. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B vertices(params: Iterable[float]) -> Iterable[Vector] Yields vertices on ellipse for iterable \fIparams\fP in WCS. .INDENT 7.0 .TP .B Parameters \fBparams\fP – param values in the range from \fB0\fP to \fB2*pi\fP in radians, param goes counter clockwise around the extrusion vector, major_axis = local x\-axis = 0 rad. .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 from [0, 2pi). .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Ellipse Transform ELLIPSE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .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). .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B to_spline(replace=True) -> Spline Convert ELLIPSE to a \fBSpline\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 .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – modelspace\- , paperspace\- or block layout .IP \(bu 2 \fBreplace\fP – replace (delete) source entity by SPLINE entity if \fBTrue\fP .UNINDENT .UNINDENT .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B classmethod from_arc(entity: DXFGraphic) -> Ellipse Create a new ELLIPSE entity from ARC or CIRCLE entity. .sp The new SPLINE entity has no owner, no handle, is not stored in the entity database nor assigned to any layout! .sp New in version 0.13. .UNINDENT .UNINDENT .SS Hatch .sp The HATCH entity (\fI\%DXF Reference\fP) fills an enclosed area defined by one or more boundary paths with a hatch pattern, solid fill, or gradient fill. .sp All points in OCS as (x, y) tuples (\fI\%Hatch.dxf.elevation\fP is the z\-axis value). .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqHATCH\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_hatch()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 tut_hatch .UNINDENT .UNINDENT .sp Boundary paths helper 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 helper 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, better use: \fI\%Hatch.set_solid_fill()\fP T} _ T{ 0 T} T{ pattern fill, better use: \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 not handled by \fIezdxf\fP, you have to set the handles to the associated DXF entities by yourself. .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 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 \fB1\fP = double pattern size else \fB0\fP\&. (int) .UNINDENT .INDENT 7.0 .TP .B dxf.n_seed_points Count of seed points (better user: \fBget_seed_points()\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.elevation Z value represents the elevation height of the OCS\&. (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 List of \fB(x, y)\fP tuples. .UNINDENT .INDENT 7.0 .TP .B has_solid_fill \fBTrue\fP if hatch has a solid fill. (read only) .UNINDENT .INDENT 7.0 .TP .B has_pattern_fill \fBTrue\fP if hatch has a pattern fill. (read only) .UNINDENT .INDENT 7.0 .TP .B has_gradient_data \fBTrue\fP if hatch has a gradient fill. A hatch with gradient fill has also a solid fill. (read only) .UNINDENT .INDENT 7.0 .TP .B bgcolor Property background color as \fB(r, g, b)\fP tuple, rgb values in the range [0, 255] (read/write/del) .sp usage: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C color = hatch.bgcolor # get background color as (r, g, b) tuple hatch.bgcolor = (10, 20, 30) # set background color del hatch.bgcolor # delete background color .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_pattern_definition(lines: Sequence, factor: float = 1, angle: float = 0) -> None Setup hatch patten definition by a list of definition lines and a definition line is a 4\-tuple [angle, base_point, offset, dash_length_items], the pattern definition should be designed for scaling factor\(ga\(ga1\(ga\(ga and angle \fB0\fP\&. .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 angle: line angle in degrees .IP \(bu 2 base\-point: 2\-tuple (x, y) .IP \(bu 2 offset: 2\-tuple (dx, dy) .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 scaling factor .IP \(bu 2 \fBangle\fP – rotation angle in degrees .UNINDENT .UNINDENT .sp Changed in version 0.13: added \fIangle\fP argument .UNINDENT .INDENT 7.0 .TP .B set_pattern_scale(scale: float) -> None Set scaling of pattern definition to \fIscale\fP\&. .sp Starts always from the original base scaling, \fBset_pattern_scale(1)\fP reset the pattern scaling to the original appearance as defined by the pattern designer, but only if the the pattern attribute \fI\%dxf.pattern_scale\fP represents the actual scaling, it is not possible to recreate the original pattern scaling from the pattern definition itself. .INDENT 7.0 .TP .B Parameters \fBscale\fP – pattern scaling factor .UNINDENT .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B set_pattern_angle(angle: float) -> None Set rotation of pattern definition to \fIangle\fP in degrees. .sp Starts always from the original base rotation \fB0\fP, \fBset_pattern_angle(0)\fP reset the pattern rotation to the original appearance as defined by the pattern designer, but only if the the pattern attribute \fI\%dxf.pattern_angle\fP represents the actual rotation, it is not possible to recreate the original rotation from the pattern definition itself. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in degrees .UNINDENT .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B set_solid_fill(color: int = 7, style: int = 1, rgb: RGB = None) Set \fI\%Hatch\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 – ACI, (\fB0\fP = BYBLOCK; \fB256\fP = BYLAYER) .IP \(bu 2 \fBstyle\fP – hatch style (\fB0\fP = normal; \fB1\fP = outer; \fB2\fP = ignore) .IP \(bu 2 \fBrgb\fP – true color value as \fB(r, g, b)\fP tuple \- has higher priority than \fIcolor\(ga\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 Set \fI\%Hatch\fP to pattern fill mode. Removes all gradient related data. The pattern definition should be designed for scaling factor 1. .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 ACI .IP \(bu 2 \fBangle\fP – angle of pattern fill in degrees .IP \(bu 2 \fBscale\fP – pattern scaling as float .IP \(bu 2 \fBdouble\fP – double size flag .IP \(bu 2 \fBstyle\fP – hatch style (\fB0\fP = normal; \fB1\fP = outer; \fB2\fP = ignore) .IP \(bu 2 \fBpattern_type\fP – pattern type (\fB0\fP = user\-defined; \fB1\fP = predefined; \fB2\fP = 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: RGB = (0, 0, 0), color2: 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 Set \fI\%Hatch\fP to gradient fill mode and removes all pattern fill related data. Gradient support requires DXF DXF R2004. 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 \fB\(aqLINEAR\(aq\fP .IP \(bu 2 \fB\(aqCYLINDER\(aq\fP .IP \(bu 2 \fB\(aqINVCYLINDER\(aq\fP .IP \(bu 2 \fB\(aqSPHERICAL\(aq\fP .IP \(bu 2 \fB\(aqINVSPHERICAL\(aq\fP .IP \(bu 2 \fB\(aqHEMISPHERICAL\(aq\fP .IP \(bu 2 \fB\(aqINVHEMISPHERICAL\(aq\fP .IP \(bu 2 \fB\(aqCURVED\(aq\fP .IP \(bu 2 \fB\(aqINVCURVED\(aq\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor1\fP – \fB(r, g, b)\fP tuple for first color, rgb values as int in the range [0, 255] .IP \(bu 2 \fBcolor2\fP – \fB(r, g, b)\fP 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 – \fB1\fP for gradient from \fIcolor1\fP to tinted \fIcolor1\(ga\fP .IP \(bu 2 \fBtint\fP – determines the tinted target \fIcolor1\fP for a one color gradient. (valid range \fB0.0\fP to \fB1.0\fP) .IP \(bu 2 \fBname\fP – name of gradient type, default \fB\(aqLINEAR\(aq\fP .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 \fB(x, y)\fP tuples. I don’t know why there can be more than one seed point. All points in OCS (\fI\%Hatch.dxf.elevation\fP is the Z value) .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Hatch Transform HATCH entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B associate(path: Union[PolylinePath, EdgePath], entities: Iterable[DXFEntity]) 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. .sp New in version 0.13. .UNINDENT .UNINDENT .SS Hatch Boundary Helper 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 add_polyline_path(path_vertices, is_closed=1, flags=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 – list of polyline vertices as \fB(x, y)\fP or \fB(x, y, bulge)\fP tuples. .IP \(bu 2 \fBis_closed\fP – \fB1\fP for a closed polyline else \fB0\fP .IP \(bu 2 \fBflags\fP – external(\fB1\fP) or outermost(\fB16\fP) or default (\fB0\fP) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_edge_path(flags=1) -> EdgePath Create and add a new \fI\%EdgePath\fP object. .INDENT 7.0 .TP .B Parameters \fBflags\fP – external(\fB1\fP) or outermost(\fB16\fP) or default (\fB0\fP) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B polyline_to_edge_path(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 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.PolylinePath A polyline as hatch boundary path. .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 tut_hatch: .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 \fB(x, y, bulge)\fP 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: Sequence[Sequence[float]], is_closed: bool = True) -> None Set new \fIvertices\fP as new polyline path, a vertex has to be a \fB(x, y)\fP or a \fB(x, y, bulge)\fP 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. AutoCAD in this regard is very picky. \fIezdxf\fP performs no checks on gaps between the edges. .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, end) -> 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, \fB(x, y)\fP tuple .IP \(bu 2 \fBend\fP – end point of line, \fB(x, y)\fP tuple .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_arc(center, radius=1., start_angle=0., end_angle=360., ccw: bool = True) -> ArcEdge Add an \fI\%ArcEdge\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of arc, \fB(x, y)\fP tuple .IP \(bu 2 \fBradius\fP – radius of circle .IP \(bu 2 \fBstart_angle\fP – start angle of arc in degrees .IP \(bu 2 \fBend_angle\fP – end angle of arc in degrees .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, major_axis_vector=(1., 0.), minor_axis_length=1., start_angle=0., end_angle=360., ccw: bool = True) -> EllipsePath Add an \fI\%EllipseEdge\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP – center point of ellipse, \fB(x, y)\fP tuple .IP \(bu 2 \fBmajor_axis\fP – vector of major axis as \fB(x, y)\fP tuple .IP \(bu 2 \fBratio\fP – ratio of minor axis to major axis as float .IP \(bu 2 \fBstart_angle\fP – start angle of arc in degrees .IP \(bu 2 \fBend_angle\fP – end angle of arc in degrees .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=None, control_points=None, knot_values=None, weights=None, degree=3, rational=0, periodic=0) -> SplinePath 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 \fB(x, y)\fP tuples .IP \(bu 2 \fBcontrol_points\fP – affects the shape of the spline, mandatory and AutoCAD crashes on invalid data. list of \fB(x, y)\fP 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: \fBezdxf.math.uniform_knot_vector()\fP, \fBezdxf.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 – \fB1\fP for periodic spline, \fB0\fP 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.LineEdge Straight boundary edge. .INDENT 7.0 .TP .B start Start point as \fB(x, y)\fP tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B end End point as \fB(x, y)\fP tuple. (read/write) .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.ArcEdge Arc as boundary edge. .INDENT 7.0 .TP .B center Center point of arc as \fB(x, y)\fP 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 degrees. (read/write) .UNINDENT .INDENT 7.0 .TP .B end_angle Arc end angle 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. .INDENT 7.0 .TP .B major_axis_vector Ellipse major axis vector as \fB(x, y)\fP 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 degrees. (read/write) .UNINDENT .INDENT 7.0 .TP .B end_angle Ellipse end angle 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 degree Spline degree as int. (read/write) .UNINDENT .INDENT 7.0 .TP .B rational \fB1\fP for rational spline else \fB0\fP\&. (read/write) .UNINDENT .INDENT 7.0 .TP .B periodic \fB1\fP for periodic spline else \fB0\fP\&. (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 \fB(x, y)\fP tuples. (read/write) .UNINDENT .INDENT 7.0 .TP .B fit_points List of fit points as \fB(x, y)\fP 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 \fB(x, y)\fP tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B end_tangent Spline end tangent (vector) as \fB(x, y)\fP tuple. (read/write) .UNINDENT .UNINDENT .SS Hatch Pattern Definition Helper 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: Vertex = (0, 0), offset: Vertex = (0, 0), dash_length_items: Iterable[float] = 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 .sp New in version 0.13. .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 \fB(x, y)\fP tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B offset Offset as \fB(x, y)\fP tuple. (read/write) .UNINDENT .INDENT 7.0 .TP .B dash_length_items List of dash length items (item > \fB0\fP is line, < \fB0\fP is gap, \fB0.0\fP = dot). (read/write) .UNINDENT .UNINDENT .SS Hatch Gradient Fill Helper Classes .INDENT 0.0 .TP .B class ezdxf.entities.Gradient .INDENT 7.0 .TP .B color1 First rgb color as \fB(r, g, b)\fP tuple, rgb values in range 0 to 255. (read/write) .UNINDENT .INDENT 7.0 .TP .B color2 Second rgb color as \fB(r, g, b)\fP tuple, rgb values in range 0 to 255. (read/write) .UNINDENT .INDENT 7.0 .TP .B one_color If \fI\%one_color\fP is \fB1\fP \- 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 tut_hatch_pattern .UNINDENT .UNINDENT .SS Image .sp Add a raster IMAGE (\fI\%DXF Reference\fP) to the DXF file, the file itself is not embedded into the DXF file, it is always a separated file. The IMAGE entity is like a block reference, you can use it multiple times to add the image on different locations with different scales and rotations. But therefore you need a also a IMAGEDEF entity, see \fBImageDef\fP\&. \fIezdxf\fP creates only images in the xy\-plan, you can place images in the 3D space too, but then you have to set the \fI\%Image.dxf.u_pixel\fP and the \fI\%Image.dxf.v_pixel\fP vectors by yourself. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqIMAGE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_image()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 WCS). .UNINDENT .INDENT 7.0 .TP .B dxf.u_pixel U\-vector of a single pixel (points along the visual bottom of the image, starting at the insertion point) as \fB(x, y, z)\fP tuple .UNINDENT .INDENT 7.0 .TP .B dxf.v_pixel V\-vector of a single pixel (points along the visual left side of the image, starting at the insertion point) as \fB(x, y, z)\fP tuple .UNINDENT .INDENT 7.0 .TP .B dxf.image_size Image size in pixels as \fB(x, y)\fP tuple .UNINDENT .INDENT 7.0 .TP .B dxf.image_def_handle Handle to the image definition entity, see \fBImageDef\fP .UNINDENT .INDENT 7.0 .TP .B dxf.flags .TS center; |l|l|l|. _ T{ \fI\%Image.dxf.flags\fP T} T{ Value T} T{ Description T} _ 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{ \fB0\fP T} T{ clipping off T} _ T{ \fB1\fP T} T{ clipping on T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.brightness Brightness value (0\-100; default = \fB50\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.contrast Contrast value (0\-100; default = \fB50\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.fade Fade value (0\-100; default = \fB0\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.clipping_boundary_type 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, maintained by \fIezdxf\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.clip_mode Clip mode (DXF R2010): .TS center; |l|l|. _ T{ 0 T} T{ Outside T} _ T{ 1 T} T{ Inside T} _ .TE .UNINDENT .INDENT 7.0 .TP .B boundary_path A list of vertices as pixel coordinates, Two vertices describe a rectangle, lower left corner is \fB(\-0.5, \-0.5)\fP and upper right corner is \fB(ImageSizeX\-0.5, ImageSizeY\-0.5)\fP, 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 \fBImageDef\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[Vertex]) -> 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[Vector] Returns the boundary/clipping path in WCS coordinates. .sp New in version 0.14. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Image Transform IMAGE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .UNINDENT .SS Leader .sp The LEADER entity (\fI\%DXF Reference\fP) 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. .sp \fI\%Leader\fP shares its styling infrastructure with \fBDimension\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 . .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqLEADER\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_leader()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 (\fBMText\fP, \fBTolerance\fP, or \fBInsert\fP entity) .UNINDENT .INDENT 7.0 .TP .B dxf.normal_vector Extrusion vector? default = \fB(0, 0, 1)\fP\&. .UNINDENT .INDENT 7.0 .TP .B \&.dxf.horizontal_direction \fIHorizontal\fP direction for leader, default = \fB(1, 0, 0)\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.leader_offset_block_ref Offset of last leader vertex from block reference insertion point, default = \fB(0, 0, 0)\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.leader_offset_annotation_placement Offset of last leader vertex from annotation placement point, default = \fB(0, 0, 0)\fP\&. .UNINDENT .INDENT 7.0 .TP .B vertices List of \fBVector\fP objects, representing the vertices of the leader (3D Point in WCS). .UNINDENT .INDENT 7.0 .TP .B set_vertices(vertices: Iterable[Vertex]) Set vertices of the leader, vertices is an iterable of \fB(x, y [,z])\fP tuples or \fBVector\fP\&. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Leader Transform LEADER entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterable[Union[Line, Arc]] Yields ‘virtual’ parts of LEADER as DXF primitives. .sp This 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. .sp New in version 0.14. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: BaseLayout = None) -> EntityQuery Explode parts of LEADER as DXF primitives into target layout, if target layout is \fBNone\fP, the target layout is the layout of the LEADER. .sp Returns an \fBEntityQuery\fP container with all DXF parts. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – target layout for DXF parts, \fBNone\fP for same layout as source entity. .UNINDENT .sp New in version 0.14. .UNINDENT .UNINDENT .SS Line .sp LINE (\fI\%DXF Reference\fP) entity is a 3D line from \fI\%Line.dxf.start\fP to \fI\%Line.dxf.end\fP\&. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqLINE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_line()\fP T} _ T{ Inherited DXF Attributes T} T{ Common graphical DXF attributes 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 WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.end end point of line (2D/3D Point in WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.thickness Line thickness in 3D space in direction \fBextrusion\fP, default value is \fB0\fP\&. This value should not be confused with the \fBlineweight\fP value. .UNINDENT .INDENT 7.0 .TP .B dxf.extrusion extrusion vector, default value is \fB(0, 0, 1)\fP .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Line Transform LINE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .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. .sp New in version 0.13. .UNINDENT .UNINDENT .SS LWPolyline .sp The LWPOLYLINE entity (\fI\%DXF Reference\fP) is defined as a single graphic entity, which differs from the old\-style \fBPolyline\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 in OCS as \fB(x, y)\fP tuples (\fI\%LWPolyline.dxf.elevation\fP is the z\-axis value). .sp Changed in version 0.8.9: \fI\%LWPolyline\fP stores point data as packed data (\fBarray.array\fP). .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqLWPOLYLINE\(aq\fP T} _ T{ factory function T} T{ \fBadd_lwpolyline()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 \fBPolyline\fP and \fI\%LWPolyline\fP entities. The bulge value defines the ratio of the arc sagitta (versine) to half line segment length, a bulge value of \fB1\fP 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 (> \fB0\fP): bulge is right of line (counter clockwise) .IP \(bu 2 negative value (< \fB0\fP): bulge is left of line (clockwise) .IP \(bu 2 \fB0\fP = 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 \fB0\fP\&. .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 tut_lwpolyline and bulge_related_functions .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 OCS z\-axis value for all polyline points, default=0 .UNINDENT .INDENT 7.0 .TP .B dxf.flags Constants defined in \fBezdxf.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{ ??? T} _ .TE .UNINDENT .INDENT 7.0 .TP .B dxf.const_width Constant line width (float), default value is \fB0\fP\&. .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 closed \fBTrue\fP if polyline is closed. A closed polyline has a connection from the last vertex to the first vertex. (read/write) .UNINDENT .INDENT 7.0 .TP .B has_arc Returns \fBTrue\fP if LWPOLYLINE has an arc segment. .UNINDENT .INDENT 7.0 .TP .B has_width Returns \fBTrue\fP if LWPOLYLINE has any segment with width attributes or DXF attribute const_width != 0. .sp New in version 0.14. .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 \fB0\fP if not present, supports extended slicing. Point format is fixed as \fB\(aqxyseb\(aq\fP\&. .sp All coordinates in OCS\&. .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 \fB0\fP or left off the default value is used. If the bulge value is left off, bulge is \fB0\fP by default (straight line). Does NOT support extend slicing. Point format is fixed as \fB\(aqxyseb\(aq\fP\&. .sp All coordinates in OCS\&. .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__() -> Iterable[Tuple[float, float, float, float, float]] Returns iterable of tuples (x, y, start_width, end_width, bulge). .UNINDENT .INDENT 7.0 .TP .B close(state: bool = True) -> None Compatibility interface to \fBPolyline\fP\&. .UNINDENT .INDENT 7.0 .TP .B vertices() -> Iterable[Tuple[float, float]] Returns iterable of all polyline points as (x, y) tuples in OCS (\fI\%dxf.elevation\fP is the z\-axis value). .UNINDENT .INDENT 7.0 .TP .B vertices_in_wcs() -> Iterable[Vertex] Returns iterable of all polyline points as Vector(x, y, z) in WCS\&. .UNINDENT .INDENT 7.0 .TP .B append(point: Sequence[float], format: str = \(aqxyseb\(aq) -> None Append \fIpoint\fP to polyline, \fIformat\(ga\fP specifies a user defined point format. .sp All coordinates in OCS\&. .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 \fB\(aqxyseb\(aq\fP, see: \fI\%format codes\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append_points(points: Iterable[Sequence[float]], format: str = \(aqxyseb\(aq) -> None Append new \fIpoints\fP to polyline, \fIformat\fP specifies a user defined point format. .sp All coordinates in OCS\&. .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 \fB\(aqxyseb\(aq\fP, see: \fI\%format codes\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B insert(pos: int, point: Sequence[float], format: str = \(aqxyseb\(aq) -> None Insert new point in front of positions \fIpos\fP, \fIformat\fP specifies a user defined point format. .sp All coordinates in OCS\&. .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 = \(aqxyseb\(aq) -> List[Sequence[float]] Returns all points as list of tuples, format specifies a user defined point format. .sp All points in OCS 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 \fB\(aqxyseb\(aq\fP, see \fI\%format codes\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_points(points: Iterable[Sequence[float]], format: str = \(aqxyseb\(aq) -> None Remove all points and append new \fIpoints\fP\&. .sp All coordinates in OCS\&. .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 \fB\(aqxyseb\(aq\fP, see \fI\%format codes\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B points(format: str = \(aqxyseb\(aq) -> List[Sequence[float]] Context manager for polyline points. Returns a standard Python list of points, according to the format string. .sp All coordinates in OCS\&. .INDENT 7.0 .TP .B Parameters \fBformat\fP – format string, see \fI\%format codes\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> LWPolyline Transform LWPOLYLINE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterable[Union[Line, Arc]] Yields ‘virtual’ parts of LWPOLYLINE as LINE or ARC entities. .sp This 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: BaseLayout = None) -> EntityQuery Explode parts of LWPOLYLINE as LINE or ARC entities into target layout, if target layout is \fBNone\fP, the target layout is the layout of the LWPOLYLINE. .sp Returns an \fBEntityQuery\fP container with all DXF parts. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtarget_layout\fP – target layout for DXF parts, \fBNone\fP for same layout .IP \(bu 2 \fBsource entity.\fP (\fIas\fP) – .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Mesh .sp The MESH entity (\fI\%DXF Reference\fP) is a 3D mesh similar to the \fBPolyface\fP entity. .sp All vertices in WCS as (x, y, z) tuples .sp Changed in version 0.8.9: \fI\%Mesh\fP stores vertices, edges, faces and creases as packed data. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqMESH\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_mesh()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 tut_mesh and helper classes: \fBMeshBuilder\fP, \fBMeshVertexMerger\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 \fB0\fP = off, \fB1\fP = on .UNINDENT .INDENT 7.0 .TP .B dxf.subdivision_levels \fB0\fP for no smoothing else integer greater than \fB0\fP\&. .UNINDENT .INDENT 7.0 .TP .B vertices Vertices as list like \fBVertexArray\fP\&. (read/write) .UNINDENT .INDENT 7.0 .TP .B edges Edges as list like \fBTagArray\fP\&. (read/write) .UNINDENT .INDENT 7.0 .TP .B faces Faces as list like \fBTagList\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() -> ezdxf.entities.mesh.MeshData Context manager various mesh data, returns \fI\%MeshData\fP\&. .sp Despite that vertices, edge and faces since \fIezdxf\fP v0.8.9 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: Matrix44) -> Mesh Transform MESH entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .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 standard Python list with (v1, v2) tuples (read/write) .sp Each edge consist of exact two vertex indices (= index in \fI\%vertices\fP). .UNINDENT .INDENT 7.0 .TP .B edge_crease_values A standard Python list of float values, one value for each edge. (read/write) .UNINDENT .INDENT 7.0 .TP .B add_face(vertices: Iterable[Sequence[float]]) -> 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(vertices: Sequence[Sequence[float]]) -> Sequence[int] Add an edge by coordinates, vertices is a list of two \fB(x, y, z)\fP tuples. .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 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 tut_mtext .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqMTEXT\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_mtext()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 OCS) .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 \fBezdxf.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 = \fB\(aqSTANDARD\(aq\fP .UNINDENT .INDENT 7.0 .TP .B dxf.text_direction X\-axis direction vector in WCS (3D Point); default value is \fB(1, 0, 0)\fP; 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 = \fB0\fP .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 \fB0.25\fP to \fB4.00\fP (float). .sp Constants defined in \fBezdxf.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: \fIbg_fill\fP, \fIbg_fill_color\fP else AutoCAD complains .sp Better use \fBset_bg_color()\fP .UNINDENT .INDENT 7.0 .TP .B dxf.bg_fill_color Background fill color as ACI (DXF R2007) .sp Better 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 \fBdxf.bg_fill_color\fP must be present, else AutoCAD complains. .sp Better 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 \fBdxf.bg_fill_color\fP must be present, else AutoCAD complains. .sp Better use \fBset_bg_color()\fP .UNINDENT .INDENT 7.0 .TP .B dxf.transparency Transparency of background fill color (DXF R2007), not supported by AutoCAD or BricsCAD. .UNINDENT .INDENT 7.0 .TP .B text MTEXT content as string (read/write). .sp Line endings \fB\en\fP will be replaced by the MTEXT line endings \fB\eP\fP at DXF export, but \fBnot\fP vice versa \fB\eP\fP by \fB\en\fP at DXF file loading. .UNINDENT .INDENT 7.0 .TP .B set_location(insert: Vertex, rotation: float = None, attachment_point: int = None) -> MText Set 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 Get text rotation in degrees, independent if it is defined by \fI\%dxf.rotation\fP or \fI\%dxf.text_direction\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_rotation(angle: float) -> ezdxf.entities.mtext.MText Set attribute \fBrotation\fP to \fIangle\fP (in degrees) and deletes \fI\%dxf.text_direction\fP if present. .UNINDENT .INDENT 7.0 .TP .B set_bg_color(color: Optional[Union[int, str, Tuple[int, int, int]]], scale: float = 1.5) Set background color as ACI value or as name string or as RGB tuple \fB(r, g, b)\fP\&. .sp Use special color name \fBcanvas\fP, to set background color to canvas background color. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcolor\fP – color as ACI, string or RGB tuple .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. .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 set_font(name: str, bold: bool = False, italic: bool = False, codepage: int = 1252, pitch: int = 0) -> None Append font change (e.g. \fB\(aq\eFkroeger|b0|i0|c238|p10\(aq\fP ) to existing content (\fI\%text\fP attribute). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – font name .IP \(bu 2 \fBbold\fP – flag .IP \(bu 2 \fBitalic\fP – flag .IP \(bu 2 \fBcodepage\fP – character codepage .IP \(bu 2 \fBpitch\fP – font size .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_color(color_name: str) -> None Append text color change to existing content, \fIcolor_name\fP as \fBred\fP, \fByellow\fP, \fBgreen\fP, \fBcyan\fP, \fBblue\fP, \fBmagenta\fP or \fBwhite\fP\&. .UNINDENT .INDENT 7.0 .TP .B add_stacked_text(upr: str, lwr: str, t: str = \(aq^\(aq) -> None Add stacked text \fIupr\fP over \fIlwr\fP, \fIt\fP defines the kind of stacking: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C "^": vertical stacked without divider line, e.g. \eSA^B: A B "/": vertical stacked with divider line, e.g. \eSX/Y: X \- Y "#": diagonal stacked, with slanting divider line, e.g. \eS1#4: 1/4 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B plain_text(split=False) -> Union[List[str], str] Returns text content without formatting codes. .INDENT 7.0 .TP .B Parameters \fBsplit\fP – returns list of strings splitted at line breaks if \fBTrue\fP else returns a single string. .UNINDENT .sp New in version 0.11.1. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> MText Transform MTEXT entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .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 overstrike T} _ T{ \eo T} T{ Stop overstrike 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{ \epxi T} T{ Control codes for bullets, numbered paragraphs and columns T} _ T{ \eX T} T{ Paragraph wrap on the dimension line (only in dimensions) T} _ T{ \eQ T} T{ Slanting (obliquing) text by angle \- e.g. \eQ30; T} _ T{ \eH T} T{ Text height \- e.g. \eH3x; T} _ T{ \eW T} T{ Text width \- e.g. \eW0.8x; T} _ T{ \eF T} T{ Font selection e.g. \eFgdt;o \- GDT\-tolerance T} _ T{ \eS T} T{ Stacking, fractions e.g. \eSA^B or \eSX/Y or \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{ \eT T} T{ Tracking, char.spacing \- e.g. \eT2; T} _ T{ \e~ T} T{ Non\-wrapping space, hard 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 MText: .TS center; |l|l|. _ T{ Constant T} T{ Description T} _ T{ UNDERLINE_START T} T{ start underline text (\fBb += b.UNDERLINE_START\fP) T} _ T{ UNDERLINE_STOP T} T{ stop underline text (\fBb += b.UNDERLINE_STOP\fP) T} _ T{ UNDERLINE T} T{ underline text (\fBb += b.UNDERLINE % "Text"\fP) T} _ T{ OVERSTRIKE_START T} T{ start overstrike T} _ T{ OVERSTRIKE_STOP T} T{ stop overstrike T} _ T{ OVERSTRIKE T} T{ overstrike text T} _ T{ STRIKE_START T} T{ start strike trough T} _ T{ STRIKE_STOP T} T{ stop strike trough T} _ T{ STRIKE T} T{ strike trough text T} _ T{ GROUP_START T} T{ start of group T} _ T{ GROUP_END T} T{ end of group T} _ T{ GROUP T} T{ group text T} _ T{ NEW_LINE T} T{ start in new line (\fBb += "Text" + b.NEW_LINE\fP) T} _ T{ NBSP T} T{ none breaking space (\fBb += "Python" + b.NBSP + "3.4"\fP) T} _ .TE .SS Point .sp POINT (\fI\%DXF Reference\fP) at location \fBdxf.point\fP\&. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqPOINT\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_point()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 WCS) .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: Matrix44) -> Point Transform POINT entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .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. .sp New in version 0.13. .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 dxftype of \fB\(aqPOLYLINE\(aq\fP\&. Detect POLYLINE type by \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 OCS\&. .sp For 3D entities all vertices in WCS\&. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqPOLYLINE\(aq\fP T} _ T{ 2D factory function T} T{ \fBezdxf.layouts.BaseLayout.add_polyline2d()\fP T} _ T{ 3D factory function T} T{ \fBezdxf.layouts.BaseLayout.add_polyline3d()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 \fI\%Vertex\fP entities are stored in a standard Python list \fI\%Polyline.vertices\fP\&. Vertices can be retrieved and deleted by direct access to \fI\%Polyline.vertices\fP attribute: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C # delete first and second vertex del polyline.vertices[:2] .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxf.elevation Elevation point, the X and Y values are always \fB0\fP, and the Z value is the polyline’s elevation (3D Point in OCS when 2D, WCS when 3D). .UNINDENT .INDENT 7.0 .TP .B dxf.flags Constants defined in \fBezdxf.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 = \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.default_end_width Default line end width (float); default = \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.m_count Polymesh M vertex count (int); default = \fB1\fP .UNINDENT .INDENT 7.0 .TP .B dxf.n_count Polymesh N vertex count (int); default = \fB1\fP .UNINDENT .INDENT 7.0 .TP .B dxf.m_smooth_density Smooth surface M density (int); default = \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.n_smooth_density Smooth surface N density (int); default = \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.smooth_type Curves and smooth surface type (int); default=0, see table below .sp Constants for \fBsmooth_type\fP defined in \fBezdxf.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. .sp New in version 0.14. .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) -> ezdxf.entities.polyline.DXFVertex Get \fI\%Vertex\fP entity at position \fIpos\fP, supports \fBlist\fP slicing. .UNINDENT .INDENT 7.0 .TP .B points() -> Iterable[ezdxf.math.vector.Vector] Returns iterable of all polyline vertices as \fB(x, y, z)\fP tuples, not as \fI\%Vertex\fP objects. .UNINDENT .INDENT 7.0 .TP .B append_vertex(point: Vertex, dxfattribs: dict = 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 \fB(x, y[, z])\fP 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[Vertex], dxfattribs: Dict = 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 \fB(x, y[, z])\fP tuples .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for \fI\%Vertex\fP class .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append_formatted_vertices(points: Iterable[Vertex], format: str = \(aqxy\(aq, dxfattribs: Dict = 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 \fB\(aqxy\(aq\fP, see: format codes .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for \fI\%Vertex\fP class .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B insert_vertices(pos: int, points: Iterable[Vertex], dxfattribs: dict = 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 \fB(x, y[, z])\fP 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: Matrix44) -> Polyline Transform POLYLINE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B virtual_entities() -> Iterable[Union[Line, Arc]] Yields ‘virtual’ parts of POLYLINE as LINE, ARC or 3DFACE primitives. .sp This 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. .sp New in version 0.12. .UNINDENT .INDENT 7.0 .TP .B explode(target_layout: BaseLayout = None) -> EntityQuery Explode POLYLINE as DXF LINE, ARC or 3DFACE primitives into target layout, if the target layout is \fBNone\fP, the target layout is the layout of the POLYLINE entity . Returns an \fBEntityQuery\fP container including all DXF primitives. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtarget_layout\fP – target layout for DXF primitives, \fBNone\fP for same .IP \(bu 2 \fBas source entity.\fP (\fIlayout\fP) – .UNINDENT .UNINDENT .sp New in version 0.12. .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{ \fBezdxf.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{ Common graphical DXF attributes T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Vertex .INDENT 7.0 .TP .B dxf.location Vertex location (2D/3D Point OCS when 2D, WCS when 3D) .UNINDENT .INDENT 7.0 .TP .B dxf.start_width Line segment start width (float); default = \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.end_width Line segment end width (float); default = \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.bulge bulge value (float); default = \fB0\fP\&. .sp The bulge value is used to create arc shaped line segments. .UNINDENT .INDENT 7.0 .TP .B dxf.flags Constants defined in \fBezdxf.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 .sp New in version 0.14. .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{ \fBezdxf.layouts.BaseLayout.add_polymesh()\fP T} _ T{ Inherited DXF Attributes T} T{ Common graphical DXF attributes T} _ .TE .INDENT 0.0 .TP .B class ezdxf.entities.Polymesh A polymesh is a grid of \fBm_count\fP x \fBn_count\fP vertices, every vertex has its own \fB(x, y, z)\fP location. The \fI\%Polymesh\fP is an subclass of \fI\%Polyline\fP, DXF type is also \fB\(aqPOLYLINE\(aq\fP but \fBget_mode()\fP returns \fB\(aqAcDbPolygonMesh\(aq\fP\&. .INDENT 7.0 .TP .B get_mesh_vertex(pos: Tuple[int, int]) -> ezdxf.entities.polyline.DXFVertex Get location of a single mesh vertex. .INDENT 7.0 .TP .B Parameters \fBpos\fP – 0\-based \fB(row, col)\fP tuple, position of mesh vertex .UNINDENT .UNINDENT .INDENT 7.0 .TP .B set_mesh_vertex(pos: Tuple[int, int], point: Vertex, dxfattribs: dict = 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() -> ezdxf.entities.polyline.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 \fB(row, col)\fP 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 \fB(row, col)\fP tuples. .UNINDENT .INDENT 7.0 .TP .B __getitem__(pos: Tuple[int, int]) -> Vertex 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: Vertex) -> 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{ \fBezdxf.layouts.BaseLayout.add_polyface()\fP T} _ T{ Inherited DXF Attributes T} T{ Common graphical DXF attributes T} _ .TE .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_polyface .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.entities.Polyface A polyface consist of multiple location independent 3D areas called faces. The \fI\%Polyface\fP is a subclass of \fI\%Polyline\fP, DXF type is also \fB\(aqPOLYLINE\(aq\fP but \fI\%get_mode()\fP returns \fB\(aqAcDbPolyFaceMesh\(aq\fP\&. .INDENT 7.0 .TP .B append_face(face: FaceType, dxfattribs: Dict = None) -> None Append a single face. A \fIface\fP is a list of \fB(x, y, z)\fP tuples. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBface\fP – List[\fB(x, y, z)\fP tuples] .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for \fI\%Vertex\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append_faces(faces: Iterable[FaceType], dxfattribs: Dict = None) -> None Append multiple \fIfaces\fP\&. \fIfaces\fP is a list of single faces and a single face is a list of \fB(x, y, z)\fP tuples. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfaces\fP – list of List[\fB(x, y, z)\fP tuples] .IP \(bu 2 \fBdxfattribs\fP – dict of DXF attributes for \fI\%Vertex\fP entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B faces() -> Iterable[List[Vertex]] Iterable of all faces, a face is a tuple of vertices. .INDENT 7.0 .TP .B Returns [vertex, vertex, vertex, [vertex,] face_record] .TP .B Return type list .UNINDENT .UNINDENT .INDENT 7.0 .TP .B optimize(precision: int = 6) -> None Rebuilds \fI\%Polyface\fP including vertex optimization 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 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{ \fBezdxf.entities.XLine\fP T} _ T{ DXF type T} T{ \fB\(aqRAY\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_ray()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 WCS) .INDENT 7.0 .TP .B dxf.unit_vector .UNINDENT .sp Unit direction vector as (3D Point in WCS) .INDENT 7.0 .TP .B transform(m: Matrix44) -> Ray Transform XLINE/RAY entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B translate(dx: float, dy: float, dz: float) -> Ray Optimized XLINE/RAY translation about \fIdx\fP in x\-axis, \fIdy\fP in y\-axis and \fIdz\fP in z\-axis, returns \fIself\fP (floating interface). .sp New in version 0.13. .UNINDENT .UNINDENT .SS Region .sp REGION (\fI\%DXF Reference\fP) created by an ACIS based geometry kernel provided by the \fI\%Spatial Corp.\fP .sp \fIezdxf\fP will never interpret ACIS source code, don’t ask me for this feature. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.Body\fP T} _ T{ DXF type T} T{ \fB\(aqREGION\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_region()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 \fBBody\fP\&. .UNINDENT .SS Shape .sp SHAPES (\fI\%DXF Reference\fP) are objects that are used like 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 create this shape files. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqSHAPE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_shape()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 WCS) .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 \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.xscale Relative X scale factor (float); default value is \fB1\fP .UNINDENT .INDENT 7.0 .TP .B dxf.oblique Oblique angle in degrees (float); default value is \fB0\fP .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Shape Transform SHAPE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .UNINDENT .SS Solid .sp SOLID (\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). .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqSOLID\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_solid()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx1 Location of 2. vertex (2D/3D Point in OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx2 Location of 3. vertex (2D/3D Point in OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx3 Location of 4. vertex (2D/3D Point in OCS) .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Solid Transform SOLID/TRACE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .UNINDENT .SS Spline .sp SPLINE curve (\fI\%DXF Reference\fP), all coordinates have to be 3D coordinates even the spline is only 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 To create a \fI\%Spline\fP curve you just need a bunch of fit points \- knot values and weights are optional (tested with AutoCAD 2010). If you add additional data, be sure that you know what you do. .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 tut_spline .UNINDENT .UNINDENT .UNINDENT .sp Since \fIezdxf\fP v0.8.9 \fI\%Spline\fP stores fit\- and control points, knots and weights as packed data (\fBarray.array\fP). .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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{ Common graphical DXF attributes 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{ \fBadd_spline()\fP T} _ T{ Spline control frame from fit points T} T{ \fBadd_spline_control_frame()\fP T} _ T{ Open uniform spline T} T{ \fBadd_open_spline()\fP T} _ T{ Closed uniform spline T} T{ \fBadd_closed_spline()\fP T} _ T{ Open rational uniform spline T} T{ \fBadd_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 WCS 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 \fBezdxf.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 = \fB1e\-10\fP .UNINDENT .INDENT 7.0 .TP .B dxf.fit_tolerance Fit tolerance (float); default = \fB1e\-10\fP .UNINDENT .INDENT 7.0 .TP .B dxf.control_point_tolerance Control point tolerance (float); default = \fB1e\-10\fP .UNINDENT .INDENT 7.0 .TP .B dxf.start_tangent Start tangent vector as (3D vector in WCS) .UNINDENT .INDENT 7.0 .TP .B dxf.end_tangent End tangent vector as (3D vector in WCS) .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 \fBVertexArray\fP of control points in WCS\&. .UNINDENT .INDENT 7.0 .TP .B fit_points \fBVertexArray\fP of fit points in WCS\&. .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() -> BSpline Returns construction tool \fBezdxf.math.BSpline\fP\&. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B apply_construction_tool(s: BSpline) -> Spline Set SPLINE data from construction tool \fBezdxf.math.BSpline\fP or from a \fBgeomdl.BSpline.Curve\fP object. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B set_open_uniform(control_points: Sequence[Vertex], degree: int = 3) -> None Open B\-spline with uniform knot vector, start and end at your first and last control points. .UNINDENT .INDENT 7.0 .TP .B set_uniform(control_points: Sequence[Vertex], degree: int = 3) -> None B\-spline with 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[Vertex], degree=3) -> None Closed B\-spline with uniform knot vector, start and end at your first control point. .UNINDENT .INDENT 7.0 .TP .B set_open_rational(control_points: Sequence[Vertex], weights: Sequence[float], degree: int = 3) -> None Open rational B\-spline with 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[Vertex], weights: Sequence[float], degree: int = 3) -> None Rational B\-spline with uniform knot vector, deos 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[Vertex], weights: Sequence[float], degree: int = 3) -> None Closed rational B\-spline with 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: Matrix44) -> Spline Transform SPLINE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B classmethod from_arc(entity: DXFGraphic) -> Spline Create a new SPLINE entity from 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! .sp New in version 0.13. .UNINDENT .UNINDENT .SS Surface .sp SURFACE (\fI\%DXF Reference\fP) created by an ACIS based geometry kernel provided by the \fI\%Spatial Corp.\fP .sp \fIezdxf\fP will never interpret ACIS source code, don’t ask me for this feature. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.Body\fP T} _ T{ DXF type T} T{ \fB\(aqSURFACE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_surface()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 \fBBody\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{ \fBezdxf.layouts.BaseLayout.add_extruded_surface()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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: \fBMatrix44\fP .UNINDENT .INDENT 7.0 .TP .B sweep_entity_transformation_matrix type: \fBMatrix44\fP .UNINDENT .INDENT 7.0 .TP .B path_entity_transformation_matrix type: \fBMatrix44\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{ \fBezdxf.layouts.BaseLayout.add_lofted_surface()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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: \fBMatrix44\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{ \fBezdxf.layouts.BaseLayout.add_revolved_surface()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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: \fBMatrix44\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{ \fBezdxf.layouts.BaseLayout.add_swept_surface()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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: \fBMatrix44\fP .UNINDENT .INDENT 7.0 .TP .B transformation_matrix_path_entity() type: \fBMatrix44\fP .UNINDENT .INDENT 7.0 .TP .B sweep_entity_transformation_matrix() type: \fBMatrix44\fP .UNINDENT .INDENT 7.0 .TP .B path_entity_transformation_matrix() type: \fBMatrix44\fP .UNINDENT .UNINDENT .SS Text .sp One line TEXT entity (\fI\%DXF Reference\fP). \fI\%Text.dxf.height\fP in drawing units and defaults to \fB1\fP, but it also depends on the font rendering of the CAD application. \fI\%Text.dxf.width\fP is a scaling factor, but the DXF reference does not define the base value to scale, in practice the \fI\%Text.dxf.height\fP is the base value, the effective text width depends on the font defined by \fI\%Text.dxf.style\fP and the font rendering of the CAD application, especially for proportional fonts, text width calculation is nearly impossible without knowlegde of the used CAD application and their font rendering behavior. This is one reason why the DXF and also DWG file format are not reliable for exchanging exact text layout, they are just reliable for exchanging exact geometry. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 tut_text .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqTEXT\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_text()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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. (str) .UNINDENT .INDENT 7.0 .TP .B dxf.insert First alignment point of text (2D/3D Point in OCS), relevant for the adjustments \fB\(aqLEFT\(aq\fP, \fB\(aqALIGN\(aq\fP and \fB\(aqFIT\(aq\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.align_point .UNINDENT .sp second alignment point of text (2D/3D Point in OCS), if the justification is anything other than \fB\(aqLEFT\(aq\fP, the second alignment point specify also the first alignment point: (or just the second alignment point for \fB\(aqALIGN\(aq\fP and \fB\(aqFIT\(aq\fP) .INDENT 7.0 .TP .B dxf.height Text height in drawing units (float); default value is \fB1\fP .UNINDENT .INDENT 7.0 .TP .B dxf.rotation Text rotation in degrees (float); default value is \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.oblique Text oblique angle in degrees (float); default value is \fB0\fP (straight vertical text) .UNINDENT .INDENT 7.0 .TP .B dxf.style \fBTextstyle\fP name (str); default value is \fB\(aqStandard\(aq\fP .UNINDENT .INDENT 7.0 .TP .B dxf.width Width scale factor (float); default value is \fB1\fP .UNINDENT .INDENT 7.0 .TP .B dxf.halign Horizontal alignment flag (int), use \fI\%set_pos()\fP and \fI\%get_align()\fP; default value is \fB0\fP .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 (int), use \fI\%set_pos()\fP and \fI\%get_align()\fP; default value is \fB0\fP .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 (int) .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 set_pos(p1: Vertex, p2: Vertex = None, align: str = None) -> Text Set text alignment, valid alignments are: .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 Alignments \fB\(aqALIGNED\(aq\fP and \fB\(aqFIT\(aq\fP are special, they require a second alignment point, text is aligned on the virtual line between these two points and has vertical alignment \fIBaseline\fP\&. .INDENT 7.0 .IP \(bu 2 \fB\(aqALIGNED\(aq\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 \fB\(aqFIT\(aq\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 \fB\(aqMIDDLE\(aq\fP: also a special adjustment, but the result is the same as for \fB\(aqMIDDLE_CENTER\(aq\fP\&. .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – first alignment point as (x, y[, z]) tuple .IP \(bu 2 \fBp2\fP – second alignment point as (x, y[, z]) tuple, required for \fB\(aqALIGNED\(aq\fP and \fB\(aqFIT\(aq\fP else ignored .IP \(bu 2 \fBalign\fP – new alignment, \fBNone\fP for preserve existing alignment. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_pos() -> Tuple[str, Vertex, Optional[Vertex]] Returns a tuple (\fIalign\fP, \fIp1\fP, \fIp2\fP), \fIalign\fP is the alignment method, \fIp1\fP is the alignment point, \fIp2\fP is only relevant if \fIalign\fP is \fB\(aqALIGNED\(aq\fP or \fB\(aqFIT\(aq\fP, otherwise it is \fBNone\fP\&. .UNINDENT .INDENT 7.0 .TP .B get_align() -> str Returns the actual text alignment as string, see also \fI\%set_pos()\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_align(align: str = \(aqLEFT\(aq) -> 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 – test alignment, see also \fI\%set_pos()\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Text Transform TEXT entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .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 (floating interface). .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B plain_text() -> str Returns text content without formatting codes. .sp New in version 0.13. .UNINDENT .UNINDENT .SS Trace .sp 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). I don’t know the difference between SOLID and TRACE. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqTRACE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_trace()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx1 Location of 2. vertex (2D/3D Point in OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx2 Location of 3. vertex (2D/3D Point in OCS) .UNINDENT .INDENT 7.0 .TP .B dxf.vtx3 Location of 4. vertex (2D/3D Point in OCS) .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Trace Transform SOLID/TRACE entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .UNINDENT .SS Underlay .sp 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 \fBUnderlayDefinition\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 OCS coordinates in drawing units but without scaling. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ internal base class T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_underlay()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 OCS\&. .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 = \fB(0, 0, 1)\fP .UNINDENT .INDENT 7.0 .TP .B dxf.underlay_def_handle Handle to the underlay definition entity, see \fBUnderlayDefinition\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 (\fB20\fP \- \fB100\fP; default = \fB100\fP) .UNINDENT .INDENT 7.0 .TP .B dxf.fade Fade value (\fB0\fP \- \fB80\fP; default = \fB0\fP) .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 \fB(x, y, z)\fP 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() -> UnderlayDefinition Returns the associated DEFINITION entity. see \fBUnderlayDefinition\fP\&. .UNINDENT .INDENT 7.0 .TP .B set_underlay_def(underlay_def: UnderlayDefinition) -> None Set the associated DEFINITION entity. see \fBUnderlayDefinition\fP\&. .UNINDENT .INDENT 7.0 .TP .B reset_boundary_path() 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{ \fBezdxf.layouts.BaseLayout.add_underlay()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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{ \fBezdxf.layouts.BaseLayout.add_underlay()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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{ \fBezdxf.layouts.BaseLayout.add_underlay()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 (\fI\%DXF Reference\fP) entity is a window from a paperspace layout to the modelspace. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqVIEWPORT\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.Paperspace.add_viewport()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 in modelspace (3D point in WCS). .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 DCS\&. .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 WCS). .UNINDENT .INDENT 7.0 .TP .B dxf.view_target_point View target point (3D point in WCS). .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 WCS\&. .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|. _ T{ 1 (0x1) T} T{ Enables perspective mode T} _ T{ 2 (0x2) T} T{ Enables front clipping T} _ T{ 4 (0x4) T} T{ Enables back clipping T} _ T{ 8 (0x8) T} T{ Enables UCS follow T} _ T{ 16 (0x10) T} T{ Enables front clip not at eye T} _ T{ 32 (0x20) T} T{ Enables UCS icon visibility T} _ T{ 64 (0x40) T} T{ Enables UCS icon at origin T} _ T{ 128 (0x80) T} T{ Enables fast zoom T} _ T{ 256 (0x100) T} T{ Enables snap mode T} _ T{ 512 (0x200) T} T{ Enables grid mode T} _ T{ 1024 (0x400) T} T{ Enables isometric snap style T} _ T{ 2048 (0x800) T} T{ Enables hide plot mode T} _ T{ 4096 (0x1000) 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{ kIsoPairRight. If set and kIsoPairTop is not set, then isopair right is enabled T} _ T{ 16384 (0x4000) T} T{ Enables viewport zoom locking T} _ T{ 32768 (0x8000) T} T{ Currently always enabled T} _ T{ 65536 (0x10000) T} T{ Enables non\-rectangular clipping T} _ T{ 131072 (0x20000) T} T{ Turns the viewport off T} _ T{ 262144 (0x40000) T} T{ Enables the display of the grid beyond the drawing limits T} _ T{ 524288 (0x80000) T} T{ Enable adaptive grid display T} _ T{ 1048576 (0x100000) T} T{ Enables subdivision of the grid below the set grid spacing when the grid display is adaptive T} _ T{ 2097152 (0x200000) T} T{ Enables grid follows workplane switching T} _ .TE .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 ACI .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 .UNINDENT .SS Wipeout .sp THE WIPEOUT (\fI\%DXF Reference\fP) entity 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 \fBImageDef\fP and \fBImageDefReactor\fP are always “0”, both are not needed by the WIPEOUT entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.Image\fP T} _ T{ DXF type T} T{ \fB\(aqWIPEOUT\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_wipeout()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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[Vertex]) -> None Set a new masking area, the area is placed in the layout xy\-plane. .UNINDENT .UNINDENT .SS XLine .sp 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{ \fBezdxf.entities.DXFGraphic\fP T} _ T{ DXF type T} T{ \fB\(aqXLINE\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.layouts.BaseLayout.add_xline()\fP T} _ T{ Inherited DXF attributes T} T{ Common graphical DXF attributes 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 WCS) .INDENT 7.0 .TP .B dxf.unit_vector .UNINDENT .sp Unit direction vector as (3D Point in WCS) .INDENT 7.0 .TP .B transform(m: Matrix44) -> XLine Transform XLINE/RAY entity by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .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, returns \fIself\fP (floating interface). .sp New in version 0.13. .UNINDENT .UNINDENT .SS DXF Objects .SS DXFObject .sp Common base class for all non\-graphical DXF objects. .INDENT 0.0 .TP .B class ezdxf.entities.DXFObject Subclass of \fBezdxf.entities.DXFEntity\fP .UNINDENT .SS Dictionary .sp The \fI\%DICTIONARY\fP 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 (\fBkey\fP, \fBDXFEntity\fP) pairs. At loading time the value could be a \fBstr\fP, because at this time not all objects are already stored in the \fBEntityDB\fP, and have to be acquired later. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqDICTIONARY\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.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 \fB1\fP, 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 \fI\%Dictionary\fP 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 items. .UNINDENT .INDENT 7.0 .TP .B __contains__(key: str) -> bool Returns \fBTrue\fP if \fIkey\fP exist. .UNINDENT .INDENT 7.0 .TP .B __getitem__(key: str) -> DXFEntity Return the value for \fIkey\fP, raises a \fBDXFKeyError\fP if \fIkey\fP does not exist. .UNINDENT .INDENT 7.0 .TP .B __setitem__(key: str, value: DXFEntity) -> None Add item as \fB(key, value)\fP pair to dictionary. .UNINDENT .INDENT 7.0 .TP .B __delitem__(key: str) -> None Delete entry \fIkey\fP from the dictionary, raises \fBDXFKeyError\fP if key does not exist. .UNINDENT .INDENT 7.0 .TP .B keys() -> KeysView Returns \fBKeysView\fP of all dictionary keys. .UNINDENT .INDENT 7.0 .TP .B items() -> ItemsView Returns \fBItemsView\fP for all dictionary entries as (\fBkey\fP, \fBDXFEntity\fP) pairs. .UNINDENT .INDENT 7.0 .TP .B count() -> int Returns count of items. .UNINDENT .INDENT 7.0 .TP .B get(key: str, default: Any = DXFKeyError) -> DXFEntity Returns \fBDXFEntity\fP for \fIkey\fP, if \fIkey\fP exist, else \fIdefault\fP or raises a \fBDXFKeyError\fP for \fIdefault\fP = \fBDXFKeyError\fP\&. .UNINDENT .INDENT 7.0 .TP .B add(key: str, value: DXFEntity) -> None Add entry \fB(key, value)\fP\&. .UNINDENT .INDENT 7.0 .TP .B remove(key: str) -> None Delete entry \fIkey\fP\&. Raises \fBDXFKeyError\fP, if \fIkey\fP does not exist. Deletes also hard owned DXF objects from OBJECTS section. .UNINDENT .INDENT 7.0 .TP .B discard(key: str) -> None Delete entry \fIkey\fP if exists. Does NOT raise an exception if \fIkey\fP not exist and does not delete hard owned DXF objects. .UNINDENT .INDENT 7.0 .TP .B clear() -> None Delete all entries from \fI\%Dictionary\fP, deletes hard owned DXF objects from OBJECTS section. .UNINDENT .INDENT 7.0 .TP .B add_new_dict(key: str, hard_owned: bool = False) -> Dictionary Create a new sub \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) -> 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 new \fBDictionaryVar\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 .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{ \fBezdxf.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) -> DXFEntity Returns \fBDXFEntity\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: ezdxf.entities.dxfentity.DXFEntity) -> None Set dictionary wide default entry. .INDENT 7.0 .TP .B Parameters \fBdefault\fP – default entry as \fBDXFEntity\fP .UNINDENT .UNINDENT .UNINDENT .SS DictionaryVar .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 dxf.schema Object schema number (currently set to \fB0\fP) .UNINDENT .INDENT 0.0 .TP .B dxf.value Value as string. .UNINDENT .SS GeoData .sp The \fI\%GEODATA\fP entity is associated to the \fBModelspace\fP object. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqGEODATA\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.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\%using_geodata.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 \fBModelspace\fP\&. .sp Changed in version 0.10: renamed from \fBdxf.block_record\fP .UNINDENT .INDENT 7.0 .TP .B dxf.design_point Reference point in WCS 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 \fBBlockRecord\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 \fBBlockRecord\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 \fBVertexArray\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 \fBVertexArray\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 .UNINDENT .SS ImageDef .sp \fI\%IMAGEDEF\fP entity defines an image file, which can be placed by the \fBImage\fP entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqIMAGEDEF\(aq\fP T} _ T{ Factory function (1) T} T{ \fBezdxf.document.Drawing.add_image_def()\fP T} _ T{ Factory function (2) T} T{ \fBezdxf.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 \fB0\fP\&. .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 \fB(x, y)\fP tuple. .UNINDENT .INDENT 7.0 .TP .B dxf.pixel_size Default size of one pixel in drawing units as \fB(x, y)\fP tuple. .UNINDENT .INDENT 7.0 .TP .B dxf.loaded \fB0\fP = unloaded; \fB1\fP = loaded, default = \fB1\fP .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 = \fB0\fP .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 DXFLayout .sp \fI\%LAYOUT\fP entity is part of a modelspace or paperspace layout definitions. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.PlotSettings\fP T} _ T{ DXF type T} T{ \fB\(aqLAYOUT\(aq\fP T} _ T{ Factory function T} T{ internal data structure, use \fBLayouts\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 CAD applications .UNINDENT .UNINDENT .sp TODO .SS Placeholder .sp The \fI\%ACDBPLACEHOLDER\fP object for internal usage. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqACDBPLACEHOLDER\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.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 \fBDXFLayout\fP entity, I don’t know if this entity also appears as standalone entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 Page setup name .UNINDENT .UNINDENT .sp TODO .SS Sun .sp \fI\%SUN\fP entity defines properties of the sun. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.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 \fB1\fP\&. .UNINDENT .INDENT 7.0 .TP .B dxf.status on = \fB1\fP or off = \fB0\fP .UNINDENT .INDENT 7.0 .TP .B dxf.color ACI value of the sun. .UNINDENT .INDENT 7.0 .TP .B dxf.true_color true color value of the sun. .UNINDENT .INDENT 7.0 .TP .B dxf.intensity Intensity value in the range of \fB0\fP to \fB1\fP\&. (float) .UNINDENT .INDENT 7.0 .TP .B dxf.julian_day use \fBcalendardate()\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 \fBUnderlay\fP entity. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ internal base class T} _ T{ Factory function (1) T} T{ \fBezdxf.document.Drawing.add_underlay_def()\fP T} _ T{ Factory function (2) T} T{ \fBezdxf.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{ \fB\(aqpdf\(aq\fP T} T{ PDF page number T} _ T{ \fB\(aqdgn\(aq\fP T} T{ always \fB\(aqdefault\(aq\fP T} _ T{ \fB\(aqdwf\(aq\fP 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{ \fBezdxf.document.Drawing.add_underlay_def()\fP T} _ T{ Factory function (2) T} T{ \fBezdxf.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{ \fBezdxf.document.Drawing.add_underlay_def()\fP T} _ T{ Factory function (2) T} T{ \fBezdxf.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{ \fBezdxf.document.Drawing.add_underlay_def()\fP T} _ T{ Factory function (2) T} T{ \fBezdxf.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 \fI\%XRECORD\fP objects are used to store and manage arbitrary data. They are composed of DXF group codes ranging from \fB1\fP through \fB369\fP\&. 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. .TS center; |l|l|. _ T{ Subclass of T} T{ \fBezdxf.entities.DXFObject\fP T} _ T{ DXF type T} T{ \fB\(aqXRECORD\(aq\fP T} _ T{ Factory function T} T{ \fBezdxf.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 \fBTags\fP\&. Be careful \fIezdxf\fP does not validate the content of XRECORDS. .UNINDENT .UNINDENT .SS Data Query .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 For usage of the query features see the tutorial: tut_getting_data .UNINDENT .UNINDENT .SS Entity Query String .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C QueryString := EntityQuery ("[" AttribQuery "]" "i"?)* .ft P .fi .UNINDENT .UNINDENT .sp The query string is the combination of two queries, first the required entity query and second the \fIoptional\fP 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 ? ".*"]\fP: always empty, because the LINE entity has no text attribute. .IP \(bu 2 \fBLINE CIRCLE[layer=="construction"]\fP: all LINE and CIRCLE entities with layer == \fB"construction"\fP .IP \(bu 2 \fB*[!(layer=="construction" & color<7)]\fP: all entities except those with layer == \fB"construction"\fP and color < \fB7\fP .IP \(bu 2 \fB*[layer=="construction"]i\fP, (ignore case) all entities with layer == \fB"construction"\fP | \fB"Construction"\fP | \fB"ConStruction"\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. .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: int) -> DXFEntity Returns DXFEntity at index \fIitem\fP, supports negative indices and slicing. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[DXFEntity] Returns iterable of DXFEntity objects. .UNINDENT .INDENT 7.0 .TP .B extend(entities: Iterable[DXFEntity], query: str = \(aq*\(aq, unique: bool = True) -> EntityQuery Extent the \fI\%EntityQuery\fP container by entities matching an additional query. .UNINDENT .INDENT 7.0 .TP .B remove(query: str = \(aq*\(aq) -> None Remove all entities from \fI\%EntityQuery\fP container matching this additional query. .UNINDENT .INDENT 7.0 .TP .B query(query: str = \(aq*\(aq) -> ezdxf.query.EntityQuery Returns a new \fI\%EntityQuery\fP container with all entities matching this additional query. .sp raises: ParseException (pyparsing.py) .UNINDENT .INDENT 7.0 .TP .B groupby(dxfattrib: str = \(aq\(aq, key: Callable[[DXFEntity], Hashable] = 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 None for ignore this object. Reason for ignoring: a queried DXF attribute is not supported by this entity .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS The new() Function .INDENT 0.0 .TP .B ezdxf.query.new(entities: Iterable[DXFEntity] = None, query: str = \(aq*\(aq) -> EntityQuery Start a new query based on sequence \fIentities\fP\&. The \fIentities\fP argument has to be an iterable of \fBDXFEntity\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: using_groupby .UNINDENT .UNINDENT .SS Groupby Function .INDENT 0.0 .TP .B ezdxf.groupby.groupby(entities: Iterable[DXFEntity], dxfattrib: str = \(aq\(aq, key: KeyFunc = None) -> Dict[Hashable, List[DXFEntity]] 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 .nf .ft C def group_key(entity: DXFEntity): return entity.dxf.layer, entity.dxf.color .ft P .fi .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 .nf .ft C { \(aq0\(aq: [ ... list of entities ], \(aqExampleLayer1\(aq: [ ... ], \(aqExampleLayer2\(aq: [ ... ], ... } .ft P .fi .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 .nf .ft C { (\(aq0\(aq, 1): [ ... list of entities ], (\(aq0\(aq, 3): [ ... ], (\(aq0\(aq, 7): [ ... ], (\(aqExampleLayer1\(aq, 1): [ ... ], (\(aqExampleLayer1\(aq, 2): [ ... ], (\(aqExampleLayer1\(aq, 5): [ ... ], (\(aqExampleLayer2\(aq, 7): [ ... ], ... } .ft P .fi .UNINDENT .UNINDENT .sp All entity containers (modelspace, paperspace layouts and blocks) and the \fBEntityQuery\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 Utilities Utility functions and classes located in module \fI\%ezdxf.math\fP\&. .SS Functions .INDENT 0.0 .TP .B ezdxf.math.is_close_points(p1: Vertex, p2: Vertex, abs_tol=1e\-10) -> bool Returns \fBTrue\fP if \fIp1\fP is very close to \fIp2\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP – first vertex as \fI\%Vector\fP compatible object .IP \(bu 2 \fBp2\fP – second vertex as \fI\%Vector\fP compatible object .IP \(bu 2 \fBabs_tol\fP – absolute tolerance .UNINDENT .TP .B Raises \fBTypeError\fP – for incompatible vertices .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.closest_point(base: Vertex, points: Iterable[Vertex]) -> Vector Returns closest point to \fIbase\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBbase\fP – base point as \fI\%Vector\fP compatible object .IP \(bu 2 \fBpoints\fP – iterable of points as \fI\%Vector\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.0) -> float Extended rounding function, 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) -> Iterable[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. .sp New in version 0.12.3. .UNINDENT .SS Bulge Related Functions .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Description of the bulge value\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.bulge_center(start_point: Vertex, end_point: Vertex, bulge: float) -> Vec2 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: Vertex, end_point: Vertex, 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.arc_to_bulge(center: Vertex, start_angle: float, end_angle: float, radius: float) -> Tuple[Vec2, Vec2, 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_to_arc(start_point: Vertex, end_point: Vertex, bulge: float) -> Tuple[Vec2, float, float, float] Returns arc parameters from bulge parameters. .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_3_points(start_point: Vertex, end_point: Vertex, point: Vertex) -> 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 .SS 2D Functions .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 the arc to the center of its base .UNINDENT .UNINDENT .sp New in version 0.14. .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 .sp New in version 0.14. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.distance_point_line_2d(point: Vec2, start: Vec2, end: Vec2) -> float Returns distance from \fIpoint\fP to line defined by \fIstart\-\fP and \fIend\fP point. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – 2D point to test as \fI\%Vec2\fP or tuple of float .IP \(bu 2 \fBstart\fP – line definition point as \fI\%Vec2\fP or tuple of float .IP \(bu 2 \fBend\fP – line definition point as \fI\%Vec2\fP or tuple of float .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.point_to_line_relation(point: Vec2, start: Vec2, end: Vec2, abs_tol=1e\-10) -> 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.is_point_on_line_2d(point: Vec2, start: Vec2, end: Vec2, ray=True, abs_tol=1e\-10) -> 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 line test .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.is_point_left_of_line(point: Vec2, start: Vec2, end: Vec2, 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_in_polygon_2d(point: Vec2, polygon: Iterable[Vec2], abs_tol=1e\-10) -> int Test if \fIpoint\fP is inside \fIpolygon\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 \fBpolygon\fP – iterable 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 .sp New in version 0.11. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.convex_hull_2d(points: Iterable[Vertex]) -> List[Vertex] Returns 2D convex hull for \fIpoints\fP\&. .INDENT 7.0 .TP .B Parameters \fBpoints\fP – iterable of points as \fI\%Vector\fP compatible objects, z\-axis is ignored .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersection_line_line_2d(line1: Sequence[Vec2], line2: Sequence[Vec2], virtual=True, abs_tol=1e\-10) -> Optional[Vec2] 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.rytz_axis_construction(d1: Vector, d2: Vector) -> Tuple[Vector, Vector, 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\%Vector\fP .IP \(bu 2 \fBd2\fP – conjugated semi\-minor axis as \fI\%Vector\fP .UNINDENT .TP .B Returns Tuple of (major axis, minor axis, ratio) .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.offset_vertices_2d(vertices: Iterable[Vertex], offset: float, closed: bool = False) -> Iterable[Vec2] 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 .sp New in version 0.11. .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 .nf .ft C source = [(0, 0), (3, 0), (3, 3), (0, 3)] result = list(offset_vertices_2d(source, offset=0.5, closed=True)) .ft P .fi .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 .nf .ft C source = [(0, 0), (0, 1), (0, 2), (0, 3)] result = list(offset_vertices_2d(source, offset=0.5, closed=True)) .ft P .fi .UNINDENT .UNINDENT [image] .SS 3D Functions .INDENT 0.0 .TP .B ezdxf.math.normal_vector_3p(a: Vector, b: Vector, c: Vector) -> Vector Returns normal vector for 3 points, which is the normalized cross product for: \fBa\->b x a\->c\fP\&. .sp New in version 0.11. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.is_planar_face(face: Sequence[Vector], 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\%Vector\fP objects .IP \(bu 2 \fBabs_tol\fP – tolerance for normals check .UNINDENT .UNINDENT .sp New in version 0.11. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.subdivide_face(face: Sequence[Union[Vector, Vec2]], quads=True) -> Iterable[List[Vector]] Yields new subdivided faces. Creates new faces from subdivided edges and the face midpoint by linear interpolation. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBface\fP – a sequence of vertices, \fI\%Vec2\fP and \fI\%Vector\fP objects supported. .IP \(bu 2 \fBquads\fP – create quad faces if \fBTrue\fP else create triangles .UNINDENT .UNINDENT .sp New in version 0.11. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.subdivide_ngons(faces: Iterable[Sequence[Union[Vector, Vec2]]]) -> Iterable[List[Vector]] Yields only triangles or quad faces, subdivides ngons into triangles. .INDENT 7.0 .TP .B Parameters \fBfaces\fP – iterable of faces as sequence of \fI\%Vec2\fP and \fI\%Vector\fP objects .UNINDENT .sp New in version 0.12. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.intersection_ray_ray_3d(ray1: Tuple[Vector, Vector], ray2: Tuple[Vector, Vector], abs_tol=1e\-10) -> Sequence[Vector] Calculate intersection of two 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 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 on the ray as \fI\%Vector\fP objects .IP \(bu 2 \fBray2\fP – second ray as tuple of two points on the ray as \fI\%Vector\fP objects .IP \(bu 2 \fBabs_tol\fP – absolute tolerance for comparisons .UNINDENT .UNINDENT .sp New in version 0.11. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.estimate_tangents(points: List[Vector], method: str = \(aq5\-points\(aq, normalize=True) -> List[Vector] 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\%Vector\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.estimate_end_tangent_magnitude(points: List[Vector], method: str = \(aqchord\(aq) -> List[Vector] 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.fit_points_to_cad_cv(fit_points: Iterable[Vertex], degree: int = 3, method=\(aqchord\(aq, tangents: Iterable[Vertex] = None) -> BSpline Returns the control vertices and knot vector configuration for DXF SPLINE entities defined only by 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 Global curve interpolation with start\- and end derivatives, e.g. 6 fit points creates 8 control vertices in BricsCAD .IP \(bu 2 Degree of B\-spline is limited to 2 or 3, a stored degree of >3 is ignored, this limit exist only for B\-splines defined by fit points .IP \(bu 2 Knot parametrization method is “chord” .IP \(bu 2 Knot distribution is “natural” .UNINDENT .sp The last missing parameter is the start\- and end tangents estimation method used by BricsCAD, if these tangents are stored in the DXF file provide them as argument \fItangents\fP as 2\-tuple (start, end) and the interpolated control vertices will match the BricsCAD calculation, except for floating point imprecision. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfit_points\fP – points the spline is passing through .IP \(bu 2 \fBdegree\fP – degree of spline, only 2 or 3 is supported by BricsCAD, default = 3 .IP \(bu 2 \fBmethod\fP – knot parametrization method, default = ‘chord’ .IP \(bu 2 \fBtangents\fP – start\- and end tangent, default is autodetect .UNINDENT .TP .B Returns \fI\%BSpline\fP .UNINDENT .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.global_bspline_interpolation(fit_points: Iterable[Vertex], degree: int = 3, tangents: Iterable[Vertex] = None, method: str = \(aqchord\(aq) -> BSpline \fI\%B\-spline\fP interpolation by \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 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\%Vector\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.local_cubic_bspline_interpolation(fit_points: Iterable[Vertex], method: str = \(aq5\-points\(aq, tangents: Iterable[Vertex] = None) -> BSpline \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\%Vector\fP compatible objects .IP \(bu 2 \fBmethod\fP – tangent estimation method .IP \(bu 2 \fBtangents\fP – tangents as \fI\%Vector\fP compatible objects (optional) .UNINDENT .TP .B Returns \fI\%BSpline\fP .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.rational_spline_from_arc(center: Vector = (0, 0), radius: float = 1, start_angle: float = 0, end_angle: float = 360, segments: int = 1) -> BSpline 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\%Vector\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), \fB1\fP for as few as needed. .UNINDENT .UNINDENT .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.rational_spline_from_ellipse(ellipse: ConstructionEllipse, segments: int = 1) -> BSpline 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 (pi/2), \fB1\fP for as few as needed. .UNINDENT .UNINDENT .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.cubic_bezier_from_arc(center: Vector = (0, 0), radius: float = 1, start_angle: float = 0, end_angle: float = 360, segments: int = 1) -> Iterable[Bezier4P] 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\%Vector\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), \fB1\fP for as few as possible. .UNINDENT .UNINDENT .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.cubic_bezier_from_ellipse(ellipse: ConstructionEllipse, segments: int = 1) -> Iterable[Bezier4P] 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 (pi/2), .IP \(bu 2 \fBfor as few as possible.\fP (\fI1\fP) – .UNINDENT .UNINDENT .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.cubic_bezier_interpolation(points: Iterable[Vertex]) -> List[Bezier4P] 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 .sp New in version 0.13. .UNINDENT .SS Transformation Classes .SS OCS Class .INDENT 0.0 .TP .B class ezdxf.math.OCS(extrusion: Vertex = Vector(0.0, 0.0, 1.0)) Establish an OCS 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: Vertex) -> Vertex Returns OCS vector for WCS \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_from_wcs(points: Iterable[Vertex]) -> Iterable[Vertex] Returns iterable of OCS vectors from WCS \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B to_wcs(point: Vertex) -> Vertex Returns WCS vector for OCS \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_to_wcs(points: Iterable[Vertex]) -> Iterable[Vertex] Returns iterable of WCS vectors for OCS \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B render_axis(layout: BaseLayout, length: float = 1, colors: Tuple[int, int, int] = (1, 3, 5)) Render axis as 3D lines into a \fIlayout\fP\&. .UNINDENT .UNINDENT .SS UCS Class .INDENT 0.0 .TP .B class ezdxf.math.UCS(origin: Vertex = (0, 0, 0), ux: Vertex = None, uy: Vertex = None, uz: Vertex = None) Establish an user coordinate system (UCS). The UCS is defined by the origin and two unit vectors for the x\-, y\- or z\-axis, all axis in WCS\&. 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 WCS .IP \(bu 2 \fBuy\fP – defines the UCS y\-axis as vector in WCS .IP \(bu 2 \fBuz\fP – defines the UCS z\-axis as vector in WCS .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() -> UCS Returns a copy of this UCS. .sp New in version 0.11. .UNINDENT .INDENT 7.0 .TP .B to_wcs(point: Vertex) -> Vector Returns WCS point for UCS \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_to_wcs(points: Iterable[Vertex]) -> Iterable[Vector] Returns iterable of WCS vectors for UCS \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B direction_to_wcs(vector: Vertex) -> Vector Returns WCS direction for UCS \fIvector\fP without origin adjustment. .UNINDENT .INDENT 7.0 .TP .B from_wcs(point: Vertex) -> Vector Returns UCS point for WCS \fIpoint\fP\&. .UNINDENT .INDENT 7.0 .TP .B points_from_wcs(points: Iterable[Vertex]) -> Iterable[Vector] Returns iterable of UCS vectors from WCS \fIpoints\fP\&. .UNINDENT .INDENT 7.0 .TP .B direction_from_wcs(vector: Vertex) -> Vector Returns UCS vector for WCS \fIvector\fP without origin adjustment. .UNINDENT .INDENT 7.0 .TP .B to_ocs(point: Vertex) -> Vector 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[Vertex]) -> Iterable[Vector] 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: Matrix44) -> UCS 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 .sp New in version 0.14. .UNINDENT .INDENT 7.0 .TP .B rotate(axis: Vertex, angle: float) -> UCS Returns a new rotated UCS, with the same origin as the source UCS. The rotation vector is located in the origin and has WCS coordinates e.g. (0, 0, 1) is the WCS z\-axis as rotation vector. .sp New in version 0.11. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBaxis\fP – arbitrary rotation axis as vector in WCS .IP \(bu 2 \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_local_x(angle: float) -> UCS Returns a new rotated UCS, rotation axis is the local x\-axis. .sp New in version 0.11. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_local_y(angle: float) -> UCS Returns a new rotated UCS, rotation axis is the local y\-axis. .sp New in version 0.11. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate_local_z(angle: float) -> UCS Returns a new rotated UCS, rotation axis is the local z\-axis. .sp New in version 0.11. .INDENT 7.0 .TP .B Parameters \fBangle\fP – rotation angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B shift(delta: Vertex) -> UCS Shifts current UCS by \fIdelta\fP vector and returns \fIself\fP\&. .sp New in version 0.11. .INDENT 7.0 .TP .B Parameters \fBdelta\fP – shifting vector .UNINDENT .UNINDENT .INDENT 7.0 .TP .B moveto(location: Vertex) -> UCS Place current UCS at new origin \fIlocation\fP and returns \fIself\fP\&. .sp New in version 0.11. .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: Vertex, axis: Vertex, point: Vertex) -> UCS Returns an 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 WCS .IP \(bu 2 \fBaxis\fP – x\-axis vector as (x, y, z) tuple in WCS .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the xy\-plane as (x, y, z) tuple in WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_x_axis_and_point_in_xz(origin: Vertex, axis: Vertex, point: Vertex) -> UCS Returns an 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 WCS .IP \(bu 2 \fBaxis\fP – x\-axis vector as (x, y, z) tuple in WCS .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the xz\-plane as (x, y, z) tuple in WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_y_axis_and_point_in_xy(origin: Vertex, axis: Vertex, point: Vertex) -> UCS Returns an 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 WCS .IP \(bu 2 \fBaxis\fP – y\-axis vector as (x, y, z) tuple in WCS .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the xy\-plane as (x, y, z) tuple in WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_y_axis_and_point_in_yz(origin: Vertex, axis: Vertex, point: Vertex) -> UCS Returns an 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 WCS .IP \(bu 2 \fBaxis\fP – y\-axis vector as (x, y, z) tuple in WCS .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the yz\-plane as (x, y, z) tuple in WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_z_axis_and_point_in_xz(origin: Vertex, axis: Vertex, point: Vertex) -> UCS Returns an 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 WCS .IP \(bu 2 \fBaxis\fP – z\-axis vector as (x, y, z) tuple in WCS .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the xz\-plane as (x, y, z) tuple in WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_z_axis_and_point_in_yz(origin: Vertex, axis: Vertex, point: Vertex) -> UCS Returns an 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 WCS .IP \(bu 2 \fBaxis\fP – z\-axis vector as (x, y, z) tuple in WCS .IP \(bu 2 \fBpoint\fP – arbitrary point unlike the origin in the yz\-plane as (x, y, z) tuple in WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_axis(layout: BaseLayout, length: float = 1, colors: Tuple[int, int, int] = (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) This is a pure Python implementation for 4x4 transformation matrices, to avoid dependency to big numerical packages like \fBnumpy\fP, before binary wheels, installation of these packages wasn’t always easy on Windows. .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 set(*args) -> None Set matrix values. .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBset()\fP creates the identity matrix. .IP \(bu 2 \fBset(values)\fP values is an iterable with the 16 components of the matrix. .IP \(bu 2 \fBset(row1, row2, row3, row4)\fP four rows, each row with four values. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_row(row: int) -> Tuple[float, …] Get row as list of 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() -> Matrix44 Returns a copy of same type. .UNINDENT .INDENT 7.0 .TP .B __copy__() -> Matrix44 Returns a copy of same type. .UNINDENT .INDENT 7.0 .TP .B classmethod scale(sx: float, sy: float = None, sz: float = None) -> Matrix44 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) -> Matrix44 Returns a translation matrix for translation vector (dx, dy, dz). .UNINDENT .INDENT 7.0 .TP .B classmethod x_rotate(angle: float) -> Matrix44 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) -> Matrix44 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) -> Matrix44 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: Vertex, angle: float) -> Matrix44 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\%Vector\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) -> Matrix44 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 perspective_projection(left: float, right: float, top: float, bottom: float, near: float, far: float) -> Matrix44 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) -> Matrix44 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: Iterable[Matrix44]) -> Matrix44 Compose a transformation matrix from one or more \fImatrices\fP\&. .UNINDENT .INDENT 7.0 .TP .B static ucs(ux: Vertex, uy: Vertex, uz: Vertex) -> Matrix44 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__() -> int Returns hash value of matrix. .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__() -> Iterable[float] Iterates over all matrix values. .UNINDENT .INDENT 7.0 .TP .B rows() -> Iterable[Tuple[float, …]] Iterate over rows as 4\-tuples. .UNINDENT .INDENT 7.0 .TP .B columns() -> Iterable[Tuple[float, …]] Iterate over columns as 4\-tuples. .UNINDENT .INDENT 7.0 .TP .B __mul__(other: Matrix44) -> Matrix44 Returns a new matrix as result of the matrix multiplication with another matrix. .UNINDENT .INDENT 7.0 .TP .B __imul__(other: Matrix44) -> Matrix44 Inplace multiplication with another matrix. .UNINDENT .INDENT 7.0 .TP .B fast_mul(other: Matrix44) -> Matrix44 Multiplies this matrix with other matrix. .sp Assumes that both matrices have a right column of (0, 0, 0, 1). This is True for matrices composed of rotations, translations and scales. fast_mul is approximately 25% quicker than the \fB*=\fP operator. .UNINDENT .INDENT 7.0 .TP .B transform(vector: Vertex) -> ezdxf.math.vector.Vector Returns a transformed vertex. .UNINDENT .INDENT 7.0 .TP .B transform_direction(vector: Vertex, normalize=False) -> ezdxf.math.vector.Vector Returns a transformed direction vector without translation. .UNINDENT .INDENT 7.0 .TP .B transform_vertices(vectors: Iterable[Vertex]) -> Iterable[ezdxf.math.vector.Vector] Returns an iterable of transformed vertices. .UNINDENT .INDENT 7.0 .TP .B transform_directions(vectors: Iterable[Vertex], normalize=False) -> Iterable[ezdxf.math.vector.Vector] 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 .UNINDENT .SS Construction Tools .SS Vector .INDENT 0.0 .TP .B class ezdxf.math.Vector(*args) This is an immutable universal 3D vector object. 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 .nf .ft C v1 = Vector(1, 2, 3) v2 = v1 v2.z = 7 # this is not possible, raises AttributeError v2 = Vector(v2.x, v2.y, 7) # this creates a new Vector() object assert v1.z == 3 # and v1 remains unchanged .ft P .fi .UNINDENT .UNINDENT .sp \fI\%Vector\fP initialization: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBVector()\fP, returns \fBVector(0, 0, 0)\fP .IP \(bu 2 \fBVector((x, y))\fP, returns \fBVector(x, y, 0)\fP .IP \(bu 2 \fBVector((x, y, z))\fP, returns \fBVector(x, y, z)\fP .IP \(bu 2 \fBVector(x, y)\fP, returns \fBVector(x, y, 0)\fP .IP \(bu 2 \fBVector(x, y, z)\fP, returns \fBVector(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 .nf .ft C v = Vector(1, 2, 3) v + (1, 2, 3) == Vector(2, 4, 6) (1, 2, 3) + v == Vector(2, 4, 6) v \- (1, 2, 3) == Vector(0, 0, 0) (1, 2, 3) \- v == Vector(0, 0, 0) v * 3 == Vector(3, 6, 9) 3 * v == Vector(3, 6, 9) Vector(3, 6, 9) / 3 == Vector(1, 2, 3) \-Vector(1, 2, 3) == (\-1, \-2, \-3) .ft P .fi .UNINDENT .UNINDENT .sp Comparison between vectors and vectors or tuples is supported: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C Vector(1, 2, 3) < Vector (2, 2, 2) (1, 2, 3) < tuple(Vector(2, 2, 2)) # conversion necessary Vector(1, 2, 3) == (1, 2, 3) bool(Vector(1, 2, 3)) is True bool(Vector(0, 0, 0)) is False .ft P .fi .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 Vector as \fB(x, y, 0)\fP, projected on the xy\-plane. .UNINDENT .INDENT 7.0 .TP .B xyz Vector 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 \fBTrue\fP for \fBVector(0, 0, 0)\fP\&. .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\(aqVector(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() -> Vector Returns a copy of vector as \fI\%Vector\fP object. .UNINDENT .INDENT 7.0 .TP .B __copy__() -> Vector Returns a copy of vector as \fI\%Vector\fP object. .UNINDENT .INDENT 7.0 .TP .B __deepcopy__(memodict: dict) -> Vector \fBcopy.deepcopy()\fP support. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index: int) -> float Support for indexing: .INDENT 7.0 .INDENT 3.5 .INDENT 0.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 .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[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, y: float = None, z: float = None) -> Vector Returns a copy of vector with replaced x\-, y\- and/or z\-axis. .UNINDENT .INDENT 7.0 .TP .B classmethod generate(items: Iterable[Vertex]) -> Iterable[Vector] Returns an iterable of \fI\%Vector\fP objects. .UNINDENT .INDENT 7.0 .TP .B classmethod list(items: Iterable[Vertex]) -> List[Vector] Returns a list of \fI\%Vector\fP objects. .UNINDENT .INDENT 7.0 .TP .B classmethod tuple(items: Iterable[Vertex]) -> Sequence[Vector] Returns a tuple of \fI\%Vector\fP objects. .UNINDENT .INDENT 7.0 .TP .B classmethod from_angle(angle: float, length: float = 1.) -> Vector Returns a \fI\%Vector\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.) -> Vector Returns a \fI\%Vector\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) -> Vector 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: Any, factor=\&.5) -> Vector 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\%Vector\fP compatible object .IP \(bu 2 \fBfactor\fP – interpolation factor (\fB0\fP = self, \fB1\fP = other, \fB0.5\fP = mid point) .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B is_parallel(other: Vector, abs_tolr=1e\-12) -> bool Returns \fBTrue\fP if \fIself\fP and \fIother\fP are parallel to vectors. .UNINDENT .INDENT 7.0 .TP .B project(other: Any) -> Vector Returns projected vector of \fIother\fP onto \fIself\fP\&. .UNINDENT .INDENT 7.0 .TP .B normalize(length: float = 1.) -> Vector Returns normalized vector, optional scaled by \fIlength\fP\&. .UNINDENT .INDENT 7.0 .TP .B reversed() -> Vector Returns negated vector (\-\fIself\fP). .UNINDENT .INDENT 7.0 .TP .B isclose(other: Any, 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. .UNINDENT .INDENT 7.0 .TP .B __neg__() -> Vector Returns negated vector (\-\fIself\fP). .UNINDENT .INDENT 7.0 .TP .B __bool__() -> bool Returns \fBTrue\fP if vector is not \fB(0, 0, 0)\fP\&. .UNINDENT .INDENT 7.0 .TP .B __eq__(other: Any) -> bool Equal operator. .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __lt__(other: Any) -> bool Lower than operator. .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __add__(other: Any) -> Vector Add operator: \fIself\fP + \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __radd__(other: Any) -> Vector RAdd operator: \fIother\fP + \fIself\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __sub__(other: Any) -> Vector Sub operator: \fIself\fP \- \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __rsub__(other: Any) -> Vector RSub operator: \fIother\fP \- \fIself\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __mul__(other: float) -> Vector Mul operator: \fIself\fP * \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – scale factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __rmul__(other: float) -> Vector RMul operator: \fIother\fP * \fIself\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – scale factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __truediv__(other: float) -> Vector Div operator: \fIself\fP / \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – scale factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __div__(other: float) -> Vector Div operator: \fIself\fP / \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – scale factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __rtruediv__(other: float) -> Vector RDiv operator: \fIother\fP / \fIself\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – scale factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __rdiv__(other: float) -> Vector RDiv operator: \fIother\fP / \fIself\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – scale factor .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dot(other: Any) -> float Dot operator: \fIself\fP . \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B cross(other: Any) -> Vector Dot operator: \fIself\fP x \fIother\fP .INDENT 7.0 .TP .B Parameters \fBother\fP – \fI\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B distance(other: Any) -> float Returns distance between \fIself\fP and \fIother\fP vector. .UNINDENT .INDENT 7.0 .TP .B angle_about(base: Vector, target: Vector) -> 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: Any) -> 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\%Vector\fP compatible object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle: float) -> Vector 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) -> Vector Returns vector rotated about \fIangle\fP around the z\-axis. .INDENT 7.0 .TP .B Parameters \fBangle\fP – angle in degrees .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.X_AXIS \fBVector(1, 0, 0)\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.Y_AXIS \fBVector(0, 1, 0)\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.Z_AXIS \fBVector(0, 0, 1)\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.NULLVEC \fBVector(0, 0, 0)\fP .UNINDENT .SS Vec2 .INDENT 0.0 .TP .B class ezdxf.math.Vec2(v) \fI\%Vec2\fP represents a special 2D vector \fB(x, y)\fP\&. The \fI\%Vec2\fP class is optimized for speed and not immutable, \fBiadd()\fP, \fBisub()\fP, \fBimul()\fP and \fBidiv()\fP modifies the vector itself, the \fI\%Vector\fP class returns a new object. .sp \fI\%Vec2\fP initialization accepts float\-tuples \fB(x, y[, z])\fP, two floats or any object providing \fBx\fP and \fBy\fP attributes like \fI\%Vec2\fP and \fI\%Vector\fP objects. .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\%Vector\fP\&. .UNINDENT .SS Plane .INDENT 0.0 .TP .B class ezdxf.math.Plane(normal: Vector, distance: float) Represents a plane in 3D space as normal vector and the perpendicular distance from origin. .sp New in version 0.11. .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: Vector, b: Vector, c: Vector) -> Plane Returns a new plane from 3 points in space. .UNINDENT .INDENT 7.0 .TP .B classmethod from_vector(vector) -> Plane Returns a new plane from a location vector. .UNINDENT .INDENT 7.0 .TP .B copy() -> Plane Returns a copy of the plane. .UNINDENT .INDENT 7.0 .TP .B signed_distance_to(v: Vector) -> 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: Vector) -> float Returns absolute (unsigned) distance of vertex \fIv\fP to plane. .UNINDENT .INDENT 7.0 .TP .B is_coplanar_vertex(v: Vector, 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: Plane, abs_tol=1e\-9) -> bool Returns \fBTrue\fP if plane \fIp\fP is coplanar, normal vectors in same or opposite direction. .UNINDENT .UNINDENT .SS BoundingBox .INDENT 0.0 .TP .B class ezdxf.math.BoundingBox(vertices: Iterable[Vertex] = None) 3D bounding box. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of \fB(x, y, z)\fP tuples or \fI\%Vector\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 center Returns center of bounding box. .UNINDENT .INDENT 7.0 .TP .B extend(vertices: Iterable[Vertex]) -> None Extend bounds by \fIvertices\fP\&. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of \fB(x, y, z)\fP tuples or \fI\%Vector\fP objects .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property has_data Returns \fBTrue\fP if data is available .UNINDENT .INDENT 7.0 .TP .B inside(vertex: Vertex) -> bool Returns \fBTrue\fP if \fIvertex\fP is inside bounding box. .UNINDENT .INDENT 7.0 .TP .B property size Returns size of bounding box. .UNINDENT .UNINDENT .SS BoundingBox2d .INDENT 0.0 .TP .B class ezdxf.math.BoundingBox2d(vertices: Iterable[Vertex] = None) Optimized 2D bounding box. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of \fB(x, y[, z])\fP tuples or \fI\%Vector\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 center Returns center of bounding box. .UNINDENT .INDENT 7.0 .TP .B extend(vertices: Iterable[Vertex]) -> None Extend bounds by \fIvertices\fP\&. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – iterable of \fB(x, y[, z])\fP tuples or \fI\%Vector\fP objects .UNINDENT .UNINDENT .INDENT 7.0 .TP .B property has_data Returns \fBTrue\fP if data is available .UNINDENT .INDENT 7.0 .TP .B inside(vertex: Vertex) -> bool Returns \fBTrue\fP if \fIvertex\fP is inside bounding box. .UNINDENT .INDENT 7.0 .TP .B property size Returns size of bounding box. .UNINDENT .UNINDENT .SS ConstructionRay .INDENT 0.0 .TP .B class ezdxf.math.ConstructionRay(p1: Vertex, p2: Vertex = None, angle: float = None) Infinite 2D construction ray as immutable object. .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(self, other: ConstructionRay) -> bool Returns \fBTrue\fP if rays are parallel. .UNINDENT .INDENT 7.0 .TP .B intersect(other: ConstructionRay) -> Vec2 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: Vertex) -> ConstructionRay Returns orthogonal ray at \fIlocation\fP\&. .UNINDENT .INDENT 7.0 .TP .B bisectrix(other: ConstructionRay) -> ConstructionRay: 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: Vertex, end: Vertex) 2D ConstructionLine 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 __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() -> Vec2 Returns mid point of line. .UNINDENT .INDENT 7.0 .TP .B inside_bounding_box(point: Vertex) -> bool Returns \fBTrue\fP if \fIpoint\fP is inside of line bounding box. .UNINDENT .INDENT 7.0 .TP .B intersect(other: ConstructionLine, abs_tol: float = 1e\-10) -> Optional[Vec2] 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: ConstructionLine, abs_tol: float = 1e\-10) -> bool Returns \fBTrue\fP if has intersection with \fIother\fP line. .UNINDENT .INDENT 7.0 .TP .B is_point_left_of_line(point: Vertex, 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: Vertex, radius: float = 1.0) Circle construction tool. .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: Vertex, p2: Vertex, p3: Vertex) -> ConstructionCircle 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) -> Vec2 Returns point on circle at \fIangle\fP as \fI\%Vec2\fP object. .INDENT 7.0 .TP .B Parameters \fBangle\fP – angle in radians .UNINDENT .UNINDENT .INDENT 7.0 .TP .B inside(point: Vertex) -> bool Returns \fBTrue\fP if \fIpoint\fP is inside circle. .UNINDENT .INDENT 7.0 .TP .B tangent(angle: float) -> ConstructionRay 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: ConstructionRay, abs_tol: float = 1e\-10) -> Sequence[Vec2] 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_circle(other: ConstructionCircle, abs_tol: float = 1e\-10) -> Sequence[Vec2] 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: Vertex = (0, 0), radius: float = 1, start_angle: float = 0, end_angle: float = 360, is_counter_clockwise: bool = True) This is a helper class to create parameters for the DXF \fBArc\fP class. .sp \fI\%ConstructionArc\fP represents a 2D arc in the xy\-plane, use an \fI\%UCS\fP to place arc 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[ezdxf.math.vector.Vec2] 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[ezdxf.math.vector.Vec2] 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) -> ConstructionArc 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) -> ConstructionArc 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) -> ConstructionArc 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: Vertex, end_point: Vertex, angle: float, ccw: bool = True) -> ConstructionArc 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: Vertex, end_point: Vertex, radius: float, ccw: bool = True, center_is_left: bool = True) -> ConstructionArc 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: Vertex, end_point: Vertex, def_point: Vertex, ccw: bool = True) -> ConstructionArc 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: BaseLayout, ucs: UCS = None, dxfattribs: dict = None) -> Arc Add arc as DXF \fBArc\fP entity to a layout. .sp Supports 3D arcs by using an UCS\&. 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 \fBBaseLayout\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 DXF \fBArc\fP entity .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS ConstructionEllipse .INDENT 0.0 .TP .B class ezdxf.math.ConstructionEllipse(center: Vertex = Vector(0.0, 0.0, 0.0), major_axis: Vertex = Vector(1.0, 0.0, 0.0), extrusion: Vertex = Vector(0.0, 0.0, 1.0), ratio: float = 1, start_param: float = 0, end_param: float = 6.283185307179586, ccw: bool = True) This is a helper class to create parameters for 3D ellipses. .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\%Vector\fP .UNINDENT .INDENT 7.0 .TP .B major_axis major axis as \fI\%Vector\fP .UNINDENT .INDENT 7.0 .TP .B minor_axis minor axis as \fI\%Vector\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\%Vector\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 Vector. .UNINDENT .INDENT 7.0 .TP .B end_point Returns end point of ellipse as Vector. .UNINDENT .INDENT 7.0 .TP .B to_ocs() -> ConstructionEllipse 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, 2pi). .UNINDENT .INDENT 7.0 .TP .B vertices(params: Iterable[float]) -> Iterable[ezdxf.math.vector.Vector] Yields vertices on ellipse for iterable \fIparams\fP in WCS. .INDENT 7.0 .TP .B Parameters \fBparams\fP – param values in the range from \fB0\fP to \fB2*pi\fP in radians, param goes counter clockwise around the extrusion vector, major_axis = local x\-axis = 0 rad. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B params_from_vertices(vertices: Iterable[Vertex]) -> Iterable[float] Yields ellipse params for all given \fIvertices\fP\&. .sp The vertex don’t has 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*pi return unpredictable results because of floating point inaccuracy, sometimes 0 and sometimes 2*pi. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B dxfattribs() -> Dict 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[ezdxf.math.vector.Vector] Yields main axis points of ellipse in the range from start\- to end param. .UNINDENT .INDENT 7.0 .TP .B classmethod from_arc(center: Vertex = (0, 0, 0), radius: float = 1, extrusion: Vertex = (0, 0, 1), start_angle: float = 0, end_angle: float = 360, ccw: bool = True) -> ConstructionEllipse 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: Matrix44) 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: BaseLayout, dxfattribs: dict = None) -> Ellipse Add ellipse as DXF \fBEllipse\fP entity to a layout. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – destination layout as \fBBaseLayout\fP object .IP \(bu 2 \fBdxfattribs\fP – additional DXF attributes for DXF \fBEllipse\fP entity .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS ConstructionBox .INDENT 0.0 .TP .B class ezdxf.math.ConstructionBox(center: Vertex = (0, 0), width: float = 1, height: float = 1, angle: float = 0) Helper class to create 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[Vec2] Iterable of box corners as \fI\%Vec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B __getitem__(corner) -> Vec2 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: Vertex, p2: Vertex) -> ConstructionBox 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: Vertex) -> bool Returns \fBTrue\fP if \fIpoint\fP is inside of box. .UNINDENT .INDENT 7.0 .TP .B is_any_corner_inside(other: ConstructionBox) -> bool Returns \fBTrue\fP if any corner of \fIother\fP box is inside this box. .UNINDENT .INDENT 7.0 .TP .B is_overlapping(other: ConstructionBox) -> bool Returns \fBTrue\fP if this box and \fIother\fP box do overlap. .UNINDENT .INDENT 7.0 .TP .B border_lines() -> Sequence[ConstructionLine] Returns border lines of box as sequence of \fI\%ConstructionLine\fP\&. .UNINDENT .INDENT 7.0 .TP .B intersect(line: ConstructionLine) -> List[Vec2] Returns 0, 1 or 2 intersection points between \fIline\fP and box border lines. .INDENT 7.0 .TP .B Parameters \fBline\fP – line to intersect with border lines .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 Shape2d .INDENT 0.0 .TP .B class ezdxf.math.Shape2d(vertices: Iterable[Vertex] = None) 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) -> Vec2 Get vertex by index \fIitem\fP, supports \fBlist\fP like slicing. .UNINDENT .INDENT 7.0 .TP .B append(vertex: Vertex) -> 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: Vertex) -> 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: Vertex = None) -> None Rotate shape around rotation \fIcenter\fP about \fIangle\fP in degrees. .UNINDENT .INDENT 7.0 .TP .B rotate_rad(angle: float, center: Vertex = 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) -> ezdxf.math.shape.Shape2d Returns a new offset shape, for more information see also \fI\%ezdxf.math.offset_vertices_2d()\fP function. .sp New in version 0.11. .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() -> ezdxf.math.shape.Shape2d Returns convex hull as new shape. .UNINDENT .UNINDENT .SS Curves .SS BSpline .INDENT 0.0 .TP .B class ezdxf.math.BSpline(control_points: Iterable[Vertex], order: int = 4, knots: Iterable[float] = None, weights: Iterable[float] = None) Representation of a \fI\%B\-spline\fP curve, using an uniform open \fI\%knot\fP vector (“clamped”). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcontrol_points\fP – iterable of control points as \fI\%Vector\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 control_points Control points as list of \fI\%Vector\fP .UNINDENT .INDENT 7.0 .TP .B count Count of control points, (n + 1 in text book notation). .UNINDENT .INDENT 7.0 .TP .B degree Degree (p) of B\-spline = order \- 1 .UNINDENT .INDENT 7.0 .TP .B order Order of B\-spline = degree + 1 .UNINDENT .INDENT 7.0 .TP .B max_t Biggest \fI\%knot\fP value. .UNINDENT .INDENT 7.0 .TP .B is_rational Returns \fBTrue\fP if curve is a rational B\-spline. (has weights) .UNINDENT .INDENT 7.0 .TP .B knots() -> List[float] Returns a list 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 normalize_knots() Normalize knot vector into range [0, 1]. .UNINDENT .INDENT 7.0 .TP .B weights() -> List[float] Returns a list of weights values as floats, one for each control point or an empty list. .UNINDENT .INDENT 7.0 .TP .B params(segments: int) -> Iterable[float] Yield evenly spaced parameters from 0 to max_t for given segment count. .UNINDENT .INDENT 7.0 .TP .B reverse() -> BSpline Returns a new BSpline with reversed control point order. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> BSpline Transform B\-spline by transformation matrix \fIm\fP inplace. .sp New in version 0.13. .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int = 20) -> Iterable[Vector] Approximates curve by vertices as \fI\%Vector\fP objects, vertices count = segments + 1. .UNINDENT .INDENT 7.0 .TP .B point(t: float) -> Vector 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: float) -> List[Vector] 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[Vector] 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\%Vector\fP objects .UNINDENT .UNINDENT .INDENT 7.0 .TP .B derivatives(t: Iterable[float], n: int = 2) -> Iterable[List[Vector]] 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\%Vector\fP objects .UNINDENT .UNINDENT .INDENT 7.0 .TP .B insert_knot(t: float) -> None Insert additional knot, without altering the curve shape. .INDENT 7.0 .TP .B Parameters \fBt\fP – position of new knot 0 < t < max_t .UNINDENT .UNINDENT .INDENT 7.0 .TP .B static from_ellipse(ellipse: ConstructionEllipse) -> BSpline 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: ConstructionArc) -> BSpline 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[Vertex], degree: int = 3, method=\(aqchord\(aq) -> BSpline Returns \fI\%BSpline\fP defined by fit points. .UNINDENT .INDENT 7.0 .TP .B static arc_approximation(arc: ConstructionArc, num: int = 16) -> BSpline Returns an arc approximation as \fI\%BSpline\fP with \fInum\fP control points. .UNINDENT .INDENT 7.0 .TP .B static ellipse_approximation(ellipse: ConstructionEllipse, num: int = 16) -> BSpline Returns an ellipse approximation as \fI\%BSpline\fP with \fInum\fP control points. .UNINDENT .INDENT 7.0 .TP .B bezier_decomposition() -> Iterable[List[Vector]] 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) -> Iterable[Bezier4P] 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. .sp 1. 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. 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 \fBsegments\fP != \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 BSplineU .INDENT 0.0 .TP .B class ezdxf.math.BSplineU(control_points: Iterable[Vertex], order: int = 4, knots: Iterable[float] = None, weights: Iterable[float] = None) Representation of an uniform (periodic) \fI\%B\-spline\fP curve (\fI\%open curve\fP). .UNINDENT .SS BSplineClosed .INDENT 0.0 .TP .B class ezdxf.math.BSplineClosed(control_points: Iterable[Vertex], order: int = 4, knots: Iterable[float] = None, weights: Iterable[float] = None) Representation of a closed uniform \fI\%B\-spline\fP curve (\fI\%closed curve\fP). .UNINDENT .SS Bezier .INDENT 0.0 .TP .B class ezdxf.math.Bezier(defpoints: Iterable[Vertex]) 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 general implementation which works with any count of definition points greater than \fB2\fP, but it is a simple and slow implementation. For more performance look at the specialized \fI\%Bezier4P\fP class. .sp Objects are immutable. .INDENT 7.0 .TP .B Parameters \fBdefpoints\fP – iterable of definition points as \fI\%Vector\fP compatible objects. .UNINDENT .INDENT 7.0 .TP .B control_points Control points as tuple of \fI\%Vector\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() -> Bezier Returns a new Bèzier\-curve with reversed control point order. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Bezier 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 .sp New in version 0.14. .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int = 20) -> Iterable[Vector] Approximates curve by vertices as \fI\%Vector\fP objects, vertices count = segments + 1. .UNINDENT .INDENT 7.0 .TP .B point(t: float) -> Vector Returns a point for parameter \fIt\fP in range [0, 1] as \fI\%Vector\fP object. .UNINDENT .INDENT 7.0 .TP .B points(t: Iterable[float]) -> Iterable[Vector] Yields multiple points for parameters in vector \fIt\fP as \fI\%Vector\fP objects. Parameters have to be in range [0, 1]. .UNINDENT .INDENT 7.0 .TP .B derivative(t: float) -> Tuple[Vector, Vector, Vector] Returns (point, 1st derivative, 2nd derivative) tuple for parameter \fIt\fP in range [0, 1] as \fI\%Vector\fP objects. .UNINDENT .INDENT 7.0 .TP .B derivatives(t: Iterable[float]) -> Iterable[Tuple[Vector, Vector, Vector]] Returns multiple (point, 1st derivative, 2nd derivative) tuples for parameter vector \fIt\fP as \fI\%Vector\fP objects. Parameters in range [0, 1] .UNINDENT .UNINDENT .SS Bezier4P .INDENT 0.0 .TP .B class ezdxf.math.Bezier4P(defpoints: Sequence[Vertex]) Implements an optimized cubic \fI\%Bézier curve\fP for exact 4 control points. A \fI\%Bézier curve\fP is a parametric curve, parameter \fIt\fP goes from \fB0\fP to \fB1\fP, where \fB0\fP is the first control point and \fB1\fP 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\%Vector\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\%Vector\fP compatible objects. .UNINDENT .INDENT 7.0 .TP .B control_points Control points as tuple of \fI\%Vector\fP or \fI\%Vec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B reverse() -> Bezier4P Returns a new Bèzier\-curve with reversed control point order. .UNINDENT .INDENT 7.0 .TP .B transform(m: Matrix44) -> Bezier4P General transformation interface, returns a new \fBBezier4p\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 .sp New in version 0.14. .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int) -> Iterable[Union[Vector, Vec2]] 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 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) -> Union[Vector, Vec2] 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) -> Union[Vector, Vec2] 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 BezierSurface .INDENT 0.0 .TP .B class ezdxf.math.BezierSurface(defpoints: List[List[Sequence[float]]]) \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) -> Sequence[float] 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[Sequence[float]]] Approximate surface as grid of \fB(x, y, z)\fP tuples. .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 \fB(x, y, z)\fP tuples. .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) -> Vector Get tangent at distance \fIt\fP as :class.\(gaVector\(ga 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) -> Vector Get point at distance \fIt\fP as :class.\(gaVector\(ga. .UNINDENT .INDENT 7.0 .TP .B circle_center(t: float) -> Vector Get circle center at distance \fIt\fP\&. .sp Changed in version 0.10: renamed from \fIcircle_midpoint\fP .UNINDENT .INDENT 7.0 .TP .B approximate(length: float, segments: int) -> Iterable[Vector] Approximate curve of length with line segments. .sp Generates segments+1 vertices as \fI\%Vector\fP objects. .UNINDENT .INDENT 7.0 .TP .B bspline(length: float, segments: int = 10, degree: int = 3, method: str = \(aquniform\(aq) -> BSpline 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 Linear Algebra .SS Functions .INDENT 0.0 .TP .B ezdxf.math.gauss_jordan_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> Tuple[Matrix, Matrix] 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 .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.gauss_jordan_inverse(A: Iterable[Iterable[float]]) -> Matrix 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 .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.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 .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.gauss_matrix_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> Matrix 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 .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.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 .nf .ft C [[b0, c0, 0, 0, ...], [a1, b1, c1, 0, ...], [0, a2, b2, c2, ...], \&... ] .ft P .fi .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 .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.tridiagonal_matrix_solver(A: Iterable[Iterable[float]], B: Iterable[Iterable[float]]) -> Matrix 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 .nf .ft C [[b0, c0, 0, 0, ...], [a1, b1, c1, 0, ...], [0, a2, b2, c2, ...], \&... ] .ft P .fi .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 .sp New in version 0.13. .UNINDENT .INDENT 0.0 .TP .B ezdxf.math.banded_matrix(A: Matrix, check_all=True) -> Tuple[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.detect_banded_matrix(A: Matrix, 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.compact_banded_matrix(A: Matrix, m1: int, m2: int) -> Matrix 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.freeze_matrix(A: Union[MatrixData, Matrix]) -> Matrix Returns a frozen matrix, all data is stored in immutable tuples. .UNINDENT .SS Matrix Class .INDENT 0.0 .TP .B class ezdxf.math.Matrix(items: Any = None, shape: Tuple[int, int] = None, matrix: List[List[float]] = None) Basic matrix implementation without any optimization for speed of 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 .sp New in version 0.13. .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]) -> ezdxf.math.linalg.Matrix 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]) -> ezdxf.math.linalg.Matrix Returns the identity matrix for configuration \fIshape\fP\&. .UNINDENT .INDENT 7.0 .TP .B row(index) -> List[float] Returns row \fIindex\fP as list of floats. .UNINDENT .INDENT 7.0 .TP .B iter_row(index) -> Iterable[float] Yield values of row \fIindex\fP\&. .UNINDENT .INDENT 7.0 .TP .B col(index) -> List[float] Return column \fIindex\fP as list of floats. .UNINDENT .INDENT 7.0 .TP .B iter_col(index) -> Iterable[float] Yield values of column \fIindex\fP\&. .UNINDENT .INDENT 7.0 .TP .B diag(index) -> List[float] Returns diagonal \fIindex\fP as list 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 iter_diag(index) -> Iterable[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: Union[float, Iterable[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: Union[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: Union[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() -> Matrix Returns a new transposed matrix. .UNINDENT .INDENT 7.0 .TP .B inverse() -> Matrix 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() -> Matrix Returns a frozen matrix, all data is stored in immutable tuples. .UNINDENT .INDENT 7.0 .TP .B lu_decomp() -> LUDecomposition 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: Matrix) -> bool Returns \fBTrue\fP if matrices are equal, tolerance value for comparision is adjustable by the attribute \fBMatrix.abs_tol\fP\&. .UNINDENT .INDENT 7.0 .TP .B __add__(other: Union[Matrix, float]) -> Matrix Matrix addition by another matrix or a float, returns a new matrix. .UNINDENT .INDENT 7.0 .TP .B __sub__(other: Union[Matrix, float]) -> Matrix Matrix subtraction by another matrix or a float, returns a new matrix. .UNINDENT .INDENT 7.0 .TP .B __mul__(other: Union[Matrix, float]) -> Matrix 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.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 .sp New in version 0.13. .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]]) -> Matrix 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() -> Matrix 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.BandedMatrixLU(A: ezdxf.math.linalg.Matrix, 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]]) -> Matrix 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 Miscellaneous .SS Global Options .sp Global options stored in \fI\%ezdxf.options\fP .INDENT 0.0 .TP .B ezdxf.options.default_text_style Default text styles, default value is \fBOpenSans\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.default_dimension_text_style Default text style for Dimensions, default value is \fBOpenSansCondensed\-Light\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.filter_invalid_xdata_group_codes Check for invalid XDATA group codes, default value is \fBFalse\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.log_unprocessed_tags Log unprocessed DXF tags for debugging, default value is \fBTrue\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.load_proxy_graphics Load proxy graphics if \fBTrue\fP, default is \fBFalse\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.store_proxy_graphics Export proxy graphics if \fBTrue\fP, default is \fBFalse\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.write_fixed_meta_data_for_testing Enable this option to always create same meta data for testing scenarios, e.g. to use a diff like tool to compare DXF documents. .UNINDENT .INDENT 0.0 .TP .B ezdxf.options.preserve_proxy_graphics() Enable proxy graphic load/store support. .UNINDENT .SS Load DXF Comments .INDENT 0.0 .TP .B ezdxf.comments.from_stream(stream: TextIO, codes: Set[int] = None) -> Iterable[DXFTag] Yields comment tags from text \fIstream\fP as \fBDXFTag\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) -> Iterable[DXFTag] Yields comment tags from file \fIfilename\fP as \fBDXFTag\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 .SS Tools .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 \fBrecover\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. .sp New in version 0.14. .INDENT 0.0 .TP .B ezdxf.has_dxf_unicode(s: str) -> bool Detect if string \fIs\fP contains encoded DXF unicode characters “\eU+xxxx”. .UNINDENT .INDENT 0.0 .TP .B ezdxf.decode_dxf_unicode(s: str) -> str Decode DXF unicode characters “\eU+xxxx” in string \fIs\fP\&. .UNINDENT .SS Tools .sp Some handy tool functions used internally by \fBezdxf\fP\&. .INDENT 0.0 .TP .B ezdxf.int2rgb(value: int) -> Tuple[int, int, int] Split RGB integer \fIvalue\fP into \fB(r, g, b)\fP tuple. .UNINDENT .INDENT 0.0 .TP .B ezdxf.rgb2int(rgb: Tuple[int, int, int]) -> int Combined integer value from \fB(r, g, b)\fP tuple. .UNINDENT .INDENT 0.0 .TP .B ezdxf.float2transparency(value: float) -> int Returns DXF transparency value as integer in the range from \fB0\fP to \fB255\fP, where \fB0\fP is 100% transparent and \fB255\fP is opaque. .INDENT 7.0 .TP .B Parameters \fBvalue\fP – transparency value as float in the range from \fB0\fP to \fB1\fP, where \fB0\fP is opaque and \fB1\fP is 100% transparency. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.transparency2float(value: int) -> float Returns transparency value as float from \fB0\fP to \fB1\fP, \fB0\fP for no transparency (opaque) and \fB1\fP for 100% transparency. .INDENT 7.0 .TP .B Parameters \fBvalue\fP – DXF integer transparency value, \fB0\fP for 100% transparency and \fB255\fP for opaque .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.juliandate(date: datetime.datetime) -> float .UNINDENT .INDENT 0.0 .TP .B ezdxf.tools.calendardate(juliandate: float) -> datetime.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.uuid1()\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.aci2rgb(index: int) -> Tuple[int, int, int] Convert ACI into \fB(r, g, b)\fP tuple, based on default AutoCAD colors. .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 ACIS 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 ACIS Text (SAT) format “encrypted” by AutoCAD. .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 \fBModelspace\fP, \fBPaperspace\fP or \fBBlockLayout\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[DXFGraphic], mapping: Union[Dict, Iterable[Tuple[str, str]]] = None) -> Iterable[DXFGraphic] 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[DXFGraphic], mapping: Union[Dict, Iterable[Tuple[str, str]]] = None) -> Iterable[DXFGraphic] 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 .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 Reference section or if you want to learn how to use \fIezdxf\fP go to the Tutorials section or to the Basic Concepts section. .SS General Document .sp General preconditions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import sys import ezdxf try: doc = ezdxf.readfile("your_dxf_file.dxf") 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() .ft P .fi .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 \fBezdxf.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 \fBezdxf.recover\fP module: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import sys from ezdxf import recover try: # low level structure repair: 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() .ft P .fi .UNINDENT .UNINDENT .sp For more loading scenarios follow the link: \fBezdxf.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 .nf .ft C doc.header[\(aqVarName\(aq] = value value = doc.header[\(aqVarName\(aq] .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fBHeaderSection\fP and online documentation from Autodesk for available \fI\%header variables\fP\&. .UNINDENT .UNINDENT .SS Set DXF Drawing Units .sp Use this HEADER variables to setup the default units for CAD applications opening the DXF file. This settings are 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: .sp $MEASUREMENT controls whether the current drawing uses imperial or metric hatch pattern and linetype files: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.header[\(aq$MEASUREMENT\(aq] = 1 .ft P .fi .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ 0 T} T{ English T} _ T{ 1 T} T{ Metric T} _ .TE .sp $LUNITS sets the linear units format for creating objects: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.header[\(aq$LUNITS\(aq] = 2 .ft P .fi .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 $AUNITS set units format for angles: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.header[\(aq$AUNITS\(aq] = 0 .ft P .fi .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 $INSUNITS set default drawing units for AutoCAD DesignCenter blocks: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C doc.header[\(aq$INSUNITS\(aq] = 6 .ft P .fi .UNINDENT .UNINDENT .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 .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 .nf .ft C # on Windows py \-3 \-m ezdxf.pp your_dxf_file.dxf # on Linux/Mac python3 \-m ezdxf.pp your_dxf_file.dxf .ft P .fi .UNINDENT .UNINDENT .sp This produces a HTML file \fIyour_dxf_file.html\fP with a nicer layout than a plain DXF file and DXF handles as links between DXF entities, this simplifies the navigation between the DXF entities. .sp Changed in version 0.8.3: Since ezdxf \fI\%v0.8.3\fP, a script called \fBdxfpp\fP will be added to your Python script path: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C usage: dxfpp [\-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 .ft P .fi .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 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 .nf .ft C doc.set_modelspace_vport(height=10, center=(10, 10)) .ft P .fi .UNINDENT .UNINDENT .sp New in version 0.11. .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 .nf .ft C doc.set_modelspace_vport(height=10, center=(0, 0)) .ft P .fi .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 So far \- no solution for showing IMAGES with relative paths on loading. .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 .nf .ft C doc.set_modelspace_vport(height=10, center=(10, 10)) .ft P .fi .UNINDENT .UNINDENT .sp New in version 0.11. .SS DXF Content .sp General preconditions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import sys import ezdxf try: doc = ezdxf.readfile("your_dxf_file.dxf") 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() .ft P .fi .UNINDENT .UNINDENT .SS Get/Set Entity Color .sp The entity color is stored as ACI (AutoCAD Color Index): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C aci = entity.dxf.color .ft P .fi .UNINDENT .UNINDENT .sp Default value is 256 which means BYLAYER: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C layer = doc.layers.get(entity.dxf.layer) aci = layer.get_color() .ft P .fi .UNINDENT .UNINDENT .sp The special \fBget_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 .nf .ft C entity.dxf.color = 1 .ft P .fi .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 .nf .ft C from ezdxf.tools.rgb import DXF_DEFAULT_COLORS, int2rgb # 24 bit value RRRRRRRRGGGGGGGGBBBBBBBB rgb24 = DXF_DEFAULT_COLORS[aci] print(f\(aqRGB Hex Value: #{rgb24:06X}\(aq) r, g, b = int2rgb(rgb24) print(f\(aqRGB Channel Values: R={r:02X} G={g:02X} b={b:02X}\(aq) .ft P .fi .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 \fBtrue_color\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # set true color value to red entity.dxf.true_color = 0xFF0000 .ft P .fi .UNINDENT .UNINDENT .sp The \fBrgb\fP property of the \fBDXFGraphic\fP entity add support to get/set RGB value as (r, g, b)\-tuple: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # set true color value to red entity.rgb = (255, 0, 0) .ft P .fi .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 Block Reference Attributes .sp Block references (\fBInsert\fP) can have attached attributes (\fBAttrib\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 .nf .ft C # get all INSERT entities with entity.dxf.name == "Part12" blockrefs = msp.query(\(aqINSERT[name=="Part12"]\(aq) if len(blockrefs): entity = blockrefs[0] # process first entity found for attrib in entity.attribs: if attrib.dxf.tag == "diameter": # identify attribute by tag attrib.dxf.text = "17mm" # change attribute content .ft P .fi .UNINDENT .UNINDENT .sp Get attribute by tag: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C diameter = entity.get_attrib(\(aqdiameter\(aq) if diameter is not None: diameter.dxf.text = "17mm" .ft P .fi .UNINDENT .UNINDENT .SS Adding XDATA to Entities .sp Adding XDATA as list of tuples (group code, value) by \fBset_xdata()\fP, overwrites data if already present: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) ]) .ft P .fi .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 \fBget_xdata()\fP returns the extended data for an entity as \fBTags\fP object. .SS Get Overridden DIMSTYLE Values from DIMENSION .sp In general the \fBDimension\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 .nf .ft C 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) .ft P .fi .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 .nf .ft C 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() .ft P .fi .UNINDENT .UNINDENT .SH FAQ .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 mode only and will not get any new features, just bugfixes. .sp There are no advantages of \fIdxfwrite\fP over \fIezdxf\fP, \fIdxfwrite\fP has the 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 normal 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. .SH RENDERING .sp The \fI\%ezdxf.render\fP subpackage provides helpful utilities to create complex forms. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 create complex meshes as \fBMesh\fP entity. .IP \(bu 2 render complex curves like bezier curves, euler spirals or splines as \fBPolyline\fP entity .IP \(bu 2 vertex generators for simple and complex forms like circle, ellipse or euler spiral .UNINDENT .UNINDENT .UNINDENT .sp Content .SS Spline .sp Render a B\-spline as 2D/3D \fBPolyline\fP, can be used with DXF R12. The advantage over \fI\%R12Spline\fP is the real 3D support which means the B\-spline curve vertices has not to be in a plane and no hassle with UCS for 3D placing. .INDENT 0.0 .TP .B class ezdxf.render.Spline .INDENT 7.0 .TP .B __init__(points: Iterable[Vertex] = None, segments: int = 100) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP – spline definition points as \fBVector\fP or \fB(x, y, z)\fP tuple .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: BaseLayout, degree: int = 3, method: str = \(aqchord\(aq, dxfattribs: dict = None) -> None Render a B\-spline as 2D/3D \fBPolyline\fP, where the definition points are fit points. .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 2D spline vertices uses: \fBadd_polyline2d()\fP .IP \(bu 2 3D spline vertices uses: \fBadd_polyline3d()\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_open_bspline(layout: BaseLayout, degree: int = 3, dxfattribs: dict = None) -> None Render an open uniform BSpline as 3D \fBPolyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\fP object .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_uniform_bspline(layout: BaseLayout, degree: int = 3, dxfattribs: dict = None) -> None Render a uniform BSpline as 3D \fBPolyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\fP object .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_closed_bspline(layout: BaseLayout, degree: int = 3, dxfattribs: dict = None) -> None Render a closed uniform BSpline as 3D \fBPolyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\fP object .IP \(bu 2 \fBdegree\fP – degree of B\-spline (order = \fIdegree\fP + 1) .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_open_rbspline(layout: BaseLayout, weights: Iterable[float], degree: int = 3, dxfattribs: dict = None) -> None Render a rational open uniform BSpline as 3D \fBPolyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_uniform_rbspline(layout: BaseLayout, weights: Iterable[float], degree: int = 3, dxfattribs: dict = None) -> None Render a rational uniform BSpline as 3D \fBPolyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_closed_rbspline(layout: BaseLayout, weights: Iterable[float], degree: int = 3, dxfattribs: dict = None) -> None Render a rational BSpline as 3D \fBPolyline\fP\&. Definition points are control points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS R12Spline .sp 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 (OCS, UCS). .sp The result is not better than \fI\%Spline\fP, it is also just a POLYLINE entity, but as with all tools, you never know if someone needs it some day. .INDENT 0.0 .TP .B class ezdxf.render.R12Spline .INDENT 7.0 .TP .B __init__(control_points: Iterable[Vertex], 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 as \fB(x, y)\fP tuples or \fBVector\fP objects .IP \(bu 2 \fBdegree\fP – degree of B\-spline, \fB2\fP or \fB3\fP are valid values .IP \(bu 2 \fBclosed\fP – \fBTrue\fP for closed curve .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render(layout: BaseLayout, segments: int = 40, ucs: UCS = None, dxfattribs: dict = None) -> Polyline Renders the B\-spline into \fIlayout\fP as 2D \fBPolyline\fP entity. Use an \fBUCS\fP to place the 2D spline in 3D space, see \fI\%approximate()\fP for more information. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\fP object .IP \(bu 2 \fBsegments\fP – count of line segments for approximation, vertex count is \fIsegments\fP + 1 .IP \(bu 2 \fBucs\fP – \fBUCS\fP definition, control points in ucs coordinates. .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int = 40, ucs: UCS = None) -> List[Vertex] Approximate B\-spline by a polyline with \fIsegments\fP line segments. If \fIucs\fP is not \fBNone\fP, ucs defines an \fBUCS\fP, to transformed the curve into OCS\&. 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 maybe 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 – \fBUCS\fP definition, control points in ucs coordinates. .UNINDENT .TP .B Returns list of vertices in \fBOCS\fP as \fBVector\fP objects .UNINDENT .UNINDENT .UNINDENT .SS Bezier .sp Render a bezier curve as 2D/3D \fBPolyline\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. .INDENT 0.0 .TP .B class ezdxf.render.Bezier .INDENT 7.0 .TP .B start(point: Vertex, tangent: Vertex) -> None Set start point and start tangent. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint\fP – start point as \fBVector\fP or \fB(x, y, z)\fP tuple .IP \(bu 2 \fBtangent\fP – start tangent as vector, example: \fB(5, 0, 0)\fP means a horizontal tangent with a length of 5 drawing units .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B append(point: Vertex, tangent1: Vertex, tangent2: Vertex = 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 as \fBVector\fP or \fB(x, y, z)\fP tuple .IP \(bu 2 \fBtangent1\fP – first control tangent as vector “left” of control point .IP \(bu 2 \fBtangent2\fP – second control tangent as vector “right” of control point, if omitted \fItangent2\fP = \fI\-tangent1\fP .IP \(bu 2 \fBsegments\fP – count of line segments for polyline approximation, count of line segments from previous control point to appended control point. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render(layout: BaseLayout, force3d: bool = False, dxfattribs: dict = None) -> None Render bezier curve as 2D/3D \fBPolyline\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\fP object .IP \(bu 2 \fBforce3d\fP – force 3D polyline rendering .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fBPolyline\fP .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS EulerSpiral .sp Render an \fI\%euler spiral\fP as 3D \fBPolyline\fP or \fI\%Spline\fP\&. .sp This is a parametric curve, which always starts at the origin \fB(0, 0)\fP\&. .INDENT 0.0 .TP .B class ezdxf.render.EulerSpiral .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: BaseLayout, length: float = 1, segments: int = 100, matrix: Matrix44 = None, dxfattribs: dict = None) Render curve as \fBPolyline\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBMatrix44\fP .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fBPolyline\fP .UNINDENT .TP .B Returns \fBPolyline\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_spline(layout: BaseLayout, length: float = 1, fit_points: int = 10, degree: int = 3, matrix: Matrix44 = None, dxfattribs: dict = None) Render curve as \fBSpline\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBMatrix44\fP .IP \(bu 2 \fBdxfattribs\fP – DXF attributes for \fBSpline\fP .UNINDENT .TP .B Returns \fBSpline\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=100, max_step_size=1, max_heading=pi / 2, retarget=20) -> Iterable[Vec2] Returns a random 2D path as iterable of \fBVec2\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=100, max_step_size=1, max_heading=pi / 2, max_pitch=pi / 8, retarget=20) -> Iterable[Vector] Returns a random 3D path as iterable of \fBVector\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\%circle()\fP .IP \(bu 2 \fI\%square()\fP .IP \(bu 2 \fI\%box()\fP .IP \(bu 2 \fI\%ellipse()\fP .IP \(bu 2 \fI\%euler_spiral()\fP .IP \(bu 2 \fI\%ngon()\fP .IP \(bu 2 \fI\%star()\fP .IP \(bu 2 \fI\%gear()\fP .UNINDENT .sp 3D Forms .INDENT 0.0 .IP \(bu 2 \fI\%cube()\fP .IP \(bu 2 \fI\%cylinder()\fP .IP \(bu 2 \fI\%cylinder_2p()\fP .IP \(bu 2 \fI\%cone()\fP .IP \(bu 2 \fI\%cone_2p()\fP .IP \(bu 2 \fI\%sphere()\fP .UNINDENT .sp 3D Form Builder .INDENT 0.0 .IP \(bu 2 \fI\%extrude()\fP .IP \(bu 2 \fI\%from_profiles_linear()\fP .IP \(bu 2 \fI\%from_profiles_spline()\fP .IP \(bu 2 \fI\%rotation_form()\fP .UNINDENT .UNINDENT .UNINDENT .SS 2D Forms .INDENT 0.0 .INDENT 3.5 Basic 2D shapes as iterable of \fBVector\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.circle(count: int, radius: float = 1, elevation: float = 0, close: bool = False) -> Iterable[Vector] Create polygon vertices for a \fI\%circle\fP with \fIradius\fP and \fIcount\fP corners, \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 \fBVector\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.square(size: float = 1.) -> Tuple[Vector, Vector, Vector, Vector] Returns 4 vertices for a square with a side length of \fIsize\fP, lower left corner is \fB(0, 0)\fP, upper right corner is (\fIsize\fP, \fIsize\fP). .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.box(sx: float = 1., sy: float = 1.) -> Tuple[Vector, Vector, Vector, Vector] Returns 4 vertices for a box \fIsx\fP by \fIsy\fP, lower left corner is \fB(0, 0)\fP, upper right corner is (\fIsx\fP, \fIsy\fP). .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 = 2 * pi, elevation: float = 0) -> Iterable[Vector] Create polygon vertices for an \fI\%ellipse\fP with \fIrx\fP as x\-axis radius and \fIry\fP for y\-axis radius with \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 \fB0\fP .. \fB2*pi\fP .IP \(bu 2 \fBend_param\fP – end of ellipse in range \fB0\fP .. \fB2*pi\fP .IP \(bu 2 \fBelevation\fP – z\-axis for all vertices .UNINDENT .TP .B Returns vertices in counter clockwise orientation as \fBVector\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[Vector] 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 \fB(0, 0)\fP\&. .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 \fBVector\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.ngon(count: int, length: float = None, radius: float = None, rotation: float = 0., elevation: float = 0., close: bool = False) -> Iterable[Vector] 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 higher priority. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – count of polygon corners >= \fB3\fP .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 \fBVector\fP objects .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.star(count: int, r1: float, r2: float, rotation: float = 0., elevation: float = 0., close: bool = False) -> Iterable[Vector] Returns corner vertices for \fI\%star shapes\fP\&. .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\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcount\fP – spike count >= \fB3\fP .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 \fBVector\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[Vector] Returns \fI\%gear\fP (cogwheel) corner vertices. .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 >= \fB3\fP .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 \fBVector\fP objects .UNINDENT .UNINDENT .SS 3D Forms .sp Create 3D forms as \fBMeshTransformer\fP objects. .INDENT 0.0 .TP .B ezdxf.render.forms.cube(center: bool = True) -> MeshTransformer Create a \fI\%cube\fP as \fBMeshTransformer\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: \fBMeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.cylinder(count: int, radius: float = 1., top_radius: float = None, top_center: Vertex = (0, 0, 1), caps=True, ngons=True) -> MeshTransformer Create a \fI\%cylinder\fP as \fBMeshTransformer\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 bottom cap and top cap (as N\-gons) .IP \(bu 2 \fBngons\fP – use ngons for caps if \fBTrue\fP else subdivide caps into triangles .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.cylinder_2p(count: int = 16, radius: float = 1, base_center=(0, 0, 0), top_center=(0, 0, 1)) -> MeshTransformer Create a \fI\%cylinder\fP as \fBMeshTransformer\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 – profiles 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 .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .sp New in version 0.11. .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.cone(count: int, radius: float, apex: Vertex = (0, 0, 1), caps=True, ngons=True) -> MeshTransformer Create a \fI\%cone\fP as \fBMeshTransformer\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 if \fBTrue\fP .IP \(bu 2 \fBngons\fP – use ngons for caps if \fBTrue\fP else subdivide caps into triangles .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.cone_2p(count: int, radius: float, apex: Vertex = (0, 0, 1)) -> MeshTransformer Create a \fI\%cone\fP as \fBMeshTransformer\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 .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .sp New in version 0.11. .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 \fBMeshTransformer\fP object, center is fixed at origin (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 quads for body faces if \fBTrue\fP else triangles .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .sp New in version 0.11. .UNINDENT .SS 3D Form Builder .INDENT 0.0 .TP .B ezdxf.render.forms.extrude(profile: Iterable[Vertex], path: Iterable[Vertex], close=True) -> MeshTransformer Extrude a \fIprofile\fP polygon along a \fIpath\fP polyline, vertices of profile should be in counter clockwise order. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBprofile\fP – sweeping profile as list of \fB(x, y, z)\fP tuples in counter clock wise order .IP \(bu 2 \fBpath\fP – extrusion path as list of \fB(x, y, z)\fP tuples .IP \(bu 2 \fBclose\fP – close profile polygon if \fBTrue\fP .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.from_profiles_linear(profiles: Iterable[Iterable[Vertex]], close=True, caps=False, ngons=True) -> MeshTransformer Create MESH entity by 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 \fBcaps\fP – close hull with bottom cap and top cap .IP \(bu 2 \fBngons\fP – use ngons for caps if \fBTrue\fP else subdivide caps into triangles .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.from_profiles_spline(profiles: Iterable[Iterable[Vertex]], subdivide: int = 4, close=True, caps=False, ngons=True) -> MeshTransformer Create MESH entity by spline interpolation between given \fIprofiles\fP\&. Requires at least 4 profiles. A subdivide 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 \fBcaps\fP – close hull with bottom cap and top cap .IP \(bu 2 \fBngons\fP – use ngons for caps if \fBTrue\fP else subdivide caps into triangles .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.render.forms.rotation_form(count: int, profile: Iterable[Vertex], angle: float = 2 * pi, axis: Vertex = (1, 0, 0)) -> MeshTransformer Create MESH entity 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 .UNINDENT .UNINDENT .sp Returns: \fBMeshTransformer\fP .UNINDENT .SS MeshBuilder .sp The \fI\%MeshBuilder\fP is a helper class to create \fBMesh\fP entities. Stores a list of vertices, a list of edges where an edge is a list of indices into the vertices list, and a faces list where each face is a list of indices into the vertices list. .sp The \fI\%MeshBuilder.render()\fP method, renders the mesh into a \fBMesh\fP entity. The \fBMesh\fP entity supports ngons in AutoCAD, ngons are polygons with more than 4 vertices. .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 \fBVector\fP or \fB(x, y, z)\fP tuple .UNINDENT .INDENT 7.0 .TP .B edges List of edges as 2\-tuple of vertex indices, where a vertex index is the index of the vertex in the \fI\%vertices\fP list. .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, \fBMesh\fP supports ngons, so the count of vertices is not limited. .UNINDENT .INDENT 7.0 .TP .B copy() Returns a copy of mesh. .UNINDENT .INDENT 7.0 .TP .B faces_as_vertices() -> Iterable[List[Vector]] Iterate over all mesh faces as list of vertices. .UNINDENT .INDENT 7.0 .TP .B edges_as_vertices() -> Iterable[Tuple[Vector, Vector]] Iterate over all mesh edges as tuple of two vertices. .UNINDENT .INDENT 7.0 .TP .B add_vertices(vertices: Iterable[Vertex]) -> Sequence[int] Add new vertices to the mesh, each vertex is a \fB(x, y, z)\fP tuple or a \fBVector\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 \fBVector\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 add_edge(vertices: Iterable[Vertex]) -> None An edge consist of two vertices \fB[v1, v2]\fP, each vertex is a \fB(x, y, z)\fP tuple or a \fBVector\fP object. The new vertex indices are stored as edge in the \fI\%edges\fP list. .INDENT 7.0 .TP .B Parameters \fBvertices\fP – list of 2 vertices : [(x1, y1, z1), (x2, y2, z2)] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add_face(vertices: Iterable[Vertex]) -> 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 \fBVector\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=None, faces=None, edges=None, mesh=None) -> None Add another mesh to this mesh. .sp A \fImesh\fP can be a \fI\%MeshBuilder\fP, \fI\%MeshVertexMerger\fP or \fBMesh\fP object or requires the attributes \fI\%vertices\fP, \fI\%edges\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 \fBVector\fP object .IP \(bu 2 \fBfaces\fP – list of faces, a face is a list of vertex indices .IP \(bu 2 \fBedges\fP – list of edges, an edge is a list of vertex indices .IP \(bu 2 \fBmesh\fP – another mesh entity .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B has_none_planar_faces() -> bool Returns \fBTrue\fP if any face is none planar. .UNINDENT .INDENT 7.0 .TP .B render(layout: BaseLayout, dxfattribs: dict = None, matrix: Matrix44 = None, ucs: UCS = None) Render mesh as \fBMesh\fP entity into \fIlayout\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBMatrix44\fP .IP \(bu 2 \fBucs\fP – transform vertices by \fBUCS\fP to WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_polyface(layout: BaseLayout, dxfattribs: dict = None, matrix: Matrix44 = None, ucs: UCS = None) Render mesh as \fBPolyface\fP entity into \fIlayout\fP\&. .sp New in version 0.11.1. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBMatrix44\fP .IP \(bu 2 \fBucs\fP – transform vertices by \fBUCS\fP to WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_3dfaces(layout: BaseLayout, dxfattribs: dict = None, matrix: Matrix44 = None, ucs: UCS = None) Render mesh as \fBFace3d\fP entities into \fIlayout\fP\&. .sp New in version 0.12. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlayout\fP – \fBBaseLayout\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 \fBMatrix44\fP .IP \(bu 2 \fBucs\fP – transform vertices by \fBUCS\fP to WCS .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B render_normals(layout: BaseLayout, length: float = 1, relative=True, dxfattribs: dict = None) Render face normals as \fBLine\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 – \fBBaseLayout\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 classmethod from_mesh(other) -> ezdxf.render.mesh.MeshBuilder 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 \fBMesh\fP entity or any object providing attributes \fI\%vertices\fP, \fI\%edges\fP and \fI\%faces\fP\&. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_polyface(other: Union[Polymesh, Polyface]) -> MeshBuilder Create new mesh from a \fBPolyface\fP or \fBPolymesh\fP object. .sp New in version 0.11.1. .UNINDENT .INDENT 7.0 .TP .B classmethod from_builder(other: MeshBuilder) Create new mesh from other mesh builder, faster than \fI\%from_mesh()\fP but supports only \fI\%MeshBuilder\fP and inherited classes. .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 subdivide(level: int = 1, quads=True, edges=False) -> MeshTransformer Returns a new \fI\%MeshTransformer\fP object with subdivided faces and edges. .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 .IP \(bu 2 \fBedges\fP – also subdivide edges if \fBTrue\fP .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(matrix: Matrix44) Transform mesh inplace by applying the transformation \fImatrix\fP\&. .INDENT 7.0 .TP .B Parameters \fBmatrix\fP – 4x4 transformation matrix as \fBMatrix44\fP object .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx: float = 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 .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: Vertex, 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 Vector .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. Location of merged vertices is the location of the first vertex with the same key. .sp This class is intended as intermediate object to create a compact meshes and convert them to \fI\%MeshTransformer\fP objects to apply transformations to the mesh: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C mesh = MeshVertexMerger() # create your mesh mesh.add_face(...) # convert mesh to MeshTransformer object return MeshTransformer.from_builder(mesh) .ft P .fi .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 and for all vertices with the same key look at 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\&. Location of merged vertices is the average location of all vertices with the same key, this needs extra memory and runtime in comparision 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 .SS Trace .sp This module provides tools to create banded lines like LWPOLYLINE with width information. Path rendering as quadrilaterals: \fBTrace\fP, \fBSolid\fP or \fBFace3d\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 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 append(trace: ezdxf.render.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[Vec2, Vec2, Vec2, Vec2] Yields all faces as 4\-tuples of \fBVec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(dxftype=\(aqTRACE\(aq, dxfattribs: Dict = None, doc: Drawing = None) -> Union[Solid, Trace, Face3d] 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_polyline(polyline: DXFGraphic, segments: int = 64) -> TraceBuilder Create a complete trace from a LWPOLYLINE or a 2D POLYLINE entity, the trace consist of multiple sub\-traces if bulge values are present. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpolyline\fP – \fBLWPolyline\fP or 2D \fBPolyline\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__(item) .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: Vertex, start_width: float, end_width: float = 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[Vec2, Vec2, Vec2, Vec2] Yields all faces as 4\-tuples of \fBVec2\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: Dict = None, doc: Drawing = None) -> Union[Solid, Trace, Face3d] 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[Vec2, Vec2, Vec2, Vec2] Yields all faces as 4\-tuples of \fBVec2\fP objects. .UNINDENT .INDENT 7.0 .TP .B virtual_entities(dxftype=\(aqTRACE\(aq, dxfattribs: Dict = None, doc: Drawing = None) -> Union[Solid, Trace, Face3d] 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: ezdxf.math.arc.ConstructionArc, start_width: float, end_width: float, segments: int = 64) -> ezdxf.render.trace.CurvedTrace Create curved trace from an arc. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBarc\fP – \fBConstructionArc\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: ezdxf.math.bspline.BSpline, start_width: float, end_width: float, segments: int) -> ezdxf.render.trace.CurvedTrace Create curved trace from a B\-spline. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBspline\fP – \fBBSpline\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 Path .sp This module implements a geometrical \fI\%Path\fP supported by several render backends, with the goal to create such paths from LWPOLYLINE, POLYLINE and HATCH boundary paths and send them to the render backend, see \fBezdxf.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 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 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 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 “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. .INDENT 0.0 .TP .B class ezdxf.render.path.Path .INDENT 7.0 .TP .B start \fI\%Path\fP start point, resetting the start point of an empty path is possible. .UNINDENT .INDENT 7.0 .TP .B end \fI\%Path\fP end point. .UNINDENT .INDENT 7.0 .TP .B is_closed Returns \fBTrue\fP if the start point is close to the end point. .UNINDENT .INDENT 7.0 .TP .B classmethod from_lwpolyline(lwpolyline: LWPolyline) -> Path Returns a \fI\%Path\fP from a \fBLWPolyline\fP entity, all vertices transformed to WCS. .UNINDENT .INDENT 7.0 .TP .B classmethod from_polyline(polyline: Polyline) -> Path Returns a \fI\%Path\fP from a \fBPolyline\fP entity, all vertices transformed to WCS. .UNINDENT .INDENT 7.0 .TP .B classmethod from_spline(spline: Spline, level: int = 4) -> Path Returns a \fI\%Path\fP from a \fBSpline\fP\&. .UNINDENT .INDENT 7.0 .TP .B classmethod from_ellipse(ellipse: Ellipse, segments: int = 1) -> Path Returns a \fI\%Path\fP from a \fBEllipse\fP\&. .UNINDENT .INDENT 7.0 .TP .B classmethod from_arc(arc: Arc, segments: int = 1) -> Path Returns a \fI\%Path\fP from an \fBArc\fP\&. .UNINDENT .INDENT 7.0 .TP .B classmethod from_circle(circle: Circle, segments: int = 1) -> Path Returns a \fI\%Path\fP from a \fBCircle\fP\&. .UNINDENT .INDENT 7.0 .TP .B classmethod from_hatch_polyline_path(polyline: PolylinePath, ocs: ezdxf.math.ucs.OCS = None, elevation: float = 0) -> Path Returns a \fI\%Path\fP from a \fBHatch\fP polyline path. .UNINDENT .INDENT 7.0 .TP .B classmethod from_hatch_edge_path(edges: EdgePath, ocs: ezdxf.math.ucs.OCS = None, elevation: float = 0) -> Path Returns a \fI\%Path\fP from a \fBHatch\fP edge path. .UNINDENT .INDENT 7.0 .TP .B control_vertices() Yields all path control vertices in consecutive order. .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. .UNINDENT .INDENT 7.0 .TP .B line_to(location: Vector) Add a line from actual path end point to \fIlocation\fP\&. .UNINDENT .INDENT 7.0 .TP .B curve_to(location: Vector, ctrl1: Vector, ctrl2: Vector) 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 close() -> None Close path by adding a line segment from the end point to the start point. .UNINDENT .INDENT 7.0 .TP .B clone() -> Path Returns a new copy of \fI\%Path\fP with shared immutable data. .UNINDENT .INDENT 7.0 .TP .B reversed() -> Path Returns a new \fI\%Path\fP with reversed segments and control vertices. .UNINDENT .INDENT 7.0 .TP .B clockwise() -> Path Returns new \fI\%Path\fP in clockwise orientation. .UNINDENT .INDENT 7.0 .TP .B counter_clockwise() -> Path Returns new \fI\%Path\fP in counter\-clockwise orientation. .UNINDENT .INDENT 7.0 .TP .B add_curves(curves: Iterable[Bezier4P]) Add multiple cubic Bèzier\-curves to the path. .sp Auto\-detect if the path end point is connected to the start\- or end point of the curves, if none of them is close to the path end point a line from the path end point to the curves start point will be added. .UNINDENT .INDENT 7.0 .TP .B add_ellipse(ellipse: ConstructionEllipse, segments=1) Add an elliptical arc as multiple cubic Bèzier\-curves, use \fBfrom_arc()\fP constructor of class \fBConstructionEllipse\fP to add circular arcs. .sp Auto\-detect connection point, if none is close a line from the path end point to the ellipse start point will be added (see \fI\%add_curves()\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 \fBellipse\fP – ellipse parameters as \fBConstructionEllipse\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 7.0 .TP .B add_spline(spline: BSpline, level=4) Add a B\-spline as multiple cubic Bèzier\-curves. .sp Non\-rational B\-splines of 3rd degree gets a perfect conversion to cubic bezier curves with a minimal count of curve segments, all other B\-spline require much more curve segments for approximation. .sp Auto\-detect connection point, if none is close a line from the path end point to the spline start point will be added (see \fI\%add_curves()\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 \fBspline\fP – B\-spline parameters as \fBBSpline\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 7.0 .TP .B transform(m: Matrix44) -> Path Returns a new transformed path. .INDENT 7.0 .TP .B Parameters \fBm\fP – transformation matrix of type \fBMatrix44\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B approximate(segments: int) -> Iterable[Vector] Approximate path by vertices, \fIsegments\fP is the count of approximation segments for each cubic bezier curve. .UNINDENT .UNINDENT .SH ADD-ONS .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 .sp New in version 0.12: Write Binary DXF files. .SS Tutorial .sp A simple example with different DXF entities: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from random import random from ezdxf.addons import r12writer with r12writer("quick_and_dirty_dxf_r12.dxf") 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("test the text entity", align="MIDDLE_CENTER") .ft P .fi .UNINDENT .UNINDENT .sp A simple example of writing really many entities in a short time: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from random import random from ezdxf.addons import r12writer MAX_X_COORD = 1000.0 MAX_Y_COORD = 1000.0 CIRCLE_COUNT = 1000000 with r12writer("many_circles.dxf") as dxf: for i in range(CIRCLE_COUNT): dxf.add_circle((MAX_X_COORD*random(), MAX_Y_COORD*random()), radius=2) .ft P .fi .UNINDENT .UNINDENT .sp Show all available line types: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .UNINDENT .UNINDENT .SS Reference .INDENT 0.0 .TP .B ezdxf.addons.r12writer.r12writer(stream: Union[TextIO, BinaryIO, str], fixed_tables=False, fmt=\(aqasc\(aq) -> R12FastStreamWriter 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 New in version 0.12: Set argument \fIfmt\fP to \fB\(aqasc\(aq\fP to write ASCII DXF file (default) or \fB\(aqbin\(aq\fP 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: [, ], 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, linetype: str = 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 ACI 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, linetype: str = 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 ACI 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, linetype: str = 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 ACI 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, linetype: str = 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 ACI 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, linetype: str = 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 ACI 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, linetype: str = 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 ACI 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, linetype: str = 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 ACI 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, linetype: str = 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 ACI see \fI\%add_line()\fP .IP \(bu 2 \fBlinetype\fP – line type as string see \fI\%add_line()\fP .UNINDENT .UNINDENT .sp Changed in version 0.12: Write only 3D POLYLINE entity, added \fIclosed\fP argument. .UNINDENT .INDENT 7.0 .TP .B add_polyface(vertices: Iterable[Sequence[float]], faces: Iterable[Sequence[int]], layer: str = \(aq0\(aq, color: int = None, linetype: str = 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 .nf .ft C 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)]) .ft P .fi .UNINDENT .UNINDENT .sp All 3D form functions of the \fBezdxf.render.forms\fP module return \fBMeshBuilder\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 ACI 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, linetype: str = 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 ACI 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 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 ACI 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 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 \fBDXFGraphic\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 \fBadd_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 .nf .ft C 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() .ft P .fi .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 \fBadd_foreign_entity()\fP for all supported types: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .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 .nf .ft C 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) .ft P .fi .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 \fBImporter\fP add\-on for a more safe entity import. .INDENT 0.0 .TP .B ezdxf.addons.iterdxf.opendxf(filename: str, errors: str = \(aqsurrogateescape\(aq) -> IterDXF 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 \fBDXFStructureError\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: str, types: Iterable[str] = 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 \fBDXFStructureError\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, errors: str = \(aqsurrogateescape\(aq) -> Iterable[DXFGraphic] Iterate over all modelspace entities as \fBDXFGraphic\fP objects in one 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 \fBDXFStructureError\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: str) -> IterDXFWriter 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) -> Iterable[DXFGraphic] Returns an iterator for all supported DXF entities in the modelspace. These entities are regular \fBDXFGraphic\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 \fBMeshTransformer\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 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 .nf .ft C 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) .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.addons.importer.Importer(source: Drawing, target: Drawing) The \fI\%Importer\fP class is central element for importing data from other DXF drawings. .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 .TP .B Variables .INDENT 7.0 .IP \(bu 2 \fBsource\fP – source drawing .IP \(bu 2 \fBtarget\fP – target drawing .IP \(bu 2 \fBused_layer\fP – Set of used layer names as string, AutoCAD accepts layer names without a LAYER table entry. .IP \(bu 2 \fBused_linetypes\fP – Set of used linetype names as string, these linetypes require a TABLE entry or AutoCAD will crash. .IP \(bu 2 \fBused_styles\fP – Set of used text style names, these text styles require a TABLE entry or AutoCAD will crash. .IP \(bu 2 \fBused_dimstyles\fP – Set of used dimension style names, these dimension styles require a TABLE entry or AutoCAD will crash. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B finalize() -> None Finalize import by importing required table entries and block definition, without finalization the target drawing is maybe invalid fore AutoCAD. Call \fI\%finalize()\fP 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. If block already exist the block will be renamed if argument \fIrename\fP is True, else the existing target block will be used instead of the source block. Required name resolving for imported block references (INSERT), will be done in \fI\%Importer.finalize()\fP\&. .sp To replace an existing block in the target drawing, just delete it before importing: \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 exists in target drawing .UNINDENT .UNINDENT .sp Returns: block name (renamed) .INDENT 7.0 .TP .B Raises \fBValueError\fP – source block not found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_blocks(block_names: Iterable[str], rename=False) -> None Import all block definitions. If block already exist the block will be renamed if argument \fIrename\fP is True, else the existing target block will be used instead of the source block. Required name resolving for imported block references (INSERT), will be done in \fI\%Importer.finalize()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBblock_names\fP – names of blocks to import .IP \(bu 2 \fBrename\fP – rename block if exists in target drawing .UNINDENT .TP .B Raises \fBValueError\fP – source block not found .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_entities(entities: Iterable[DXFEntity], target_layout: BaseLayout = None) -> None Import all \fIentities\fP into \fItarget_layout\fP or the modelspace of the target drawing, if \fItarget_layout\fP is \fINone\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 drawing .UNINDENT .TP .B Raises \fBDXFStructureError\fP – \fItarget_layout\fP is not a layout of target drawing .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_entity(entity: DXFEntity, target_layout: BaseLayout = None) -> None Imports a single DXF \fIentity\fP into \fItarget_layout\fP or the modelspace of the target drawing, if \fItarget_layout\fP is \fINone\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 drawing .UNINDENT .TP .B Raises \fBDXFStructureError\fP – \fItarget_layout\fP is not a layout of target drawing .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_modelspace(target_layout: BaseLayout = None) -> None Import all entities from source modelspace into \fItarget_layout\fP or the modelspace of the target drawing, if \fItarget_layout\fP is \fINone\fP\&. .INDENT 7.0 .TP .B Parameters \fBtarget_layout\fP – any layout (modelspace, paperspace or block) from the target drawing .TP .B Raises \fBDXFStructureError\fP – \fItarget_layout\fP is not a layout of target drawing .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_paperspace_layout(name: str) -> Layout Import paperspace layout \fIname\fP into target drawing. Recreates the source paperspace layout in the target drawing, renames the target paperspace if already a paperspace with same \fIname\fP exist and imports all entities from source paperspace into 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 \fBDXFTypeError\fP – invalid modelspace import .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_paperspace_layouts() -> None Import all paperspace layouts and their content into target drawing. Target layouts will be renamed if already a layout with same name exist. Layouts will be imported in original tab order. .UNINDENT .INDENT 7.0 .TP .B import_table(name: str, entries: Union[str, Iterable[str]] = \(aq*\(aq, replace=False) -> None Import specific table entries from source drawing into target drawing. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP – valid table names are \fBlayers\fP, \fBlinetypes\fP and \fBstyles\fP .IP \(bu 2 \fBentries\fP – Iterable of table names as strings, or a single table name or \fB*\fP for all table entries .IP \(bu 2 \fBreplace\fP – True to replace already existing table entry else ignore existing entry .UNINDENT .TP .B Raises \fBTypeError\fP – unsupported table type .UNINDENT .UNINDENT .INDENT 7.0 .TP .B import_tables(table_names: Union[str, Iterable[str]] = \(aq*\(aq, replace=False) -> None Import DXF tables from source drawing into target drawing. .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 \fB*\fP for all supported tables .IP \(bu 2 \fBreplace\fP – True 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) -> Layout Recreate source paperspace layout \fIname\fP in the target drawing. The layout will be renamed if \fIname\fP already exist in the target drawing. 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 Drawing / Export Addon .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 .nf .ft C $ ./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 .ft P .fi .UNINDENT .UNINDENT .sp Example for the usage of the \fBmatplotlib\fP backend: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .UNINDENT .UNINDENT .sp Simplified render workflow but with less control: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .UNINDENT .UNINDENT .SS Details .sp The rendering is performed in two stages. The front\-end traverses the DXF document structure, converting each encountered entity into primitive drawing commands. These commands are fed to a back\-end which implements the interface: \fBBackend\fP\&. Currently a PyQt5 (QGraphicsScene based) and Matplotlib backend are implemented. .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 \fBRenderContext\fP class supports passing a plot style table (CTB\-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 see \fBexamples/addons/drawing/cad_viewer.py\fP for an advanced use of the module. See \fBexamples/addons/drawing/draw_cad.py\fP for a simple use of the module. .sp see \fIdrawing.md\fP in the ezdxf repository for additional behaviours documented during the development of this add\-on. .SS Limitations .INDENT 0.0 .IP \(bu 2 Line types and hatch patterns/gradients are ignored .IP \(bu 2 rich text formatting is ignored (drawn as plain text) .IP \(bu 2 If the backend does not match the font then the exact text placement and wrapping may appear slightly different .IP \(bu 2 No support for MULTILEADER .IP \(bu 2 The style which POINT entities are drawn in are not stored in the dxf file and so cannot be replicated exactly .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 hatches with holes (holes are rendered filled) .IP \(bu 2 viewports (rendered as rectangles) .IP \(bu 2 3D (some entities may not display correctly in 3D (see possible improvements below)) however many things should already work in 3D. .IP \(bu 2 vertical text (will render as horizontal text) .IP \(bu 2 multiple columns of text (placement of additional columns may be incorrect) .UNINDENT .UNINDENT .SS Future Possible Improvements .INDENT 0.0 .IP \(bu 2 pass the font to backend if available .IP \(bu 2 deal with nested polygons/hatches by triangulating them: \fI\%Triangulation\fP .IP \(bu 2 both the matplotlib and pyqt backends have built\-in support for rendering hatched patterns (see \fI\%MatplotlibHatch\fP and \fI\%QtBrushHatch\fP) so the interface could pass that information through or query the backend to determine whether it automatically supports complex drawing commands such as hatching, or whether the frontend should break the shape into simpler commands (i.e. calculate and draw each line of a hatch) .IP \(bu 2 text formatting commands could be interpreted and broken into text chunks which can be drawn with a single font weight or modification such as italics .UNINDENT .SS dxf2code .sp Translate DXF entities and structures into Python source code. .sp Short example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.dxf2code.entities_to_code(entities: Iterable[DXFEntity], layout: str = \(aqlayout\(aq, ignore: Iterable[str] = None) -> Code 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: BlockLayout, drawing: str = \(aqdoc\(aq, ignore: Iterable[str] = None) -> Code 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[DXFEntity], drawing=\(aqdoc\(aq) -> Code .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 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: ezdxf.addons.dxf2code.Code, 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 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 \fBPaperspace\fP or the \fBModelspace\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) -> Union[ColorDependentPlotStyles, NamedPlotStyles] Load the CTB or STB file \fIfilename\fP from file system. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.new_ctb() -> ColorDependentPlotStyles Create a new CTB file. .sp Changed in version 0.10: renamed from \fBnew()\fP .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.acadctb.new_stb() -> NamedPlotStyles Create a new STB file. .sp New in version 0.10. .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) -> PlotStyle Returns \fI\%PlotStyle\fP for ACI \fIaci\fP\&. .UNINDENT .INDENT 7.0 .TP .B __iter__() -> Iterable[PlotStyle] Iterable of all plot styles. .UNINDENT .INDENT 7.0 .TP .B new_style(aci: int, data: dict = None) -> PlotStyle 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 – ACI .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 ACI\&. .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(filename: str) -> None 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) -> PlotStyle Returns \fI\%PlotStyle\fP by \fIname\fP\&. .UNINDENT .INDENT 7.0 .TP .B __delitem__(name: str) 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, localized_name: str = None, data: dict = None) -> PlotStyle 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 ACI\&. .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(filename: str) -> None Save STB file as \fIfilename\fP to the file system. .UNINDENT .INDENT 7.0 .TP .B write(stream: BinaryIO) -> None 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 ACI 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 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 New in version 0.11. .sp Example for usage: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .UNINDENT .UNINDENT [image: Cube vs Cylinder] [image] .sp This CSG kernel supports only meshes as \fBMeshBuilder\fP objects, which can be created from and converted to DXF \fBMesh\fP entities. .sp This CSG kernel is \fBnot\fP compatible with ACIS objects like \fBSolid3d\fP, \fBBody\fP, \fBSurface\fP or \fBRegion\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 .nf .ft C 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) .ft P .fi .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 .nf .ft C 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}) .ft P .fi .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 .nf .ft C 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}) .ft P .fi .UNINDENT .UNINDENT [image: Menger Sponge vs Sphere] [image] .SS CSG Class .INDENT 0.0 .TP .B class ezdxf.addons.pycsg.CSG(mesh: MeshBuilder, 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 \fBMeshBuilder\fP objects and results can be exported as \fBMeshTransformer\fP objects to \fIezdxf\fP by method \fI\%mesh()\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmesh\fP – \fBezdxf.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 \fBezdxf.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: CSG) -> CSG 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 .nf .ft C A.union(B) +\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-+ | | | | | A | | | | +\-\-+\-\-\-\-+ = | +\-\-\-\-+ +\-\-\-\-+\-\-+ | +\-\-\-\-+ | | B | | | | | | | +\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-+ .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __add__(other: CSG) -> CSG .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C union = A + B .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B subtract(other: CSG) -> CSG 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 .nf .ft C A.subtract(B) +\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-+ | | | | | A | | | | +\-\-+\-\-\-\-+ = | +\-\-+ +\-\-\-\-+\-\-+ | +\-\-\-\-+ | B | | | +\-\-\-\-\-\-\-+ .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __sub__(other: CSG) -> CSG .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C difference = A \- B .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B intersect(other: CSG) -> CSG 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 .nf .ft C A.intersect(B) +\-\-\-\-\-\-\-+ | | | A | | +\-\-+\-\-\-\-+ = +\-\-+ +\-\-\-\-+\-\-+ | +\-\-+ | B | | | +\-\-\-\-\-\-\-+ .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __mul__(other: CSG) -> CSG .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C intersection = A * B .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B inverse() -> CSG 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 Showcase Forms .SS MengerSponge .sp Build a 3D \fI\%Menger sponge\fP\&. .INDENT 0.0 .TP .B class ezdxf.addons.MengerSponge(location: Vertex = (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: dict = None, matrix: Matrix44 = None, ucs: UCS = 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() -> Iterable[ezdxf.render.mesh.MeshTransformer] Yields all cubes of the menger sponge as individual \fBMeshTransformer\fP objects. .UNINDENT .INDENT 7.0 .TP .B mesh() -> ezdxf.render.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: Vertex = (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: dict = None, matrix: Matrix44 = None, ucs: UCS = 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[ezdxf.render.mesh.MeshTransformer] Yields all pyramids of the sierpinsky pyramid as individual \fBMeshTransformer\fP objects. .UNINDENT .INDENT 7.0 .TP .B mesh() -> ezdxf.render.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 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 .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. .sp At least at Windows the GUI of the ODA File Converter pops up on every call. .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 .sp Usage: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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) .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.exec_path Path to installed \fIODA File Converter\fP executable, default is \fB"C:\eProgram Files\eODA\eODAFileConverter\eODAFileConverter.exe"\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.temp_path Path to a temporary folder by default the system temp folder defined by environment variable \fBTMP\fP or \fBTEMP\fP\&. .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.readfile(filename: str, version: str = None, audit=False) -> Drawing Use 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 .UNINDENT .UNINDENT .INDENT 0.0 .TP .B ezdxf.addons.odafc.export_dwg(doc: Drawing, filename: str, version: str = None, audit=False) Use an installed \fI\%ODA File Converter\fP to export a DXF document \fIdoc\fP as a DWG file. .sp Saves a temporary DXF file and convert this DXF file into a DWG file 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 – export filename of DWG file, extension will be changed to \fB\(aq.dwg\(aq\fP .IP \(bu 2 \fBversion\fP – export file as specific version, by default the same version as the source document. .IP \(bu 2 \fBaudit\fP – audit source file by ODA File Converter at exporting .UNINDENT .UNINDENT .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 String Value Encoding .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 \fB(group code, value)\fP\&. .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 (with the introduction of extended symbol names in DXF R2000, the 255\-character limit has been increased to 2049 single\-byte characters not including the newline at the end of the line) T} _ T{ 10\-39 T} T{ Double precision 3D point value T} _ T{ 40\-59 T} T{ Double\-precision floating\-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 (255\-character maximum, less for Unicode strings) T} _ T{ 102 T} T{ String (255\-character maximum, less for Unicode strings) 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{ String representing hex handle value T} _ T{ 330\-369 T} T{ String representing hex object IDs 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{ String representing hex handle value T} _ T{ 999 T} T{ Comment (string) T} _ T{ 1000\-1009 T} T{ String (same limits as indicated with 0\-9 code range) 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{ 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 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 data but ends \fBbefore\fP \fI\%Embedded Objects\fP\&. .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: About 1005 Group Codes 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. T} _ T{ 1011, 1021, 1031 T} T{ Unlike a simple 3D point, the world space coordinates are moved, scaled, rotated, mirrored, and stretched along with the parent entity to which the extended data belongs. T} _ T{ 1012, 1012, 1022 T} T{ Also a 3D point that is scaled, rotated, and mirrored along with the parent (but is not moved or stretched) T} _ T{ 1013, 1023, 1033 T} T{ Also a 3D point that is scaled, rotated, and mirrored along with the parent (but is not moved or stretched) 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 \fB(1001, ...)\fP 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 \fB(1001, APPID)\fP 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 \fB(1, ...)\fP\&. If the text string is longer than 250 characters, the string is divided into 250\-character chunks, which appear in one or more \fB(3, ...)\fP tags. If \fB(3, ...)\fP tags are used, the last group is a \fB(1, ...)\fP tag and has fewer than 250 characters: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 3 \&... TwoHundredAndFifty Characters .... 3 \&... TwoHundredAndFifty Characters .... 1 less than TwoHundredAndFifty Characters .ft P .fi .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 DXF File Encoding .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 \fB(100, Subclass Name)\fP 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 .nf .ft C 102 {ACAD_XDICTIONARY 360 Hard\-owner ID/handle to owner dictionary 102 } .ft P .fi .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 .nf .ft C 102 {ACAD_REACTORS 330 first Soft\-pointer ID/handle to owner dictionary 330 second Soft\-pointer ID/handle to owner dictionary \&... 102 } .ft P .fi .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 \fB(0, ...)\fP and \fB(102, \(aq{...\(aq)\fP\&. “{YOURAPPID” means the APPID string with an preceding “{“. The application defined data tag sequence: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 102 {YOURAPPID \&... 102 } .ft P .fi .UNINDENT .UNINDENT .sp \fB(102, \(aqYOURAPPID}\(aq)\fP is also a valid closing tag: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 102 {YOURAPPID \&... 102 YOURAPPID} .ft P .fi .UNINDENT .UNINDENT .sp All groups defined with a beginning \fB(102, ...)\fP 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 Embedded object start with \fB(101, "Embedded Object")\fP tag .IP \(bu 2 Embedded object is appended to the encapsulated object .IP \(bu 2 \fB(101, "Embedded Object")\fP tag is the end of the encapsulating object, also of its \fI\%Extended Data\fP .IP \(bu 2 Embedded object tags can contain any group code except the DXF structure tag \fB(0, ...)\fP .UNINDENT .sp \fBUnconfirmed assumptions:\fP .INDENT 0.0 .IP \(bu 2 The encapsulating object can contain more than one embedded object. .IP \(bu 2 Embedded objects separated by \fB(101, "Embedded Object")\fP tags .IP \(bu 2 every entity can contain embedded objects .IP \(bu 2 XDATA sections replaced by embedded objects, at least for the MTEXT entity .UNINDENT .sp Real world example from an AutoCAD 2018 file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 .ft P .fi .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. .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. .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: dxf_tags_internals .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 .nf .ft C 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 .ft P .fi .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 .nf .ft C 0 SECTION 2 ENTITIES 0 ENDSEC 0 EOF .ft P .fi .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 DICTONARY ACAD_GROUP can be empty .UNINDENT .sp Minimal DXF to download: \fI\%https://bitbucket.org/mozman/ezdxf/downloads/Minimal_DXF_AC1021.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 model space, 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 File Structure .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 Block Management Structures 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 Layout Management Structures 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, a drastic real world example why it is better to avoid 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. 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. The ezdxf template for DXF R2018 contains 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 \fBACAD_GROUP:\fP supported by ezdxf .IP \(bu 2 \fBACAD_LAYOUT:\fP supported by ezdxf .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 \fBACAD_PLOTSTYLENAME:\fP 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 .nf .ft C 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 shoul 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 .ft P .fi .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 .nf .ft C 0 <<< Begin HEADER section SECTION 2 HEADER 9 $ACADVER <<< Header variable items go here 1 AC1009 \&... 0 ENDSEC <<< End HEADER section .ft P .fi .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 \fBHeaderSection\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 \fBClassesSection\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 .nf .ft C 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. Set to 1 if class was not loaded when this DXF file was created, and 0 otherwise 0 281 <<< is\-an\-entity flag. Set to 1 if class reside in the BLOCKS or ENTITIES section. If 0, instances may appear only in the OBJECTS section 0 0 <<< second CLASS entity CLASS \&... \&... 0 <<< end of CLASSES section ENDSEC .ft P .fi .UNINDENT .UNINDENT .SS TABLES Section .sp TODO .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 .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Block Management Structures Layout Management Structures .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, extension_dict_internals and XRECORD data of graphical entities are also stored in the OBJECTS section. .SS DXF Tables .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 .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 Coordinate Systems .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 .nf .ft C 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 .ft P .fi .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 DCS, 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 .nf .ft C 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 .ft P .fi .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 .nf .ft C 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 .ft P .fi .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 .UNINDENT .UNINDENT .UNINDENT .SS Table Structure DXF R12 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 0 <<< start of table TABLE 2 <<< set table type LTYPE 70 <<< count of line types defined in this table, 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 .ft P .fi .UNINDENT .UNINDENT .SS Table Structure DXF R2000+ .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 0 <<< start of table TABLE 2 <<< set table type LTYPE 5 <<< LTYPE table handle 5F 330 <<< owner tag, tables has no owner 0 100 <<< subclass marker AcDbSymbolTable 70 <<< count of line types defined in this table, 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 .ft P .fi .UNINDENT .UNINDENT .SS Simple Line Type .sp \fIezdxf\fP setup for line type ‘CENTER’: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dwg.linetypes.new("CENTER", dxfattribs={ description = "Center ____ _ ____ _ ____ _ ____ _ ____ _ ____", pattern=[2.0, 1.25, \-0.25, 0.25, \-0.25], }) .ft P .fi .UNINDENT .UNINDENT .SS Simple Line Type Tag Structure DXF R2000+ .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 65 73 4 40 2.0 49 1.25 74 0 49 \-0.25 74 0 49 0.25 74 0 49 \-0.25 74 0 .ft P .fi .UNINDENT .UNINDENT .SS Complex Line Type TEXT .sp \fIezdxf\fP setup for line type ‘GASLEITUNG’: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dwg.linetypes.new(\(aqGASLEITUNG\(aq, dxfattribs={ \(aqdescription\(aq: \(aqGasleitung2 \-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\-\-GAS\-\-\(aq, \(aqlength\(aq: 1, \(aqpattern\(aq: \(aqA,.5,\-.2,["GAS",STANDARD,S=.1,U=0.0,X=\-0.1,Y=\-.05],\-.25\(aq, }) .ft P .fi .UNINDENT .UNINDENT .SS TEXT Tag Structure .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 65 73 3 40 1 49 0.5 74 0 49 \-0.2 74 2 75 0 340 11 46 0.1 50 0.0 44 \-0.1 45 \-0.05 9 GAS 49 \-0.25 74 0 .ft P .fi .UNINDENT .UNINDENT .SS Complex Line Type SHAPE .sp ezdxf setup for line type ‘GRENZE2’: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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, }) .ft P .fi .UNINDENT .UNINDENT .SS SHAPE Tag Structure .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 0 LTYPE 5 615 330 5F 100 <<< subclass marker AcDbSymbolTableRecord 100 <<< subclass marker AcDbLinetypeTableRecord 2 GRENZE2 70 0 3 Grenze eckig \-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\-\-\-\-[]\-\-\-\-[]\-\- 72 65 73 4 40 1.45 49 0.25 74 0 49 \-0.1 74 4 75 132 340 616 46 0.1 50 0.0 44 \-0.1 45 0.0 49 \-0.1 74 0 49 1.0 74 0 .ft P .fi .UNINDENT .UNINDENT .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 .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .SS DIMSTYLE Entry DXF R12 .SS DIMSTYLE Variables DXF R12 .sp Source: \fI\%CADDManger 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 .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .SS Additional DIMSTYLE Variables DXF R13/14 .sp Source: \fI\%CADDManger 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\%CADDManger 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 .nf .ft C 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 .ft P .fi .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 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 DXF Entities .SS DIMENSION Entity .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: dimstyle_table_internals .UNINDENT .UNINDENT .UNINDENT [image] .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: blocks_section_internals .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 .nf .ft C 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 .ft P .fi .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 Layout Management Structures, 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 Tag Structure DXF R13 and later .IP \(bu 2 ezdxf DXF Internals: tables_section_internals .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 .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp DXF R13 BLOCK_RECORD structure: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 "layout key" 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 "layout key" 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 .ft P .fi .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 Block Management Structures .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 .nf .ft C 0 LAYOUT 5 <<< handle 59 102 <<< extension dictionary (ignore) {ACAD_XDICTIONARY 360 1C3 102 } 102 <<< reactor (required?) {ACAD_REACTORS 330 1A <<< pointer to "ACAD_LAYOUT" DICTIONARY (layout management table) 102 } 330 <<< owner handle 1A <<< pointer to "ACAD_LAYOUT" 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 ("Model" 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) \&... .ft P .fi .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 .nf .ft C 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 \&... "Layout1") 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 <<< "main" 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 .ft P .fi .UNINDENT .UNINDENT .SH DEVELOPER GUIDES .sp Information about \fIezdxf\fP internals. .SS Design .sp The pkg\-design 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: \fBModelspace\fP, \fBPaperspace\fP layouts and \fBBlockLayout\fP\&. The core management object of this layouts is the BLOCK_RECORD entity (\fBBlockRecord\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: Layout Management Structures .sp For more information about blocks see also: Block Management Structures .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: objects_section_internals .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: Data Model .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 \fBezdxf.read()\fP and \fBezdxf.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 \fBDXFEntity\fP objects by it’s handle, every \fBDrawing\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) -> DXFEntity 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: DXFEntity) -> 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: Union[str, DXFEntity]) -> 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__() -> Iterable[str] Iterable of all handles, does filter destroyed entities but not entities in the trashcan. .UNINDENT .INDENT 7.0 .TP .B get(handle: str) -> Optional[DXFEntity] 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[DXFEntity] Iterable of all entities, does filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B items() -> Iterable[Tuple[str, DXFEntity]] Iterable of all (handle, entities) pairs, does filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B add(entity: DXFEntity) -> 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() -> ezdxf.entitydb.EntityDB.Trashcan Returns a new trashcan, empty trashcan manually by: : func:\fITrashcan.clear()\fP\&. .UNINDENT .INDENT 7.0 .TP .B trashcan() -> ezdxf.entitydb.EntityDB.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 .UNINDENT .SS Entity Space .INDENT 0.0 .TP .B class ezdxf.entitydb.EntitySpace(entities=None) An \fI\%EntitySpace\fP is a collection of \fBDXFEntity\fP objects, that stores only references to \fBDXFEntity\fP objects. .sp The \fBModelspace\fP, any \fBPaperspace\fP layout and \fBBlockLayout\fP objects have an \fI\%EntitySpace\fP container to store their entities. .INDENT 7.0 .TP .B __iter__() -> Iterable[DXFEntity] Iterable of all entities, filters destroyed entities. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index) -> DXFEntity 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 less entities as \fBList[DXFEntity]\fP\&. Does not filter destroyed entities. .UNINDENT .INDENT 7.0 .TP .B __len__() -> int Count of entities inluding 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: DXFEntity) -> None Add \fIentity\fP\&. .UNINDENT .INDENT 7.0 .TP .B extend(entities: Iterable[DXFEntity]) -> None Add multiple \fIentities\fP\&. .UNINDENT .INDENT 7.0 .TP .B remove(entity: DXFEntity) -> 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: TagValue) -> ezdxf.lldxf.types.DXFTag 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, TagValue]]) -> Iterable[ezdxf.lldxf.types.DXFTag] Returns an iterable if :class: \fIDXFTag\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: TagValue) Immutable DXFTag class \- immutable by design, not by implementation. .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 .TP .B Variables .INDENT 7.0 .IP \(bu 2 \fBcode\fP – group code as int (do not change) .IP \(bu 2 \fBvalue\fP – tag value (read\-only property) .UNINDENT .UNINDENT .INDENT 7.0 .TP .B __eq__(other) -> bool \fBTrue\fP if \fIother\fP and \fIself\fP has same content for \fBcode\fP and \fBvalue\fP\&. .UNINDENT .INDENT 7.0 .TP .B __getitem__(index: int) Returns \fBcode\fP for index 0 and \fBvalue\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__() -> Iterable 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() -> ezdxf.lldxf.types.DXFTag 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[Tuple] 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 \fBDXFTag\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 \fBDXFTag\fP as flat list. Low level tag container, only required for advanced stuff. .INDENT 7.0 .TP .B classmethod from_text(text: str) -> Tags 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 \fBDXFValueError\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 \fBDXFTag\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) -> DXFTag Returns first \fBDXFTag\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 \fBDXFTag\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[DXFTag] Returns a list of \fBDXFTag\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[DXFTag] 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) -> Tags 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) -> int Return index of first \fBDXFTag\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: DXFTag) 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: DXFTag) 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[DXFTag] 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: Tags, codes: Iterable[int]) -> Tags 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 \fBDXFTag\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[DXFTag], splitcode: int = 0) -> Iterable[Tags] 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 \fBint\fP (\fIsplitcode\fP) – group code of split tag .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B class ezdxf.lldxf.extendedtags.ExtendedTags(tags: Iterable[DXFTag] = None, legacy=False) Represents the extended DXF tag structure introduced with DXF R13. .INDENT 7.0 .TP .B Args: tags: iterable of \fBDXFTag\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() -> ExtendedTags 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) -> Tags 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) -> Tags 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: IterableTags = None) -> Tags 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 .nf .ft C try: xdata = tags.get_xdata(\(aqEZDXF\(aq) except ValueError: xdata = tags.new_xdata(\(aqEZDXF\(aq) .ft P .fi .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) -> Tags 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) -> Tags 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: IterableTags = None, subclass_name: str = None) -> Tags 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 .nf .ft C 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) .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B classmethod from_text(text: str, legacy: bool = False) -> ExtendedTags 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() -> TagList Returns a deep copy. .UNINDENT .INDENT 7.0 .TP .B classmethod from_tags(tags: Tags, code: int) -> TagList 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__() -> Iterable[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() -> VertexArray Returns a deep copy. .UNINDENT .INDENT 7.0 .TP .B classmethod from_tags(tags: Iterable[DXFTag], code: int = 10) -> VertexArray Setup point array from iterable tags. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtags\fP – iterable of \fBDXFVertex\fP .IP \(bu 2 \fBcode\fP – group code to collect .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B export_dxf(tagwriter: ezdxf.lldxf.tagwriter.TagWriter, code=10) .UNINDENT .UNINDENT .SS Documentation Guide .SS Formatting Guide .sp This section is only for me, 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 .nf .ft C pip install sphinx\-rtd\-theme .ft P .fi .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, "x")\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 .nf .ft C e = ExampleCls(flag=True) .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flag This is the attribute \fI\%flag\fP\&. .sp New in version 0.9: New feature \fIflag\fP .sp Changed in version 0.10: The new meaning of \fIflag\fP is … .sp Deprecated since version 0.11: \fIflag\fP is obsolete .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 ACI .TP .B ACIS The 3D ACIS Modeler (\fI\%ACIS\fP) is a geometric modeling kernel developed by \fI\%Spatial Corp.\fP ® (formerly Spatial Technology), part of Dassault Systems. .TP .B bulge The bulge value is used to create arc shaped line segments in \fBPolyline\fP and \fBLWPolyline\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 ®. .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 INDICES AND TABLES .INDENT 0.0 .IP \(bu 2 genindex .IP \(bu 2 search .UNINDENT .SH AUTHOR Manfred Moitzi .SH COPYRIGHT 2011-2020, Manfred Moitzi .\" Generated by docutils manpage writer. .