การอ่านตารางจาก DWG/DXF
Contents
[
Hide
]วิธีการอ่านตารางจาก DWG/DXF
ปัญหา: วิธีการอ่านตารางจาก DWG/DXF.
เคล็ดลับ: เพื่อทำเช่นนี้ คุณสามารถรับไฟล์โดยใช้วิธีการโหลด รับเอนติตี้ที่จำเป็น.
หมายเหตุ: โค้ดนี้แสดงตัวอย่างของการดึงตารางและดึงค่าออกจากตารางเหล่านั้น โดยวิธีนี้คุณสามารถรับค่าที่เขียนในตารางของไฟล์ได้.
ตัวอย่าง:
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 var cadImage = (CadImage)Image.Load(GetFileFromDesktop(fileName1)); | |
List<CadBlockEntity> tableBlocks = new List<CadBlockEntity>(); | |
var entitys = cadImage.BlockEntities.ValuesTyped; | |
foreach (CadBlockEntity entity in entitys) | |
{ | |
if (entity.Name.StartsWith("*T")) | |
{ | |
tableBlocks.Add(entity); | |
} | |
} | |
var textElements = tableBlocks.FirstOrDefault().Entities; | |
foreach (var entity in textElements) | |
{ | |
if (entity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
System.Console.WriteLine("Table Text " + (entity as CadText).DefaultValue); | |
} | |
if (entity.TypeName == CadEntityTypeName.MTEXT) | |
{ | |
System.Console.WriteLine("Table Mtext " + (entity as CadMText).FullClearText); | |
} | |
} |