NodeController#
- class omni.graph.core.NodeController(*args, **kwargs)#
Bases:
object
Helper class that provides a simple interface to modifying the contents of a node
Methods
__init__
(*args, **kwargs)Initializes the class with a particular configuration.
create_attribute
(*args, **kwargs)Create a new dynamic attribute on the node
promote_attribute
(*args, **kwargs)Promotes an attribute on a node in a compound graph, making it accessable to the parenting compound node.
remove_attribute
(*args, **kwargs)Removes an existing dynamic attribute from a node.
safe_node_name
(node_type_name[, abbreviated])Returns a USD-safe node name derived from the node_type_name
- __init__(*args, **kwargs)#
Initializes the class with a particular configuration. The arguments are flexible so that classes can initialize only what they need for the calls they will be making. The argument is optional and there may be other arguments present that will be ignored
- Parameters:
undoable (bool) – If True the operations performed with this instance of the class are to be added to the undo queue, else they are done immediately and forgotten
- classmethod create_attribute(
- *args,
- **kwargs,
Create a new dynamic attribute on the node
This function can be called either from the class or using an instantiated object. The first argument is positional, being either the class or object. All others are by keyword and optional, defaulting to the value set in the constructor in the object context and the function defaults in the class context.
- Parameters:
obj – Either cls or self depending on how the function was called
node – Node on which to create the attribute (path or og.Node)
attr_name – Name of the new attribute, either with or without the port namespace
attr_type – Type of the new attribute, as an OGN type string or og.Type
attr_port – Port type of the new attribute, default is og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT
attr_default – The initial value to set on the attribute, default is None which means use the type’s default
attr_extended_type – The extended type of the attribute, default is og.ExtendedAttributeType.REGULAR. If the extended type is og.ExtendedAttributeType.UNION then this parameter will be a 2-tuple with the second element being a list or comma-separated string of union types
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten
- Returns:
The newly created attribute, None if there was a problem creating it
- Return type:
- classmethod promote_attribute(
- *args,
- **kwargs,
Promotes an attribute on a node in a compound graph, making it accessable to the parenting compound node.
This function can be called either from the class or using an instantiated object. The first argument is positional, being either the class or object. All others are by keyword and optional, defaulting to the value set in the constructor in the object context and the function defaults in the class context.
- Parameters:
obj – Either cls or self depending on how the function was called
src_spec – Specification of the attribute to be promoted
name – The name of the promoted attribute. If not specified, the namespace prefix will be prepended based
src_spec. (on)
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Returns:
The attribute created on the compound node that connects to the attribute
- Return type:
og.Attribute
- Raises:
OmniGraphError – If attribute could not be found, the attribute does not belong to a compound, or the promoted
name already exists –
- classmethod remove_attribute(*args, **kwargs) bool #
Removes an existing dynamic attribute from a node.
This function can be called either from the class or using an instantiated object. The first argument is positional, being either the class or object. All others are by keyword and optional, defaulting to the value set in the constructor in the object context and the function defaults in the class context.
- Parameters:
obj – Either cls or self depending on how the function was called
attribute – Reference to the attribute to be removed
node – If the attribute reference is a string the node is used to find the attribute to be removed
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten
- Raises:
OmniGraphError – if the attribute was not found or could not be removed
- classmethod safe_node_name(
- node_type_name: str,
- abbreviated: bool = False,
Returns a USD-safe node name derived from the node_type_name
- Parameters:
node_type_name – Fully namespaced name of the node type (e.g. omni.graph.nodes.Clamp)
abbreviated – If True then remove the namespace, else just make the separators into underscores
- Returns:
A safe node name that roughly corresponds to the given node type name
- Return type:
str