### Installation Output Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Expected output format after successful installation. ```default ezdxf 0.17.2b4 from D:\Source\build\.venv\lib\site-packages\ezdxf Python version: 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] using C-extensions: yes using Matplotlib: no ``` -------------------------------- ### Example installation output Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Expected output after running the verification command. ```text ezdxf 0.17.2b4 from /home/pi/src/.venv/lib/python3.7/site-packages/ezdxf Python version: 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] using C-extensions: yes using Matplotlib: yes ``` -------------------------------- ### Linux Installation Output Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Expected output format after successful installation on Linux. ```default ezdxf 0.17.2b4 from /home/mozman/src/.venv/lib/python3.8/site-packages/ezdxf Python version: 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0] using C-extensions: yes using Matplotlib: no ``` -------------------------------- ### Install PyQt5 on Ubuntu Server Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Installs PyQt5 bindings via apt. ```bash sudo apt install python3-pyqt5 ``` -------------------------------- ### Verify Installation Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Check the installed version and configuration. ```default python3 -m ezdxf -V ``` -------------------------------- ### Build and Install ezdxf Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Compile and install the package from the local directory. ```default cd ezdxf pip3 install . ``` -------------------------------- ### Install Sphinx and Theme Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Installs Sphinx and the Read the Docs theme for building documentation. Run this command in your build environment. ```bash pip3 install Sphinx sphinx-rtd-theme ``` -------------------------------- ### AutoLISP Output Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/custom_data.md Example output from the SHOWXDATA AutoLISP command. ```Text : SHOWXDATA Select entity: ("YOUR_UNIQUE_ID" (1000 . "custom text") (1040 . 3.141592) ... ``` -------------------------------- ### Install Linux Python Dependencies Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Install Cython and wheel in the virtual environment. ```default pip3 install cython wheel ``` -------------------------------- ### guide.ExampleCls Source: https://github.com/mozman/ezdxf/blob/master/docs/source/develop/doc_formatting_guide.md Example class demonstrating constructor, attributes, and methods. ```APIDOC ## guide.ExampleCls ### Description The [`ExampleCls`](#guide.ExampleCls) constructor accepts a number of optional keyword arguments. Each keyword argument corresponds to an instance attribute. ### Method POST (example, actual method not specified) ### Endpoint /guide/ExampleCls ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **flag** (bool) - Optional - This is the attribute [`flag`](#guide.ExampleCls.flag). ### Request Example ```json { "flag": true } ``` ### Response #### Success Response (200) - **flag** (bool) - The flag attribute of the ExampleCls instance. #### Response Example ```json { "flag": true } ``` ``` ```APIDOC ## guide.ExampleCls.set_axis ### Description Sets the axis for the ExampleCls instance. ### Method PUT (example, actual method not specified) ### Endpoint /guide/ExampleCls/{instance_id}/set_axis ### Parameters #### Path Parameters - **instance_id** (str) - Required - The ID of the ExampleCls instance. #### Query Parameters None #### Request Body - **axis** (tuple) - Required - axis as (x, y, z) tuple ### Request Example ```json { "axis": [1.0, 2.0, 3.0] } ``` ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## guide.ExampleCls.example_method ### Description Example method of class [`ExampleCls`](#guide.ExampleCls). ### Method GET (example, actual method not specified) ### Endpoint /guide/ExampleCls/{instance_id}/example_method ### Parameters #### Path Parameters - **instance_id** (str) - Required - The ID of the ExampleCls instance. #### Query Parameters - **flag** (bool) - Optional - Description for flag parameter, defaults to False. #### Request Body None ### Request Example ```json { "flag": true } ``` ### Response #### Success Response (200) None (function returns None) #### Response Example None ``` -------------------------------- ### Install Sphinx Read the Docs Theme Source: https://github.com/mozman/ezdxf/blob/master/docs/source/develop/doc_formatting_guide.md Use this command to install the required Sphinx theme for documentation rendering. ```default pip install sphinx-rtd-theme ``` -------------------------------- ### Cache performance output examples Source: https://github.com/mozman/ezdxf/blob/master/docs/source/bbox.md Example output showing cache hits and misses for different configurations. ```default Cache(n=1226, hits=0, misses=3273) ``` ```default Cache(n=2206, hits=0, misses=3273) ``` ```default 1st run: Cache(n=1226, hits=0, misses=3273) 2nd run: Cache(n=1226, hits=1224, misses=3309) ``` ```default 1st run: Cache(n=2206, hits=0, misses=3273) 2nd run: Cache(n=2206, hits=1224, misses=3309) ``` ```default 1st run: Cache(n=1037, hits=0, misses=4074) 2nd run: Cache(n=1037, hits=1037, misses=6078) ``` ```default 1st run: Cache(n=2019, hits=0, misses=4074) 2nd run: Cache(n=2019, hits=2018, misses=4116) ``` -------------------------------- ### guide.example_func Source: https://github.com/mozman/ezdxf/blob/master/docs/source/develop/doc_formatting_guide.md Example function demonstrating parameter types and default values. ```APIDOC ## guide.example_func(a: int, b: str, test: str = None, flag: bool = True) ### Description Parameters a and b are positional arguments, argument test defaults to `None` and flag to `True`. Set a to 70 and b to “x” as an example. ### Method GET (example, actual method not specified) ### Endpoint /guide/example_func ### Parameters #### Path Parameters None #### Query Parameters - **test** (str) - Optional - Description for test parameter - **flag** (bool) - Optional - Description for flag parameter #### Request Body None ### Request Example ```json { "a": 70, "b": "x" } ``` ### Response #### Success Response (200) None (function returns None) #### Response Example None ``` -------------------------------- ### Example Usage of Bin-Packing Add-on Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/binpacking.md This code replicates the example from the py3dbp package, demonstrating how to add items and bins, pack them, and export the results to a DXF file. It requires the ezdxf and py3dbp libraries. ```python from typing import List import ezdxf from ezdxf import colors from ezdxf.addons import binpacking as bp SMALL_ENVELOPE = ("small-envelope", 11.5, 6.125, 0.25, 10) LARGE_ENVELOPE = ("large-envelope", 15.0, 12.0, 0.75, 15) SMALL_BOX = ("small-box", 8.625, 5.375, 1.625, 70.0) MEDIUM_BOX = ("medium-box", 11.0, 8.5, 5.5, 70.0) MEDIUM_BOX2 = ("medium-box-2", 13.625, 11.875, 3.375, 70.0) LARGE_BOX = ("large-box", 12.0, 12.0, 5.5, 70.0) LARGE_BOX2 = ("large-box-2", 23.6875, 11.75, 3.0, 70.0) ALL_BINS = [ SMALL_ENVELOPE, LARGE_ENVELOPE, SMALL_BOX, MEDIUM_BOX, MEDIUM_BOX2, LARGE_BOX, LARGE_BOX2, ] def build_packer(): packer = bp.Packer() packer.add_item("50g [powder 1]", 3.9370, 1.9685, 1.9685, 1) packer.add_item("50g [powder 2]", 3.9370, 1.9685, 1.9685, 2) packer.add_item("50g [powder 3]", 3.9370, 1.9685, 1.9685, 3) packer.add_item("250g [powder 4]", 7.8740, 3.9370, 1.9685, 4) packer.add_item("250g [powder 5]", 7.8740, 3.9370, 1.9685, 5) packer.add_item("250g [powder 6]", 7.8740, 3.9370, 1.9685, 6) packer.add_item("250g [powder 7]", 7.8740, 3.9370, 1.9685, 7) packer.add_item("250g [powder 8]", 7.8740, 3.9370, 1.9685, 8) packer.add_item("250g [powder 9]", 7.8740, 3.9370, 1.9685, 9) return packer def make_doc(): doc = ezdxf.new() doc.layers.add("FRAME", color=colors.YELLOW) doc.layers.add("ITEMS") doc.layers.add("TEXT") return doc def main(filename): bins: List[bp.Bin] = [] for box in ALL_BINS: packer = build_packer() packer.add_bin(*box) packer.pack(bp.PickStrategy.BIGGER_FIRST) bins.extend(packer.bins) doc = make_doc() bp.export_dxf(doc.modelspace(), bins, offset=(0, 20, 0)) doc.saveas(filename) if __name__ == "__main__": main("py3dbp_example.dxf") ``` -------------------------------- ### Install Linux Build Dependencies Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Install system-level build tools and Python headers on Ubuntu/WSL. ```default sudo apt install build-essential python3.10-dev ``` -------------------------------- ### Install Build Dependencies Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Install required Python packages for building C-extensions. ```default pip3 install setuptools wheel cython ``` -------------------------------- ### Setup Windows Build Environment Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Commands to create a virtual environment on Windows. ```default mkdir build cd build py -m venv .venv .venv/Scripts/activate.bat ``` -------------------------------- ### Setup Linux Build Environment Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Commands to create a virtual environment on Linux. ```default cd ~ mkdir build cd build python3 -m venv .venv source .venv/bin/activate ``` -------------------------------- ### Install PyMuPdf Backend Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/drawing.md Install the PyMuPdf package using pip. This is required for the PyMuPdfBackend. ```bash pip install pymupdf ``` -------------------------------- ### Install build requirements on Ubuntu Server Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Installs essential build tools and Python venv support. ```bash sudo apt install build-essential python3-pip python3.9-venv ``` -------------------------------- ### Printed Output of AppData Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/custom_data.md This shows the expected output when running the AppData example code, displaying the entity information and the retrieved custom tags. ```Text LINE(#30) has 3 tags of AppData for AppID 'YOUR_UNIQUE_ID' (300, 'custom text') (370, 4711) (460, 3.141592) ``` -------------------------------- ### Install build requirements on Raspberry Pi OS Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Installs Matplotlib and PyQt5 bindings using the system package manager. ```bash sudo apt install python3-pip python3-matplotlib python3-pyqt5 ``` -------------------------------- ### Complete installation on Manjaro Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Executes the remaining build and verification steps. ```bash pip3 install cython wheel git clone https://github.com/mozman/ezdxf.git cd ezdxf pip3 install . python3 -m ezdxf -V ``` -------------------------------- ### Install Matplotlib Source: https://github.com/mozman/ezdxf/blob/master/docs/source/disassemble.md Install the optional Matplotlib package for improved text boundary calculations. This is done via the command line. ```default C:\> pip3 install matplotlib ``` -------------------------------- ### Run test suite Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Installs pytest and executes the project tests. ```bash pip3 install pytest python3 -m pytest tests integration_tests ``` -------------------------------- ### Importer Usage Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/importer.md An example demonstrating how to use the Importer class to import entities, layouts, and blocks from a source DXF drawing to a target drawing. ```APIDOC ## Example Usage ```python import ezdxf from ezdxf.addons import Importer sdoc = ezdxf.readfile('original.dxf') 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('SOURCE_ENTS') # query source entities ents = sdoc.modelspace().query('CIRCLE LINE') # 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('imported.dxf') ``` ``` -------------------------------- ### Initialize ExampleCls with Keyword Arguments Source: https://github.com/mozman/ezdxf/blob/master/docs/source/develop/doc_formatting_guide.md Demonstrates the constructor usage for the ExampleCls class with optional keyword arguments. ```default e = ExampleCls(flag=True) ``` -------------------------------- ### ARC Entity Transformation Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/upright.md Demonstrates the transformation of an ARC entity, including mirroring and applying the upright function. It highlights how start and end points may swap after the upright transformation. ```Python import ezdxf from ezdxf.upright import upright from ezdxf.math import Matrix44 doc = ezdxf.new() msp = doc.modelspace() arc = msp.add_arc( (5, 0), radius=5, start_angle=-90, end_angle=90, dxfattribs={"color": ezdxf.const.RED}, ) # draw lines to the start- and end point of the ARC msp.add_line((0, 0), arc.start_point, dxfattribs={"color": ezdxf.const.GREEN}) msp.add_line((0, 0), arc.end_point, dxfattribs={"color": ezdxf.const.BLUE}) # copy arc mirrored_arc = arc.copy() msp.add_entity(mirrored_arc) # mirror copy mirrored_arc.transform(Matrix44.scale(-1, 1, 1)) # This creates an inverted extrusion vector: assert mirrored_arc.dxf.extrusion.isclose((0, 0, -1)) # draw lines to the start- and end point of the mirrored ARC msp.add_line((0, 0), mirrored_arc.start_point, dxfattribs={"color": ezdxf.const.GREEN}) msp.add_line((0, 0), mirrored_arc.end_point, dxfattribs={"color": ezdxf.const.BLUE}) # This creates an inverted extrusion vector: assert mirrored_arc.dxf.extrusion.isclose((0, 0, -1)) start_point_inv = mirrored_arc.start_point end_point_inv = mirrored_arc.end_point upright(mirrored_arc) # OCS is aligned with WCS: assert mirrored_arc.dxf.extrusion.isclose((0, 0, 1)) # start- and end points are swapped after applying upright() assert mirrored_arc.start_point.isclose(end_point_inv) assert mirrored_arc.end_point.isclose(start_point_inv) ``` -------------------------------- ### Create DXF with Setup Resources Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/simple_drawings.md Initialize a DXF document with predefined resources like linetypes and text styles by setting `setup=True` in `ezdxf.new()`. This simplifies adding entities with standard styles. Note that font path configuration for text styles is application-specific. ```Python import ezdxf doc = ezdxf.new("R2010", setup=True) msp = doc.modelspace() msp.add_line((0, 0), (10, 0), dxfattribs={"linetype": "DASHED"}) ``` -------------------------------- ### Filter DXF Entities by Color (Default Value) Source: https://github.com/mozman/ezdxf/blob/master/docs/source/howto/drawing-addon.md Example of a filter function that safely accesses the 'color' attribute using `get()` with a default value of 7, preventing errors if the attribute is missing. This ensures robust filtering. ```default def my_filter(e: DXFGraphic) -> bool: return e.dxf.get("color", 7) != 2 ``` -------------------------------- ### GUID Management Source: https://github.com/mozman/ezdxf/blob/master/docs/source/drawing/drawing.md Functions to reset fingerprint and version GUIDs. ```APIDOC ## reset_fingerprint_guid() ### Description Reset fingerprint GUID. ``` ```APIDOC ## reset_version_guid() ### Description Reset version GUID. ``` -------------------------------- ### Using Custom Configuration Files Source: https://github.com/mozman/ezdxf/blob/master/docs/source/options.md Setting environment variables and loading custom configuration files. ```Text C:\> set EZDXF_CONFIG_FILE=D:\user\path\custom.ini ``` ```Python import ezdxf ezdxf.options.read("my_config.ini") ``` -------------------------------- ### Initialize DXF Document and Modelspace Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/mtext.md Sets up a new DXF document with R2007 support and prepares the modelspace for adding entities. Includes a lorem ipsum text for content. ```python import ezdxf doc = ezdxf.new("R2007", 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. """ ``` -------------------------------- ### Install build requirements on Manjaro Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Uses pacman to install necessary Python packages. ```bash sudo pacman -S python-pip python-matplotlib python-pyqt5 ``` -------------------------------- ### Setup Environment for XREF Tutorial Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/xref_module.md Required imports and constants for working with the ezdxf.xref module. ```python import ezdxf from ezdxf.addons import odafc from ezdxf.document import Drawing from ezdxf import xref, units, colors from ezdxf.render import forms DXFVERSION = "R2013" ``` -------------------------------- ### Install optional packages via pip Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Installs Matplotlib and PySide6 for Windows and WSL environments. ```bash pip3 install matplotlib PySide6 ``` -------------------------------- ### Initialize DXF Document and Layout Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/dxf_primitives.md Sets up a new DXF document, creates a layer, and prepares the modelspace for entity addition. ```default import ezdxf from ezdxf.gfxattribs import GfxAttribs doc = ezdxf.new() doc.layers.new("ENTITY", color=1) msp = doc.modelspace() attribs = GfxAttribs(layer="ENTITY") ``` -------------------------------- ### Bin Packing Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/binpacking.md This code demonstrates how to use the bin packing add-on to pack items into bins and export the result to a DXF file. ```APIDOC ## Bin Packing Example ### Description This example demonstrates how to use the `ezdxf.addons.binpacking` module to pack various items into different types of bins and then export the packed layout to a DXF file. ### Code ```python from typing import List import ezdxf from ezdxf import colors from ezdxf.addons import binpacking as bp SMALL_ENVELOPE = ("small-envelope", 11.5, 6.125, 0.25, 10) LARGE_ENVELOPE = ("large-envelope", 15.0, 12.0, 0.75, 15) SMALL_BOX = ("small-box", 8.625, 5.375, 1.625, 70.0) MEDIUM_BOX = ("medium-box", 11.0, 8.5, 5.5, 70.0) MEDIUM_BOX2 = ("medium-box-2", 13.625, 11.875, 3.375, 70.0) LARGE_BOX = ("large-box", 12.0, 12.0, 5.5, 70.0) LARGE_BOX2 = ("large-box-2", 23.6875, 11.75, 3.0, 70.0) ALL_BINS = [ SMALL_ENVELOPE, LARGE_ENVELOPE, SMALL_BOX, MEDIUM_BOX, MEDIUM_BOX2, LARGE_BOX, LARGE_BOX2, ] def build_packer(): packer = bp.Packer() packer.add_item("50g [powder 1]", 3.9370, 1.9685, 1.9685, 1) packer.add_item("50g [powder 2]", 3.9370, 1.9685, 1.9685, 2) packer.add_item("50g [powder 3]", 3.9370, 1.9685, 1.9685, 3) packer.add_item("250g [powder 4]", 7.8740, 3.9370, 1.9685, 4) packer.add_item("250g [powder 5]", 7.8740, 3.9370, 1.9685, 5) packer.add_item("250g [powder 6]", 7.8740, 3.9370, 1.9685, 6) packer.add_item("250g [powder 7]", 7.8740, 3.9370, 1.9685, 7) packer.add_item("250g [powder 8]", 7.8740, 3.9370, 1.9685, 8) packer.add_item("250g [powder 9]", 7.8740, 3.9370, 1.9685, 9) return packer def make_doc(): doc = ezdxf.new() doc.layers.add("FRAME", color=colors.YELLOW) doc.layers.add("ITEMS") doc.layers.add("TEXT") return doc def main(filename): bins: List[bp.Bin] = [] for box in ALL_BINS: packer = build_packer() packer.add_bin(*box) packer.pack(bp.PickStrategy.BIGGER_FIRST) bins.extend(packer.bins) doc = make_doc() bp.export_dxf(doc.modelspace(), bins, offset=(0, 20, 0)) doc.saveas(filename) if __name__ == "__main__": main("py3dbp_example.dxf") ``` ### Output This script generates a DXF file named `py3dbp_example.dxf` visualizing the packed bins. ``` -------------------------------- ### Build HTML Documentation Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Navigates to the docs directory and builds the HTML documentation using Make. The output will be in the build/html directory. ```bash cd docs make html ``` -------------------------------- ### MTEXT Background Fill Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/dxfinternals/entities/mtext.md Example of group codes for MTEXT background fill with ACI color and scaling. ```text ... 1 eu feugiat nulla facilisis at vero eros et accumsan et iusto ... 73 1 44 1.0 90 1, b00000001 <<< use a color 63 1 <<< ACI color (red) 45 1.5 <<< bg scaling factor, relative to the char height 441 0 <<< ignored (optional) ... ``` -------------------------------- ### Initialize DXF Document and MLEADERSTYLE Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/mleader.md Sets up a new DXF document and creates a custom MLEADERSTYLE based on the Standard style. ```python doc = ezdxf.new(setup=True) # Create a new custom MLEADERSTYLE: mleaderstyle = doc.mleader_styles.duplicate_entry("Standard", "EZDXF") # The required TEXT style "OpenSans" was created by ezdxf.new() because setup is True: mleaderstyle.set_mtext_style("OpenSans") msp = doc.modelspace() ``` -------------------------------- ### Create and Save a DXF Document Source: https://github.com/mozman/ezdxf/blob/master/README.md Demonstrates initializing a new DXF document, adding layers, inserting entities like lines and text, and saving the file. ```Python import ezdxf from ezdxf import colors from ezdxf.enums import TextEntityAlignment # Create a new DXF document. doc = ezdxf.new(dxfversion="R2010") # Create new table entries (layers, linetypes, text styles, ...). doc.layers.add("TEXTLAYER", color=colors.RED) # DXF entities (LINE, TEXT, ...) reside in a layout (modelspace, # paperspace layout or block definition). msp = doc.modelspace() # Add entities to a layout by factory methods: layout.add_...() msp.add_line((0, 0), (10, 0), dxfattribs={"color": colors.YELLOW}) msp.add_text( "Test", dxfattribs={ "layer": "TEXTLAYER" }).set_placement((0, 0.2), align=TextEntityAlignment.CENTER) # Save the DXF document. doc.saveas("test.dxf") ``` -------------------------------- ### MTEXT Text Frame XDATA Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/dxfinternals/entities/mtext.md Example of XDATA for MTEXT text frame, used for DXF versions < R2018. ```text ... 1001 ACAD 1000 ACAD_MTEXT_TEXT_BORDERS_BEGIN 1070 80 <<< group code for repeated flags 1070 16 <<< repeated group code 90? 1070 46 <<< group code for scaling factor, which is fixed? 1040 1.5 <<< scaling factor 1070 81 <<< group code for repeated flow direction? 1070 1 <<< flow direction? 1070 5 <<< group code for a handle, multiple entries possible 1005 #A8 <<< handle to the LWPOLYLINE text frame 1070 5 <<< group code for next handle 1005 #A9 <<< next handle ... 1000 ACAD_MTEXT_TEXT_BORDERS_END ``` -------------------------------- ### Get attribute with default value Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tasks/get_dxf_attributes.md Use the get method to retrieve an attribute value or a specified default if the attribute is missing. ```Python e.dxf.get('color', 9) ``` -------------------------------- ### Create New DXF Document with Standard Linetypes Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/common_graphical_attributes.md Initializes a new DXF document with standard linetypes included by setting the `setup` argument to `True`. ```python doc = ezdxf.new("R2010", setup=True) ``` -------------------------------- ### DXF R12 File Structure Example Source: https://github.com/mozman/ezdxf/blob/master/docs/source/dxfinternals/filestructure.md A template showing the standard section organization for a DXF R12 file. ```none 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 ``` -------------------------------- ### Set Spline Start and End Tangents via DXF Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/spline.md Sets the start and end tangents for splines defined by fit points directly through DXF attributes. ```python spline.dxf.start_tangent = (0, 1, 0) spline.dxf.end_tangent = (0, 1, 0) ``` -------------------------------- ### Configure Frontend Rendering Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/image_export.md Create a Frontend instance with a custom Configuration for a white background and black foreground color policy. ```python # 2. create the backend backend = svg.SVGBackend() # create a new configuration for a white background and and a black foreground color cfg = config.Configuration( background_policy=config.BackgroundPolicy.WHITE, color_policy=config.ColorPolicy.BLACK, ) # 3. create the frontend frontend = Frontend(context, backend, config=cfg) ``` -------------------------------- ### Install Build Requirements for Python Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Installs essential packages required for building Python from source on Debian-based systems. Ensure your package list is updated and upgraded first. ```bash sudo apt-get update sudo apt-get upgrade sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \ libncurses5-dev libncursesw5-dev xz-utils tk-dev ``` -------------------------------- ### Format Python Code with Black Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/dxf2code.md Formats a given Python source code string using the Black formatter. Ensure Black is installed (`pip3 install black`). ```default pip3 install black ``` -------------------------------- ### Build and Install Python Source: https://github.com/mozman/ezdxf/blob/master/docs/source/setup.md Compiles the Python interpreter using parallel jobs for faster build times and then installs it. The '-j 4' option utilizes 4 CPU cores for compilation. ```bash make -j 4 sudo make install ``` -------------------------------- ### Initialize DXF Document for TablePainter Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/tablepainter.md Set up a new DXF document with required styles and header settings for lineweight support. ```Python import ezdxf from ezdxf.enums import MTextEntityAlignment from ezdxf.addons import TablePainter doc = ezdxf.new("R2000") # required for lineweight support doc.header["$LWDISPLAY"] = 1 # show lineweights doc.styles.add("HEAD", font="OpenSans-ExtraBold.ttf") doc.styles.add("CELL", font="OpenSans-Regular.ttf") ``` -------------------------------- ### Import DXF entities using Importer Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/importer.md Demonstrates the workflow of initializing an Importer, importing modelspace entities and layouts, and finalizing the target document. ```Python import ezdxf from ezdxf.addons import Importer sdoc = ezdxf.readfile('original.dxf') 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('SOURCE_ENTS') # query source entities ents = sdoc.modelspace().query('CIRCLE LINE') # 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('imported.dxf') ``` -------------------------------- ### Initialize Configuration Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/drawing.md Creates a Configuration object for the drawing add-on. This allows customization of various drawing aspects like lineweight scaling. ```default my_config = Configuration(lineweight_scaling=2) ``` -------------------------------- ### Create LWPolyline with varying start and end widths Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/lwpolyline.md Demonstrates creating an LWPolyline where each segment has different start and end widths. The width values are specified in the point tuples. Ensure `dxf.const_width` is unset. ```python doc = ezdxf.new("R2000") 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") ``` -------------------------------- ### Set and Get RGB Color for Layer Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tables/layer_table_entry.md Use the `rgb` property to set or get the true color of a layer as an (R, G, B) tuple. This is the recommended method over direct DXF attribute access. ```python layer.rgb = (30, 40, 50) r, g, b = layer.rgb ``` -------------------------------- ### Create New DXF Documents Source: https://github.com/mozman/ezdxf/blob/master/docs/source/usage_for_beginners.md Initialize new DXF documents with optional versioning and standard resource setup. ```python doc = ezdxf.new() ``` ```python doc = ezdxf.new("R12") ``` ```python doc = ezdxf.new(setup=True) ``` -------------------------------- ### ezdxf.addons.openscad.is_installed Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/openscad.md Checks if the OpenSCAD application is installed and accessible. ```APIDOC ## ezdxf.addons.openscad.is_installed ### Description Returns True if OpenSCAD is installed and can be located via system paths or configuration. ### Response - **bool** - True if OpenSCAD is found, False otherwise. ``` -------------------------------- ### add_line() Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/r12writer.md Add a LINE entity from start to end. ```APIDOC ## add_line() ### Description Add a LINE entity from start to end. ### Parameters - **start** (Sequence[float]) - Required - start vertex as (x, y[, z]) tuple - **end** (Sequence[float]) - Required - end vertex as (x, y[, z]) tuple - **layer** (str) - Optional - layer name as string - **color** (int) - Optional - color as AutoCAD Color Index (ACI) - **linetype** (str) - Optional - line type as string ``` -------------------------------- ### Initialize Document with Standard Styles Source: https://github.com/mozman/ezdxf/blob/master/docs/source/tutorials/text.md Initializes a new DXF document with standard linetypes and text styles enabled. ```default doc = ezdxf.new('R12', setup=True) ``` -------------------------------- ### ezdxf.edgeminer.find_simple_chain Source: https://github.com/mozman/ezdxf/blob/master/docs/source/edgeminer.md Returns a simple chain containing the start edge. A simple chain starts and ends at a leaf or a junction, with all connected edges having vertices of degree 2, except for the first and last vertices which have a degree of 1 (leaf) or greater than 2 (junction). ```APIDOC ## ezdxf.edgeminer.find_simple_chain ### Description Returns a simple chain containing start edge. A simple chain start and ends at a leaf or a junction. All connected edges have vertices of degree 2, except the first and last vertex. The first and the last vertex have a degree of 1 (leaf) or greater 2 (junction). ### Method GET ### Endpoint /ezdxf/edgeminer/find_simple_chain ### Parameters #### Query Parameters - **deposit** (Deposit) - Required - The edge deposit. - **start** (Edge) - Required - The starting edge of the chain. ``` -------------------------------- ### ezdxf.addons.odafc.is_installed Source: https://github.com/mozman/ezdxf/blob/master/docs/source/addons/odafc.md Checks if the ODA File Converter is installed and accessible. ```APIDOC ## is_installed() -> bool ### Description Returns True if the ODAFileConverter is installed and configured correctly. ### Response #### Success Response (200) - **result** (boolean) - Returns True if installed, False otherwise. ``` -------------------------------- ### GUID Generation Source: https://github.com/mozman/ezdxf/blob/master/docs/source/low_level_tools/functions.md Function to generate universally unique identifiers. ```APIDOC ## ezdxf.tools.guid ### Description Returns a general unique ID, based on `uuid.uuid4()`. This function creates a GUID for the header variables $VERSIONGUID and $FINGERPRINTGUID, which matches the AutoCAD pattern `{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}`. ### Method `guid` ### Response #### Success Response (str) - **GUID** (str) - A unique identifier string. ```