How to Appending custom object from external blender file using relative path
How to Appending custom object from external blender file using relative path so i can pack the file with the addon i can append file easily with absolute path like this
but I could fined how to do it with relative path
# external blender file path ---> D:\blend_folder
# blender file name ---> external_blender_file.blend
# object name ---> object_2
#~~~~~~~~~~~~~~~~~~[ this with absolute path ]~~~~~~~~~~~~~~~~~~~~~
# import bpy
# bpy.ops.wm.append(filename="OBJECT_NAME", directory="/PATH/TO/BLENDFILE/NAME.blend\\Object\\")
import bpy
bpy.ops.wm.append(filename="object_2", directory="D:/blend_folder/external_blender_file.blend\\Object\\")
#~~~~~~~~~~~~~~~[ How to make it with relative path ......???? ]~~~~~~~~~~~~~~~~~
1 Comment
There is a pretty nice example using BlendDataLibraries and a relative path in the API: docs.blender.org/api/current/bpy.types.BlendDataLibraries.html
Example script to append all objects named Cube... from a blend file called link_library.blend in the same folder as the script like the add-on directory (tested):
import bpy import os
Further reading:
blender.stackexchange.com/questions/173524/how-can-i-append-an-object-from-an-external-blender-file-using-a-relative-path-w/173628