java Java中的AutoCAD库读取.dwg文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31874109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 19:17:05  来源:igfitidea点击:

AutoCAD library in Java to read .dwg files?

javaautocaddxfdwg

提问by user3336544

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

是否有任何开源 Java 或 JavaScript 库可用于解析 .dwg 文件并从中获取对象。

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.

与 JAVA 相比,AutoCAD 开发人员社区似乎更喜欢 .NET 和 C/C++。

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

我找到的唯一免费替代方法是首先将 .dwg 转换为 .dxf,然后使用 Kabeja 库从中读取。

回答by Ognyan Dimitrov

The Teigha library from opendesignaliancehas C++, C#, and Javainterface. 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.

从Teigha库opendesignalianceC ++,C#和Java接口。Teigha 是 RealDWG 的替代品,被许多 CAD 软件供应商广泛使用。它很稳定,并且可以毫无问题地读取/编辑/写入 dwg。我们有超过 3 年的经验,我可以说它非常好,而且便宜很多。当我们要在 RealDWG 和 Teigha 之间进行选择时,我们选择了 Teigha,我很高兴我们做到了。

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.

利用 SWIG 为 Java 创建 Teigha

2013 年,ODA 使用 SWIG 提供的 Java 支持创建了“Teigha for Java”。Java 版 Teigha 包括以下内容:

Java 访问 .dwg 和 .dgn 文件的完整 Teigha API。支持 Windows、Linux 和 Mac 平台。API 与 Teigha.NET 非常相似,简化了语言之间的转换。

回答by user3336544

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

感谢所有回答的人,我已经测试了您的所有提议,这是我在 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.

目前没有免费且可靠的解决方案来读取和操作 .dwg 和 .dxf 文件。这尤其适用于 AutoCAD 的最新版本,例如:Autocad 2010、Autocad 2013 等、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)...

可靠(且昂贵)的解决方案是 ODA 的 Teigha(每年 2000 美元)和 Autocad 的 C# 中的 RealDWG(每年 5000 美元)......

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..
  • AutoCAD I/O 每月 10 美元(根据 Augusto Gonclaves 的建议),但目前功能有限。
  • 编写 LISPS 例程并在 AutoCAD 2015/2016 的付费实例中使用 SCRIPT 文件运行它们。
  • 等待更完整的 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.

Kabeja 和 YCad 等开源库可能能够处理较旧的 AutoCAD 版本,但对它们的期望并不高,因为这些项目自几年前就处于非活动状态。不过值得关注 Apache Tika,因为他们开始为 .dwg 文件编写解析器,但开发速度很慢。

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.

就个人而言,我认为 AutoDesk 现在在 CAD 市场上拥有强大而自私的垄断地位,他们让其他人难以加入。 .dwg 文件的格式版本变化如此频繁,我猜开源开发人员会在某些时候不得不放弃并改用官方产品。

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

让我们希望在未来几年有更多的开源解决方案

回答by Augusto Goncalves

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.

Autodesk 主要使用 C++ 开发 AutoCAD,并提供对 C++、.NET、JavaScript、VBA 和 LISP 的插件支持,这就是为什么没有原生 Java 支持的原因。所有这些都需要在机器上安装 AutoCAD。

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

或者,您可以使用 AutoCAD I/O 网络服务(基本上是在云上运行的实例)来运行自定义代码并提取数据或创建新图形。这将支持所有 DWG 功能。检查http://developer.autodesk.com

回答by Yoku

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.

正如您所指出的,请改用 DXF 格式,还有开源 Java 库,YCAD,您可以使用并且非常易于使用。