TitlePages

Thursday, 22 January 2015

ArcFm Auto Updaters to Update the Shape Length of the Feature

Schneider electric

Update the Shape Length of the Poly line Feature

Special Auto Up-daters

A special Auto Up-daters differs from the attribute Auto Up-daters in that it is not associated with a field/event combination but rather a feature/event combination. A special Auto Up-daters can be associated to the On Feature Create, On Feature Update, or On Feature Delete events of a feature.

Special Auto Up-daters are not limited to simple field updates like attribute Auto Up-daters. Rather, they can be written to perform a wide array of tasks such as writing out text files, updating records in a remote database, sending emails - just about anything that you would need to programmatically do in response to a feature/object.

IMMSpecialAUStrategyEx Interface




  1. Do the following steps to start with AutoUpdaters.
  2. Start your Visual Studio 2010 or More 
  3. Create a New Project of Type base Command from ArcGIS tab .Choose the Programming Language of your comfort(VB or C#.Net)
  4. Give a Name to the Project and your can see base class library with your dll registered function with Unique Code GUID.
  1. To get the Functionality of the Special AutoUpdaters in your code implement the Specific Interface ie. IMMSpecialAUStrategyEx Interface


public class ShapeLengthAU : IMMSpecialAUStrategyEx
    {

        private string _name;
//Name is a required parameter for the Implemented Interface
        public string Name
        {
            get
            {
                if (string.IsNullOrEmpty(_name))
                {
                    _name =”Name of your Autoupdater
                }
                return _name;
            }
        }

        
        public void Execute(IObject obj, mmAutoUpdaterMode eAUMode, mmEditEvent editEvent)
        {
            IPCursor pCursor = null;
            try
            {
//Autoupdater will update only when the EditEvent is of Type like FeatureCreate,FeatureSplit,FeatureUpdate
                if (editEvent == mmEditEvent.mmEventFeatureCreate || editEvent == mmEditEvent.mmEventFeatureSplit || editEvent == mmEditEvent.mmEventFeatureUpdate)
                {
                    IFeature pFeature = obj as IFeature;
                    IPolyline pPolyLine = pFeature.Shape as IPolyline;
                    double ftLength = pPolyLine.Length;
//Place the length value in to the Pfeature respective field
                    pFeature.set_Value(pFeature.Fields.FindField(“ShapeFieldName”), ftLength);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (pCursor != null)
                {
//Use the Marshalling Method to release the Cursoer from the Memory
                    Marshal.ReleaseComObject(pCursor); 
                }
            }           
        }
//get_Enabled is a required Method for the Implemented Interface
        public bool get_Enabled(IObjectClass,pObjectClass, mmEditEvent eEvent)
        {
            return true;
        }

        
    }
}

Now Compile the Code and Execute.
Note:Set the Startup Project for Debugging as ArcCatalog.exe in the Project Properties.

Go to Arc-Catalog , Right Click on your ArcFM feature and Select ArcFm Properties Mangaer

Select the Object Tab.It will display the various event from the ArcFm for the Particular Object.
Assign your Auto Updaters to the various event you want to call.

Do the edit in the feature through ArcMap editor.This will trigger your Updaters.






No comments: