omni.asset_validator.ui API

omni.asset_validator.ui.get_instance()

Get the global instance of the Asset Validator UI Extension.

class omni.asset_validator.ui.PublicExtension

The public interface for the Asset Validator UI.

AssetMode

Mode of validation in the Asset Validator Window. Either AssetMode.Uri or AssetMode.Stage are accepted.

Type

int

Example

Initialize the UI and configure it for the user

import omni.asset_validator.core
import omni.asset_validator.ui

ui = omni.asset_validator.ui.get_instance()

# opt out of some rules
ui.disableRule(omni.asset_validator.core.ValidationRulesRegistry.rule('TextureChecker'))
ui.disableRule(omni.asset_validator.core.ValidationRulesRegistry.rule('KindChecker'))

# make the window visible (though it could remain behind other windows)
ui.show()

# switch to the current stage
ui.setAssetMode(ui.AssetMode.Stage)

# run the validator
import asyncio
asyncio.ensure_future(ui.validate_async())

# go back but retain your settings
ui.reset()

# switch to a bespoke stage and validate it in-memory, including any unsaved edits
from pxr import Usd, Kind
stage = Usd.Stage.Open('omniverse://localhost/NVIDIA/Samples/Astronaut/Astronaut.usd')
prim = stage.DefinePrim(f'{stage.GetDefaultPrim().GetPath()}/MyCube', 'cube')
Usd.ModelAPI(prim).SetKind(Kind.Tokens.component)
ui.setStage(stage)
asyncio.ensure_future(ui.validate_async())
show() None

Show the Asset Validator Window.

hide() None

Hide the Asset Validator Window.

visible() bool

Determine if the Asset Validator Window is currently visible.

Note it may still be under another window.

Returns

Bool indicating whether it is visible.

enableRule(Rule: omni.asset_validator.core.complianceChecker.BaseRuleChecker) None

Enable a given rule in the Asset Validator Window.

This gives control to client code to enable rules one by one. Rules must be BaseRuleChecker derived classes, and must be registered with the ValidationRulesRegistry before they are enabled in the UI.

Parameters

Rule – A BaseRuleChecker derived class to be enabled.

disableRule(Rule: omni.asset_validator.core.complianceChecker.BaseRuleChecker) None

Disable a given rule in the Asset Validator Window.

This gives control to client code to disable rules one by one. Rules must be BaseRuleChecker derived classes, and should be registered with the ValidationRulesRegistry before they are disabled in the UI.

Parameters

Rule – A BaseRuleChecker derived class to be enabled

enabled(Rule: omni.asset_validator.core.complianceChecker.BaseRuleChecker) bool

Check if the given rule is enabled in the Asset Validator Window.

Parameters

Rule – A BaseRuleChecker derived class to be enabled.

Returns

Bool indicating whether the given Rule is enabled. Note it does not guarantee the Rule exists.

reset(resetAssets: bool = False, resetRules: bool = False) None

Reset the Asset Validator Window to its default state.

If no arguments are provided the window will return to the selection page, but will remain in the same mode, with the same asset selected, and same rules enabled. This is equivalent of clicking the “Back to Rules Selection” button.

Parameters
  • resetAssets – Flag to reset the configured Assets (both Uri and Stage).

  • resetRules – Flag to reset the user selected Rules (all categories).

getAssetMode() omni.asset_validator.ui.ui.AssetValidatorUI.AssetMode

Get the current mode of validation that the Asset Validator Window will use.

Returns

The current mode of validation that the Asset Validator Window will use.

setAssetMode(mode: omni.asset_validator.ui.ui.AssetValidatorUI.AssetMode) None

Set the current mode of validation that the Asset Validator Window will use.

Parameters

mode – Either AssetMode.Uri or AssetMode.Stage are accepted.

getAssetUri() str

Get the Asset URI that will be validated if the Asset Validator Window is in Uri mode.

Returns

A single Omniverse Asset. Note this can be a file URI or folder/container URI.

setAssetUri(asset: str) None

Set the Asset URI that will be validated if the Asset Validator Window is in Uri mode.

Parameters

asset – A single Omniverse Asset. Note this can be a file URI or folder/container URI.

getStage() pxr.Usd.Stage

Get the Usd.Stage that will be validated if the Asset Validator Window is in Stage mode.

Returns

A live Usd.Stage.

setStage(stage: pxr.Usd.Stage) None

Set the Usd.Stage that will be validated if the Asset Validator Window is in Stage mode.

Parameters

stage – A live Usd.Stage.

async validate_async() List[omni.asset_validator.core.autofix.Results]

Run the validation with the currently selected Asset in the current mode.

This is equivalent to clicking the “Run Asset Validation” button. The Asset Validator Window will display results as normal, and they will be returned here for convenience once all assets have been validated.

Returns

All issues reported by the enabled rules, index aligned with their respective asset. Note order of validation is not guaranteed. Re-validation of the same folder URI may return results in a different order.