Odczyt tabel z DWG/DXF

Jak odczytać tabele z DWG/DXF

Problem: Jak odczytać tabele z DWG/DXF.

Wskazówki: Aby to zrobić, możesz pobrać plik za pomocą metody load, uzyskać niezbędne encje.

Uwaga: Ten fragment kodu pokazuje przykład pobierania tabel i odczytywania wartości z nich. W ten sposób możesz uzyskać wartości zapisane w tabelach pliku.

Przykład:

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);
}
}