Reading of tables from DWG/DXF
Contents
[
Hide
]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:
This file contains 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); | |
} | |
} |