Length of a lwpolyline
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Length of a lwpolyline

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
DRW1975
Guest





Posted: Thu Dec 16, 2004 10:59 pm    Post subject: Length of a lwpolyline Reply with quote

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

Back to top
fantum
Guest





Posted: Thu Dec 16, 2004 11:49 pm    Post subject: Re: Length of a lwpolyline Reply with quote

You don't specify a version but the current one exposes a Length property for lwp's.
Back to top
DRW1975
Guest





Posted: Fri Dec 17, 2004 12:28 am    Post subject: Re: Length of a lwpolyline Reply with quote

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

Back to top
R. Robert Bell
Guest





Posted: Fri Dec 17, 2004 8:57 pm    Post subject: Re: Length of a lwpolyline Reply with quote

The Length property was added in 2004 (I believe).

--
R. Robert Bell


"DRW1975" <nospam@address.withheld> wrote in message
news:2955948.1103220001000.JavaMail.jive@jiveforum1.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
Back to top
Kevin Terry
Guest





Posted: Wed Jan 05, 2005 7:48 pm    Post subject: Re: Length of a lwpolyline Reply with quote

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@jiveforum1.autodesk.com...
Quote:
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.
Quote:

DRW
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB