This project has moved and is read-only. For the latest updates, please go here.

Question about .net DXF

Jan 17, 2017 at 3:56 PM
Edited Jan 17, 2017 at 4:00 PM
       DxfDocument DXF = new DxfDocument();
// preparing for first polyline
        List<PolylineVertex> pp=new List<PolylineVertex>();
        pp.Add(new PolylineVertex(258891.203, 471390.125, 88));
         //... some more points added here
        pp.Add(new PolylineVertex(258893.546, 471391.25, 88));
        pp.Add(new PolylineVertex(258891.969, 471391.031, 88));
        pp.Add(new PolylineVertex(258891.296, 471390.75, 88));

        Polyline polyline = new Polyline(pp, true);
        polyline.Color = new netDxf.AciColor(2);

        DXF.AddEntity(polyline);  //add the first polyline
// preparing for second polyline
        pp.Clear(); //clear all points
        pp.Add(new PolylineVertex(258891.109, 471390.969, 88));
        // ...some more other points added here
        pp.Add(new PolylineVertex(258895.078, 471391.4, 88));
        pp.Add(new PolylineVertex(258895.25, 471389.875, 88));
        pp.Add(new PolylineVertex(258891.281, 471389.438, 88));

        polyline = new Polyline(pp, true);
        polyline.Color = new netDxf.AciColor(6);

        DXF.AddEntity(polyline );   // add the second polyline
   If I only add only one polyline, the dxf file I got can be open. Everything is fine. However, when I added two polylines, the Dxf file I got could not be open by CAD.
   Who can tell me what is wrong about my code?
   Thank you in advance.

   I use Win10 64bit, MS vs2010.  .net DXF version
Jan 19, 2017 at 6:50 PM
Update your netDxf library to the latest, the one you are using is very old and I cannot support outdated versions. You can try to use two different lists of PolylineVertex, one for each Polyline entity, instead of using only one where you add vertexes and clear the list to add the new ones. That might work but again the first thing you should always try is to use the latest version.