The script below is meant to add an effect like "Cross" to the active strip in the VSE..However,after adding 2 colorstrips ,selecting them (alternatively and both together)and on running the script,it gives the following error -
RuntimeError: Operator bpy.ops.sequencer.effect_strip_add.poll() failed, context is incorrectError:
On using the Bruteforce method here,to override the context the terminal throws new error's. TypeError: bpy_struct: item.attr = val: enum "TIMELINE" not found in (, 'VIEW_3D', 'IMAGE_EDITOR', 'NODE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR', 'DOPESHEET_EDITOR', 'GRAPH_EDITOR', 'NLA_EDITOR', 'TEXT_EDITOR', 'CONSOLE', 'INFO', 'OUTLINER', 'PROPERTIES', 'FILE_BROWSER', 'PREFERENCES')
However ,on running the following command ,the 'TIMELINE' window opens ,as expected -
bpy.context.area.ui_type ="TIMELINE"
Please let me know, how to overide this Poll error .
import bpy
#check poll data
#all the area types except 'EMPTY' from blender.org/api/blender_python_api_current/bpy.types.Area.html#bpy.types.Area.type
types = {'VIEW_3D', 'TIMELINE', 'GRAPH_EDITOR', 'DOPESHEET_EDITOR', 'NLA_EDITOR', 'IMAGE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR', 'TEXT_EDITOR', 'NODE_EDITOR', 'LOGIC_EDITOR', 'PROPERTIES', 'OUTLINER', 'USER_PREFERENCES', 'INFO', 'FILE_BROWSER', 'CONSOLE'}
#save the current area
area = bpy.context.area.type
#try each type
for type in types:
#set the context
bpy.context.area.type = type
#print out context where operator works (change the ops below to check a different operator)
if bpy.ops.sequencer.duplicate.poll():
print(type)
#leave the context where it was
bpy.context.area.type = area
#Script to apply a Cross effect at the end of the selected strip
activeStrip = bpy.context.scene.sequence_editor.active_strip
aEnd = activeStrip.frame_final_end
bpy.ops.sequencer.effect_strip_add(frame_start= aEnd, frame_end=aEnd +10, channel=1, replace_sel=True, overlap=False, type='CROSS', color=(0.0, 0.0, 0.0))