[英]How can I use python to write a dxf file from coordinates?
我正在尝试使用 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')
它包括 de Z 轴并在文件中添加几行。
add_line 参考: https://ezdxf.readthedocs.io/en/master/r12writer.html#ezdxf.r12writer.R12FastStreamWriter.add_line
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.