SpaceHandler from Script Menu

Hi
I am trying to allow a spacehandler script to run when another script is run. I have got the registration details(the #!BPY bit) as the first line but then I cant tell Blender to treat this as a spacehandler using the # SPACEHANDLER.VIEW3D.EVENT header, since if I put the registration details as the first line, it doesnt treat this as a spacehandler event and in the “SpaceHandlers” menu, my script doesnt show up. I have another script which I need the spacehandler for, is there any other way of running the space handler without having to open it in the text editor separately or any way to get around this?
Thanks
Ishan

I have the exact same question.

Hi!
As far as i know there’s no “nice” way to do it.
For a script to show up in the menus, you need the #BPY as first line. A spacehandler needs the #SPACEHANDLER… in the first line.

What you can do though - split your script in two parts:

1st part: #BPY - shows up in the menus - this script just loads the second part as text into the Blender Text editor.

2nd part: #SPACEHANDLER… - once loaded by the first part of the script, the spacehandler can be chosen from the view-menu.

It’s not nice - i know. The user has to choose from the menus two times. Once to execute the loader (first part - which can also display a message for the user to activate the spacehandler) and a second time to activate the just loaded spacehandler.

Michael

How do I load the space handler script from my 1st script?

import Blender
from Blender import Text
script_text = “”"#SPACEHANDLER.VIEW3D.EVENT

Does that do it?

I found how to do it
import Blender
from Blender import Text
Text.Load(‘insert filename with complete path here’)

Perhpas one day there will be an second spacehandler menu item that shows all the unloaded spacehandlers.

ish90an,
there is maybe a better way to do this.
you can store your text in a .py in bpymodules.
just add,
import my_text (where my_text is the name of your module)
to the script.

import Blender
from Blender import NMesh ,Draw, BGL,Text

import my_module

this should find your text file (dependent module) automatically in bpymodules folder.

hope this helps.
reference scripts: http://wiki.blender.org/index.php/Scripts/Catalog#SpaceHandlers