Get a cursor of Rows given a set of object ids.
[Visual Basic 6.0] Function GetFeatures(
ByVal fids As Variant, _
ByVal Recycling As Boolean _
) As IFeatureCursor
[Visual Basic .NET] Public Function GetFeatures ( _ ByVal fids As Object, _ ByVal Recycling As Boolean _ ) As IFeatureCursor
[C#] public IFeatureCursor GetFeatures ( object fids, bool Recycling );
[Java] public IFeatureCursor getFeatures ( Object fids, Boolean Recycling ) throws IOException, AutomationException
[C++] HRESULT GetFeatures( VARIANT fids, VARIANT_BOOL Recycling, IFeatureCursor** Cursor );
Parameters
fids [in]
fids is a parameter of type VARIANT
Recycling [in]
Recycling is a parameter of type VARIANT_BOOL
Cursor [out, retval]
Cursor is a parameter of type IFeatureCursor
GetFeatures will return an IFeatureCursor which contains the features from the feature class with the parameter-specified Object IDs (OID). This method can be used to loop through a particular set of features with known Object IDs.
Calling the GetFeatures method from the IFeatureClass interface has the same effect as calling the GetRows method from the ITable interface except that the return value is an IFeatureCursor reference, rather than an ICursor reference.
The fids parameter should be provided with an integer array. If the array contains an invalid Object ID, no error will occur, and no feature will be retrieved for the value.
This method should not be called from .NET or Java applications. Instead, call IGeoDatabaseBridge.GetFeatures.
The following example loops through a set of features of the feature class and pops up a message box with the value of a particular field for each of those features.
Dim pFeatcls As IFeatureClass
Dim pFeatLayer As IFeatureLayer
Dim pDoc As IMxDocument
Dim pMap As IMap
Set pDoc = ThisDocument
Set pMap = pDoc.Maps.Item(0)
Set pFeatLayer = pMap.Layer(0)
Set pFeatcls = pFeatLayer.FeatureClass
' get the index of the field we are intersected in
Dim lFld As Long
lFld = pFeatcls.FindField("SYMBOL")
Dim iOIDList() As Long
Dim iOIDListCount As Long
Dim pFeatureCursor As IFeatureCursor
iOIDListCount = 5
ReDim iOIDList(iOIDListCount)
iOIDList(0) = 1
iOIDList(1) = 2
iOIDList(2) = 3
iOIDList(3) = 4
iOIDList(4) = 5
Set pFeatureCursor = pFeatcls.GetFeatures(iOIDList, False)
' loop through the first 10 features and get the value for the field
Dim pFeat As IFeature
Set pFeat = pFeatureCursor.NextFeature
While Not pFeat Is Nothing
' do something with each feature.
MsgBox pFeat.Value(lFld)
Set pFeat = pFeatureCursor.NextFeature
Wend
IFeatureClass Interface | IFeature Interface | IFeatureCursor Interface