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?
2 Answers
$\begingroup$
$\endgroup$
I figured it out:
bpy.context.scene.objects.link(object)
$\begingroup$
$\endgroup$
1
In Blender 2.8 this is now
bpy.context.collection.objects.link(object)
-
$\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$– Cardboy0Commented Nov 18, 2021 at 20:48