# How to create a files-parameter for the bpy.ops.sequencer.image_strip_add()-operator?

I'm trying to figure out how to do things with Python in Blender and am struggling really hard to get even the most basic things done. The construction of the override-parameter in my script below is probably not ideal but seems to work.

The files-arg is of course nonsense. As I understand it I would need to construct a bpy.types.bpy_prop_collection of bpy.types.OperatorFileListElement. But I have no clue how to initialize either of them.

import bpy

screen = bpy.context.window.screen

area   = [area for area in screen.areas if area.type == 'SEQUENCE_EDITOR'][0]
region = [region for region in area.regions if region.type == 'WINDOW'][0]

override = {'window': bpy.context.window,
'screen': screen,
'area': area,
'region': region,
'scene': bpy.context.scene}



Don't use operators to do this; they aren't intended to be called from Python.

The regular data/function API is much simpler to use:

import bpy

se = bpy.context.scene.sequence_editor_create()
seq = se.sequences.new_image('hey', 'C:/temp/hey.png', 1, 1)


It turns out that the problem is just the documentation (it's really misleading). Working code is:

bpy.ops.sequencer.image_strip_add(override,
channel=3,
directory='/home/me/somewhere',
files=({'name': "test"},))


The information what other keys the dict could have is possibly hidden somewhere in the docs. I haven't found it yet.

It seems to be a general concept in the Blender scripting api to "fish in collections". E.g. to create the override arg. But also if you want a reference to the object you just inserted you seem to need to fish in a collection. But maybe I just don't get it yet. (I hope so)

• I know this doesn't answer your question, but for a start I would recommend using the up-to-date api documentation, here: blender.org/documentation/blender_python_api Apr 3 '17 at 17:41
• Don't use operators for this. See my answer for a better approach. Jun 10 '18 at 9:29