How the DWG/DXF Viewer Works
AnyTool DWG/DXF Viewer opens an AutoCAD drawing entirely in the browser. When you choose a file it is read to an ArrayBuffer, and the engine inspects the leading bytes to detect the format: a DWG file begins with an ASCII version tag such as AC1032, while a DXF file is plain text whose first markers are CAD group codes and a SECTION header. For DXF — AutoCAD’s ASCII interchange format — the bundled dxf-parser library (served from the same origin, never a CDN) parses the text into entities, the layer table and the header, and the engine flattens that into render-ready 2D primitives, reads each layer’s name and AutoCAD Color Index, and computes a bounding box from the header $EXTMIN/$EXTMAX or, when absent, from the geometry itself. It then draws the drawing onto an HTMLCanvasElement with a fit-to-view transform that flips the Y axis (CAD is Y-up), colouring each entity by its layer. For DWG — Autodesk’s proprietary binary format — there is no free client-side renderer, so the engine reads only the six-byte version tag and reports metadata.
- Format auto-detected from leading bytes: DXF text vs DWG AC10xx tag
- DXF parsed with the dxf-parser library, fully in the browser — no CDN, no server
- Entities flattened to 2D primitives and drawn on a canvas with a Y-flip fit transform
- Bounding box from header $EXTMIN/$EXTMAX, falling back to geometry extents
- DWG: six-byte header tag mapped to an AutoCAD release; metadata only
