Appending objects into the scene by name from an external blend file

In order to append the necessary meshes into the scene by name from an external blend file, we can use the wm.append operator or use the BlendDataLibraries mechanism.

You can get the contents of an external blend file by calling the bpy.data.libraries.load method:

specifying the path to the external blend file as an input parameter.

The method returns two pointers to libraries of objects: data_from – a library of objects obtained from an external blend file and data_to – an empty library into which pointers to objects loaded into the scene should be copied.

Let’s define the path to the external blend file:

and the list of object names that we want to get from it:

Now we can read this external blend file and copy the objects from the “objects” section of the data_from library into the same “objects” section of the data_to library:

When the names of the required meshes are appended to the data_to library, these objects will be copied to the current scene.

Now we just need to link them to the active scene collection:

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments