写入 dxf 或 dwg 格式?

发布于 2024-12-19 14:21:22 字数 92 浏览 1 评论 0原文

我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

二货你真萌 2024-12-26 14:21:22

很久以前,我用 VB.NET 2003 编写了一个 DXF 编写器,我已将其转换为 C#。它具有直线、圆、圆弧、文本、尺寸、矩形、折线和点的方法。您可以这样使用它:

DxfMaker dxf = new DxfMaker();

float[,] points = new float[,]
{
    { 0, 10 },
    { 1, 12 },
    { 2, 17 },
    { 3, 14 },
    { 4, 9  }
};
int N = points.GetLength(0);
for (int i = 1; i < N; i++)
{
    dxf.DXF_Line(
        points[i - 1, 0], points[i - 1, 1], 0,
        points[i, 0], points[i, 1], 0);
}

dxf.DXF_Save("curve.dxf");

带有源代码的项目在此处共享 github.com/ja72/DxfMaker 。需要注意的是,因为VB本来有些数值类型不一致(floatdouble之间),结果还不错。 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:

DxfMaker dxf = new DxfMaker();

float[,] points = new float[,]
{
    { 0, 10 },
    { 1, 12 },
    { 2, 17 },
    { 3, 14 },
    { 4, 9  }
};
int N = points.GetLength(0);
for (int i = 1; i < N; i++)
{
    dxf.DXF_Line(
        points[i - 1, 0], points[i - 1, 1], 0,
        points[i, 0], points[i, 1], 0);
}

dxf.DXF_Save("curve.dxf");

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 and double) by the results are good. The original code for DXF was taken from elsewhere (see comments) and adapted to my needs.

望她远 2024-12-26 14:21:22

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.

请你别敷衍 2024-12-26 14:21:22

如果您使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文