Extension: omni.kit.window.content_browser-2.9.18 |
Documentation Generated: Sep 11, 2024 |
Usage Examples
Cut and Paste Items
from omni.kit.window.content_browser.api import ContentBrowserAPI
# Instantiate the Content Browser API
content_browser_api = ContentBrowserAPI()
# Assume we have a file we want to cut and paste
file_path_to_cut = "my_file_to_cut.usd" # Replace with actual file path
# Perform the cut operation
content_browser_api.cut_selected_items()
# Assume we have a destination path to paste into
destination_path = "my_destination_folder/" # Replace with actual destination path
content_browser_api.navigate_to(destination_path)
# Perform the paste operation
content_browser_api.paste_items()
Copy and Paste Items
from omni.kit.window.content_browser.api import ContentBrowserAPI
# Instantiate the Content Browser API
content_browser_api = ContentBrowserAPI()
# Perform the copy operation
content_browser_api.copy_selected_items()
# Assume we have a destination path to paste into
destination_path = "my_destination_folder/" # Replace with actual destination path
content_browser_api.navigate_to(destination_path)
# Perform the paste operation
content_browser_api.paste_items()
Delete Selected Items
from omni.kit.window.content_browser.api import ContentBrowserAPI
# Instantiate the Content Browser API
content_browser_api = ContentBrowserAPI()
# Perform the delete operation
content_browser_api.delete_selected_items()
Rename Selected Item
from omni.kit.window.content_browser.api import ContentBrowserAPI
# Instantiate the Content Browser API
content_browser_api = ContentBrowserAPI()
# popup the rename dialog
content_browser_api.rename_selected_item()
Register File Open Handler
from omni.kit.window.content_browser.api import ContentBrowserAPI
# Instantiate the Content Browser API
content_browser_api = ContentBrowserAPI()
# Define a file open handler function
def my_open_handler(file_path):
print(f"Opening file: {file_path}")
# Register the file open handler
content_browser_api.add_file_open_handler("my_handler", my_open_handler, file_type=1) # Corrected with a valid file type constant
Deregister File Open Handler
from omni.kit.window.content_browser.api import ContentBrowserAPI
# Instantiate the Content Browser API
content_browser_api = ContentBrowserAPI()
# Name of the previously registered handler
handler_name = "my_handler"
# Deregister the file open handler
content_browser_api.delete_file_open_handler(handler_name)