Message 1 of 13
Why it's not working? (please help)

Not applicable
06-01-2005
06:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to check a polyline direction using the following code (found
here). Sometimes it works ok, but sometimes not (please see attached file).
Please help me!
Thanks,
Andre
Sub cw()
' based on lisp file from
';; ! Copyright: (C) 2000, Four Dimension Technologies, Singapore
';; ! Contact : rakesh.rao@4d-technologies.com for help/support/info
Dim objPline As Object, entBasePnt As Double
Dim varCoords As Variant
Dim i As Integer
Dim dbltemppt(0 To 1) As Double
Dim varVertexList As Variant
Dim intCoordCnt As Integer
Dim pt1 As Variant, pt2 As Variant
Dim Direction As Double, dblVertexCnt As Double, temp As Double
ThisDrawing.Utility.GetEntity objPline, entBasePnt, vbCr & "Select closed
Polyline: "
varCoords = objPline.Coordinates
i = 0
ReDim varVertexList(0 To ((UBound(varCoords) + 1) / 2))
For intCoordCnt = 1 To UBound(varCoords) Step 2
dbltemppt(0) = varCoords(intCoordCnt - 1)
dbltemppt(1) = varCoords(intCoordCnt)
varVertexList(i) = dbltemppt
i = i + 1
Next intCoordCnt
i = 0
dblVertexCnt = UBound(varVertexList)
While i < dblVertexCnt - 1
pt1 = varVertexList(i)
pt2 = varVertexList(i + 1)
Direction = Direction + (pt1(1) * pt2(0))
i = i + 1
Wend
pt1 = varVertexList(dblVertexCnt - 1)
pt2 = varVertexList(0)
Direction = Direction + (pt1(1) * pt2(0))
i = 0: temp = 0
While i < dblVertexCnt - 1
pt1 = varVertexList(i)
pt2 = varVertexList(i + 1)
temp = temp + (pt1(1) * pt2(0))
i = i + 1
Wend
pt1 = varVertexList(0)
pt2 = varVertexList(dblVertexCnt - 1)
temp = temp + (pt1(1) * pt2(0))
Direction = 0.5 * (Direction - temp)
If Direction > 0 Then MsgBox "CW"
If Direction < 0 Then MsgBox "CCW"
If Direction = 0 Then MsgBox "?"
End Sub
I'm trying to check a polyline direction using the following code (found
here). Sometimes it works ok, but sometimes not (please see attached file).
Please help me!
Thanks,
Andre
Sub cw()
' based on lisp file from
';; ! Copyright: (C) 2000, Four Dimension Technologies, Singapore
';; ! Contact : rakesh.rao@4d-technologies.com for help/support/info
Dim objPline As Object, entBasePnt As Double
Dim varCoords As Variant
Dim i As Integer
Dim dbltemppt(0 To 1) As Double
Dim varVertexList As Variant
Dim intCoordCnt As Integer
Dim pt1 As Variant, pt2 As Variant
Dim Direction As Double, dblVertexCnt As Double, temp As Double
ThisDrawing.Utility.GetEntity objPline, entBasePnt, vbCr & "Select closed
Polyline: "
varCoords = objPline.Coordinates
i = 0
ReDim varVertexList(0 To ((UBound(varCoords) + 1) / 2))
For intCoordCnt = 1 To UBound(varCoords) Step 2
dbltemppt(0) = varCoords(intCoordCnt - 1)
dbltemppt(1) = varCoords(intCoordCnt)
varVertexList(i) = dbltemppt
i = i + 1
Next intCoordCnt
i = 0
dblVertexCnt = UBound(varVertexList)
While i < dblVertexCnt - 1
pt1 = varVertexList(i)
pt2 = varVertexList(i + 1)
Direction = Direction + (pt1(1) * pt2(0))
i = i + 1
Wend
pt1 = varVertexList(dblVertexCnt - 1)
pt2 = varVertexList(0)
Direction = Direction + (pt1(1) * pt2(0))
i = 0: temp = 0
While i < dblVertexCnt - 1
pt1 = varVertexList(i)
pt2 = varVertexList(i + 1)
temp = temp + (pt1(1) * pt2(0))
i = i + 1
Wend
pt1 = varVertexList(0)
pt2 = varVertexList(dblVertexCnt - 1)
temp = temp + (pt1(1) * pt2(0))
Direction = 0.5 * (Direction - temp)
If Direction > 0 Then MsgBox "CW"
If Direction < 0 Then MsgBox "CCW"
If Direction = 0 Then MsgBox "?"
End Sub