32 #include "../generic/py_capi_utils.h"
36 ".. method:: write(filepath, datablocks, path_remap=False, fake_user=False, compress=False)\n"
38 " Write data-blocks into a blend file.\n"
42 " Indirectly referenced data-blocks will be expanded and written too.\n"
44 " :arg filepath: The path to write the blend-file.\n"
45 " :type filepath: string\n"
46 " :arg datablocks: set of data-blocks (:class:`bpy.types.ID` instances).\n"
47 " :type datablocks: set\n"
48 " :arg path_remap: Optionally remap paths when writing the file:\n"
50 " - ``NONE`` No path manipulation (default).\n"
51 " - ``RELATIVE`` Remap paths that are already relative to the new location.\n"
52 " - ``RELATIVE_ALL`` Remap all paths to be relative to the new location.\n"
53 " - ``ABSOLUTE`` Make all paths absolute on writing.\n"
55 " :type path_remap: string\n"
56 " :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
57 " :type fake_user: bool\n"
58 " :arg compress: When True, write a compressed blend file.\n"
59 " :type compress: bool\n");
65 PyObject *datablocks =
NULL;
76 bool use_fake_user =
false, use_compress =
false;
78 static const char *_keywords[] = {
86 static _PyArg_Parser _parser = {
97 if (!_PyArg_ParseTupleAndKeywordsFast(args,
112 Main *bmain_src =
self->ptr.data;
130 } * id_store_array, *id_store;
131 int id_store_len = 0;
140 id_store_array =
MEM_mallocN(
sizeof(*id_store_array) * PySet_Size(datablocks), __func__);
141 id_store = id_store_array;
144 while (_PySet_NextEntry(datablocks, &
pos, &key, &
hash)) {
147 PyErr_Format(PyExc_TypeError,
"Expected an ID type, not %.200s", Py_TYPE(key)->tp_name);
152 id_store->id_flag = id_store->id->flag;
153 id_store->id_us = id_store->id->us;
158 id_store->id->us = 1;
174 bmain_src, filepath_abs, write_flags, path_remap.
value_found, &reports);
187 PyErr_SetString(PyExc_IOError,
"Unknown error writing library data");
195 id_store = id_store_array;
197 for (
int i = 0; i < id_store_len; id_store++, i++) {
205 id_store->id->us = id_store->id_us;
218 METH_VARARGS | METH_KEYWORDS,
void BKE_blendfile_write_partial_begin(struct Main *bmain_src)
void BKE_blendfile_write_partial_end(struct Main *bmain_src)
bool BKE_blendfile_write_partial(struct Main *bmain_src, const char *filepath, int write_flags, int remap_mode, struct ReportList *reports)
void BKE_blendfile_write_partial_tag_ID(struct ID *id, bool set)
const char * BKE_main_blendfile_path_from_global(void)
void BKE_reports_clear(ReportList *reports)
void BKE_reports_init(ReportList *reports, int flag)
void BKE_reports_print(ReportList *reports, eReportType level)
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
external writefile.c function prototypes.
@ BLO_WRITE_PATH_REMAP_NONE
@ BLO_WRITE_PATH_REMAP_RELATIVE_ALL
@ BLO_WRITE_PATH_REMAP_ABSOLUTE
@ BLO_WRITE_PATH_REMAP_RELATIVE
Read Guarded memory(de)allocation.
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
PyDoc_STRVAR(bpy_lib_write_doc, ".. method:: write(filepath, datablocks, path_remap=False, fake_user=False, compress=False)\n" "\n" " Write data-blocks into a blend file.\n" "\n" " .. note::\n" "\n" " Indirectly referenced data-blocks will be expanded and written too.\n" "\n" " :arg filepath: The path to write the blend-file.\n" " :type filepath: string\n" " :arg datablocks: set of data-blocks (:class:`bpy.types.ID` instances).\n" " :type datablocks: set\n" " :arg path_remap: Optionally remap paths when writing the file:\n" "\n" " - ``NONE`` No path manipulation (default).\n" " - ``RELATIVE`` Remap paths that are already relative to the new location.\n" " - ``RELATIVE_ALL`` Remap all paths to be relative to the new location.\n" " - ``ABSOLUTE`` Make all paths absolute on writing.\n" "\n" " :type path_remap: string\n" " :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n" " :type fake_user: bool\n" " :arg compress: When True, write a compressed blend file.\n" " :type compress: bool\n")
static PyObject * bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject *kw)
PyMethodDef BPY_library_write_method_def
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
int PyC_ParseStringEnum(PyObject *o, void *p)
int PyC_ParseBool(PyObject *o, void *p)