Jump to content

Recommended Posts

Posted

Hello, I have a polyline with many vertices, I can find the closest point [red X] of this polyline with other point [blue X] with vlax-curve-getClosestPointTo as the image bellow, but how I find the two vertices [red circles] that represent the line segment of the red X?

ex.png

Posted (edited)

Use

 (setq p_param (vlax-curve-getparamatpoint ent (red cross coords)))

this will return the polyline parameter at that point (each vertex is a whole number parameter)

 

Then

(setq pre_param (fix p_param)   ;the parameter of the vertex before
	  post-param (1+ pre_param) ;the vertex after
	  pre_vtx (vlax-curve-getpointatparam ent pre_param)   ;gets the coords of the vertex before
	  post_vtx (vlax-curve-getpointatparam ent post_param) ;the coords of the vertex after
)

 

Edited by dlanorh
  • Thanks 1
Posted

No problem.

 

You could run them together, but you start to lose readability

 

 (setq p_param (vlax-curve-getparamatpoint ent closest-pt-on-pline ))


(setq pre_vtx (vlax-curve-getpointatparam ent (fix p_param))       ;gets the coords of the vertex before
      post_vtx (vlax-curve-getpointatparam ent (1+ (fix p_param))) ;the coords of the vertex after
)

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...