خواندن جداول از 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); | |
} | |
} |