9
$\begingroup$

I'm developing a basic sculpting addon for practice and one of the features I'd like to include in this addon requires modes to be set explicitly.

Here's an example of the type of api that I'm looking for.

if bpy.context.mode != 'OBJECT':
    bpy.ops.set_mode('OBJECT')

I tried looking for something on my own, but I only found methods that toggle the mode.

Is there a method like what I was describing that would do the job?

$\endgroup$
13
$\begingroup$

You can go directly to a specific mode using -

bpy.ops.object.mode_set(mode='EDIT', toggle=False)

Valid mode values are 'OBJECT', 'EDIT', 'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT', 'PARTICLE_EDIT', 'POSE' but not all will be accepted at anytime, eg PARTICLE_EDIT will only be accepted if the object has a particle system.

$\endgroup$
0

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.