attr
[get] [set] [rm] [append] [list] [show] [sort] [copy] {object_name_pattern
} [arguments
]
Used to create, change, retrieve, or view attributes of database objects. Note that the attribute names may not contain embedded white space, and if attribute values contain embedded white space, they must be surrounded by {} or double quotes.
A newly formed region always has four attributes automatically assigned to it:
los
material_id
region
region_id
The 'region' attribute is the 'region flag' mentioned in the edcomb command.
Retrieve and display the specified attributes from the object or objects matched by the pattern. The arguments for the "get" sub-command are attribute names. If no arguments are provided all attributes are displayed.
Assigned the value provided for the specified attribute to the object or objects matched by the pattern. The arguments for "set" sub-command are attribute name/value pairs.
Removes the specified attribute from the object or objects matched by the pattern. The arguments for the "rm" sub-command are attribute names.
Adds the attribute and value provied for the specified attribute to the object or objects matched by the pattern, or sets the value if the attribute already exists. The arguments for the "append" sub-command are attribute name/value pairs.
Lists the attributes assigned to the object or objects matched by the pattern. If multiple objects are matched, the list returned is a consolidated list of all attribute types present on one or more of the matched objects. This option is useful when investigating what attributes are present in objects in a database.
Optionally, the list subcommand will accept filters that are used to match key or key/value combinations and report only those matches. If both key and value filters are supplied, the output of the list subcommand will be not just the unique matching attribute keys but the unique matching key/value pairs. The latter is particularly useful as a way to get an overview of all actively used values associated with a particular attribute key.
Pretty print the specified attributes for the object or objects matching the pattern. If no attributes are listed, all attributes are printed for each object. The arguments for the "rm" sub-command are attribute names.
Pretty prints all attributes on each object matched by the pattern. Attributes are sorted into alphabetical order before printing. The arguments for the "sort" sub-command set the sort type for the attributes: 'case' (default), 'nocase', 'value', and 'value-nocase'.
Takes the value of the first attribute from the specified object and set the second attribute on the object to that value. The sequence of "attr copy" and "attr rm" can be used to rename attributes on objects.
The examples demonstrate the use of the attr command and subcommands to assign and list attributes of database objects.
Example 1. Assigns an attribute to an object.
mged>
attr set region_1 material_id 10
Assigns an attribute name "material_id" to region_1. Its value is 10.
Example 2. Assigns an attribute (with embedded white space in its value) to an object.
mged>
attr set region_1 comment {This is a comment for region_1}
Assigns an attribute named "comment" to region_1. Its value is "This is a comment for region_1."
Example 3. List all the attributes for an object
mged>
attr show region_1 comment
Lists all the attributes for region_1.
Example 4. List all the attribute types present on one or more objects in a database
mged>
attr list *
aircode
los
material_id
oshader
region
region_id
regionid_colortable
rgb
shader
title
units
Generate a list of all attribute keys found one one or more objects in the database. It may be necessary to place a '\' character before the asterisk to quote it on the MGED tcl prompt so that it reaches the attr command unexpanded. The above output is the attribute list from the m35.g sample database.
Example 5. List all the material_id attribute values in use in a database
mged>
attr list * material_id *
material_id=1
material_id=2
material_id=4
material_id=7
material_id=8
material_id=14
material_id=17
material_id=18
material_id=19
material_id=20
Produces a list of all material_id values found one or more times in the database on an object. It may be necessary to place a '\' character before the asterisks to quote them on the MGED tcl prompt so that they reaches the attr command correctly. The above output is the attribute list from the m35.g sample database.
This software is Copyright (c) 2008-2020 United States Government as represented by the U.S. Army Research Laboratory.
Reports of bugs or problems should be submitted via electronic
mail to <devs@brlcad.org>