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 omni.graph.core.Graph object

  • A string containing the path to an omni.graph.core.Graph object

  • An Sdf.Path containing the path to an omni.graph.core.Graph object

  • A list of any of the above

NodeSpec_t
  • An omni.graph.core.Node object

  • A string containing the path to an omni.graph.core.Node object

  • An Sdf.Path containing the path to an omni.graph.core.Node object

  • A Usd.Prim or Usd.Typed that is the USD backing of an 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 omni.graph.core.GraphSpec_t, where the string is a relative path to the omni.graph.core.Node object within the 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 Sdf.Path containing the full path to the omni.graph.core.Attribute object on the USD stage

  • A Usd.Attribute or Usd.Relationship 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 omni.graph.core.Node

  • A list of any of the above

Prim_t
  • A Usd.Prim or Usd.Typed object

  • A string containing the path to a Usd.Prim or Usd.Typed object

  • An Sdf.Path containing the path to a Usd.Prim or Usd.Typed object

  • A NodeSpec_t, identifying a node whose USD backing Usd.Prim or 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 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 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.

compound_graph(node_id)

Returns the compound graph of a given node or nodes, or None if the node does not contain a compound graph

compound_node(item_id)

Returns the owning compound node for a given graph, or node, or None if the graph or node is not encapsulated by a compound node

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

usd_property(attribute_specs)

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

usd_relationship(attribute_specs)

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

variable(variable_id)

Returns the variables(s) corresponding to the variable description

__init__()
classmethod attribute(attribute_id: omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed] | list[omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]], node_id: Optional[Union[str, Node, Path, Prim, Typed]] = None, graph_id: Optional[Union[str, Path, Graph, Prim, Typed]] = None) Union[Attribute, List[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 one of 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 or Usd.Relationship 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

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: omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]) 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

Return type

str

Raises

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

classmethod attribute_type(type_id: str | omni.graph.core._omni_graph_core.Type | omni.graph.core._omni_graph_core.Attribute | omni.graph.core._omni_graph_core.AttributeData) 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 one of:

  • 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

Return type

omni.graph.core.Type

Raises

OmniGraphError – if the attribute type description wasn’t one of the recognized types

classmethod compound_graph(node_id: str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed | tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed] | list[str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed | tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]]) Union[Graph, None, List[omni.graph.core._omni_graph_core.Graph | None]]

Returns the compound graph of a given node or nodes, or None if the node does not contain a compound graph

Parameters

node_id

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

Returns:
omni.graph.core.Graph | None | list[omni.graph.core.Graph | None]: The compound graph instances

the contained by the given nodes. If node does not encapsulate a compound graph, the value None is returned.

Raises:

omni.graph.core.OmniGraphError: node_id description wasn’t a recognized type

classmethod compound_node(item_id: Union[str, Path, Graph, Prim, Typed, Node, tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed], List[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed | omni.graph.core._omni_graph_core.Node | tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]]]) Union[Node, None, List[omni.graph.core._omni_graph_core.Graph | None]]

Returns the owning compound node for a given graph, or node, or None if the graph or node is not encapsulated by a compound node

Parameters

item_id – The graph, node, or list of graphs and nodes, to retrieve the owning compound node(s) for.

Returns

The compound node(s) that encapsulate the provided graph(s), or None if the graph(s) are not encapsulated by a compound node

Return type

omni.graph.core.Node | None | list[omni.graph.core.Node | None]

Raises

omni.graph.core.OmniGraphError – The provided graphs or nodes are invalid or unrecognized types.

classmethod graph(graph_id: Optional[Union[str, Path, Graph, Prim, Typed, list[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]]]) Union[Graph, List[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

Return type

omni.graph.core.Graph | list[omni.graph.core.Graph]

Raises

OmniGraphError – if a graph matching the identifier wasn’t found

classmethod node(node_id: str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed | tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed] | list[str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed | tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]], graph_id: Optional[Union[str, Path, Graph, Prim, Typed]] = None) Union[Node, List[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

Return type

omni.graph.core.Node | list[omni.graph.core.Node]

Raises
  • 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: str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed | tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]) 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.

Return type

str

Raises

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

classmethod node_type(type_id: str | omni.graph.core._omni_graph_core.NodeType | omni.graph.core._omni_graph_core.Node | pxr.Usd.Prim | pxr.Usd.Typed | list[str | omni.graph.core._omni_graph_core.NodeType | omni.graph.core._omni_graph_core.Node | pxr.Usd.Prim | pxr.Usd.Typed]) Union[NodeType, List[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; it will be one of:

  • 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

Return type

omni.graph.core.NodeType | list[omni.graph.core.NodeType]

Raises

OmniGraphError – if the node type description wasn’t one of the recognized types or could not be found

classmethod prim(prim_id: str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Node | pxr.Usd.Prim | pxr.Usd.Typed | omni.graph.core._omni_graph_core.Graph | list[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Node | pxr.Usd.Prim | pxr.Usd.Typed | omni.graph.core._omni_graph_core.Graph]) Union[Prim, List[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

Return type

Usd.Prim | list[Usd.Prim]

Raises

OmniGraphError – if the node description(s) didn’t correspond to a valid prim(s).

classmethod prim_path(prim_ids: str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Node | pxr.Usd.Prim | pxr.Usd.Typed | omni.graph.core._omni_graph_core.Graph | list[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Node | pxr.Usd.Prim | pxr.Usd.Typed | omni.graph.core._omni_graph_core.Graph]) 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

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

Return type

str | list[str]

Raises

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, Path]) Tuple[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

where graph is the lowest graph in the tree and node_path is the

relative path to the node from the graph

Return type

tuple[omni.graph.core.Graph, str]

classmethod usd_attribute(attribute_specs: omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed] | list[omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]]) Union[Attribute, List[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 USD stage

Return type

Usd.Attribute | list[Usd.Attribute]

Raises

OmniGraphError – if the attribute description didn’t correspond to a valid Usd.Attribute.

classmethod usd_property(attribute_specs: omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed] | list[omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]]) Union[Property, List[Property]]

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

Parameters

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

Returns

Usd.Property(s) corresponding to the description(s) in the USD stage

Return type

Usd.Property | list[Usd.Property]

Raises

OmniGraphError – if the attribute description didn’t correspond to a valid Usd.Property.

classmethod usd_relationship(attribute_specs: omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed] | list[omni.graph.core._omni_graph_core.Attribute | str | pxr.Sdf.Path | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str | omni.graph.core._omni_graph_core.Node | pxr.Sdf.Path | pxr.Usd.Prim | pxr.Usd.Typed] | tuple[str | tuple[str, omni.graph.core._omni_graph_core.AttributePortType], str, str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed]]) Union[Relationship, List[Relationship]]

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

Parameters

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

Returns

Usd.Relationship(s) corresponding to the description(s) in the USD stage

Return type

Usd.Relationship | list[Usd.Relationship]

Raises

OmniGraphError – if the attribute description didn’t correspond to a valid Usd.Relationship.

classmethod variable(variable_id: str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.IVariable | tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed, str] | list[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.IVariable | tuple[str | pxr.Sdf.Path | omni.graph.core._omni_graph_core.Graph | pxr.Usd.Prim | pxr.Usd.Typed, str]]) Union[IVariable, List[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

Return type

omni.graph.core.IVariable | list[omni.graph.core.IVariable]

Raises

OmniGraphError – if the variable description didn’t correspond to a valid variable