我一直在使用 Autocad API 根据(预先确定的)句柄 ID 填写块属性。下面是一个实现示例:
frame1 = acad.ActiveDocument.HandleToObject('18CA1')
frame2 = acad.ActiveDocument.HandleToObject('77CE9')
frames = [frame1, frame2]
for i in range(len(frames)):
for attrib in frames[i].GetAttributes():
if attrib.TagString == 'DATE':
attrib.TextString = datasource.date
if attrib.TagString == 'CLIENT_NAME':
attrib.TextString = datasource.client_name
attrib.Update()
现在我想使用 ezdxf 库实现相同的功能。我只是找不到类似于.HandleToObject("xxx")的方法。根据以下代码,我确定句柄 ID 确实与 AutoCAD 实现中的相同。
modelspace = dxf.modelspace()
for e in modelspace:
if e.dxftype()== 'TEXT':
print("text: %s\n" % e.dxf.text)
print("handle: %s\n" % e.dxf.handle)
这在ezdxf中可行吗?我已经列出了我需要更改的所有特定句柄,理想情况下,我宁愿遍历该列表而不是遍历所有实体以检查它们的句柄。