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
29 * ***** END GPL/BL DUAL LICENSE BLOCK *****
36 #include <BKE_global.h>
39 #include <DNA_object_types.h>
40 #include <DNA_scriptlink_types.h>
42 /*****************************************************************************/
43 /* Description: This function returns true if both given strings are equal, */
44 /* otherwise it returns false. */
45 /*****************************************************************************/
46 int StringEqual (char * string1, char * string2)
48 return (strcmp(string1, string2)==0);
51 /*****************************************************************************/
52 /* Description: This function returns the name of the given ID struct */
53 /* without the Object type identifying characters prepended. */
54 /*****************************************************************************/
55 char * GetIdName (ID *id)
57 return ((id->name)+2);
60 /*****************************************************************************/
61 /* Description: This function sets an internal string with the given type */
62 /* and error_msg arguments. */
63 /*****************************************************************************/
64 PyObject * PythonReturnErrorObject (PyObject * type, char * error_msg)
66 PyErr_SetString (type, error_msg);
70 /*****************************************************************************/
71 /* Description: This function increments the reference count of the given */
73 /*****************************************************************************/
74 PyObject * PythonIncRef (PyObject *object)
80 /*****************************************************************************/
81 /* Description: This function maps the event identifier to a string. */
82 /*****************************************************************************/
83 char * event_to_name(short event)
87 case SCRIPT_FRAMECHANGED:
88 return "FrameChanged";
98 /*****************************************************************************/
99 /* Description: Returns the object with the name specified by the argument */
100 /* name. Note that the calling function has to remove the first */
101 /* two characters of the object name. These two characters */
102 /* specify the type of the object (OB, ME, WO, ...) */
103 /* The function will return NULL when no object with the given */
105 /*****************************************************************************/
106 struct Object * GetObjectByName (char * name)
110 obj_iter = G.main->object.first;
113 if (StringEqual (name, GetIdName (&(obj_iter->id))))
117 obj_iter = obj_iter->id.next;
120 /* There is no object with the given name */