How to append an object from another blend file to the scene using the Blender Python API

The Blender Python API provides the ability to append or link objects from another *.blend file to the current scene using the “append” command.

To append an object (for example – a mesh) from another .blend file, we need to do the following:

  1. Specify the full path to the blend-file from which to get an object.

  1. Specify the relative path to the required object in the internal hierarchy of the blend file.

  1. Specify the name of the required object.

  1. And execute the “append” operator with three required parameters:

After executing this code, by clicking the “Run Script” button, we will append the “Suzanne” mesh from the specified 11.blend file into the current scene.

Full code:

5 3 votes
Article Rating
Subscribe
Notify of
guest

9 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
hannes
hannes
2 years ago

this is legacy code, using operators is best avoided since it doesn’t run correctly sometimes.

the new way is using BlendDataLibraries https://docs.blender.org/api/blender_python_api_2_77_1/bpy.types.BlendDataLibraries.html

hannes
hannes
2 years ago
Reply to  hannes

example:

Brian
Brian
10 months ago
Reply to  Nikita

I think your example code was perfect because I only wanted to import a single material from a .blend that contains many. All of the other examples I’ve seen pull in all materials from the source blend….not what I wanted. BTW I’m using blender 4.0 and it works perfectly

Last edited 10 months ago by Brian
JunoMars
2 years ago

While this code is nice and neat, I can’t get it to work. What am I doing wrong?

Peter MOUEZA
3 years ago

How to do if we don’t know object name ?

Lawrence D’Oliveiro
Lawrence D’Oliveiro
3 years ago

The filepath argument is not necessary.