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

pick polyline and get nearest vertex coordinate

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
wang890
3424 Views, 5 Replies

pick polyline and get nearest vertex coordinate

i am making a command in vb.net which user pick a polyline and the program get it's layer name and place a text that lines up with the polyline.

 

i can pick the polyline and get layer and put text no problem. but how do i go from  GetSelection() to getting a proximity coordinate and get the vertex and previous (or next) vertex and get an angle and apply to the text?

see attached picture for what i am trying to do.

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
5 REPLIES 5
Message 2 of 6
caddzone
in reply to: wang890

Set the PromptSelectionOptions.PrepareOptionalDetails argument to true, and

then if the user picks the polyline, the object in the selection set will be a

PickPointSelectedObject, and you can examine it to find out where it was

picked. You can use Curve.GetParameterAtPoint() to get the index of the

vertex/segment that was picked based on the pick point.

 

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 3 of 6
wang890
in reply to: wang890

hi Tony

 

i found out how to get the point user selected, but can you tell me how the curve.GetParameterAtPoint works?

 

thanks.

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
Message 4 of 6
wang890
in reply to: wang890

i got the point like this:

 

Dim poly As Polyline = TryCast(tr.GetObject(prResult.Value(0).ObjectId, OpenMode.ForRead), Polyline)

Dim ppso As PickPointSelectedObject = DirectCast(prResult.Value(0), PickPointSelectedObject)

Dim p3d As Point3d = poly.GetClosestPointTo(ppso.PickPoint.PointOnLine, False)

 

but it's not the point i want. i want the closest vertex. so i can get it's index and get the next one and calculated an angle.

 

right now it's giving the picked point on the polyline. it's what some people want not for me this time.

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
Message 5 of 6
caddzone
in reply to: wang890

The GraphicsSystemMarker property of the PickPointSelectedObject

gives you the index of the selected polyline segment.

 

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 6 of 6
wang890
in reply to: wang890

ha, you are genius. there is no way i can figure this out on my own.

 

thank you so much!

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19

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