3

I want to use code to analyze dwg file. Any one know any SDK tools to start with?

user496949
  • 83,087
  • 147
  • 309
  • 426

3 Answers3

8

From Wikipedia:

Autodesk sells a read/write library, called RealDWG, under selective licensing terms for use in non-competitive applications. Several companies have attempted to reverse engineer Autodesk's DWG format, and offer software libraries to read and write Autodesk DWG files. The most successful is Open Design Alliance, a non-profit consortium created in 1998 by a number of software developers (including competitors to Autodesk), released a read/write/view library called the OpenDWG Toolkit, which was based on the MarComp AUTODIRECT libraries. ODA has since rewritten and updated that code.

littlegreen
  • 7,290
  • 9
  • 45
  • 51
2

WoutWare's cadlib supports WinForms embedding and a few other things.

Wesley Rice
  • 2,711
  • 19
  • 8
0

If you don't have any AutoCAD or compatible CADs, there are several OSS libraries that can handle DXF. ODA provides a free (unfortunately not open-sourced) tool ODA File Converter that converts DWG to DXF. Notably, ezdxf has a wrapper API for the ODA converter.

from ezdxf.addons import odafc

# Load a DWG file
doc = odafc.readfile('my.dwg')

# Use loaded document like any other ezdxf document
print(f'Document loaded as DXF version: {doc.dxfversion}.')
msp = doc.modelspace()
...

# Export document as DWG file for AutoCAD R2018
odafc.export_dwg(doc, 'my_R2018.dwg', version='R2018')

There is also LibreCAD's module libdxfrw, but I haven't tried it.

snipsnipsnip
  • 2,268
  • 2
  • 33
  • 34