写入 dxf 或 dwg 格式?
我有 C# 中曲线的 X 和 Y 值,我希望使用相同的 C# 项目以 dxf 或 dwg 文件格式绘制它们。
有办法做到这一点吗?
谢谢。
I have the X and Y values for a curve in C# and I want them to be drawn in a dxf or dwg file format using the same C# project.
Is there a way to do that?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
很久以前,我用 VB.NET 2003 编写了一个 DXF 编写器,我已将其转换为 C#。它具有直线、圆、圆弧、文本、尺寸、矩形、折线和点的方法。您可以这样使用它:
带有源代码的项目在此处共享 github.com/ja72/DxfMaker 。需要注意的是,因为VB本来有些数值类型不一致(
float
和double
之间),结果还不错。 DXF 的原始代码取自其他地方(请参阅注释)并根据我的需要进行了调整。A long time ago I wrote a DXF writer with VB.NET 2003, that I have converted to C#. It has methods for line, circle, arc, text, dimension, rectangle, polyline and points. You use it like this:
The project with the source code is shared here github.com/ja72/DxfMaker. Caveat is because it was VB originally some of the numerical types are inconsistent (between
float
anddouble
) by the results are good. The original code for DXF was taken from elsewhere (see comments) and adapted to my needs.CadLib 可以编写 DXF 和 DWG 文件,绝对比自己查看 DXF 规范更容易。还有一些用于编写 DXF 的免费库。如果您的要求很基本,那么这些可能就足够了。
CadLib can write DXF and DWG files, definitely easier than going through the DXF specification yourself. There are a few free libraries out there for writing DXF as well. If you're requirements are basic, then these might be good enough.
如果您使用 C# 生成数据,在 AutoCAD 中获取结果的最简单方法是编写 dxf 文件。 dxf 文件是一个文本文件。 Autodesk(AutoCAD 制造商)在此处发布了 dxf 规范。您需要一些基本的 AutoCAD 知识(块/图层/组等)才能理解规范。
If you are generating data in C# the easiest way to the results in AutoCAD is to write a dxf file. The dxf file is a text file. Autodesk (maker of AutoCAD) publishes the dxf specification here. You will need some basic AutoCAD knowledge (blocks/layers/groups etc.) to understand the spec.