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

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) Optional[omni.graph.core._omni_graph_core.Attribute]

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.EXTENDED_ATTR_TYPE_REGULAR. If the extended type is og.ExtendedAttributeType.EXTENDED_ATTR_TYPE_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

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

Returns

True if the attribute was successfully removed, else False (including when the attribute wasn’t found)

classmethod safe_node_name(node_type_name: str, abbreviated: bool = False) str

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