Forked from p2or/blender-append-known-obj-from-another-file.py
Created
April 7, 2020 02:28
-
-
Save pampanelson/359efbf9e140317a1eaaeab6852f1de8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy | |
| # current scene | |
| scn = bpy.context.scene | |
| # path to the blend | |
| filepath = "/path/to/file.blend" | |
| # name of object to import | |
| obj_name = "Cube" | |
| # append, set to true to keep the link to the original file | |
| link = False | |
| # link all objects starting with 'A' | |
| with bpy.data.libraries.load(filepath, link=link) as (data_from, data_to): | |
| # find all objects named "Cube" | |
| data_to.objects = [name for name in data_from.objects if name.startswith(obj_name)] | |
| #link object to current scene | |
| for obj in data_to.objects: | |
| if obj is not None: | |
| scn.objects.link(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment