### Setup and Lorem Ipsum Text for MTEXT Tutorial Source: https://ezdxf.mozman.at/docs/tutorials/mtext.html Initializes a new R2007 DXF document with setup, gets the modelspace, and defines a lorem ipsum text block used in subsequent examples. ```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. """ ``` -------------------------------- ### DXF document setup for quick_leader Source: https://ezdxf.mozman.at/docs/tutorials/mleader.html Initializes a new DXF document with setup=True, duplicates the 'Standard' MLEADERSTYLE as 'EZDXF', sets the MTEXT style to 'OpenSans', and gets the modelspace. ```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() ``` -------------------------------- ### Expected output of ezdxf -V on Raspberry Pi OS Source: https://ezdxf.mozman.at/docs/setup.html Example output showing the installed ezdxf version, Python version, and enabled features. ```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 ``` -------------------------------- ### Build and install ezdxf from source Source: https://ezdxf.mozman.at/docs/setup.html Build and install ezdxf from the cloned source code. ```bash cd ezdxf pip3 install . ``` -------------------------------- ### Install Sphinx for documentation Source: https://ezdxf.mozman.at/docs/setup.html Install Sphinx and the sphinx-rtd-theme. Assumes you are in the build directory build/ezdxf. ```bash pip3 install Sphinx sphinx-rtd-theme ``` -------------------------------- ### Install, build, and verify ezdxf on Manjaro Source: https://ezdxf.mozman.at/docs/setup.html Install Cython and wheel, clone the repository, build and install ezdxf, and check the version. ```bash pip3 install cython wheel git clone https://github.com/mozman/ezdxf.git cd ezdxf pip3 install . python3 -m ezdxf -V ``` -------------------------------- ### Common prolog for Python examples Source: https://ezdxf.mozman.at/docs/tutorials/custom_data.html Common prolog for all Python code examples in this tutorial. Creates a new DXF document and gets the modelspace. ```python import ezdxf doc = ezdxf.new() msp = doc.modelspace() ``` -------------------------------- ### Install PyQt5 bindings on Ubuntu Server 21.10 Source: https://ezdxf.mozman.at/docs/setup.html Install PyQt5 bindings via apt on Ubuntu Server 21.10. ```bash sudo apt install python3-pyqt5 ``` -------------------------------- ### Build and Install ezdxf from Source on Windows Source: https://ezdxf.mozman.at/docs/setup.html Build and install ezdxf from source on Windows. Requires a C++ compiler and the Visual Studio Build Tools. The output shows the installed version and whether C-extensions are enabled. ```batch mkdir build cd build py -m venv .venv .venv/Scripts/activate.bat ``` ```bash pip3 install setuptools wheel cython ``` ```bash git clone https://github.com/mozman/ezdxf.git ``` ```bash cd ezdxf pip3 install . ``` ```bash python3 -m ezdxf -V ``` ```text 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 ``` -------------------------------- ### Install ezdxf from GitHub Source: https://ezdxf.mozman.at/docs/setup.html Install the latest development version of ezdxf directly from GitHub using pip3. ```bash pip3 install git+https://github.com/mozman/ezdxf.git@master ``` -------------------------------- ### Set and get custom meta data with doc.ezdxf_metadata() Source: https://ezdxf.mozman.at/docs/tutorials/custom_data.html Use the MetaData instance to store custom strings up to 254 characters. The example adds a custom key and prints the built-in CREATED_BY_EZDXF entry and the custom entry. ```python metadata = doc.ezdxf_metadata() metadata["MY_UNIQUE_KEY"] = "my additional meta data" print(metadata.get("CREATED_BY_EZDXF")) print(metadata.get("MY_UNIQUE_KEY")) ``` -------------------------------- ### Install sphinx-rtd-theme Source: https://ezdxf.mozman.at/docs/develop/doc_formatting_guide.html Install the Read the Docs Sphinx theme, which is used for the documentation theme. ```bash pip install sphinx-rtd-theme ``` -------------------------------- ### Install ezdxf with pip3 Source: https://ezdxf.mozman.at/docs/setup.html Basic installation command for ezdxf. The packages pyparsing, numpy, fontTools, and typing_extensions are hard dependencies and will be installed automatically. ```bash pip3 install ezdxf ``` -------------------------------- ### Build and Install ezdxf from Source on WSL & Ubuntu Source: https://ezdxf.mozman.at/docs/setup.html Build and install ezdxf from source on WSL & Ubuntu. Requires build-essential and python3.10-dev packages. The output shows the installed version and whether C-extensions are enabled. ```bash sudo apt install build-essential python3.10-dev ``` ```bash cd ~ mkdir build cd build python3 -m venv .venv source .venv/bin/activate ``` ```bash pip3 install cython wheel ``` ```bash git clone https://github.com/mozman/ezdxf.git ``` ```bash cd ezdxf pip3 install . ``` ```bash python3 -m ezdxf -V ``` ```text 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 ``` -------------------------------- ### Check ezdxf installation version Source: https://ezdxf.mozman.at/docs/setup.html Run the ezdxf command to verify the installation and display version information. ```bash python3 -m ezdxf -V ``` -------------------------------- ### Run tests with pytest Source: https://ezdxf.mozman.at/docs/setup.html Install pytest and run the test suite. Assumes you are in the build directory build/ezdxf and ezdxf is installed in the venv. ```bash pip3 install pytest python3 -m pytest tests integration_tests ``` -------------------------------- ### Install Cython and wheel in venv on Raspberry Pi OS Source: https://ezdxf.mozman.at/docs/setup.html Install Cython and wheel in the virtual environment to compile C-extensions. ```bash pip3 install cython wheel ``` -------------------------------- ### Embedded object example from AutoCAD 2018 Source: https://ezdxf.mozman.at/docs/dxfinternals/dxftags.html Real-world example of an embedded object in an MTEXT entity. The encapsulating object starts with 100 AcDbMText, and the embedded object starts with 101 Embedded Object. The embedded object is appended after the encapsulating object's data. ```dxf 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 {\fArial|b0|i0|c162|p34;CHANGE;\P\P\PTEXT} 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 ``` -------------------------------- ### Create a DXF document with setup=True Source: https://ezdxf.mozman.at/docs/concepts/linetypes.html Creates a DXF R2007 document with standard linetypes set up. The setup parameter is required to have the simple linetypes available. ```python doc = ezdxf.new('R2007', setup=True) ``` -------------------------------- ### Run drawing add-on example scripts Source: https://ezdxf.mozman.at/docs/addons/drawing.html Run the example scripts from the `examples/addons/drawing` folder. The first command lists supported output formats for the matplotlib backend, the second renders a DXF file to a PNG, the third renders a specific layout, and the fourth opens an interactive GUI viewer. ```shell $ ./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 ``` -------------------------------- ### Mirror an ARC and apply upright() to fix extrusion vector Source: https://ezdxf.mozman.at/docs/upright.html Demonstrates the effect of the upright() function on a mirrored ARC entity. The example creates an ARC, mirrors it to get an inverted extrusion vector, then applies upright() and shows that start and end points are swapped. The code is split into two blocks: the first creates the mirrored ARC, the second applies upright() and verifies the result. ```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}) ``` ```python # This creates an inverted extrusion vector: assert mirrored_arc.dxf.extrusion.isclose((0, 0, -1)) start_point_inv = mirrored_arc.start_point end_point_inv = mirrored_arc.end_point upright(mirrored_arc) # OCS is aligned with WCS: assert mirrored_arc.dxf.extrusion.isclose((0, 0, 1)) # start- and end points are swapped after applying upright() assert mirrored_arc.start_point.isclose(end_point_inv) assert mirrored_arc.end_point.isclose(start_point_inv) # draw lines to the start- and end point of the mirrored ARC msp.add_line((0, 0), mirrored_arc.start_point, dxfattribs={"color": ezdxf.const.GREEN}) msp.add_line((0, 0), mirrored_arc.end_point, dxfattribs={"color": ezdxf.const.BLUE}) ``` -------------------------------- ### Create a DXF document with standard text styles using setup=True Source: https://ezdxf.mozman.at/docs/tutorials/text.html Creates a new R12 DXF document with standard text styles and linetypes. The setup=True argument replaces proprietary font declarations (ARIAL, ARIAL_NARROW, ISOCPEUR, TIMES) with open source fonts, using the font name as the style name (e.g., 'OpenSans-Italic'). ```python doc = ezdxf.new('R12', setup=True) ``` -------------------------------- ### Select chained entities using bbox_chained Source: https://ezdxf.mozman.at/docs/tutorials/entity_selection.html Selects elements directly or indirectly connected by overlapping bounding boxes, starting from a given entity. The example starts from the first LINE entity and prints the chain. ```python # choose entity for the beginning of the chain: line = msp.query("LINE").first for entity in select.bbox_chained(line, msp): print(str(entity)) ``` ```text LINE(#A1) CIRCLE(#9D) LWPOLYLINE(#9E) SPLINE(#A0) ``` -------------------------------- ### Set and Get True Color as RGB-Tuple Source: https://ezdxf.mozman.at/docs/howto/content.html Use the `rgb` property of a `DXFGraphic` entity to set or get the true color as an (r, g, b) tuple. The example sets red and then retrieves the values. ```python # set true color value to red entity.rgb = (0xFF, 0, 0) # get true color values r, g, b = entity.rgb ``` -------------------------------- ### get_subclass(_name: str, _pos: int = 0) -> Tags Source: https://ezdxf.mozman.at/docs/develop/dxftag_collections.html Gets a subclass by name, starting search at the given position. ```APIDOC ## get_subclass(_name: str, _pos: int = 0) -> Tags ### Description Gets a subclass by name, starting search at the given position. ### Method get_subclass ### Parameters - **name** (str) - Required - Subclass name as string like "AcDbEntity". - **pos** (int) - Optional - Start searching at subclass pos. Default is 0. ### Returns - **Tags** - The subclass tags. ``` -------------------------------- ### Get Block Reference Attribute by Tag Source: https://ezdxf.mozman.at/docs/howto/content.html Use `get_attrib()` to retrieve a specific attribute by tag. The example checks for None before modifying the text. ```python diameter = entity.get_attrib('diameter') if diameter is not None: diameter.dxf.text = "17mm" ``` -------------------------------- ### Create ExampleCls instance with flag=True Source: https://ezdxf.mozman.at/docs/develop/doc_formatting_guide.html Create an instance of ExampleCls with the flag attribute set to True. The constructor accepts optional keyword arguments that correspond to instance attributes. ```python e = ExampleCls(flag=True) ``` -------------------------------- ### Estimate spline tangents with estimate_tangents() and lerp() Source: https://ezdxf.mozman.at/docs/tutorials/spline.html Uses ezdxf.math.estimate_tangents() to estimate start and end tangents from fit points, then linearly interpolates between the first and last tangent to get a single tangent direction. Passes the interpolated tangent as both start and end tangents to add_cad_spline_control_frame(). ```python tangents = estimate_tangents(fit_points) # linear interpolation of the first and the last tangent: t0 = tangents[0].lerp(tangents[-1], 0.5) msp.add_cad_spline_control_frame(fit_points, tangents=[t0, t0]) ``` -------------------------------- ### ezdxf config -h help output Source: https://ezdxf.mozman.at/docs/launcher.html Shows the usage and options for the ezdxf config command. Use -p to print configuration, -w to write configuration, --home to create a config file in the user home directory, and --reset to factory reset. ```text C:\> ezdxf config -h usage: ezdxf config [-h] [-p] [-w FILE] [--home] [--reset] optional arguments: -h, --help show this help message and exit -p, --print print configuration -w FILE, --write FILE write configuration --home create config file 'ezdxf.ini' in the user home directory '~/.config/ezdxf', $XDG_CONFIG_HOME is supported if set --reset factory reset, delete default config files 'ezdxf.ini' ``` -------------------------------- ### Bin packing example with ezdxf binpacking add-on Source: https://ezdxf.mozman.at/docs/addons/binpacking.html Replicates the py3dbp package example. Defines bin dimensions and weights, builds a packer with nine powder items, packs each bin using the BIGGER_FIRST strategy, and exports the result to a DXF file named py3dbp_example.dxf. Requires the ezdxf binpacking add-on and creates layers FRAME, ITEMS, and TEXT. ```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") ``` -------------------------------- ### Check available layers using LayerTable protocols Source: https://ezdxf.mozman.at/docs/tutorials/layers.html Demonstrates standard Python protocols supported by the `LayerTable` object: iterating over layers, checking for an existing layer definition with `in`, retrieving a layer with `get`, and getting the total count with `len`. The iteration example switches off all layers except layer "0". ```python # iteration for layer in doc.layers: if layer.dxf.name != "0": layer.off() # switch all layers off except layer "0" # check for existing layer definition if "MyLines" in doc.layers: layer = doc.layers.get("MyLines") layer_count = len(doc.layers) # total count of layer definitions ``` -------------------------------- ### Configure support_dirs in config file Source: https://ezdxf.mozman.at/docs/options.html Config file example for the core section's support_dirs key. Use quotes for paths including spaces. ```ini [core] support_dirs = ~/dir1, ~/dir2, "~/dir 3", ``` -------------------------------- ### Prelude: Create DXF document and entity layer Source: https://ezdxf.mozman.at/docs/tutorials/dxf_primitives.html Sets up a new DXF document, creates a layer named "ENTITY" with color 1, gets the modelspace, and defines common graphical attributes for subsequent entity creation. ```python import ezdxf from ezdxf.gfxattribs import GfxAttribs doc = ezdxf.new() doc.layers.new("ENTITY", color=1) msp = doc.modelspace() attribs = GfxAttribs(layer="ENTITY") ``` -------------------------------- ### Set paragraph properties with ParagraphProperties Source: https://ezdxf.mozman.at/docs/tutorials/mtext.html Sets paragraph properties for an MText editor, including first-line indentation and alignment. The indentation is relative to the left indentation and is multiplied by the character height to get drawing units. This example uses a justified alignment and adds the resulting MText to the model space. ```python # import support classes: from ezdxf.tools.text import ParagraphProperties, MTextParagraphAlignment attribs = dict(ATTRIBS) attribs["char_height"] = 0.25 attribs["width"] = 7.5 editor = MTextEditor("Indent the first line:" + NP) props = ParagraphProperties( indent=1, # indent first line = 1x0.25 drawing units align=MTextParagraphAlignment.JUSTIFIED ) editor.paragraph(props) editor.append(lorem_ipsum) msp.add_mtext(str(editor), attribs) ``` ```python # import support classes: from ezdxf.tools.text import ParagraphProperties, MTextParagraphAlignment attribs = dict(ATTRIBS) attribs["char_height"] = 0.25 attribs["width"] = 7.5 editor = MTextEditor("Indent the first line:" + NP) props = ParagraphProperties( indent=1, # indent first line = 1x0.25 drawing units align=MTextParagraphAlignment.JUSTIFIED ) editor.paragraph(props) editor.append(lorem_ipsum) msp.add_mtext(str(editor), attribs) ``` -------------------------------- ### Reset main CAD viewport to extents of model space entities Source: https://ezdxf.mozman.at/docs/tools/zoom.html Example usage to reset the main CAD viewport of the model space to the extents of its entities using `zoom.extents()`. It creates a new DXF document, gets the model space, and after adding DXF entities, calls the zoom function and saves the drawing. ```python import ezdxf from ezdxf import zoom doc = ezdxf.new() msp = doc.modelspace() ... # add your DXF entities zoom.extents(msp) doc.saveas("your.dxf") ``` -------------------------------- ### Create build directory for Python source Source: https://ezdxf.mozman.at/docs/setup.html Create a build directory in the home directory and change into it. ```bash cd ~ mkdir build cd build ``` -------------------------------- ### Find loop by pick-point using edgesmith and edgeminer Source: https://ezdxf.mozman.at/docs/tutorials/edges.html This snippet finds the smallest HATCH boundary loop containing a pick-point. It uses intersecting_edges_2d() to find a starting edge, find_loop_by_edge() to get candidates in both directions, sorts by area, and selects the smallest loop containing the point. The code reads 'junctions.dxf', adds a hatch, and saves the result to 'find_loop_by_pick_point.dxf'. ```python doc = ezdxf.readfile("junctions.dxf") msp = doc.modelspace() lines = msp.query("LINE") edges = list(edgesmith.edges_from_entities_2d(lines)) pick_point = (110, 50) # 1. find a starting edge near the pick-point intersecting_edges = edgesmith.intersecting_edges_2d(edges, pick_point) if not len(intersecting_edges): print("no intersection found") return hatch = msp.add_hatch(color=2) # The intersecting edges are sorted by ascending distance to the pick-point # take the closest edge as starting edge: start = intersecting_edges[0].edge # 2. find the best loop candidates deposit = edgeminer.Deposit(edges) candidates = [ edgeminer.find_loop_by_edge(deposit, start, clockwise=True), edgeminer.find_loop_by_edge(deposit, start, clockwise=False), ] # 3. sort candidates by area candidates.sort(key=edgesmith.loop_area) for loop in candidates: # 4. take the smallest loop which contains the pick-point if edgesmith.is_inside_polygon_2d(loop, pick_point): hatch.paths.append(edgesmith.polyline_path_from_chain(loop)) break else: # for loop ended without break print("no loop found") return doc.saveas("find_loop_by_pick_point.dxf") ``` -------------------------------- ### Create document with standard linetypes Source: https://ezdxf.mozman.at/docs/tutorials/common_graphical_attributes.html Creates a new DXF document with setup=True to include standard linetypes. Without setup, only necessary resources are created. ```python doc = ezdxf.new("R2010", setup=True) ``` -------------------------------- ### Set up a new DXF document Source: https://ezdxf.mozman.at/docs/addons/tablepainter.html Initializes a new DXF document in R2000 format with lineweight display enabled, and adds two text styles for the header and cell content. ```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") ``` -------------------------------- ### ODAFC configuration file example Source: https://ezdxf.mozman.at/docs/addons/odafc.html Shows the default configuration entries for the ODAFC add-on, including the Windows executable path and an empty Unix path. ```ini [odafc-addon] win_exec_path = "C:\Program Files\ODA\ODAFileConverter\ODAFileConverter.exe" unix_exec_path = ``` -------------------------------- ### Get a DXF attribute with a default using get() Source: https://ezdxf.mozman.at/docs/usage_for_beginners.html Use the get() method to retrieve a DXF attribute and provide a fallback default value when the attribute is not present. ```python entity.dxf.get("true_color", 0) ``` -------------------------------- ### Get a default value for a missing DXF attribute with get() Source: https://ezdxf.mozman.at/docs/tutorials/getting_data.html Uses the get() method to return a default value (0) for the 'paperspace' attribute if it does not exist, avoiding a DXFValueError. ```python # If DXF attribute 'paperspace' does not exist, the entity defaults # to modelspace: p = e.dxf.get("paperspace", 0) ``` -------------------------------- ### Install Matplotlib for improved text boundary calculation Source: https://ezdxf.mozman.at/docs/disassemble.html Install the optional Matplotlib package to improve text boundary calculations for TEXT, ATTRIB, and ATTDEF entities. This is a command-line installation step. ```bash C:\> pip3 install matplotlib ``` -------------------------------- ### Build HTML documentation with make html Source: https://ezdxf.mozman.at/docs/setup.html Build the HTML documentation. The output is located in build/ezdxf/docs/build/html. ```bash cd docs make html ``` -------------------------------- ### Create a DXF document with setup=True and use DASHED linetype Source: https://ezdxf.mozman.at/docs/tutorials/simple_drawings.html Creates a new DXF R2010 document with standard resources (linetypes and text styles) by setting setup=True. Adds a LINE entity with the DASHED linetype. Note that text styles may require font configuration in the viewer application. ```python import ezdxf doc = ezdxf.new("R2010", setup=True) msp = doc.modelspace() msp.add_line((0, 0), (10, 0), dxfattribs={"linetype": "DASHED"}) ``` -------------------------------- ### Create venv with system site-packages on Raspberry Pi OS Source: https://ezdxf.mozman.at/docs/setup.html Create and activate a virtual environment with access to system site-packages for using Matplotlib and Qt bindings. ```bash cd ~ mkdir build cd build python3 -m venv --system-site-packages .venv source .venv/bin/activate ``` -------------------------------- ### Get color attribute Source: https://ezdxf.mozman.at/docs/tutorials/common_graphical_attributes.html Gets the current color attribute value from a DXF entity. ```python value = entity.dxf.color ``` -------------------------------- ### ezdxf.options.print() Source: https://ezdxf.mozman.at/docs/options.html Prints the configuration to stdout. ```APIDOC ## ezdxf.options.print() ### Description Prints the current configuration to standard output. ### Method Function ### Signature `ezdxf.options.print()` ### Parameters None ### Returns None ```