The FeatureLayer.FeatureCount method returns the total number of features of a feature layer in the drawing. Use this method to count how many document or web feature layer features of the specified feature layer are in the drawing.
Declaration
public int? Esri.ArcGISForAutoCAD.FeatureLayer.FeatureCount(Document doc, string flName, string sublayerName = null)
Parameters
| Type | Name | Description | Required |
|---|---|---|---|
Document | doc | The AutoCAD document to act on. | required |
string | flName | An existing document or web feature layer name defined in the drawing. | required |
string | sublayerName | An existing feature layer sublayer name in the drawing. | optional |
Returns
| Type | Description |
|---|---|
int? | The number of features in the feature layer. |
Remarks on error conditions
This method can throw an exception or may return null if a parameter is invalid.
Example 1
Print the number of features in the Shelters feature layer that are currently in the drawing.// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
// Get the feature count
var sheltersCount = Esri.ArcGISForAutoCAD.FeatureLayer.FeatureCount(doc, "Shelters");
// Print the count
doc.Editor.WriteMessage("\nFeature count: " + sheltersCount);
/* Example output
Feature count: 15
*/
Example 2
Print the number of features in the Shelters feature layer with the Open sublayer that are currently in the drawing.// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
// Get the feature count
var openSheltersCount = Esri.ArcGISForAutoCAD.FeatureLayer.FeatureCount(doc, "Shelters", "Open");
// Print the count
doc.Editor.WriteMessage("\nFeature count: " + openSheltersCount);
/* Example output
Feature count: 11
*/
See also
esri_featurelayer_featurecount—An AutoLISP function that returns the total number of features of a feature layer in the drawing.