I am writing a blender addon that shows a panel with an enum property in the object properties. In some cases if the user changes the enum value, the addon needs to create a new object. I managed to get this working using the update callback of the enum property and
bpy.ops.mesh.primitive_cube_add(). Unfortunately, this changes the object selection so that the right column of the blender UI suddenly displays the properties of the new object. Is it possible that the original object stays selected and that the UI keeps displaying my addon panel with the properties of the original object?
I tried to restore the original selection by calling
bpy.ops.object.select_all(action="DESELECT") followed by
obj.select = True. This does select the original object, but the right column of the blender UI still displays the properties of the new object.
I think I need a python command that performs the same action as clicking an object in the scene graph panel, but I could not find any in the blender documentation.