Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
I'm trying to get the distance until a certain point but keep getting the same error. The point exist in the line.
this is my code:
(setq Ent (entsel "Select the polyline : " ) )
(setq Vl-Obj (vlax-ename->vla-Object (car Ent )) )
(setq p2 (list -102469.3 -47412.9 0.0)
(vlax-curve-getDistAtPoint vl-obj pt2)
Solved! Go to Solution.
Solved by Ranjit_Singh2. Go to Solution.
@Anonymous wrote:
I'm trying to get the distance until a certain point but keep getting the same error. The point exist in the line.
.............
(setq p2 (list -102469.3 -47412.9 0.0)
(vlax-curve-getDistAtPoint vl-obj pt2)
You are calling the wrong variable pt2. It should be p2.
You cannot exactly catch a point on the polyline by typing it in because of decimal issue. Try this
(vlax-curve-getDistAtPoint vl-obj (vlax-curve-getclosestpointto vl-obj p2))
[The (vlax-curve...) functions will take entity names -- no need to convert to a VLA object unless you need that for some other purpose.]
[You're also missing the closing ) on the (setq p2... line.]
Another way to go about getting the point exactly on it from the point that apparently isn't quite on it:
(setq Ent (entsel "Select the polyline : "))
(setq p2 (list -102469.3 -47412.9 0.0))
(vlax-curve-getDistAtPoint (car ent) (osnap p2 "nea"))
@Kent1Cooper wrote, "(vlax-curve-getDistAtPoint (car ent) (osnap p2 "nea"))"
That's fine if there are no other nearby objects.
I think that closestpointto is more reliable because it focuses on the object of interest.
I presume that precision makes a difference in the "atpoint" functions, though I have not done a study.
That's why we should write code that covers the misses without erroring out...
(or (setq p (vlax-curve-getclosestpointto object p)) (prompt "\nUnable to find closest point to object.") )
John F. Uhden
Your explanation made a lot of sense ! Thank you so much for the help !
It worked just fine !
Can't find what you're looking for? Ask the community or share your knowledge.