Go to: Synopsis. Return value. Keywords. Flags. Python examples.

Synopsis

displayString([string][string][string][string], [delete=boolean], [exists=boolean], [keys=boolean], [replace=boolean], [value=string])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

displayString is NOT undoable, queryable, and NOT editable.

Assign a string value to a string identifier. Allows you define a string in one location and then refer to it by its identifier in many other locations. Formatted strings are also supported (NOTE however, this functionality is now provided in a more general fashion by the format command, use of format is recommended). You may embed up to 3 special character sequences ^1s, ^2s, and ^3s to perform automatic string replacement. The embedded characters will be replaced with the extra command arguments. See example section for more detail. Note the extra command arguments do not need to be display string identifiers.

Return value

None

In query mode, return type is based on queried flag.

Keywords

display, string

Flags

delete, exists, keys, replace, value
Long name (short name) Argument types Properties
delete(d) boolean create
This flag is used to remove an identifer string. The command will fail if the identifier does not exist.
exists(ex) boolean create
Returns true or false depending upon whether the specified identifier exists.
keys(k) boolean createquery
List all displayString keys that match the identifier string. The identifier string may be a whole or partial key string. The command will return a list of all identifier keys that contain this identifier string as a substring.
replace(r) boolean createquery
Since a displayString command will fail if it tries to assign a new value to an existing identifer, this flag is required to allow updates to the value of an already-existing identifier. If the identifier does not already exist, a new identifier is added as if the -replace flag were not present.
value(v) string createquery
The display string\'s value. If you do not specify this flag when creating a display string then the value will be the same as the identifier.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

#    Associate a string with an identifier.
#
cmds.displayString( 'kExampleHelloWorld', value='Hello world' )
#    Query string associated with an identifer.
#
cmds.displayString( 'kExampleHelloWorld', query=True, value=True )
#    Define a simple formatted string to append ellipses.
#
cmds.displayString( 'kExampleEllipsesFormat', value='^1s...' )
cmds.displayString( 'kExampleEllipsesFormat', 'kExampleHelloWorld', query=True, value=True )
#    Define a formatted string using all the available
#    embedded characters.
#
cmds.displayString( 'kExampleAnotherFormat', value='These ^1s are ^2s me ^3s' )
cmds.displayString( 'kExamplePretzels', value='pretzels' )
cmds.displayString( 'kExampleAnotherFormat', 'kExamplePretzels', 'making', 'thirsty', query=True, value=True )
# Obtain a list of matching displayString keys.
# In the first example  a list of  all keys containing the substring
# "niceName".
# In the second example a list of all keys in the string set
# m_testStrings
cmds.displayString( 'niceName', query=True, keys=True )
cmds.displayString( 'm_testStrings.', query=True, keys=True )
#    If you do not specify the -v/value flag on creating then
#    the value will be the same as the identifier.
#
cmds.displayString( 'kExampleMissingValue' )
cmds.displayString( 'kExampleMissingValue', query=True, value=True )