The FeatureLabel.Set method adds or modifies the relationship between an attribute field of a feature and an AutoCAD TEXT, MTEXT, DIMENSION, or ATTDEF entity.
Keep the following in mind when using the FeatureLabel.Set method:
- If the label entity's text value is modified, the linked feature's attribute value is updated automatically.
- If the attribute value of the linked feature is modified, the value in the linked text entity is updated automatically.
- 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.
- Linked DIMENSION entities are read-only. The linked field value is derived from the DIMENSION text.
Declaration
public bool Esri.ArcGISForAutoCAD.FeatureLabel.Set(Document doc, string flName, string fieldName, ObjectId featureObjectId, ObjectId textObjectId)
Parameters
| Type | Name | Description | Required |
|---|---|---|---|
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 |
ObjectId | featureObjectId | The AutoCAD ObjectId of the feature to link to the specified text. | required |
ObjectId | textObjectId | The AutoCAD ObjectId of the text entity to link as a field attribute value. | required |
Returns
| Type | Description |
|---|---|
bool | true if the label was set 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 selecting a feature of the Parcels feature layer and a text entity to set the value of the Owner field.// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var flName = "Parcels";
var fieldName = "Owner";
var featureObjId = Esri.ArcGISForAutoCAD.FeatureLayer.SelectEntity(doc, flName);
var textObjId = doc.Editor.GetEntity(new PromptEntityOptions("\nSelect text entity: ")).ObjectId;
// Set the label
var success = Esri.ArcGISForAutoCAD.FeatureLabel.Set(doc, flName, fieldName, featureObjId, textObjId);
// Print the success
doc.Editor.WriteMessage(success.ToString());
/* Example output
True
*/
See also
esri_label_set—An AutoLISP function that adds or modifies the relationship between an attribute field of a feature and an AutoCAD TEXT, MTEXT, DIMENSION, or ATTDEFentity.