omni.flux.material_api#

Omni.Flux Material API

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

class omni.flux.material_api.placeholder_attribute.PlaceholderAttribute(name, prim=None, metadata=None)#

Bases: object

This is a placeholder for Usd.Attribute object as those objects have to be attached to a Usd.Prim object. This conforms to enough of the Usd.Attribute API to be used by omni.kit.property.usd widgets.

The purpose of this is so custom Usd.Attributes can be created and displayed by widgets but don’t actually effect the Usd.Prim until user modifies a value, then the CreateAttribute function will be called and a real Usd.Attribute will be created using values from this class.

CreateAttribute()#

Create the Usd.Attribute in the Usd.Prim

Get(time_code=0)#

Mock Usd.Attribute function

GetAllMetadata()#

Mock Usd.Attribute function

GetMetadata(token)#

Mock Usd.Attribute function

GetPath()#

Mock Usd.Attribute function

GetPrim()#

Mock Usd.Attribute function

GetPropertyStack(*args, **kwargs)#
HasAuthoredConnections()#

Mock Usd.Attribute function

IsHidden()#

Mock Usd.Attribute function

ValueMightBeTimeVarying()#

Mock Usd.Attribute function

This module defines the UsdShadePropertyPlaceholder class, which acts as a stand-in for Usd.Attribute for use in UsdShade widgets without serializing default properties and metadata to USD files.

class omni.flux.material_api.scripts.widgets.usdshade.placeholder.placeholder.UsdShadePropertyPlaceholder(
name: str,
metadata: dict | None,
from_sdr: bool = False,
)#

Bases: object

This class serves as a stand-in for Usd.Attribute within the context of various UsdShade widgets.

By default, the UsdPropertiesWidget widget is driven by Usd.Attributes, and if we want to display properties for a prim, then those properties need to exist on the stage. This is problematic for UsdShade properties as we don’t want to serialize properties whose values have not been changed from their default. We also don’t want to serialize all of the corresponding metadata these properties may contain, doing so results in unnecessarily bloated USD files. Therefore, this class can serve as a stand-in. It contains all of the necessary functions required by the UI widgets and allows us to display all of the parameters for a UsdShade.Shader that are defined via an Sdr.ShaderNode definition without having to store them on the stage and/or session layer first. These objects also provide a convenient means for overwriting metadata used to drive the display without having to serialize.

Parameters:
  • name (str) – The name of the property.

  • metadata (Union[dict | None]) – The metadata associated with the property.

  • from_sdr (bool) – Indicates whether the property is from SDR.

FromSdr() bool#

Indicates if the property placeholder was created from an Sdr node.

Returns:

True if created from Sdr, False otherwise.

Return type:

bool

GetAllMetadata() dict#

Retrieves all metadata associated with the property.

Returns:

A dictionary of all metadata.

Return type:

dict

GetAllSdrMetadata() Dict#
GetColorSpace() str | None#

Gets the color space of the property.

Returns:

The color space of the property, or None if not set.

Return type:

Union[str, None]

GetConnectability() str | None#
GetDefaultValue() Any | None#

Gets the default value of the property.

Returns:

The default value of the property, or None if not set.

Return type:

Union[Any, None]

GetDisplayGroup() str#

Gets the display group of the property.

Returns:

The display group of the property.

Return type:

str

GetDisplayName() str#

Gets the display name of the property.

Returns:

The display name of the property.

Return type:

str

GetDocumentation() str | None#
GetEnableIfCondition() str | None#

Gets the enable-if condition for the property.

Returns:

The enable-if condition, or None if not set.

Return type:

Union[str, None]

GetHidden() bool#
GetMdlArrayElementType() str | None#
GetMdlModifier() str#
GetMdlStructType() str | None#
GetMdlSymbol() str | None#
GetMetadata(
key: str,
) Any | None#

Retrieves the metadata value for the given key.

Parameters:

key (str) – The metadata key to query.

Returns:

The value of the given metadata key, or None if not set.

Return type:

Union[Any, None]

GetName() str#

Retrieves the name of the property.

Returns:

The name of the property.

Return type:

str

GetPropertyType()#

Gets the type of the property represented by the placeholder.

Returns:

The type of property.

Return type:

Usd.Attribute

GetRenderType() str | None#
GetSdrMetadata(
key,
default_value=None,
) Any | None#
GetTypeName() str | None#

Gets the type name of the property.

Returns:

The type name of the property, or None if not set.

Return type:

Union[str, None]

HasMetadata(key) bool#

Checks if the specified metadata key is present.

Parameters:

key (str) – The metadata key to check.

Returns:

True if the key is present, False otherwise.

Return type:

bool

IsHidden() bool#

Checks if the property is hidden.

Returns:

True if the property is hidden, False otherwise.

Return type:

bool

MATERIAL_INPUT_SUFFIX = '__material_input__'#
classmethod PlaceholderFromAttribute(
usd_attribute: Attribute,
)#

Create a UsdShadePropertyPlaceholder from a Usd.Attribute.

Parameters:

usd_attribute (Usd.Attribute)

Returns:

UsdShadePropertyPlaceholder

SetColorSpace(value: str) None#

Sets the color space of the property.

Parameters:

value (str) – The new color space for the property.

SetDisplayGroup(value: str) None#

Sets the display group of the property.

Parameters:

value (str) – The new display group for the property.

SetDisplayName(value: str) None#

Sets the display name of the property.

Parameters:

value (str) – The new display name for the property.

SetHidden(value: bool) None#

Sets the hidden state of the property.

Parameters:

value (bool) – The new hidden state for the property.

SetMetadata(
key: str,
value: Any,
) None#

Sets the metadata key to the given value.

Parameters:
  • key (str) – The metadata key.

  • value (Any) – The value to associate with the key.

SetName(name: str) None#

Sets the name of the property.

Parameters:

name (str) – The new name for the property.