.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Detect if selected point of polyline is its a vertex - how?

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
GrzesiekGP
713 Views, 6 Replies

Detect if selected point of polyline is its a vertex - how?

Hello!

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?

 

Thanks.

6 REPLIES 6
Message 2 of 7
adadnet
in reply to: GrzesiekGP

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.

 

felix

Message 3 of 7
hgasty1001
in reply to: adadnet

Hi,

 

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
 pcol.Add(pline.GetPointAtParameter(i))
Next

 

'Aproach 1

If pcol.Contains(PickedPoint) then

 ...

Else

 ...

End If

 

'Aproach 2

 

For each p as Point3D in pcol

 If p.DistanceTo(Pickedpoint) <= Tolerance then

  ...

  Exit For

 Else

  ....

 End If

Next

 

 

Gaston Nunez

 

Message 4 of 7
adadnet
in reply to: hgasty1001

hi gaston

 

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).

 

felix

Message 5 of 7
hgasty1001
in reply to: adadnet

Hi Felix,

 

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).

 

Gaston Nunez

 

 

Message 6 of 7
adadnet
in reply to: hgasty1001

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).

Message 7 of 7

For polyline is true that rule: if  GetParameterAtPoint method return value equal integer - then that integer is a index of polyline vertex (zero based).

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost