2
$\begingroup$

When I copy an object using bpy.context.active_object.copy() the new object doesn't show up in the Outliner even though it appears when I list() objects in the Python shell.

Questions:

  1. Is there a second step to get the object to show in the Outliner?
  2. Or perhaps it's only copying the object's data? (If so, to what purpose?)
  3. Are there no companion functions, ie: paste() and/or cut()? (Command line completion yields nothing.)

Note: bpy.ops.object.duplicate() makes a copy that does show up in the Outliner, so these questions aren't about how to make a working copy/duplicate. I want to understand the purpose of copy().

$\endgroup$
5
$\begingroup$

Link it to a collection

Prior to 2.8 a copied object required linking to the scene's objects collection. For 2.8+ link it to a collection.

It will show in the outliner when collection is linked to a scene, or is the base scene collection.

The duplicate operator links the dupe to the context collection.

import bpy
from bpy import context


ob = context.object.copy()
context.collection.objects.link(ob)

link new object to scene with python in 2.8

$\endgroup$
1
  • $\begingroup$ Thanks again, batFINGER. I was going to say, "You da man," but in this era, perhaps... "You da person," is more PC. $\endgroup$ – no-one Aug 22 '20 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.