From e031f322a783c42d09cfcb08a846bfc6e34dc3b6 Mon Sep 17 00:00:00 2001 From: Michel Selten Date: Wed, 19 Mar 2003 18:57:23 +0000 Subject: [PATCH] * Implemented the BPY_do_all_scripts interface function (BPY_interface.c) * Created a function to return all scripts from a linked list (DoAllScriptsFromList). Michel --- source/blender/python/BPY_interface.c | 46 +++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index ce63eace501..d205f790f90 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -36,18 +36,23 @@ #include +#include +#include #include +#include #include +#include +#include +#include +#include #include #include #include +#include -#include +#include "BPY_extern.h" #include "api2_2x/interface.h" -/* unfortunately the following #include is needed because of some missing */ -/* functionality in BKE/DNA */ -/* #include "api2_2x/gen_utils.h" */ /*****************************************************************************/ /* Structure definitions */ @@ -70,6 +75,7 @@ PyObject * RunPython(Text *text, PyObject *globaldict); char * GetName(Text *text); PyObject * CreateGlobalDictionary (void); void ReleaseGlobalDictionary (PyObject * dict); +void DoAllScriptsFromList (ListBase * list, short event); /*****************************************************************************/ /* Description: This function will initialise Python and all the implemented */ @@ -163,12 +169,22 @@ void BPY_clear_bad_scriptlinks(struct Text *byebye) } /*****************************************************************************/ -/* Description: */ -/* Notes: Not implemented yet */ +/* Description: Loop through all scripts of a list of object types, and */ +/* execute these scripts. */ +/* For the scene, only the current active scene the scripts are */ +/* executed (if any). */ /*****************************************************************************/ void BPY_do_all_scripts(short event) { printf ("In BPY_do_all_scripts(event=%d)\n",event); + + DoAllScriptsFromList (&(G.main->object), event); + DoAllScriptsFromList (&(G.main->lamp), event); + DoAllScriptsFromList (&(G.main->camera), event); + DoAllScriptsFromList (&(G.main->mat), event); + DoAllScriptsFromList (&(G.main->world), event); + + BPY_do_pyscript (&(G.scene->id), event); return; } @@ -325,3 +341,21 @@ void ReleaseGlobalDictionary (PyObject * dict) Py_DECREF (dict); /* Release dictionary. */ } +/*****************************************************************************/ +/* Description: This function runs all scripts (if any) present in the */ +/* list argument. The event by which the function has been */ +/* called, is passed in the event argument. */ +/*****************************************************************************/ +void DoAllScriptsFromList (ListBase * list, short event) +{ + ID * id; + + id = list->first; + + while (id != NULL) + { + BPY_do_pyscript (id, event); + id = id->next; + } +} +