Odczyt tabel z DWG/DXF
Contents
[
Hide
]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:
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); | |
} | |
} |