Author Topic: How to find if there is a coordinate point between two points on polyline  (Read 880 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Hello guys.

I am having a hard time to find if there is a coordinate point between the two points placed on a polyline and I have attached an image showing the problem in more details.

How can I get the coordinate point of a Polyline that is placed between the two points ( p1  p2 ) otherwise return nil if not found.

I hope also if the codes can find if there are more than one coordinate in some situations.

Code: [Select]
(setq poly (car (entsel "\nSelect polyline :")))
(setq p1 (vlax-curve-getpointatdist poly 0.5))
(setq p2 (vlax-curve-getpointatdist poly 1.5))

Thanks in advance.
« Last Edit: May 01, 2016, 12:13:19 PM by Coder »

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Here is an easy way, but is dependent on the parameterisation of the polyline:
Code - Auto/Visual Lisp: [Select]
  1. (defun vertexbetween-p ( ent pt1 pt2 )
  2.     (/= (fix (vlax-curve-getparamatpoint ent pt1))
  3.         (fix (vlax-curve-getparamatpoint ent pt2))
  4.     )
  5. )

Here is another way:
Code - Auto/Visual Lisp: [Select]
  1. (defun vertexbetween-p ( ent pt1 pt2 / di1 di2 tmp )
  2.     (setq di1 (vlax-curve-getdistatpoint ent pt1)
  3.           di2 (vlax-curve-getdistatpoint ent pt2)
  4.           tmp (min di1 di2)
  5.           di2 (max di1 di2)
  6.           di1 tmp
  7.     )
  8.     (vl-some '(lambda ( x ) (< di1 (vlax-curve-getdistatpoint ent (trans (cdr x) ent 0)) di2))
  9.         (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) (entget ent))
  10.     )
  11. )

Additionally testing may be required to account for closed polylines.

Both of the above are untested.

Coder

  • Swamp Rat
  • Posts: 827
Many thanks Lee , that is prefect.