ArcObjects Library Reference (GeoDatabase)  

IFeatureClass.CreateFeature Method

Create a new feature, with a system assigned object ID and null property values.

[Visual Basic .NET]
Public Function CreateFeature ( _
) As IFeature
[C#]
public IFeature CreateFeature (
);
[C++]
HRESULT CreateFeature(
  IFeature** Feature
);
[C++]

Parameters

Feature [out, retval]

  Feature is a parameter of type IFeature

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

CreateFeature will create a new feature for the feature class. The new feature is by default assigned a unique object ID (OID). All other fields are initialized to null values if they can be made null and to built-in default values appropriate to the type of the field if they cannot be made null. Use the IFeature::Store method to actually store this new feature in the database. When working with a versioned feature class, CreateFeature should only be called within an edit session. You can start an edit session by calling IWorkspaceEdit::StartEditing. All edits to features that participate in a Topology or Geometric Network must be performed within an edit session and bracketed within an edit operation.

After calling CreateFeature, the default subtype value is not automatically set nor are default values initialized. For features without a subtype that have defined default values, calling IRowSubtypes::InitDefaultValues will initialize the default values.  Use IRowSubtypes::SubtypeCode to set the subtype value for features with subtypes before calling IRowSubtypes::InitDefaultValues to initialize the default values for the particular subtype.

Calling the CreateFeature method on a feature class (via the IFeatureClass interface on the feature class) has the same effect as calling the CreateRow method on the FeatureClass (via the ITable interface on the feature class) except that the IFeatureClass methods return IFeature interfaces on the returned row object.

If multiple features with common attributes are being sequentially created, the CreateFeatureBuffer method, IFeatureCursor.InsertFeature method and IFeatureBuffer interface should be used for better performance.

The basic process to create a new feature is:

1) Create the feature
2) Create the geometry for the feature
3) Store the geometry in the feature
4) Store the feature

See Also

IFeatureClass Interface | IFeatureCursor Interface | IFeature Interface

.NET Samples

Points along line construction tool (Code Files: PointsAlongLineForm)

.NET Related Topics

Creating features | DataSourcesRaster | Geodatabase | Using feature templates