2

I built an Arcobjects add-in in the past that records the username and datetime every time a feature is created or modified:

Sub OnStartEditing_Handler()
    AddHandler Events.OnCreateFeature, AddressOf OnCreateChangeFeature_Handler
    AddHandler Events.OnChangeFeature, AddressOf OnCreateChangeFeature_Handler
End Sub

Sub OnCreateChangeFeature_Handler(ByVal obj As ESRI.ArcGIS.Geodatabase.IObject)
    Dim feature As IFeature = CType(obj, IFeature)

    'Update Date field
    'Update Username field

End Sub 

I have recently been working on another add-in that updates a different field during an edit session:

'Populate Feature attribute
m_editor.StartOperation()
m_feature.Value(m_hgtFieldIdx) = CInt(height)
m_editor.StopOperation("Measure Height")

The second add-in successfully updates the field, however the first add-in is not updating the username and date fields. Does the StartOperation() or StopOperation() not fire the OnChangeFeature event? I cannot find any documentation for this situation. If not, can I fire it programmatically, or is there another way to catch feature(s) changed during the Start/StopOperation()?

  • 1
    Are you missing m_feature.Store() ? – Chris Kushnir Feb 18 '17 at 6:37
  • @ChrisKushnir No, since I am doing the updates during an edit session, the store() method cannot be used – Barbarossa Feb 18 '17 at 14:25
  • Did you actually try putting m_feature.Store() before StopOperation, or are you just assuming it isn't needed ? – Chris Kushnir Feb 19 '17 at 0:50
  • @ChrisKushnir Your assumption about my assumptions are correct. I had not tried it, as I misread the documentation You nailed it though. I'll accept your answer if you post it. – Barbarossa Feb 19 '17 at 1:47
2

You are missing m_feature.Store(). Try putting m_feature.Store() before StopOperation.

See here.

  • It depends on how you got the feature.. if you have the feature from GetFeature(ID) or through a Search() then yes you need to .Store it to update the changes back to its feature class but if you've got the feature from an .Update() cursor then you need to update the feature via the cursor and definitely not .Store it; calling Store on a feature from an Update cursor will cause errors. – Michael Stimson Mar 2 '17 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.