40 ".. method:: write(filepath, datablocks, *, "
41 "path_remap=False, fake_user=False, compress=False)\n"
43 " Write data-blocks into a blend file.\n"
47 " Indirectly referenced data-blocks will be expanded and written too.\n"
49 " :arg filepath: The path to write the blend-file.\n"
50 " :type filepath: str | bytes\n"
51 " :arg datablocks: set of data-blocks.\n"
52 " :type datablocks: set[:class:`bpy.types.ID`]\n"
53 " :arg path_remap: Optionally remap paths when writing the file:\n"
55 " - ``NONE`` No path manipulation (default).\n"
56 " - ``RELATIVE`` Remap paths that are already relative to the new location.\n"
57 " - ``RELATIVE_ALL`` Remap all paths to be relative to the new location.\n"
58 " - ``ABSOLUTE`` Make all paths absolute on writing.\n"
60 " :type path_remap: str\n"
61 " :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
62 " :type fake_user: bool\n"
63 " :arg compress: When True, write a compressed blend file.\n"
64 " :type compress: bool\n");
70 PyObject *datablocks =
nullptr;
81 bool use_fake_user =
false, use_compress =
false;
83 static const char *_keywords[] = {
91 static _PyArg_Parser _parser = {
103 if (!_PyArg_ParseTupleAndKeywordsFast(args,
138 if (PySet_GET_SIZE(datablocks) > 0) {
139 PyObject *it = PyObject_GetIter(datablocks);
141 while ((key = PyIter_Next(it))) {
146 PyErr_Format(PyExc_TypeError,
"Expected an ID type, not %.200s", Py_TYPE(key)->tp_name);
149 partial_write_ctx.
id_add(
id, add_options,
nullptr);
163 bool success = partial_write_ctx.
write(
164 filepath_abs, write_flags, path_remap.
value_found, reports);
166 PyObject *py_return_value;
169 py_return_value = Py_None;
170 Py_INCREF(py_return_value);
174 PyErr_SetString(PyExc_IOError,
"Unknown error writing library data");
176 py_return_value =
nullptr;
181 return py_return_value;
186# pragma clang diagnostic push
187# pragma clang diagnostic ignored "-Wcast-function-type"
189# pragma GCC diagnostic push
190# pragma GCC diagnostic ignored "-Wcast-function-type"
197 METH_VARARGS | METH_KEYWORDS,
203# pragma clang diagnostic pop
205# pragma GCC diagnostic pop
const char * BKE_main_blendfile_path_from_global()
@ RPT_PRINT_HANDLED_BY_OWNER
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
char * STRNCPY(char(&dst)[N], const char *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
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
PyMethodDef BPY_library_write_method_def
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")
static PyObject * bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject *kw)
ID * id_add(const ID *id, IDAddOptions options, blender::FunctionRef< IDAddOperations(LibraryIDLinkCallbackData *cb_data, IDAddOptions options)> dependencies_filter_cb=nullptr)
bool write(const char *write_filepath, int write_flags, int remap_mode, ReportList &reports)
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()