ChimeraX docs icon

Command: setattr

Usage:
setattr  spec   level  attr-name   value  [ create  true | false ] [ type  color | boolean | integer | float | string ]

Setattr is a general, multipurpose attribute-setting command. It sets an attribute named attr-name (existing or new) of the specified items at the indicated level to a single user-supplied value. Following the usual convention, a blank specification means “all.” A new attribute will not be created unless create is true (default false). Whereas setattr assigns only a single value per command, many values can be assigned at once by reading a separately generated attribute assignment file with the open command. See also: info, the custom preset example, amino acid hydrophobicity, Selection Inspector

The level can be any one of the following:

The attr-name may include upper- and lower-case letters, numbers (digits), and underscores, but cannot start with a digit.

If the type option is omitted, the data type will be guessed as follows:

  1. If attr-name ends in “color,” value will be interpreted as a color specifier.
  2. If value is given as true or false (exactly as shown, not truncated), it will be interpreted as Boolean.
  3. Otherwise, an attempt will be made to parse value first as an integer, then as a floating-point (real) number, then as a character string.

If the type is given as boolean, value can be truncated, with synonyms for true: True, 1, and synonyms for false: False, 0.

Although setattr does not restrict which attributes it can affect, using it for certain attributes may not make sense. For example, a simpler command may already exist to perform the same task:

setattr /a res ribbon_color orange
– is equivalent to –
color /a orange targ r

UCSF Resource for Biocomputing, Visualization, and Informatics / February 2022