Blender V5.3
BPY_extern_run.hh File Reference
#include "BLI_compiler_attrs.hh"
#include "BLI_string_ref.hh"
#include "BLI_sys_types.hh"

Go to the source code of this file.

Classes

struct  blender::BPy_RunErrInfo

Namespaces

namespace  blender
 BMesh Iterators.

Functions

Run File/Text as a Script
Note
BPY_run_filepath and BPY_run_filepath have almost identical behavior one operates on a file-path, the other on a blender text-block.
bool blender::BPY_run_filepath (bContext *C, const char *filepath, ReportList *reports) ATTR_NONNULL(1
bool bool blender::BPY_run_text (bContext *C, Text *text, ReportList *reports, bool do_jump) ATTR_NONNULL(1
Run a String as a Script
  • Use 'eval' for simple single-line expressions.
  • Use 'exec' for full multi-line scripts.
bool blender::BPY_string_compile_check (const char *expr)
bool blender::BPY_run_string_exec (bContext *C, const char *imports[], const char *expr)
bool blender::BPY_run_string_eval (bContext *C, const char *imports[], const char *expr)
bool blender::BPY_run_string_exec_with_locals (bContext *C, StringRefNull script, IDProperty &locals)
std::optional< IDProperty * > blender::BPY_run_string_exec_with_locals_return_idprop (bContext *C, StringRefNull script, IDProperty &locals, StringRefNull result_var_name)
Run a String as a Script & Return the Result

Convenience functions for executing a script and returning the result as an expected type.

bool blender::BPY_run_string_as_number (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, double *r_value) ATTR_NONNULL(1
bool bool blender::BPY_run_string_as_intptr (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, intptr_t *r_value) ATTR_NONNULL(1
bool bool bool blender::BPY_run_string_as_string_and_len (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, char **r_value, size_t *r_value_len) ATTR_NONNULL(1
bool bool bool bool blender::BPY_run_string_as_string (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, char **r_value) ATTR_NONNULL(1
bool bool bool bool bool blender::BPY_run_string_as_string_and_len_or_none (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, char **r_value, size_t *r_value_len) ATTR_NONNULL(1
bool bool bool bool bool bool blender::BPY_run_string_as_string_or_none (bContext *C, const char *imports[], const char *expr, BPy_RunErrInfo *err_info, char **r_value) ATTR_NONNULL(1

Detailed Description

Common Arguments

  • C the #bContext (never NULL).
  • imports: This is simply supported for convenience since imports can make constructing strings more cumbersome as otherwise small expressions become multi-line code-blocks. Optional (ignored when NULL), otherwise this is a NULL terminated array of module names.

    Failure to import any modules prevents any further execution.

  • err_info #BPy_RunErrInfo is passed to some functions so errors can be forwarded to the UI. Option (when NULL errors are printed to the stdout and cleared). However this should be used in any case the error would be useful to show to the user.

Definition in file BPY_extern_run.hh.