6
$\begingroup$

I have an object that I got by accessing bpy.data.objects[] by its index. I later call .copy() on this object to copy it and it works, I get a copy but it isn't added to the scene, how would I go about adding the copy to the scene?

$\endgroup$

2 Answers 2

6
$\begingroup$

I figured it out:

bpy.context.scene.objects.link(object)
$\endgroup$
3
$\begingroup$

In Blender 2.8 this is now

bpy.context.collection.objects.link(object)
$\endgroup$
1
  • $\begingroup$ Note that bpy.context.collection isn't always the "main" collection of a scene, it's rather something like the currently "active" one (at least for Blender 2.93.5). It can for example be the one you last clicked on in the Outliner. As such, you should rather use bpy.context.scene.collection.objects.link(object) instead, as this is always the main collection of the current scene. $\endgroup$
    – Cardboy0
    Commented Nov 18, 2021 at 20:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .