Open Source Cad Drawing (Dwg) Library in C#

CAD/CAM without C++

If you have a lot of legacy code that would need to be rewritten, I don't see it making business sense to switch to a different language. Even if there were gains to be had from using a different language (which is questionable), the cost of testing and debugging the new code would more than overcome them. You also have a development team that are experts in C++. There would be a big productivity drop while they came up to speed on the new language.

Are there any libraries for parsing AutoCAD files?

Duplicate of (or at least related to) Open source cad drawing (dwg) library in C# & .Net CAD component that can read/write dxf/ dwg files

There isn't anything available for parsing DWG for free that I would regard as reliable. The Open Design Alliance tends to be cheaper & runs on more OS's than AutoDesk's RealDWG offering. The ODA has a price-tier for startups who aren't yet shipping code - RealDWG doesn't. Both the ODA and AutoDesk offer support in forums - you have to be a member of the ODA but AutoDesk's forums are at http://discussion.autodesk.com/forums/ where you can join for free.

DXF is a text-file format (similar to XML) which you can parse with anything you like - if you know what you're looking for. You may have more luck with finding a library for that (I haven't looked into it) but that would involve conversion from DWG format. Note that there are various releases of the DXF format

You can try Autodesk's DWG Trueview (free) but it is an end-user viewer - it doesn't officially offer an API. Some people have had varying degree of success in the past automating it. I haven't tried myself & I strongly suspect the latest versions have been hardened against that.

Ultimately, if you are working for high-profile clients who are likely to insist on, or at least balk at the absence of 'official' AutoCAD libraries and the "Trusted DWG" BS that goes with it then you may need to invest in a membership of the Autodesk Developer Network.

As a long-time end user I can tell you the devs at the ODA are more responsive to bug reports than AutoCAD.

Reading .DXF files

Cadlib from WoutWare have I been using for a couple of projects with good results.

Create Autocad file with C#

I think your only choice if you want DWG is to use OpenDesign. If you don't want to pay what that costs, you can write DXF instead. I have used VectorDraw, which does give a reasonable object model, and can export DXF without any extra component (I think), or use OpenDesign to write DWG.

AutoCAD - Is it possible to analyze .dwg file?

You could, but it's not easy.

An AutoCAD .DWG file is basically just geometry (lines and arcs). You may have some well organized files with block, let's say a "Door" block, but it's not 100% confident: for instance, you may have "Door1" and "Out Patio Door" as a block name.

For both cases, the way the main problem is to understand the geometry and interpret somehow. Assuming you can, then you have some options of paths:

  • Run an in-process plugin on AutoCAD: this can be accomplished in C++, .NET (C#, VB.NET), LISP or VBA. There are tons of resources, like DevCenter, blog and blog.
  • Use as a library to access the objects, like RealDWG or other open source. This might be tricky and requires programming (like above).
  • Use a webservice, like AutoCAD I/O, to upload a .DWG and a .DLL (.NET) code that will analyse your drawing.

To interpret the geometry (with any of the above), the BRep API is the best way to analyze the geometry, like intersection points and other relations. The the blog you'll find some samples around it, but I don't believe there is something on this area. Check this and this.

Finally, as a summary, with .NET you'll need the Autodesk.AutoCAD.DatabaseServices namespace with Line, Arc, BlockReference and the respective IntersectWith methods to do some basic analysis.

Now if you have an AutoCAD Architecture .DWG drawing, it might be easier as some basic objects are available as part of the APIs, like Walls and Doors. I don't believe that's the case, but if so, check at this link.

Moving an engineering application from standalone to internal to CAD

Have a look at my answers to a couple of previous AutoCAD questions

Open source cad drawing (dwg) library in C#

.Net CAD component that can read/write dxf/ dwg files

If you were looking for the same code base to work both inside and outside of AutoCAD then the RealDWG approach may work for you since the code is the same - RealDWG doesn't need AutoCAD as a host application. The open Design Alliance libraries are for making stand-alone applications. Both have supported C++ for years & can be considered stable - well, as stable as CAD gets.

This blog (http://through-the-interface.typepad.com/) is a good one for RealDWG



Related Topics



Leave a reply



Submit