reloading all text-blocks

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

dertom
Posts: 3
Joined: Mon Sep 28, 2009 8:49 pm
Location: Germany

reloading all text-blocks

Postby dertom » Tue Jul 17, 2012 11:55 pm

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: Select all

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

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Wed Jul 18, 2012 1:17 am

Code: Select all

for text in bpy.data.texts:
    override = {'edit_text': text}
    bpy.ops.text.reload(override)
I'm sitting, waiting, wishing, building Blender in superstition...

dertom
Posts: 3
Joined: Mon Sep 28, 2009 8:49 pm
Location: Germany

Postby dertom » Wed Jul 18, 2012 1:22 am

Ahh,..thanks a lot.


Return to “Python”

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests