CW or CCW

Discussion in 'AutoCAD' started by fazzini, Feb 26, 2004.

  1. fazzini

    fazzini Guest

    Can i get the orientation (CW or CCW) of a polyline.
    My polyline don't have any radius? I cannot use the
    get bulge method. THX to all.
     
    fazzini, Feb 26, 2004
    #1
  2. fazzini

    Bill Wright Guest

    Here is a sub that I wrote that uses determinants of a matrix to get the
    direction by setting up columns of the x and y coordinates. It uses a
    collection of points but you should be able to modify it to work for
    you.

    Public Sub ccw()
    'dimension locals
    Dim PolyPoints As New Collection
    Dim PolyCounter As Integer
    Dim numPoints As Long
    Dim Pnt() As Variant
    Dim Pnt1() As Variant
    Dim PointCounter As Long
    Dim top As Single
    Dim bottom As Single
    Dim Result As Single
    Dim SectionPolyCol As New Collection

    'get a polygon point collection from a global collection of polygons

    Set SectionPolyCol = gSectionCol.Item(1)

    PolyCounter = 1

    For Each PolyPoints In SectionPolyCol
    numPoints = PolyPoints.Count
    top = 0
    bottom = 0
    Result = 0

    For PointCounter = 1 To numPoints - 1
    Pnt = PolyPoints.Item(PointCounter)
    Pnt1 = PolyPoints.Item(PointCounter + 1)

    top = top - (Pnt(1) * Pnt1(0))
    bottom = bottom + (Pnt(0) * Pnt1(1))

    Next PointCounter

    Result = top + bottom

    If Result > 0 Then
    MsgBox "CounterClockwise"
    Else
    MsgBox "Clockwise"
    End If

    PolyCounter = PolyCounter + 1
    Next PolyPoints

    End Sub

    Good Luck,
    Bill
     
    Bill Wright, Feb 26, 2004
    #2
  3. fazzini

    wivory Guest

    wivory, Feb 27, 2004
    #3
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
Loading...