ContextMenu
- class omni.kit.widget.stage.ContextMenu
Bases:
object
Class for mananging context menu and menu items for the Stage widget.
Methods
__init__
()Creates the ContextMenu instance.
add_create_menu
(menu_dict)Adds the menu to the end of the stage context create menu.
add_menu
(menu_dict)Adds the menu to the end of the context menu.
Displays the dialog where users can select materials and bind to selected prims.
Binds the hovered material prim to selected prims.
Clears the default prim of the stage.
Collapses all hovered or selected prims.
collapse_to
(kind)Collapses the hovered or selected prims recursively if the kind matches the given Kind.
destroy
()Destroys the ContextMenu instance, resets the function list.
Expands all hovered or selected prims.
expand_to
(kind)Expands the hovered or selected prims recursively if the kind matches the given Kind.
Checks if the selected prim is the default prim of the stage.
Checks whether there's a provided rename function in the current context object.
Checks if the hoved prim is a USD Material prim.
Checks if the selected prim is active.
Checks if the selected prim is NOT active.
Checks if the selected prim is at the root level of the stage.
link_selected
(layer_identifier, hierarchy, ...)Lock or unlink selected prims.
lock_selected
(hierarchy, objects)Lock or unlock selected prims.
Checks if the selected prim is NOT the default prim of the stage.
on_mouse_event
(event)ContextMenuEvent handler for the current context menu.
Runs the provided 'rename_item' function on a prim.
Select all linked prims in the current usd context.
Select all locked prims in the current usd context.
Sets the (first) selected prim as the default prim of the stage.
If the collapsion related context menu items should be shown for the (first) selected prim.
Builds and shows the "Create" and "Add" menu.
If the expansion related context menu items should be shown for the (first) selected prim.
- __init__()
Creates the ContextMenu instance.
- static add_create_menu(menu_dict)
Adds the menu to the end of the stage context create menu. Returns the MenuSubscription object that should be alive all the time. Once the returned object is destroyed, the added menu will be destroyed as well.
- Parameters
menu_dict – A dictionary containing menu settings. See ContextMenuExtension docs for information on values.
- Returns
- MenuSubscription. Keep a copy of this as the custom menu will be removed when `release()` is explicitly
called or when this is garbage collected.
- static add_menu(menu_dict)
Adds the menu to the end of the context menu. Returns the MenuSubscription object that should be alive all the time. Once the returned object is destroyed, the added menu will be destroyed as well.
- Parameters
menu_dict – A dictionary containing menu settings. See ContextMenuExtension docs for information on values.
- Returns
- MenuSubscription. Keep a copy of this as the custom menu will be removed when `release()` is explicitly
called or when this is garbage collected.
- bind_material_to_prim_dialog()
Displays the dialog where users can select materials and bind to selected prims. Will not show the dialog if no prims are selected.
- Parameters
objects (Dict) – The context object.
- bind_material_to_selected_prims()
Binds the hovered material prim to selected prims. If either the hovered prim or the prim list is empty, no operation will be done.
- Parameters
objects (Dict) – The context object.
- clear_default_prim()
Clears the default prim of the stage.
- Parameters
objects (Dict) – The context object.
- collapse_all()
Collapses all hovered or selected prims.
- Parameters
objects (Dict) – The context object.
- collapse_to(kind)
Collapses the hovered or selected prims recursively if the kind matches the given Kind.
- Parameters
objects (Dict) – The context object.
kind (str) – The USD Kind to collapse.
- destroy()
Destroys the ContextMenu instance, resets the function list.
- expand_all()
Expands all hovered or selected prims.
- Parameters
objects (Dict) – The context object.
- expand_to(kind)
Expands the hovered or selected prims recursively if the kind matches the given Kind.
- Parameters
objects (Dict) – The context object.
kind (str) – The USD Kind to collapse.
- has_default_prim()
Checks if the selected prim is the default prim of the stage. If the prim selection is not a single prim (eg. empty selection or multiple selected), returns False. If the stage doesn’t have a default prim, also returns False.
- Parameters
objects (Dict) – The context object.
- Returns
Whether the selected prim is the default prim. If the prim selection is not a single prim, returns False.
- Return type
bool
- has_rename_function()
Checks whether there’s a provided rename function in the current context object.
- Parameters
objects (Dict) – The context object.
- Returns
True if ‘rename_item’ is in function list
- Return type
bool
- is_hovered_prim_material()
Checks if the hoved prim is a USD Material prim. If no hovered prim detected, returns False.
- Parameters
objects (Dict) – The context object.
- Returns
Whether the hovered prim is a USD Material prim. If no hovered prim detected, returns False.
- Return type
bool
- is_prim_active()
Checks if the selected prim is active. If the prim selection is not a single prim (eg. empty selection or multiple selected), returns False.
- Parameters
objects (Dict) – The context object.
- Returns
Whether the selected prim is active. If the prim selection is not a single prim, returns False.
- Return type
bool
- is_prim_not_active()
Checks if the selected prim is NOT active. If the prim selection is not a single prim (eg. empty selection or multiple selected), returns True.
- Parameters
objects (Dict) – The context object.
- Returns
Whether the selected prim is NOT active. If the prim selection is not a single prim, returns True.
- Return type
bool
- is_prim_sudo_root()
Checks if the selected prim is at the root level of the stage. If the prim selection is not a single prim (eg. empty selection or multiple selected), returns False.
- Parameters
objects (Dict) – The context object.
- Returns
Whether the selected prim is at root level. If the prim selection is not a single prim, returns False.
- Return type
bool
- link_selected(layer_identifier, hierarchy, objects)
Lock or unlink selected prims.
- Parameters
link_or_unlink (bool) – Links the spec paths if True, else the operation is unlink.
layer_identifiers (Union[str, List[str]]) – List of layer identifiers or single layer identifier.
hierarchy (bool) – Linking/Unlinking descendant specs or not.
objects – The context object.
- lock_selected(hierarchy, objects)
Lock or unlock selected prims.
- Parameters
lock_or_unlock (bool) – Locks the spec paths if True, else the operation is unlock.
hierarchy (bool) – Locking/Unlocking descendant specs or not.
objects – The context object.
- no_default_prim()
Checks if the selected prim is NOT the default prim of the stage. If the prim selection is not a single prim (eg. empty selection or multiple selected), returns True. If the stage doesn’t have a default prim, also returns True.
- Parameters
objects (Dict) – The context object.
- Returns
- Whether the selected prim is NOT the default prim. If the prim selection is not a single prim,
returns False.
- Return type
bool
- on_mouse_event(event)
ContextMenuEvent handler for the current context menu.
- Parameters
event (omni.kit.widget.stage.stage_delegate.ContextMenuEvent) – The incoming ContextMenuEvent. It contains information of the stage, prim path and node expansion status in its payload.
- rename_prim()
Runs the provided ‘rename_item’ function on a prim. If the prim list provided in the context is empty or of multiple prims, it returns False without applying any rename function.
- Parameters
objects (Dict) – The context object.
- Returns
- False if the prim list provided is empty or is of multiple prims. Otherwise if a rename
function is provided, it will run the function without returning.
- Return type
Optional[bool]
- select_linked_prims()
Select all linked prims in the current usd context.
- Parameters
objects (Dict) – The context object. Unused.
- select_locked_prims()
Select all locked prims in the current usd context.
- Parameters
objects (Dict) – The context object. Unused.
- set_default_prim()
Sets the (first) selected prim as the default prim of the stage.
- Parameters
objects (Dict) – The context object.
- show_close_tree()
If the collapsion related context menu items should be shown for the (first) selected prim. If the prim is a light or camera and doesn’t have multiple children, items should not be shown. Otherwise, if the prim doesn’t have any children, items should not be shown. If the current prim’s associated tree node item is open, then items should be shown.
- Args:
objects (Dict): The context object.
- Returns
Whether the collapsion related context menu items should be shown for the (first) selected prim.
- Return type
bool
- show_create_menu()
Builds and shows the “Create” and “Add” menu.
- Parameters
objects (Dict) – The context object.
- show_open_tree()
If the expansion related context menu items should be shown for the (first) selected prim. If the prim is a light or camera and doesn’t have multiple children, items should not be shown. Otherwise, if the prim doesn’t have any children, items should not be shown. If the current prim’s associated tree node item is open, then items should not be shown.
- Args:
objects (Dict): The context object.
- Returns
Whether the expansion related context menu items should be shown for the (first) selected prim.
- Return type
bool