I am trying to use this operator: bpy.ops.outliner.id_paste() to paste a collection I have copied in the clipboard, and my problem is setting the right context, because I keep getting this error:
RuntimeError: Operator bpy.ops.outliner.id_paste.poll() failed, context is incorrect
This has been my current approach. I suspect it might be solved by being able to select the scene collection, but I have tried almost everything I could find.
override = bpy.context.copy()
for area in bpy.context.screen.areas:
if area.type == 'OUTLINER':
override['area'] = area
bpy.ops.outliner.id_paste()
Any help would be greatly appreciated :)
bpy.context.scene.collection, but no way of getting me there. I think you got as close as possible right now, but I might do the whole operation a different way, by simply pasting the objects and then creating a new collection for the objects, then I can control that collection. – William Larsen Bang Apr 18 '23 at 09:10