I would like to know if there is any way to detect if selected point of the selected polyline is its vertex?
1. The user is drawing rectangle or any other figure with polyline.
2. Entering command "GetMe".
3. Selecting polyline.
4. Selecting point.
Is there any built-in function in Autodesk's API?
hi, i think there is not.
therefore i think you have to either collect the points from user to start off with or explode the poly and collect start and endpts, and then compare each to the pickedpoint from the entity selection result.
You don't need to explode the polyline, just iterate the parameters, get the point at each parameter value and add it to a Point3dCollection and then check if the picked point is in the collection. By other side i believe it's *very* dificult for a user to pick exactly in a vertex without osnap, and so I think you need a tolerance to check the the distance from the picked point to the vertex for each one.
something like this:
Dim pcol As New Point3dCollection
Dim fp, lp As Double
fp = pline.StartParam
lp = pline.EndParam
For i = fp To lp
If pcol.Contains(PickedPoint) then
For each p as Point3D in pcol
If p.DistanceTo(Pickedpoint) <= Tolerance then
exploding simply allows you to separate the polyline into its individual sections, lines or arcs, bulge or not etc, which gives you the sought of vertices.
with no tolerance there's an infinite amount of parameter values in a curve; with tolerance you still don't know whether or not any parameter value happens to be one of the polyline's vertices. i agree, with regards to point3d-accuracy and tolerance, it matters whether or not grip selection is enabled for selection, however, i don't think this applies to the prompt entity selection.
apart from start and endpoint, the polyline's vertices, e.g. number and location, once it is a dbobject are not known. the polyline has a .getlineat(integer) method which looks appropriate enough to get to the vertices, however, the integer iteration maximum is, i believe, not known. and also, it only works if the section is in fact a line section as opposed to an arc section. exploding simply allows bypassing the information surrounding the vertices, and the original polyline is retained (unless it is explicitly erased separately).
I deeply disagree, you can obtain the NumberOfVertices property of the Polyline object and then get the point at each vertex with GetPoint3dAt using the vertex index, in the same way as with GetPointAtParameter (the vertex are positioned at increments of 1 from the start parameter to the end parameter, no matter if there are arcs in between). The curve class and its derivates has a lot of methods to obtain data from its geometry, properties and structure without the need to explode the objects. Jus check it, no more than 10 lines of code (other than doc,db,transaction, etc).
well, you are right, i've overlooked the polyline.numberofvertices property, and yes, i agree that traversing the polyline to collect the points is probably more elegant than exploding it, provided that that fits in with the overall task.
going back to the original question however, the polyline hasn't got a method of comparing a pickedpoint to its vertices, i.e. the points still need to be collected and traversed for comparison whichever way its done. so, holding onto the user's initial input points may still be advantagous (together with a tolerance for the pickedpoint property).
Start with some of our most frequented solutions to get help installing your software.