UsdSuperLayer
✨ New in Katana 8.5
Introduction
The UsdSuperLayer node type is a new base SuperTool node type whose underlying type is
the UsdLayerSuperTool class. This SuperTool
provides direct access to a USD Layer at the node graph level. The purpose is to use USD as its
core source of truth, with parameters serving as UI elements. This is fundamentally different to
other node types in Katana where, typically, parameters store the recipe that define the node. This
base node type is not intended to replace our typical, fully procedural node types, since some
proceduralism is lost. However, for certain workflows, there is a significant gain in performance
and usability.
These are the derived node types that extend the UsdSuperLayer node type:
The common interface for the node types that derive from UsdSuperLayer:
- class NodesUsdAPI.UsdSuperLayer.UsdLayerSuperTool
Bases:
SuperToolThe node part of the UsdSuperLayer SuperTool.
- FN_PROPERTIES_GROUP = 'fnPropertiesGroup'
- __init__() None
Initializes an instance of the class.
- addParameterHints(attrName: str, inputDict: dict) None
Adds parameter hints to the given dictionary of hints for a GenericAssign parameter that shows the value of an attribute from the incoming scene.
- Parameters:
attrName (
str) – The name of the scene graph attribute from the incoming scene for which to add parameter hints.inputDict (
dict) – The dictionary to which to add parameter hints.
- Return type:
None
- appendChangeDescription(description: str) None
Appends a description of a change to the content layer. This description will be used to create a meaningful undo stack entry when the content layer is serialized.
This is primarily intended for use by ContextMenu plug-ins and other external code that modifies the content layer directly, allowing them to document their changes.
- Parameters:
description (
str) – A brief description of the change made to the content layer.- Return type:
None
- buildParametersForPrimPath(primPath: str) None
Rebuilds the dynamic parameters for the provided
primsPathby relaying the request to each of the registered plug-ins via thebuildOrUpdateParameters()method on each plug-in.- Parameters:
primPath (
str) – The prim path to build or rebuild parameters for.- Return type:
None
- canOverride(attrName: str) bool
Checks if the given attribute is overridable or not in the node. This is required by manipulators.
- Parameters:
attrName (
str) – The name of the attribute to check if overridable.- Return type:
bool
- checkDynamicParameters() None
Checks the dynamic parameters for the prims in the target prim paths and rebuilds them if necessary.
- Return type:
None
- contentLayerChangedByNode(primPaths: list[Path]) None
Post process after content layer has changed.
- Parameters:
primPaths (
list[Path]) – The list of prim paths that have changed.- Return type:
None
- getComponentsFromPropertiesParameter(parameter: Parameter) tuple[str, str, str, Parameter] | None
Returns all components from the provided parameter. This will return a list of tuples containing the prim path and the parameter name. An example for the input parameter:
properties.parent.child.fnPropertiesGroup.PropertiesParametersHandlerPlugin.size.valuewould return: ``(‘parent/child’, ‘/root/parent/child’,‘PropertiesParametersHandlerPlugin’, self.getParameter( ‘properties.parent.child.fnPropertiesGroup.PropertiesParametersHandlerPlugin’) )``.
- Parameters:
param – The parameter to extract the components from.
parameter (
Parameter)
- Returns:
tuple[str,str,str,Parameter] |None– A tuple containing the relative prim path, absolute prim path, plug-in name, and plugin root parameter, orNoneif the parameter does not represent a plug-in parameter.
- getEngineIds(graphState: GraphState) list
Returns engine ids of the underlying StageSubtreeController node.
- Parameters:
graphState (
GraphState)- Return type:
list
- getIncomingLocalUsgValue(prim: Prim, paramFullName: str) Value | None
Called by the
StageParameterPolicyto retrieve theusg.Valuedata from the prim.
- getInternalLayerNode() Node
Returns the hidden internal node responsible for managing the StageSubtreeController for the SuperTool.
- Return type:
- getOverridableAttrs() list[str]
- Returns:
list[str] – The list of attributes that can be overridden using the setOverride function.
- getParameterNameFromPropertiesParameter(parameter: Parameter) str
Returns the parameter name component from a properties parameter path.
Extracts everything after the plugin name. For example: “properties.parent.child.fnPropertiesGroup.Plugin.size.value” returns “size.value”.
This assumes parameters are plugin-created with proper structure since malformed parameters won’t appear in the properties UI.
- Parameters:
parameter (
Parameter) – The parameter to extract the name from.- Returns:
str– The short name of the parameter from the provided prim parameter.
- getPluginNameFromParam(parameter: Parameter) str | None
Returns the name of the plug-in which created this parameter.
An example for the input parameter:
properties.parent.child.fnPropertiesGroup.PropertiesParametersHandlerPlugin.size.valuewould return:'PropertiesParametersHandlerPlugin'.- Param:
The parameter to extract the plug-in name from.
- Returns:
str|None– The plug-in name as a string orNoneif the parameter does not represent a plug-in parameter.- Parameters:
parameter (
Parameter)
- getPluginParamRoot(parameter: Parameter) Parameter | None
Returns the root group parameter for the plug-in which created the provided parameter.
An example for the input parameter:
properties.parent.child.fnPropertiesGroup.PropertiesParametersHandlerPlugin.size.valuewould return: ``self.getParameter(‘properties.parent.child.fnPropertiesGroup.PropertiesParametersHandlerPlugin’)``.
- getPrimPathFromPropertiesParameter(parameter: Parameter, absolutePath: bool = False) Path | None
Returns the prim path from the provided parameter. Optional argument of
absolutePathcan be set to true to return the absolute prim path instead of the relative one. This adds the current base prim path to the relative prim path. An example for the input parameter:properties.parent.child.fnPropertiesGroup.PropertiesParametersHandlerPlugin.size.valuewould return:'parent/child'or'/root/parent/child'.
- getStageAndStates(force: bool = False) tuple[Stage, int, int]
Gets a stage and state from this point in the hierarchy from the internal _UsdLayerNode.
This will fetch the stage by performing a traversal and running the USD processing engine.
If force is True, the traversal will always be performed. If force is False(default) a traversal will only occur if the stage is empty. This node does not keep track of changes or updates.
It is important not to cache the returned stage to avoid keeping references to layers that may need to be flushed! Gets the state of the stage, or if there is no incoming stage, the hash of the current ContentLayer. If you do need to retain the stage. Ensure you implement a method on the event
cacheManager_flushset the stage to None and re-fetch at the next idle event to prevent layers from not being reloaded on flush caches.- Parameters:
force (
bool) – Whether to force re-traversal of the scene. False by default.- Return type:
tupleof (usg.Stage,int,int)- Returns:
The
usg.Stageof the current node graph to this point, and the states of the
stage, and the contentLayer itself.
- getStageParameterPolicyMaskPath() str
Called by the
StageParameterPolicyto determine the prim path to the USD Prim that will be utilised as the mask path for the UsdStage, if this method is not overriden, it will default to masking based on the path returned by thegetStageParameterPolicyPrimPathmethod.- Returns:
str– The prim path to the USD Prim that is to be used as the mask path for the Stage.
- getStageParameterPolicyPrimPath(frameTime: float = 0.0) str
Called by the
StageParameterPolicyto determine the prim path to the USD Prim that will be queried in the incoming USD Stage.- Parameters:
frameTime (
float, default:0.0) – The sample time to query data at.- Returns:
str– The prim path to the USD Prim that is to be queried in the incoming USD Stage.
- getStageSubtreeController() StageSubtreeController
Accessor for the internal nodes getStageSubtreeController method.
- Return type:
usg.StageSubtreeControllerorNone- Returns:
The
usg.StageSubtreeControllercreated by this node or None if it has not been
created.
- getTargetPrimPath() str
- Returns:
str– The path to the currently selected prim, or an empty string if none.
- getTargetPrimPaths() list[str]
- Returns:
list[str] – The list of target prim paths.
- polish() None
This method is automatically called on the SuperTool after it has finished loading and initialization. It will only be called once.
- Return type:
None
- setFilteredApiSchemas(apiSchemas: list[str]) None
Sets the string array
apiSchemaparameter controlling which the tree view for this node should be filtered by. If empty the list will not be filtered by any api schemas.- Parameters:
apiSchemas (
list[str]) – The list of apiSchemas to filter. If empty no filtering based on api schemas takes place.- Return type:
None
- setFilteredConcreteSchemas(concreteSchemas: list[str]) None
Sets the string array
concreteSchemaparameter controlling which the tree view for this node should be filtered by. If empty the list will not be filtered by any concrete schemas.- Parameters:
concreteSchemas (
list[str]) – The list of concrete schemas to filter. If empty no filtering based on concrete schemas takes place.- Return type:
None
- setOverride(path: str, attrName: str, time: float, attrData: list[float], args: list[str], index: int = 0, **kwargs: dict[str, object]) bool
Applies the node’s transform parameter overrides from given attribute value. This is required by manipulators.
- Parameters:
path (
str) – The location to set override.attrName (
str) – The name of the attribute to override.time (
float) – The frameTime of current graph state.attrData (
list[float]) – The list of attribute data to override with.args (
list[str]) – Throw away argument, required to match pattern of AttributeEditors.index (
int, default:0) – Throw away argument, required to match pattern of AttributeEditors.kwargs (
dict[str,object]) – Throw away argument, required to match pattern of AttributeEditors.
- Return type:
bool
- setTargetPrimPath(primPath: str, force: bool = False) None
Sets the target prim path to the provided prim paths.
- Parameters:
primPath (
str) – The prim path to set, or empty to clear it.force (
bool, default:False) – Signal a change even when the prim path was already set as the target
- Raises:
RuntimeError – If the target prim path is not a descendant of the base prim path.
- Return type:
None
- setTargetPrimPaths(primPaths: list[str], force: bool = False) None
Sets the target prim paths to the provided list of prim paths.
- Parameters:
primPaths (
list[str]) – The list of prim paths to set.force (
bool, default:False) – Signal a change even when the prim path was already set as the target.
- Raises:
RuntimeError – If the target prim path is not a descendant of the base prim path.
- Return type:
None
- syncLayerAndParameters() bool
Reserializes the content layer, updates the internal state in the node, and rebuilds parameters for the target prim if the serialized content layer has changed.
- Returns:
bool– Whether the serialized content layer has changed compared to the previous call.
- property targetPrimPathsChanged: SignalInstance
- Returns:
The reference to the
targetPrimPathsChangedsignal.
- updateParameters(prim: Prim, paramFullName: str) bool
Called by the
StageParameterPolicyon potential changes upstream.- Parameters:
prim (
Prim) – The USD Prim composed upstream.paramFullName (
str) – The name of the parameter being evaluated.
- Returns:
bool– Whether parameters have triggered a change.
How to make your own SuperTool from UsdSuperLayer
This section explains how to extend the UsdSuperLayer node type to construct your own
SuperTool. The SuperTool plug-in consists of its module, its registration, its editor and its node.
They are defined in Python files placed within a subdirectory named /SuperTools under the
KATANA_RESOURCES path. This allows Katana to automatically pick up and load the plug-in during
startup.
First we need to register the new SuperTool as a plug-in.
# Copyright (c) 2025 The Foundry Visionmongers Ltd. All Rights Reserved.
"""
Registering the CustomUsdSuperLayer SuperTool plug-in.
"""
import logging
import NodegraphAPI
log = logging.getLogger("CustomUsdSuperLayer")
try:
from . import v1 as CustomUsdSuperLayer # noqa: N812
except ImportError:
log.exception("Error importing Super Tool Python package.")
raise
PluginRegistry = [
(
"SuperTool",
2,
"CustomUsdSuperLayer",
(CustomUsdSuperLayer.CustomUsdSuperLayerNode, CustomUsdSuperLayer.GetEditor),
),
]
NodegraphAPI.AddNodeFlavor("CustomUsdSuperLayer", "nativeusd")
NodegraphAPI.AddNodeFlavor("CustomUsdSuperLayer", "prims")
Next we initialize the module for our SuperTool. We define a GetEditor function, which will return the Editor class for this node.
# Copyright (c) 2025 The Foundry Visionmongers Ltd. All Rights Reserved.
"""
Initializing module for the CustomUsdSuperLayer SuperTool.
"""
from .Node import CustomUsdSuperLayerNode # noqa: F401
def GetEditor() -> type:
"""
:return: The class that implements the SuperTool's editor interface.
"""
from .Editor import CustomUsdSuperLayerEditor # noqa: PLC0415
return CustomUsdSuperLayerEditor
Next we initialize our editor for the SuperTool, often containing functionality around the UI elements.
# Copyright (c) 2025 The Foundry Visionmongers Ltd. All Rights Reserved.
"""
Module implementing the Editor part of the CustomUsdSuperLayer SuperTool.
"""
from PySide6 import QtWidgets
from Katana import NodegraphAPI
from NodesUsdAPI.UsdSuperLayer.Editor import UsdSuperLayerEditor
from UI4.FormMaster import ParameterPolicy, StageParameterPolicy
class CustomUsdSuperLayerEditor(UsdSuperLayerEditor):
"""
UI for the CustomUsdSuperLayer SuperTool.
"""
def __init__(self, parent: QtWidgets.QWidget, group: NodegraphAPI.Node) -> None:
"""
Initializes an instance of the Editor.
"""
super().__init__(parent, group)
# Customize which schema types the visibility column can effect in the stage.
self.setVisibilityEnabledSchemas([
"Xform",
])
# Here we need to hook into our stage parameter policy delegate and register our new node
# so that parameter types can be resolved.
ParameterPolicy.RegisterPolicyDelegate(
"CustomUsdSuperLayer",
StageParameterPolicy.StageParameterPolicyDelegate(),
)
Finally is the node for our SuperTool, this will contain functionality around parameters.
# Copyright (c) 2025 The Foundry Visionmongers Ltd. All Rights Reserved.
"""
Module implementing the Node part of the CustomUsdSuperLayer SuperTool.
"""
import Utils
from NodesUsdAPI.UsdSuperLayer import ContextMenuPlugin, UsdLayerSuperTool
INITIAL_PRIM_PATH = '/root'
class CustomUsdSuperLayerNode(UsdLayerSuperTool):
"""
Node for the CustomUsdSuperLayer SuperTool.
"""
def __init__(self) -> None:
"""
Initializer for the CustomUsdSuperLayer Node.
"""
Utils.UndoStack.OpenGroup('Create CustomUsdSuperLayer node')
try:
super().__init__()
# If for example, you only want to show "Scope" types then you can apply a filter.
# self.setFilteredConcreteSchemas([
# "Scope",
# ])
self.getParameter('primPath').setValue(INITIAL_PRIM_PATH, 0)
self.getInternalLayerNode()._changeBasePath(INITIAL_PRIM_PATH) # noqa: SLF001
finally:
Utils.UndoStack.CloseGroup()
# Add the example context menu to the entries available.
reg = ContextMenuPlugin.GetRegistry()
reg.setActive("SampleContextMenuPlugin", True)
reg.registerNodeToPlugin("AddRigContextMenuPlugin", "CustomUsdSuperLayer")
Plug-ins
UsdSuperLayer-derived node types can be extended with various forms of Python plug-ins.
Parameters Handler Plug-ins
Overview
This section describes how extra parameters can be created with UsdSuperLayerParametersHandler
plug-ins registered for UsdSuperLayer-derived node types.
These extensions are written in the form of
ParametersHandlerPluginBase-derived
classes that are registered as regular Katana Python plug-ins. A ParametersHandlerPlugin defines the
parameters that are shown in the Parameters tab when a target prim is selected; handling
of parameter changes is implemented in the plug-in too: the plug-in can modify the USD Prim in the
content layer.
In addition to registering and unregistering plug-ins from the plug-in registry, which can be done
at runtime with the
ParametersHandlerPluginRegistry
Python API, it is also possible to temporarily deactivate without unregistering plug-ins from the
system.
The plug-in consists of a class and its registration, defined in a Python file placed within a
subdirectory named /Plugins under the KATANA_RESOURCES path. This allows Katana to
automatically pick up and load the plug-in during startup.
To define the class, it must derive from
ParametersHandlerPluginBase
and implement the
isPrimSupported(),
buildOrUpdateParameters(),
and onParameterChanged()
class methods.
class UsdSuperLayerExampleParametersHandlerPlugin(ParametersHandlerPluginBase):
@classmethod
def isPrimSupported(
cls,
node: NodegraphAPI.Node,
primPath: str,
usdPrim: usg.Prim | None,
sdfPrim: usg.Prim | None,
) -> bool:
...
@classmethod
def buildOrUpdateParameters(
cls,
node: NodegraphAPI.Node,
primPath: str,
usdPrim: usg.Prim | None,
sdfPrim: usg.Prim | None,
groupParam: NodegraphAPI.Parameter,
) -> None:
...
@classmethod
def onParameterChanged(
cls,
node: NodegraphAPI.Node,
primPath: str,
sdfPrim: usg.Prim,
groupParam: NodegraphAPI.Parameter,
parameter: NodegraphAPI.Parameter,
parameterSampleTime: float,
usdSampleTime: float,
) -> bool:
...
The isPrimSupported()
class method must return True to indicate that the target prim, as specified by the prim path
argument, is to be managed by the plug-in. For example, the predicate can be based on the existence
of a certain USD Schema applied in the prim.
The
buildOrUpdateParameters()
class method is called on prims that have been stated as supported by the
isPrimSupported()
method. The method is in charge of defining (or updating) parameters for the target prim.
The
onParameterChanged()
class method is invoked when parameters previously created by the
buildOrUpdateParameters()
method change. It gives the plug-in an opportunity to make persistent changes in the content layer
from the UsdSuperLayer-derived node.
To register the defined class as a plug-in, a top-level, global variable called PluginRegistry
must be defined in the Python module. The variable is a list of tuples, with each tuple containing
plug-in definitions. For example:
PluginRegistry = [
(
'UsdSuperLayerParametersHandler',
1,
'ExampleParametersHandlerPlugin',
(
UsdSuperLayerExampleParametersHandlerPlugin,
{
'active': True,
'priority': 0,
'appliedNodes': ['all'],
},
),
),
]
UsdSuperLayerParametersHandleris the plug-in type name.1is the plug-in version.ExampleParametersHandlerPluginis the unique plug-in name. A list of currently registered plug-in names can be found by querying the ParametersHandlerPlugin registry.UsdSuperLayerExampleParametersHandlerPluginis the class derived from theParametersHandlerPluginBaseclass.{'active': True, 'priority': 0, 'appliedNodes': ['all']}are plug-in options, which currently supports the following:activedefines whether the plug-in is initially active. The default value isTrue. Plug-ins’ active state can be changed at a later time viaParametersHandlerPluginRegistry.setActive().prioritydefines the order in which plug-ins of this type will be loaded, where 0 is the default. Lower values are higher priority, and thus will appear higher up in the parameter list in the UI.appliedNodesis a list of node type names. The plug-in will apply to node instances of the given node type(s). Ifallis included in the list, the plug-in is applied to all node types. Plug-ins’ nodes list can be added to at a later time viaParametersHandlerPluginRegistry.registerNodeToPlugin().
Examples
# Copyright (c) 2025 The Foundry Visionmongers Ltd. All Rights Reserved.
"""
Module containing an example Parameters Handler plug-in for UsdSuperLayer-derived node types.
"""
import logging
import usg
import NodegraphAPI
from NodesUsdAPI.UsdSuperLayer import ParametersHandlerPlugin, Utils
log = logging.getLogger("ExampleParametersHandlerPlugin")
class UsdSuperLayerExampleParametersHandlerPlugin(
ParametersHandlerPlugin.ParametersHandlerPluginBase,
):
"""
An example of a ``UsdSuperLayerParametersHandler`` plug-in that adds a new parameter group called
``'image'`` that includes some user-defined parameters that are then translated into USD
Attributes on the target USD Prim in the UsdSuperLayer-derived nodes.
"""
@classmethod
def isPrimSupported(
cls,
node: NodegraphAPI.Node,
primPath: str,
usdPrim: usg.Prim | None,
sdfPrim: usg.Prim | None,
) -> bool:
"""
Implements `ParametersHandlerPluginBase.isPrimSupported()`.
Invoked by UsdSuperLayer-derived nodes when the selected prim in the node changes, the prim
in the incoming USD Stage changes, or the prim in the content layer changes.
Plug-ins must implement the function to specify whether a given prim is to be handled by
this plug-in. If supported, :py:obj:`buildOrUpdateParameters()` will be invoked next after
a dedicated group parameter has been created for this prim path and plug-in.
:param node: The UsdSuperLayer-derived node.
:param primPath: The absolute path to the prim.
:param usdPrim: The USD Prim in the stage if it exists.
:param sdfPrim: The USD Prim in the content layer if it exists.
:return: Whether the prim should be handled by the plug-in, in which case
:py:obj:`buildOrUpdateParameters()` will be invoked next.
"""
# All prims are supported and will create parameters defined by this plug-in.
return True
@classmethod
def getGroupParameterLabel(cls) -> str:
"""
Implements `ParametersHandlerPluginBase.getGroupParameterLabel()`.
Invoked by UsdSuperLayer-derived nodes.
Plug-ins can implement the function to define the label that will be used for the group
parameter widget that holds the parameters that the plug-in creates.
:return: The label for the group parameter that will hold the parameters that the plug-in
creates. Common labels can be ``'properties'``, ``'inputs'``, or ``'transform'``.
"""
return 'image'
@classmethod
def buildOrUpdateParameters(
cls,
node: NodegraphAPI.Node,
primPath: str,
usdPrim: usg.Prim | None,
sdfPrim: usg.Prim | None,
groupParam: NodegraphAPI.Parameter,
) -> None:
"""
Implements `ParametersHandlerPluginBase.buildOrUpdateParameters()`.
Invoked by UsdSuperLayer-derived nodes if :py:obj:`isPrimSupported()` in the plug-in has
returned ``True``.
Plug-ins can implement the function to create their own parameters based on the prim in the
incoming stage.
:param node: The UsdSuperLayer-derived node.
:param primPath: The absolute path to the prim.
:param usdPrim: The USD Prim in the stage if it exists.
:param sdfPrim: The USD Prim in the content layer if it exists.
:param groupParam: The group parameter, previously manufactured for the plug-in only, in
which the plug-in can create its relevant child parameters.
"""
# Build parameters if not yet created. These parameters include a **stageparameter** child
# parameter that enables the StageParameterPolicy in the group parameter.
filepathGroupParam = groupParam.getChild('filepath')
if filepathGroupParam is None:
filepathGroupParam = groupParam.createChildGroup('filepath')
filepathGroupParam.createChildNumber('enable', 0)
filepathGroupParam.createChildString('default', '')
filepathGroupParam.createChildString('value', '')
filepathGroupParam.createChildNumber('stageparameter', 0.0)
filepathGroupParam.setHintString(
str({
'widget': 'assetIdInput',
'fileTypes': 'png|gif|jpg|webp',
'help': 'An example parameter where the user can select an image filepath.',
}),
)
scaleGroupParam = groupParam.getChild('scale')
if scaleGroupParam is None:
scaleGroupParam = groupParam.createChildGroup('scale')
scaleGroupParam.createChildNumber('enable', 0)
scaleGroupParam.createChildNumber('default', 0.0)
scaleGroupParam.createChildNumber('value', 0.0)
scaleGroupParam.createChildNumber('stageparameter', 0.0)
scaleGroupParam.setHintString(
str({'help': 'Another parameter with a hypothetical image scale.'}),
)
modeGroupParam = groupParam.getChild('mode')
if modeGroupParam is None:
modeGroupParam = groupParam.createChildGroup('mode')
modeGroupParam.createChildNumber('enable', 0)
modeGroupParam.createChildString('default', '')
modeGroupParam.createChildString('value', '')
modeGroupParam.createChildNumber('stageparameter', 0.0)
modeGroupParam.setHintString(
str({
'widget': 'popup',
'options': ('', 'RGBA', 'RGB', 'Grayscale'),
'help': 'Yet another parameter to select a color mode.',
}),
)
# Update state based on content layer.
if sdfPrim is not None:
attr = sdfPrim.getAttr('image:filepath')
enableState = 0.0
value = None
if attr is not None:
if attr.isBlocked():
enableState = -1.0
else:
enableState = 1.0
value = attr.get()
filepathGroupParam.getChild('enable').setValue(enableState, 0.0)
if value is not None:
filepathGroupParam.getChild('value').setValue(value, 0.0)
attr = sdfPrim.getAttr('image:scale')
enableState = 0.0
value = None
if attr is not None:
if attr.isBlocked():
enableState = -1.0
else:
enableState = 1.0
value = attr.get()
scaleGroupParam.getChild('enable').setValue(enableState, 0.0)
if value is not None:
scaleGroupParam.getChild('value').setValue(value, 0.0)
attr = sdfPrim.getAttr('image:mode')
enableState = 0.0
value = None
if attr is not None:
if attr.isBlocked():
enableState = -1.0
else:
enableState = 1.0
value = attr.get()
modeGroupParam.getChild('enable').setValue(enableState, 0.0)
if value is not None:
modeGroupParam.getChild('value').setValue(value, 0.0)
else:
# Remove the enable state from all the parameters if the prim is not valid, since they
# will no longer be local.
filepathGroupParam.getChild('enable').setValue(0, 0.0)
scaleGroupParam.getChild('enable').setValue(0, 0.0)
modeGroupParam.getChild('enable').setValue(0, 0.0)
@classmethod
def onParameterChanged(
cls,
node: NodegraphAPI.Node,
primPath: str,
sdfPrim: usg.Prim,
groupParam: NodegraphAPI.Parameter,
parameter: NodegraphAPI.Parameter,
parameterSampleTime: float,
usdSampleTime: float,
) -> bool:
"""
Implements `ParametersHandlerPluginBase.onParameterChanged()`.
Invoked by UsdSuperLayer-derived nodes when a parameter created previously by
:meth:`buildOrUpdateParameters()` changes.
Plug-ins can implement the function to react to parameter changes.
:param node: The UsdSuperLayer-derived node.
:param primPath: The absolute path to the prim.
:param sdfPrim: The prim in the content layer that the plug-in can modify.
:param groupParam: The group parameter that holds all the plug-in-defined parameters for the
target prim.
:param parameter: The parameter, created previously by :meth:`buildOrUpdateParameters()`,
that has changed.
:param parameterSampleTime: The time at which to sample the parameter to retrieve the value.
:param usdSampleTime: The sample time at which to store the USD property. During an
interactive session, this will typically be the defaultTimeSample. Whilst exporting or
rendering, this will be called for all required time samples.
:return: ``True`` if the ``sdfPrim`` was modified as a result of the parameter change;
otherwise ``False``.
"""
# Select the children of the StageParameterPolicy group parameter.
parameterParts = Utils.getEnableParameterParts(parameter)
if parameterParts is None:
return False
sppGroupParam, _valueParamType, enableState, valueParam, _defaultParam = parameterParts
paramName = sppGroupParam.getName()
attributeName = f'image:{paramName}'
# Incoming value.
if enableState == 0.0:
# If no local value is set, the property is cleared
sdfPrim.removeProperty(attributeName)
else:
# If a local value is set, an attribute will be created (if it does not exist yet), and
# the value will be set.
attr = sdfPrim.getAttr(attributeName)
if attr is None:
# In this example, only two types are used: either string or double.
if valueParam.getType() == 'string':
attributeType = usg.Value.Type.String
else:
attributeType = usg.Value.Type.Double
attr = sdfPrim.createAttr(attributeName, attributeType)
# Local value.
if enableState == 1.0:
# Here we use the parameter sample time to read the value from the parameter, and
# the usd sample time to set the value on the attribute.
attr.set(valueParam.getValue(parameterSampleTime), usdSampleTime)
# Force default.
else:
attr.block()
# The method must return `True` if a change has been made to the `sdfPrim` prim. In this
# example, all code paths lead to a change.
return True
@classmethod
def getIncomingLocalUsgValue(
cls,
node: NodegraphAPI.Node,
prim: usg.Prim,
groupParam: NodegraphAPI.Parameter,
parameter: NodegraphAPI.Parameter,
) -> usg.Value | None:
"""
Implements `ParametersHandlerPluginBase.getIncomingLocalUsgValue()`.
Invoked by UsdSuperLayer-derived nodes when a parameter, created previously by
:meth:`buildOrUpdateParameters()`, requires the local value from the incoming USD Stage.
Plug-ins must implement this function if the parameters created in
:meth:`buildOrUpdateParameters()` are managed by the StageParameterPolicy.
:param node: The UsdSuperLayer-derived node.
:param prim: The USD Prim from which to source the `usg.Value`.
:param groupParam: The group parameter that holds all the plug-in-defined parameters for the
target prim.
:param parameter: The parameter; a descendant of the `groupParam` group parameter; that is
associated to the incoming local value request. Plug-in implementations can use it to
determine how to source or synthesize the value.
:return: The `usg.Value` retrieved from the given USD Prim based on the parameter.
"""
paramName = parameter.getName()
attributeName = f'image:{paramName}'
# The method needs to query the incoming USD Stage to retrieve the potential incoming value
# from the target attribute.
attr = prim.getAttr(attributeName)
if attr is None or not attr.isValid():
return None
return attr.getUsgValue()
PluginRegistry = [
(
'UsdSuperLayerParametersHandler',
1,
'ExampleParametersHandlerPlugin',
(
UsdSuperLayerExampleParametersHandlerPlugin,
{
'active': True,
'priority': 0,
'appliedNodes': ['all'],
},
),
),
]
API
- class NodesUsdAPI.UsdSuperLayer.ParametersHandlerPlugin.ParametersHandlerPluginBase
Bases:
ABCBase class for ParametersHandler plug-ins.
- abstractmethod classmethod buildOrUpdateParameters(node: Node, primPath: str, usdPrim: Prim | None, sdfPrim: Prim | None, groupParam: Parameter) None
Invoked by UsdSuperLayer-derived nodes if
isPrimSupported()in the plug-in has returnedTrue.Plug-ins can implement the function to create their own parameters based on the prim in the incoming stage.
- Parameters:
node (
Node) – The UsdSuperLayer-derived node.primPath (
str) – The absolute path to the prim.usdPrim (
Prim|None) – The USD Prim in the stage if it exists.sdfPrim (
Prim|None) – The USD Prim in the content layer if it exists.groupParam (
Parameter) – The group parameter, previously manufactured for the plug-in only, in which the plug-in can create its relevant child parameters.
- Return type:
None
- abstractmethod classmethod getGroupParameterLabel() str
Invoked by UsdSuperLayer-derived nodes.
Plug-ins can implement the function to define the label that will be used for the group parameter widget that holds the parameters that the plug-in creates.
- Returns:
str– The label for the group parameter that will hold the parameters that the plug-in creates. Common labels can be'properties','inputs', or'transform'.
- abstractmethod classmethod getIncomingLocalUsgValue(node: Node, prim: Prim, groupParam: Parameter, parameter: Parameter) Value | None
Invoked by UsdSuperLayer-derived nodes when a parameter, created previously by
buildOrUpdateParameters(), requires the local value from the incoming USD Stage.Plug-ins must implement this function if the parameters created in
buildOrUpdateParameters()are managed by the StageParameterPolicy.- Parameters:
node (
Node) – The UsdSuperLayer-derived node.prim (
Prim) – The USD Prim from which to source theusg.Value.groupParam (
Parameter) – The group parameter that holds all the plug-in-defined parameters for the target prim.parameter (
Parameter) – The parameter; a descendant of thegroupParamgroup parameter; that is associated to the incoming local value request. Plug-in implementations can use it to determine how to source or synthesize the value.
- Returns:
Value|None– Theusg.Valueretrieved from the given USD Prim based on the parameter.
- abstractmethod classmethod isPrimSupported(node: Node, primPath: str, usdPrim: Prim | None, sdfPrim: Prim | None) bool
Invoked by UsdSuperLayer-derived nodes when the selected prim in the node changes, the prim in the incoming USD Stage changes, or the prim in the content layer changes.
Plug-ins must implement the function to specify whether a given prim is to be handled by this plug-in. If supported,
buildOrUpdateParameters()will be invoked next after a dedicated group parameter has been created for this prim path and plug-in.- Parameters:
- Returns:
bool– Whether the prim should be handled by the plug-in, in which casebuildOrUpdateParameters()will be invoked next.
- abstractmethod classmethod onParameterChanged(node: Node, primPath: str, sdfPrim: Prim, groupParam: Parameter, parameter: Parameter, parameterSampleTime: float, usdSampleTime: float) bool
Invoked by UsdSuperLayer-derived nodes when a parameter created previously by
buildOrUpdateParameters()changes.Plug-ins can implement the function to react to parameter changes.
- Parameters:
node (
Node) – The UsdSuperLayer-derived node.primPath (
str) – The absolute path to the prim.sdfPrim (
Prim) – The prim in the content layer that the plug-in can modify.groupParam (
Parameter) – The group parameter that holds all the plug-in-defined parameters for the target prim.parameter (
Parameter) – The parameter, created previously bybuildOrUpdateParameters(), that has changed.parameterSampleTime (
float) – The time at which to sample the parameter to retrieve the value.usdSampleTime (
float) – The sample time at which to store the USD property. During an interactive session, this will typically be the defaultTimeSample. Whilst exporting or rendering, this will be called for all required time samples.
- Returns:
bool–Trueif thesdfPrimwas modified as a result of the parameter change, otherwiseFalse.
- classmethod setOverride(node: Node, propertiesParam: Parameter, attrName: str, time: float, attrData: list[float]) bool
Applies the node’s transform parameter overrides from given attribute value. This is required by manipulators. The Parameter Handler Plug-ins are responsible for handling this if they want to. The default is that they do not, and return False.
- Parameters:
node (
Node) – The node to which the parameters belong.propertiesParam (
Parameter) – The group parameter that holds all the plug-in-defined parameters for the target prim.attrName (
str) – The name of the attribute to be overriden.time (
float) – The frameTime of current graph state.attrData (
list[float]) – The list of attribute data to override with.
- Returns:
bool– Whether the plug-in has acted on this method.
- class NodesUsdAPI.UsdSuperLayer.ParametersHandlerPlugin.PluginRegistry.ParametersHandlerPluginRegistry
Bases:
PluginRegistryBase- PLUGIN_TYPE_NAME = 'UsdSuperLayerParametersHandler'
- __init__()
Initializer.
- classmethod __new__(*args, **kwargs)
- getActive(pluginName: str) bool | None
Returns the
activevalue of the plug-in specified bypluginName. If there is no corresponding plug-in, returnsNone.- Parameters:
pluginName (
str) – plug-in name.- Returns:
bool|None– Theactivevalue.
- getNodesRegisteredToPlugin(pluginName: str) list[str] | None
Returns the list of nodes that the plug-in specified will construct for when building a context menu.
- Parameters:
pluginName (
str) – The name of the plug-in.- Returns:
list[str] |None– The nodes the plug-in constructs for.
- getPlugin(pluginName: str) type | None
Returns the registered plug-in.
- Parameters:
pluginName (
str) – The name of the plug-in to find.- Returns:
type|None– The registered plug-in. ReturnsNoneif the Plugin with the provided name cannot be found.
- getPluginName(plugin: type) str | None
Returns the plug-in name of the specified
plugin. If there is no corresponding plug-in, returnsNone.A plug-in can be retrieved via
getPlugin().- Parameters:
plugin (
type) – The registered plug-in.- Returns:
str|None– The plug-in name.
- getPluginNames(onlyActive: bool = True) list[str]
Returns registered active plug-in names by default. The names are returned in a sorted order based on priority and then plug-in name if priorities match.
- Parameters:
onlyActive (
bool, default:True) – IfTrue, gather active plug-ins only; otherwise all plug-ins (active and inactive) will be selected. Defaults toTrue.- Returns:
list[str] – The names of plug-ins.
- classmethod getPluginTypeName() str
- Returns:
str– The type of the plug-in.
- getPlugins(onlyActive: bool = True) list[type]
Return the registered active plug-ins by default. The plug-ins are returned in a sorted order based on priority and then plug-in name if priorities match.
- Parameters:
onlyActive (
bool, default:True) – IfTrue, gather active plug-ins only; otherwise all plug-ins (active and inactive) will be selected. Defaults toTrue.- Returns:
list[type] – The registered active plug-ins.
- getPluginsForNodeType(nodeTypeName: str, onlyActive: bool = True) list[type]
Retrieves the plug-in types registered for a given node type name.
By default, only the plug-in type of active plug-ins is returned.
- Parameters:
nodeTypeName (
str) – The name of the node type.onlyActive (
bool, default:True) – IfTrue, gather active plug-ins only; otherwise all plug-ins (active and inactive) will be selected. Defaults toTrue.
- Returns:
list[type] – The plug-in types for the given node type.
- getPriority(pluginName: str) int | None
Returns the
priorityvalue of the plug-in specified bypluginName. if there is no corresponding plug-in, returnsNone.- Parameters:
pluginName (
str) – The name of the plug-in.- Returns:
int|None– Thepriorityvalue.
- loadPluginsFromKatanaResources(reloadCached: bool = False) None
Loads the plug-ins from the “Plugins” subfolder of all folders registered to the KATANA_RESOURCES environment variable.
- Parameters:
reloadCached (
bool, default:False) – Decides whether it should reload modules this plug-in system has already searched and added. By default this is set toFalse.- Return type:
None
- registerNodeToPlugin(pluginName: str, nodeName: str) bool
Registers the specified
nodeNameto the list of nodes that the plug-in specified will construct for when building a context menu. Will returnFalseif the node is already registered.- Parameters:
pluginName (
str) – The name of the plug-in.nodeName (
str) – The name of the node.
- Returns:
bool–Trueif the givenpluginNameis successfully registered;Falseotherwise.
- registerPlugin(plugin: Plugin) bool
Registers the plug-in with the plug-in name into self._registeredPlugins. If the plug-in was already found with the same plug-in name, this plug-in will not be registered.
- Parameters:
plugin (
Plugin) – The plug-in registered.- Returns:
bool–Trueif the registration is successful;Falseotherwise.
- setActive(pluginName: str, active: bool = True) bool
Sets the given active value for the plugin specified by the provided name. The active value is used to determine which plug-ins are gathered in functions like getPlugins, GetPluginNames, etc.
- Parameters:
pluginName (
str) – plug-in name.active (
bool, default:True) – active value set for plug-in, defaults toTrue.
- Returns:
bool–Trueif this the given active is successfully set,Falseotherwise.
- setPriority(pluginName: str, priority: int) bool
Sets the given priority value for the plug-in specified by the provided name. The priority value is used to determine which plug-ins are returned first in functions like getPlugins, GetPluginNames, etc.
- Parameters:
pluginName (
str) – The name of the plug-in.priority (
int) – Priority value set for plug-in.
- Returns:
bool–Trueif the given priority is successfully set;Falseotherwise.
- unregisterNodeFromPlugin(pluginName: str, nodeName: str) bool
Unregister the specified
nodeNamefrom the list of nodes that the plug-in specified will construct for when building a context menu. Will returnFalseif the node isn’t already registered.- Parameters:
pluginName (
str) – The name of the plug-in.nodeName (
str) – The name of the node.
- Returns:
bool–Trueif the givenpluginNameis successfully unregistered;Falseotherwise.
- unregisterPlugin(pluginName: str) None
Removes a plug-in from the UsdLayerSuperTool plug-ins, preventing it from running whilst performing a UsdLayerSuperTool.
- Parameters:
pluginName (
str) – The name of the plug-in to find.- Return type:
None
- validatePlugin(pluginName: str, pluginClass: type, args: dict) str
Implements the
PluginRegistryBase.validatePlugin()virtual method to validate plug-ins.- Parameters:
pluginName (
str) – The plug-in name.pluginClass (
type) – The plug-in class.args (
dict) – The plug-in arguments.
- Returns:
str– A non-empty error message if the validation fails.