Skip to content
cadkithome
Menu

Format · DWG

DWG reader for Rust, Python and JavaScript

Read DWG files from R14 to 2018 in Rust, Python, JavaScript (WebAssembly) and C with cadkit: layers, blocks, layouts and entities, without a vendor SDK.

What is supported

FormatReadWriteStatus
DWGReadAC1014 (R14) to AC1032 (2018), including 2007No writerRead-only. R13 (AC1012) is untested; entity coverage is still growing.

Supported

  • Versions AC1014 (R14), AC1015 (2000), AC1018 (2004), AC1021 (2007), AC1024 (2010), AC1027 (2013) and AC1032 (2018)
  • Model space, paper layouts, layers, linetypes, text styles and block definitions
  • Lines, points, circles, arcs, ellipses, splines, polylines and meshes, text and multiline text, attributes, block references, hatches, dimensions, leaders, faces, images and viewports
  • Header-only inspection (version, units, code page) without decoding entities
  • Export of the document as SVG, JSON, DXF, CityGML or (seed-based) DGN V8

Not supported yet

  • Writing DWG: there is no DWG writer
  • R13 (AC1012): implemented on the R14 code path, but untested for lack of a permissively licensed sample
  • Password-protected (encrypted) files
  • Multileaders, tables, subdivision meshes, PDF underlays, arc-length and large radial dimensions: kept as unknown entities
  • ACIS solids and regions beyond their header; proxy-entity graphics

Read a DWG file

Open a drawing, print its version and layer count, and render model space as SVG. The reader detects the format, so the same code opens DGN and DXF.

src/main.rs
fn main() -> Result<(), cadkit::Error> {
let doc = cadkit::open("plan.dwg")?;
println!("{} {} layers", doc.source.version, doc.layers.len());
std::fs::write("plan.svg", cadkit::to_svg(&doc, &cadkit::SvgOptions::new()))?;
Ok(())
}

From the shell

The cadkit CLI inspects a DWG without decoding it, summarises it and lists layers and blocks.

shell
cadkit inspect plan.dwg --json # header only: format, version, units, code page
cadkit info plan.dwg --warnings # summary plus the first 20 warnings
cadkit layers plan.dgn --json # DGN levels are layers
cadkit blocks plan.dxf # block definitions with entity counts
cadkit dump plan.dxf --kind arc # one line per entity of a kind

Reference