1
$\begingroup$

When the object is in edit mode, I want to execute this:-

bpy.ops.object.modifier_add(type='SUBSURF")

And if the same object is in object mode, I want to execute this instead:-

bpy.ops.object.modifier_add(type='SOLDIFY')

I'm really confused about setting up the conditional operators regarding to the context of the object(modes). How do i it ?

$\endgroup$

1 Answer 1

4
$\begingroup$

You can check this in the context.

mode = bpy.context.active_object.mode
if mode == 'EDIT':
    ...

elif mode == 'OBJECT':
    ...
$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .