I have a DXF file with lines assigned to several layers. I would like to determine a layer for each line object in a DXF file. As there is no layer info in DL_LineData struct, I hoped to get the line->layer affiliation info using order of addLine() and addLayer() calls. I wrote simple test app and discovered that all addLayer() calls during execution of DL_Dxf::in() happen before first addLine call(). How to check to which layer a line belongs to?

Layers are reported through the DL_CreationInterface using the function DL_CreationInterface::addLayer(...). All layers that are reported through that interface are typically stored in a list or map of layers.

The current layer is part of the current entity attributes. You can get the current attributes by calling

DL_Attributes getAttributes()

of your implementation of the DL_CreationInterface.

When an entity is reported, for example a line entity though DL_CreationInterface::addLine(...), you can get information about the layer it is on (as well as other attributes) through the attributes member variable: