Skip To Content

DocFeatureLayer.Add (.NET)

The DocFeatureLayer.Add method adds a document feature layer definition to the AutoCAD drawing.

When using this method, consider the following:

  • If the geometry type and layer filter are omitted, the feature layer will be created without a query filter, and the geomTypeString parameter will be set to point.
  • If the optional layerFilter parameter is included, it is used as the QUERYFILTER value.
  • If a more sophisticated query filter is required, use the DocFeatureLayer.SetQuery method.
  • If the new feature layer name already exists, the specified name will be added with an appended number in succession.

Declaration

public string Esri.ArcGISForAutoCAD.DocFeatureLayer.Add(Document doc, string flName, string geomTypeString = "Point", IEnumerable<string> layerFilter = null)

Parameters

TypeNameDescriptionRequired

Document

doc

The AutoCAD document to act on.

required

string

flName

The new document feature layer name.

required

string

geomTypeString

The geometric type of the new feature layer: "Polygon", "Point", "Polyline", "Annotation", or "Multipatch".

optional (The default is Point.)

IEnumerable<string>

layerFilter

One or more AutoCAD layer names to define a QUERYFILTER of the new feature class.

optional (The default is "*", which is all layers.)

Returns

TypeDescription

string

The new document feature layer name.

Remarks on error conditions

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

Example

Add a polyline document feature layer named Roads in which the entities that define the feature layer are on the AutoCAD STREETS layer, and print its name.

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

// Add the document feature layer
var layerFilter = new List<string> { "STREETS" };
var newDfl = Esri.ArcGISForAutoCAD.DocFeatureLayer.Add(doc, "Roads", "Polyline", layerFilter);

// Print the document feature layer name
doc.Editor.WriteMessage(newDflName);

/* Example output
Roads
*/

See also

WebFeatureLayer.AddAsync—A .NET method that adds a new web feature layer with an optional filtering query.

DocFeatureLayer.SetQuery—A .NET method that modifies the QUERYFILTER value of an existing document feature layer.

esri_docfeaturelayer_add—An AutoLISP function that adds a document feature layer definition to the drawing.