Reading of tables from DWG/DXF

How to read tables from DWG/DXF

Issue: How to read tables from DWG/DXF.

Tips: To do this, you can get the file using the load method, get the necessary entities.

Note: This code snippet shows an example of retrieving tables and retrieving values from them. This way you can get the values written in the tables of the file.

Example:

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