MaterialBindingWidget

class omni.kit.property.material.scripts.widgets.material_binding.material_binding_widget.MaterialBindingWidget(extension_path: Optional[str] = None, add_context_menu=False, title='Materials on selected models', material_purpose='', filter_fn=None, get_materials_async_fn=None, **kwargs)

Bases: SimplePropertyWidget

A widget designed to bind materials to selected USD prims.

This widget facilitates the association of materials to prims in USD stages by providing a user interface for selection and assignment. It supports context menus, search functionality, thumbnail previews, and asynchronous material retrieval.

Parameters
  • extension_path (Optional[str]) – The path where the extension is located. Used for loading icons and other resources.

  • add_context_menu (bool) – Indicates whether to add a context menu to the widget.

  • title (str) – The title of the widget.

  • material_purpose (str) – The purpose of the material (e.g., ‘allPurpose’, ‘preview’, etc.).

  • filter_fn (Optional[callable]) – A function used to filter materials.

  • get_materials_async_fn (Optional[callable]) – An asynchronous function to retrieve materials.

Keyword Arguments
  • collapsed (bool) – Specifies whether the widget is initially collapsed.

  • collapsable (bool) – Specifies whether the widget is collapsible.

  • enable_bound_widget (bool) – Enables the display of the bound widget.

  • enable_strength_widget (bool) – Enables the display of the material strength widget.

Methods

__init__([extension_path, add_context_menu, ...])

Initializes a new instance of the MaterialBindingWidget.

bind_material_to_prims(bind_material_path, items)

Binds a material to prims.

build_bound_widget(type_label, prim_style, ...)

Builds a widget showing the bound type and prims.

build_items()

Builds the items for the widget based on the current payload.

build_strength_widget(strength_value, ...)

Builds a widget for adjusting material binding strength.

build_thumbnail_widget(style_name, ...)

Builds a thumbnail widget.

clean()

Cleans up the widget's resources.

get_on_dragdrop_callback()

Gets a callback for handling drag and drop operations.

get_on_material_changed_callback(material_list)

Gets a callback for when the material selection changes.

get_on_material_goto_callback()

Gets a callback for navigating to a material.

get_on_strength_changed_callback()

Gets a callback for when the material strength changes.

on_new_payload(payload)

Handles a new payload for the widget.

reset()

Resets the widget to its initial state.

Attributes

EXTENSION_PATH

Path for extension-specific resources.

__init__(extension_path: Optional[str] = None, add_context_menu=False, title='Materials on selected models', material_purpose='', filter_fn=None, get_materials_async_fn=None, **kwargs)

Initializes a new instance of the MaterialBindingWidget.

bind_material_to_prims(bind_material_path, items)

Binds a material to prims.

Parameters
  • bind_material_path (str) – Path of the material to bind.

  • items (List[Tuple]) – List of items to bind the material to.

build_bound_widget(type_label, prim_style, bound_prims)

Builds a widget showing the bound type and prims.

Parameters
  • type_label (str) – Label indicating the type (Prim or Collection).

  • prim_style (str) – Style of the primary label.

  • bound_prims (str) – Label showing the bound prims or collections.

build_items()

Builds the items for the widget based on the current payload.

build_strength_widget(strength_value, on_strength_fn)

Builds a widget for adjusting material binding strength.

Parameters
  • strength_value (str) – Initial strength value.

  • on_strength_fn (callable) – Function to call when strength is changed.

build_thumbnail_widget(style_name, material_path, index)

Builds a thumbnail widget.

Parameters
  • style_name (str) – Style name for the thumbnail widget.

  • material_path (str) – Path of the material for the thumbnail.

  • index (int) – Index of the thumbnail in the list.

Returns

A UI button with the thumbnail image.

Return type

ui.Button

clean()

Cleans up the widget’s resources.

get_on_dragdrop_callback()

Gets a callback for handling drag and drop operations.

Returns

A callback function.

Return type

callable

get_on_material_changed_callback(material_list)

Gets a callback for when the material selection changes.

Parameters

material_list (List[str]) – List of available materials.

Returns

A callback function.

Return type

callable

get_on_material_goto_callback()

Gets a callback for navigating to a material.

Returns

A callback function.

Return type

callable

get_on_strength_changed_callback()

Gets a callback for when the material strength changes.

Returns

A callback function.

Return type

callable

on_new_payload(payload)

Handles a new payload for the widget.

Parameters

payload (Dict) – The new payload to be handled by the widget.

Returns

True if the payload is valid and handled; False otherwise.

Return type

bool

reset()

Resets the widget to its initial state.

EXTENSION_PATH = None

Path for extension-specific resources.

Type

Optional[str]