无法使用dxfgrabb检索层详细信息

2024-10-04 05:23:09 发布

您现在位置:Python中文网/ 问答频道 /正文

在Python脚本中,我使用dxfgrabber读取dxf文件,并能够获得层的名称和其他信息。我的一个图层中有文本信息,我无法通过代码获取文本信息。到目前为止,我已经试过了-

import dxfgrabber
dxf = dxfgrabber.readfile("/home/user/skype_files/289253.dxf")
myTextLayer = dxf.layers.__getitem__('Text-Info-Layer')
print myTextLayer.name, myTextLayer.linetype

文本信息层是包含文本信息的层,但我不知道如何获取这些信息。有什么帮助吗?在

谢谢!在


Tags: 文件代码文本import脚本名称图层信息
1条回答
网友
1楼 · 发布于 2024-10-04 05:23:09

在dxf图层仅包含图层定义。使用过滤器收集特定图层的所有dxf图元dxf.实体,其中包含模型空间的所有实体:

entities = [e for e in dxf.entities if e.layer=='Text-Info-Layer']
# collect all TEXT entities from layer 'Text-Info-Layer'
text_entities = [e for e in entities if e.dxftype=='TEXT']
# the attribute 'text' of the text entity contains the text 

相关问题 更多 >