Release v0.18.1

By mozman, Sa 03 September 2022, in category Release

acis, angular, arc, chamfer, dimension, fillet, helix, meshbuilder, mleader, obj, off, openscad, ordinate, release, stl, sweep, torus

Dimension Types

Angular Dimension

New support for creating angular dimensions.

dim-angular

There are several factory methods to add angular dimensions:

  1. layout.add_angular_dim_cra() - definition by center, radius and angles
  2. layout.add_angular_dim_2l() - definition by two lines
  3. layout.add_angular_dim_3p() - definition by three points
  4. layout.add_angular_dim_arc() - definition by a ConstructionArc object

For more information: Tutorial for Angular Dimension

Arc Dimension

New support for creating arc dimensions.

dim-arc

There are several factory methods to add arc dimensions:

  1. layout.add_arc_dim_cra() - definition by center, radius and angles
  2. layout.add_arc_dim_3p() - definition by three points
  3. layout.add_arc_dim_arc() - definition by a ConstructionArc object

For more information: Tutorial for Arc Dimension

Ordinate Dimension

New support for creating ordinate dimensions by these factory methods:

  1. layout.add_ordinate_x_dim() - add x-type ordinate dimension
  2. layout.add_ordinate_y_dim() - add y-type ordinate dimension

Global feature location: the ordinate origin is the global WCS origin

dim-ordinate-global

Local feature location: the ordinate origin is the origin of a user defined UCS

dim-ordinate-local

For more information: Tutorial for Ordinate Dimension

Extended Entity Query

Extended usability of the EntityQuery class.

This is a simple entity query which selects all LINE entities from the modelspace as starting point for the following explanations:

lines = msp.query("LINE")
  1. Extended __getitem__() method to accept also a DXF attribute name that returns all entities which support this attribute, this is the base for supporting queries by relational operators.
  2. New __setitem__() method to assigns a DXF attribute to all supported entities in the EntityQuery container. E.g. change the layer of all selected lines: lines["layer"] = "MyLayer"
  3. New __delitem__() method to discard a DXF attribute from all entities in
    the EntityQuery container. E.g. delete the layer attribute from all selected lines: del lines["layer"], which reset the layer to the default value 0
  4. New descriptors for some basic DXF attributes which simplifies the attribute selection and has auto-completion support from IDEs. E.g. change the layer of all selected lines: lines.layer = "MyLayer"
  5. New selection by relational operators (<, <=, ==, !=, >=, >) which work in conjunction with the extended attribute selection of __getitem__() to allow further conditional selections. E.g. select all lines on layer "MyLayer": lines_on_my_layer = lines.layer == "MyLayer"
  6. New selection by regular expression: lines.layer.match("^My.*")
  7. Use your own filter functions to build selections: lines.filter(lambda e: ...)
  8. Set operators to combine queries by union (|), intersection (&), difference (-) and symmetric_difference (^).

Example for selecting all blue lines and red circles from modelspace:

result = (msp.query("LINE").color == 5) | (msp.query("CIRCLE").color == 1)  

For more information: Extended EntityQuery Features

DXF Entity Improvements

DXF Attribute Helper Class

The ezdxf.gfxattribs module provides the GfxAttribs class to create valid attribute dictionaries for the most often used DXF attributes supported by all graphical DXF entities. The advantage of using this class is auto-completion support by IDEs and an instant validation of the attribute values.

import ezdxf
from ezdxf.gfxattribs import GfxAttribs

doc = ezdxf.new()
msp = doc.modelspace()

attribs = GfxAttribs(layer="MyLayer", color=ezdxf.colors.RED)
line = msp.add_line((0, 0), (1, 0), dxfattribs=attribs)
circle = msp.add_circle((0, 0), radius=1.0, dxfattribs=attribs)

For more information: Documentation of the gfxattribs module

TEXT, ATTRIB and ATTDEF

TextEntityAlignment enum replaces the string based alignment definition.

New Text methods:

Extended Factory Methods

MTEXT

New virtual DXF attribute MText.dxf.text which is linked to the MText.text attribute, this adds API compatibility to other text based entities: TEXT, ATTRIB and ATTDEF

MULTILEADER

New support for creating MULTILEADER entities.

New Factory Methods

Both factory methods return builder objects:

Due of the lack of good documentation it’s not possible to support all combinations of MULTILEADER properties with decent quality!

For more information: Tutorial for creating MultiLeaders

HELIX

New support for creating HELIX entities by the factory method add_helix().

VIEWPORT/LAYER

New support for layer attribute override in VIEWPORT entities. This feature is implemented in the LAYER entity. The new method Layer.get_vp_overrides returns a LayoutOverride object which allows overriding properties for this specific layer for individual viewports.

For more information: Example for overriding layer attributes in viewports

CAD Application Settings

The ezdxf.appsettings is a high-level module for working with CAD application settings and behaviors. None of these settings have any influence on the behavior of ezdxf, since ezdxf only takes care of the content of the DXF file and not of the way it is presented to the user.

Example for updating the extents of the modelspace:

import ezdxf
from ezdxf import zoom, appsettings

doc = ezdxf.readfile("your.dxf")
extents = appsettings.update_extents(doc)

The function updates only the values in the HEADER section, to zoom the active viewport to these extents, use the zoom module:

zoom.center(doc.modelspace(), extents.center, extents.size)

For more information: Documentation of the appsettings module

Improved Bounding Box Module

Refactoring of the ezdxf.bbox.extents function to make use of the improved bounding box calculation for Bézier curves, this eliminates the need to estimate a suitable flattening distance. The argument flatten is replaced by fast. If argument fast is True the calculation of Bézier curves is based on their control points, this may return a slightly larger bounding box. The fast mode also uses a simpler and mostly inaccurate text size calculation instead of the more precise but very slow calculation by matplotlib.

Add-ons

New Mesh Exchange Add-on

The ezdxf.addons.meshex module provides functions to exchange meshes with other tools by the following file formats:

The source or target object is always a MeshBuilder instance and therefore the supported features are also limited by this class. Only vertices and faces are exchanged, colors, textures and explicit face- and vertex normals are lost.

For more information: Documentation of the meshex add-on

New OpenScad Add-on

Interface to the OpenSCAD application to apply boolean operations to MeshBuilder objects. The OpenSCAD application is not bundled with ezdxf, you need to install the application yourself.

This example subtracts a sphere from a Menger sponge by OpenSCAD and exports the result as MESH entity in a DXF file:

import ezdxf
from ezdxf.render import forms
from ezdxf.addons import MengerSponge, openscad

doc = ezdxf.new()
msp = doc.modelspace()

sponge = MengerSponge(level=3).mesh()
sponge.flip_normals()  # important for OpenSCAD
sphere = forms.sphere(
    count=32, stacks=16, radius=0.5, quads=True
).translate(0.25, 0.25, 1)
sphere.flip_normals()  # important for OpenSCAD

script = openscad.boolean_operation(openscad.DIFFERENCE, sponge, sphere)
result = openscad.run(script)
result.render_mesh(msp)

doc.set_modelspace_vport(6, center=(5, 0))
doc.saveas("OpenSCAD.dxf")

openscad-menger-sponge-minus-sphere

For more information: Documentation of the OpenSCAD add-on

New Binpacking Add-on

This add-on is based on the 3D bin packing module py3dbp to solve the bin packing problem.

For more information: Documentation of the binpacking add-on

Extended ODAFC Add-on

New functions added:

For more information: Documentation of the odafc add-on

Text Tools

Path Improvements

Fillet and Chamfer Tools

Helix Tool

New ezdxf.path.helix() function: Returns a helix as a Path object.

Bounding Box Calculation

Improved ezdxf.path.bbox() function: New algorithm to determine the exact bounding boxes of Bézier curves, eliminating the need to estimate a suitable flattening distance. Added argument fast which allows bounding box calculation based on Bézier curve control points, this may result in slightly larger bounding boxes in favor of increased execution speed. Removed the arguments flatten and segments without deprecation warnings (raises TypeError).

Render Tools

New Functions

New MeshBuilder Methods

New MeshDiagnose Tool

New helper class ezdxf.render.MeshDiagnose to analyze and detect errors of MeshBuilder objects.

New FaceOrientationDetector Tool

New Helper class ezdxf.render.FaceOrientationDetector for face orientation and face normal vector detection.

Math Tools

New ConstructionPolyline Tool

New class ezdxf.math.ConstructionPolyline to measure, interpolate and divide anything that can be approximated or flattened into vertices.

New ApproxParamT Tool

New class ezdxf.math.ApproxParamT, an approximation tool for parametrized curves.

New Plane Methods

New 2D/3D Construction Function

Changes of BoundingBox Classes

New RTree Tool

New class ezdxf.math.rtree.RTree: Immutable spatial search tree loosely based on R-Trees.

New Clustering Functions

ACIS Tools

The new ezdxf.acis sub-package provides some ACIS data management tools for curious and experienced users. These tools cannot replace the official ACIS SDK due to the complexity of the data structures and the absence of an ACIS kernel in ezdxf.

Launcher

The new info command show info and optional stats of DXF files.

C:\> ezdxf info gear.dxf
Filename: ".\gear.dxf"
Format: ASCII
Release: R2013
DXF Version: AC1027
Codepage: ANSI_1252
Encoding: utf-8
Created by ezdxf: 0.18b6 @ 2022-07-06T14:21:18.530488+00:00
Written by ezdxf: 0.18b6 @ 2022-07-06T14:21:18.530488+00:00

The new browse-acis command can show and export the SAT or SAB content of ACIS entities.

C:\> ezdxf browse-acis 3dsolid.dxf

browse-acis

For more information read the launcher documentation.

Change Log

Version 0.18.1 - 2022-09-03

Version 0.18 - 2022-07-29

Release notes for v0.17