ixmilia / dxf

MIT License
218 stars 67 forks source link

how to read dxf file content text? #205

Open farshadvl opened 5 months ago

farshadvl commented 5 months ago

Hi every body

I have a DXF file format that have drawing and text in it.

I want to extract text from this file but I have no idea to do that.

can any one help me? [Uploading 4-FUG-16802-AAR61-N_Sht_1.txt…]() Capture

brettfo commented 5 months ago

The top of the README file at the root of this repo has an example snippet of how to read a DXF file and extract some information. In your instance the inside of the foreach loop would look something like this:

switch (entity.EntityType)
{
    // ....
    case EntityType.Text:
        var text = (DxfText)entity;
        // at this point the interesting parts would be things like:
        //   text.Value is the string of the text
        //   text.Location is a point representing the insertion location in the drawing
        break;
    case EntityType.MText:
        var mtext = (DxfMText)entity;
        // at this point the interesting parts would be things like:
        //   mtext.Text is the string of the text
        //   mtext.InsertionPoint is a point representing the insertion location in the drawing
        break;
    // ....
}