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. In query mode, return type is based on queried flag.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
delete (d) | bool | ||
|
|||
exists (ex) | bool | ||
|
|||
keys (k) | bool | ||
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.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list. |
|||
replace (r) | bool | ||
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) | unicode | ||
|
Derived from mel command maya.cmds.displayString
Example:
import pymel.core as pm
import maya.cmds as cmds
# Associate a string with an identifier.
#
pm.displayString( 'kExampleHelloWorld', value='Hello world' )
# Query string associated with an identifer.
#
pm.displayString( 'kExampleHelloWorld', query=True, value=True )
# Define a simple formatted string to append ellipses.
#
pm.displayString( 'kExampleEllipsesFormat', value='^1s...' )
pm.displayString( 'kExampleEllipsesFormat', 'kExampleHelloWorld', query=True, value=True )
# Define a formatted string using all the available
# embedded characters.
#
pm.displayString( 'kExampleAnotherFormat', value='These ^1s are ^2s me ^3s' )
pm.displayString( 'kExamplePretzels', value='pretzels' )
pm.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
pm.displayString( 'niceName', query=True, keys=True )
pm.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.
#
pm.displayString( 'kExampleMissingValue' )
pm.displayString( 'kExampleMissingValue', query=True, value=True )