added the option to Blender.Library to 'link' data for malefico
This commit is contained in:
@@ -218,9 +218,8 @@ BLO_blendhandle_close(
|
||||
|
||||
char *BLO_gethome(void);
|
||||
int BLO_has_bfile_extension(char *str);
|
||||
|
||||
void BLO_library_append(struct SpaceFile *sfile, char *dir, int idcode);
|
||||
void BLO_script_library_append(BlendHandle *bh, char *dir, char *name, int idcode);
|
||||
void BLO_script_library_append(BlendHandle *bh, char *dir, char *name, int idcode, short flag);
|
||||
|
||||
BlendFileData* blo_read_blendafterruntime(int file, int actualsize, BlendReadError *error_r);
|
||||
|
||||
|
||||
@@ -6548,7 +6548,7 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
|
||||
* scripts can load data from .blend files -- see Blender.Library module.*/
|
||||
|
||||
/* append to G.scene */
|
||||
void BLO_script_library_append(BlendHandle *bh, char *dir, char *name, int idcode)
|
||||
void BLO_script_library_append(BlendHandle *bh, char *dir, char *name, int idcode, short flag)
|
||||
{
|
||||
ListBase mainlist;
|
||||
Main *mainl;
|
||||
@@ -6563,7 +6563,7 @@ void BLO_script_library_append(BlendHandle *bh, char *dir, char *name, int idcod
|
||||
/* which one do we need? */
|
||||
mainl = blo_find_main(&mainlist, dir, G.sce);
|
||||
|
||||
append_named_part(fd, mainl, G.scene, name, idcode, 0);
|
||||
append_named_part(fd, mainl, G.scene, name, idcode, flag);
|
||||
|
||||
/* make main consistant */
|
||||
expand_main(fd, mainl);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_space_types.h" /* for line linked */
|
||||
#include "BKE_library.h" /* for all_local */
|
||||
#include "BKE_font.h" /* for text_to_curve */
|
||||
#include "BKE_utildefines.h"
|
||||
@@ -309,27 +310,29 @@ PyObject *M_Library_Load( PyObject * self, PyObject * args )
|
||||
char *base = NULL;
|
||||
int update = 1;
|
||||
int blocktype = 0;
|
||||
int linked = 0;
|
||||
|
||||
if( !bpy_openlib ) {
|
||||
return EXPP_ReturnPyObjError( PyExc_IOError,
|
||||
"no library file: you need to open one, first." );
|
||||
}
|
||||
|
||||
if( !PyArg_ParseTuple( args, "ss|i", &name, &base, &update ) ) {
|
||||
if( !PyArg_ParseTuple( args, "ss|ii", &name, &base, &update, &linked ) ) {
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected two strings as arguments." );
|
||||
}
|
||||
|
||||
blocktype = ( int ) BLO_idcode_from_name( base );
|
||||
|
||||
if( !blocktype ) {
|
||||
if( !blocktype )
|
||||
return EXPP_ReturnPyObjError( PyExc_NameError,
|
||||
"no such Blender datablock type" );
|
||||
}
|
||||
|
||||
BLO_script_library_append( bpy_openlib, bpy_openlibname, name,
|
||||
blocktype );
|
||||
|
||||
|
||||
if (linked)
|
||||
BLO_script_library_append( bpy_openlib, bpy_openlibname, name, blocktype, FILE_LINK);
|
||||
else
|
||||
BLO_script_library_append( bpy_openlib, bpy_openlibname, name, blocktype, 0);
|
||||
|
||||
if( update ) {
|
||||
M_Library_Update( self );
|
||||
Py_DECREF( Py_None ); /* incref'ed by above function */
|
||||
|
||||
@@ -80,17 +80,19 @@ def Datablocks (group):
|
||||
@param group: datablock group, see L{LinkableGroups}.
|
||||
"""
|
||||
|
||||
def Load (datablock, group, update = 1):
|
||||
def Load (datablock, group, update = 1, linked = 0):
|
||||
"""
|
||||
Load the given datablock object from the current library file
|
||||
@type datablock: string
|
||||
@type group: string
|
||||
@type update: bool
|
||||
@type linked: bool
|
||||
@param datablock: an available object name, as returned by L{Datablocks}.
|
||||
@param group: an available group name, as returned by L{LinkableGroups}.
|
||||
@param update: defines if Blender should be updated after loading this
|
||||
object. This means linking all objects and remaking all display lists,
|
||||
so it is potentially very slow.
|
||||
@param linked: Will keep objects linked to their source blend file, the update option or later updating will unlink the data from the original blend and make it local.
|
||||
|
||||
@warn: If you plan to load more than one object in sequence, it is
|
||||
B{definitely recommended} to set 'update' to 0 in all calls to this
|
||||
|
||||
Reference in New Issue
Block a user