Skip To Content

FeatureLabel.Generate (.NET)

The FeatureLabel.Generate method generates labels for the features of the specified feature layer using values from the specified attribute field. Optional parameters can be used to offset the text and override the default text size. You can link feature attribute field values to most types of feature attribute fields. You cannot link reporting fields to text or block attribute values.

Declaration

public bool Esri.ArcGISForAutoCAD.FeatureLabel.Generate(Document doc, string flName, string fieldName, IEnumerable<double> offset = null, double textSize = 5)

Parameters

TypeNameDescriptionRequired

Document

doc

The AutoCAD document to act on.

required

string

flName

An existing feature layer name in the drawing.

required

string

fieldName

The feature attribute field name source for the label.

required

IEnumerable<double>

offset

A collection of three doubles that includes the offset distance from the standard label point in the x-direction, y-direction, and z-direction.

optional

double

textSize

The text size of the new text labels to be generated.

optional (The default is 5.)

Returns

TypeDescription

bool

true if the labels were generated successfully.

Remarks on error conditions

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

Example

Print the success of generating labels for the Owner field of the Parcels feature layer in which the text is offset 10 units up and to the right of the default label point with a text size of 7 units.

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var offset = new List<double> { 10, 10, 0 };

// Generate labels
var success = Esri.ArcGISForAutoCAD.FeatureLabel.Generate(doc, "Parcels", "Owner", offset, 7);

// Print the success
doc.Editor.WriteMessage(success.ToString());
        
/* Example output 
True
*/

See also

esri_label_generate—An AutoLISP function that generates feature attribute labels.