2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-02-27 20:10:08 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup pythonintern
|
2011-11-05 08:21:12 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
2011-02-27 20:10:08 +00:00
|
|
|
*/
|
2010-03-03 13:59:57 +00:00
|
|
|
|
2021-11-10 01:14:56 +11:00
|
|
|
/* Future-proof, See https://docs.python.org/3/c-api/arg.html#strings-and-buffers */
|
|
|
|
|
#define PY_SSIZE_T_CLEAN
|
|
|
|
|
|
2011-02-14 04:15:25 +00:00
|
|
|
#include <Python.h>
|
|
|
|
|
|
2013-01-07 05:26:12 +00:00
|
|
|
#include "BLI_string.h"
|
2023-10-18 17:15:30 +02:00
|
|
|
#include "BLI_string_utils.hh"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2013-03-07 02:44:55 +00:00
|
|
|
|
2024-01-21 19:42:13 +01:00
|
|
|
#include "BKE_appdir.hh"
|
2016-04-24 22:42:41 +10:00
|
|
|
#include "BKE_blender_version.h"
|
2024-02-09 19:23:03 +01:00
|
|
|
#include "BKE_bpath.hh"
|
2024-02-10 18:25:14 +01:00
|
|
|
#include "BKE_global.hh" /* XXX, G_MAIN only */
|
2013-01-07 05:26:12 +00:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
|
|
|
|
#include "RNA_enum_types.hh"
|
2024-07-10 18:30:02 +02:00
|
|
|
#include "RNA_prototypes.hh"
|
2013-01-07 05:26:12 +00:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_state.hh"
|
2020-10-09 16:33:24 +02:00
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh" /* For #WM_ghost_backend */
|
2022-10-10 10:56:05 +11:00
|
|
|
|
2024-09-24 12:23:25 +02:00
|
|
|
#include "bpy.hh"
|
2024-09-24 12:05:13 +02:00
|
|
|
#include "bpy_app.hh"
|
2024-09-24 12:23:25 +02:00
|
|
|
#include "bpy_cli_command.hh"
|
|
|
|
|
#include "bpy_driver.hh"
|
Python: Geometry: create GeometrySet wrapper for Python
In Geometry Nodes a geometry is represented by a `GeometrySet`. This is a
container that can contain one geometry of each of the supported types (mesh,
curves, volume, grease pencil, pointcloud, instances). It's possible for a
`GeometrySet` to contain e.g. a mesh and a point cloud.
This patch creates a Python wrapper for the built-in `GeometrySet`. For now,
it's main purpose is to consume the complete evaluated geometry of an object
without having to go through complex hoops via `depsgraph.object_instances`. It
also also allows retrieving instances that have been created with legacy
instancing systems such as dupli-verts or particles.
In the future, the `GeometrySet` API could also be used for more kinds of
geometry processing from Python, similar to how we use `GeometrySet` internally
as generic geometry storage.
Since we can't really have constness guarantees in Python currently, it's
enforced that the `GeometrySet` wrapper always has its own copy of each geometry
type (so e.g. it does not share a `Mesh` data-block pointer with any other place
in Blender). Without the copy, changes to the mesh in the geometry set would
also affect the evaluated geometry that Blender sees. The copy has a small cost,
but typically the overhead should be low, because attributes and other run-time
data can still be shared. This should be entirely thread-safe, assuming that no
code modifies implicitly shared data, which is forbidden. For historic reasons
there are still cases like #132423 where this assumption does not hold in all
cases. Those cases should be fixed. To my knowledge, this patch does not
introduce any new such issues or makes existing issues worse.
Pull Request: https://projects.blender.org/blender/blender/pulls/135318
2025-03-28 22:40:01 +01:00
|
|
|
#include "bpy_geometry_set.hh"
|
2025-09-11 06:08:30 +02:00
|
|
|
#include "bpy_inline_shader_nodes.hh"
|
2024-09-24 12:23:25 +02:00
|
|
|
#include "bpy_library.hh"
|
|
|
|
|
#include "bpy_operator.hh"
|
|
|
|
|
#include "bpy_props.hh"
|
2024-09-24 11:30:38 +02:00
|
|
|
#include "bpy_rna.hh"
|
|
|
|
|
#include "bpy_rna_data.hh"
|
|
|
|
|
#include "bpy_rna_gizmo.hh"
|
|
|
|
|
#include "bpy_rna_types_capi.hh"
|
2024-09-24 12:23:25 +02:00
|
|
|
#include "bpy_utils_previews.hh"
|
|
|
|
|
#include "bpy_utils_units.hh"
|
2010-05-11 07:08:32 +00:00
|
|
|
|
2024-09-24 15:25:36 +02:00
|
|
|
#include "../generic/py_capi_utils.hh"
|
2025-06-20 04:19:35 +00:00
|
|
|
#include "../generic/python_compat.hh" /* IWYU pragma: keep. */
|
2024-09-24 15:25:36 +02:00
|
|
|
#include "../generic/python_utildefines.hh"
|
2014-08-11 17:53:42 +10:00
|
|
|
|
2012-03-26 20:41:54 +00:00
|
|
|
/* external util modules */
|
2024-09-24 15:25:36 +02:00
|
|
|
#include "../generic/idprop_py_api.hh"
|
|
|
|
|
#include "../generic/idprop_py_ui_api.hh"
|
2024-09-24 12:23:25 +02:00
|
|
|
#include "bpy_msgbus.hh"
|
2010-02-13 01:13:16 +00:00
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
|
|
|
|
# include "BPy_Freestyle.h"
|
|
|
|
|
#endif
|
2010-02-16 22:34:43 +00:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
PyObject *bpy_package_py = nullptr;
|
2011-02-20 23:39:29 +00:00
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
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"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: tuple[str, str]\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_script_paths(PyObject * /*self*/)
|
2010-02-11 14:08:22 +00:00
|
|
|
{
|
2011-12-26 12:26:11 +00:00
|
|
|
PyObject *ret = PyTuple_New(2);
|
2012-03-21 22:29:49 +00:00
|
|
|
PyObject *item;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-01-23 18:38:15 +01:00
|
|
|
std::optional<std::string> path = BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, nullptr);
|
2024-02-10 22:35:32 +11:00
|
|
|
item = PyC_UnicodeFromStdStr(path.value_or(""));
|
2023-07-21 02:18:59 +02:00
|
|
|
BLI_assert(item != nullptr);
|
2012-03-21 22:29:49 +00:00
|
|
|
PyTuple_SET_ITEM(ret, 0, item);
|
2023-07-21 02:18:59 +02:00
|
|
|
path = BKE_appdir_folder_id(BLENDER_USER_SCRIPTS, nullptr);
|
2024-02-10 22:35:32 +11:00
|
|
|
item = PyC_UnicodeFromStdStr(path.value_or(""));
|
2023-07-21 02:18:59 +02:00
|
|
|
BLI_assert(item != nullptr);
|
2012-03-21 22:29:49 +00:00
|
|
|
PyTuple_SET_ITEM(ret, 1, item);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
return ret;
|
2010-02-11 14:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
static bool bpy_blend_foreach_path_cb(BPathForeachPathData *bpath_data,
|
2023-07-21 02:18:59 +02:00
|
|
|
char * /*path_dst*/,
|
|
|
|
|
size_t /*path_dst_maxncpy*/,
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
const char *path_src)
|
2011-10-27 01:25:07 +00:00
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
PyObject *py_list = static_cast<PyObject *>(bpath_data->user_data);
|
2023-02-15 16:15:59 +11:00
|
|
|
PyList_APPEND(py_list, PyC_UnicodeFromBytes(path_src));
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
return false; /* Never edits the path. */
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_blend_paths_doc,
|
2025-08-26 02:14:30 +00:00
|
|
|
".. function:: blend_paths(*, absolute=False, packed=False, local=False)\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
"\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"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type absolute: bool\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :arg packed: When true skip file paths for packed data.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type packed: bool\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :arg local: When true skip linked library paths.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type local: bool\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :return: path list.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: list[str]\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_blend_paths(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
2010-05-11 07:08:32 +00:00
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
eBPathForeachFlag flag = eBPathForeachFlag(0);
|
2011-10-27 01:25:07 +00:00
|
|
|
PyObject *list;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-08-04 18:34:20 +10:00
|
|
|
bool absolute = false;
|
|
|
|
|
bool packed = false;
|
|
|
|
|
bool local = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
static const char *_keywords[] = {"absolute", "packed", "local", nullptr};
|
2022-04-08 09:41:28 +10:00
|
|
|
static _PyArg_Parser _parser = {
|
2023-08-30 14:05:32 +10:00
|
|
|
PY_ARG_PARSER_HEAD_COMPAT()
|
2022-04-08 09:41:28 +10:00
|
|
|
"|$" /* Optional keyword only arguments. */
|
|
|
|
|
"O&" /* `absolute` */
|
|
|
|
|
"O&" /* `packed` */
|
|
|
|
|
"O&" /* `local` */
|
|
|
|
|
":blend_paths",
|
|
|
|
|
_keywords,
|
2023-08-03 19:14:53 +10:00
|
|
|
nullptr,
|
2022-04-08 09:41:28 +10:00
|
|
|
};
|
2017-10-05 10:52:18 +11:00
|
|
|
if (!_PyArg_ParseTupleAndKeywordsFast(args,
|
|
|
|
|
kw,
|
|
|
|
|
&_parser,
|
2015-08-04 18:34:20 +10:00
|
|
|
PyC_ParseBool,
|
|
|
|
|
&absolute,
|
|
|
|
|
PyC_ParseBool,
|
|
|
|
|
&packed,
|
|
|
|
|
PyC_ParseBool,
|
|
|
|
|
&local))
|
|
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
return nullptr;
|
2010-05-11 07:08:32 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (absolute) {
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
flag |= BKE_BPATH_FOREACH_PATH_ABSOLUTE;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
|
|
|
|
if (!packed) {
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
flag |= BKE_BPATH_FOREACH_PATH_SKIP_PACKED;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
|
|
|
|
if (local) {
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
flag |= BKE_BPATH_FOREACH_PATH_SKIP_LINKED;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
list = PyList_New(0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
BPathForeachPathData path_data{};
|
|
|
|
|
path_data.bmain = G_MAIN;
|
|
|
|
|
path_data.callback_function = bpy_blend_foreach_path_cb;
|
|
|
|
|
path_data.flag = flag;
|
|
|
|
|
path_data.user_data = list;
|
|
|
|
|
BKE_bpath_foreach_path_main(&path_data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-05-11 07:08:32 +00:00
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_flip_name_doc,
|
2025-08-26 02:14:30 +00:00
|
|
|
".. function:: flip_name(name, *, strip_digits=False)\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
"\n"
|
|
|
|
|
" Flip a name between left/right sides, useful for \n"
|
|
|
|
|
" mirroring bone names.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg name: Bone name to flip.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type name: str\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :arg strip_digits: Whether to remove ``.###`` suffix.\n"
|
|
|
|
|
" :type strip_digits: bool\n"
|
|
|
|
|
" :return: The flipped name.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: str\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_flip_name(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
2021-11-10 01:14:56 +11:00
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
const char *name_src = nullptr;
|
2021-11-10 01:14:56 +11:00
|
|
|
Py_ssize_t name_src_len;
|
|
|
|
|
bool strip_digits = false;
|
|
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
static const char *_keywords[] = {"", "strip_digits", nullptr};
|
2021-11-10 01:14:56 +11:00
|
|
|
static _PyArg_Parser _parser = {
|
2023-08-30 14:05:32 +10:00
|
|
|
PY_ARG_PARSER_HEAD_COMPAT()
|
2021-11-10 01:14:56 +11:00
|
|
|
"s#" /* `name` */
|
|
|
|
|
"|$" /* Optional, keyword only arguments. */
|
|
|
|
|
"O&" /* `strip_digits` */
|
|
|
|
|
":flip_name",
|
|
|
|
|
_keywords,
|
2023-08-03 19:14:53 +10:00
|
|
|
nullptr,
|
2021-11-10 01:14:56 +11:00
|
|
|
};
|
|
|
|
|
if (!_PyArg_ParseTupleAndKeywordsFast(
|
|
|
|
|
args, kw, &_parser, &name_src, &name_src_len, PyC_ParseBool, &strip_digits))
|
|
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
return nullptr;
|
2021-11-10 01:14:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Worst case we gain one extra byte (besides null-terminator) by changing
|
2022-04-11 11:41:00 +10:00
|
|
|
* "Left" to "Right", because only the first appearance of "Left" gets replaced. */
|
2021-11-10 01:14:56 +11:00
|
|
|
const size_t size = name_src_len + 2;
|
2023-07-21 02:18:59 +02:00
|
|
|
char *name_dst = static_cast<char *>(PyMem_MALLOC(size));
|
2021-11-10 01:14:56 +11:00
|
|
|
const size_t name_dst_len = BLI_string_flip_side_name(name_dst, name_src, strip_digits, size);
|
|
|
|
|
|
|
|
|
|
PyObject *result = PyUnicode_FromStringAndSize(name_dst, name_dst_len);
|
|
|
|
|
|
|
|
|
|
PyMem_FREE(name_dst);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-26 02:14:30 +00:00
|
|
|
/* `bpy_user_resource_doc`, Now in `bpy/utils/__init__.py`. */
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_user_resource(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
2010-10-03 20:00:22 +00:00
|
|
|
{
|
2023-07-21 10:59:54 +10:00
|
|
|
const PyC_StringEnumItems type_items[] = {
|
2019-10-01 05:16:40 +10:00
|
|
|
{BLENDER_USER_DATAFILES, "DATAFILES"},
|
|
|
|
|
{BLENDER_USER_CONFIG, "CONFIG"},
|
|
|
|
|
{BLENDER_USER_SCRIPTS, "SCRIPTS"},
|
2024-03-22 16:00:33 +11:00
|
|
|
{BLENDER_USER_EXTENSIONS, "EXTENSIONS"},
|
2023-07-21 02:18:59 +02:00
|
|
|
{0, nullptr},
|
2019-10-01 05:16:40 +10:00
|
|
|
};
|
2023-07-21 10:59:54 +10:00
|
|
|
PyC_StringEnum type = {type_items};
|
2023-08-11 14:59:55 +10:00
|
|
|
PyC_UnicodeAsBytesAndSize_Data subdir_data = {nullptr};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
static const char *_keywords[] = {"type", "path", nullptr};
|
2022-04-08 09:41:28 +10:00
|
|
|
static _PyArg_Parser _parser = {
|
2023-08-30 14:05:32 +10:00
|
|
|
PY_ARG_PARSER_HEAD_COMPAT()
|
2022-04-08 09:41:28 +10:00
|
|
|
"O&" /* `type` */
|
|
|
|
|
"|$" /* Optional keyword only arguments. */
|
2023-08-11 14:59:55 +10:00
|
|
|
"O&" /* `path` */
|
2022-04-08 09:41:28 +10:00
|
|
|
":user_resource",
|
|
|
|
|
_keywords,
|
2023-08-03 19:14:53 +10:00
|
|
|
nullptr,
|
2022-04-08 09:41:28 +10:00
|
|
|
};
|
2023-08-11 14:59:55 +10:00
|
|
|
if (!_PyArg_ParseTupleAndKeywordsFast(args,
|
|
|
|
|
kw,
|
|
|
|
|
&_parser,
|
|
|
|
|
PyC_ParseStringEnum,
|
|
|
|
|
&type,
|
|
|
|
|
PyC_ParseUnicodeAsBytesAndSize,
|
|
|
|
|
&subdir_data))
|
|
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
return nullptr;
|
2010-10-03 20:00:22 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-29 19:59:13 +10:00
|
|
|
/* same logic as BKE_appdir_folder_id_create(),
|
|
|
|
|
* but best leave it up to the script author to create */
|
2024-01-23 18:38:15 +01:00
|
|
|
const std::optional<std::string> path = BKE_appdir_folder_id_user_notest(type.value_found,
|
|
|
|
|
subdir_data.value);
|
2023-08-11 14:59:55 +10:00
|
|
|
Py_XDECREF(subdir_data.value_coerce);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-02-10 22:35:32 +11:00
|
|
|
return PyC_UnicodeFromStdStr(path.value_or(""));
|
2010-10-03 20:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_system_resource_doc,
|
2025-08-26 02:14:30 +00:00
|
|
|
".. function:: system_resource(type, *, path=\"\")\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
"\n"
|
|
|
|
|
" Return a system resource path.\n"
|
|
|
|
|
"\n"
|
2024-06-07 11:36:20 +10:00
|
|
|
" :arg type: string in ['DATAFILES', 'SCRIPTS', 'EXTENSIONS', 'PYTHON'].\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type type: str\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :arg path: Optional subdirectory.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type path: str | bytes\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_system_resource(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
2019-07-23 16:23:56 +10:00
|
|
|
{
|
2023-07-21 10:59:54 +10:00
|
|
|
const PyC_StringEnumItems type_items[] = {
|
2019-10-01 05:16:40 +10:00
|
|
|
{BLENDER_SYSTEM_DATAFILES, "DATAFILES"},
|
|
|
|
|
{BLENDER_SYSTEM_SCRIPTS, "SCRIPTS"},
|
2024-06-07 11:36:20 +10:00
|
|
|
{BLENDER_SYSTEM_EXTENSIONS, "EXTENSIONS"},
|
2019-10-01 05:16:40 +10:00
|
|
|
{BLENDER_SYSTEM_PYTHON, "PYTHON"},
|
2023-07-21 02:18:59 +02:00
|
|
|
{0, nullptr},
|
2019-10-01 05:16:40 +10:00
|
|
|
};
|
2023-07-21 10:59:54 +10:00
|
|
|
PyC_StringEnum type = {type_items};
|
2019-10-01 05:16:40 +10:00
|
|
|
|
2023-08-11 14:59:55 +10:00
|
|
|
PyC_UnicodeAsBytesAndSize_Data subdir_data = {nullptr};
|
2019-07-23 16:23:56 +10:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
static const char *_keywords[] = {"type", "path", nullptr};
|
2022-04-08 09:41:28 +10:00
|
|
|
static _PyArg_Parser _parser = {
|
2023-08-30 14:05:32 +10:00
|
|
|
PY_ARG_PARSER_HEAD_COMPAT()
|
2022-04-08 09:41:28 +10:00
|
|
|
"O&" /* `type` */
|
|
|
|
|
"|$" /* Optional keyword only arguments. */
|
2023-08-11 14:59:55 +10:00
|
|
|
"O&" /* `path` */
|
2022-04-08 09:41:28 +10:00
|
|
|
":system_resource",
|
|
|
|
|
_keywords,
|
2023-08-03 19:14:53 +10:00
|
|
|
nullptr,
|
2022-04-08 09:41:28 +10:00
|
|
|
};
|
2023-08-11 14:59:55 +10:00
|
|
|
if (!_PyArg_ParseTupleAndKeywordsFast(args,
|
|
|
|
|
kw,
|
|
|
|
|
&_parser,
|
|
|
|
|
PyC_ParseStringEnum,
|
|
|
|
|
&type,
|
|
|
|
|
PyC_ParseUnicodeAsBytesAndSize,
|
|
|
|
|
&subdir_data))
|
|
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
return nullptr;
|
2019-07-23 16:23:56 +10:00
|
|
|
}
|
|
|
|
|
|
2024-01-23 18:38:15 +01:00
|
|
|
std::optional<std::string> path = BKE_appdir_folder_id(type.value_found, subdir_data.value);
|
2023-08-11 14:59:55 +10:00
|
|
|
Py_XDECREF(subdir_data.value_coerce);
|
2019-07-23 16:23:56 +10:00
|
|
|
|
2024-02-10 22:35:32 +11:00
|
|
|
return PyC_UnicodeFromStdStr(path.value_or(""));
|
2019-07-23 16:23:56 +10:00
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(
|
2024-01-25 10:22:16 +11:00
|
|
|
/* Wrap. */
|
2011-05-24 16:05:51 +00:00
|
|
|
bpy_resource_path_doc,
|
2025-08-26 02:14:30 +00:00
|
|
|
".. function:: resource_path(type, *, major=bpy.app.version[0], minor=bpy.app.version[1])\n"
|
2011-04-11 13:56:58 +00:00
|
|
|
"\n"
|
|
|
|
|
" Return the base path for storing system files.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg type: string in ['USER', 'LOCAL', 'SYSTEM'].\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type type: str\n"
|
2011-04-11 13:56:58 +00:00
|
|
|
" :arg major: major version, defaults to current.\n"
|
|
|
|
|
" :type major: int\n"
|
|
|
|
|
" :arg minor: minor version, defaults to current.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type minor: str\n"
|
2011-04-11 13:56:58 +00:00
|
|
|
" :return: the resource path (not necessarily existing).\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: str\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_resource_path(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
2011-04-11 13:56:58 +00:00
|
|
|
{
|
2023-07-21 10:59:54 +10:00
|
|
|
const PyC_StringEnumItems type_items[] = {
|
2019-10-01 05:16:40 +10:00
|
|
|
{BLENDER_RESOURCE_PATH_USER, "USER"},
|
|
|
|
|
{BLENDER_RESOURCE_PATH_LOCAL, "LOCAL"},
|
|
|
|
|
{BLENDER_RESOURCE_PATH_SYSTEM, "SYSTEM"},
|
2023-07-21 02:18:59 +02:00
|
|
|
{0, nullptr},
|
2019-10-01 05:16:40 +10:00
|
|
|
};
|
2023-07-21 10:59:54 +10:00
|
|
|
PyC_StringEnum type = {type_items};
|
2019-10-01 05:16:40 +10:00
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
int major = BLENDER_VERSION / 100, minor = BLENDER_VERSION % 100;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
static const char *_keywords[] = {"type", "major", "minor", nullptr};
|
2022-04-08 09:41:28 +10:00
|
|
|
static _PyArg_Parser _parser = {
|
2023-08-30 14:05:32 +10:00
|
|
|
PY_ARG_PARSER_HEAD_COMPAT()
|
2022-04-08 09:41:28 +10:00
|
|
|
"O&" /* `type` */
|
|
|
|
|
"|$" /* Optional keyword only arguments. */
|
|
|
|
|
"i" /* `major` */
|
|
|
|
|
"i" /* `minor` */
|
|
|
|
|
":resource_path",
|
|
|
|
|
_keywords,
|
2023-08-03 19:14:53 +10:00
|
|
|
nullptr,
|
2022-04-08 09:41:28 +10:00
|
|
|
};
|
2019-10-01 05:16:40 +10:00
|
|
|
if (!_PyArg_ParseTupleAndKeywordsFast(
|
|
|
|
|
args, kw, &_parser, PyC_ParseStringEnum, &type, &major, &minor))
|
|
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
return nullptr;
|
2011-04-11 13:56:58 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-01-23 18:38:15 +01:00
|
|
|
const std::optional<std::string> path = BKE_appdir_resource_path_id_with_version(
|
|
|
|
|
type.value_found, false, (major * 100) + minor);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-02-10 22:35:32 +11:00
|
|
|
return PyC_UnicodeFromStdStr(path.value_or(""));
|
2011-04-11 13:56:58 +00:00
|
|
|
}
|
|
|
|
|
|
2022-07-12 16:05:15 +10:00
|
|
|
/* This is only exposed for tests, see: `tests/python/bl_pyapi_bpy_driver_secure_eval.py`. */
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_driver_secure_code_test_doc,
|
2025-08-26 02:14:30 +00:00
|
|
|
".. function:: _driver_secure_code_test(code, *, namespace=None, verbose=False)\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
"\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"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type namespace: dict[str, Any]\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :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");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_driver_secure_code_test(PyObject * /*self*/, PyObject *args, PyObject *kw)
|
2022-07-12 16:05:15 +10:00
|
|
|
{
|
|
|
|
|
PyObject *py_code;
|
2023-07-21 02:18:59 +02:00
|
|
|
PyObject *py_namespace = nullptr;
|
2022-07-12 16:05:15 +10:00
|
|
|
const bool verbose = false;
|
2023-07-21 02:18:59 +02:00
|
|
|
static const char *_keywords[] = {"code", "namespace", "verbose", nullptr};
|
2022-07-12 16:05:15 +10:00
|
|
|
static _PyArg_Parser _parser = {
|
2023-08-30 14:05:32 +10:00
|
|
|
PY_ARG_PARSER_HEAD_COMPAT()
|
2022-07-12 16:05:15 +10:00
|
|
|
"O!" /* `expression` */
|
|
|
|
|
"|$" /* Optional keyword only arguments. */
|
|
|
|
|
"O!" /* `namespace` */
|
|
|
|
|
"O&" /* `verbose` */
|
|
|
|
|
":driver_secure_code_test",
|
|
|
|
|
_keywords,
|
2023-08-03 19:14:53 +10:00
|
|
|
nullptr,
|
2022-07-12 16:05:15 +10:00
|
|
|
};
|
|
|
|
|
if (!_PyArg_ParseTupleAndKeywordsFast(args,
|
|
|
|
|
kw,
|
|
|
|
|
&_parser,
|
|
|
|
|
&PyCode_Type,
|
|
|
|
|
&py_code,
|
|
|
|
|
&PyDict_Type,
|
|
|
|
|
&py_namespace,
|
|
|
|
|
PyC_ParseBool,
|
|
|
|
|
&verbose))
|
|
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
return nullptr;
|
2022-07-12 16:05:15 +10:00
|
|
|
}
|
|
|
|
|
return PyBool_FromLong(BPY_driver_secure_bytecode_test(py_code, py_namespace, verbose));
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_escape_identifier_doc,
|
|
|
|
|
".. function:: escape_identifier(string)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Simple string escaping function used for animation paths.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg string: text\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type string: str\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :return: The escaped string.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: str\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_escape_identifier(PyObject * /*self*/, PyObject *value)
|
2014-02-25 16:18:10 +11:00
|
|
|
{
|
|
|
|
|
Py_ssize_t value_str_len;
|
2021-02-13 22:57:01 +11:00
|
|
|
const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len);
|
2014-02-25 16:18:10 +11:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
if (value_str == nullptr) {
|
2014-02-25 16:18:10 +11:00
|
|
|
PyErr_SetString(PyExc_TypeError, "expected a string");
|
2023-07-21 02:18:59 +02:00
|
|
|
return nullptr;
|
2014-02-25 16:18:10 +11:00
|
|
|
}
|
|
|
|
|
|
2020-12-10 14:12:55 +11:00
|
|
|
const size_t size = (value_str_len * 2) + 1;
|
2023-07-21 02:18:59 +02:00
|
|
|
char *value_escape_str = static_cast<char *>(PyMem_MALLOC(size));
|
2020-12-10 14:12:55 +11:00
|
|
|
const Py_ssize_t value_escape_str_len = BLI_str_escape(value_escape_str, value_str, size);
|
2014-02-25 16:18:10 +11:00
|
|
|
|
2020-12-10 14:12:55 +11:00
|
|
|
PyObject *value_escape;
|
2014-02-25 16:18:10 +11:00
|
|
|
if (value_escape_str_len == value_str_len) {
|
|
|
|
|
Py_INCREF(value);
|
|
|
|
|
value_escape = value;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
value_escape = PyUnicode_FromStringAndSize(value_escape_str, value_escape_str_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyMem_FREE(value_escape_str);
|
|
|
|
|
|
|
|
|
|
return value_escape;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_unescape_identifier_doc,
|
|
|
|
|
".. function:: unescape_identifier(string)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Simple string un-escape function used for animation paths.\n"
|
2024-11-03 19:18:34 +11:00
|
|
|
" This performs the reverse of :func:`escape_identifier`.\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
"\n"
|
|
|
|
|
" :arg string: text\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :type string: str\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :return: The un-escaped string.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: str\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_unescape_identifier(PyObject * /*self*/, PyObject *value)
|
2020-12-10 14:09:29 +11:00
|
|
|
{
|
|
|
|
|
Py_ssize_t value_str_len;
|
2021-02-13 22:57:01 +11:00
|
|
|
const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len);
|
2020-12-10 14:09:29 +11:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
if (value_str == nullptr) {
|
2020-12-10 14:09:29 +11:00
|
|
|
PyErr_SetString(PyExc_TypeError, "expected a string");
|
2023-07-21 02:18:59 +02:00
|
|
|
return nullptr;
|
2020-12-10 14:09:29 +11:00
|
|
|
}
|
|
|
|
|
|
2020-12-10 14:12:55 +11:00
|
|
|
const size_t size = value_str_len + 1;
|
2023-07-21 02:18:59 +02:00
|
|
|
char *value_unescape_str = static_cast<char *>(PyMem_MALLOC(size));
|
2020-12-10 14:12:55 +11:00
|
|
|
const Py_ssize_t value_unescape_str_len = BLI_str_unescape(value_unescape_str, value_str, size);
|
2020-12-10 14:09:29 +11:00
|
|
|
|
2020-12-10 14:12:55 +11:00
|
|
|
PyObject *value_unescape;
|
2020-12-10 14:09:29 +11:00
|
|
|
if (value_unescape_str_len == value_str_len) {
|
|
|
|
|
Py_INCREF(value);
|
|
|
|
|
value_unescape = value;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
value_unescape = PyUnicode_FromStringAndSize(value_unescape_str, value_unescape_str_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyMem_FREE(value_unescape_str);
|
|
|
|
|
|
|
|
|
|
return value_unescape;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
extern "C" const char *buttons_context_dir[];
|
|
|
|
|
extern "C" const char *clip_context_dir[];
|
|
|
|
|
extern "C" const char *file_context_dir[];
|
|
|
|
|
extern "C" const char *image_context_dir[];
|
|
|
|
|
extern "C" const char *node_context_dir[];
|
|
|
|
|
extern "C" const char *screen_context_dir[];
|
|
|
|
|
extern "C" const char *sequencer_context_dir[];
|
|
|
|
|
extern "C" const char *text_context_dir[];
|
|
|
|
|
extern "C" const char *view3d_context_dir[];
|
|
|
|
|
|
2022-05-18 16:59:16 +10:00
|
|
|
/**
|
|
|
|
|
* \note only exposed for generating documentation, see: `doc/python_api/sphinx_doc_gen.py`.
|
|
|
|
|
*/
|
|
|
|
|
PyDoc_STRVAR(
|
2024-01-25 10:22:16 +11:00
|
|
|
/* Wrap. */
|
2022-05-18 16:59:16 +10:00
|
|
|
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"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: dict[str, tuple[str]]\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_context_members(PyObject * /*self*/)
|
2022-05-18 16:59:16 +10:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
const char *name;
|
|
|
|
|
const char **dir;
|
|
|
|
|
} context_members_all[] = {
|
|
|
|
|
{"buttons", buttons_context_dir},
|
|
|
|
|
{"clip", clip_context_dir},
|
|
|
|
|
{"file", file_context_dir},
|
|
|
|
|
{"image", image_context_dir},
|
|
|
|
|
{"node", node_context_dir},
|
|
|
|
|
{"screen", screen_context_dir},
|
|
|
|
|
{"sequencer", sequencer_context_dir},
|
|
|
|
|
{"text", text_context_dir},
|
|
|
|
|
{"view3d", view3d_context_dir},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PyObject *result = _PyDict_NewPresized(ARRAY_SIZE(context_members_all));
|
|
|
|
|
for (int context_index = 0; context_index < ARRAY_SIZE(context_members_all); context_index++) {
|
|
|
|
|
const char *name = context_members_all[context_index].name;
|
|
|
|
|
const char **dir = context_members_all[context_index].dir;
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; dir[i]; i++) {
|
|
|
|
|
/* Pass. */
|
|
|
|
|
}
|
|
|
|
|
PyObject *members = PyTuple_New(i);
|
|
|
|
|
for (i = 0; dir[i]; i++) {
|
|
|
|
|
PyTuple_SET_ITEM(members, i, PyUnicode_FromString(dir[i]));
|
|
|
|
|
}
|
|
|
|
|
PyDict_SetItemString(result, name, members);
|
|
|
|
|
Py_DECREF(members);
|
|
|
|
|
}
|
|
|
|
|
BLI_assert(PyDict_GET_SIZE(result) == ARRAY_SIZE(context_members_all));
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 14:07:08 +10:00
|
|
|
/**
|
|
|
|
|
* \note only exposed for generating documentation, see: `doc/python_api/sphinx_doc_gen.py`.
|
|
|
|
|
*/
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_rna_enum_items_static_doc,
|
|
|
|
|
".. function:: rna_enum_items_static()\n"
|
|
|
|
|
"\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :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");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_rna_enum_items_static(PyObject * /*self*/)
|
2022-05-31 14:07:08 +10:00
|
|
|
{
|
|
|
|
|
#define DEF_ENUM(id) {STRINGIFY(id), id},
|
|
|
|
|
struct {
|
|
|
|
|
const char *id;
|
|
|
|
|
const EnumPropertyItem *items;
|
|
|
|
|
} enum_info[] = {
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_enum_items.hh"
|
2022-05-31 14:07:08 +10:00
|
|
|
};
|
|
|
|
|
PyObject *result = _PyDict_NewPresized(ARRAY_SIZE(enum_info));
|
|
|
|
|
for (int i = 0; i < ARRAY_SIZE(enum_info); i++) {
|
|
|
|
|
/* Include all items (including headings & separators), can be shown in documentation. */
|
|
|
|
|
const EnumPropertyItem *items = enum_info[i].items;
|
|
|
|
|
const int items_count = RNA_enum_items_count(items);
|
|
|
|
|
PyObject *value = PyTuple_New(items_count);
|
|
|
|
|
for (int item_index = 0; item_index < items_count; item_index++) {
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA ptr = RNA_pointer_create_discrete(
|
2023-09-06 00:48:50 +02:00
|
|
|
nullptr, &RNA_EnumPropertyItem, (void *)&items[item_index]);
|
2022-05-31 14:07:08 +10:00
|
|
|
PyTuple_SET_ITEM(value, item_index, pyrna_struct_CreatePyObject(&ptr));
|
|
|
|
|
}
|
|
|
|
|
PyDict_SetItemString(result, enum_info[i].id, value);
|
|
|
|
|
Py_DECREF(value);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-10 10:56:05 +11:00
|
|
|
/* This is only exposed for (Unix/Linux), see: #GHOST_ISystem::getSystemBackend for details. */
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_ghost_backend_doc,
|
|
|
|
|
".. function:: _ghost_backend()\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :return: An identifier for the GHOST back-end.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: str\n");
|
2023-07-21 02:18:59 +02:00
|
|
|
static PyObject *bpy_ghost_backend(PyObject * /*self*/)
|
2022-10-10 10:56:05 +11:00
|
|
|
{
|
|
|
|
|
return PyUnicode_FromString(WM_ghost_backend());
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-26 21:26:44 +10:00
|
|
|
/* NOTE(@ideasman42): This is a private function because the keys in the returned dictionary,
|
|
|
|
|
* are not considered stable. Sometimes a function is temporarily only supported by one platform.
|
|
|
|
|
* Once all platforms support the functionality there is no need for the flag
|
|
|
|
|
* and it can be removed. This is at odds with a public API that has values which are
|
|
|
|
|
* intended to be kept between releases.
|
|
|
|
|
* If this were to be made public we would have to document that this is subject to change. */
|
|
|
|
|
|
|
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
bpy_wm_capabilities_doc,
|
|
|
|
|
".. function:: _wm_capabilities()\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :return: A dictionary of capabilities (string keys, boolean values).\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: dict[str, bool]\n");
|
2024-04-26 21:26:44 +10:00
|
|
|
static PyObject *bpy_wm_capabilities(PyObject *self)
|
|
|
|
|
{
|
2024-10-18 12:23:34 +11:00
|
|
|
PyObject *py_id_capabilities = PyUnicode_FromString("_wm_capabilities_");
|
2024-04-26 21:26:44 +10:00
|
|
|
PyObject *result = nullptr;
|
2024-10-18 12:23:34 +11:00
|
|
|
switch (PyObject_GetOptionalAttr(self, py_id_capabilities, &result)) {
|
|
|
|
|
case 1: {
|
2025-03-26 15:34:07 +11:00
|
|
|
BLI_assert(result != nullptr);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 0: {
|
2024-10-18 12:23:34 +11:00
|
|
|
result = PyDict_New();
|
2024-04-26 21:26:44 +10:00
|
|
|
|
2024-10-18 12:23:34 +11:00
|
|
|
const eWM_CapabilitiesFlag flag = WM_capabilities_flag();
|
2024-04-26 21:26:44 +10:00
|
|
|
|
|
|
|
|
#define SetFlagItem(x) \
|
|
|
|
|
PyDict_SetItemString(result, STRINGIFY(x), PyBool_FromLong((WM_CAPABILITY_##x) & flag));
|
|
|
|
|
|
2025-07-08 16:39:22 +10:00
|
|
|
/* Only exposed flags which are used, by Blender's built-in scripts
|
|
|
|
|
* since this is a private API. */
|
|
|
|
|
|
2024-10-18 12:23:34 +11:00
|
|
|
SetFlagItem(TRACKPAD_PHYSICAL_DIRECTION);
|
2025-03-28 13:15:55 +11:00
|
|
|
SetFlagItem(KEYBOARD_HYPER_KEY);
|
2024-04-26 21:26:44 +10:00
|
|
|
|
|
|
|
|
#undef SetFlagItem
|
2024-10-18 12:23:34 +11:00
|
|
|
PyObject_SetAttr(self, py_id_capabilities, result);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
/* Unlikely, but there may be an error, forward it. */
|
|
|
|
|
BLI_assert(result == nullptr);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2024-04-26 21:26:44 +10:00
|
|
|
|
2024-10-18 12:23:34 +11:00
|
|
|
Py_DECREF(py_id_capabilities);
|
2024-04-26 21:26:44 +10:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-01 12:06:03 +11:00
|
|
|
#ifdef __GNUC__
|
|
|
|
|
# ifdef __clang__
|
|
|
|
|
# pragma clang diagnostic push
|
|
|
|
|
# pragma clang diagnostic ignored "-Wcast-function-type"
|
|
|
|
|
# else
|
|
|
|
|
# pragma GCC diagnostic push
|
|
|
|
|
# pragma GCC diagnostic ignored "-Wcast-function-type"
|
|
|
|
|
# endif
|
2023-07-21 13:42:35 +10:00
|
|
|
#endif
|
|
|
|
|
|
2022-07-12 16:05:17 +10:00
|
|
|
static PyMethodDef bpy_methods[] = {
|
|
|
|
|
{"script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc},
|
|
|
|
|
{"blend_paths",
|
|
|
|
|
(PyCFunction)bpy_blend_paths,
|
|
|
|
|
METH_VARARGS | METH_KEYWORDS,
|
|
|
|
|
bpy_blend_paths_doc},
|
|
|
|
|
{"flip_name", (PyCFunction)bpy_flip_name, METH_VARARGS | METH_KEYWORDS, bpy_flip_name_doc},
|
2023-07-21 02:18:59 +02:00
|
|
|
{"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS | METH_KEYWORDS, nullptr},
|
2022-07-12 16:05:17 +10:00
|
|
|
{"system_resource",
|
|
|
|
|
(PyCFunction)bpy_system_resource,
|
|
|
|
|
METH_VARARGS | METH_KEYWORDS,
|
|
|
|
|
bpy_system_resource_doc},
|
|
|
|
|
{"resource_path",
|
|
|
|
|
(PyCFunction)bpy_resource_path,
|
|
|
|
|
METH_VARARGS | METH_KEYWORDS,
|
|
|
|
|
bpy_resource_path_doc},
|
|
|
|
|
{"escape_identifier", (PyCFunction)bpy_escape_identifier, METH_O, bpy_escape_identifier_doc},
|
|
|
|
|
{"unescape_identifier",
|
|
|
|
|
(PyCFunction)bpy_unescape_identifier,
|
|
|
|
|
METH_O,
|
|
|
|
|
bpy_unescape_identifier_doc},
|
|
|
|
|
{"context_members", (PyCFunction)bpy_context_members, METH_NOARGS, bpy_context_members_doc},
|
|
|
|
|
{"rna_enum_items_static",
|
|
|
|
|
(PyCFunction)bpy_rna_enum_items_static,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
bpy_rna_enum_items_static_doc},
|
2022-10-10 10:56:05 +11:00
|
|
|
|
|
|
|
|
/* Private functions (not part of the public API and may be removed at any time). */
|
|
|
|
|
{"_driver_secure_code_test",
|
|
|
|
|
(PyCFunction)bpy_driver_secure_code_test,
|
|
|
|
|
METH_VARARGS | METH_KEYWORDS,
|
|
|
|
|
bpy_driver_secure_code_test_doc},
|
|
|
|
|
{"_ghost_backend", (PyCFunction)bpy_ghost_backend, METH_NOARGS, bpy_ghost_backend_doc},
|
2024-04-26 21:26:44 +10:00
|
|
|
{"_wm_capabilities", (PyCFunction)bpy_wm_capabilities, METH_NOARGS, bpy_wm_capabilities_doc},
|
2022-10-10 10:56:05 +11:00
|
|
|
|
2023-07-21 02:18:59 +02:00
|
|
|
{nullptr, nullptr, 0, nullptr},
|
2022-05-31 14:07:08 +10:00
|
|
|
};
|
2010-02-11 14:08:22 +00:00
|
|
|
|
2025-04-01 12:06:03 +11:00
|
|
|
#ifdef __GNUC__
|
|
|
|
|
# ifdef __clang__
|
|
|
|
|
# pragma clang diagnostic pop
|
|
|
|
|
# else
|
|
|
|
|
# pragma GCC diagnostic pop
|
|
|
|
|
# endif
|
2023-07-21 13:42:35 +10:00
|
|
|
#endif
|
|
|
|
|
|
2011-02-20 23:39:29 +00:00
|
|
|
static PyObject *bpy_import_test(const char *modname)
|
2010-02-11 14:08:22 +00:00
|
|
|
{
|
2023-07-21 02:18:59 +02:00
|
|
|
PyObject *mod = PyImport_ImportModuleLevel(modname, nullptr, nullptr, nullptr, 0);
|
2020-10-09 16:33:24 +02:00
|
|
|
|
2011-10-13 01:29:08 +00:00
|
|
|
if (mod) {
|
2010-02-11 14:08:22 +00:00
|
|
|
Py_DECREF(mod);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
PyErr_Print();
|
2012-12-11 22:00:22 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-02-20 23:39:29 +00:00
|
|
|
return mod;
|
2010-02-11 14:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-21 10:59:54 +10:00
|
|
|
void BPy_init_modules(bContext *C)
|
2010-02-11 14:08:22 +00:00
|
|
|
{
|
|
|
|
|
PyObject *mod;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-02-11 14:08:22 +00:00
|
|
|
/* Needs to be first since this dir is needed for future modules */
|
2024-01-23 18:38:15 +01:00
|
|
|
const std::optional<std::string> modpath = BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS,
|
|
|
|
|
"modules");
|
|
|
|
|
if (modpath.has_value()) {
|
2010-04-18 14:47:45 +00:00
|
|
|
// printf("bpy: found module path '%s'.\n", modpath);
|
2011-12-26 12:26:11 +00:00
|
|
|
PyObject *sys_path = PySys_GetObject("path"); /* borrow */
|
2024-01-30 15:54:10 +11:00
|
|
|
PyObject *py_modpath = PyC_UnicodeFromStdStr(modpath.value());
|
2010-02-11 14:08:22 +00:00
|
|
|
PyList_Insert(sys_path, 0, py_modpath); /* add first */
|
|
|
|
|
Py_DECREF(py_modpath);
|
|
|
|
|
}
|
2010-04-18 14:47:45 +00:00
|
|
|
else {
|
2021-06-22 10:42:32 -07:00
|
|
|
printf("bpy: couldn't find 'scripts/modules', blender probably won't start.\n");
|
2010-04-18 14:47:45 +00:00
|
|
|
}
|
2010-02-11 14:08:22 +00:00
|
|
|
/* stand alone utility modules not related to blender directly */
|
2010-10-29 22:59:39 +00:00
|
|
|
IDProp_Init_Types(); /* not actually a submodule, just types */
|
Refactor IDProperty UI data storage
The storage of IDProperty UI data (min, max, default value, etc) is
quite complicated. For every property, retrieving a single one of these
values involves three string lookups. First for the "_RNA_UI" group
property, then another for a group with the property's name, then for
the data value name. Not only is this inefficient, it's hard to reason
about, unintuitive, and not at all self-explanatory.
This commit replaces that system with a UI data struct directly in the
IDProperty. If it's not used, the only cost is of a NULL pointer. Beyond
storing the description, name, and RNA subtype, derived structs are used
to store type specific UI data like min and max.
Note that this means that addons using (abusing) the `_RNA_UI` custom
property will have to be changed. A few places in the addons repository
will be changed after this commit with D9919.
**Before**
Before, first the _RNA_UI subgroup is retrieved the _RNA_UI group,
then the subgroup for the original property, then specific UI data
is accessed like any other IDProperty.
```
prop = rna_idprop_ui_prop_get(idproperties_owner, "prop_name", create=True)
prop["min"] = 1.0
```
**After**
After, the `id_properties_ui` function for RNA structs returns a python
object specifically for managing an IDProperty's UI data.
```
ui_data = idproperties_owner.id_properties_ui("prop_name")
ui_data.update(min=1.0)
```
In addition to `update`, there are now other functions:
- `as_dict`: Returns a dictionary of the property's UI data.
- `clear`: Removes the property's UI data.
- `update_from`: Copy UI data between properties,
even if they have different owners.
Differential Revision: https://developer.blender.org/D9697
2021-08-27 08:27:24 -05:00
|
|
|
IDPropertyUIData_Init_Types();
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2010-02-13 01:13:16 +00:00
|
|
|
Freestyle_Init();
|
2012-12-20 07:57:26 +00:00
|
|
|
#endif
|
2010-02-11 14:08:22 +00:00
|
|
|
|
2011-12-26 12:26:11 +00:00
|
|
|
mod = PyModule_New("_bpy");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-02-11 14:08:22 +00:00
|
|
|
/* add the module so we can import it */
|
2010-08-14 05:33:20 +00:00
|
|
|
PyDict_SetItemString(PyImport_GetModuleDict(), "_bpy", mod);
|
2010-02-11 14:08:22 +00:00
|
|
|
Py_DECREF(mod);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-08-10 11:43:23 +10:00
|
|
|
/* Needs to be first so `_bpy_types` can run. */
|
2024-09-06 14:32:08 +10:00
|
|
|
PyObject *bpy_types = BPY_rna_types();
|
Python: Geometry: create GeometrySet wrapper for Python
In Geometry Nodes a geometry is represented by a `GeometrySet`. This is a
container that can contain one geometry of each of the supported types (mesh,
curves, volume, grease pencil, pointcloud, instances). It's possible for a
`GeometrySet` to contain e.g. a mesh and a point cloud.
This patch creates a Python wrapper for the built-in `GeometrySet`. For now,
it's main purpose is to consume the complete evaluated geometry of an object
without having to go through complex hoops via `depsgraph.object_instances`. It
also also allows retrieving instances that have been created with legacy
instancing systems such as dupli-verts or particles.
In the future, the `GeometrySet` API could also be used for more kinds of
geometry processing from Python, similar to how we use `GeometrySet` internally
as generic geometry storage.
Since we can't really have constness guarantees in Python currently, it's
enforced that the `GeometrySet` wrapper always has its own copy of each geometry
type (so e.g. it does not share a `Mesh` data-block pointer with any other place
in Blender). Without the copy, changes to the mesh in the geometry set would
also affect the evaluated geometry that Blender sees. The copy has a small cost,
but typically the overhead should be low, because attributes and other run-time
data can still be shared. This should be entirely thread-safe, assuming that no
code modifies implicitly shared data, which is forbidden. For historic reasons
there are still cases like #132423 where this assumption does not hold in all
cases. Those cases should be fixed. To my knowledge, this patch does not
introduce any new such issues or makes existing issues worse.
Pull Request: https://projects.blender.org/blender/blender/pulls/135318
2025-03-28 22:40:01 +01:00
|
|
|
PyModule_AddObject(bpy_types, "GeometrySet", BPyInit_geometry_set_type());
|
2025-09-11 06:08:30 +02:00
|
|
|
PyModule_AddObject(bpy_types, "InlineShaderNodes", BPyInit_inline_shader_nodes_type());
|
2024-09-06 14:32:08 +10:00
|
|
|
PyModule_AddObject(mod, "types", bpy_types);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-08-10 11:43:23 +10:00
|
|
|
/* Needs to be first so `_bpy_types` can run. */
|
2020-05-29 14:50:29 +10:00
|
|
|
BPY_library_load_type_ready();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-09 01:01:31 +11:00
|
|
|
BPY_rna_data_context_type_ready();
|
|
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
BPY_rna_gizmo_module(mod);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-08-10 03:48:48 +00:00
|
|
|
/* Important to internalizes `_bpy_types` before creating RNA instances. */
|
|
|
|
|
{
|
|
|
|
|
/* Set a dummy module so the `_bpy_types.py` can access `bpy.types.ID`
|
|
|
|
|
* without a null pointer dereference when instancing types. */
|
|
|
|
|
PyObject *bpy_types_dict_dummy = PyDict_New();
|
|
|
|
|
BPY_rna_types_dict_set(bpy_types_dict_dummy);
|
|
|
|
|
PyObject *bpy_types_module_py = bpy_import_test("_bpy_types");
|
|
|
|
|
/* Something has gone wrong if this is ever populated. */
|
|
|
|
|
BLI_assert(PyDict_GET_SIZE(bpy_types_dict_dummy) == 0);
|
|
|
|
|
Py_DECREF(bpy_types_dict_dummy);
|
|
|
|
|
|
|
|
|
|
PyObject *bpy_types_module_py_dict = PyModule_GetDict(bpy_types_module_py);
|
|
|
|
|
BPY_rna_types_dict_set(bpy_types_module_py_dict);
|
|
|
|
|
}
|
|
|
|
|
PyModule_AddObject(mod, "data", BPY_rna_module());
|
2024-09-06 14:32:08 +10:00
|
|
|
BPY_rna_types_finalize_external_types(bpy_types);
|
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
PyModule_AddObject(mod, "props", BPY_rna_props());
|
2011-11-26 15:18:30 +00:00
|
|
|
PyModule_AddObject(mod, "ops", BPY_operator_module());
|
2011-06-02 08:29:16 +00:00
|
|
|
PyModule_AddObject(mod, "app", BPY_app_struct());
|
2014-06-17 16:03:40 +02:00
|
|
|
PyModule_AddObject(mod, "_utils_units", BPY_utils_units());
|
2015-05-11 16:29:12 +02:00
|
|
|
PyModule_AddObject(mod, "_utils_previews", BPY_utils_previews_module());
|
2017-11-13 19:43:34 +11:00
|
|
|
PyModule_AddObject(mod, "msgbus", BPY_msgbus_module());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA ctx_ptr = RNA_pointer_create_discrete(nullptr, &RNA_Context, C);
|
2011-12-26 12:26:11 +00:00
|
|
|
bpy_context_module = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ctx_ptr);
|
2010-03-03 08:56:48 +00:00
|
|
|
PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-13 15:05:09 +10:00
|
|
|
/* Register methods and property get/set for RNA types. */
|
|
|
|
|
BPY_rna_types_extend_capi();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-05 13:54:17 +11:00
|
|
|
#define PYMODULE_ADD_METHOD(mod, meth) \
|
2024-04-26 21:26:44 +10:00
|
|
|
PyModule_AddObject(mod, (meth)->ml_name, (PyObject *)PyCFunction_New(meth, mod))
|
2024-03-05 13:54:17 +11:00
|
|
|
|
2022-07-12 16:05:17 +10:00
|
|
|
for (int i = 0; bpy_methods[i].ml_name; i++) {
|
|
|
|
|
PyMethodDef *m = &bpy_methods[i];
|
|
|
|
|
/* Currently there is no need to support these. */
|
|
|
|
|
BLI_assert((m->ml_flags & (METH_CLASS | METH_STATIC)) == 0);
|
2024-03-05 13:54:17 +11:00
|
|
|
PYMODULE_ADD_METHOD(mod, m);
|
2022-07-12 16:05:17 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* Register functions (`bpy_rna.cc`). */
|
2024-03-05 13:54:17 +11:00
|
|
|
PYMODULE_ADD_METHOD(mod, &meth_bpy_register_class);
|
|
|
|
|
PYMODULE_ADD_METHOD(mod, &meth_bpy_unregister_class);
|
|
|
|
|
|
|
|
|
|
PYMODULE_ADD_METHOD(mod, &meth_bpy_owner_id_get);
|
|
|
|
|
PYMODULE_ADD_METHOD(mod, &meth_bpy_owner_id_set);
|
|
|
|
|
|
2024-03-08 11:07:41 +11:00
|
|
|
/* Register command functions. */
|
|
|
|
|
PYMODULE_ADD_METHOD(mod, &BPY_cli_command_register_def);
|
|
|
|
|
PYMODULE_ADD_METHOD(mod, &BPY_cli_command_unregister_def);
|
|
|
|
|
|
2024-03-05 13:54:17 +11:00
|
|
|
#undef PYMODULE_ADD_METHOD
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-02-11 14:08:22 +00:00
|
|
|
/* add our own modules dir, this is a python package */
|
2011-12-26 12:26:11 +00:00
|
|
|
bpy_package_py = bpy_import_test("bpy");
|
2010-02-11 14:08:22 +00:00
|
|
|
}
|