How to move obj from Objects to Collection / How to copy objects Blender 2.8

Hi, I’m wondering how to copy an object and I found the way to copy it but it isn’t visible in viewport, it isn’t in scene but it’s ‘hided’… I couldn’t find any way to solve this problem…
I thought it would be easy just to copy an object and move it into scene>collection.
In console you have

x =[‘Dead_Bush_Model.002’]
y = x.copy()

so I know I sucesfully copied object
When I move it manually to collection “Info” window “doesn’t” says how it did it.

Thanks for help!

view3d = context.space_data

ob =["Dead_Bush_Model.002"]
ob_copy = ob.copy()
if view3d.local_view:
    ob_copy.local_view_set(view3d, True)
1 Like

Thakns for that!
but I must mention that if you want use code above you have to have in script:

import bpy
from bpy import context

or just change every line which is starting with context to bpy.context

view3d = context.space_data
change to
view3d = bpy.context.space_data

Now I know why It didn’t work before :upside_down_face:

If you’re using it in an operator, context is part of execute and invoke.