TfTokenAttributeModel#
- class omni.kit.property.usd.TfTokenAttributeModel(
- stage: Stage,
- attribute_paths: List[Path],
- self_refresh: bool,
- metadata: dict,
- **kwargs,
Bases:
AbstractItemModel,UsdBaseA model for managing USD attributes of type ‘TfToken’.
This model allows for the interaction and manipulation of TfToken attributes within a USD stage. It keeps track of allowed tokens and provides functionality for selecting and updating the value of the attribute based on the allowed set of tokens.
- Parameters:
stage (
Usd.Stage) – The USD stage where the attribute is located.attribute_paths (List[
Sdf.Path]) – The list of attribute paths to be managed by the model.self_refresh (bool) – A flag indicating whether the model should automatically update itself when changes occur.
metadata (dict) – A dictionary containing metadata associated with the attribute.
- Keyword Arguments:
change_on_edit_end (bool) – A flag indicating whether the model should only apply changes when an edit ends.
ambiguous (bool) – A flag indicating whether the attribute has ambiguous values (true for multi-selection).
treat_as_asset_path (bool) – A flag indicating if the attribute should be treated as an asset path.
treat_array_entry_as_comp (bool) – A flag indicating whether array entries should be treated as components.
allowed_tokens (List[str]) – A list of strings representing the allowed tokens for the attribute.
The model is a combination of ui.AbstractItemModel and UsdBase, which allows for both UI interaction and underlying USD functionality.
Methods
__init__(stage, attribute_paths, ...)Initializer for TfTokenAttributeModel.
begin_edit([item])Begins an edit operation on the model.
clean()Cleans up the model, removing any cached data.
end_edit([item])Ends an edit operation on the model.
get_item_children(item)Retrieves the children of a given item in the model.
get_item_value_model(item, column_id)Gets the value model associated with a given item and column.
Retrieves the current value as a token.
is_allowed_token(token)Checks if a token is allowed in the model.
set_value(value[, comp])Sets the value of the model.
Attributes
Represents a duplicate token, used when ui.Combobox's have duplicate items.
- __init__(
- stage: Stage,
- attribute_paths: List[Path],
- self_refresh: bool,
- metadata: dict,
- **kwargs,
Initializer for TfTokenAttributeModel.
- begin_edit(item=None)#
Begins an edit operation on the model.
- Parameters:
item – The item being edited.
- clean()#
Cleans up the model, removing any cached data.
- end_edit(item=None)#
Ends an edit operation on the model.
- Parameters:
item – The item that was edited.
- get_item_children(item)#
Retrieves the children of a given item in the model.
- Parameters:
item – The item whose children are to be retrieved.
- Returns:
A list of the allowed tokens.
- Return type:
list
- get_item_value_model(item, column_id)#
Gets the value model associated with a given item and column.
- Parameters:
item – The item for which to retrieve the value model.
column_id (int) – The column identifier.
- Returns:
The value model for the specified item and column.
- Return type:
ui.AbstractValueModel
- get_value_as_token()#
Retrieves the current value as a token.
- Returns:
The current value as a token or None if the current index is not valid.
- Return type:
str
- is_allowed_token(token)#
Checks if a token is allowed in the model.
- Parameters:
token (str) – The token to check.
- Returns:
True if the token is allowed, False otherwise.
- Return type:
bool
- set_value(value, comp: int = -1) bool#
Sets the value of the model.
- Parameters:
value (str) – The value to set in the model.
comp (int) – An optional component index when dealing with vector types.
- DUPLICATE_TAG = '** DUPLICATE **'#
Represents a duplicate token, used when ui.Combobox’s have duplicate items.
- Type:
str