after duplicate

I have an active object in scene (cube for example) and I execute duplicate() function

import bpy
r = bpy.ops.object.duplicate()

but I’m not execute r.select = True because an error occurs

‘set’ object has no attribute ‘select’

What happens? :confused:

Thanks in advance.

I don’t think bpy.ops will return a new object.
See docs here.

There is no mention that the operation will return a result.
So your variable r is nothing. And nothing does not have a select attribute.

yep, and operators usually targets active object, but as soon as you duplicate an object the new one gets context…


import bpy
obj = bpy.context.object
bpy.ops.object.duplicate()
dup = bpy.context.object
dup.select = True

print (dup)
print (obj)

my friends many thanks for your help, now I can keep working on my plugin.
:smiley: