Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c751ea4
Add the DwgIO.Scene adapter and the dwgio scene command
mahach666 Nov 19, 2026
8b7ed94
Export drawings to OBJ and GLB through the scene
mahach666 Nov 19, 2026
d3d1ada
Draw model space to SVG
mahach666 Nov 19, 2026
946d20c
Write a standalone HTML viewer of the drawing
mahach666 Nov 19, 2026
9dee879
Fix the entity colour index, invariant CLI numbers and inspect diagno…
mahach666 Nov 19, 2026
163ec6f
Resync the object walk at handle-map offsets and report gaps (#13)
mahach666 Nov 19, 2026
6d66bf5
Report skipped encrypted sections in Diagnostics and inspect (#38)
mahach666 Nov 19, 2026
ca4b62c
Give dwgio preview its own exit code for a missing thumbnail (#14)
mahach666 Nov 19, 2026
45288b7
Add --version/--help, an entities command and JSON to stdout
mahach666 Nov 19, 2026
970e93a
Fill DwgAppInfo.Product from the product XML's name attribute (#35)
mahach666 Nov 19, 2026
cf6967e
Parse the history and template sections (#36)
mahach666 Nov 20, 2026
f0b5bbd
Add DwgDocument.Open(Stream) (#37, first step)
mahach666 Nov 20, 2026
c0acbc5
Run the tests in CI on Linux and macOS; add the public fixture folder…
mahach666 Nov 20, 2026
2820153
Complete the fixed object type table (#20) and temper the AC1018 clai…
mahach666 Nov 20, 2026
025619d
Link the public fixture README through its GitHub URL
mahach666 Nov 20, 2026
f30167d
Link the public fixture README through its GitHub URL
mahach666 Nov 20, 2026
ce18d89
Keep the previous OBJ/MTL pair when a replace step fails
mahach666 Nov 20, 2026
23c0847
Merge commit 'ce18d898f02a57e18a74ad14f60eaf511fd0b7aa' into codex/fi…
mahach666 Nov 20, 2026
6485730
Correct DWG export, metadata and fixture regressions
mahach666 Nov 20, 2026
bcddcab
Merge commit 'b13d5d13227d514e36c814b2cdf5c96b8240bb2d'; commit 'c389…
mahach666 Nov 20, 2026
22b3cfc
Apply protected ACL fixtures to both OBJ output files
mahach666 Nov 20, 2026
c3347cc
Merge pull request #63 from IOExtend/feat/20-39-type-table
mahach666 Nov 20, 2026
e7d26ef
Merge pull request #62 from IOExtend/feat/33-34-ci-and-public-fixtures
mahach666 Nov 20, 2026
d7562a5
Merge pull request #61 from IOExtend/feat/37-open-stream
mahach666 Nov 20, 2026
3bc5f00
Merge pull request #60 from IOExtend/feat/36-history-sections
mahach666 Nov 20, 2026
819a4ca
Merge pull request #59 from IOExtend/fix/35-appinfo-product
mahach666 Nov 20, 2026
a0fe8ea
Merge pull request #58 from IOExtend/feat/18-19-cli-entities-stdout
mahach666 Nov 20, 2026
c29a4db
Merge pull request #57 from IOExtend/fix/14-preview-exit-code
mahach666 Nov 20, 2026
fc4a34b
Merge pull request #56 from IOExtend/fix/38-encrypted-section-diagnos…
mahach666 Nov 20, 2026
060be4c
Merge pull request #55 from IOExtend/fix/13-object-stream-gaps
mahach666 Nov 20, 2026
df8d874
Merge pull request #54 from IOExtend/fix/entity-colour-locale-diagnos…
mahach666 Nov 20, 2026
ffafa58
Merge pull request #53 from IOExtend/feat/html-viewer
mahach666 Nov 20, 2026
7d0aff1
Merge pull request #52 from IOExtend/feat/svg-export
mahach666 Nov 20, 2026
1205965
Merge pull request #51 from IOExtend/feat/export-obj-glb
mahach666 Nov 20, 2026
b3c0231
Merge remote-tracking branch 'origin/main' into codex/merge-dwgio-stack
mahach666 Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
Expand All @@ -31,14 +31,3 @@ jobs:
name: packages-${{ matrix.os }}
path: artifacts/*.nupkg
if-no-files-found: error

build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v6
with:
dotnet-version: |
8.0.x
10.0.x
- run: dotnet build src/DwgIO.Cli/DwgIO.Cli.csproj -c Release
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,63 @@ API between minor releases.

## [Unreleased]

### Added
- CI runs the tests on Linux and macOS as well as Windows (both target frameworks), replacing the Linux
build-only job (#34).
- `test-files/public`: the folder for committed redistributable test drawings, with the origin and licence
recorded next to each file; the fixture search includes it, so a committed drawing turns the skipped
fixture tests into real runs in CI (#33, infrastructure — the drawings themselves follow).
- `DwgDocument.Open(Stream, documentName?, options?)`: a drawing can now come from a stream (a network
handle, an archive entry, an already-open file). The stream is read to memory once, so the results are
identical to `Open(path)` on the same bytes; the unsupported-version message names the source (#37, first
step — reading data pages on demand remains open).
- `AcDb:RevHistory`, `AcDb:AuxHeader` and `AcDb:Template` parsing exposes the revision values, auxiliary
header and template description on `DwgDocument`, in JSON and in `dwgio inspect`. The undecoded
`AcDb:AppInfoHistory` section is exposed as decompressed bytes, with its size in JSON and CLI output (#36).
- Fixed object type names are available in `DwgObjectInfo.TypeName`, `dwgio inspect` and the JSON
`objects.byTypeName` field. Existing `objects.byType` keys are preserved (#20, fixed types only).
- `dwgio --version` and `--help` (and `-v`/`-h`) print the version and the usage with exit code 0; an unknown
option still exits 1 (#18).
- `dwgio entities <file.dwg> [--type LINE,CIRCLE] [--json]` lists decoded entities one line each or as a JSON
array, with the type filter validated against the known type names (#19). The JSON export writes to standard
output when the target is `-` (#19).
- `DwgIO.Scene` package: converts a drawing into a neutral [IOScene](https://www.nuget.org/packages/IOScene) scene
document, the shared scene model of the IOExtend tools. One element per decoded entity with the handle as
`SourceId`, line and point geometries scaled to metres (`DwgSceneOptions.LengthUnit`), ACI colours on the
placements and a conversion report (`DwgSceneResult`). The scene passes the IOScene structural validation and
round-trips through the IOScene JSON format.
- `dwgio scene <file.dwg> <out.json> [--unit mm|cm|m|ft|in]` writes the scene document.
- `DwgSceneExport.SaveObj`/`SaveGlb` write a drawing to Wavefront OBJ (with an adjacent MTL colour library,
written as a pair) and binary glTF (GLB) through the IOScene writers; `dwgio drawing.dwg out.obj` and
`dwgio drawing.dwg out.glb` dispatch by extension.
- `DwgSvgExporter` and `dwgio svg <file.dwg> <out.svg> [--scale n]` draw model space to SVG (#32): LINE,
CIRCLE, ARC and POINT in the top view with the y axis up, in their ACI colours, inside a view box that
contains every exported entity. Polylines, curves and text follow as the core decodes them.
- `DwgViewerExport.SaveViewer` and `dwgio drawing.dwg out.html` write a standalone interactive 3D HTML viewer
(the IOViewer WebGL runtime embedded with the IOScene scene document; no server, no external scripts).
- `dwgio inspect` is written through a `TextWriter`, so the report is testable directly.

### Fixed
- `DwgAppInfo.Product` is filled from the product XML's `name` attribute ("AutoCAD", "AutoCAD LT",
"Teigha(R)", ...), so `dwgio inspect` and the JSON export name the product instead of an empty string (#35).
- `dwgio preview` exits with code 5 when the drawing has no thumbnail, distinct from the parse-error code, and
reports a mismatch between the requested output extension and the image kind on standard error instead of
keeping both silent (#14).
- Encrypted sections (encryption flag 1) are reported in `Diagnostics` and by `dwgio inspect` (the section
table marks them) instead of being skipped silently; decrypting them remains out of scope (#38).
- Object stream: after a gap (a zero run or a broken record) the object walk resynchronises at the next
handle-map offset instead of stopping, and every early stop or skipped gap is reported in `Diagnostics`; the
inventory-versus-handle-map difference is reported as well, and `DwgHandleMap.Parse` reports truncated blocks
and drops negative offsets with a diagnostic (#13).
- Fixture tests skip drawings of an unsupported version and count them in the skip reason, so one AC1021 file
in the fixture folder does not fail every test (#17).
- Entity colour: the DXF 62 index takes the low 9 bits of the stored colour value, so BYLAYER (256) is reported
as 256 and not as 0 (which also means BYBLOCK) (#40). The JSON export writes `colorIndex` for BYBLOCK and
BYLAYER so they are distinguishable.
- `dwgio` formats counts and byte sizes invariantly; the output no longer follows the machine's digit grouping
(#15).
- `dwgio inspect` always prints the diagnostic total and the first diagnostics, whether or not any entity was
decoded (#16).
- Packed 16-bit and 32-bit integers in their full-width form are read little-endian. They were read with their bytes
reversed, so entity records that store a colour, extended data size or reactor count in that form were decoded from
the wrong bit position and failed or gave NaN or absurd coordinates (#7).
Expand Down
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ facts as they are observed in DWG files, in your own words, in code comments,
documentation and commit messages.

Do not add vendor code, SDKs, SDK internals, headers or binaries, decompiled or
leaked source, or anything taken from analysing vendor binaries. Do not add DWG
or DXF drawings, customer data, or names, paths, sizes or other details of
leaked source, or anything taken from analysing vendor binaries.
Add DWG fixtures only under `test-files/public` and only when they meet its origin and licence rules.
Do not add other drawings, customer data, or names, paths, sizes or other details of
private sample drawings to the repository, including tests, comments and
documentation. Test inputs are built synthetically in the tests; tests that
need private drawings read them from the folder named by `DWGIO_TEST_FILES` and
Expand Down Expand Up @@ -87,7 +88,7 @@ Include:
- The build and test commands run, their results, and any skipped checks.
- Before and after output comparison results when the output is affected.

Do not add drawings, customer data, vendor code or binaries to the
Do not add private drawings, customer data, vendor code or binaries to the
repository. Keep private test drawings outside version control.

Write commit messages in the imperative mood, for example,
Expand Down
9 changes: 9 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.404" />
</ItemGroup>

<ItemGroup>
<!-- Neutral scene model, referenced by DwgIO.Scene with a range whose upper bound is a prerelease.
IOScene.Formats (GLB and OBJ writers) ships as a preview and needs IOScene 0.1.1 or later. -->
<PackageVersion Include="IOScene" Version="[0.1.1, 0.2.0-0.0)" />
<PackageVersion Include="IOScene.Formats" Version="[0.1.0-preview.1]" />
<!-- Standalone WebGL HTML viewer generator; accepts IOScene scene documents directly. -->
<PackageVersion Include="IOViewer" Version="[0.3.1]" />
</ItemGroup>

<ItemGroup>
<!-- Test-only packages, pinned to exact versions (no floating ranges). -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
Expand Down
1 change: 1 addition & 0 deletions DwgIO.slnx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Solution>
<Project Path="src/DwgIO/DwgIO.csproj" />
<Project Path="src/DwgIO.Scene/DwgIO.Scene.csproj" />
<Project Path="src/DwgIO.Cli/DwgIO.Cli.csproj" />
<Project Path="tests/DwgIO.Tests/DwgIO.Tests.csproj" />
</Solution>
78 changes: 71 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ DwgIO is a .NET library and command line tool that reads Autodesk AutoCAD drawin
- Parses drawing metadata: summary information with custom properties and dates, application information, file dependencies and the embedded thumbnail preview.
- Lists the objects of a drawing through its handle map and decodes the geometry of LINE, CIRCLE, ARC and POINT entities.
- Writes a JSON export of the metadata, the section catalog and the decoded entities.
- Converts a drawing into a neutral [IOScene](https://www.nuget.org/packages/IOScene) scene document (`DwgIO.Scene` package): geometry in metres, ACI entity colours, one element per entity with its handle.
- Exports the scene to Wavefront OBJ (with an MTL colour library) and binary glTF (GLB).
- Draws model space to SVG (`dwgio svg`): LINE, CIRCLE, ARC and POINT in the top view, in their ACI colours.
- Writes a standalone interactive 3D HTML viewer (`.html`): the WebGL viewer of [IOViewer](https://github.com/IOExtend/IOViewer) embedded with the scene, no server or external scripts.

## Install

Expand All @@ -21,13 +25,14 @@ Install the command line tool:
dotnet tool install --global DwgIO.Cli
```

and add the library to a .NET project:
and add the libraries to a .NET project:

```sh
dotnet add package DwgIO
dotnet add package DwgIO.Scene
```

The library targets .NET 8 and .NET 10. It uses managed code without native dependencies or Windows-only APIs and supports Windows, Linux and macOS. Tests currently run on Windows.
The libraries target .NET 8 and .NET 10. They use managed code without native dependencies or Windows-only APIs and support Windows, Linux and macOS. Tests run on Windows, Linux and macOS.

## Command line

Expand All @@ -49,13 +54,51 @@ Write the decompressed bytes of one named section:
dwgio extract drawing.dwg AcDb:Header header.bin
```

Save the embedded thumbnail preview. Without an extension, `.png`, `.wmf` or `.bmp` is added to match the image:
Save the embedded thumbnail preview. Without an extension, `.png`, `.wmf` or `.bmp` is added to match the image; a mismatching extension is reported on standard error, and a drawing without a thumbnail exits with code 5:

```sh
dwgio preview drawing.dwg thumbnail
```

Errors go to standard error.
Export a neutral IOScene scene document (geometry in metres, ACI colours, one element per decoded entity). `--unit` names the drawing unit the coordinates are scaled from — one of `mm`, `cm`, `m` (default), `ft`, `in`:

```sh
dwgio scene drawing.dwg drawing.scene.json --unit mm
```

The plain export command writes OBJ and GLB by output extension, through the same scene:

```sh
dwgio drawing.dwg drawing.obj # Wavefront OBJ + drawing.mtl with the ACI colours
dwgio drawing.dwg drawing.glb # binary glTF for viewers and web scenes
```

Draw model space to SVG (X to the right, Y up, ACI colours; `--scale` sets pixels per drawing unit):

```sh
dwgio svg drawing.dwg drawing.svg --scale 2
```

Open the drawing in a standalone interactive 3D HTML viewer:

```sh
dwgio drawing.dwg drawing.html
```

List the decoded entities, one line each, optionally filtered by type and as JSON:

```sh
dwgio entities drawing.dwg --type LINE,CIRCLE
dwgio entities drawing.dwg --json
```

The JSON export also writes to standard output when the target is `-`:

```sh
dwgio drawing.dwg - | jq .summaryInfo
```

`dwgio --version` prints the package version, `dwgio --help` the usage. Errors go to standard error.

### Exit codes

Expand All @@ -65,11 +108,12 @@ Errors go to standard error.
| 1 | The command line is wrong. |
| 2 | The input file does not exist. |
| 3 | The DWG version is not supported yet (R13 to R2000, R2007) or not recognised. |
| 4 | The file could not be parsed, the drawing has no thumbnail preview (`preview`), or an unexpected error occurred. |
| 4 | The file could not be parsed, or an unexpected error occurred. |
| 5 | The drawing has no thumbnail preview (`preview`). |

## Library

Open a drawing, list its sections and read one of them:
Open a drawing (from a path or from a stream — a network handle, an archive entry, an already-open file; the stream is read to memory once and `Open(Stream)` gives the same results as `Open(path)`), list its sections and read one of them:

```csharp
using System;
Expand All @@ -79,6 +123,9 @@ var doc = DwgDocument.Open("drawing.dwg");

Console.WriteLine($"{doc.Version.Release} ({doc.Version.Magic})");

// or from a stream:
// var doc = DwgDocument.Open(httpResponse.Content.ReadAsStream(), "remote.dwg");

foreach (var section in doc.Sections)
{
Console.WriteLine($"{section.Name,-24} {section.Size,12} bytes pages={section.PageCount}");
Expand All @@ -96,6 +143,19 @@ foreach (var entity in doc.Entities)

The JSON export is `DwgJsonExporter` in the `DwgIO.Json` namespace. See [Getting started](docs/getting-started.md) and [Public API](docs/public-api.md) for the supported types.

The scene export is `DwgSceneReader` in the `DwgIO.Scene` package. It converts a drawing into an `IOScene.SceneDocument` — the neutral scene model of the IOExtend tools, shared with RvtIO and NwcIO:

```csharp
using DwgIO.Scene;

var scene = DwgSceneReader.Read("drawing.dwg", new DwgSceneOptions { LengthUnit = "mm" });
IOScene.SceneJson.Save(scene.Document, "drawing.scene.json");
```

Every coordinate is scaled to metres by `LengthUnit` (a DWG stores plain numbers, so the unit is a caller decision and `UnitAssumed` records it), each entity becomes an element with its handle as `SourceId`, and LINE, CIRCLE, ARC and POINT become line and point geometries with their ACI colour.

`DwgSceneExport` writes that scene out in the exchange formats: `SaveObj(document, "drawing.obj", options)` produces an OBJ with an adjacent MTL colour library (with rollback if replacement fails), `SaveGlb(document, "drawing.glb", options)` produces binary glTF. Both return the same `DwgSceneResult` report.

The documentation site with the API reference is at <https://ioextend.github.io/DwgIO/>. [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/IOExtend/DwgIO) offers an automatically generated overview of the repository.

## Status
Expand All @@ -111,6 +171,10 @@ The documentation site with the API reference is at <https://ioextend.github.io/
| `AcDb:AppInfo`, `AcDb:FileDepList` and `AcDb:Preview` parsing | done |
| Handle map and object stream inventory | done |
| Entity decoding: LINE, CIRCLE, ARC and POINT geometry | done (partial) |
| IOScene scene export (`DwgIO.Scene`): entities, geometry, ACI colours | done (partial) |
| OBJ and GLB export through the scene | done (partial) |
| SVG export of model space (`dwgio svg`) | done (partial) |
| Standalone HTML viewer export through IOViewer | done (partial) |
| AutoCAD 2007 container (AC1021) | planned |
| R13 to R2000 container (AC1012 to AC1015) | planned |

Expand All @@ -121,7 +185,7 @@ The documentation site with the API reference is at <https://ioextend.github.io/
| AC1012 | R13 | flat section locators | planned |
| AC1014 | R14 | flat section locators | planned |
| AC1015 | R2000 | flat section locators | planned |
| AC1018 | R2004 | paged, compressed sections | done |
| AC1018 | R2004 | paged, compressed sections | verified locally on real drawings |
| AC1021 | R2007 | Reed-Solomon coded pages | planned |
| AC1024 | R2010 | paged, compressed sections | done |
| AC1027 | R2013 | paged, compressed sections | done |
Expand Down
15 changes: 14 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The packages are published on nuget.org and attached to each tagged GitHub relea
```sh
dotnet tool install --global DwgIO.Cli
dotnet add package DwgIO
dotnet add package DwgIO.Scene
```

## Command line tool
Expand All @@ -20,6 +21,7 @@ dwgio inspect drawing.dwg # version, metadata, entities and
dwgio drawing.dwg drawing.json # metadata, section catalog and entities as JSON
dwgio extract drawing.dwg AcDb:Header out.bin # decompressed bytes of one named section
dwgio preview drawing.dwg thumbnail # embedded thumbnail; .png, .wmf or .bmp is added
dwgio scene drawing.dwg drawing.scene.json # neutral IOScene scene document (--unit mm|cm|m|ft|in)
```

Sections are named as stored in the drawing, for example `AcDb:Header`, `AcDb:Classes` or `AcDb:SummaryInfo`. Errors go to standard error.
Expand All @@ -30,7 +32,8 @@ Sections are named as stored in the drawing, for example `AcDb:Header`, `AcDb:Cl
| 1 | The command line is wrong. |
| 2 | The input file does not exist. |
| 3 | The DWG version is not supported yet or not recognised. |
| 4 | The file could not be parsed, the drawing has no thumbnail preview (`preview`), or an unexpected error occurred. |
| 4 | The file could not be parsed, or an unexpected error occurred. |
| 5 | The drawing has no thumbnail preview (`preview`). |

## Library

Expand Down Expand Up @@ -64,6 +67,16 @@ foreach (var diagnostic in doc.Diagnostics)
}
```

The scene export converts a drawing into an [IOScene](https://www.nuget.org/packages/IOScene) scene document with
`DwgSceneReader` (see [Public API](public-api.md)):

```csharp
using DwgIO.Scene;

var scene = DwgSceneReader.Read("drawing.dwg", new DwgSceneOptions { LengthUnit = "mm" });
IOScene.SceneJson.Save(scene.Document, "drawing.scene.json");
```

The supported surface is listed in [Public API](public-api.md); every type is in the [API reference](api/DwgIO.yml).

## Status
Expand Down
Loading
Loading