PyAPI: support writing compressed library blends
This commit is contained in:
@@ -66,13 +66,15 @@ PyDoc_STRVAR(bpy_lib_write_doc,
|
|||||||
" :type relative_remap: bool\n"
|
" :type relative_remap: bool\n"
|
||||||
" :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
|
" :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
|
||||||
" :type fake_user: bool\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(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
|
static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
static const char *kwlist[] = {
|
static const char *kwlist[] = {
|
||||||
"filepath", "datablocks",
|
"filepath", "datablocks",
|
||||||
/* optional */
|
/* optional */
|
||||||
"relative_remap", "fake_user",
|
"relative_remap", "fake_user", "compress",
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,15 +82,16 @@ static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject
|
|||||||
const char *filepath;
|
const char *filepath;
|
||||||
char filepath_abs[FILE_MAX];
|
char filepath_abs[FILE_MAX];
|
||||||
PyObject *datablocks = NULL;
|
PyObject *datablocks = NULL;
|
||||||
bool use_relative_remap = false, use_fake_user = false;
|
bool use_relative_remap = false, use_fake_user = false, use_compress = false;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
args, kwds,
|
args, kwds,
|
||||||
"sO!|$O&O&:write", (char **)kwlist,
|
"sO!|$O&O&O&:write", (char **)kwlist,
|
||||||
&filepath,
|
&filepath,
|
||||||
&PySet_Type, &datablocks,
|
&PySet_Type, &datablocks,
|
||||||
PyC_ParseBool, &use_relative_remap,
|
PyC_ParseBool, &use_relative_remap,
|
||||||
PyC_ParseBool, &use_fake_user))
|
PyC_ParseBool, &use_fake_user,
|
||||||
|
PyC_ParseBool, &use_compress))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -100,6 +103,10 @@ static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject
|
|||||||
write_flags |= G_FILE_RELATIVE_REMAP;
|
write_flags |= G_FILE_RELATIVE_REMAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use_compress) {
|
||||||
|
write_flags |= G_FILE_COMPRESS;
|
||||||
|
}
|
||||||
|
|
||||||
BLI_strncpy(filepath_abs, filepath, FILE_MAX);
|
BLI_strncpy(filepath_abs, filepath, FILE_MAX);
|
||||||
BLI_path_abs(filepath_abs, G.main->name);
|
BLI_path_abs(filepath_abs, G.main->name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user