calculate the Length off a polyline from begin till a point at the polyline VBA

Discussion in 'AutoCAD' started by Vrijbuiter, May 8, 2005.

  1. Vrijbuiter

    Vrijbuiter Guest

    I want to know the length of a line from the begin till the point where
    I click or where the line cross a other line.
    I can get the line and i can find where the intersection points are
    with VBA but I can NOT find a function that calculate the the exact
    length from begin to the intersection.
    Can anyone help me to find the good way.


    Thanks,

    Alexander
    Holland
     
    Vrijbuiter, May 8, 2005
    #1
  2. Vrijbuiter

    Wyatt Earp Guest

    What you want is the distance between the intersection point and one of
    the endpoints of the line segment.

    Assuming the intersection point's coordinates are given by
    ix and iy and the line segment's endpoint coordinates are given by ex
    and ey the distance d would be:

    d = Sqrt(((ix-ex)*(ix-ex))+((iy-ey)*(iy-ey)))

    I'm not sure if Sqrt() is a valid VBA function, I typically use a C#
    over the VBA API, but the math is correct.
     
    Wyatt Earp, May 8, 2005
    #2
  3. Vrijbuiter

    Vrijbuiter Guest

    Dear Wyatt Earp

    Thanks for your answer.
    The function you use call at visual basic -> CalculateSquareRoot =
    Sqr(NumberArg)
    But the problem is that a polyline not a strait line but a combination
    of more line's and arc's is, so I hope you see my problem.

    Alxander
     
    Vrijbuiter, May 8, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.