# How to reload all text editor scripts at once

I'm creating some simple scripts to automatize my workflow. Things like:

import bpy
# import find_and_close_open_edges

def select_by_pattern(name="SovereignMace",part=None,number=None,partsep="_",numsep="."):

# Sql NVL
xstr = lambda s: s or "*"

# name = "Name_<part>[.partnumber]"
if name is None:
pattern = ""
elif part is None:
pattern = name
elif number is None:
pattern = name + partsep + part
else:
pattern = name + partsep + part + numsep + number

pattern = pattern + "*"

# pattern = xstr(name) + xstr(partsep) + \
# xstr(part) + xstr(numsep) + \
# xstr(number)

print("Pattern:",pattern)

# deselect all
bpy.ops.object.select_all(action='DESELECT')

# select all objects by pattern
bpy.ops.object.select_pattern(pattern=pattern)

return {'FINISHED'}


They grow in number, and they become to be dependent on each other. I use an external editor, so I seldom need to reload one or more script at once and the run them in Blender text editor by ALT-P. Is there a way to reload all scripts used in Blender text editor at once? (Mind I'm not asking how to do F8 reload... that's unrelated) Thank you

• I'd suggest convert all scripts into one addon instead (convert all functions into operators, what is probably needed at some point anyway), then press F8 to reload. Related: blender.stackexchange.com/questions/31126/… BTW: There is no reason to return FINISHED (if it's not an operator), have a look into the templates. – brockmann Apr 27 '18 at 10:44
• thanks, it's too early for an addon at present...just looking for a fast tweak... – Kabu Apr 27 '18 at 11:20
• Related – batFINGER Apr 27 '18 at 13:23

Here's a script who does the job:

import bpy

def execute():
""" Check modified external scripts in the scene and update if possible
"""
ctx = bpy.context.copy()
#Ensure  context area is not None
ctx['area'] = ctx['screen'].areas[0]
for t in bpy.data.texts:
if t.is_modified and not t.is_in_memory:
print("  * Warning: Updating external script", t.name)
# Change current context to contain a TEXT_EDITOR
oldAreaType = ctx['area'].type
ctx['area'].type = 'TEXT_EDITOR'
ctx['edit_text'] = t