Skip to main content
added sample blend file
Source Link

I'm working on an audio visualizer mostly from scratch. I'm trying to override the context so I can run bpy.ops.graph.sound_bake() but for some reason I can't get the context right. The code is below, as well as the stack trace. What am I doing wrong?

Code:

for window in bpy.context.window_manager.windows:
    screen = window.screen
    for area in screen.areas:
        if area.type == 'VIEW_3D':
            area_type = area.type
            area_ui_type = area.ui_type
            area.type = 'GRAPH_EDITOR'
            area.ui_type = 'FCURVES'
            with bpy.context.temp_override(window=window, area=area):
                bpy.ops.graph.sound_bake(filepath=file)
            area.type = area_type
            area.ui_type = area_ui_type

Stack trace:

Traceback (most recent call last):                                                                                                                                                                               File "E:\Git\music\blender.py", line 348, in <module>
main(music_file)
File "E:\Git\music\blender.py", line 336, in main
create_centerpiece(file, 16)
File "E:\Git\music\blender.py", line 319, in create_centerpiece
bpy.ops.graph.sound_bake(filepath=file)
File "C:\Users\devin gardner\AppData\Local\Programs\Python\Python310\lib\site-packages\bpy\3.6\scripts\modules\bpy\ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.graph.sound_bake.poll() failed, context is incorrect    

Added sample .blend file:

I'm working on an audio visualizer mostly from scratch. I'm trying to override the context so I can run bpy.ops.graph.sound_bake() but for some reason I can't get the context right. The code is below, as well as the stack trace. What am I doing wrong?

Code:

for window in bpy.context.window_manager.windows:
    screen = window.screen
    for area in screen.areas:
        if area.type == 'VIEW_3D':
            area_type = area.type
            area_ui_type = area.ui_type
            area.type = 'GRAPH_EDITOR'
            area.ui_type = 'FCURVES'
            with bpy.context.temp_override(window=window, area=area):
                bpy.ops.graph.sound_bake(filepath=file)
            area.type = area_type
            area.ui_type = area_ui_type

Stack trace:

Traceback (most recent call last):                                                                                                                                                                               File "E:\Git\music\blender.py", line 348, in <module>
main(music_file)
File "E:\Git\music\blender.py", line 336, in main
create_centerpiece(file, 16)
File "E:\Git\music\blender.py", line 319, in create_centerpiece
bpy.ops.graph.sound_bake(filepath=file)
File "C:\Users\devin gardner\AppData\Local\Programs\Python\Python310\lib\site-packages\bpy\3.6\scripts\modules\bpy\ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.graph.sound_bake.poll() failed, context is incorrect    

I'm working on an audio visualizer mostly from scratch. I'm trying to override the context so I can run bpy.ops.graph.sound_bake() but for some reason I can't get the context right. The code is below, as well as the stack trace. What am I doing wrong?

Code:

for window in bpy.context.window_manager.windows:
    screen = window.screen
    for area in screen.areas:
        if area.type == 'VIEW_3D':
            area_type = area.type
            area_ui_type = area.ui_type
            area.type = 'GRAPH_EDITOR'
            area.ui_type = 'FCURVES'
            with bpy.context.temp_override(window=window, area=area):
                bpy.ops.graph.sound_bake(filepath=file)
            area.type = area_type
            area.ui_type = area_ui_type

Stack trace:

Traceback (most recent call last):                                                                                                                                                                               File "E:\Git\music\blender.py", line 348, in <module>
main(music_file)
File "E:\Git\music\blender.py", line 336, in main
create_centerpiece(file, 16)
File "E:\Git\music\blender.py", line 319, in create_centerpiece
bpy.ops.graph.sound_bake(filepath=file)
File "C:\Users\devin gardner\AppData\Local\Programs\Python\Python310\lib\site-packages\bpy\3.6\scripts\modules\bpy\ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.graph.sound_bake.poll() failed, context is incorrect    

Added sample .blend file:

deleted 44 characters in body
Source Link

I'm working on an audio visualizer mostly from scratch. I'm trying to override the context so I can run bpy.ops.graph.sound_bake() but for some reason I can't get the context right. The code is below, as well as the stack trace. What am I doing wrong?

Code:

for window in bpy.context.window_manager.windows:
        screen = window.screen
        for area in screen.areas:
            if area.type == 'VIEW_3D':
                area_type = area.type
                area_ui_type = area.ui_type
                area.type = 'GRAPH_EDITOR'
                area.ui_type = 'FCURVES'
                with bpy.context.temp_override(window=window, area=area):
                    bpy.ops.graph.sound_bake(filepath=file)
                area.type = area_type
                area.ui_type = area_ui_type

Stack trace:

Traceback (most recent call last):                                                                                                                                                                               File "E:\Git\music\blender.py", line 348, in <module>
main(music_file)
File "E:\Git\music\blender.py", line 336, in main
create_centerpiece(file, 16)
File "E:\Git\music\blender.py", line 319, in create_centerpiece
bpy.ops.graph.sound_bake(filepath=file)
File "C:\Users\devin gardner\AppData\Local\Programs\Python\Python310\lib\site-packages\bpy\3.6\scripts\modules\bpy\ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.graph.sound_bake.poll() failed, context is incorrect    

I'm working on an audio visualizer mostly from scratch. I'm trying to override the context so I can run bpy.ops.graph.sound_bake() but for some reason I can't get the context right. The code is below, as well as the stack trace. What am I doing wrong?

Code:

for window in bpy.context.window_manager.windows:
        screen = window.screen
        for area in screen.areas:
            if area.type == 'VIEW_3D':
                area_type = area.type
                area_ui_type = area.ui_type
                area.type = 'GRAPH_EDITOR'
                area.ui_type = 'FCURVES'
                with bpy.context.temp_override(window=window, area=area):
                    bpy.ops.graph.sound_bake(filepath=file)
                area.type = area_type
                area.ui_type = area_ui_type

Stack trace:

Traceback (most recent call last):                                                                                                                                                                               File "E:\Git\music\blender.py", line 348, in <module>
main(music_file)
File "E:\Git\music\blender.py", line 336, in main
create_centerpiece(file, 16)
File "E:\Git\music\blender.py", line 319, in create_centerpiece
bpy.ops.graph.sound_bake(filepath=file)
File "C:\Users\devin gardner\AppData\Local\Programs\Python\Python310\lib\site-packages\bpy\3.6\scripts\modules\bpy\ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.graph.sound_bake.poll() failed, context is incorrect    

I'm working on an audio visualizer mostly from scratch. I'm trying to override the context so I can run bpy.ops.graph.sound_bake() but for some reason I can't get the context right. The code is below, as well as the stack trace. What am I doing wrong?

Code:

for window in bpy.context.window_manager.windows:
    screen = window.screen
    for area in screen.areas:
        if area.type == 'VIEW_3D':
            area_type = area.type
            area_ui_type = area.ui_type
            area.type = 'GRAPH_EDITOR'
            area.ui_type = 'FCURVES'
            with bpy.context.temp_override(window=window, area=area):
                bpy.ops.graph.sound_bake(filepath=file)
            area.type = area_type
            area.ui_type = area_ui_type

Stack trace:

Traceback (most recent call last):                                                                                                                                                                               File "E:\Git\music\blender.py", line 348, in <module>
main(music_file)
File "E:\Git\music\blender.py", line 336, in main
create_centerpiece(file, 16)
File "E:\Git\music\blender.py", line 319, in create_centerpiece
bpy.ops.graph.sound_bake(filepath=file)
File "C:\Users\devin gardner\AppData\Local\Programs\Python\Python310\lib\site-packages\bpy\3.6\scripts\modules\bpy\ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.graph.sound_bake.poll() failed, context is incorrect    
Source Link

Trying to bake sound with a context override through Python

I'm working on an audio visualizer mostly from scratch. I'm trying to override the context so I can run bpy.ops.graph.sound_bake() but for some reason I can't get the context right. The code is below, as well as the stack trace. What am I doing wrong?

Code:

for window in bpy.context.window_manager.windows:
        screen = window.screen
        for area in screen.areas:
            if area.type == 'VIEW_3D':
                area_type = area.type
                area_ui_type = area.ui_type
                area.type = 'GRAPH_EDITOR'
                area.ui_type = 'FCURVES'
                with bpy.context.temp_override(window=window, area=area):
                    bpy.ops.graph.sound_bake(filepath=file)
                area.type = area_type
                area.ui_type = area_ui_type

Stack trace:

Traceback (most recent call last):                                                                                                                                                                               File "E:\Git\music\blender.py", line 348, in <module>
main(music_file)
File "E:\Git\music\blender.py", line 336, in main
create_centerpiece(file, 16)
File "E:\Git\music\blender.py", line 319, in create_centerpiece
bpy.ops.graph.sound_bake(filepath=file)
File "C:\Users\devin gardner\AppData\Local\Programs\Python\Python310\lib\site-packages\bpy\3.6\scripts\modules\bpy\ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.graph.sound_bake.poll() failed, context is incorrect