AutoCAD library in Java to read .dwg files?

2019-01-25 21:47发布

Is there any open-source Java or JavaScript library available to parse .dwg files and get the objects from it.

I would like to extract data from a table of text for my project.

It seems that the AutoCAD developer community prefers .NET and C/C++ over JAVA.

The only free alternative I found is by converting .dwg to .dxf first and using the Kabeja lib to read from it.

4条回答
可以哭但决不认输i
2楼-- · 2019-01-25 22:15

Credits to all who have answered, I've tested all your proposition and here's what I've found , as of 2015:

There is currently no free AND reliable solution to read and manipulate .dwg and .dxf files. This applies especially to latest versions of AutoCAD, ex : Autocad 2010, Autocad 2013 etc, RF 2013, RF 2010.

Reliable (and expensive) solutions would be Teigha by ODA (2000$ a year) and RealDWG in C# by Autocad (5000$ a year)...

Cheaper alternatives are as such :

  • AutoCAD I/O for 10$ per month (as suggested by Augusto Gonclaves), but limited functionalities for now.
  • writing LISPS routine and running them with a SCRIPT file in a paid instance of AutoCAD 2015/2016..
  • wait for a more complete implementation of AutoCad Core Console..

Open-source libraries such as Kabeja and YCad may be able to deal with older AutoCAD versions but do not expect much from them as these projects are inactive since a few years ago. It's worth to keep an eye out for Apache Tika though, since they started writing parsers for .dwg files but development has been slow.

On a personal note, I think that AutoDesk has a strong and selfish monopoly on the CAD market now and they are making it difficult for others to join in. The format's version of .dwg files changes so often and I guess open-source developers will have to give up at some point and use the official product instead.

Let's hope for more open-source solutions in the coming years

查看更多
唯我独甜
3楼-- · 2019-01-25 22:17

Autodesk developed AutoCAD mainly with a C++ and offers plug-in support for C++, .NET, JavaScript, VBA and LISP, that's why there is no native Java support. All of those will require AutoCAD installed on the machine.

Alternatively, you can use the AutoCAD I/O webservice, that is basically a running instance on the cloud, to run custom code and extract data or create new drawings. That will have support for all DWG features. Check http://developer.autodesk.com

查看更多
孤傲高冷的网名
4楼-- · 2019-01-25 22:25

As you pointed out, use DXF format instead, there is open source java library, YCAD also, that you can use and is very easy to use.

查看更多
闹够了就滚
5楼-- · 2019-01-25 22:27

The Teigha library from opendesignaliance has C++, C#, and Java interface. Teigha is the alternative of RealDWG and it is widely used by many CAD software vendors. It is stable and has the power to read/edit/write dwgs without problem. We have more than 3 years of experience with it and I can say it is excellent and a lot cheaper. When we were at the point to choose between RealDWG and Teigha we chose Teigha and I am glad we did it.

Leveraging SWIG to Create Teigha for Java

In 2013, ODA used the Java support provided by SWIG to create "Teigha for Java". Teigha for Java includes the following:

Java access to the full Teigha API for both .dwg and .dgn files. Support for Windows, Linux and Mac platforms. API very similar to Teigha.NET, simplifying the transition between languages.

查看更多
登录 后发表回答