ChimeraX docs icon

Command: setattr

setattr  spec   level  attr-name   value  [ create  true | false ]

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). See also: info, the custom preset example

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.

Regardless of whether the attribute already exists, the data type is discerned as follows:

  1. the value is parsed to identify data type in the order: Boolean, integer, floating-point (real), character string
  2. if the data type is character string and attr-name ends in “color,” the value is interpreted as a color specifier

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 / June 2019