Hi Guys
Could you Please help any one on the subjected request. As i Need to Get vertices Between Two user Selected Points in a polyline.
The Return Type I need it in the Form of Point3dCollection.
Thanks
Alex Andrews
Hi,
You can try the following code.
It assumes point1 and point2 are defined in WCS coordinates and the current view is Top.
For a solution working whatever the context, you can read the discussion I had with @ActivistInvestor about getting a point on curve in this post.
private Point3dCollection GetPolylineVerticesBetweenPoints(Polyline pline, Point3d point1, Point3d point2) { double param1 = pline.GetParameterAtPoint(pline.GetClosestPointTo(point1, false)); double param2 = pline.GetParameterAtPoint(pline.GetClosestPointTo(point2, false)); double startParam = Math.Min(param1, param2); double endParam = Math.Max(param1, param2); int startIndex = (int)startParam; if (startIndex != startParam) startIndex++; int endIndex = (int)endParam; if (endIndex == endParam) endIndex++; var vertices = new Point3dCollection(); for (int i = startIndex; i < endIndex; i++) { vertices.Add(pline.GetPoint3dAt(i)); } return vertices; }
Oopss...
There's a mistake in the upper code.
Try this one instead.
private Point3dCollection GetPolylineVerticesBetweenPoints(Polyline pline, Point3d point1, Point3d point2) { double param1 = pline.GetParameterAtPoint(pline.GetClosestPointTo(point1, false)); double param2 = pline.GetParameterAtPoint(pline.GetClosestPointTo(point2, false)); double startParam = Math.Min(param1, param2); double endParam = Math.Max(param1, param2); int startIndex = (int)startParam; if (startIndex != startParam) startIndex++; int endIndex = (int)endParam + 1; var vertices = new Point3dCollection(); for (int i = startIndex; i < endIndex; i++) { vertices.Add(pline.GetPoint3dAt(i)); } return vertices; }
Hi Gilles, Thanks for Helping me.
How ever I have few more issues, When handling with Different Geometries.
As "pline.GetPoint3dAt(i)" method is ssupportable for only Polylines; Incase of Lines, Arc, Spline, Its Can't be found... Could you Please Look into this?
Regards
Alex.
@Anonymous wrote:Hi Gilles, Thanks for Helping me.
How ever I have few more issues, When handling with Different Geometries.
As "pline.GetPoint3dAt(i)" method is ssupportable for only Polylines; Incase of Lines, Arc, Spline, Its Can't be found... Could you Please Look into this?
Regards
Alex.
You didn't ask for that.
Read the subject line of your post. It says Vertices between two Points of a Polyline or Line.
Lines, arcs, splines, and other curves aside from polylines do not have vertices, so your question makes no sense from the outset.
Can't find what you're looking for? Ask the community or share your knowledge.