Skip to content

0.6.0: code pages, rebuilt dimensions, header variables, attributes, geometric tolerances

Choose a tag to compare

@gsdali gsdali released this 21 Nov 08:47
ce3606b

Reading a drawing as its own file says to: its code page, header variables, number format and attributes, the dimension values that were missing, and four entity types that were skipped (#30, #31, #33, #34, #36, #37, #39).

New

  • Code page (#36). A file is read through its $DWGCODEPAGE: ANSI_1252 (McMaster-Carr's drawings) reads é, ° and Ø as written, not as Shift-JIS. A file of R2007 or later is read as UTF-8. %%nnn and \M+nXXXX are decoded and \U+ surrogate pairs are one character. DXF.CodePage, Drawing.codePage and Dimension.codePage are new.
  • Rebuilding dimensions (#37). Drawing.rebuildingDimensions(_:) rebuilds DIMENSIONs from the loose pieces a converter leaves (value texts, dimension lines, extension lines and marks), infers the scale of each layer group, and says what it could not explain. Dimension.rebuilt marks them. dxfdump --rebuild [--scale N] [--numbers ...]. On the Jw_cad 2120 it rebuilds all 29 dimensions at 1:80.
  • How a drawing writes numbers (#39). DimensionText(_:numbers:codePage:), Dimension.text(numbers:) and DimensionRebuild.Options(numbers:) take a NumberConvention: .commaSeparatesThousands (Jw_cad's 10,439 is 10439), .commaIsDecimalMark (0,125 is 0.125) or .plain, the default, which leaves a comma out of a number as before. Full-width digits and the full-width comma read as numbers.
  • Angular and ordinate values (#33). computedMeasurement has a value for angular, three-point angular and ordinate dimensions: degrees for the angles (on the side of the arc location), a distance along x or y for an ordinate (Dimension.isXOrdinate). An angle typed into the text (45°, 45%%d) is a new DimensionText.Part.angle, in typedAngles.
  • Header variables (#31). Drawing.headerVariables holds every variable of the HEADER section by name, with its group-coded values. measurement, currentDimensionStyleName, dimensionScale, linearUnitFormat, linearUnitPrecision and a computed currentDimensionStyle are built on it. dxfdump --header.
  • Attributes (#30). BlockReference.attributes holds the ATTRIB records of an INSERT (tag, value, position, height, rotation, layer, flags, identity) and Block.attributeDefinitions the ATTDEFs. ReadOptions(expandAttributes:) flattens visible attributes into TEXT entities whose identity via names the reference. R2018 multiline attributes read their text. dxfdump --attributes.
  • Geometric tolerances, solids, wipeouts and faces (#34). .tolerance reads a feature control frame into rows of characteristic, tolerance value with its modifiers, and datums ({\Fgdt;i}%%v0.012%%v%%vB%%v%%v is symmetry, 0.012, datum B); a symbol or box it cannot place is kept and flagged, never guessed. .solid, .wipeout and .face3D are read as well. None of the four appears in skipped any more.
  • Oracles and tools: tools/oracle.py --header, tools/attrib_oracle.py, tools/oracle_diff.py, and fixture generators for each.

Checked against ezdxf on real drawings

  • Header variables: 2,943 DXF files, no differences on any variable.
  • Attributes: 170 drawings, 7,020 attributes on model-space references, 3,634 inside blocks, 6,680 definitions and all 441 visible ones after expansion, no differences.
  • SOLID and 3DFACE: 365 SOLIDs in 35 drawings and 13,106 3DFACEs in 170, every count and coordinate agrees.
  • Angular: all 8 three-point angular dimensions in two AutoCAD drawings match the text AutoCAD stored. ezdxf puts the arc on the other side for two of them, so the side rule follows AutoCAD, not ezdxf.

Changed (see "Upgrading from 0.5" in the README)

  • DXF.Entity has four new cases, Counts four new fields, and Contour.Warning a new case, .ignoredEntities(type:count:), which replaces .skippedEntities for these types. An exhaustive switch over any of them needs the new cases.
  • DimensionText.Part has a new case, .angle, and typedNumbers of 45° is [], where it was [45].
  • Header values are read from the HEADER section only; a group 9 elsewhere in the file was once taken for a variable. No real drawing differs.
  • ATTRIB is no longer in skipped. A stray ATTRIB and a model-space ATTDEF still are.
  • A SOLID on a -z plane is converted into the world, as an ARC is. A block expansion no longer scales an angular dimension's group 42 by the insertion scale.
  • Every existing initialiser keeps its parameters in order, the new ones last and defaulted.

Not yet

  • No real TOLERANCE or WIPEOUT was found on the machines checked, so both rest on ezdxf-written fixtures; how AutoCAD writes a projected-zone height or a datum identifier is unverified and lands in Frame.unread.
  • No AutoCAD ordinate dimension was available, so ordinate values are checked against ezdxf only and are not signed. No real file has an angular dimension carrying group 42.
  • DIMAUNIT and DIMADEC (angle display units and places) are not modelled. WIPEOUT clip mode and a SOLID's R11 elevation are not read.
  • An AutoCAD-written title block was not available for #30; attributes are checked on ezdxf-written R2000, R2018 multiline and array fixtures and on 170 real R12 and R2013 drawings.
  • Decoding of TOLERANCE and WIPEOUT for a DWG is SwiftDWG#13.