Question

I have problem that should be easy to resolve, but it's giving me a headache not being able to figure it out.

I have a bunch of polylines, and I want to merge these polylines together into a single polyline object. These polylines are not necessarily connected and I do not want them to connect in the process of merging. The end result will be a single polyline object consisting of seperate segments or 'paths'.

I have tried creating segments from each polyline and adding these segments to a segment collection, which I then cast to a polyline object, however this appears to magically join the segments together in the process.

I know this is possible, I've seen multipath polyline objects before. Please help!

Was it helpful?

Solution

Typical. Almost as soon as I posted this, I managed to resolve it.

I had to create path objects from each polyline and add these to a new geometry collection representing a polyline object. See below:

                Dim newPath As ISegmentCollection = New Path
                Dim missing As Object = Type.Missing
                Dim pNewPolyGeom As IGeometryCollection = New Polyline

                pSegment.FromPoint = pTempPolyline.FromPoint
                pSegment.ToPoint = pTempPolyline.ToPoint
                newPath.AddSegment(pSegment, missing, missing)
                pNewPolyGeom.AddGeometry(newPath, missing, missing)

Now my polyline (pNewPolyGeom) is a single polyline object composed of seperate non-connecting line segments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top