GraphController
- class omni.graph.core.GraphController(*args, **kwargs)
Bases:
object
Helper class that provides a simple interface to modifying the contents of a graph
Methods
__init__
(*args, **kwargs)Initializes the class with a particular configuration.
connect
(*args, **kwargs)Create a connection between two attributes
create_graph
(*args, **kwargs)Create a graph from the description
create_node
(*args, **kwargs)Create an OmniGraph node of the given type and version at the given path.
create_prim
(*args, **kwargs)Create a prim node containing a predefined set of attribute values and a ReadPrim OmniGraph node for it
create_variable
(*args, **kwargs)Creates a variable with the given name on the graph
delete_node
(*args, **kwargs)Deletes one or more OmniGraph nodes.
disconnect
(*args, **kwargs)Break a connection between two attributes
disconnect_all
(*args, **kwargs)Break all connections to and from an attribute
expose_prim
(*args, **kwargs)Create a new compute node attached to an ordinary USD prim or list of prims.
exposed_attribute_name
(exposure_type)Returns the name of the attribute that will be used to expose the prim for a given exposure type
get_variable_default_value
(variable_id)Gets the default value of the given variable
node_type_to_expose
(exposure_type)Returns the type of node that will be used to expose the prim for a given exposure type
set_variable_default_value
(variable_id, value)Sets the default value of a variable object.
Attributes
ExposePrimNode_t
(*args, **kwargs)Typing for information required to expose a prim in a node
ExposePrimNodes_t
(*args, **kwargs)Typing for information required to expose a list of prims in nodes
PrimExposureType_t
(*args, **kwargs)Flexible type to specify how to expose the prim
- __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. Both arguments are optional, and there may be other arguments present that will be ignored.
- Parameters
update_usd (bool) – Should any graphs, nodes, and prims referenced in operations be updated immediately to USD? (default True)
undoable (bool) – If True the operations performed with this instance of the class are added to the undo queue, else they are done immediately and forgotten (default True)
allow_exists_node – If True then succeed creation of a node when matching path, type, and version already exists. It is still a failure if one of those properties on the existing node does not match.
allow_exists_prim – If True then succeed creation of a prim when matching path and type already exists. It is still a failure if type on the existing prim does not match.
- class PrimExposureType(value)
Bases:
Enum
Value that specifies the method of exposing USD prims to OmniGraph
- AS_ATTRIBUTES = 'attributes'
Expose the prim via a node that creates outputs for all of the prim’s attributes
- AS_BUNDLE = 'bundle'
Expose the prim via a node that creates a single output bundle with all of the prim’s attributes
- AS_WRITABLE = 'writable'
Expose the prim to be written to via a node that creates inputs for the prim’s attributes
- classmethod connect(*args, **kwargs)
Create a connection between two attributes
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 the source end of the connection
dst_spec – Specification of the attribute to be the destination end of the connection
update_usd – If specified then override whether to delete the node’s USD backing (default True)
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Raises
OmniGraphError – If attributes could not be found or the connection fails
- classmethod create_graph(*args, **kwargs) Graph
Create a graph from the description
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. The second argument can be positional or by keyword and is mandatory, resulting in an error if omitted. 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.
new_graph = og.GraphController.create_graph("/TestGraph") controller = og.GraphController(undoable=True) controller.create_graph({"graph_path": "/UndoableGraph", "evaluator_name": "execution"})
- Parameters
obj – Either cls or self, depending on how the function was called
graph_id –
Parameters describing the graph to be created. If the graph is just a path then a default graph will be created at that location. If the identifier is a dictionary then it will be interpreted as a set of parameters describing the type of graph to create
graph_path: Full path to the graph prim to be created to house the OmniGraph
evaluator_name: Type of evaluator the graph should use (default push)
fc_backing_type: og.GraphBackingType that tells you what kind of Fabric to use for graph data (default og.GraphBackingType.GRAPH_BACKING_TYPE_FABRIC_SHARED)
pipeline_stage: og.GraphPipelineStage that tells you which pipeline stage this graph fits into (default og.GraphPipelineStage.GRAPH_PIPELINE_STAGE_SIMULATION)
evaluation_mode: og.GraphEvaluationMode that tells you which evaluation mode this graph uses (default og.GraphEvaluationMode.GRAPH_EVALUATION_MODE_AUTOMATIC)
update_usd (bool) – If specified then override whether to create the graph with a USD backing (default True)
undoable (bool) – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Returns
The created graph
- Return type
- Raises
OmniGraphError – if the graph creation failed for any reason
- classmethod create_node(*args, **kwargs) Graph
Create an OmniGraph node of the given type and version at the given path.
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. “node_id” and “node_type_id” are mandatory, and can be specified either as positional or keyword arguments. All others are by keyword only and optional, defaulting to the value set in the constructor in the object context where available, and the function defaults elsewhere.
og.GraphController.create_node("/MyGraph/MyNode", "omni.graph.nodes.NodeType") og.GraphController(update_usd=True).create_node("/MyGraph/MyNode", "omni.graph.nodes.NodeType") og.GraphController.create_node("/MyGraph/MyNode", "omni.graph.nodes.NodeType", update_usd=True) og.GraphController.create_node(node_id="/MyGraph/MyNode", node_type="omni.graph.nodes.NodeType")
- Parameters
obj – Either cls or self, depending on how the function was called
node_id – Absolute path, or (Relative Path, Graph) where the node will be constructed. If an absolute path was passed in it must be part of an existing graph.
node_type_id – Unique identifier for the type of node to create (name or og.NodeType)
allow_exists – If True then succeed if a node with matching path, type, and version already exists. It is still a failure if one of those properties on the existing node does not match.
version – Version of the node type to create. By default it creates the most recent.
update_usd – If specified then override whether to create the node with a USD backing or not (default True)
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Raises
og.OmniGraphError – If one or more of the nodes could not be added to the scene for some reason.
- Returns
Node(s) added to the scene
- Return type
- classmethod create_prim(*args, **kwargs) Prim
Create a prim node containing a predefined set of attribute values and a ReadPrim OmniGraph node for it
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. The “prim_path” is mandatory and can appear as either a positional or keyword argument. All others are optional, also by position or keyword, defaulting to the value set in the constructor in the object context if available, and the function defaults elsewhere.
og.GraphController.create_prim("/MyPrim") og.GraphController(undoable=False).create_prim("/MyPrim", undoable=True) # Will be undoable og.GraphController().create_prim(prim_path="/MyPrim", prim_type="MyPrimType") og.GraphController.create_prim("/MyPrim", )
- Parameters
obj – Either cls or self depending on how the function was called
prim_path – Location of the prim
attribute_values – Dictionary of {NAME: (TYPE, VALUE)} for all prim attributes The TYPE recognizes OGN format, SDF format, or og.Type values The VALUE should be in a format suitable for passing to pxr::UsdAttribute.Set()
prim_type – The type of prim to create. (default “OmniGraphPrim”)
allow_exists – If True then succeed if a prim with matching path and type already exists. It is still a failure if type on the existing prim does not match.
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Returns
Prim created
- Return type
Usd.Prim
- Raises
OmniGraphError – If any of the attribute specifications could not be applied to the prim, or if the prim could not be created.
- classmethod create_variable(*args, **kwargs) IVariable
Creates a variable with the given name on the graph
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
graph_id – The graph to create a variable on
name – The name of the variable to create
var_type – The type of the variable to create, either a string or an OG.Type
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
default_value – The default value of the variable to set, or None to not set a default value. (default None)
- Raises
OmniGraphError – If the variable can’t be created
- Returns
The created variable
- Return type
- classmethod delete_node(*args, **kwargs) bool
Deletes one or more OmniGraph nodes.
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_id – Specification of a node or list of nodes to be deleted
graph_id – Only required if the node_id does not contain enough information to uniquely identify it
ignore_if_missing – If True then succeed even if no node with a matching path exists
update_usd – If specified then override whether to delete the node’s USD backing (default True)
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Raises
OmniGraphError – If the node does not exist
- Returns
True if the node was successfully deleted
- Return type
bool
- classmethod disconnect(*args, **kwargs)
Break a connection between two attributes
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 that is the source end of the connection
dst_spec – Specification of the attribute that is the destination end of the connection
update_usd – If specified then override whether to delete the node’s USD backing (default True)
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Raises
OmniGraphError – If attributes could not be found or the disconnection fails
- classmethod disconnect_all(*args, **kwargs)
Break all connections to and from an attribute
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_spec – Attribute whose connections are to be removed. (attr or (attr, node) pair)
update_usd – If specified then override whether to delete the node’s USD backing (default True)
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Raises
OmniGraphError – If attribute could not be found, connection didn’t exist, or disconnection fails
- classmethod expose_prim(*args, **kwargs) Node
Create a new compute node attached to an ordinary USD prim or list of prims.
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
exposure_type – Method for exposing the prim to OmniGraph
prim_id – Identifier of an existing prim in the USD stage
node_path_id – Identifier of a node path that is valid but does not currently exist
update_usd – If specified then override whether to delete the node’s USD backing (default True)
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten (default True)
- Returns
Node exposing the prim to OmniGraph
- Return type
- Raises
og.OmniGraphError – if the prim does not exist, or the node path already exists
- classmethod exposed_attribute_name(exposure_type: PrimExposureType_t) str
Returns the name of the attribute that will be used to expose the prim for a given exposure type
- Parameters
exposure_type – Type of exposure desired
- Returns
Name of the attribute at which a connection should be made to the prim for exposure
- Return type
str
- classmethod get_variable_default_value(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]) Any
Gets the default value of the given variable
- Parameters
variable_id – The variable whose value is to be set
- Returns
The default value of the variable.
- Return type
Any
- Raises
OmniGraphError – If the variable is not valid or does not have valid usd backing.
- classmethod node_type_to_expose(exposure_type: PrimExposureType_t) str
Returns the type of node that will be used to expose the prim for a given exposure type
- Parameters
exposure_type – Type of exposure desired
- Returns
Node type of the appropriate omni.graph.core.Node to use to expose the prim
- Return type
str
- classmethod set_variable_default_value(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], value)
Sets the default value of a variable object.
- Parameters
variable_id – The variable whose value is to be set
value – The value to set
- Raises
OmniGraphError – If the variable is not valid, does not have valid usd backing, or value
is not a compatible type –
- ExposePrimNode_t(*args, **kwargs)
Typing for information required to expose a prim in a node
alias of
Tuple
[str
|Path
|Node
|Prim
|Typed
|Graph
,str
|Path
|tuple
[str
|Path
|Graph
|Prim
|Typed
]]
- ExposePrimNodes_t(*args, **kwargs)
Typing for information required to expose a list of prims in nodes
alias of
Union
[Tuple
[str
|Path
|Node
|Prim
|Typed
|Graph
,str
|Path
|tuple
[str
|Path
|Graph
|Prim
|Typed
]],List
[Tuple
[str
|Path
|Node
|Prim
|Typed
|Graph
,str
|Path
|tuple
[str
|Path
|Graph
|Prim
|Typed
]]]]
- PrimExposureType_t(*args, **kwargs)
Flexible type to specify how to expose the prim
alias of
Union
[str
,PrimExposureType
]