Message 1 of 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
The routine posted below should return a list in which:
1st item - coordinates of the nearest vertex of the polyline relative to the picked location on the polyline
2nd item - coordinates of the second vertex of the picked polyline segment
3rd item - the angle between the first and second obtained points.
(defun c:Test ( / s e pr p a b pt1 pt2 )
(if (and (setq s (entsel)) (wcmatch (cdr (assoc 0 (entget (setq e (car s))))) "*POLYLINE"))
(progn
(setq
pr
(vlax-curve-getparamatpoint e (setq p (vlax-curve-getclosestpointto e (cadr s))))
)
(if (< (distance p (setq a (vlax-curve-getpointatparam e (fix pr))))
(distance p (setq b (vlax-curve-getpointatparam e (1+ (fix pr)))))
)
(setq pt1 a pt2 b)
(setq pt1 b pt2 a)
)
(list pt1 pt2 (angle '(0 0) (mapcar '- a b)))
)
(princ "\n Nothing selected or not a Polyline <!>")
)
)
(vl-load-com)
The problem is that the function returns the wrong angle value. Here I found a way to determine the angle between the obtained 3D points, but the expression
(angle '(0 0) (mapcar '- a b))
does not return the correct angle value.
How can this issue be resolved?
Solved! Go to Solution.