1

What happens exactly, is that after duplicating an object, then deselecting all selected objects, using:

bpy.ops.object.duplicate()
bpy.ops.object.select_all(action='DESELECT')

then running:

bpy.data.objects['anyobject'].select=True

object is selected in red outline, not orange as usual, as a result, when editing object in edit mode, also in python, it doesn't work either however, before running bpy.ops.object.duplicate(), everything works properly.

I stumbled at this weird problem for a long while, i wonder how to fix it

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
user8844
  • 91
  • 1
  • 8

1 Answers1

2

You need to set the object to be the active object as well as selected

The below code works for me, I just added a Cube at origin (0, 0, 0) selected it then run this script from the text editor (or you can run it from the console as well):

import bpy
C = bpy.context
scene = C.scene
bpy.ops.object.duplicate()
bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects['Cube'].select=True
scene.objects.active = bpy.data.objects['Cube']

This is what happens after running the script:

enter image description here

Tak
  • 6,293
  • 7
  • 43
  • 85