TextColor Property (ActiveX)

Specifies the color of the text for dimension and tolerance objects.

Supported platforms: Windows only

Signature

VBA:

object.TextColor
object

Type: Dim3PointAngular, DimAligned, DimAngular, DimArcLength, DimDiametric, Dimension, DimOrdinate, DimRadial, DimRadialLarge, DimRotated, MLeaderStyle, Tolerance

The objects this property applies to.

Property Value

Read-only: No

Type: acColor enum

Use a color index number from 0 to 256, or one of the constants listed here:

Remarks

Colors can be set and read as numeric index values ranging from 0 to 256. Constants have been provided for the standard seven colors, as well as the BYBLOCK and BYLAYER designations.

If you use acByBlock, AutoCAD draws new objects in the default color (white or black, depending on your configuration) until they are grouped into the block. When the block is inserted in the drawing, the objects in the block inherit the current setting of the color property.

If you use acByLayer, new objects assume the color of the layer upon which they are drawn.

Note: This property overrides the value of the DIMCLRT system variable for the given dimension or tolerance object.

Examples

VBA:

Sub Example_TextColor()
   ' This example creates an aligned dimension in model space and
   ' uses the TextColor property to toggle the dimension text color to red

    Dim dimObj As AcadDimAligned
    Dim point1(0 To 2) As Double, point2(0 To 2) As Double
    Dim location(0 To 2) As Double
    
    ' Define the dimension
    point1(0) = 5: point1(1) = 5: point1(2) = 0
    point2(0) = 7: point2(1) = 5: point2(2) = 0
    location(0) = 5: location(1) = 7: location(2) = 0
    
    ' Create an aligned dimension object in model space
    Set dimObj = ThisDrawing.ModelSpace.AddDimAligned(point1, point2, location)
    ThisDrawing.Application.ZoomAll

    ' Read and display current dimension text color
    MsgBox "The dimension text color for this object is currently set to: " & dimObj.TextColor

    ' Change the dimension text color
    dimObj.TextColor = acRed
    ThisDrawing.Regen acAllViewports
    
    ' Read and display current dimension text color
    MsgBox "The dimension text color for this object is now set to: " & dimObj.TextColor & " (Red)"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_TextColor()
    ;; This example creates an aligned dimension in model space and
    ;; uses the TextColor property to toggle the dimension text color to red
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the dimension
    (setq point1 (vlax-3d-point 5 5 0)
          point2 (vlax-3d-point 7 5 0)
          location (vlax-3d-point 5 7 0))
    
    ;; Create an aligned dimension object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq dimObj (vla-AddDimAligned modelSpace point1 point2 location))
    (vla-ZoomAll acadObj)

    ;; Read and display current dimension text color
    (alert (strcat "The dimension text color for this object is currently set to: " (itoa (vla-get-TextColor dimObj))))

    ;; Change the dimension text color
    (vla-put-TextColor dimObj acRed)
    (vla-Regen doc acAllViewports)
    
    ;; Read and display current dimension text color
    (alert (strcat "The dimension text color for this object is now set to: " (itoa (vla-get-TextColor dimObj)) " (Red)"))
)