访问块对象内的实体
Contents
[
Hide
]如何访问块对象内的实体
问题: 如何访问块对象内的实体 (CADNET-552)。
提示: 要做到这一点,您需要访问块对象内的实体,您需要访问图纸中的块,然后您需要使用 CadBlockEntity 类进行访问。
示例:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (CadImage cadImage = (CadImage)Image.Load(GetPath(fileName))) | |
{ | |
for (int i = 0; i < cadImage.Entities.Length; i++) | |
{ | |
if (cadImage.Entities[i].TypeName == CadEntityTypeName.INSERT) | |
{ | |
CadBlockEntity block = cadImage.BlockEntities[(cadImage.Entities[i] as CadInsertObject).Name]; | |
foreach (CadBaseEntity baseEntity in block.Entities) | |
{ | |
System.Console.WriteLine("Type = " + baseEntity.TypeName); | |
} | |
} |