Release v0.14.1

By mozman, Sa 19 September 2020, in category Release

drawing, path, recover, release, reorder, trace, unicode, validation

Recover Module

The indention of the recover module is to provide a more stable and reliable DXF loading function. This is required because the DXF reference is often not precise about valid data ranges or does not show the correct usage of DXF attributes and structures and therefore exist many DXF files with structural flaws.

The recover.read() and recover.readfile() functions will repair as much flaws as possible and run the required audit process automatically afterwards and return the result of this audit process:

import sys
import ezdxf
from ezdxf import recover

try:
    doc, auditor = recover.readfile("messy.dxf")
except IOError:
    print(f'Not a DXF file or a generic I/O error.')
    sys.exit(1)
except ezdxf.DXFStructureError:
    print(f'Invalid or corrupted DXF file.')
    sys.exit(2)

if auditor.has_errors:
    auditor.print_error_report()

A recovered DXF file can still have unrecoverable errors, but this is just a problem when saving the recovered DXF file.

This extra work requires additional efforts and longer loading times, to avoid this penalty for DXF files from trusted sources like AutoCAD or BricsCAD, the current loading function ezdxf.readfile() remains as it was, except the legacy_mode argument was removed to force usage of the recover module.

Drawing Add-on

Support for the start- and end width attributes of LWPOLYLINE and 2D POLYLINE vertices to draw banded 2D lines.

Controller-M128-top

A simple qsave() function to export renderings of DXF layouts as raster- or vector graphic by matplotlib:

import ezdxf
from ezdxf.addons.drawing import matplotlib

doc = ezdxf.readfile('your.dxf')
matplotlib.qsave(doc.modelspace(), 'your.png')

Further Improvements:

DXF Entities

Render Tools

TraceBuilder() class to create banded 2D lines and curves by quadrilaterals, see docs.

Path() class to create complex paths only by lines and cubic Bèzier curves. Supports splines, circular- and elliptic arcs as path elements all approximated by cubic Bèzier curves, see docs.

Reorder Module

Tools to reorder DXF entities by handle or a special sort handle mapping, see docs.

Math Tools

Unicode Handling

New errors argument for all DXF loading functions like ezdxf.readfile() to support different methods for unicode error handling:

The ezdxf.has_dxf_unicode(s) and ezdxf.decode_dxf_unicode(s) are new support functions to decode unicode characters "\U+xxxx" manually, see docs.

The decoding of unicode characters "\U+xxxx" is not done automatically by the regular loading functions like ezdxf.readfile() to avoid a speed penalty, only the recover module does the decoding automatically, because this loading mode is already slow.

This kind of encoding is most likely used only in older DXF versions, because since DXF R2007 the whole DXF file is encoded in utf8 and a special unicode encoding is not necessary.

New Drawing.encode(s) function to encode unicode strings with correct encoding and error handler.

Change Log

Version 0.14.1 - 2020-09-19

Version 0.14.0 - 2020-09-12