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
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
You don't specify a version but the current one exposes a Length property for lwp's.
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
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
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...
cut.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
DRW