rennerken

Programmatically setting new feature enabled.

Discussion created by rennerken on Mar 11, 2011
Does anyone know how I set the ancillary role and enabled state of a new feature created within ArcObjects. This feature class participates in a Geometric Network. If I create the Features through the ArcEditor UI both fields are set by default.

In ArcObjects....

IFeature feature = pfcl.CreateFeature();
//Edit the attributes....
feature.store();

The above creates the feature but the "enabled" and "AncillaryRole" fields are Null.

If I do the below, the enabled field is set correctly but the AncillaryRole is still null.

private void StoreFeature(IFeature _feature)
        {
            try
            {                              
                if (_feature is INetworkFeature)
                    {
                         INetworkFeature If = (INetworkFeature)_feature;                       
                          if (!(If == null))
                            {
                                If.CreateNetworkElements();                                                           
                                If.Enabled = true;                                                           
                                _feature.Store();
                            }
                     }
                else
                {
                    _feature.Store();
                }                  
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " Method StoreFeature");               
            }
        }


Thanks for any help you can give me.

Ken

Outcomes