Blender V4.3
bpy.cc File Reference
#include <Python.h>
#include "BLI_string.h"
#include "BLI_string_utils.hh"
#include "BLI_utildefines.h"
#include "BKE_appdir.hh"
#include "BKE_blender_version.h"
#include "BKE_bpath.hh"
#include "BKE_global.hh"
#include "RNA_access.hh"
#include "RNA_enum_types.hh"
#include "RNA_prototypes.hh"
#include "GPU_state.hh"
#include "WM_api.hh"
#include "bpy.hh"
#include "bpy_app.hh"
#include "bpy_cli_command.hh"
#include "bpy_driver.hh"
#include "bpy_library.hh"
#include "bpy_operator.hh"
#include "bpy_props.hh"
#include "bpy_rna.hh"
#include "bpy_rna_data.hh"
#include "bpy_rna_gizmo.hh"
#include "bpy_rna_types_capi.hh"
#include "bpy_utils_previews.hh"
#include "bpy_utils_units.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_compat.hh"
#include "../generic/python_utildefines.hh"
#include "../generic/idprop_py_api.hh"
#include "../generic/idprop_py_ui_api.hh"
#include "bpy_msgbus.hh"
#include "RNA_enum_items.hh"

Go to the source code of this file.

Macros

#define PY_SSIZE_T_CLEAN
 
#define DEF_ENUM(id)   {STRINGIFY(id), id},
 
#define SetFlagItem(x)    PyDict_SetItemString(result, STRINGIFY(x), PyBool_FromLong((WM_CAPABILITY_##x) & flag));
 
#define PYMODULE_ADD_METHOD(mod, meth)    PyModule_AddObject(mod, (meth)->ml_name, (PyObject *)PyCFunction_New(meth, mod))
 

Functions

 PyDoc_STRVAR (bpy_script_paths_doc, ".. function:: script_paths()\n" "\n" " Return 2 paths to blender scripts directories.\n" "\n" " :return: (system, user) strings will be empty when not found.\n" " :rtype: tuple[str, str]\n")
 
static PyObject * bpy_script_paths (PyObject *)
 
static bool bpy_blend_foreach_path_cb (BPathForeachPathData *bpath_data, char *, size_t, const char *path_src)
 
 PyDoc_STRVAR (bpy_blend_paths_doc, ".. function:: blend_paths(absolute=False, packed=False, local=False)\n" "\n" " Returns a list of paths to external files referenced by the loaded .blend file.\n" "\n" " :arg absolute: When true the paths returned are made absolute.\n" " :type absolute: bool\n" " :arg packed: When true skip file paths for packed data.\n" " :type packed: bool\n" " :arg local: When true skip linked library paths.\n" " :type local: bool\n" " :return: path list.\n" " :rtype: list[str]\n")
 
static PyObject * bpy_blend_paths (PyObject *, PyObject *args, PyObject *kw)
 
 PyDoc_STRVAR (bpy_flip_name_doc, ".. function:: flip_name(name, strip_digits=False)\n" "\n" " Flip a name between left/right sides, useful for \n" " mirroring bone names.\n" "\n" " :arg name: Bone name to flip.\n" " :type name: str\n" " :arg strip_digits: Whether to remove ``.###`` suffix.\n" " :type strip_digits: bool\n" " :return: The flipped name.\n" " :rtype: str\n")
 
static PyObject * bpy_flip_name (PyObject *, PyObject *args, PyObject *kw)
 
static PyObject * bpy_user_resource (PyObject *, PyObject *args, PyObject *kw)
 
 PyDoc_STRVAR (bpy_system_resource_doc, ".. function:: system_resource(type, path=\"\")\n" "\n" " Return a system resource path.\n" "\n" " :arg type: string in ['DATAFILES', 'SCRIPTS', 'EXTENSIONS', 'PYTHON'].\n" " :type type: str\n" " :arg path: Optional subdirectory.\n" " :type path: str | bytes\n")
 
static PyObject * bpy_system_resource (PyObject *, PyObject *args, PyObject *kw)
 
 PyDoc_STRVAR (bpy_resource_path_doc, ".. function:: resource_path(type, major=bpy.app.version[0], minor=bpy.app.version[1])\n" "\n" " Return the base path for storing system files.\n" "\n" " :arg type: string in ['USER', 'LOCAL', 'SYSTEM'].\n" " :type type: str\n" " :arg major: major version, defaults to current.\n" " :type major: int\n" " :arg minor: minor version, defaults to current.\n" " :type minor: str\n" " :return: the resource path (not necessarily existing).\n" " :rtype: str\n")
 
static PyObject * bpy_resource_path (PyObject *, PyObject *args, PyObject *kw)
 
 PyDoc_STRVAR (bpy_driver_secure_code_test_doc, ".. function:: _driver_secure_code_test(code)\n" "\n" " Test if the script should be considered trusted.\n" "\n" " :arg code: The code to test.\n" " :type code: code\n" " :arg namespace: The namespace of values which are allowed.\n" " :type namespace: dict[str, Any]\n" " :arg verbose: Print the reason for considering insecure to the ``stderr``.\n" " :type verbose: bool\n" " :return: True when the script is considered trusted.\n" " :rtype: bool\n")
 
static PyObject * bpy_driver_secure_code_test (PyObject *, PyObject *args, PyObject *kw)
 
 PyDoc_STRVAR (bpy_escape_identifier_doc, ".. function:: escape_identifier(string)\n" "\n" " Simple string escaping function used for animation paths.\n" "\n" " :arg string: text\n" " :type string: str\n" " :return: The escaped string.\n" " :rtype: str\n")
 
static PyObject * bpy_escape_identifier (PyObject *, PyObject *value)
 
 PyDoc_STRVAR (bpy_unescape_identifier_doc, ".. function:: unescape_identifier(string)\n" "\n" " Simple string un-escape function used for animation paths.\n" " This performs the reverse of :func:`escape_identifier`.\n" "\n" " :arg string: text\n" " :type string: str\n" " :return: The un-escaped string.\n" " :rtype: str\n")
 
static PyObject * bpy_unescape_identifier (PyObject *, PyObject *value)
 
 PyDoc_STRVAR (bpy_context_members_doc, ".. function:: context_members()\n" "\n" " :return: A dict where the key is the context and the value is a tuple of it's members.\n" " :rtype: dict[str, tuple[str]]\n")
 
static PyObject * bpy_context_members (PyObject *)
 
 PyDoc_STRVAR (bpy_rna_enum_items_static_doc, ".. function:: rna_enum_items_static()\n" "\n" " :return: A dict where the key the name of the enum, the value is a tuple of enum items.\n" " :rtype: dict[str, tuple[:class:`bpy.types.EnumPropertyItem`]]\n")
 
static PyObject * bpy_rna_enum_items_static (PyObject *)
 
 PyDoc_STRVAR (bpy_ghost_backend_doc, ".. function:: _ghost_backend()\n" "\n" " :return: An identifier for the GHOST back-end.\n" " :rtype: str\n")
 
static PyObject * bpy_ghost_backend (PyObject *)
 
 PyDoc_STRVAR (bpy_wm_capabilities_doc, ".. function:: _wm_capabilities()\n" "\n" " :return: A dictionary of capabilities (string keys, boolean values).\n" " :rtype: dict[str, bool]\n")
 
static PyObject * bpy_wm_capabilities (PyObject *self)
 
static PyObject * bpy_import_test (const char *modname)
 
void BPy_init_modules (bContext *C)
 

Variables

PyObject * bpy_package_py = nullptr
 
const char * buttons_context_dir []
 
const char * clip_context_dir []
 
const char * file_context_dir []
 
const char * image_context_dir []
 
const char * node_context_dir []
 
const char * screen_context_dir []
 
const char * sequencer_context_dir []
 
const char * text_context_dir []
 
const char * view3d_context_dir []
 
static PyMethodDef bpy_methods []
 

Detailed Description

This file defines the '_bpy' module which is used by python's 'bpy' package to access C defined builtin functions. A script writer should never directly access this module.

Definition in file bpy.cc.

Macro Definition Documentation

◆ DEF_ENUM

#define DEF_ENUM ( id)    {STRINGIFY(id), id},

◆ PY_SSIZE_T_CLEAN

#define PY_SSIZE_T_CLEAN

Definition at line 14 of file bpy.cc.

◆ PYMODULE_ADD_METHOD

#define PYMODULE_ADD_METHOD ( mod,
meth )    PyModule_AddObject(mod, (meth)->ml_name, (PyObject *)PyCFunction_New(meth, mod))

Referenced by BPy_init_modules().

◆ SetFlagItem

#define SetFlagItem ( x)     PyDict_SetItemString(result, STRINGIFY(x), PyBool_FromLong((WM_CAPABILITY_##x) & flag));

Referenced by bpy_wm_capabilities().

Function Documentation

◆ bpy_blend_foreach_path_cb()

static bool bpy_blend_foreach_path_cb ( BPathForeachPathData * bpath_data,
char * ,
size_t ,
const char * path_src )
static

Definition at line 90 of file bpy.cc.

References PyC_UnicodeFromBytes(), and BPathForeachPathData::user_data.

Referenced by bpy_blend_paths().

◆ bpy_blend_paths()

◆ bpy_context_members()

◆ bpy_driver_secure_code_test()

static PyObject * bpy_driver_secure_code_test ( PyObject * ,
PyObject * args,
PyObject * kw )
static

◆ bpy_escape_identifier()

static PyObject * bpy_escape_identifier ( PyObject * ,
PyObject * value )
static

Definition at line 421 of file bpy.cc.

References BLI_str_escape().

◆ bpy_flip_name()

static PyObject * bpy_flip_name ( PyObject * ,
PyObject * args,
PyObject * kw )
static

◆ bpy_ghost_backend()

static PyObject * bpy_ghost_backend ( PyObject * )
static

Definition at line 591 of file bpy.cc.

References WM_ghost_backend().

◆ bpy_import_test()

static PyObject * bpy_import_test ( const char * modname)
static

Definition at line 694 of file bpy.cc.

References GPU_bgl_end(), and mod().

Referenced by BPy_init_modules().

◆ BPy_init_modules()

◆ bpy_resource_path()

static PyObject * bpy_resource_path ( PyObject * ,
PyObject * args,
PyObject * kw )
static

◆ bpy_rna_enum_items_static()

static PyObject * bpy_rna_enum_items_static ( PyObject * )
static

◆ bpy_script_paths()

static PyObject * bpy_script_paths ( PyObject * )
static

◆ bpy_system_resource()

◆ bpy_unescape_identifier()

static PyObject * bpy_unescape_identifier ( PyObject * ,
PyObject * value )
static

Definition at line 461 of file bpy.cc.

References BLI_str_unescape().

◆ bpy_user_resource()

◆ bpy_wm_capabilities()

static PyObject * bpy_wm_capabilities ( PyObject * self)
static

Definition at line 610 of file bpy.cc.

References flag, result, self, SetFlagItem, and WM_capabilities_flag().

◆ PyDoc_STRVAR() [1/12]

PyDoc_STRVAR ( bpy_blend_paths_doc ,
".. function:: blend_paths(absolute=False, packed=False, local=False)\n" "\n" " Returns a list of paths to external files referenced by the loaded .blend file.\n" "\n" " :arg absolute: When true the paths returned are made absolute.\n" " :type absolute: bool\n" " :arg packed: When true skip file paths for packed data.\n" " :type packed: bool\n" " :arg local: When true skip linked library paths.\n" " :type local: bool\n" " :return: path list.\n" " :rtype: list\n" [str] )

◆ PyDoc_STRVAR() [2/12]

PyDoc_STRVAR ( bpy_context_members_doc ,
".. function:: context_members()\n" "\n" " :return: A dict where the key is the context and the value is a tuple of it's members.\n" " :rtype: dict]\n" [str, tuple[str] )
Note
only exposed for generating documentation, see: doc/python_api/sphinx_doc_gen.py.

◆ PyDoc_STRVAR() [3/12]

PyDoc_STRVAR ( bpy_driver_secure_code_test_doc ,
".. function:: _driver_secure_code_test(code)\n" "\n" " Test if the script should be considered trusted.\n" "\n" " :arg code: The code to test.\n" " :type code: code\n" " :arg namespace: The namespace of values which are allowed.\n" " :type namespace: dict\n" " :arg verbose: Print the reason for considering insecure to the ``stderr``.\n" " :type verbose: bool\n" " :return: True when the script is considered trusted.\n" " :rtype: bool\n" [str, Any] )

◆ PyDoc_STRVAR() [4/12]

PyDoc_STRVAR ( bpy_escape_identifier_doc ,
".. function:: escape_identifier(string)\n" "\n" " Simple string escaping function used for animation paths.\n" "\n" " :arg string: text\n" " :type string: str\n" " :return: The escaped string.\n" " :rtype: str\n"  )

◆ PyDoc_STRVAR() [5/12]

PyDoc_STRVAR ( bpy_flip_name_doc ,
".. function:: flip_name(name, strip_digits=False)\n" "\n" " Flip a name between left/right sides,
useful for \n" " mirroring bone names.\n" "\n" " :arg name:Bone name to flip.\n" " :type name:str\n" " :arg strip_digits:Whether to remove ``.###`` suffix.\n" " :type strip_digits:bool\n" " :return:The flipped name.\n" " :rtype:str\n"  )

◆ PyDoc_STRVAR() [6/12]

PyDoc_STRVAR ( bpy_ghost_backend_doc ,
".. function:: _ghost_backend()\n" "\n" " :return: An identifier for the GHOST back-end.\n" " :rtype: str\n"  )

◆ PyDoc_STRVAR() [7/12]

PyDoc_STRVAR ( bpy_resource_path_doc ,
".. function:: resource_path(type, major=bpy.app.version[0], minor=bpy.app.version[1])\n" "\n" " Return the base path for storing system files.\n" "\n" " :arg type: string in .\n" " :type type: str\n" " :arg major: major version[ 'USER', 'LOCAL', 'SYSTEM'],
defaults to current.\n" " :type major:int\n" " :arg minor:minor version,
defaults to current.\n" " :type minor:str\n" " :return:the resource path(not necessarily existing).\n" " :rtype:str\n"  )

◆ PyDoc_STRVAR() [8/12]

PyDoc_STRVAR ( bpy_rna_enum_items_static_doc ,
".. function:: rna_enum_items_static()\n" "\n" " :return: A dict where the key the name of the enum,
the value is a tuple of enum items.\n" " :rtype:dict]\n" [str, tuple[:class:`bpy.types.EnumPropertyItem`] )
Note
only exposed for generating documentation, see: doc/python_api/sphinx_doc_gen.py.

◆ PyDoc_STRVAR() [9/12]

PyDoc_STRVAR ( bpy_script_paths_doc ,
".. function:: script_paths()\n" "\n" " Return 2 paths to blender scripts directories.\n" "\n" " :return: (system, user) strings will be empty when not found.\n" " :rtype: tuple\n" [str, str] )

◆ PyDoc_STRVAR() [10/12]

PyDoc_STRVAR ( bpy_system_resource_doc ,
".. function:: system_resource(type, path=\"\")\n" "\n" " Return a system resource path.\n" "\n" " :arg type: string in .\n" " :type type: str\n" " :arg path: Optional subdirectory.\n" " :type path: str | bytes\n" [ 'DATAFILES', 'SCRIPTS', 'EXTENSIONS', 'PYTHON'] )

◆ PyDoc_STRVAR() [11/12]

PyDoc_STRVAR ( bpy_unescape_identifier_doc ,
".. function:: unescape_identifier(string)\n" "\n" " Simple string un-escape function used for animation paths.\n" " This performs the reverse of :func:`escape_identifier`.\n" "\n" " :arg string: text\n" " :type string: str\n" " :return: The un-escaped string.\n" " :rtype: str\n"  )

◆ PyDoc_STRVAR() [12/12]

PyDoc_STRVAR ( bpy_wm_capabilities_doc ,
".. function:: _wm_capabilities()\n" "\n" " :return: A dictionary of capabilities (string keys, boolean values).\n" " :rtype: dict\n" [str, bool] )

Variable Documentation

◆ bpy_methods

PyMethodDef bpy_methods[]
static

Definition at line 652 of file bpy.cc.

Referenced by BPy_init_modules().

◆ bpy_package_py

PyObject* bpy_package_py = nullptr

Definition at line 62 of file bpy.cc.

Referenced by BPy_init_modules().

◆ buttons_context_dir

const char* buttons_context_dir[]

Definition at line 489 of file bpy.cc.

Referenced by bpy_context_members().

◆ clip_context_dir

const char* clip_context_dir[]

Definition at line 490 of file bpy.cc.

Referenced by bpy_context_members().

◆ file_context_dir

const char* file_context_dir[]

Definition at line 491 of file bpy.cc.

Referenced by bpy_context_members().

◆ image_context_dir

const char* image_context_dir[]

Definition at line 492 of file bpy.cc.

Referenced by bpy_context_members().

◆ node_context_dir

const char* node_context_dir[]

Definition at line 493 of file bpy.cc.

Referenced by bpy_context_members(), and blender::ed::space_node::node_context().

◆ screen_context_dir

const char* screen_context_dir[]

Definition at line 494 of file bpy.cc.

Referenced by bpy_context_members().

◆ sequencer_context_dir

const char* sequencer_context_dir[]

Definition at line 495 of file bpy.cc.

Referenced by bpy_context_members().

◆ text_context_dir

const char* text_context_dir[]

Definition at line 496 of file bpy.cc.

Referenced by bpy_context_members().

◆ view3d_context_dir

const char* view3d_context_dir[]

Definition at line 497 of file bpy.cc.

Referenced by bpy_context_members().