我想删除 DXF 文件中的每个 Circle 实体。我正在使用 ezdxf,它似乎是完成此类工作的好工具。
我使用 ezdxf doc 编写代码,但我从 Python 中收到错误:
AttributeError: 'str' objet has no attribute 'destroy'
我不明白为什么。我使用了这个文档:http://pythonhosted.org/ezdxf/layouts.html#delete-entities
这是我的代码:
import dxfgrabber
import ezdxf
dwg = dxfgrabber.readfile("test.dxf")
print(dwg)
c = []
center_points = [entity.center for entity in dwg.entities if entity.dxftype == 'CIRCLE']
dxf = ezdxf.readfile("test.dxf")
modelspace = dxf.modelspace()
for point in center_points:
modelspace.add_point(point)
c.append(point)
modelspace.delete_entity('CIRCLE')
dxf.save()
print(c)
谢谢。
最佳答案
我成功了。我发布我的代码:
entities = dxf.entities
for e in entities:
if e.dxftype() == 'CIRCLE':
modelspace.delete_entity(e)
而不是:
modelspace.delete_entity('CIRCLE')
我认为它可能有更好的方法来做到这一点,但它确实有效。
关于python - 使用 ezdxf 删除 DXF 中的圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45139989/