Expressions in Annotations

AutoCAD Map 3D .NET API

 
Expressions in Annotations
 
 
 

Use expressions to set the text or the display properties of the annotation. Some of the items that can use expressions are:

  • Annotation text
  • Text color
  • Text size
  • Rotation angle
  • Position relative to the drawing object being annotated
NoteProperties in an attribute definition can be overridden by annotation expressions. For example, if the attribute definition defines the location of the text, the annotation expression could override it.

AnnotationTemplate.SetExpressionString() sets properties for the entire template. Annotations.SetExpressionString() sets properties for annotation text within the block.

Expressions are evaluated by the AutoLISP interpreter, and return a single value. Depending on the property being set, the value can be numeric or string. If the expression cannot be evaluated properly it displays the attribute tag name instead.

NoteFor more details about expressions, including a list of functions and variables, see the Map 3D Help. In the Reference Guide section there is a chapter about the Expression Evaluator.

The enum Annotation.AnnotationExpressionFields contains the complete list of fields that can use expressions.

In most cases, expressions are used to define the text of the annotation, but they can also be used to define things like color, size, or position.

Example

To set the annotation text based on object data, use the syntax :fieldname@tablename. For example:

Imports Autodesk.Gis.Map.Annotation
annotations.SetExpressionString(attDef, _
AnnotationExpressionFields.AttributeDefinitionAnnotationString, _
  ":PARCEL_OWNER@ParcelData")