Author Topic: DotSpatial-ACadSharp  (Read 136 times)

0 Members and 1 Guest are viewing this topic.

sigster

  • Newt
  • Posts: 31
DotSpatial-ACadSharp
« on: February 06, 2024, 05:32:22 AM »

Hi


Can someone help with this Please


I am try to read Polyline from Shapefile and write to DWG using DotSpatial and ACadSharp

I can read and write the DWG but I get to many Polyline  109 Polyline Instead of 1 Polyline


Code: [Select]

    Dim vertices As List(Of LwPolyline.Vertex)

     doc.Header.Version = ACadVersion.AC1018


     doc.VPorts(VPort.DefaultName).ShowGrid = False

     For Each vp As VPort In doc.VPorts
         vp.ShowGrid = False
     Next

     Dim shapeActual = FeatureSet.Open(Path)
     Dim FeatureQty As Int16 = shapeActual.Features.Count


     ' Dim plineLst As List(Of Polyline) = New List(Of Polyline)()

     For Each feature As IFeature In shapeActual.Features
         For i As Integer = 0 To feature.Geometry.NumGeometries - 1

             For Each coord As Coordinate In feature.Geometry.GetGeometryN(i).Coordinates

                 Dim typ As DotSpatial.Data.FeatureType = feature.FeatureType
                 If typ = FeatureType.Line OrElse typ = FeatureType.Polygon Then


                     Dim LwPline = New LwPolyline()

                     For Each crd As Coordinate In feature.Geometry.Coordinates

                         vertices = New List(Of LwPolyline.Vertex)() From {
                                    New LwPolyline.Vertex(New XY(crd.X, crd.Y))
                                }
                         For i44 As Integer = 0 To vertices.Count - 1
                             LwPline.Vertices.Add(vertices(i44))
                             LwPline.Layer = doc.Layers(Layer)
                         Next
                     Next
                     doc.Entities.Add(LwPline)

                 ElseIf typ = FeatureType.Point Then

                 ElseIf typ = FeatureType.MultiPoint Then

                 ElseIf typ = FeatureType.Unspecified Then

                 End If

             Next
         Next
     Next

Regards
Sigster