Colors

AutoCAD Map 3D ObjectARX

 
Colors
 
 
 

Colors can be specified or returned as AutoCAD color indexes or true colors.

AutoCAD Color Indexes (ACIs)

The valid ACI formats are

Color Indexes, integer strings from 0 through 256. For example, "123". Note that indexes 0 and 256 do not specify colors literally, as 1 through 255 do, but logically. See "Logical Colors" below. And note that indexes 8 and 9 (a dark gray and a light gray), together with the named colors (see "Color Names" below), are collectively called the standard colors.

Color Names, which correspond to indexes 1 through 7. The color names are red, yellow, green, cyan, blue, magenta, and white. For example, "yellow" (always double-quoted). Note that index 7, the color named white, displays as white or black depending on background color.

Index Name
1 Red
2 Yellow
3 Green
4 Cyan
5 Blue
6 Magenta
7 White

Logical Colors, which correspond to indexes 0 and 256. The logical colors are ByBlock (0) and ByLayer (256), and they reflect the current block and layer colors respectively. For example, "ByBlock" (always double-quoted). Note that ByBlock and ByLayer can return true colors or ACIs.

For more information about ACIs,

  1. In AutoCAD Map 3D, click Format > Color.
  2. In the Select Color dialog box, click Help.

True Colors

By true colors we mean 24-bit color: three RGB components, 8 bits each, with no alpha component (that is, no transparency value).

The valid true-color formats are

RGB Triplets, where each component is an integer from 0 through 255. For example, "255,0,0". RGB triplets are wrapped in double quotes except when they are used in query conditions, in which case they must always be wrapped in escaped double quotes ('\"'). See "Color Patterns" below.

Color Book Colors, such as "Pantone, 123 CVC", a composite of two comma-separated names representing a Color Book and a color within it. Color book strings are wrapped in double quotes except when they are used in query conditions, in which case they must always be wrapped in escaped double quotes ('\"'). See "Color Patterns" below. And no matter where they are used, color book strings must always be wrapped in escaped double quotes if they contain certain special characters. If you are unsure if a color book string contains special characters, there is no harm wrapping it in escaped double quotes just to be sure.

Expressions, such as ".COLOR" or ".TRUECOLOR" (always double-quoted). ".COLOR" always returns an ACI color. If the selected object's color is a true color it returns the nearest ACI equivalent. ".TRUECOLOR" returns a true color if the selected object's color is a true color, or an ACI if its color is an ACI. Note that ".TRUECOLOR", and other expressions that can return true colors, return in valid format only if the type argument of (ade_expreval) is "string".

Color Patterns, comma-separated lists of colors in any of the valid formats, including ACI colors, always double-quoted. Color patterns are used to express multiple color conditions in compact format. Consider the color pattern "red, green". The pseudocode expression, color = "red,green", is logically equivalent to (color = "red") OR (color = "green"). Similarly, color <> "red,green" is logically equivalent to (color <> "red") AND (color <> "green"). Because color patterns are comma-separated lists, Color Book colors and RGB colors in query conditions are always bounded by escaped double quotes ('\"') because they are themselves comma-separated. For example, the following color pattern includes six colors: three ACIs, one RGB, and one Color Book color.

"12,34,56,\"12,34,56\",\"Pantone, 123 CVC\""

NoteNote You can use wildcard characters when you specify a match string for Color Book colors (but not for RGB colors). For this reason, any wildcard character in a Color Book string that is meant to be taken literally must be escaped using a backquote, "`". For example, the "." character in the following string, normally a wildcard matching any non-alphanumeric character, is meant as a literal: "My`.Colors, Hot".

Colors in Query Conditions

You can specify ACI colors in query conditions as color names or color indexes. But if you retrieve such conditions, ACI colors are always reported as color indexes, because that is how they are stored, even if they were originally specified as color names.

However, this is not the case with color patterns, which can include color indexes, color names, or both. If you retrieve a query condition where color is specified as a color pattern, the color pattern is reported as it was originally specified.