LWPOLYLINE elevation value not applied
Posted: Wed Jan 29, 2025 1:57 pm
While exporting a polyline to a file, I noticed that z-values are not taken into account. I made the following code modifications and now it works fine:
/**
* Writes a polyline entity to the file.
*
* @param dw DXF writer
* @param data Entity data from the file
* @param attrib Attributes
* @see writeVertex
*/
void DL_Dxf::writePolyline(DL_WriterA& dw,
const DL_PolylineData& data,
const DL_Attributes& attrib) {
if (version==DL_VERSION_2000) {
dw.entity("LWPOLYLINE");
dw.dxfString(100, "AcDbEntity");
dw.entityAttributes(attrib);
dw.dxfString(100, "AcDbPolyline");
dw.dxfInt(90, (int)data.number);
dw.dxfInt(70, data.flags);
dw.dxfReal(38, data.elevation); // Added this line ......
} else {
dw.entity("POLYLINE");
dw.entityAttributes(attrib);
polylineLayer = attrib.getLayer();
dw.dxfInt(66, 1);
dw.dxfInt(70, data.flags);
dw.dxfReal(30, data.elevation); // and this line
dw.coord(DL_VERTEX_COORD_CODE, 0.0, 0.0, 0.0);
}
}
/**
* Writes a polyline entity to the file.
*
* @param dw DXF writer
* @param data Entity data from the file
* @param attrib Attributes
* @see writeVertex
*/
void DL_Dxf::writePolyline(DL_WriterA& dw,
const DL_PolylineData& data,
const DL_Attributes& attrib) {
if (version==DL_VERSION_2000) {
dw.entity("LWPOLYLINE");
dw.dxfString(100, "AcDbEntity");
dw.entityAttributes(attrib);
dw.dxfString(100, "AcDbPolyline");
dw.dxfInt(90, (int)data.number);
dw.dxfInt(70, data.flags);
dw.dxfReal(38, data.elevation); // Added this line ......
} else {
dw.entity("POLYLINE");
dw.entityAttributes(attrib);
polylineLayer = attrib.getLayer();
dw.dxfInt(66, 1);
dw.dxfInt(70, data.flags);
dw.dxfReal(30, data.elevation); // and this line
dw.coord(DL_VERTEX_COORD_CODE, 0.0, 0.0, 0.0);
}
}