AutoNodeTypeConversion
- class omni.graph.core.autonode.AutoNodeTypeConversion
Bases:
object
Static class for storing conversion methods between python types and Omnigraph types
Methods
__init__
()from_ogn_type
(og_type)Searches the conversion registry using an Omnigraph type.
from_type
(type_desc)Searches the conversion registry using a python type.
register_type_conversion
(python_type, ...[, ...])Registers a type conversion between a python type and an ogn type.
unregister_type_conversion
([python_type, ...])Unregisters a type conversion from python to ogn.
Attributes
types
user_types
- __init__()
- class Method(value)
Bases:
enum.Enum
An enumeration.
- classmethod from_ogn_type(og_type: str) Optional[omni.graph.core._impl.autonode.type_definitions.TypeDesc]
Searches the conversion registry using an Omnigraph type. Searches the user types first, defaults to the system types.
- Parameters
og_type – string representing the incoming ogn type
- Returns
TypeDesc for the found python type if it’s found, None otherwise
- classmethod from_type(type_desc: type) Optional[omni.graph.core._impl.autonode.type_definitions.TypeDesc]
Searches the conversion registry using a python type.
- Parameters
type_desc – python type to convert
- Returns
TypeDesc for the found python type if it’s found, None otherwise
- classmethod register_type_conversion(python_type: type, ogn_typename: str, python_to_ogn: Optional[Callable] = None, python_to_ogn_method: omni.graph.core._impl.autonode.type_definitions.AutoNodeTypeConversion.Method = Method.ASSIGN, ogn_to_python: Optional[Callable] = None, ogn_to_python_method: omni.graph.core._impl.autonode.type_definitions.AutoNodeTypeConversion.Method = Method.ASSIGN, default=None)
Registers a type conversion between a python type and an ogn type. Masks any existing system setting. If a previous user-submitted type conversion is registered, it will be overridden.
- Parameters
python_type – the type representation in python.
ogn_typename – string representation of the ogn type. Node generation will fail if the type isn’t recognized by ogn.
python_to_ogn – [optional] function to convert a python return value to an OGN struct. Signature is Callable[[[python_type], object]. Defaults to None
ogn_to_python – [optional] function to convert an OGN struct to a python return value. Signature is Callable[[[object], python_type]. Defaults to None
- classmethod unregister_type_conversion(python_type: Optional[type] = None, ogn_type_name: Optional[str] = None) Optional[omni.graph.core._impl.autonode.type_definitions.TypeDesc]
Unregisters a type conversion from python to ogn. Doesn’t unregister system types.
- Parameters
python_type – the python type to be removed from support
ogn_type_name – the ogn type name type to be removed from support
- Returns
The TypeDesc tuple just unregistered, or none.