Open source cad drawing (dwg) library in C#

82,699

Solution 1

The major hurdle with the DWG format is that the binary format changes every 3 years - and it is due to change again in March 2009. It is encrypted and the specifications for it are not made public. It is a massively complicated library with many dark alleys unknown to even AutoDesk (they acquired it years ago).

Not open source but the Open Design Alliance ... (from their Web site)...

is a non-profit membership-based consortium of software companies, developers and users committed to promoting the open exchange of CAD data now and in the future. In addition to setting standards for CAD data formats, the ODA also focuses on the practical matter of developing software libraries of exceptional quality that enable ODA members to develop applications capable of reading and writing the popular DWG and DGN CAD file formats.

Cost depends on what you are using the libraries for but the base-level cost for a developer is U$100/year with a U$250 joining fee. Compare that to AutoDesk's RealDWG at $2500/year and $5000 for the 1st year then it's a bargain. The RealDWG licence is per product, by the way. The ODA licenses are a bit more reasonable and also allow you to make more than 1 product on the same license. you can pay for the source code but it costs a bomb - less than developing it yourself though

If you only have 1 product then perhaps RealDWG will suit you but it's Windows only - bonus, it has a .NET API which the ODA are still working on ... the ODA's .NET APIs (there are 2) are well-established. The ODA products are compiled for a number of operating systems, including Windows (32-bit), SGI, Solaris, Windows (64-bit), Macintosh, HP, Windows CE, Linux, IBM AIX.

I any case that's a massive wheel to reinvent so it's definitely worth paying for one that already turns.

Some 3rd-party libraries exist out there with limited specific API functionality to try searching for those if your needs are very specific.

It is also worth noting that AutoDesk has been in more-or-less continuous litigation with the ODA for years now. If you decide to compete with them then that's another complexity you have to look forward to.

UPDATE:

Those days are pretty-much over.

I am also developing a product that talks to DWG files. I'm going the commercial route because the time, expense and hassle involved is utterly uneconomical for me.

UPDATE:

I did. tvCAD.tv is built on RealDwg

Update July 2018

Although I used RealDwg for tvCAD, I would probably use the ODA libraries if I were to start that project today. Building the RealDwg installer was a nightmare. Also, the RealDwg install size is about 10x the ODA install size. Yah, seriously.

Autodesk's dominance in the AutoCAD market is waning, it is no longer the "IBM" choice. I may convert tvCAD to the ODA libraries sometime in the future - it wouldn't take much more pain to push me into that. The licensing costs are comparable.

I have historically found the support from the ODA to be better than that in the Autodesk environment, apart from the active and fantastic peer support on the forums mentioned in the AutoCAD tag wiki which is pretty universal to all the platforms. .NET code from RealDwg can be used pretty-much verbatim with the ODA libraries. Ditto with .NET plugins for AutoCAD / BricsCAD etc.

Solution 2

If you go down the dxf route I would suggest netDXF . it's open source and worked well for my limited requirements though it is missing multi-line text support and the author says there are some other things he wont support because they're proprietary to autodesk.

Solution 3

There are no open source solutions, there are a few commercial ones, amongst which a .NET component named CadLib provided by Wout Ware: http://www.woutware.com/cadlib.html.

Solution 4

did anyone try cadsofttools CAD Import?

http://www.cadsofttools.com http://www.cadsofttools.com/en/products/cad_import_.net.html

Solution 5

The easiest route is to convert dwg to dxf ascii, it is fairly simple to query ascii dxf.

Share:
82,699

Related videos on Youtube

Mac
Author by

Mac

Software engineer.

Updated on March 06, 2020

Comments

  • Mac
    Mac over 4 years

    Anyone knows of an open source DWG (autocad drawing) library in C#?

  • CAD bloke
    CAD bloke over 14 years
    brace = brave. The ODA's .NET version is alive & well and in production.
  • CAD bloke
    CAD bloke over 13 years
    The ODA's .NET API is alive & kicking. I find they are much more responsive to bug reports etc than the "official" alternative
  • DynamicScope
    DynamicScope over 12 years
    I am trying to make CAD application using some CAD engine. Does the Teigha support constructions/modifications of entities like points, line, polyline, polygon, etc. ???
  • CAD bloke
    CAD bloke over 12 years
    Yes, it supports nearly all of the AutoCAD feature set. The only things missing are really fancy functions from the very latest versions, afaik. It has always had everything I want.
  • DynamicScope
    DynamicScope over 12 years
    Thanks for the reply. I am wondering if LiteCAD can be integrated with ObjectARX (AutoCAD). If so, up to what version of ObjectARX can be supported?
  • CAD bloke
    CAD bloke over 12 years
    AutoCAD LT? No, it doesn't have an API except for DIESEL which is a very limited approach.
  • DynamicScope
    DynamicScope over 12 years
    Oops, sorry. I don't know why I said LiteCAD I meant "Teigha." I'm sorry.
  • CAD bloke
    CAD bloke over 12 years
    Nor sure about Teigha & ObjectARX. You'd best look at their site for that info
  • Oak_3260548
    Oak_3260548 almost 5 years
    I've been testing it for about a year. There were two large limitations: Inability to open older files before 2010 formats (looks like solved by Zmorzinski branch) and possible inability to break blocks (read their content). Perphaps the second issue was sorted as well, I saw some discussion over it, but didn't tested yet. Otherwise it's easy to implement to .NET and fast.