Call Python from C++
Utility functions to invoke Python via Carbonite’s scripting-python plugin and execute python commands with simple return types.
Note: Python library support is a compile-time optional feature. These functions are only available if Python was enabled at compile time.
If more complex behavior is required, use pybind11 to call python directly.
Functions
- std::shared_ptr< carb::scripting::Object > omni::connect::core::acquirePythonObjectInstance(const std::string &function)
Execute a global python function which returns an instance of an object.
- bool omni::connect::core::executePythonCommand(const std::string &command)
Execute a single python command.
- int omni::connect::core::executePythonIntFunction(const std::string &function)
Execute a global python function which returns an int.
- int omni::connect::core::executePythonIntMethod(carb::scripting::Object *instance, const std::string &method)
Given an instance of a python object, execute a method which returns an int.
- std::string omni::connect::core::executePythonStringFunction(const std::string &function)
Execute a global python function which returns a string.
- std::string omni::connect::core::executePythonStringMethod(carb::scripting::Object *instance, const std::string &method)
Given an instance of a python object, execute a method which returns a string.
- bool omni::connect::core::startupPython()
Load Carbonite's scripting-python plugin and initialize the python interpreter.