46 #include "../generic/py_capi_utils.h"
50 ".. method:: write(filepath, datablocks, path_remap=False, fake_user=False, compress=False)\n"
52 " Write data-blocks into a blend file.\n"
56 " Indirectly referenced data-blocks will be expanded and written too.\n"
58 " :arg filepath: The path to write the blend-file.\n"
59 " :type filepath: string\n"
60 " :arg datablocks: set of data-blocks (:class:`bpy.types.ID` instances).\n"
61 " :type datablocks: set\n"
62 " :arg path_remap: Optionally remap paths when writing the file:\n"
64 " - ``NONE`` No path manipulation (default).\n"
65 " - ``RELATIVE`` Remap paths that are already relative to the new location.\n"
66 " - ``RELATIVE_ALL`` Remap all paths to be relative to the new location.\n"
67 " - ``ABSOLUTE`` Make all paths absolute on writing.\n"
69 " :type path_remap: string\n"
70 " :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
71 " :type fake_user: bool\n"
72 " :arg compress: When True, write a compressed blend file.\n"
73 " :type compress: bool\n");
79 PyObject *datablocks =
NULL;
90 bool use_fake_user =
false, use_compress =
false;
92 static const char *_keywords[] = {
101 static _PyArg_Parser _parser = {
"sO!|$O&O&O&:write", _keywords, 0};
102 if (!_PyArg_ParseTupleAndKeywordsFast(args,
117 Main *bmain_src =
self->ptr.data;
135 } * id_store_array, *id_store;
136 int id_store_len = 0;
145 id_store_array =
MEM_mallocN(
sizeof(*id_store_array) * PySet_Size(datablocks), __func__);
146 id_store = id_store_array;
149 while (_PySet_NextEntry(datablocks, &
pos, &key, &
hash)) {
152 PyErr_Format(PyExc_TypeError,
"Expected an ID type, not %.200s", Py_TYPE(key)->tp_name);
157 id_store->id_flag = id_store->id->flag;
158 id_store->id_us = id_store->id->us;
163 id_store->id->us = 1;
179 bmain_src, filepath_abs, write_flags, path_remap.
value_found, &reports);
192 PyErr_SetString(PyExc_IOError,
"Unknown error writing library data");
200 id_store = id_store_array;
202 for (
int i = 0; i < id_store_len; id_store++, i++) {
210 id_store->id->us = id_store->id_us;
223 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, const int write_flags, const 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_print(ReportList *reports, ReportType level)
void BKE_reports_clear(ReportList *reports)
void BKE_reports_init(ReportList *reports, int flag)
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
external writefile 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)