|
Blender V5.0
|
#include <Python.h>#include <cstddef>#include "MEM_guardedalloc.h"#include "BLI_bitmap.h"#include "BLI_string.h"#include "BKE_bpath.hh"#include "BKE_global.hh"#include "BKE_lib_id.hh"#include "BKE_lib_query.hh"#include "BKE_main.hh"#include "DNA_ID.h"#include "WM_api.hh"#include "WM_types.hh"#include "bpy_rna_id_collection.hh"#include "../generic/py_capi_rna.hh"#include "../generic/py_capi_utils.hh"#include "../generic/python_compat.hh"#include "../generic/python_utildefines.hh"#include "RNA_enum_types.hh"#include "RNA_prototypes.hh"#include "bpy_rna.hh"Go to the source code of this file.
Classes | |
| struct | IDUserMapData |
| struct | IDFilePathMapData |
| struct | IDFilePathForeachData |
Functions | |
| static Main * | pyrna_bmain_FromPyObject (PyObject *obj) |
| static int | id_code_as_index (const short idcode) |
| static bool | id_check_type (const ID *id, const BLI_bitmap *types_bitmap) |
| static int | foreach_libblock_id_user_map_callback (LibraryIDLinkCallbackData *cb_data) |
| PyDoc_STRVAR (bpy_user_map_doc, ".. method:: user_map(*, subset=None, key_types=None, value_types=None)\n" "\n" " Returns a mapping of all ID data-blocks in current ``bpy.data`` to a set of all " "data-blocks using them.\n" "\n" " For list of valid set members for key_types & value_types, see: " ":class:`bpy.types.KeyingSetPath.id_type`.\n" "\n" " :arg subset: When passed, only these data-blocks and their users will be " "included as keys/values in the map.\n" " :type subset: Sequence[:class:`bpy.types.ID`]\n" " :arg key_types: Filter the keys mapped by ID types.\n" " :type key_types: set[str]\n" " :arg value_types: Filter the values in the set by ID types.\n" " :type value_types: set[str]\n" " :return: dictionary that maps data-blocks ID's to their users.\n" " :rtype: dict[:class:`bpy.types.ID`, set[:class:`bpy.types.ID`]]\n") | |
| static PyObject * | bpy_user_map (PyObject *self, PyObject *args, PyObject *kwds) |
| static bool | foreach_id_file_path_map_callback (BPathForeachPathData *bpath_data, char *, size_t, const char *path_src) |
| static void | foreach_id_file_path_map (BPathForeachPathData &bpath_data) |
| PyDoc_STRVAR (bpy_file_path_map_doc, ".. method:: file_path_map(*, subset=None, key_types=None, include_libraries=False)\n" "\n" " Returns a mapping of all ID data-blocks in current ``bpy.data`` to a set of all " "file paths used by them.\n" "\n" " For list of valid set members for key_types, see: " ":class:`bpy.types.KeyingSetPath.id_type`.\n" "\n" " :arg subset: When given, only these data-blocks and their used file paths " "will be included as keys/values in the map.\n" " :type subset: sequence\n" " :arg key_types: When given, filter the keys mapped by ID types. Ignored if ``subset`` is " "also given.\n" " :type key_types: set[str]\n" " :arg include_libraries: Include library file paths of linked data. False by default.\n" " :type include_libraries: bool\n" " :return: dictionary of :class:`bpy.types.ID` instances, with sets of file path " "strings as their values.\n" " :rtype: dict\n") | |
| static PyObject * | bpy_file_path_map (PyObject *self, PyObject *args, PyObject *kwds) |
| static bool | foreach_id_file_path_foreach_callback (BPathForeachPathData *bpath_data, char *path_dst, const size_t path_dst_maxncpy, const char *path_src) |
| PyDoc_STRVAR (bpy_file_path_foreach_doc, ".. method:: file_path_foreach(visit_path_fn, *, subset=None, visit_types=None, " "flags={'SKIP_PACKED', 'SKIP_WEAK_REFERENCES'})\n" "\n" " Call ``visit_path_fn`` for the file paths used by all ID data-blocks in current " "``bpy.data``.\n" "\n" " For list of valid set members for visit_types, see: " ":class:`bpy.types.KeyingSetPath.id_type`.\n" "\n" " :arg visit_path_fn: function that takes three parameters: the data-block, a file path, " "and a placeholder for future use. The function should return either ``None`` or a ``str``. " "In the latter case, the visited file path will be replaced with the returned string.\n" " :type visit_path_fn: Callable[[:class:`bpy.types.ID`, str, Any], str|None]\n" " :arg subset: When given, only these data-blocks and their used file paths " "will be visited.\n" " :type subset: set[str]\n" " :arg visit_types: When given, only visit data-blocks of these types. Ignored if " "``subset`` is also given.\n" " :type visit_types: set[str]\n" " :type flags: set[str]\n" " :arg flags: Set of flags that influence which data-blocks are visited. See " ":ref:`rna_enum_file_path_foreach_flag_items`.\n") | |
| static PyObject * | bpy_file_path_foreach (PyObject *self, PyObject *args, PyObject *kwds) |
| PyDoc_STRVAR (bpy_batch_remove_doc, ".. method:: batch_remove(ids)\n" "\n" " Remove (delete) several IDs at once.\n" "\n" " Note that this function is quicker than individual calls to :func:`remove()` " "(from :class:`bpy.types.BlendData`\n" " ID collections), but less safe/versatile (it can break Blender, e.g. by removing " "all scenes...).\n" "\n" " :arg ids: Sequence of IDs (types can be mixed).\n" " :type ids: Sequence[:class:`bpy.types.ID`]\n") | |
| static PyObject * | bpy_batch_remove (PyObject *self, PyObject *args, PyObject *kwds) |
| PyDoc_STRVAR (bpy_orphans_purge_doc, ".. method:: orphans_purge()\n" "\n" " Remove (delete) all IDs with no user.\n" "\n" " :arg do_local_ids: Include unused local IDs in the deletion, defaults to True\n" " :type do_local_ids: bool, optional\n" " :arg do_linked_ids: Include unused linked IDs in the deletion, defaults to True\n" " :type do_linked_ids: bool, optional\n" " :arg do_recursive: Recursively check for unused IDs, ensuring no orphaned one " "remain after a single run of that function, defaults to False\n" " :type do_recursive: bool, optional\n" " :return: The number of deleted IDs.\n") | |
| static PyObject * | bpy_orphans_purge (PyObject *self, PyObject *args, PyObject *kwds) |
Variables | |
| const EnumPropertyItem | rna_enum_file_path_foreach_flag_items [] |
| PyMethodDef | BPY_rna_id_collection_user_map_method_def |
| PyMethodDef | BPY_rna_id_collection_file_path_map_method_def |
| PyMethodDef | BPY_rna_id_collection_file_path_foreach_method_def |
| PyMethodDef | BPY_rna_id_collection_batch_remove_method_def |
| PyMethodDef | BPY_rna_id_collection_orphans_purge_method_def |
This file adds some helpers related to ID/Main handling, that cannot fit well in RNA itself.
Definition in file bpy_rna_id_collection.cc.
|
static |
Definition at line 820 of file bpy_rna_id_collection.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), BKE_id_multi_delete(), NC_WINDOW, PY_ARG_PARSER_HEAD_COMPAT, Py_DECREF(), pyrna_bmain_FromPyObject(), pyrna_id_FromPyObject(), self, and WM_main_add_notifier().
|
static |
Definition at line 680 of file bpy_rna_id_collection.cc.
References BKE_bpath_foreach_path_id(), BKE_BPATH_FOREACH_PATH_SKIP_PACKED, BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES, BPathForeachPathData::bmain, BPathForeachPathData::callback_function, BPathForeachPathData::flag, foreach_id_file_path_foreach_callback(), FOREACH_MAIN_LISTBASE_BEGIN, FOREACH_MAIN_LISTBASE_END, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, id_check_type(), PY_ARG_PARSER_HEAD_COMPAT, Py_DECREF(), pyrna_bmain_FromPyObject(), pyrna_enum_bitfield_from_set(), pyrna_enum_bitmap_from_set(), pyrna_id_FromPyObject(), rna_enum_file_path_foreach_flag_items, rna_enum_id_type_items, IDFilePathForeachData::seen_error, self, BPathForeachPathData::user_data, and IDFilePathForeachData::visit_path_fn.
|
static |
Definition at line 381 of file bpy_rna_id_collection.cc.
References BKE_BPATH_FOREACH_PATH_SKIP_PACKED, BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES, BPathForeachPathData::bmain, BPathForeachPathData::callback_function, error(), IDFilePathMapData::file_path_map, BPathForeachPathData::flag, foreach_id_file_path_map(), foreach_id_file_path_map_callback(), FOREACH_MAIN_LISTBASE_BEGIN, FOREACH_MAIN_LISTBASE_END, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, IDFilePathMapData::id, id_check_type(), IDFilePathMapData::id_file_path_set, IDFilePathMapData::include_libraries, MEM_freeN(), PY_ARG_PARSER_HEAD_COMPAT, Py_DECREF(), pyrna_bmain_FromPyObject(), pyrna_enum_bitmap_from_set(), pyrna_id_CreatePyObject(), pyrna_id_FromPyObject(), ret, rna_enum_id_type_items, self, and BPathForeachPathData::user_data.
|
static |
Definition at line 888 of file bpy_rna_id_collection.cc.
References BKE_id_multi_tagged_delete(), BKE_lib_query_unused_ids_tag(), LibQueryUnusedIDsData::do_linked_ids, LibQueryUnusedIDsData::do_local_ids, LibQueryUnusedIDsData::do_recursive, ID_TAG_DOIT, INDEX_ID_NULL, NC_WINDOW, LibQueryUnusedIDsData::num_total, PY_ARG_PARSER_HEAD_COMPAT, PyC_ParseBool(), pyrna_bmain_FromPyObject(), self, and WM_main_add_notifier().
|
static |
Definition at line 160 of file bpy_rna_id_collection.cc.
References BKE_library_foreach_ID_link(), error(), foreach_libblock_id_user_map_callback(), FOREACH_MAIN_LISTBASE_BEGIN, FOREACH_MAIN_LISTBASE_END, FOREACH_MAIN_LISTBASE_ID_BEGIN, FOREACH_MAIN_LISTBASE_ID_END, id_check_type(), IDUserMapData::id_curr, IDWALK_NOP, IDUserMapData::is_subset, MEM_freeN(), PY_ARG_PARSER_HEAD_COMPAT, Py_DECREF(), IDUserMapData::py_id_curr, pyrna_bmain_FromPyObject(), pyrna_enum_bitmap_from_set(), pyrna_id_CreatePyObject(), pyrna_id_FromPyObject(), ret, rna_enum_id_type_items, self, IDUserMapData::types_bitmap, and IDUserMapData::user_map.
|
static |
Definition at line 575 of file bpy_rna_id_collection.cc.
References BLI_assert, BLI_strncpy(), data, ID::name, BPathForeachPathData::owner_id, Py_DECREF(), PyC_UnicodeAsBytesAndSize(), pyrna_struct_CreatePyObject(), PyTuple_SET_ITEMS, result, RNA_id_pointer_create(), and BPathForeachPathData::user_data.
Referenced by bpy_file_path_foreach().
|
static |
Definition at line 344 of file bpy_rna_id_collection.cc.
References BKE_bpath_foreach_path_id(), data, Library::filepath, ID_IS_LINKED, ID::lib, Py_DECREF(), PyC_UnicodeFromBytes(), and BPathForeachPathData::user_data.
Referenced by bpy_file_path_map().
|
static |
Definition at line 326 of file bpy_rna_id_collection.cc.
References BLI_assert, data, BPathForeachPathData::owner_id, Py_DECREF(), PyC_UnicodeFromBytes(), and BPathForeachPathData::user_data.
Referenced by bpy_file_path_map().
|
static |
Definition at line 87 of file bpy_rna_id_collection.cc.
References LibraryIDLinkCallbackData::cb_flag, data, id_check_type(), LibraryIDLinkCallbackData::id_pointer, IDWALK_CB_EMBEDDED, IDWALK_CB_EMBEDDED_NOT_OWNING, IDWALK_CB_LOOPBACK, IDWALK_RET_NOP, Py_DECREF(), pyrna_id_CreatePyObject(), and LibraryIDLinkCallbackData::user_data.
Referenced by bpy_user_map().
|
static |
Definition at line 82 of file bpy_rna_id_collection.cc.
References BLI_BITMAP_TEST_BOOL, GS, id_code_as_index(), and ID::name.
Referenced by bpy_file_path_foreach(), bpy_file_path_map(), bpy_user_map(), and foreach_libblock_id_user_map_callback().
|
static |
Definition at line 77 of file bpy_rna_id_collection.cc.
Referenced by id_check_type().
| PyDoc_STRVAR | ( | bpy_batch_remove_doc | , |
| ".. method:: | batch_removeids)\n" "\n" " Remove (delete) several IDs at once.\n" "\n" " Note that this function is quicker than individual calls to :func:`remove()` " "(from :class:`bpy.types.BlendData`\n" " ID collections, | ||
| but less safe/versatile(it can break Blender, e.g. by removing " "all scenes...).\n" "\n" " :arg ids:Sequence of IDs(types can be mixed).\n" " :type ids:Sequence\n" | [:class:`bpy.types.ID`] ) |
| PyDoc_STRVAR | ( | bpy_file_path_foreach_doc | , |
| ".. method:: file_path_foreach(visit_path_fn, *, subset=None, visit_types=None, " "flags={'SKIP_PACKED', 'SKIP_WEAK_REFERENCES'})\n" "\n" " Call ``visit_path_fn`` for the file paths used by all ID data-blocks in current " "``bpy.data``.\n" "\n" " For list of valid set members for | visit_types, | ||
| see:" ":class:`bpy.types.KeyingSetPath.id_type`.\n" "\n" " :arg visit_path_fn:function that takes three parameters:the data- | block, | ||
| a file | path, | ||
| " "and a placeholder for future use. The function should return either ``None`` or a ``str``. " "In the latter | case, | ||
| the visited file path will be replaced with the returned string.\n" " :type visit_path_fn:Callable | [[:class:`bpy.types.ID`, str, Any], | ||
| str|None]\n" " :arg subset:When | given, | ||
| only these data-blocks and their used file paths " "will be visited.\n" " :type subset:set\n" " :arg visit_types:When | given[str], | ||
| only visit data-blocks of these types. Ignored if " "``subset`` is also given.\n" " :type visit_types:set\n" " :type flags:set\n" " :arg flags:Set of flags that influence which data-blocks are visited. See " ":ref:`rna_enum_file_path_foreach_flag_items`.\n" | [str][str] ) |
| PyDoc_STRVAR | ( | bpy_file_path_map_doc | , |
| ".. method:: file_path_map(*, subset=None, key_types=None, include_libraries=False)\n" "\n" " Returns a mapping of all ID data-blocks in current ``bpy.data`` to a set of all " "file paths used by them.\n" "\n" " For list of valid set members for | key_types, | ||
| see:" ":class:`bpy.types.KeyingSetPath.id_type`.\n" "\n" " :arg subset:When | given, | ||
| only these data-blocks and their used file paths " "will be included as keys/values in the map.\n" " :type subset:sequence\n" " :arg key_types:When | given, | ||
| filter the keys mapped by ID types. Ignored if ``subset`` is " "also given.\n" " :type key_types:set\n" " :arg include_libraries:Include library file paths of linked data. False by default.\n" " :type include_libraries:bool\n" " :return:dictionary of :class:`bpy.types.ID` | instances[str], | ||
| with sets of file path " "strings as their values.\n" " :rtype:dict\n" | ) |
| PyDoc_STRVAR | ( | bpy_orphans_purge_doc | , |
| ".. method:: orphans_purge()\n" "\n" " Remove (delete) all IDs with no user.\n" "\n" " :arg do_local_ids: Include unused local IDs in the | deletion, | ||
| defaults to True\n" " :type do_local_ids:bool | , | ||
| optional\n" " :arg do_linked_ids:Include unused linked IDs in the | deletion, | ||
| defaults to True\n" " :type do_linked_ids:bool | , | ||
| optional\n" " :arg do_recursive:Recursively check for unused | IDs, | ||
| ensuring no orphaned one " "remain after a single run of that | function, | ||
| defaults to False\n" " :type do_recursive:bool | , | ||
| optional\n" " :return:The number of deleted IDs.\n" | ) |
| PyDoc_STRVAR | ( | bpy_user_map_doc | , |
| ".. method:: user_map(*, subset=None, key_types=None, value_types=None)\n" "\n" " Returns a mapping of all ID data-blocks in current ``bpy.data`` to a set of all " "data-blocks using them.\n" "\n" " For list of valid set members for key_types & | value_types, | ||
| see:" ":class:`bpy.types.KeyingSetPath.id_type`.\n" "\n" " :arg subset:When | passed, | ||
| only these data-blocks and their users will be " "included as keys/values in the map.\n" " :type subset:Sequence\n" " :arg key_types:Filter the keys mapped by ID types.\n" " :type key_types:set\n" " :arg value_types:Filter the values in the set by ID types.\n" " :type value_types:set\n" " :return:dictionary that maps data-blocks ID 's to their users.\n" " :rtype:dict]\n" | [:class:`bpy.types.ID`][str][str][:class:`bpy.types.ID`, set[:class:`bpy.types.ID`] ) |
|
static |
Definition at line 44 of file bpy_rna_id_collection.cc.
References BPy_StructRNA_Check, BPy_StructRNA::ptr, and PYRNA_STRUCT_CHECK_OBJ.
Referenced by bpy_batch_remove(), bpy_file_path_foreach(), bpy_file_path_map(), bpy_orphans_purge(), and bpy_user_map().
| PyMethodDef BPY_rna_id_collection_batch_remove_method_def |
Definition at line 966 of file bpy_rna_id_collection.cc.
Referenced by BPY_rna_types_extend_capi().
| PyMethodDef BPY_rna_id_collection_file_path_foreach_method_def |
Definition at line 960 of file bpy_rna_id_collection.cc.
Referenced by BPY_rna_types_extend_capi().
| PyMethodDef BPY_rna_id_collection_file_path_map_method_def |
Definition at line 954 of file bpy_rna_id_collection.cc.
Referenced by BPY_rna_types_extend_capi().
| PyMethodDef BPY_rna_id_collection_orphans_purge_method_def |
Definition at line 972 of file bpy_rna_id_collection.cc.
Referenced by BPY_rna_types_extend_capi().
| PyMethodDef BPY_rna_id_collection_user_map_method_def |
Definition at line 948 of file bpy_rna_id_collection.cc.
Referenced by BPY_rna_types_extend_capi().
| const EnumPropertyItem rna_enum_file_path_foreach_flag_items[] |
Wraps eBPathForeachFlag from BKE_path.hh.
This is exposed publicly (as in, not inline in a function) for the purpose of being included in documentation.
Definition at line 534 of file bpy_rna_id_collection.cc.
Referenced by bpy_file_path_foreach().