WhatDidYouDoWithAILoading
Back to the forum

DXF 导入后弧线断掉的刀路检查器

一个三轴件在 DXF 段数超过 400 时会崩,弧线转换还没稳定。

I’m building a CNC toolpath checker, and the annoying part is not the checker itself but what happens when a DXF comes in with arcs. I wrote a small Python parser, then tried FreeCAD exports as a fallback, but one 3-axis job crashes if the file has more than 400 segments.

The failure mode is ugly: the imported geometry looks fine at first, then one arc gets flattened into a pile of short segments and the path length jumps. I can reproduce it with the same file every time, which is helpful, but only after wasting an afternoon on a bad export setting.

I added a few sanity checks for rapid moves, self-intersections, and obviously impossible radii. Those work on clean files, but DXF from different CAM tools is inconsistent enough that I still end up normalizing entities by hand. The Python parser is now doing more cleanup than checking.

What I didn’t expect was that the segment count threshold matters more than the machine motion itself. I’m still unsure whether to preserve arcs end-to-end or convert everything to lines early and accept some precision loss. That choice changes the whole checker, and I haven’t settled it yet.

10 replies

Owen Li#1 · 2026-08-05

超过 400 segments 就崩,是递归爆了还是内存涨太快?

Maya Chen#2 · 2026-08-05

更像是几何库的重建太慢,不是纯内存问题。

Nina West#3 · 2026-08-05

If you can keep arcs as bulge segments until the last mile, you avoid a lot of flattening drift.

Mark Chen#4 · 2026-08-05

我也遇到过 FreeCAD 导出把圆弧拆碎,最后只好回到原始 DXF 解析。

Alicia Torres#5 · 2026-08-05

把所有东西转线会简单,但 3-axis 检查会更容易误报碰撞。

Maya Chen#6 · 2026-08-05

对,误报已经有了。现在最烦的是同一条路径在不同导出器上结果不一致。

钱墨#7 · 2026-08-05

可以先把弧线段单独走一条管线,最后只在刀路检查前做一次采样。我之前这么搞过,400 段以上的崩溃基本就从解析阶段挪走了。

Ahmad Liu#8 · 2026-08-05

你现在的 DXF 里是只看 ARC,还是 LWPOLYLINE 的 bulge 也会进来?我怀疑有些导出器把圆弧拆成了很多短线。

Jason Liu#9 · 2026-08-05

我碰到过同一个图纸在 LibreCAD 和 AutoCAD 导出后结果差一圈,最后发现单位和圆心精度都不一样。

Maya Chen#10 · 2026-08-05

我现在在加一个中间层,先把 arc/bulge 统一成同一种对象,再决定什么时候离散化。问题是有些老图纸里半径只有 3 位小数,离散完刀路会抖。