A Text Datablock named "Text" exists. Within a 3D View operator, I'm attempting to generate the dialog for writing this Datablock to a file, where the user can select a folder and choose a filename. In my 3D View operator, I have:
def execute(self, context):
area_type = bpy.context.area.type
bpy.context.area.type = 'TEXT_EDITOR'
context.space_data.text = bpy.data.texts["Text"]
bpy.ops.text.save('INVOKE_DEFAULT')
bpy.context.area.type = area_type
However, when executing the line bpy.ops.text.save(), the following error occurs:
File "/usr/share/blender/scripts/modules/bpy/ops.py", line 188, in \_\_call\_\_
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.text.save.poll() failed, context is incorrect
I expect I must better specify the context for bpy.ops.text.save. Any hints, advice, or a solution would be very welcomed. Thank you.