遍历图层中的每一个节点

Public Sub VisitAllFeature(pLayer As  ILayer)

    Dim pFeatcls As IFeatureClass
    Dim pFeatLayer As IFeatureLayer
    Dim pPointCollection As IPointCollection
    Dim pFeatureCursor As IFeatureCursor
    Dim pFeature As IFeature
    Dim pPoint As IPoint
    Dim i, j As Integer
    Set pFeatLayer = pLayer

    Set pFeatcls = pFeatLayer.FeatureClass
    Dim pQFilt As IQueryFilter
    Set pQFilt = New QueryFilter
    pQFilt.WhereClause = ""

    Set pFeatureCursor = pFeatcls.Search(pQFilt, False)

    Set pFeature = pFeatureCursor.NextFeature
    For i = 0 To pFeatcls.FeatureCount(pQFilt) - 1
        If Not (pFeature Is Nothing) Then
            If
pFeature.Shape.GeometryType = esriGeometryPoint Then            
Set pPoint = pFeature.Shape            
Debug.Print pLayer.Name & " " & pPoint.x & ","
& pPoint.y
            Else
              
Set pPointCollection = pFeature.Shape            
For j = 0 To pPointCollection.PointCount - 1
                
Set pPoint = pPointCollection.Point(j)               
Debug.Print pLayer.Name & " " & pPoint.x & ","
& pPoint.y         
Next j
            End If
        End If
        DoEvents
        Set pFeature =
pFeatureCursor.NextFeature
    Next i
End Sub

转载自:http://bbs.esrichina-bj.cn/esri/viewthread.php?tid=37449

你可能感兴趣的:(遍历)