How to add your knowledge

Creating Features

    Table of contents
    No headers

    To create a new blank feature, call the FeatureClass.CreateFeature() method. This reserves a unique key or feature identifier (FID) for the feature.

    // Get the FeatureClass
    Autodesk.Map.IM.Data.FeatureClass myPointClass = 
      myConnection.FeatureClasses["MYPOINT"];
     
    // Create a new Feature
    Autodesk.Map.IM.Data.Feature myPointFeature = 
      myPointClass.CreateFeature();
    

    Once the feature instance is created, set its properties. For example, you can add geometry to the feature through the Feature.Geometry property:

    myPointFeature.Geometry = new Autodesk.Map.IM.Graphic.Point(100, 100);
    

    To insert the new feature into AutoCAD Map 3D (that is, create a new record in the feature class table), use the FeatureClass.InsertFeature() method:

    myPointClass.InsertFeature(ref myPointFeature);
    

    To update an existing feature in AutoCAD Map 3D, use the FeatureClass.UpdateFeature() method :

    myPointFeature.Geometry = new Autodesk.Map.IM.Graphic.Point(200, 200);
    // Now that a property has been changed, the feature needs to 
    // be updated.
    myPointClass.UpdateFeature(ref myPointFeature);
    

    To delete an existing feature from AutoCAD Map 3D, use the FeatureClass.DeleteFeature() method, which requires the identifier of the feature to be deleted.

    bool success = myPointClass.DeleteFeature(myPointFeature.ID);