Jump to content

Calculate distance between two points along polyline


nkeseci

Recommended Posts

Hi,

 

I need to calculate distance between two points along a polyline. These points may exist on different segments of the same polyline. Maybe there is a function, I couldn't find it.

 

I'd be very grateful for your help.

Link to comment
Share on other sites

If these two points are vertices why not just Getpoint pt1 Getpoint pt2 distance all done. If they are intersection points of say a line intersecting pline then same thing but like Tharwat Vla-intersectwith to work out pt1 pt2

 

There is plenty of pline vertice lsp here that will pull out the co-ords of the vertice's.

 

You need to provide some more information.

Link to comment
Share on other sites

Tharwat : I used vlax-curve-getDistAtPoint function but I get nil. i.e. (vlax-curve-getDistAtPoint plObj ip5) where ip5 is an intersection point on pline.

 

BIGAL : With my lisp code, I have all the intersection points and the verticies. I only need to calculate distance from vp0 to ip1, then vp0 to ip2, vp0 to ip3 and so on. The path must be followed vp0-ip1-ip2-vp1-ip3-ip4-vp2-vp3-ip5 points for length of vp0-ip5, ie. As you guess, the points may vary case to case.

Link to comment
Share on other sites

Tharwat : I used vlax-curve-getDistAtPoint function but I get nil. i.e. (vlax-curve-getDistAtPoint plObj ip5) where ip5 is an intersection point on pline.

 

e.g.

 

(vl-load-com)
(if (and (progn (prompt "\n Select Polyline :")
          (setq e (ssget "_+.:s" '((0 . "*POLYLINE"))))
        )
        (setq p (getpoint "\n Specify point on the previous selected polyline :"))
   )
 (print (vlax-curve-getdistatpoint (ssname e 0) (vlax-curve-getclosestpointto (ssname e 0) p)))
)

Link to comment
Share on other sites

Yes, the vlax-curve-* functions are extremely finicky about points being "exactly" on top of the polyline. Usually even snapping to it is not enough. Thus you use the vlax-curve-getClosestPointTo function to convert your point to something "exactly" on top of the PL - as Tharwat's shown.

 

BTW, do you want to have the distances displayed on the dwg? I.e. something like a chaining-distance? Then perhaps look at this old thread: http://forums.augi.com/showthread.php?40128-distance-and-offset-along-a-polyline

Link to comment
Share on other sites

Yes, it is working correctly with the vlax-curve-getClosestPointTo function. e.g.

 

(setq distance (vlax-curve-getDistAtPoint plObj (vlax-curve-getClosestPointTo plObj (list (car intP) (cadr intP) 0.0))))

 

I want to display those distances like a chaining-distance. I will look at your link :)

 

Thank you very much to all of you :)

Link to comment
Share on other sites

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