import bpy
# to find special characters
la1=len(bpy.context.screen.areas)
print ('Lenght areas =', la1)
print ()
for j in range(0,la1):
#a1=bpy.context.screen.areas[j].active_space.text
a1=bpy.context.screen.areas[j].type
print (' j=',j,' area=',a1)
k=0
for j in range(0,la1):
print('j=',j ,' area type=',bpy.context.screen.areas[j].type)
if bpy.context.screen.areas[j].type=="TEXT_EDITOR":
k=j
print('This is area number k =',k)
text = bpy.context.screen.areas[k].active_space.text
import bpy
for i, l in enumerate(text.lines):
line = l.body
print(i, line)
how do you identify the different files in the text editor ?
and which one is the active one to read data?
if you have more then one text file in editor
I thought you had to select it first somehow
You should get clear about what you actually mean, get the text of a text datablock or get the text of one of the text datablocks that is currently show in a text editor.
how do you list all text file name ?
Text datablock access path: bpy.data.texts
Reference to a text datablock of a text editor (“active text block”): SpaceTextEditor.text
and how do you copy file name in editor bottom header?
I don’t think you mean file name but text datablock name: Text.name
The file path can be accessed via Text.filepath,
if you want the file name only, you can e.g. use bpy.path.basename(Text.filepath)
Since strings are immutable, it’s always a copy.