Error: Object "Cube" not in View Layer "RenderLayer"!

I try to patch still - it’s now 5 month I patch. :frowning:

Code before was: = ob
obSelect = = True

No more working. So I replace: = ob
obSelect = ob.select_get(view_layer = None)

But give error: Object “Cube” not in View Layer “RenderLayer”!

EDIT: I try to save object select state and make it active. I iterate thoough ob list to modify every object so I need to make select true. But after I want to give object back it select state it has before.

Please how to fix?