Closest distance from a point on a curve to the start or end of the curve

Closest distance from a point on a curve to the start or end of the curve

Browning_Zed
Advocate Advocate
416 Views
2 Replies
Message 1 of 3

Closest distance from a point on a curve to the start or end of the curve

Browning_Zed
Advocate
Advocate

Hi all,

 

I am trying to find a solution how to get the distance along a curve from a specified point lying on the curve. I specify a point in this way:

(setq
    curveobj (entsel)
    closepnt (vlax-curve-getclosestpointto (car curveobj) (cadr curveobj))
)

Now I need the following steps:
1. Find out the distance from closepnt to the start of the curve;
2. Find out the distance from closepnt to the end of the curve;
3. Compare these two distances, and if distance 1 is less than distance 2 then return T, otherwise nil.

 

Thanks in advance for your help.

`

0 Likes
Accepted solutions (1)
417 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution
Message 3 of 3

Browning_Zed
Advocate
Advocate

Thanks man, you're great as always. I did it thanks to you.

 

(setq
    enselobj (entsel)
    curveobj (car enselobj)
    startdis
        (vlax-curve-getDistAtPoint
            curveobj
            (vlax-curve-getclosestpointto curveobj (cadr enselobj))
        )
)
( < startdis
    ( - (vlax-curve-getDistAtParam
            curveobj
            (vlax-curve-getEndParam curveobj)
        )
        startdis
    )
)