PointNumberSelect Example

Land Auto

PointNumberSelect Example

Sub Example_PointNumberSelect()
    
    ' This gets all the CogoPoint numbers in a selection set and
    ' displays them as a comma delimited string.
    Dim cogoPnts As AeccCogoPoints
    Dim entity As Object
    Dim pntNum As Long
    Dim odjId As Long
    Dim firstPnt As Boolean
    Dim strPnts As String
    
    Set cogoPnts = AeccApplication.ActiveProject.CogoPoints
    
    On Error Resume Next
    
    ' Delete existing SelectionSet
    ThisDrawing.SelectionSets("SSet").Delete
    
    ' Create the selection filtered for CogoPoint objects
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("SSet")
    
    Dim gpCode(0) As Integer
    Dim dataValue(0) As Variant
    
    gpCode(0) = 0
    dataValue(0) = "AECC_POINT"
    
    Dim groupCode As Variant
    Dim dataCode As Variant
    
    groupCode = gpCode
    dataCode = dataValue
    ssetObj.SelectOnScreen groupCode, dataCode
    
    firstPnt = True
    ' Process selection set
    For Each entity In ssetObj
        objId = entity.ObjectID
        pntNum = cogoPnts.PointNumberFromObjID(objId)
        If pntNum > 0 Then
            If firstPnt = True Then
                strPnts = Format(pntNum)
                firstPnt = False
            Else
                strPnts = strPnts + "," + Format(pntNum)
            End If
        End If
    Next
    
    MsgBox "The CogoPoint numbers in the selection are: " & _
        strPnts, vbInformation, "PointNumberFromObjID Example"
    
End Sub