Blender  V3.3
Macros | Functions | Variables
bpy.c File Reference
#include <Python.h>
#include "BLI_string.h"
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
#include "BKE_appdir.h"
#include "BKE_blender_version.h"
#include "BKE_bpath.h"
#include "BKE_global.h"
#include "RNA_access.h"
#include "RNA_enum_types.h"
#include "RNA_prototypes.h"
#include "RNA_types.h"
#include "GPU_state.h"
#include "bpy.h"
#include "bpy_app.h"
#include "bpy_capi_utils.h"
#include "bpy_driver.h"
#include "bpy_library.h"
#include "bpy_operator.h"
#include "bpy_props.h"
#include "bpy_rna.h"
#include "bpy_rna_data.h"
#include "bpy_rna_gizmo.h"
#include "bpy_rna_id_collection.h"
#include "bpy_rna_types_capi.h"
#include "bpy_utils_previews.h"
#include "bpy_utils_units.h"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "../generic/idprop_py_api.h"
#include "../generic/idprop_py_ui_api.h"
#include "bpy_msgbus.h"
#include "RNA_enum_items.h"

Go to the source code of this file.

Macros

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

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 of strings\n")
 
static PyObject * bpy_script_paths (PyObject *UNUSED(self))
 
static bool bpy_blend_foreach_path_cb (BPathForeachPathData *bpath_data, char *UNUSED(path_dst), 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: boolean\n" " :arg packed: When true skip file paths for packed data.\n" " :type packed: boolean\n" " :arg local: When true skip linked library paths.\n" " :type local: boolean\n" " :return: path list.\n" " :rtype: list of strings\n")
 
static PyObject * bpy_blend_paths (PyObject *UNUSED(self), 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: string\n" " :arg strip_digits: Whether to remove ``.###`` suffix.\n" " :type strip_digits: bool\n" " :return: The flipped name.\n" " :rtype: string\n")
 
static PyObject * bpy_flip_name (PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 
static PyObject * bpy_user_resource (PyObject *UNUSED(self), 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', 'PYTHON'].\n" " :type type: string\n" " :arg path: Optional subdirectory.\n" " :type path: string\n")
 
static PyObject * bpy_system_resource (PyObject *UNUSED(self), 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: string\n" " :arg major: major version, defaults to current.\n" " :type major: int\n" " :arg minor: minor version, defaults to current.\n" " :type minor: string\n" " :return: the resource path (not necessarily existing).\n" " :rtype: string\n")
 
static PyObject * bpy_resource_path (PyObject *UNUSED(self), 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\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 *UNUSED(self), 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: string\n" " :return: The escaped string.\n" " :rtype: string\n")
 
static PyObject * bpy_escape_identifier (PyObject *UNUSED(self), 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 `escape_identifier`.\n" "\n" " :arg string: text\n" " :type string: string\n" " :return: The un-escaped string.\n" " :rtype: string\n")
 
static PyObject * bpy_unescape_identifier (PyObject *UNUSED(self), 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\n")
 
static PyObject * bpy_context_members (PyObject *UNUSED(self))
 
 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 " ":class:`bpy.types.EnumPropertyItem`.\n" " :rtype: dict of \n")
 
static PyObject * bpy_rna_enum_items_static (PyObject *UNUSED(self))
 
static PyObject * bpy_import_test (const char *modname)
 
void BPy_init_modules (struct bContext *C)
 

Variables

PyObject * bpy_package_py = NULL
 
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.c.

Macro Definition Documentation

◆ DEF_ENUM

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

◆ PY_SSIZE_T_CLEAN

#define PY_SSIZE_T_CLEAN

Definition at line 12 of file bpy.c.

Function Documentation

◆ bpy_blend_foreach_path_cb()

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

Definition at line 86 of file bpy.c.

References PyC_UnicodeFromByte(), and BPathForeachPathData::user_data.

Referenced by bpy_blend_paths().

◆ bpy_blend_paths()

static PyObject* bpy_blend_paths ( PyObject *  UNUSEDself,
PyObject *  args,
PyObject *  kw 
)
static

◆ bpy_context_members()

static PyObject* bpy_context_members ( PyObject *  UNUSEDself)
static

◆ bpy_driver_secure_code_test()

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

Definition at line 344 of file bpy.c.

References BPY_driver_secure_bytecode_test(), NULL, PyC_ParseBool(), and verbose.

◆ bpy_escape_identifier()

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

Definition at line 382 of file bpy.c.

References BLI_str_escape(), NULL, and size().

◆ bpy_flip_name()

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

Definition at line 173 of file bpy.c.

References BLI_string_flip_side_name(), NULL, PyC_ParseBool(), result, and size().

◆ bpy_import_test()

static PyObject* bpy_import_test ( const char *  modname)
static

Definition at line 572 of file bpy.c.

References GPU_bgl_end(), mod(), and NULL.

Referenced by BPy_init_modules().

◆ BPy_init_modules()

void BPy_init_modules ( struct bContext C)

◆ bpy_resource_path()

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

◆ bpy_rna_enum_items_static()

static PyObject* bpy_rna_enum_items_static ( PyObject *  UNUSEDself)
static

◆ bpy_script_paths()

static PyObject* bpy_script_paths ( PyObject *  UNUSEDself)
static

◆ bpy_system_resource()

static PyObject* bpy_system_resource ( PyObject *  UNUSEDself,
PyObject *  args,
PyObject *  kw 
)
static

◆ bpy_unescape_identifier()

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

Definition at line 420 of file bpy.c.

References BLI_str_unescape(), NULL, and size().

◆ bpy_user_resource()

static PyObject* bpy_user_resource ( PyObject *  UNUSEDself,
PyObject *  args,
PyObject *  kw 
)
static

◆ PyDoc_STRVAR() [1/10]

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: boolean\n" " :arg packed: When true skip file paths for packed data.\n" " :type packed: boolean\n" " :arg local: When true skip linked library paths.\n" " :type local: boolean\n" " :return: path list.\n" " :rtype: list of strings\n"   
)

◆ PyDoc_STRVAR() [2/10]

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"   
)
Note
only exposed for generating documentation, see: doc/python_api/sphinx_doc_gen.py.

◆ PyDoc_STRVAR() [3/10]

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"   
)

◆ PyDoc_STRVAR() [4/10]

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: string\n" " :return: The escaped string.\n" " :rtype: string\n"   
)

◆ PyDoc_STRVAR() [5/10]

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:string\n" " :arg strip_digits:Whether to remove ``.###`` suffix.\n" " :type strip_digits:bool\n" " :return:The flipped name.\n" " :rtype:string\n"   
)

◆ PyDoc_STRVAR() [6/10]

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: string\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:string\n" " :return:the resource path(not necessarily existing).\n" " :rtype:string\n"   
)

◆ PyDoc_STRVAR() [7/10]

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 " ":class:`bpy.types.EnumPropertyItem`.\n" " :rtype:dict of \n"   
)
Note
only exposed for generating documentation, see: doc/python_api/sphinx_doc_gen.py.

◆ PyDoc_STRVAR() [8/10]

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 of strings\n"   
)

◆ PyDoc_STRVAR() [9/10]

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: string\n" " :arg path: Optional subdirectory.\n" " :type path: string\n"  [ 'DATAFILES', 'SCRIPTS', 'PYTHON'] 
)

◆ PyDoc_STRVAR() [10/10]

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 `escape_identifier`.\n" "\n" " :arg string: text\n" " :type string: string\n" " :return: The un-escaped string.\n" " :rtype: string\n"   
)

Variable Documentation

◆ bpy_methods

PyMethodDef bpy_methods[]
static

Definition at line 539 of file bpy.c.

Referenced by BPy_init_modules().

◆ bpy_package_py

PyObject* bpy_package_py = NULL

Definition at line 59 of file bpy.c.

Referenced by BPy_init_modules().