TypeConversion
- class omni.graph.core.typing.TypeConversion
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
Conversion method to go from source type to destination type
- ASSIGN = (0,)
Return the value to be assigned to the destination
- MODIFY = 1
Pass in the destination object to be modified in place
- classmethod from_ogn_type(og_type: str) omni.graph.core._impl.autonode_deprecated.data_typing.TypeDesc | None
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) omni.graph.core._impl.autonode_deprecated.data_typing.TypeDesc | None
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: callable = None, python_to_ogn_method: Method = Method.ASSIGN, ogn_to_python: callable = None, ogn_to_python_method: 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 – Type representation in python.
ogn_typename – String representation of the ogn type. Node generation will fail on unrecognized types.
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
ogn_to_python_method – [optional] Type
- classmethod unregister_type_conversion(python_type: type = None, ogn_type_name: str = None) omni.graph.core._impl.autonode_deprecated.data_typing.TypeDesc | None
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.