I'm new at scripting.
I know that it's a basic question but I tried everything I could and nothing works.
So here's my problem:
I want to create a shortcut that automatically sets up a mirror modifier to an empty and then my custom pie menu opens with extra modifier options.
The only problem is that the menu will show me the option only of the selected object, and in my series of code I'm stuck at selecting the empty. I just want to select the object I defined as "OB" and it's done.
Here is the code:
import bpy
OB = bpy.context.selected_objects[0]
bpy.ops.object.modifier_add(type='MIRROR')
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.empty_add(type='PLAIN_AXES', view_align=False, location=(bpy.context.scene.cursor_location))
bpy.context.object.name = "Mirror Axes"
OB.modifiers["Mirror"].mirror_object = bpy.data.objects["Mirror Axes"]
# HERE I NEED THE CODE THAT SELECTS "OB"
open_menu("D Mirror Menu")
I tried:
bpy.context.scene.objects.active = OB
OB.select = True
bpy.context.selected_objects[0] = OB
bpy.context.object = OB
And many other methods, but nothing works, the empty is still selected !! and I dont know why.
thanks