Previous Thread  Next Thread

chat icon reloading all text-blocks

dertom

Posted: Tue Jul 17, 2012 10:55 pm
Joined: 28 Sep 2009
Posts: 3
Hi there,

I try to reload all text-blocks by a loop, cause I want to use an external editor and let blender reload the scripts before starting the game.

But actually I'm not sure how to achieve this.
Manipulating each of the blocks via
Code:
bpy.data.texts['...']

is not the problem. But I don't know how to use the operator or how to set the context the right way:

bpy.ops.text.reload()

Looking in the sourcecode tells me that reload looks for "edit_text" in the blender-context, which is a Text-type

Would be great if someone could give me a hint, how to set "edit_text" properly.

Thx, dertom
Reply with quote


CoDEmanX

Posted: Wed Jul 18, 2012 12:17 am
Joined: 05 Apr 2009
Posts: 689
Code:
for text in bpy.data.texts:
    override = {'edit_text': text}
    bpy.ops.text.reload(override)

_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


dertom

Posted: Wed Jul 18, 2012 12:22 am
Joined: 28 Sep 2009
Posts: 3
Ahh,..thanks a lot.
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group