Page 1 of 1

LWPOLYLINE elevation value not applied

Posted: Wed Jan 29, 2025 1:57 pm
by Manicat
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);
}
}

Re: LWPOLYLINE elevation value not applied

Posted: Wed Jan 29, 2025 5:04 pm
by petevick
The reason that Z values are not taken into account is that Qcad is a purely 2D cad programme.

Re: LWPOLYLINE elevation value not applied

Posted: Wed Jan 29, 2025 7:36 pm
by CVH
@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.
petevick wrote:
Wed Jan 29, 2025 5:04 pm
Qcad is a purely 2D cad programme.
@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

Re: LWPOLYLINE elevation value not applied

Posted: Thu Jan 30, 2025 12:57 pm
by Manicat
petevick wrote:
Wed Jan 29, 2025 5:04 pm
The reason that Z values are not taken into account is that Qcad is a purely 2D cad programme.
I disagree. It is perfectly OK to export e.g. 3D lines

Re: LWPOLYLINE elevation value not applied

Posted: Thu Jan 30, 2025 2:34 pm
by CVH
Manicat wrote:
Thu Jan 30, 2025 12:57 pm
I disagree. It is perfectly OK to export e.g. 3D lines
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
:arrow: From the header: This file is part of the dxflib project.

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

Regards,
CVH