Skip to content

Releases

SwiftDWG 0.2.0

Choose a tag to compare

@gsdali gsdali released this 19 Nov 02:56
f62c11a

R14 lightweight polylines and hatches are read, and a hatch's pattern lines are written with the right DXF group codes (#12).

Fixed

  • R14 (AC1014) lightweight polylines and hatches. An R14 file has no fixed type codes for them: it declares a class for each, and the objects carry the class's number. SwiftDWG only knew the fixed codes, so each such object came through as a record holding only its handle, and nothing counted it as lost. An object whose class is LWPOLYLINE (or LWPLINE) or HATCH is now read with the existing decoders, as ACadSharp does. One that still cannot be read is counted as UNREADABLE_LWPOLYLINE or UNREADABLE_HATCH, so nothing is lost silently.
    • Checked against AutoCAD's own DXF of ACadSharp's R14 sample: 23 of 23 lightweight polylines and 8 of 8 hatches equal by handle, field by field.
    • Checked against acadrust's output on a Jw_cad R14 export: 14 of 14 polylines and 2 of 2 hatches equal by handle.
    • The DXF text of 289 other readable drawings, R2000 to R2018, is byte for byte what 0.1.0 wrote.
  • Hatch pattern lines in DWG.dxfText. A pattern line's base point was written as groups 43/53 and its offset as 45/55; DXF uses 43/44 and 45/46. DWG.read was not affected, since SwiftDXF does not read pattern lines; dxfText used as a DXF converter was. Pattern lines now equal AutoCAD's on every hatch of ACadSharp's R2000 to R2018 samples.

Still open

  • VIEWPORT objects in an R14 file still come through as records with only a handle (#13).
  • Insert attributes are not decoded (#9).

Requires Swift 5.9 and SwiftDXF 0.4.0 or later.

SwiftDWG 0.1.0

Choose a tag to compare

@gsdali gsdali released this 14 Nov 03:27
999c936

First release of SwiftDWG: a native-Swift reader for DWG, AutoCAD's binary drawing format. DWG.read(contentsOf:) returns a SwiftDXF DXF.Drawing: the same model SwiftDXF gives for a DXF, with each entity's handle as its identity, blocks, layers, line types and dimension styles. No binary, no subprocess, no C or Rust dependency.

.package(url: "https://github.com/SecondMouseAU/SwiftDWG.git", from: "0.1.0")

What is checked

A DWG is read into DXF text with AutoCAD's own group codes and handed to SwiftDXF, so a drawing from a DWG goes through the same code as one from a DXF. Every comparison is against SwiftDXF's reading of the DXF AutoCAD itself wrote from the same drawing.

  • R2000, R2004, R2007, R2010, R2013 and R2018: 262 of 267 entities identical on each, handles included. Layers, line types, dimension styles, blocks, units and extents agree.
  • R14: read, and compared with the R2000 file for lines, circles, arcs and points. R13 is written and has never been run (no sample). R12 and older are not read.
  • The comparisons against AutoCAD's sample drawings need DWG_CORPUS and run on a developer machine, not in CI; CI runs the unit tests and the two small committed drawings.

Limits (the README lists them all)

  • Splines AutoCAD R2013 and later keeps as fit points only come through without control points; a leader's hook-line vertex is not synthesised.
  • Not decoded: polyface and polygon meshes, and the attributes of an insert.
  • A layer's true colour gets the nearest palette index.
  • Text in a code page before R2007 that SwiftDWG has no table for reads as Windows-1252.
  • Many paths are checked only against hand-built bit streams, not against drawings AutoCAD wrote: MINSERT, TEXT alignment and oblique, TRACE, 2D polylines, hatch arc, ellipse and spline edges, and every R13 path.
  • Anything that cannot be read is left out and counted in SwiftDXF's skipped types (UNREADABLE_<type>), and a damaged table control object makes DWG.read throw. Before R2004 an unreadable entity no longer takes the ones after it: the links are followed from both ends of the block and the rest is found by owner. With three or more unreadable entities in one block, the draw order between them can be lost.
  • A corrupt file ends in a DWG.Error or a drawing that counts what it lost; it is not meant to trap or never return. That is checked by inverting single bytes of the committed drawings and of the AutoCAD samples (about 1,500 positions each, every byte of the file header and page maps), not proved for every byte. A file found to trap or hang is a bug to report (#6 was the two found before this release).
  • Performance has not been measured.

Provenance

SwiftDWG is a Swift port of ACadSharp (MIT) with the Open Design Specification for .dwg files. It is not clean-room. NOTICE.md carries ACadSharp's licence and the record of what was and was not consulted: no LibreDWG (GPL) or acadrust (MPL) source was read or used. DWG is a trademark of Autodesk, Inc.

Requires Swift 5.9 and SwiftDXF 0.4.0 or later.