ObjectLookup

class omni.graph.core.ObjectLookup

Bases: object

Helper to extract OmniGraph types from various types of descriptions for them.

These functions take flexible spec types that identify attributes, nodes, or graphs. In most cases the spec types can be either one of or a list of the objects being used or found by the functions. The forms each spec type can take are as follows:

GraphSpec_t
  • An :py:class:`omni.graph.core.Graph` object

  • A string containing the path to an :py:class:`omni.graph.core.Graph` object

  • An :py:class:`Sdf.Path` containing the path to an :py:class:`omni.graph.core.Graph` object

  • A list of any of the above

NodeSpec_t
  • An :py:class:`omni.graph.core.Node` object

  • A string containing the path to an :py:class:`omni.graph.core.Node` object

  • An :py:class:`Sdf.Path` containing the path to an :py:class:`omni.graph.core.Node` object

  • A :py:class:`Usd.Prim` or :py:class:`Usd.Typed` that is the USD backing of an :py:class:`omni.graph.core.Node` object

  • None, for situations in which the node itself is redundant information

  • A 2-tuple consisting of a string and a :py:const:`omni.graph.core.GraphSpec_t`, where the string is a relative path to the :py:class:`omni.graph.core.Node` object within the :py:class:`omni.graph.core.Graph`

  • A list of any of the above

AttributeSpec_t
  • An omni.graph.core.Attribute object

  • A string containing the full path to the omni.graph.core.Attribute object on the USD stage

  • An :py:class:`Sdf.Path` containing the full path to the omni.graph.core.Attribute object on the USD stage

  • A Usd.Attribute that is the USD backing of an omni.graph.core.Attribute object

  • A 2-tuple consisting of a string and a NodeSpec_t, where the string is the omni.graph.core.Attribute object’s name within the :py:class:`omni.graph.core.Node`

  • A list of any of the above

Prim_t
  • A :py:class:`Usd.Prim` or :py:class:`Usd.Typed` object

  • A string containing the path to a :py:class:`Usd.Prim` or :py:class:`Usd.Typed` object

  • An :py:class:`Sdf.Path` containing the path to a :py:class:`Usd.Prim` or :py:class:`Usd.Typed` object

  • A NodeSpec_t, identifying a node whose USD backing :py:class:`Usd.Prim` or :py:class:`Usd.Typed` object is to be returned

  • A list of any of the above

Variables_t
  • An omni.graph.core.IVariable object

  • A 2-tuple consisting of a :py:const:`omni.graph.core.GraphSpec_t` and a string, where the string is the name of the variable

  • A string containing the path of the attribute representing the variable

  • An :py:class:`Sdf.Path` containing the path of the attribute representing the variable

  • A list of any of the above

Methods

attribute(attribute_id[, node_id, graph_id])

Returns the OmniGraph attribute(s) corresponding to the variable type parameter

attribute_path(attribute_spec)

Infers an attribute path from a spec where the attribute may or may not exist

attribute_type(type_id)

Returns the OmniGraph attribute type corresponding to the variable type parameter.

graph(graph_id)

Returns the OmniGraph graph(s) corresponding to the variable type parameter

node(node_id[, graph_id])

Returns the OmniGraph node(s) corresponding to the variable type parameter

node_path(node_spec)

Infers a node path from a spec where the node may or may not exist

node_type(type_id)

Returns the OmniGraph node type corresponding to the variable type parameter

prim(prim_id)

Returns the prim(s) corresponding to the node descriptions

prim_path(prim_ids)

Infers a prim path from a spec where the prim may or may not exist

split_graph_from_node_path(node_path)

Find the lowest level graph from a node path

usd_attribute(attribute_specs)

Returns the Usd.Attribute(s) corresponding to the attribute descriptions

variable(variable_id)

Returns the variables(s) corresponding to the variable description

__init__()
classmethod attribute(attribute_id: Union[omni.graph.core._omni_graph_core.Attribute, str, pxr.Sdf.Path, Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed]], Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed], Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]], List[Union[omni.graph.core._omni_graph_core.Attribute, str, pxr.Sdf.Path, Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed]], Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed], Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]]]]], node_id: Optional[Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed]] = None, graph_id: Optional[Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]] = None) Union[omni.graph.core._omni_graph_core.Attribute, List[omni.graph.core._omni_graph_core.Attribute]]

Returns the OmniGraph attribute(s) corresponding to the variable type parameter

Parameters
  • attribute_id

    Information on which attribute to look for. If a list then get all of them. The attribute_id can take several forms, for maximum flexibility:

    • a 2-tuple consisting of the attribute name as str and a node spec. The named attribute must exist on the node - e.g. (“inputs:value”, my_node) or (“inputs:value”, “/Graph/MyNode”). This is equivalent to passing in the attribute and node spec as two different parameters. You’d use this form when requesting several attributes from different nodes rather than a bunch of attributes from the same node.

    • a str or Sdf.Path pointing directly to the attribute - e.g. “/Graph/MyNode/inputs:value”

    • a str that’s an attribute name, iff the node_id is also specified

    • a Usd.Attribute pointing to the attribute’s reference on the USD side

  • node_id – Node to which the attribute belongs, when only the attribute’s name is provided

  • graph_id – Graph to which the node and attribute belong.

Returns

Attribute(s) matching the description(s) - None where there is no match

Raises
  • og.OmniGraphError if the attribute description wasn't one of the recognized types, if

  • any of the attributes could not be found, or if there was a mismatch in node or graph and attribute.

classmethod attribute_path(attribute_spec: Union[omni.graph.core._omni_graph_core.Attribute, str, pxr.Sdf.Path, Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed]], Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed], Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]]]) str

Infers an attribute path from a spec where the attribute may or may not exist

Parameters

attribute_spec – Location of where the attribute would be, if it exists

Returns

Location of the attribute, if it exists

Raises

og.OmniGraphError – If there was something inconsistent in the attribute spec or a path could not be inferred

classmethod attribute_type(type_id: Union[str, omni.graph.core._omni_graph_core.Type, omni.graph.core._omni_graph_core.Attribute, omni.graph.core._omni_graph_core.AttributeData]) omni.graph.core._omni_graph_core.Type

Returns the OmniGraph attribute type corresponding to the variable type parameter.

All legal OGN types are recognized, as well as the UNKNOWN type.

Parameters

type_id

Variable description of the attribute type object as:

  • An omni.graph.core.Type object

  • An OGN-style type description - e.g. “float[3]”

  • An Sdf-style type description - e.g. “float3”

  • An omni.graph.core.Attribute whose (resolved) type is to be retrieved

  • An omni.graph.core.AttributeData whose (resolved) type is to be retrieved

Returns

Attribute type matching the description

Raises

og.OmniGraphError if the attribute type description wasn't one of the recognized types

classmethod graph(graph_id: Optional[Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph, List[Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]]]]) Union[omni.graph.core._omni_graph_core.Graph, List[omni.graph.core._omni_graph_core.Graph]]

Returns the OmniGraph graph(s) corresponding to the variable type parameter

Parameters

graph_id – Information for the graph to find. If a list then iterate over the list

Returns

Graph(s) corresponding to the description(s) in the current scene, None where there is no match

Raises

og.OmniGraphError if a graph matching the identifier wasn't found

classmethod node(node_id: Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed, Tuple[str, Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]], List[Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed, Tuple[str, Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]]]]], graph_id: Optional[Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]] = None) Union[omni.graph.core._omni_graph_core.Node, List[omni.graph.core._omni_graph_core.Node]]

Returns the OmniGraph node(s) corresponding to the variable type parameter

Parameters
  • node_id – Information for the node to find. If a list then iterate over the list

  • graph_id – Identifier for graph to which the node belongs.

Returns

Node(s) corresponding to the description(s) in the current graph, None where there is no match

Raises
  • og.OmniGraphError – node description wasn’t a recognized type or if a mismatched graph was passed in

  • og.OmniGraphValueError – If the node description did not match a node in the graph

classmethod node_path(node_spec: Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed, Tuple[str, Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]]]) str

Infers a node path from a spec where the node may or may not exist

Parameters

node_spec – Description of a path to a node that may or may not exist

Returns

The path inferred from the node spec. No assumption should be made about the validity of the path.

Raises

og.OmniGraphError – If there was something inconsistent in the node spec or a path could not be inferred

classmethod node_type(type_id: Union[str, omni.graph.core._omni_graph_core.NodeType, omni.graph.core._omni_graph_core.Node, pxr.Usd.Prim, pxr.Usd.Typed, List[Union[str, omni.graph.core._omni_graph_core.NodeType, omni.graph.core._omni_graph_core.Node, pxr.Usd.Prim, pxr.Usd.Typed]]]) Union[omni.graph.core._omni_graph_core.NodeType, List[omni.graph.core._omni_graph_core.NodeType]]

Returns the OmniGraph node type corresponding to the variable type parameter

Parameters
  • type_id – Information used to identify the omni.graph.core.NodeType object.

  • object (- an omni.graph.core.NodeType) –

  • type (- a string that is the unique identifier of the node) –

  • returned (- a Usd.Prim or Usd.Typed that is the USD backing of an omni.graph.core.Node whose type is to be) –

  • returned

  • above (- a list of any combination of the) –

Returns

Node type(s) matching the description

Raises

og.OmniGraphError if the node type description wasn't one of the recognized types or could not be found

classmethod prim(prim_id: Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed, List[Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed]]]) Union[pxr.Usd.Prim, List[pxr.Usd.Prim]]

Returns the prim(s) corresponding to the node descriptions

Parameters

prim_id – Information for the node to find. If a list then iterate over the list

Returns

Prim(s) corresponding to the description(s) in the current graph, None where there is no match

Raises

og.OmniGraphError if the node description didn't correspond to a valid prim.

classmethod prim_path(prim_ids: Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed, List[Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed]]]) Union[str, List[str]]

Infers a prim path from a spec where the prim may or may not exist

Parameters

prim_ids – Identifier of a prim or list of prims that may or may not exist

Returns

The path(s) inferred from the prim spec(s). No assumption should be made about their validity.

Raises

og.OmniGraphError – If there was something inconsistent in the prim spec or a path could not be inferred

classmethod split_graph_from_node_path(node_path: Union[str, pxr.Sdf.Path]) Tuple[omni.graph.core._omni_graph_core.Graph, str]

Find the lowest level graph from a node path

The path /World/Graph1/Graph2/Node1/Node2 would return the og.Graph at /World/Graph1/Graph2 and the relative node path “Node1/Node2”.

Parameters

node_path – Full path to the node from the root

Returns

(graph, node_path) where graph is the lowest graph in the tree and node_path is the relative path to the node from the graph

classmethod usd_attribute(attribute_specs: Union[omni.graph.core._omni_graph_core.Attribute, str, pxr.Sdf.Path, Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed]], Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed], Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]], List[Union[omni.graph.core._omni_graph_core.Attribute, str, pxr.Sdf.Path, Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed]], Tuple[str, Union[str, omni.graph.core._omni_graph_core.Node, pxr.Sdf.Path, pxr.Usd.Prim, pxr.Usd.Typed], Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph]]]]]) Union[pxr.Usd.Attribute, List[pxr.Usd.Attribute]]

Returns the Usd.Attribute(s) corresponding to the attribute descriptions

Parameters

attribute_specs – Location or list of locations from which to infer a matching Usd.Attribute

Returns

Usd.Attribute(s) corresponding to the description(s) in the current graph

Raises

og.OmniGraphError if the attribute description didn't correspond to a valid Usd.Attribute.

classmethod variable(variable_id: Union[omni.graph.core._omni_graph_core.IVariable, Tuple[Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph], str], str, pxr.Sdf.Path, List[Union[omni.graph.core._omni_graph_core.IVariable, Tuple[Union[str, pxr.Sdf.Path, omni.graph.core._omni_graph_core.Graph], str], str, pxr.Sdf.Path]]]) Union[omni.graph.core._omni_graph_core.IVariable, List[omni.graph.core._omni_graph_core.IVariable]]

Returns the variables(s) corresponding to the variable description

Parameters

variable_id – Information for the variable to find. If a list then iterate over the list

Returns

Variables(s) corresponding to the description(s) in the current graph, None where there is no match

Raises

og.OmniGraphError if the variable description didn't correspond to a valid variable