C# 中的开源 cad 绘图 (dwg) 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/169390/
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-08-03 16:31:18  来源:igfitidea点击:

Open source cad drawing (dwg) library in C#

c#open-sourceautocadcaddwg

提问by Mac

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

任何人都知道 C# 中的开源 DWG(autocad 绘图)库?

采纳答案by CAD bloke

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).

DWG 格式的主要障碍是二进制格式每 3 年更改一次 - 它将于 2009 年 3 月再次更改。它是加密的,其规范不公开。这是一个非常复杂的图书馆,里面有许多黑暗的小巷,甚至 AutoDesk 都不知道(他们多年前收购了它)。

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.

是一个由软件公司、开发人员和用户组成的非盈利会员制联盟,致力于在现在和将来促进 CAD 数据的开放交换。除了为 CAD 数据格式设定标准之外,ODA 还专注于开发质量卓越的软件库的实际问题,使 ODA 成员能够开发能够读写流行的 DWG 和 DGN CAD 文件格式的应用程序。

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 RealDWGat $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

成本取决于您使用这些库的目的,但开发人员的基本成本为 100 美元/年,加入费为 250 美元。与AutoDesk 的 RealDWG2500 美元/年和第一年 5000 美元相比,这很划算。顺便说一下,R​​ealDWG 许可证是针对每个产品的。ODA 许可证更合理一些,并且还允许您在同一个许可证上制作 1 个以上的产品。你可以为源代码付费,但它的成本是一颗炸弹——虽然比自己开发要少

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.

如果您只有 1 个产品,那么 RealDWG 可能适合您,但它仅适用于 Windows - 奖金,它有一个 .NET API ,ODA 仍在开发该 API……ODA 的 .NET API(有 2 个)已经完善。ODA 产品针对多种操作系统进行编译,包括 Windows(32 位)、SGI、Solaris、Windows(64 位)、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.

一些 3rd 方库存在有限的特定 API 功能,如果您的需求非常具体,可以尝试搜索这些库。

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.

还值得注意的是,多年来,AutoDesk 或多或少一直在与 ODA 打官司。如果您决定与他们竞争,那么这是您必须期待的另一种复杂性。

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.

我也在开发一种与 DWG 文件对话的产品。我要走商业路线,因为所涉及的时间、费用和麻烦对我来说是完全不经济的。

UPDATE:

更新:

I did. tvCAD.tv is built on RealDwg

我做到了。tvCAD.tv 基于 RealDwg

Update July 2018

2018 年 7 月更新

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.

尽管我在 tvCAD 中使用了 RealDwg,但如果我今天开始该项目,我可能会使用 ODA 库。构建 RealDwg 安装程序是一场噩梦。此外,RealDwg 安装大小约为 ODA 安装大小的 10 倍。嗯,认真的。

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.

Autodesk 在 AutoCAD 市场的主导地位正在减弱,它不再是“IBM”的选择。我可能会在将来的某个时候将 tvCAD 转换为 ODA 库 - 推动我这样做不会花费更多的痛苦。许可成本是可比的。

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 wikiwhich 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.

从历史上看,我发现 ODA 的支持比 Autodesk 环境中的支持要好,除了AutoCAD 标签维基中提到的论坛上的活跃和出色的同行支持,这对所有平台都非常普遍。RealDwg 中的 .NET 代码几乎可以逐字地与 ODA 库一起使用。同样适用于 AutoCAD / BricsCAD 等的 .NET 插件。

回答by Eric Wilhelm

There was at one time an effort to port Art Haas's .dwg parser (from the pythoncad project) to c#. I can't seem to find the link ATM, but it was a few years ago. Creating an open source cross-platform .dwg library is at the top of my list for VectorSection, so let me know what you find out!

曾经有人努力将 Art Haas 的 .dwg 解析器(来自 pythoncad 项目)移植到 c#。我似乎找不到 ATM 的链接,但那是几年前的事了。创建一个开源跨平台 .dwg 库是我的VectorSection列表的顶部,所以让我知道你发现了什么!

回答by keith

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

最简单的方法是将 dwg 转换为 dxf ascii,查询 ascii dxf 相当简单。

回答by Wout

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.

没有开源解决方案,有一些商业解决方案,其中包括Wout Ware提供的一个名为CadLib的.NET组件:http://www.woutware.com/cadlib.html 。

回答by Jonathan Pritchard

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.

如果你走 dxf 路线,我会建议netDXF。它是开源的,虽然它缺少多行文本支持,但对我有限的需求来说效果很好,而且作者说还有一些他不会支持的其他东西,因为它们是 Autodesk 专有的。

回答by John

The only open source one I know of is LibreDwg and I don't think it is completed. It never really got very far.

我所知道的唯一一个开源软件是 LibreDwg,我认为它还没有完成。它从来没有真正走得很远。

I do know of one that is practically free, its called the Ivan CAD Library 2012 and its located at www.ivancad.com.

我知道有一个实际上是免费的,它叫做 Ivan CAD Library 2012,位于 www.ivancad.com。

It might serve your needs very well.

它可能会很好地满足您的需求。