Selecting an object in 2.8?

hello
for

OB = bpy.context.selected_objects[0]
... 

the selection code from 2.79 was

bpy.context.scene.objects.active = OB
OB.select = True

is not working anymore in 2.8 due to api changes
its supposed to be replaced by this i think?

bpy.context.render_layer.objects.active = OB 
OB.select_set(action='SELECT')

but its still not working for me
could someone tell me if its normal?
or whar are the exact new codes? i got some response that told me that its not documented

im the creator of thoses two topics and im stuck


thansk for the help

o.select_set(state=True)
context.view_layer.objets.active = o

1 Like

thanks :slight_smile:
o.select_set(state=True)
works

but
context.view_layer.objets.active = o
don’t

you forgot a c in object, it took me a while to see it

now its
bpy.context.view_layer.objects.active = OB

thanks a looootttt !!!

1 Like