Skip To Content

Attributes.Get (.NET)

This method gets a dictionary of the field names and their attribute values.

  • If only the ArcGIS for AutoCAD ObjectId is provided, all attribute fields and their values stored on the entity are returned.
  • If the flName value is provided, only attributes belonging to that feature layer are included.
  • If both the flName and fieldName values are provided, only the stored value of the field or its default is returned, and only if it belongs to the feature layer.

Declaration

public Dictionary<string, IConvertible> Esri.ArcGISForAutoCAD.Attributes.Get(Document doc, ObjectId objId, string flName = null, string fieldName = null)

Parameters

TypeNameDescriptionRequired

Document

doc

The AutoCAD document to act on.

required

ObjectId

objId

The AutoCAD ObjectId of the feature.

required

string

flName

The feature layer name. It is assumed that the entity is a member of this feature layer and will only include field values for the specified feature layer. Default values are returned if no values are set.

required if fieldName is provided

string

fieldName

The single field name. The returned value is limited to this one field.

optional

Returns

TypeDescription

Dictionary<string, IConvertible>

A dictionary of field names and their attribute values. Key: Field name, Value: Attribute value.

Remarks on error conditions

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

Example 1

Print the Centerlines feature layer attributes for the designated entity.

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var flName = "Centerlines";
var objId = Esri.ArcGISForAutoCAD.FeatureLayer.SelectEntity(doc, flName);

// Get the attributes
var centerlinesAttributes = Esri.ArcGISForAutoCAD.Attributes.Get(doc, objId, flName);

// Print the attributes
foreach (var attribute in centerlinesAttributes)
{
  doc.Editor.WriteMessage("\nKey = {0}, Value = {1}", attribute.Key, attribute.Value);
}

/* Example output 
Key = EntityHandle, Value = 252
Key = EntityType, Value = LWPOLYLINE
Key = StreetName, Value = S Roosevelt Blvd
Key = Pavement, Value = 6
Key = Rating, Value = 0.6259
*/

Example 2

Print the single StreetName field value from the Centerlines feature layer for the designated entity.

// Initialize 
var doc = Application.DocumentManager.MdiActiveDocument;
var flName = "Centerlines";
var objId = Esri.ArcGISForAutoCAD.FeatureLayer.SelectEntity(doc, flName);

// Get the attribute from the single field
var streetNameAttribute = Esri.ArcGISForAutoCAD.Attributes.Get(doc, objId, flName, "StreetName");

// Print the street name
doc.Editor.WriteMessage("The street name is " + streetNameAttribute["StreetName"]);

/* Example output
The street name is Truman Avenue
*/

See also

FeatureLayer.GetAttributes—A .NET method that returns a collection of dictionaries of all the field names and values for all the features within the specified feature layer in the drawing.

FeatureLayer.SelectEntity —A .NET method that prompts for the selection of one entity and returns its AutoCAD ObjectId.

esri_attributes_get—An AutoLISP function that gets an associated list of the field names and their default attribute values.