From 3bd71e9ad50fc002e4dacd0b869dadb9a580f2e5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Oct 2006 15:24:15 +0000 Subject: added the option to Blender.Library to 'link' data for malefico --- source/blender/blenloader/BLO_readfile.h | 3 +-- source/blender/blenloader/intern/readfile.c | 4 ++-- source/blender/python/api2_2x/Library.c | 17 ++++++++++------- source/blender/python/api2_2x/doc/Library.py | 4 +++- 4 files changed, 16 insertions(+), 12 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 29650953641..2d1a8b7db05 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -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); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ed23113082e..b5c5aa87bbe 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -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); diff --git a/source/blender/python/api2_2x/Library.c b/source/blender/python/api2_2x/Library.c index 8e25820a4b6..ac88fb53268 100644 --- a/source/blender/python/api2_2x/Library.c +++ b/source/blender/python/api2_2x/Library.c @@ -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 */ diff --git a/source/blender/python/api2_2x/doc/Library.py b/source/blender/python/api2_2x/doc/Library.py index f12b2e8a08b..3d1949be297 100644 --- a/source/blender/python/api2_2x/doc/Library.py +++ b/source/blender/python/api2_2x/doc/Library.py @@ -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 -- cgit v1.2.3