Results 1 to 5 of 5

Thread: Length of a lwpolyline

  1. #1
    DRW1975 Guest

    Length of a lwpolyline

    is there a way to get the length of an lwpolyline without actually calculating it based on coordinates of each point?
    (like how .area works)

    DRW

  2. #2
    fantum Guest
    You don't specify a version but the current one exposes a Length property for lwp's.

  3. #3
    DRW1975 Guest
    I am using 2002 here at work, and it doesn't seem to exist... I will look into it in 2005 version.

    If I have to, I will code a routine to determine the length of a lwp, it would not be long, I was just wondering if there might be a one-line short cut.

    DRW

  4. #4
    R. Robert Bell Guest
    The Length property was added in 2004 (I believe).

    --
    R. Robert Bell


    "DRW1975" <nospam@address.withheld> wrote in message
    news:2955948.1103220001000.JavaMail.jive@jiveforum 1.autodesk.com...
    is there a way to get the length of an lwpolyline without actually
    calculating it based on coordinates of each point?
    (like how .area works)

    DRW

  5. #5
    Kevin Terry Guest
    Here's a function that'll do this for you:

    I'm pretty sure I got this from Randall Rath originally...

    ' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    .. . . . . . . . . . .
    '
    'Returns length of polyline passed in
    '
    'Passed variables:
    'objPline = polyline object
    '
    Public Function PlineLenEX(objPline As AcadLWPolyline) As Double
    Dim intVCnt As Integer
    Dim varCords As Variant
    Dim varVert As Variant
    Dim varCord As Variant
    Dim varNext As Variant
    Dim intCrdCnt As Integer
    Dim dblTemp As Double
    Dim dblArc As Double
    Dim dblAng As Double
    Dim dblChord As Double
    Dim dblInclAng As Double
    Dim dblRad As Double
    Dim intDiv As Integer
    On Error GoTo Err_Control
    intDiv = 2
    varCords = objPline.Coordinates
    For Each varVert In varCords
    intVCnt = intVCnt + 1
    Next
    For intCrdCnt = 0 To intVCnt / intDiv - 1
    If intCrdCnt < intVCnt / intDiv - 1 Then
    varCord = objPline.Coordinate(intCrdCnt)
    varNext = objPline.Coordinate(intCrdCnt + 1)
    ElseIf objPline.Closed Then
    varCord = objPline.Coordinate(intCrdCnt)
    varNext = objPline.Coordinate(0)
    Else
    Exit For
    End If
    If objPline.GetBulge(intCrdCnt) = 0 Then
    'computes a simple Pythagorean length
    dblTemp = dblTemp + Sqr((Sqr(((varCord(0) - _
    varNext(0)) ^ 2) + ((varCord(1) - varNext(1)) ^ 2)) ^ 2))
    Else
    'If there is a bulge we need to get an arc length
    dblChord = Sqr((Sqr(((varCord(0) - varNext(0)) ^ 2) _
    + ((varCord(1) - varNext(1)) ^ 2)) ^ 2))
    'Bulge is the tangent of 1/4 of the included angle between
    'vertices. So we reverse the process...
    dblInclAng = Atn(Abs(objPline.GetBulge(intCrdCnt))) * 4
    dblAng = (dblInclAng / 2) - ((Atn(1) * 4) / 2)
    dblRad = (dblChord / 2) / (Cos(dblAng))
    dblArc = dblInclAng * dblRad
    dblTemp = dblTemp + dblArc
    End If
    'End If
    Next
    PlineLenEX = dblTemp
    Exit_Here:
    Exit Function
    Err_Control:
    Select Case Err.Number
    Case Else
    MsgBox Err.Description
    Err.Clear
    Resume Exit_Here
    End Select
    End Function


    Kevin

    "DRW1975" <nospam@address.withheld> wrote in message
    news:14824369.1103225317941.JavaMail.jive@jiveforu m1.autodesk.com...
    I am using 2002 here at work, and it doesn't seem to exist... I will look
    into it in 2005 version.

    If I have to, I will code a routine to determine the length of a lwp, it
    would not be long, I was just wondering if there might be a one-line short
    cut.
    DRW

Similar Threads

  1. Curve length API
    By in forum SolidWorks
    Replies: 1
    Last Post: 03-30-2005, 02:06 AM
  2. Dimensioning Arc Length
    By n.almeida in forum Customization
    Replies: 1
    Last Post: 02-10-2005, 03:37 PM
  3. Remove a vertex from a polyline or lwpolyline by picking
    By Tabasco Ed in forum Customization
    Replies: 0
    Last Post: 02-01-2005, 12:55 PM
  4. Entmake a LWPOLYLINE
    By BillZ in forum Customization
    Replies: 5
    Last Post: 01-25-2005, 04:44 PM
  5. Arc length
    By AJMII in forum AutoCAD
    Replies: 6
    Last Post: 09-28-2004, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum