omni.kit.actions.core

User Guide

API Reference

Omni Kit Actions Core

Omni Kit Actions Core is a framework for creating, registering, and discovering actions.

Here is an example of registering an action that creates a new file when it is executed:

action_registry = omni.kit.actions.core.get_action_registry()
actions_tag = "File Actions"

action_registry.register_action(
    extension_id,
    "new",
    omni.kit.window.file.new,
    display_name="File->New",
    description="Create a new USD stage.",
    tag=actions_tag,
)

For more examples, please consult the Python and C++ Usage Example pages.

For Python API documentation, please consult the following subpages.

For C++ API documentation, please consult the API(C++) page.

class omni.kit.actions.core.Action

Bases: pybind11_object

Abstract action base class.

property description

Get the description of this action.

Returns

The description of this action.

Return type

str

property display_name

Get the display name of this action.

Returns

The display name of this action.

Return type

str

execute(self: omni.kit.actions.core._kit_actions_core.Action, *args, **kwargs) object

Execute the action.

Parameters
  • *args – Variable length argument list which will be forwarded to execute.

  • **kwargs – Arbitrary keyword arguments that will be forwarded to execute.

Returns

The result of executing the action, converted to a Python object (could be None).

property extension_id

Get the id of the source extension which registered this action.

Returns

The id of the source extension which registered this action.

Return type

str

property icon_url

Get the URL of the icon used to represent this action.

Returns

The URL of the icon used to represent this action.

Return type

str

property id

Get the id of this action, unique to the extension that registered it.

Returns

The id of this action, unique to the extension that registered it.

Return type

str

invalidate(self: omni.kit.actions.core._kit_actions_core.Action) None

Invalidate this action so that executing it will not do anything. This can be called if it is no longer safe to execute the action, and by default is called when deregistering an action (optional).

property parameters

Get the parameters accepted by this action’s execute function.

Returns

The parameters accepted by this action’s execute function.

Return type

dict

property requires_parameters

Query whether this action requires any parameters to be passed when executed?

Returns

True if this action requires any parameters to be passed when executed, false otherwise.

Return type

bool

property tag

Get the tag that this action is grouped with.

Returns

The tag that this action is grouped with.

Return type

str

class omni.kit.actions.core.IActionRegistry

Bases: pybind11_object

Maintains a collection of all registered actions and allows any extension to discover them.

deregister_action(*args, **kwargs)

Overloaded function.

  1. deregister_action(self: omni.kit.actions.core._kit_actions_core.IActionRegistry, action: omni::kit::actions::core::IAction, invalidate: bool = True) -> None

    Deregister an action.

    Args:

    action: The action to deregister. invalidate: Should the action be invalidated so executing does nothing?

  2. deregister_action(self: omni.kit.actions.core._kit_actions_core.IActionRegistry, extension_id: str, action_id: str, invalidate: bool = True) -> omni::kit::actions::core::IAction

    Find and deregister an action.

    Args:

    extension_id: The id of the source extension that registered the action. action_id: Id of the action, unique to the extension that registered it. invalidate: Should the action be invalidated so executing does nothing?

    Return:

    The action if it exists and was deregistered, an empty object otherwise.

deregister_all_actions_for_extension(self: omni.kit.actions.core._kit_actions_core.IActionRegistry, extension_id: str, invalidate: bool = True) None

“Deregister all actions that were registered by the specified extension.

Parameters
  • extension_id – The id of the source extension that registered the actions.

  • iinvalidate – Should the actions be invalidated so executing does nothing?

execute_action(self: omni.kit.actions.core._kit_actions_core.IActionRegistry, extension_id: str, action_id: str, *args, **kwargs) object

Find and execute an action.

Parameters
  • extension_id – The id of the source extension that registered the action.

  • action_id – Id of the action, unique to the extension that registered it.

  • *args – Variable length argument list which will be forwarded to execute.

  • **kwargs – Arbitrary keyword arguments that will be forwarded to execute.

Returns

The result of executing the action, which is an arbitrary Python object that could be None (will also return None if the action was not found).

get_action(self: omni.kit.actions.core._kit_actions_core.IActionRegistry, extension_id: str, action_id: str) omni::kit::actions::core::IAction

Get an action.

Parameters
  • extension_id – The id of the source extension that registered the action.

  • action_id – Id of the action, unique to the extension that registered it.

Returns

The action if it exists, an empty object otherwise.

get_all_actions(self: omni.kit.actions.core._kit_actions_core.IActionRegistry) List[omni::kit::actions::core::IAction]

Get all registered actions.

Returns

All registered actions.

get_all_actions_for_extension(self: omni.kit.actions.core._kit_actions_core.IActionRegistry, extension_id: str) List[omni::kit::actions::core::IAction]

Get all actions that were registered by the specified extension.

Parameters

extension_id – The id of the source extension that registered the actions.

Returns

All actions that were registered by the specified extension.

register_action(*args, **kwargs)

Overloaded function.

  1. register_action(self: omni.kit.actions.core._kit_actions_core.IActionRegistry, action: omni::kit::actions::core::IAction) -> None

    Register an action.

    Args:

    action: The action to register.

  2. register_action(self: omni.kit.actions.core._kit_actions_core.IActionRegistry, extension_id: str, action_id: str, python_object: object, display_name: str = ‘’, description: str = ‘’, icon_url: str = ‘’, tag: str = ‘’) -> omni::kit::actions::core::IAction

    Create and register an action.

    Args:

    extension_id: The id of the source extension registering the action. action_id: Id of the action, unique to the extension registering it. python_object: The Python object called when the action is executed. display_name: The name of the action for display purposes. description: A brief description of what the action does. icon_url: The URL of an image which represents the action. tag: Arbitrary tag used to group sets of related actions.

    Return:

    The action if it was created and registered, an empty object otherwise.

omni.kit.actions.core.execute_action(extension_id: str, action_id: str, *args, **kwargs)

Find and execute an action.

Parameters
  • extension_id – The id of the source extension that registered the action.

  • action_id – Id of the action, unique to the extension that registered it.

  • *args – Variable length argument list which will be forwarded to execute.

  • **kwargs – Arbitrary keyword arguments that will be forwarded to execute.

Returns

The result of executing the action, which is an arbitrary Python object that could be None (will also return None if the action was not found).

omni.kit.actions.core.get_action_registry() IActionRegistry

Get the action registry.

Returns

ActionRegistry object which implements the IActionRegistry interface.