.netlayerdxfdxflib

Dxf : how to know which layers to show?


I have to parse dxf files to transform it to images in .net.

I used DxfLib (https://github.com/mkernel/DXFLib).

I have a probleme with layers : I have 3 layers and only one need to be shown (I uploaded my file in some dxf viewer and they only show one layer)

I don't know how to know if a layer need to be shown or not. I didn't find the information in my dxf parsed file.

Do you know where i can find this ? (maybe it's a missing element from DxfLib)

EDIT : there is a exemple of my dxf file : https://github.com/mkernel/DXFLib/files/286112/DIAMOND-R.zip


Solution

  • The DXF file contains a LAYERS table in the HEADER section. Here is the details about the layer table record:

    http://www.autodesk.com/techpubs/autocad/acad2000/dxf/layer_dxf_04.htm

    You are interested in group code 62:

    Group code 62

    As you can see, if the layer colour is negative the layer is switched off. Here is an example:

      0
    LAYER
      5
    242
    330
    2
    100
    AcDbSymbolTableRecord
    100
    AcDbLayerTableRecord
      2
    LAYER2
     70
         0
     62
        -3
      6
    Continuous
    370
        -3
    390
    F
    347
    EE
    348
    0
      0
    ENDTAB
    

    So, when you process an entity and examine the layer value, lookup it up in the LAYERS table in the HEADER section. This is the start of that section:

      0
    TABLE
      2
    LAYER
    

    Once located, examine the colour property and if negative, the layer is switched off.

    I do not know what features DXFLib has available for parsing the HEADERS section of the DXF file. But I hope this detail helps you!