I wrote a python script that modifies an existing blender armature that I have and some of these modifications include some commands that are only possible in Edit Mode. I know that depending on what is selected, some modes are not possible to switch to. In my case Pose, Edit and Object mode are the three available modes when I select my armature. In this instance, the following three commands could be used:




Of the above three only the second one switches to wrong mode i.e. Object Mode. I found no similar questions/forums on this kind of issue. When trying to change to Edit Mode, blender changes to Object mode and my commands that are intended for edit mode show context error messages (as expected if in Pose/Object mode..) making it not possible for my script to apply the correct changes.

Does anyone have any idea why this is happening and how I could stop this from happening?? Thanks

  • 3
    $\begingroup$ Could we see your script, please? It might be faulty. $\endgroup$ Jan 22, 2019 at 9:59
  • 1
    $\begingroup$ Hello, @TiberiumFusion, I've taken the liberty of editing your last comment. By all means make your case, but we have to gauge ad hominem phrasing carefully.. short-form exchanges between folks who don't yet know one another can easily be misread as offensive. Prefer a neutral tone, unless you're confident you'll be taken the right way. :) $\endgroup$
    – Robin Betts
    Sep 5, 2023 at 6:33
  • 1
    $\begingroup$ @RobinBetts Hello. How is "we don't need 2.79 anymore :D" a neutral tone? Detracting a solution with a big smile... When one declares a legitimate solution is not needed - not merely personally disregarded by the commenter himself, but asserting that we do not need it, that everyone has no need for it (and with a wide grin, no less) - are you "confident you'll be taken the right way :)"? You rewrote my comment. Your logic compels you to rewrite Harry McKenzie's words as well. It is generally displeasing on forums to see people of popularity/power hold exemptions against the rules. $\endgroup$ Sep 6, 2023 at 4:56
  • 2
    $\begingroup$ Hello, @TiberiumFusion, I take your point entirely. My edit was an attempt to resolve a complaint. Hence the asymmetry. Had you made the complaint, the edit and my explanation of it would have been addressed to HarryMcKenzie. His original remark was made on what initially seems a reasonable assumption about newer versions.. your response validly argues the assumption is false. All of that is useful. I was just trying to strip out the bits which had actually been read as personal attack. Now I'm better informed. ( I'm pretty sure, in fact, neither of you intends to insult the other :). ) $\endgroup$
    – Robin Betts
    Sep 6, 2023 at 7:17
  • 1
    $\begingroup$ @HarryMcKenzie .. I've taken a similar liberty with your original comment. $\endgroup$
    – Robin Betts
    Sep 6, 2023 at 7:22

1 Answer 1


I think I know what you are having here. if you see in the outliner, when you select an object via script it becomes orange and not yellow (if you have the default theme on) that means that the object is selected but not active. so if you go to edit mode, it goes automatically to the last object you edited, even if it's no longer selected. I recently faced the same and I solved it kinda the hard core way.

#set the objects to select
ob= bpy.data.objects.get("the_object_you_want_to_edit")
#deselect all the objects to avoid to edit all together
#select the desired object
#set the desired object to active
bpy.context.view_layer.objects.active = ob

it's probably not an elegant solution but works 100% of the times , error free


You must log in to answer this question.

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