python - 如何使用 python 从坐标写入 dxf 文件?

标签 python ezdxf

我正在尝试使用 ezdxf 从坐标列表写入 dxf 文件。

我可以使用以下代码创建一个带有简单线条的 dxf 文件:

import ezdxf
doc = ezdxf.new('R2010') # create a new DXF drawing in R2010 fromat 

msp = doc.modelspace() # add new entities to the modelspace
msp.add_line((0, 0), (10, 0)) # add a LINE entity
doc.saveas('test_line.dxf') 

对于我正在使用的文件,还有一个“Z”坐标,根据我在文档中看到的内容,我不知道如何传递该坐标。我还想在不仅仅是一行中传递数百个坐标。

最佳答案

试试这个:

import ezdxf
doc = ezdxf.new('R2010') # create a new DXF drawing in R2010 fromat 

msp = doc.modelspace() # add new entities to the modelspace
lines = [(0, 0, 0), (10, 0, 0)], [(0, 0, 0), (20, 0, 0)],
for line in lines:
    start = line[0]
    end = line[1]
    msp.add_line(start, end) # add a LINE entity
doc.saveas('test_line.dxf') 

它包括 Z 轴并向文件添加几行。

关于python - 如何使用 python 从坐标写入 dxf 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58754325/

相关文章:

python - Hadoop 中 Map 函数的输入拆分

python - 我可以从 mayabatch 中 pm.playblast 吗?

python-3.x - 如何使用ezdxf返回 'MTEXT'内的字符串?

python - 使用 ezdxf 接口(interface)从 Python 导出 Mesh 后无法在 Freecad 中显示 Mesh

用于合并 DXF 文件的 Python 模块

python - 当我尝试从 Python 调用 Jira 项目时,出现 JSON 错误

python - pip 不会安装我的包的依赖项

python - 有没有一种更优雅/优化的方式来实现这种连接算法?