2
* $Id: bpy.c,v 1.2 2007/04/18 22:53:20 campbellbarton Exp $
3
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version. The Blender
9
* Foundation also sells licenses for use in proprietary software under
10
* the Blender License. See http://www.blender.org/BL/ for information
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software Foundation,
20
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23
* All rights reserved.
25
* This is a new part of Blender.
27
* Contributor(s): Michel Selten, Willian P. Germano, Joseph Gilbert,
30
* ***** END GPL/BL DUAL LICENSE BLOCK *****
33
/* for open, close in Blender_Load */
35
#include "BLI_blenlib.h"
36
#include "BKE_global.h"
37
#include "BKE_utildefines.h"
38
#include "BKE_scene.h"
41
#include "DNA_scene_types.h"
48
#include "bpy_config.h"
50
/*****************************************************************************/
51
/* Global variables */
52
/*****************************************************************************/
55
/*****************************************************************************/
56
/* Function: initBlender */
57
/*****************************************************************************/
64
/* G.scene should only aver be NULL if blender is executed in
65
background mode, not loading a blend file and executing a python script eg.
66
blender -P somescript.py -b
67
The if below solves the segfaults that happen when python runs and
69
if(G.background && G.main->scene.first==NULL) {
70
Scene *sce= add_scene("1");
71
/*set_scene(sce);*/ /* causes a crash */
75
module = Py_InitModule3("bpy", NULL, "The main bpy module");
77
types_InitAll(); /* set all our pytypes to &PyType_Type */
79
dict = PyModule_GetDict(module);
82
PyModule_AddObject( module, "config", Config_CreatePyObject() );
83
PyDict_SetItemString( dict, "data", Data_Init());
84
PyDict_SetItemString( dict, "libraries", Library_Init( ) );