Author Topic: ZWCAD SHP file  (Read 2645 times)

0 Members and 1 Guest are viewing this topic.

sigster

  • Newt
  • Posts: 31
ZWCAD SHP file
« on: October 16, 2016, 08:16:33 AM »

Hi

I was testing ZWCAD and it is no SHP Inport

Have anyone try to use one of this to import SHP file to CAD

http://www.easygisdotnet.com/
https://dotspatial.codeplex.com

sigster

  • Newt
  • Posts: 31
Re: ZWCAD SHP file
« Reply #1 on: October 21, 2016, 10:00:41 PM »

I got a little help, this is what I have but it draw one long line

how can I end each Polyline


Code: [Select]
  <CommandMethod("XY")> _
        Public Sub readxy()

            Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()

                Dim acBlkTbl As BlockTable
                acBlkTbl = CType(acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead), BlockTable)

                Dim acBlkTblRec As BlockTableRecord
                acBlkTblRec = CType(acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)

                Dim shapeActual As FeatureSet = FeatureSet.Open("PATH\FILE.shp")

                shapeActual.FillAttributes()
                Dim dt As System.Data.DataTable = shapeActual.DataTable

                Dim pline As Polyline = New Polyline()
                pline.SetDatabaseDefaults()

                For count As Integer = 0 To shapeActual.Features.Count - 1
                    For Each feature As IFeature In shapeActual.Features 'circle through the features
                        For i As Integer = 0 To feature.BasicGeometry.NumGeometries - 1 'circle through the parts of one feature
                            For Each coord As Coordinate In feature.BasicGeometry.GetBasicGeometryN(i).Coordinates() 'circle through the coordinates of the feature part
                                Dim AdresX = coord.X
                                Dim AdresY = coord.Y

                                pline.AddVertexAt(count, New Point2d(coord.X, (coord.Y + 1)), 0.0, 0.0, 0.0)
                                count = count + 1

                                ed.WriteMessage(vbCr & count)
                                ed.WriteMessage(vbCr & feature.FeatureType.ToString)
                            Next
                        Next
                    Next

                Next
                acBlkTblRec.AppendEntity(pline)
                acTrans.AddNewlyCreatedDBObject(pline, True)
                acTrans.Commit()
            End Using

        End Sub

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: ZWCAD SHP file
« Reply #2 on: October 21, 2016, 10:16:26 PM »
do you mean 'close' each pline? If so use pline.Close() to make a closed polyline (no gaps)
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

sigster

  • Newt
  • Posts: 31
Re: ZWCAD SHP file
« Reply #3 on: October 22, 2016, 04:10:47 AM »

Do you mean  pline.Closed = True   already try it

the Image I upload show House line I insert

1. how it insert one line
2. manual delete extra line

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: ZWCAD SHP file
« Reply #4 on: October 22, 2016, 06:15:40 PM »
Ahh, ok. It looks lie you need to find the start/end pairs of the geometry data.
can you attach your shp sample file so I can have a look?
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

sigster

  • Newt
  • Posts: 31
Re: ZWCAD SHP file
« Reply #5 on: October 23, 2016, 09:40:25 AM »

This is SHP sample

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: ZWCAD SHP file
« Reply #6 on: October 23, 2016, 06:50:13 PM »
Hi sigster,
I was hoping to be able to read the shp file but it's binary, I also looked at the MAP help doc's which were almost useless (to me anyway without knowing the product) but after looking at the picture a bit I would try to just add line segments, not a polyline and see what you get.
That is, instead of appending a vertex every point, create a line after every second point. In other words, split the vertex list into tuples of 2 points and create a line for each tuple, hope that makes sense?

It probably won't be what you want but it may lead to some clues.
Can you point to some online help for the "FeatureSet" library/api you are using?
« Last Edit: October 23, 2016, 06:54:52 PM by MickD »
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

sigster

  • Newt
  • Posts: 31
Re: ZWCAD SHP file
« Reply #7 on: October 23, 2016, 07:32:18 PM »