AnsweredAssumed Answered

Trouble looping through a selection set where feature type is polyline which is part of a topology class.

Question asked by WDMGIS on Aug 31, 2017
Latest reply on Sep 18, 2017 by Hornbydd


I have code that loops through selected features and updates an attribute for those features.  The code throws an error at runtime when the featureclass is a polyline type which participates in a topology class.  The error seems to happen at iSelectionset.Update.  Below is the entire function.  Any ideas would be appreciated.


Private Sub txtRFrom_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtRFrom.KeyPress
If Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 9 Then
If cmbLayer.SelectedIndex = -1 Then
MsgBox("Please Select an Edit Layer!!")
Exit Sub
End If

Dim intValue As Integer

If Not Integer.TryParse(txtRFrom.Text, intValue) Then
Exit Sub
End If

Dim pfLayer As IFeatureLayer
pfLayer = FindLayerByName(cmbLayer.SelectedItem)

Dim pfClass As IFeatureClass
pfClass = pfLayer.FeatureClass

Dim pfeatsel As IFeatureSelection
pfeatsel = pfLayer

Dim pSelectionSet As ISelectionSet2
pSelectionSet = pfeatsel.SelectionSet

If pSelectionSet.Count = 0 Then
MsgBox("No features selected!!")
Exit Sub
End If

Dim pFeatureCursor As IFeatureCursor
pFeatureCursor = Nothing

Dim pFeature As IFeature

'update the selectionset setting the IQueryFilter object to Nothing

pSelectionSet.Update(Nothing, False, pFeatureCursor)

pFeature = pFeatureCursor.NextFeature

Do Until pFeature Is Nothing

pFeature.Value(pFeature.Fields.FindField("RFromAddr")) = txtRFrom.Text

pFeature = pFeatureCursor.NextFeature

End If

End Sub