3

I have a feature class in a file geodatabase and it contains a field called [curing] in short integer type and another field called [IsPopulated] in short integer as well.

What I want to achieve is to make [IsPopulated] automatically populated with "0" or "1" depending on whether the [curing] column is filled with a numeric value.

"Field Calculator" does not help as it's just a one-off operation and NOT automatic.

5

I think there is a programming solution for it.Add a class that implements IExtension interface,override OnChangeFeature event of Editor object in IExtension startup routine of this class.Now any update in your features (which is done by ArcMap Editor toolbar) is catched and falls into the code of this OnChangeFeature procedure code.Here you can check current editing layer and if it's your target layer,update the field(s) you want depending on other fields value of the feature being edited.

here is some snippets to show how I use this technique:

public class clsArcMapExtension : IExtension
{
    private IApplication m_ipApplication;
    private IMxDocument m_ipDocument = null;
    private IActiveView m_ipActiveView = null;
    private Editor m_Editor = null;

and here is how I initialize these member variables(I just copy/paste my old codes,maybe some of these variables do not have any use for you)

public void Startup(ref object initializationData)
    {
        m_ipApplication = initializationData as IApplication;
        if (m_ipApplication == null)
            return;
        this.m_ipDocument = this.m_ipApplication.Document as IMxDocument;
        this.m_ipActiveView = this.m_ipDocument.ActivatedView;

        this.m_Editor = this.m_ipApplication.FindExtensionByName("ESRI Object Editor") as Editor;
        this.m_Editor.OnChangeFeature += new IEditEvents_OnChangeFeatureEventHandler(m_Editor_OnChangeFeature);

and here is the trap for any update of features on the map,you can put your code here:

void m_Editor_OnChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj)
    {
        if (!(obj is IFeature))
            return;

        IFeatureLayer ipCurrentLayer = (this.m_Editor as IEditLayers).CurrentLayer;
        //Here you can check your target layer and edit feature being edited
        IFeature ipMyFeature=(IFeature)obj;
        ipMyFeature.set_Value(2,"MyNewValue");

Sure I can not put all code lines here.But it's a sample that works for me.i use ArcMap 10.2 and Vistual Studio 2012 to develope my extention for ArcMap.Hope it helps.

  • Thanks Reza for your code. But I will need to wrap up the feature class in a file geodatabase to be published to ArcGIS Online. So non-programmatic way is preferred. – alextc Aug 7 '14 at 0:17

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.