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);
}
}
LWPOLYLINE elevation value not applied
Moderator: andrew
-
- Registered Member
- Posts: 2
- Joined: Wed Jan 29, 2025 1:50 pm
- petevick
- Premier Member
- Posts: 413
- Joined: Tue May 19, 2020 9:34 am
- Location: North Norfolk coast UK
Re: LWPOLYLINE elevation value not applied
The reason that Z values are not taken into account is that Qcad is a purely 2D cad programme.
Pete Vickerstaff
Linux Mint 21.3 Cinnamon, Qcad Pro 3.31.1
Linux Mint 21.3 Cinnamon, Qcad Pro 3.31.1
-
- Premier Member
- Posts: 4920
- Joined: Wed Sep 27, 2017 4:17 pm
Re: LWPOLYLINE elevation value not applied
@Manicat
Hi, and welcome to the QCAD forum.
I am about sure that this is not a QCAD Community Edition topic ...
... Rather something related to DXFLIB: dxflib 'How Do I' Questions or dxflib Troubleshooting and Problems
Not sure about 'elevation', I think it is still something different then any arbitrary Z coordinate.
Or individual Z values for each polyline node or vertex.
Rather more something as an elevated level where entities live on.
It would be common that mixed Z values and bulging polyline segments don't go hand in hand.
Under QCAD these are flattened before writing them.
The main reason is that Arcs/Circles/Ellipses can only exist as flat.
True, QCAD tools are mostly intended for handling 2D data but it is fully capable of reading and writing data with non-zero Z coordinates.
QCAD/CAM relies heavily on that.
Regards,
CVH
Hi, and welcome to the QCAD forum.
I am about sure that this is not a QCAD Community Edition topic ...
... Rather something related to DXFLIB: dxflib 'How Do I' Questions or dxflib Troubleshooting and Problems
Not sure about 'elevation', I think it is still something different then any arbitrary Z coordinate.
Or individual Z values for each polyline node or vertex.
Rather more something as an elevated level where entities live on.
It would be common that mixed Z values and bulging polyline segments don't go hand in hand.
Under QCAD these are flattened before writing them.
The main reason is that Arcs/Circles/Ellipses can only exist as flat.
@petevick
True, QCAD tools are mostly intended for handling 2D data but it is fully capable of reading and writing data with non-zero Z coordinates.
QCAD/CAM relies heavily on that.
Regards,
CVH
-
- Registered Member
- Posts: 2
- Joined: Wed Jan 29, 2025 1:50 pm
-
- Premier Member
- Posts: 4920
- Joined: Wed Sep 27, 2017 4:17 pm
Re: LWPOLYLINE elevation value not applied
Indeed, but your options are rather limited to lines and segments ...
... As explained, Arc/Circle/Ellipse shapes can only exist as flat shapes in a certain Z level.
A Polyline with 3D segments is perfectly possible until any bulge factor differs from zero.
What petevick really means is that most QCAD drawing tools may fail when handling 3D information.
Simply because they are only intended to draw shapes in 2D.
Then this is NOT at all a QCAD CE topic as I presumed.
As in: Creating 2D drawings using the QCAD GUI in CE mode.
Checked it again and the string "version==DL_VERSION_2000" only occurs in:
...QCAD/src/3rdparty/dxflib/src/dl_dxf.cpp

Most QCAD CE users will probably not know how to alter this C++ resource that is usually only present in compiled form.
Regards,
CVH