43 ".. method:: write(filepath, datablocks, path_remap=False, fake_user=False, compress=False)\n"
45 " Write data-blocks into a blend file.\n"
49 " Indirectly referenced data-blocks will be expanded and written too.\n"
51 " :arg filepath: The path to write the blend-file.\n"
52 " :type filepath: str | bytes\n"
53 " :arg datablocks: set of data-blocks.\n"
54 " :type datablocks: set[:class:`bpy.types.ID`]\n"
55 " :arg path_remap: Optionally remap paths when writing the file:\n"
57 " - ``NONE`` No path manipulation (default).\n"
58 " - ``RELATIVE`` Remap paths that are already relative to the new location.\n"
59 " - ``RELATIVE_ALL`` Remap all paths to be relative to the new location.\n"
60 " - ``ABSOLUTE`` Make all paths absolute on writing.\n"
62 " :type path_remap: str\n"
63 " :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
64 " :type fake_user: bool\n"
65 " :arg compress: When True, write a compressed blend file.\n"
66 " :type compress: bool\n");
72 PyObject *datablocks =
nullptr;
83 bool use_fake_user =
false, use_compress =
false;
85 static const char *_keywords[] = {
93 static _PyArg_Parser _parser = {
105 if (!_PyArg_ParseTupleAndKeywordsFast(args,
136 PartialWriteContext::IDAddOperations::ADD_DEPENDENCIES |
137 (use_fake_user ? PartialWriteContext::IDAddOperations::SET_FAKE_USER : 0))};
144 while (_PySet_NextEntry(datablocks, &
pos, &key, &
hash)) {
146 PyErr_Format(PyExc_TypeError,
"Expected an ID type, not %.200s", Py_TYPE(key)->tp_name);
150 partial_write_ctx.id_add(
id, add_options,
nullptr);
159 bool success = partial_write_ctx.write(
160 filepath_abs, write_flags, path_remap.
value_found, reports);
162 PyObject *py_return_value;
165 py_return_value = Py_None;
166 Py_INCREF(py_return_value);
170 PyErr_SetString(PyExc_IOError,
"Unknown error writing library data");
172 py_return_value =
nullptr;
177 return py_return_value;
180#if (defined(__GNUC__) && !defined(__clang__))
181# pragma GCC diagnostic push
182# pragma GCC diagnostic ignored "-Wcast-function-type"
188 METH_VARARGS | METH_KEYWORDS,
192#if (defined(__GNUC__) && !defined(__clang__))
193# pragma GCC diagnostic pop
const char * BKE_main_blendfile_path_from_global()
void BKE_reports_free(ReportList *reports)
void BKE_reports_init(ReportList *reports, int flag)
void BKE_reports_print(ReportList *reports, eReportType level)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
#define STRNCPY(dst, src)
external writefile.cc 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: str | bytes\n" " :arg datablocks: set of data-blocks.\n" " :type datablocks: set[:class:`bpy.types.ID`]\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: str\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")
PyMethodDef BPY_library_write_method_def
static PyObject * bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject *kw)
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
int PyC_ParseUnicodeAsBytesAndSize(PyObject *o, void *p)
int PyC_ParseStringEnum(PyObject *o, void *p)
int PyC_ParseBool(PyObject *o, void *p)
header-only compatibility defines.
#define PY_ARG_PARSER_HEAD_COMPAT()