# Python for Text migrating from 2.79 to 2.8

I have a Python script that changes the text in a blend. In 2.79 the script is:

s = bpy.context.scene
sed = s.sequence_editor
sequences = sed.sequences
f = s.objects['Text']
f.data.body = "New text in the field."


"Text" is the name of the field. This works great.

However, in 2.8 I can use Add Text to do the job of placing the text. However, when I try using the above code, I get:

Traceback (most recent call last):
File "/home/ec2-user/proj004/proj004master.py", line 27, in <module>
f = s.objects['Text']
KeyError: 'bpy_prop_collection[key]: key "Text" not found'


I am assuming that since I used Add Text I need to use something other than:

s = bpy.context.scene
sed = s.sequence_editor
sequences = sed.sequences


Does anybody know how I can make this work?

• s.objects["Text"] is a text object linked to the scene. Since in 2.8 you are using a text strip in VSE ( I assume) there is no font object in scene named "Text", hence the keyerror. So do something other than that. – batFINGER Aug 27 '19 at 11:38
• Are you saying there is no way to modify the contents of a text strip using a python script? – mcgeo52 Aug 27 '19 at 20:38

## 1 Answer

Turns out to be stupid simple:

bpy.context.scene.sequence_editor.sequences_all["Test"].text = "New text in the field."