viewhack

DGN viewer: open a MicroStation V7 drawing and save it as SVG

Open a .dgn without MicroStation: a road or rail plan from a highways agency, a survey from a contractor, an old site drawing from an archive. You see the drawing in the file's own colours, every level with a switch to hide it, the units and global origin, and you can save it as SVG or PNG.

The file is read on your device. It is not uploaded, and nothing in it is fetched or run.

What it shows

How a V7 file stores a position: a worked example

A V7 design file does not store metres or feet. Every coordinate is a whole number of UORs (units of resolution), a 32-bit integer, and the file header says how UORs turn into real units: how many sub-units make one master unit (at byte 1112) and how many UORs make one sub-unit (at byte 1116).

Take smalltest.dgn, the sample file in GDAL's test suite. Its header gives 10 sub-units (“su”) per master unit (“mu”) and 1,000 UORs per sub-unit, so 10,000 UORs per master unit. Its text element “Demo Text” stores its origin as x = 7,365 and y = 42,198 UORs: that is 0.7365 and 4.2198 master units. Its height is stored as 1,666,667, a number in steps of 6/1,000 of a UOR: 1,666,667 × 6 ÷ 1,000 = 10,000 UORs (to the nearest UOR), which is 1 master unit. This page reads those same numbers, and its test checks them.

The 32-bit integer is also why V7 drawings have a size limit: the whole design plane is 232 = 4,294,967,296 UORs across. At 1,000 UORs per metre that is about 4,295 km, enough for a country; at 100,000 UORs per metre (0.01 mm resolution) it is only 42.9 km, and a long road scheme can run off the edge. Moving that edge is what the global origin is for.

V7 or V8? Telling them apart

MicroStation V7 (this page opens it)
The format of MicroStation/J and earlier versions, back to Intergraph's IGDS. It starts with the type-9 design file header: bytes 08 09 FE 02 for a 2D file, C8 09 FE 02 for 3D. Some highway, rail and survey offices still hand out V7 files, because so many programs read it.
MicroStation V8, XM, V8i and CONNECT (not opened here)
Since MicroStation V8 in 2001 the .dgn name holds a different format: an OLE compound file, starting D0 CF 11 E0, the container old Word and Excel files use. viewhack recognises it and says so. Bentley View (free, Windows) opens and prints V8 files, and QGIS opens them as map layers in builds that include GDAL's DGNv8 driver (it needs the ODA libraries, which not every QGIS download has). MicroStation itself can save a copy as V7, which opens here.

What this cannot do

The reader was written for viewhack from the published V7 element descriptions; MicroStation's default colour table comes from GDAL's MIT-licensed dgnlib. viewhack is not affiliated with Bentley Systems; MicroStation is their trademark.