ROCHEDY
ROCHEDY

Reputation: 85

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

Upvotes: 2

Views: 1916

Answers (2)

ROCHEDY
ROCHEDY

Reputation: 85

Finally I found a solution !

My problem was not to show/hide a layer but how to detect and hide unrelevant objects.

I use DrawingExtendsLowerRight and DrawingExtendsUpperRight properties in header section to know the limits of my drawing. I only keep elements that are in the limits.

Upvotes: 1

Andrew Truckle
Andrew Truckle

Reputation: 19197

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!

Upvotes: 5

Related Questions