Files
test/source/blender/python/intern
Bastien Montagne 76e7770bc9 Python API: Add link/append pre/post handlers.
The `pre` handler is called after blender internal code is done populating
the link/append context with data to be processed, and before this data
starts being linked from library files.

The `post` handler is called after blender is done linking, and
potentailly appending and/or instantiating, the requested data and all
of their dependencies.

Both handlers are called with a single argument, the link/append
context.

An new RNA sets of wrappers have been added to expose relevant info from
these internal C++ structures.

NOTE: !113658 is very similar (but tied to asset drag & drop), whereas
this PR is more general (these could probably live hand-in-hand / side-
by-side).

Implements #122357

Pull Request: https://projects.blender.org/blender/blender/pulls/128279

-----------------

Some quick py example  code:

```python
import bpy

def my_handler_pre(lapp_context):
    print("About to {}:\n\t".format("link" if "LINK" in lapp_context.options else "append"),
          "\n\t".join("{} '{}', from libs ['{}']".format(item.id_type, item.name,
                                                         "', '".join([l.filepath for l in item.source_libraries]))
                      for item in lapp_context.import_items))

def my_handler_post(lapp_context):
    print("{}:\n\t".format("Linked" if "LINK" in lapp_context.options else "Appended"),
          "\n\t".join("{} '{}', from lib '{}'".format(item.id.id_type, item.id.name, item.source_library.filepath)
                      for item in lapp_context.import_items))

bpy.app.handlers.link_append_pre.append(my_handler_pre)
bpy.app.handlers.link_append_post.append(my_handler_post)
```
2024-10-02 16:44:38 +02:00
..
2024-10-01 09:59:33 +10:00