library loading api.
this is not well suited to RNA so this is a native python api. This uses: bpy.data.libraries.load(filepath, link=False, relative=False) however the return value needs to use pythons context manager, this means the library loading is confined to a block of code and python cant leave a half loaded library state. eg, load a single scene we know the name of: with bpy.data.libraries.load(filepath) as (data_from, data_to): data_to.scenes = ["Scene"] eg, load all scenes: with bpy.data.libraries.load(filepath) as (data_from, data_to): data_to.scenes = data_from.scenes eg, load all objects starting with 'A' with bpy.data.libraries.load(filepath) as (data_from, data_to): data_to.objects = [name for name in data_from.objects if name.startswith("A")] As you can see gives 2 objects like 'bpy.data', but containing lists of strings which can be moved from one into another.
This commit is contained in:
@@ -190,6 +190,7 @@ static PyObject *bpy_import_test(const char *modname)
|
||||
void BPy_init_modules( void )
|
||||
{
|
||||
extern BPy_StructRNA *bpy_context_module;
|
||||
extern int bpy_lib_init(PyObject *);
|
||||
PointerRNA ctx_ptr;
|
||||
PyObject *mod;
|
||||
|
||||
@@ -219,7 +220,9 @@ void BPy_init_modules( void )
|
||||
|
||||
PyModule_AddObject( mod, "types", BPY_rna_types() ); /* needs to be first so bpy_types can run */
|
||||
PyModule_AddObject(mod, "StructMetaPropGroup", (PyObject *)&pyrna_struct_meta_idprop_Type); /* metaclass for idprop types, bpy_types.py needs access */
|
||||
|
||||
|
||||
bpy_lib_init(mod); /* adds '_bpy._library_load', must be called before 'bpy_types' which uses it */
|
||||
|
||||
bpy_import_test("bpy_types");
|
||||
PyModule_AddObject( mod, "data", BPY_rna_module() ); /* imports bpy_types by running this */
|
||||
bpy_import_test("bpy_types");
|
||||
|
Reference in New Issue
Block a user