我想用 dxfgrabber 库解析 dxf 文件以获取对象(线、点、文本等)。
代码如下
#!/usr/bin/env python
import dxfgrabber
dxf = dxfgrabber.readfile("1.dxf")
print ("DXF version : {}".format(dxf.dxfversion))
但它会出现一些错误......
Traceback (most recent call last):
File "parsing.py", line 6, in <module>
dxf = dxfgrabber.readfile("1.dxf")
File "/usr/local/lib/python2.7/dist-packages/dxfgrabber/__init__.py", line 43, in readfile
with io.open(filename, encoding=get_encoding()) as fp:
File "/usr/local/lib/python2.7/dist-packages/dxfgrabber/__init__.py", line 39, in get_encoding
info = dxfinfo(fp)
File "/usr/local/lib/python2.7/dist-packages/dxfgrabber/tags.py", line 96, in dxfinfo
tag = next(tagreader)
File "/usr/local/lib/python2.7/dist-packages/dxfgrabber/tags.py", line 52, in __next__
return next_tag()
File "/usr/local/lib/python2.7/dist-packages/dxfgrabber/tags.py", line 45, in next_tag
raise StopIteration()
StopIteration
简单的 1.dxf 文件只包含行。
文件链接是https://docs.google.com/file/d/0BySHG7k180kETlQ2UnRxQmxoUk0/edit?usp=sharing
这是 dxfgrabber 库的错误吗?有没有什么好的库可以在 python 中解析 dxf 文件?
我正在使用 dxfgrabber 0.4 和 python 2.7.3。