With the sample code and drawing you can see that on the candy cane looking object that ' vlax-curve-getClosestPointTo ' does not return the closest point along the object. I was wondering if anyone else has seen this, and if there is a way to fix it?
The two yellow lines represent the start point of the curve to the cursor location, then cursor location to where ' vlax-curve-getClosestPointTo ' is selecting the point.
The red line is just start point of the curve to the point returned by ' vlax-curve-getClosestPointTo '.
You will notice that on the other objects in the drawing, besides the solid, the lines are shown correctly. If you change the UCS to world, and the run the program, then it will show correctly on the candy cane, but not the other two. So now I'm back to the original section in the post. I have tried ' trans 'ing the points different ways, but nothing I have thought of has worked.
Thanks.
(defun c:Test ( / Sel Ent Norm StPt Ext GrList tempPt Pt )
(setq Sel (entsel "\n Select candy cane looking object: "))
(setq Ent (car Sel))
(setq StPt (vlax-curve-getPointAtParam Ent (vlax-curve-getStartParam Ent)))
(setq Norm (cdr (assoc 210 (entget Ent))))
(while (and (not Ext) (setq GrList (grread T 13 1)))
(cond
((equal (car GrList) 5)
(setq tempPt (vlax-curve-getClosestPointTo Ent (trans (cadr GrList) 1 0) nil))
(redraw)
(grvecs
(list
1
(trans StPt 0 1)
(trans tempPt 0 1)
2
(trans StPt 0 1)
(cadr GrList)
2
(cadr GrList)
(trans tempPt 0 1)
)
)
)
((equal (car GrList) 3)
(setq Pt (vlax-curve-getClosestPointTo Ent (trans (cadr GrList) 1 0) nil))
)
(
(and
(equal (car GrList) 2)
(member (cadr GrList) '(13))
)
(setq Ext T)
)
((member (car GrList) '(11 25))
(setq Ext T)
)
)
)
(redraw)
(princ)
)