1
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

From https://blender.stackexchange.com/a/38626/58482 I found out that I need to set the active object in addition to selecting it. So using bpy.context.scene.objects.active = obj after creating the new object seems to solve the problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.