[Bf-python] scriptlinks

Willian Padovani Germano wgermano at ig.com.br
Thu May 26 20:37:21 CEST 2005


Martin DeMello wrote:

>So I've got a SCREEN_HANDLER_NETWORK up and running, which calls a C
>function every time data is written to a socket. I'm stuck on the next
>step, though - how do I attach scriptlinks (or, indeed, any sort of
>python callback) to this? Even the simplest possible thing I could
>think of (BPY_txt_do_python_Text( net_script );) didn't work.
>
Hi Martin,

You need to add a place in the interface for them and also a call to the 
running function, BPY_do_pyscript in 
source/blender/python/BPY_interface.c (grep the sources for places where 
this function is called).  But your scriptlink event seems more 
appropriate for the normal kind, linked to a scene, not for space 
handlers, which use the same scriptlink structs but are assigned and 
handled slightly differently.

Alternatively check do_screenhandlers in 
source/blender/src/editscreen.c, added recently by Ton.  These are per 
screen, though.  This file also has a call to BPY_do_pyscript for scene 
ONLOAD events, if you want an example of that.

If you go for a new scene scriptlink event, check 
source/blender/src/buttons_script.c to see how to add your event to the 
scene events menu in the script buttons window.  Also add your new event 
define at the end of source/blender/makesdna/DNA_scriptlink_types.h, if 
you haven't done it yet.  Then you need a proper place to put your call 
to BPY_do_pyscript(), but you said you already have a C function called 
when data comes in, so that's probably the best place.

-- 
Willian





More information about the Bf-python mailing list