0
$\begingroup$

Meyan has a bot that can send tasks for rendering. But I need it to check if pose Mode is set in the scene. If yes, switch it to object and select everything. If not, then just select everything. But I get an error when I run the script through the Linux terminal.

bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.mode_set(mode='OBJECT')

enter image description here

Here is a piece of code that is executed through the console. This is all I can show without nda please understan

enter image description here

error text

enter image description here enter image description here

$\endgroup$
2
  • $\begingroup$ Please add the script you are trying to run and the full error you're seeing. $\endgroup$ Commented Aug 14, 2022 at 19:01
  • $\begingroup$ The error message indicates that there is currently no active object in the scene. Could it be that there is no object present? $\endgroup$ Commented Aug 15, 2022 at 7:22

1 Answer 1

1
$\begingroup$
import bpy
from bpy import context

window = context.window_manager.windows[0]

bpy.ops.object.mode_set(mode='OBJECT')

#creates a list with all scene objects if their type is armature(rig)
scene_armature_obj = [obj for obj in bpy.context.scene.objects if obj.type == "ARMATURE"]

with context.temp_override(window=window):
    bpy.ops.object.select_all(action='DESELECT')

    #loop to select all armature objects and set their mode to EDIT and select them
    for obj in scene_armature_obj:
        bpy.context.view_layer.objects.active = obj
        obj.select_set(True)
        bpy.ops.object.mode_set(mode='EDIT')
$\endgroup$
5
  • $\begingroup$ developer.blender.org/T92464 here is what needs to be done. But I could not understand what exactly can you help? it has something to do with override $\endgroup$
    – Welet
    Commented Aug 15, 2022 at 14:39
  • $\begingroup$ Updated the code. Is that what you meant? $\endgroup$
    – APEC
    Commented Aug 15, 2022 at 15:17
  • $\begingroup$ yes, but I need to select all the rigs, because I don’t know for sure which character will be in which scene $\endgroup$
    – Welet
    Commented Aug 15, 2022 at 15:38
  • $\begingroup$ Updated the code to loop all scene armature objects. $\endgroup$
    – APEC
    Commented Aug 15, 2022 at 15:56
  • $\begingroup$ I have integrated your version into my code. But as a result, they write an error, maybe I'm doing something wrong. I am executing the code via the Linux command /blender -b '/mnt/project/superrally/episodes/test/test/test/test.blend' --python '/home/user/Desktop/plugins/bot/blender_python-redmine. py' and I need to change pose to object sometimes when the wrong mode is set $\endgroup$
    – Welet
    Commented Aug 16, 2022 at 11:53

You must log in to answer this question.

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