我寻求帮助,因为我真的不知道我必须为此做什么。我绞尽脑汁两天了,我不得不承认我就是不明白......
我需要一个脚本来将定序器中的 View 设置为 bpy.ops.sequencer.view_all() (或类似:bpy.ops.sequencer.view_selected())
为此,我需要覆盖上下文并告诉脚本它必须在定序器区域中运行该命令,如果没有,它将给出:
Python: Traceback (most recent call last):
File "\Text", line 4, in <module>
File "F:\MEDIA\GAMES\Steam\steamapps\common\Blender\3.4\scripts\modules\bpy\ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.sequencer.view_all.poll() failed, context is incorrect
..当然只是设置:
bpy.context.area.ui_type = 'SEQUENCE_EDITOR'
..什么也不做 但我再次完全不知道该怎么做,任何帮助将不胜感激..
最佳答案
这是正确的上下文覆盖:
import bpy
# go through all areas until sequence editor is found
for area in bpy.context.screen.areas:
if area.type == "SEQUENCE_EDITOR":
override = bpy.context.copy()
# change context to the sequencer
override["area"] = area
override["region"] = area.regions[-1]
# run the command with the correct context
with bpy.context.temp_override(**override):
bpy.ops.sequencer.view_all()
break
关于python - bpy.ops.sequencer.view_all() 轮询失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75193580/