Skip To Content

FieldDefinition.Add (.NET)

The FieldDefinition.Add method adds a new field definition to an existing document feature layer.

Note:

You cannot modify field definitions of a web feature layer.

Declaration

public string Esri.ArcGISForAutoCAD.FieldDefinition.Add(Document doc, string flName, string name, string type = "String", int length = 254, IConvertible value = null, bool readOnly = false)

Parameters

TypeNameDescriptionRequired

Document

doc

The AutoCAD document to act on.

required

string

flName

An existing document feature layer name in the drawing.

required

string

name

The new field name.

required

string

type

The field type value: "Double", "Short", "GUID", "Integer", "String", "Float", or "Date".

optional (default "String")

int

length

The length of the field.

optional

IConvertible

value

The default value of the field.

Note:

When working with fields that have coded domain values, value is the description, not the code.

optional

bool

readOnly

Specifies whether the new field is read-only.

optional (default false)

Returns

TypeDescription

string

The name of the new field.

Remarks on error conditions

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

Example

Add a short integer field named YearPurchased to the Parks feature layer and print the new field name.

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

// Add field definition
var addedField = Esri.ArcGISForAutoCAD.FieldDefinition.Add(doc, "Parks", "YearPurchased", "Short", 254, 1954);

// Print new field name
doc.Editor.WriteMessage("New field: " + addedField);

/* Example output
New field: YearPurchased
*/

See also

esri_fielddef_add—An AutoLISP function that adds a field definition.