39using namespace blender::bke::blendfile;
44 ".. method:: write(filepath, datablocks, *, "
45 "path_remap='NONE', fake_user=False, compress=False)\n"
47 " Write data-blocks into a blend file.\n"
51 " Indirectly referenced data-blocks will be expanded and written too.\n"
53 " :param filepath: The path to write the blend-file.\n"
54 " :type filepath: str | bytes\n"
55 " :param datablocks: set of data-blocks.\n"
56 " :type datablocks: set[:class:`bpy.types.ID`]\n"
57 " :param path_remap: Optionally remap paths when writing the file:\n"
59 " - ``NONE`` No path manipulation (default).\n"
60 " - ``RELATIVE`` Remap paths that are already relative to the new location.\n"
61 " - ``RELATIVE_ALL`` Remap all paths to be relative to the new location.\n"
62 " - ``ABSOLUTE`` Make all paths absolute on writing.\n"
64 " :type path_remap: str\n"
65 " :param fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
66 " :type fake_user: bool\n"
67 " :param compress: When True, write a compressed blend file.\n"
68 " :type compress: bool\n");
74 PyObject *datablocks =
nullptr;
85 bool use_fake_user =
false, use_compress =
false;
87 static const char *_keywords[] = {
95 static _PyArg_Parser _parser = {
106 if (!_PyArg_ParseTupleAndKeywordsFast(args,
123 Main *bmain_src =
static_cast<Main *
>(self->
ptr->data);
151 if (PySet_GET_SIZE(datablocks) > 0) {
152 PyObject *it = PyObject_GetIter(datablocks);
154 while ((key = PyIter_Next(it))) {
159 PyErr_Format(PyExc_TypeError,
"Expected an ID type, not %.200s", Py_TYPE(key)->tp_name);
162 partial_write_ctx.
id_add(
id, add_options,
nullptr);
176 bool success = partial_write_ctx.
write(
177 filepath_abs, write_flags, path_remap.
value_found, reports);
179 PyObject *py_return_value;
182 py_return_value = Py_None;
183 Py_INCREF(py_return_value);
187 PyErr_SetString(PyExc_IOError,
"Unknown error writing library data");
189 py_return_value =
nullptr;
194 return py_return_value;
199# pragma clang diagnostic push
200# pragma clang diagnostic ignored "-Wcast-function-type"
202# pragma GCC diagnostic push
203# pragma GCC diagnostic ignored "-Wcast-function-type"
210 METH_VARARGS | METH_KEYWORDS,
216# pragma clang diagnostic pop
218# pragma GCC diagnostic pop
external writefile.cc function prototypes.
ID * id_add(const ID *id, IDAddOptions options, 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)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
char * STRNCPY(char(&dst)[N], const char *src)
int PyC_ParseBool(PyObject *o, void *p)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
void BKE_reports_free(ReportList *reports)
PyMethodDef BPY_library_write_method_def
void BKE_reports_init(ReportList *reports, int flag)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
const char * BKE_main_blendfile_path_from_global()
@ BLO_WRITE_PATH_REMAP_RELATIVE_ALL
@ BLO_WRITE_PATH_REMAP_RELATIVE
@ BLO_WRITE_PATH_REMAP_NONE
@ BLO_WRITE_PATH_REMAP_ABSOLUTE
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
bool BKE_main_view_layers_synced_ensure(const Main *bmain)
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
bool BLI_path_abs_from_cwd(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
int PyC_ParseUnicodeAsBytesAndSize(PyObject *o, void *p)
void BKE_reports_print(ReportList *reports, eReportType level)
static PyObject * bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject *kw)
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
int PyC_ParseStringEnum(PyObject *o, void *p)
@ RPT_PRINT_HANDLED_BY_OWNER
header-only compatibility defines.
PyObject_HEAD std::optional< PointerRNA > ptr