การเข้าถึงเอนทิตีภายในบล็อกออบเจ็กต์
Contents
[
Hide
]วิธีการเข้าถึงเอนทิตีภายในบล็อกออบเจ็กต์
ปัญหา: วิธีการเข้าถึงเอนทิตีภายในบล็อกออบเจ็กต์ (CADNET-552).
เคล็ดลับ: เพื่อทำเช่นนี้ คุณต้องเข้าถึงเอนทิตีภายในบล็อกออบเจ็กต์ คุณต้องเข้าถึงบล็อกในแผนภาพ จากนั้นคุณต้องใช้คลาส CadBlockEntity เพื่อเข้าถึง
ตัวอย่าง:
This file contains hidden or 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); | |
} | |
} |