Reading DXF: how to assign a line to a layer ?
Moderator: andrew
-
- Registered Member
- Posts: 2
- Joined: Sun Jun 23, 2013 7:51 pm
Reading DXF: how to assign a line to a layer ?
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?
- andrew
- Site Admin
- Posts: 8774
- Joined: Fri Mar 30, 2007 6:07 am
Re: Reading DXF: how to assign a line to a layer ?
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
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:
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:
MyImporter::addLine(const DL_LineData& data) { std::out << "line is on layer " << getAttributes().getLayer(); }
-
- Registered Member
- Posts: 2
- Joined: Sun Jun 23, 2013 7:51 pm
Re: Reading DXF: how to assign a line to a layer ?
I missed whole attributes thing. But now my sample works exactly as I need to
Thank you very much!
