VB's getPointAtDist?

Discussion in 'AutoCAD' started by mgrigoriev, May 14, 2004.

  1. mgrigoriev

    mgrigoriev Guest

    Is there a VB analog to LISP's getPointAtDist function?
    My goal is actualy to get a midpoint of a polyline.
     
    mgrigoriev, May 14, 2004
    #1
  2. mgrigoriev

    Jeff Mishler Guest

    Yes, sortof, using Frank Oquendo's VLAX and Curve classes. See a request by
    me for these from a month or two ago. I don't have them on this machine or
    I'd post them again.

    Jeff
     
    Jeff Mishler, May 14, 2004
    #2
  3. Or simply find the polyline's midst segment, then find the mid point of that
    segment. Pure VBA.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, May 16, 2004
    #3
  4. And if a polyline has an even number of segments?

    Besides, what makes you think these classes are not pure VBA?
     
    Frank Oquendo, May 17, 2004
    #4
  5. mgrigoriev

    Mark Propst Guest

    What if the pline had a bunch of short segs on one side and long one(s) on
    other side(of center)?
     
    Mark Propst, May 17, 2004
    #5
  6. mgrigoriev

    Ed Jobe Guest

    Also, that would require that each segment be equal length, e.g. a 3 segment pl with lengths of 10,10,1 units. The midpoint would not be on the *middle* of the second segment, but weighted toward the first segment.

    --
    ----
    Ed
    ----
    And if a polyline has an even number of segments?

    Besides, what makes you think these classes are not pure VBA?
     
    Ed Jobe, May 17, 2004
    #6
  7. Allright, allright, my mistake - here's the coded answer (more or less): It
    solves LWPlines with line segments only - no arcs included. Also no error
    trapping of any kind. Pass the function the LWPline length (search the code
    down the NG) divided by 2 and the LWPline itself.

    '===========================================================================
    ====
    ' Stationery point along LWPolyline
    ' Input: polyline length/2 and polyline itself
    ' Result: forced 2D point (three element array of doubles)
    '===========================================================================
    ====
    Function StacionazaTacka(valStacionaza As Double, obj As AcadLWPolyline) As
    Variant
    Dim Coords As Variant
    Dim UBnd As Long
    Dim PntA(0 To 2) As Double
    Dim PntB(0 To 2) As Double
    Dim PntX As Variant
    Dim RunDist As Double
    Dim DistAB As Double
    Dim i as Long

    RunDist = 0
    DistAB = 0
    Coords = obj.Coordinates
    UBnd = UBound(Coords)

    i = 0
    Do While True
    PntA(0) = Coords(i): PntA(1) = Coords(i + 1): PntA(2) = 0
    PntB(0) = Coords(i + 2): PntB(1) = Coords(i + 3): PntB(2) = 0
    DistAB = XYDistance(PntA, PntB)
    PrevDist = RunDist
    RunDist = RunDist + DistAB
    If RunDist >= valStacionaza Then
    ugao = ThisDrawing.Utility.AngleFromXAxis(PntA, PntB)
    Razlika = DistAB - (RunDist - valStacionaza)
    PntX = ThisDrawing.Utility.PolarPoint(PntA, ugao, Razlika)
    StacionazaTacka = Array(PntX(0), PntX(1), 0#)
    Exit Do
    End If
    If i + 2 > UBnd Then
    StacionazaTacka = Array(0#, 0#, 0#)
    Exit Do
    Else
    i = i + 2
    End If
    Loop
    End Function
     
    Maksim Sestic, May 18, 2004
    #7
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.
Similar Threads
There are no similar threads yet.
Loading...