TheSwamp
Code Red => .NET => Topic started by: sigster 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
-
I got a little help, this is what I have but it draw one long line
how can I end each Polyline
<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
-
do you mean 'close' each pline? If so use pline.Close() to make a closed polyline (no gaps)
-
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
-
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?
-
This is SHP sample
-
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?
-
I use this
https://dotspatial.codeplex.com/