Skip To Content

FeatureLayer.Select (.NET)

The FeatureLayer.Select method returns an AutoCAD selection set filtered by the specified feature layer and optional sublayer from the drawing, and optionally, a specified selection set and attribute query. This method is similar to the Objects option of the Select Features tool on the context menu of a web feature layer or document feature layer in the Contents pane.

Note:

Attempting to manage a large number of selection sets simultaneously is not recommended. An application cannot have more than 128 selection sets open at once. (The limit may be lower on your system.) When the limit is reached, AutoCAD will not create more selection sets. Keep a minimum number of sets open at a time, and release them from memory as soon as possible. If the maximum number of selection sets is reached you will not be able to create more.

Declaration

public SelectionSet Esri.ArcGISForAutoCAD.FeatureLayer.Select(Document doc, string flName, string sublayerName = null , SelectionSet selectionSet = null, string attributeQuery = null)

Parameters

TypeNameDescriptionRequired

Document

doc

The AutoCAD document to act on.

required

string

flName

An existing feature layer name in the drawing.

required

string

sublayerName

An existing feature layer sublayer name in the drawing.

optional

SelectionSet

selectionSet

A collection of ArcGIS for AutoCAD objects to filter by.

optional

string

attributeQuery

A WHERE clause using a single field name to limit the return value.

optional

Returns

TypeDescription

SelectionSet

An AutoCAD selection set object.

Remarks on error conditions

This method may throw an exception or return null if a parameter is invalid.

Example 1

Print the number of entities that belong to the Shelters feature layer in the current drawing.

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;

// Create a selection set of all entities that belong to the feature layer
var sheltersSelection = Esri.ArcGISForAutoCAD.FeatureLayer.Select(doc, "Shelters");

// Print the count
doc.Editor.WriteMessage("\nNumber of entities selected: " + sheltersSelection.Count.ToString());

/* Example output
Number of entities selected: 36
*/

Example 2

Print the number of entities that belong to the Open sublayer of the Shelters feature layer in the current drawing in which the capacity field values are greater than 400.

// Initialize 
var doc = Application.DocumentManager.MdiActiveDocument;

// Create a selection set of the entities that meet the selection criteria
var sheltersSelection = Esri.ArcGISForAutoCAD.FeatureLayer.Select(doc, "Shelters", "Open", null, "capacity > 400");

// Print the count
doc.Editor.WriteMessage("\nNumber of entities selected: " + sheltersSelection.Count.ToString());

/* Example output
Number of entities selected: 3
*/

See also

FeatueLayer.SelectSpecial—A .NET method that returns an AutoCAD selection set from a specified feature layer based on special criteria.

esri_featurelayer_select —An AutoLISP function that returns an AutoCAD selection set filtered by the specified feature layer and optional sublayer from the drawing, and optionally, a specified selection set.