LWPOLYLINE elevation value not read

If you are having problems with dxflib, post here. Please report bugs here.

Moderator: andrew

LWPOLYLINE elevation value not read

Postby Aranda » Mon Mar 16, 2009 4:33 am

Hi, I also submitted a bug for this but I thought I should post here so other uses may benefit.

I was able to fix this bug by changing the DL_Dxf::addPolyline() method. The DXF specification on LWPOLYLINE (http://www.autodesk.com/techpubs/autocad/acadr14/dxf/lwpolyline_al_u05_c.htm) states that group code 38 is for elevation. DXF Lib was assuming it was the same group code as POLYLINE entity (30). Here is the modified source:

Code: Select all
/**
 * Adds a polyline entity that was read from the file via the creation interface.
 */
void DL_Dxf::addPolyline(DL_CreationInterface* creationInterface) {
    if (currentEntity==DL_ENTITY_POLYLINE) {
      DL_PolylineData pd(maxVertices, toInt(values[71], 0), toInt(values[72], 0), toInt(values[70], 0), toReal(values[30]));
      creationInterface->addPolyline(pd);
   } else if (currentEntity==DL_ENTITY_LWPOLYLINE) {
      DL_PolylineData pd(maxVertices, toInt(values[71], 0), toInt(values[72], 0), toInt(values[70], 0), toReal(values[38]));
      creationInterface->addPolyline(pd);

      for (int i=0; i<maxVertices; i++) {
            DL_VertexData d(vertices[i*4],
                            vertices[i*4+1],
                            vertices[i*4+2],
                            vertices[i*4+3]);

            creationInterface->addVertex(d);
        }
      creationInterface->endEntity();
    }
}
Aranda
Newbie Member
 
Posts: 4
Joined: Wed Sep 17, 2008 4:44 am
Location: Perth Australia

Re: LWPOLYLINE elevation value not read

Postby p.r.thompson » Wed Apr 24, 2013 3:17 am

I also found this bug.

I noticed your patch requires modifying DL_PolylineData to include the z along with the other values and flag.
However, DXFLib already has the elevation in the extrusion field.

Therefore I think this patch is more correct and is self-contained.


Code: Select all
diff --git a/src/dl_dxf.cpp b/src/dl_dxf.cppindex cfbab15..2afc725 100644 (file)

--- a/src/dl_dxf.cpp
+++ b/src/dl_dxf.cpp
@@ -462,10 +462,21 @@ bool DL_Dxf::processDXFGroup(DL_CreationInterface* creationInterface,
                                linetype);          // linetype
         creationInterface->setAttributes(attrib);
 
+        int elevationGroupCode=30;
+        if( currentEntity==DL_ENTITY_LWPOLYLINE )
+        {
+            // see lwpolyline group codes reference
+            elevationGroupCode=38;
+        }
+        else
+        {
+            // see polyline group codes reference
+            elevationGroupCode=30;
+        }
         creationInterface->setExtrusion(toReal(values[210], 0.0),
                                         toReal(values[220], 0.0),
                                         toReal(values[230], 1.0),
-                                        toReal(values[30], 0.0));
+                                        toReal(values[elevationGroupCode], 0.0));
p.r.thompson
Registered Member
 
Posts: 1
Joined: Tue Apr 23, 2013 7:36 am

Re: LWPOLYLINE elevation value not read

Postby andrew » Wed Apr 24, 2013 12:22 pm

p.r.thompson: Many thanks for the patch. I will incorporate this in the next dxflib release if you don't mind.
User avatar
andrew
Site Admin
 
Posts: 2370
Joined: Fri Mar 30, 2007 6:07 am


Return to dxflib Troubleshooting and Problems

Who is online

Users browsing this forum: No registered users and 2 guests