Lấy tất cả các thực thể TEXT/MTEXT từ DWG/DXF

Cách lấy tất cả các thực thể TEXT/MTEXT từ DWG/DXF

Vấn đề: Cách lấy tất cả các thực thể TEXT/MTEXT từ DWG/DXF.

Mẹo: Để làm điều này, bạn cần lấy các thực thể CadText(DefaultValue) và CadMText(FullClearText) từ bản vẽ.

Ví dụ:

using CadImage cadImage = (CadImage)Image.Load(fileName);
foreach (CadBaseEntity entity in cadImage.Entities)
{
if (entity.GetType() == typeof(CadText))
{
CadText text = (CadText)entity;
System.Console.WriteLine(text.DefaultValue);
}
if (entity.GetType() == typeof(CadMText))
{
CadMText mtext = (CadMText)entity;
System.Console.WriteLine(mtext.FullClearText);
}
}