| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  | /* 
 | 
					
						
							| 
									
										
										
										
											2004-09-18 18:47:03 +00:00
										 |  |  |  * $Id$ | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. The Blender | 
					
						
							|  |  |  |  * Foundation also sells licenses for use in proprietary software under | 
					
						
							|  |  |  |  * the Blender License.  See http://www.blender.org/BL/ for information
 | 
					
						
							|  |  |  |  * about this. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2003-10-05 11:17:14 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Object module provides generic access to Objects of various types via | 
					
						
							|  |  |  |  * the Python interface. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2004-01-16 23:40:14 +00:00
										 |  |  |  * Contributor(s): Michel Selten, Willian Germano, Jacques Guignot, | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  |  * Joseph Gilbert, Stephen Swaney, Bala Gi, Campbell Barton | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-21 20:33:06 +00:00
										 |  |  | #include "Object.h"
 | 
					
						
							| 
									
										
										
										
											2004-04-19 06:57:41 +00:00
										 |  |  | #include "NLA.h"
 | 
					
						
							| 
									
										
										
										
											2004-06-11 13:15:50 +00:00
										 |  |  | #include "logic.h"
 | 
					
						
							| 
									
										
										
										
											2004-06-10 15:14:49 +00:00
										 |  |  | #include <blendef.h>
 | 
					
						
							|  |  |  | #include <DNA_scene_types.h>
 | 
					
						
							| 
									
										
										
										
											2004-06-11 13:15:50 +00:00
										 |  |  | #include <DNA_property_types.h>
 | 
					
						
							| 
									
										
										
										
											2004-06-10 15:14:49 +00:00
										 |  |  | #include <BSE_edit.h>
 | 
					
						
							| 
									
										
										
										
											2004-06-11 13:15:50 +00:00
										 |  |  | #include <BKE_property.h>
 | 
					
						
							| 
									
										
										
										
											2004-06-10 15:14:49 +00:00
										 |  |  | #include <BKE_mball.h>
 | 
					
						
							|  |  |  | #include <BIF_editview.h>
 | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-11 13:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Python API function prototypes for the Blender module.					 */ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyObject *M_Object_New(PyObject *self, PyObject *args); | 
					
						
							|  |  |  | PyObject *M_Object_Get(PyObject *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-29 19:57:41 +00:00
										 |  |  | PyObject *M_Object_get(PyObject *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | static PyObject *M_Object_GetSelected (PyObject *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-29 19:57:41 +00:00
										 |  |  | static PyObject *M_Object_getSelected (PyObject *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* The following string definitions are used for documentation strings.		 */ | 
					
						
							|  |  |  | /* In Python these will be written to the console when doing a				 */ | 
					
						
							|  |  |  | /* Blender.Object.__doc__													 */ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | char M_Object_doc[] = | 
					
						
							|  |  |  | "The Blender Object module\n\n\
 | 
					
						
							|  |  |  | This module provides access to **Object Data** in Blender.\n"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | char M_Object_New_doc[] = | 
					
						
							|  |  |  | "(type) - Add a new object of type 'type' in the current scene"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | char M_Object_Get_doc[] = | 
					
						
							|  |  |  | "(name) - return the object with the name 'name', returns None if not\
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	found.\n\ | 
					
						
							|  |  |  | 	If 'name' is not specified, it returns a list of all objects in the\n\ | 
					
						
							|  |  |  | 	current scene."; | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | char M_Object_GetSelected_doc[] = | 
					
						
							|  |  |  | "() - Returns a list of selected Objects in the active layer(s)\n\
 | 
					
						
							|  |  |  | The active object is the first in the list, if visible"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Python method structure definition for Blender.Object module:			 */ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | struct PyMethodDef M_Object_methods[] = { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	{"New",			(PyCFunction)M_Object_New,		   METH_VARARGS, | 
					
						
							|  |  |  | 					M_Object_New_doc}, | 
					
						
							|  |  |  | 	{"Get",			(PyCFunction)M_Object_Get,		   METH_VARARGS, | 
					
						
							|  |  |  | 					M_Object_Get_doc}, | 
					
						
							|  |  |  | 	{"get",			(PyCFunction)M_Object_get,		   METH_VARARGS, | 
					
						
							|  |  |  | 					M_Object_Get_doc}, | 
					
						
							|  |  |  | 	{"GetSelected", (PyCFunction)M_Object_GetSelected, METH_VARARGS, | 
					
						
							|  |  |  | 					M_Object_GetSelected_doc}, | 
					
						
							|  |  |  | 	{"getSelected", (PyCFunction)M_Object_getSelected, METH_VARARGS, | 
					
						
							|  |  |  | 					M_Object_GetSelected_doc}, | 
					
						
							|  |  |  | 	{NULL, NULL, 0, NULL} | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Python BPy_Object methods declarations:									   */ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-07-25 19:52:51 +00:00
										 |  |  | static PyObject *Object_buildParts (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static PyObject *Object_clearIpo (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_clrParent (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | static PyObject *Object_clearTrack (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getData (BPy_Object *self); | 
					
						
							|  |  |  | static PyObject *Object_getDeltaLocation (BPy_Object *self); | 
					
						
							|  |  |  | static PyObject *Object_getDrawMode (BPy_Object *self); | 
					
						
							|  |  |  | static PyObject *Object_getDrawType (BPy_Object *self); | 
					
						
							|  |  |  | static PyObject *Object_getEuler (BPy_Object *self); | 
					
						
							|  |  |  | static PyObject *Object_getInverseMatrix (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static PyObject *Object_getIpo (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getLocation (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | static PyObject *Object_getMaterials (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  | static PyObject *Object_getMatrix (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | static PyObject *Object_getName (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getParent (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2004-01-23 02:59:54 +00:00
										 |  |  | static PyObject *Object_getSize (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2004-04-02 18:38:38 +00:00
										 |  |  | static PyObject *Object_getTimeOffset (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getTracked (BPy_Object *self); | 
					
						
							|  |  |  | static PyObject *Object_getType (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | static PyObject *Object_getBoundBox (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2004-04-19 06:57:41 +00:00
										 |  |  | static PyObject *Object_getAction (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  | static PyObject *Object_isSelected (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | static PyObject *Object_makeDisplayList (BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_link (BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_makeParent (BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_materialUsage (BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_setDeltaLocation (BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_setDrawMode (BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_setDrawType (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2004-03-03 00:45:10 +00:00
										 |  |  | static PyObject *Object_setEuler (BPy_Object *self, PyObject *args);\ | 
					
						
							|  |  |  | static PyObject *Object_setMatrix (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static PyObject *Object_setIpo (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_setLocation (BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | static PyObject *Object_setName (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2004-01-23 02:59:54 +00:00
										 |  |  | static PyObject *Object_setSize (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2004-04-02 18:38:38 +00:00
										 |  |  | static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | static PyObject *Object_makeTrack (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  | static PyObject *Object_Select (BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
										
										
											2004-06-11 13:15:50 +00:00
										 |  |  | static PyObject *Object_getAllProperties (BPy_Object *self); | 
					
						
							|  |  |  | static PyObject *Object_addProperty(BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_removeProperty(BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_getProperty(BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_removeAllProperties(BPy_Object *self); | 
					
						
							|  |  |  | static PyObject *Object_copyAllPropertiesTo(BPy_Object *self, PyObject *args); | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | static PyObject *Object_getScriptLinks(BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_addScriptLink(BPy_Object *self, PyObject *args); | 
					
						
							|  |  |  | static PyObject *Object_clearScriptLinks(BPy_Object *self); | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Python BPy_Object methods table:											   */ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyMethodDef BPy_Object_methods[] = { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	/* name, method, flags, doc */ | 
					
						
							|  |  |  |   {"buildParts", (PyCFunction)Object_buildParts, METH_NOARGS, | 
					
						
							|  |  |  | 	"Recalcs particle system (if any) "}, | 
					
						
							|  |  |  |   {"getIpo", (PyCFunction)Object_getIpo, METH_NOARGS, | 
					
						
							|  |  |  | 		"Returns the ipo of this object (if any) "},    | 
					
						
							|  |  |  |   {"clrParent", (PyCFunction)Object_clrParent, METH_VARARGS, | 
					
						
							|  |  |  | 	"Clears parent object. Optionally specify:\n\
 | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | mode\n\tnonzero: Keep object transform\nfast\n\t>0: Don't update scene \ | 
					
						
							|  |  |  | hierarchy (faster)"}, | 
					
						
							|  |  |  |   {"clearTrack", (PyCFunction)Object_clearTrack, METH_VARARGS, | 
					
						
							|  |  |  | 	"Make this object not track another anymore. Optionally specify:\n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \ | 
					
						
							|  |  |  | hierarchy (faster)"}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"getData", (PyCFunction)Object_getData, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the datablock object containing the object's data, e.g. Mesh"}, | 
					
						
							|  |  |  |   {"getDeltaLocation", (PyCFunction)Object_getDeltaLocation, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object's delta location (x, y, z)"}, | 
					
						
							|  |  |  |   {"getDrawMode", (PyCFunction)Object_getDrawMode, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object draw modes"}, | 
					
						
							|  |  |  |   {"getDrawType", (PyCFunction)Object_getDrawType, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object draw type"}, | 
					
						
							| 
									
										
										
										
											2004-04-19 06:57:41 +00:00
										 |  |  |   {"getAction", (PyCFunction)Object_getAction, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the active action for this object"}, | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  |   {"isSelected", (PyCFunction)Object_isSelected, METH_NOARGS, | 
					
						
							|  |  |  | 	"Return a 1 or 0 depending on whether the object is selected"},   | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"getEuler", (PyCFunction)Object_getEuler, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object's rotation as Euler rotation vector\n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | (rotX, rotY, rotZ)"}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"getInverseMatrix", (PyCFunction)Object_getInverseMatrix, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object's inverse matrix"}, | 
					
						
							|  |  |  |   {"getLocation", (PyCFunction)Object_getLocation, METH_VARARGS, | 
					
						
							|  |  |  | 	"Returns the object's location (x, y, z)"}, | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  |   {"getMaterials", (PyCFunction)Object_getMaterials, METH_VARARGS, | 
					
						
							|  |  |  | 	"(i = 0) - Returns list of materials assigned to the object.\n\
 | 
					
						
							|  |  |  | if i is nonzero, empty slots are not ignored: they are returned as None's."}, | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  |   {"getMatrix", (PyCFunction)Object_getMatrix, METH_VARARGS, | 
					
						
							|  |  |  | 	"Returns the object matrix - worlspace or localspace (default)"}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"getName", (PyCFunction)Object_getName, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the name of the object"}, | 
					
						
							|  |  |  |   {"getParent", (PyCFunction)Object_getParent, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object's parent object"}, | 
					
						
							| 
									
										
										
										
											2004-01-23 02:59:54 +00:00
										 |  |  |   {"getSize", (PyCFunction)Object_getSize, METH_VARARGS, | 
					
						
							|  |  |  | 	"Returns the object's size (x, y, z)"}, | 
					
						
							| 
									
										
										
										
											2004-04-02 18:38:38 +00:00
										 |  |  |   {"getTimeOffset", (PyCFunction)Object_getTimeOffset, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object's time offset"}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"getTracked", (PyCFunction)Object_getTracked, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object's tracked object"}, | 
					
						
							|  |  |  |   {"getType", (PyCFunction)Object_getType, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns type of string of Object"}, | 
					
						
							|  |  |  |   {"getBoundBox", (PyCFunction)Object_getBoundBox, METH_NOARGS, | 
					
						
							|  |  |  | 	"Returns the object's bounding box"}, | 
					
						
							|  |  |  |   {"makeDisplayList", (PyCFunction)Object_makeDisplayList, METH_NOARGS, | 
					
						
							|  |  |  | 	"Update this object's Display List. Some changes like turning \n\
 | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | 'SubSurf' on for a mesh need this method (followed by a Redraw) to \n\ | 
					
						
							|  |  |  | show the changes on the 3d window."}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"link", (PyCFunction)Object_link, METH_VARARGS, | 
					
						
							|  |  |  | 	"Links Object with data provided in the argument. The data must \n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | match the Object's type, so you cannot link a Lamp to a Mesh type object."}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"makeParent", (PyCFunction)Object_makeParent, METH_VARARGS, | 
					
						
							|  |  |  | 	"Makes the object the parent of the objects provided in the \n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | argument which must be a list of valid Objects. Optional extra arguments:\n\ | 
					
						
							|  |  |  | mode:\n\t0: make parent with inverse\n\t1: without inverse\n\ | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | fast:\n\t0: update scene hierarchy automatically\n\t\ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | don't update scene hierarchy (faster). In this case, you must\n\t\ | 
					
						
							|  |  |  | explicitely update the Scene hierarchy."}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"materialUsage", (PyCFunction)Object_materialUsage, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2004-01-23 02:59:54 +00:00
										 |  |  | 	"Determines the way the material is used and returns status.\n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | Possible arguments (provide as strings):\n\ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | \tData:   Materials assigned to the object's data are shown. (default)\n\ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | \tObject: Materials assigned to the object are shown."}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"setDeltaLocation", (PyCFunction)Object_setDeltaLocation, METH_VARARGS, | 
					
						
							|  |  |  | 	"Sets the object's delta location which must be a vector triple."}, | 
					
						
							|  |  |  |   {"setDrawMode", (PyCFunction)Object_setDrawMode, METH_VARARGS, | 
					
						
							|  |  |  | 	"Sets the object's drawing mode. The argument can be a sum of:\n\
 | 
					
						
							|  |  |  | 2:	axis\n4:  texspace\n8:	drawname\n16: drawimage\n32: drawwire"}, | 
					
						
							|  |  |  |   {"setDrawType", (PyCFunction)Object_setDrawType, METH_VARARGS, | 
					
						
							|  |  |  | 	"Sets the object's drawing type. The argument must be one of:\n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | 1: Bounding box\n2: Wire\n3: Solid\n4: Shaded\n5: Textured"}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"setEuler", (PyCFunction)Object_setEuler, METH_VARARGS, | 
					
						
							|  |  |  | 	"Set the object's rotation according to the specified Euler\n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | angles. The argument must be a vector triple"}, | 
					
						
							| 
									
										
										
										
											2004-03-03 00:45:10 +00:00
										 |  |  |   {"setMatrix", (PyCFunction)Object_setMatrix, METH_VARARGS, | 
					
						
							|  |  |  | 	"Set and apply a new matrix for the object"}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"setLocation", (PyCFunction)Object_setLocation, METH_VARARGS, | 
					
						
							|  |  |  | 	"Set the object's location. The first argument must be a vector\n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | triple."}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"setMaterials", (PyCFunction)Object_setMaterials, METH_VARARGS, | 
					
						
							|  |  |  | 	"Sets materials. The argument must be a list of valid material\n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | objects."}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"setName", (PyCFunction)Object_setName, METH_VARARGS, | 
					
						
							|  |  |  | 	"Sets the name of the object"}, | 
					
						
							| 
									
										
										
										
											2004-01-23 02:59:54 +00:00
										 |  |  |   {"setSize", (PyCFunction)Object_setSize, METH_VARARGS, | 
					
						
							|  |  |  | 	"Set the object's size. The first argument must be a vector\n\
 | 
					
						
							|  |  |  | triple."}, | 
					
						
							| 
									
										
										
										
											2004-04-02 18:38:38 +00:00
										 |  |  |   {"setTimeOffset", (PyCFunction)Object_setTimeOffset, METH_VARARGS, | 
					
						
							|  |  |  | 	"Set the object's time offset."}, | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  |   {"makeTrack", (PyCFunction)Object_makeTrack, METH_VARARGS, | 
					
						
							|  |  |  | 	"(trackedobj, fast = 0) - Make this object track another.\n\
 | 
					
						
							|  |  |  | 	 (trackedobj) - the object that will be tracked.\n\ | 
					
						
							|  |  |  | 	 (fast = 0) - if 0: update the scene hierarchy automatically.  If you\n\ | 
					
						
							|  |  |  | 	 set 'fast' to a nonzero value, don't forget to update the scene yourself\n\ | 
					
						
							|  |  |  | 	 (see scene.update())."}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS, | 
					
						
							|  |  |  | 	"Link data of self with object specified in the argument. This\n\
 | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | works only if self and the object specified are of the same type."}, | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  |   {"select", (PyCFunction)Object_Select, METH_VARARGS, | 
					
						
							|  |  |  | 	"( 1 or 0 )  - Set the selected state of the object.\n\
 | 
					
						
							|  |  |  |    1 is selected, 0 not selected "}, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   {"setIpo", (PyCFunction)Object_setIpo, METH_VARARGS, | 
					
						
							|  |  |  | 	"(Blender Ipo) - Sets the object's ipo"}, | 
					
						
							|  |  |  |   {"clearIpo", (PyCFunction)Object_clearIpo, METH_NOARGS, | 
					
						
							|  |  |  | 	"() - Unlink ipo from this object"}, | 
					
						
							| 
									
										
										
										
											2004-06-11 13:15:50 +00:00
										 |  |  |   {"getAllProperties", (PyCFunction)Object_getAllProperties, METH_NOARGS, | 
					
						
							|  |  |  |   "() - Get all the properties from this object"}, | 
					
						
							|  |  |  |   {"addProperty", (PyCFunction)Object_addProperty, METH_VARARGS, | 
					
						
							|  |  |  |   "() - Add a property to this object"}, | 
					
						
							|  |  |  |   {"removeProperty", (PyCFunction)Object_removeProperty, METH_VARARGS, | 
					
						
							|  |  |  |   "() - Remove a property from  this object"}, | 
					
						
							|  |  |  |   {"getProperty", (PyCFunction)Object_getProperty, METH_VARARGS, | 
					
						
							|  |  |  |   "() - Get a property from this object by name"}, | 
					
						
							|  |  |  |    {"removeAllProperties", (PyCFunction)Object_removeAllProperties, METH_NOARGS, | 
					
						
							|  |  |  |   "() - removeAll a properties from this object"}, | 
					
						
							|  |  |  |    {"copyAllPropertiesTo", (PyCFunction)Object_copyAllPropertiesTo, METH_VARARGS, | 
					
						
							|  |  |  |   "() - copy all properties from this object to another object"}, | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 	{"getScriptLinks", (PyCFunction)Object_getScriptLinks, METH_VARARGS, | 
					
						
							|  |  |  | 			"(eventname) - Get a list of this object's scriptlinks (Text names) " | 
					
						
							|  |  |  | 			"of the given type\n" | 
					
						
							|  |  |  | 	"(eventname) - string: FrameChanged or Redraw."}, | 
					
						
							|  |  |  | 	{"addScriptLink", (PyCFunction)Object_addScriptLink, METH_VARARGS, | 
					
						
							|  |  |  | 			"(text, evt) - Add a new object scriptlink.\n" | 
					
						
							|  |  |  | 	"(text) - string: an existing Blender Text name;\n" | 
					
						
							|  |  |  | 	"(evt) string: FrameChanged or Redraw."}, | 
					
						
							|  |  |  | 	{"clearScriptLinks", (PyCFunction)Object_clearScriptLinks, METH_NOARGS, | 
					
						
							|  |  |  | 			"() - Delete all scriptlinks from this object."}, | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  |   {NULL, NULL, 0, NULL} | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* PythonTypeObject callback function prototypes							 */ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static void		 Object_dealloc (BPy_Object *obj); | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject* Object_getAttr (BPy_Object *obj, char *name); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static int		 Object_setAttr (BPy_Object *obj, char *name, PyObject *v); | 
					
						
							|  |  |  | static PyObject* Object_repr	(BPy_Object *obj); | 
					
						
							|  |  |  | static int		 Object_compare (BPy_Object *a, BPy_Object *b); | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Python TypeObject structure definition.									 */ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyTypeObject Object_Type = | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   PyObject_HEAD_INIT(NULL) | 
					
						
							|  |  |  |   0,								/* ob_size */ | 
					
						
							|  |  |  |   "Blender Object",					/* tp_name */ | 
					
						
							|  |  |  |   sizeof (BPy_Object),				/* tp_basicsize */ | 
					
						
							|  |  |  |   0,								/* tp_itemsize */ | 
					
						
							|  |  |  |   /* methods */ | 
					
						
							|  |  |  |   (destructor)Object_dealloc,		/* tp_dealloc */ | 
					
						
							|  |  |  |   0,								/* tp_print */ | 
					
						
							|  |  |  |   (getattrfunc)Object_getAttr,		/* tp_getattr */ | 
					
						
							|  |  |  |   (setattrfunc)Object_setAttr,		/* tp_setattr */ | 
					
						
							|  |  |  |   (cmpfunc)Object_compare,			/* tp_compare */ | 
					
						
							|  |  |  |   (reprfunc)Object_repr,			/* tp_repr */ | 
					
						
							|  |  |  |   0,								/* tp_as_number */ | 
					
						
							|  |  |  |   0,								/* tp_as_sequence */ | 
					
						
							|  |  |  |   0,								/* tp_as_mapping */ | 
					
						
							|  |  |  |   0,								/* tp_as_hash */ | 
					
						
							|  |  |  |   0,0,0,0,0,0, | 
					
						
							|  |  |  |   0,								/* tp_doc */  | 
					
						
							|  |  |  |   0,0,0,0,0,0, | 
					
						
							|  |  |  |   BPy_Object_methods,				/* tp_methods */ | 
					
						
							|  |  |  |   0,								/* tp_members */ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:			  M_Object_New										 */ | 
					
						
							|  |  |  | /* Python equivalent:	  Blender.Object.New								 */ | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  | PyObject *M_Object_New(PyObject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   struct Object * object; | 
					
						
							|  |  |  |   BPy_Object	  * blen_object; | 
					
						
							|  |  |  |   int		type; | 
					
						
							|  |  |  |   char	* str_type; | 
					
						
							|  |  |  |   char	* name = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "s|s", &str_type, &name)) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		EXPP_ReturnPyObjError (PyExc_TypeError, "string expected as argument"); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		return (NULL); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (strcmp (str_type, "Armature") == 0)	  type = OB_ARMATURE; | 
					
						
							|  |  |  |   else if (strcmp (str_type, "Camera") == 0)  type = OB_CAMERA; | 
					
						
							|  |  |  |   else if (strcmp (str_type, "Curve") == 0)   type = OB_CURVE; | 
					
						
							|  |  |  | /*	else if (strcmp (str_type, "Text") == 0)	type = OB_FONT; */ | 
					
						
							|  |  |  | /*	else if (strcmp (str_type, "Ika") == 0)		type = OB_IKA; */ | 
					
						
							|  |  |  |   else if (strcmp (str_type, "Lamp") == 0)	  type = OB_LAMP; | 
					
						
							| 
									
										
										
										
											2003-11-13 04:00:59 +00:00
										 |  |  |   else if (strcmp (str_type, "Lattice") == 0) type = OB_LATTICE; | 
					
						
							| 
									
										
										
										
											2004-06-08 07:27:37 +00:00
										 |  |  | 	else if (strcmp (str_type, "Mball") == 0)	type = OB_MBALL;  | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   else if (strcmp (str_type, "Mesh") == 0)	  type = OB_MESH; | 
					
						
							| 
									
										
										
										
											2004-01-16 01:19:36 +00:00
										 |  |  |   else if (strcmp (str_type, "Surf") == 0)	  type = OB_SURF; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /*	else if (strcmp (str_type, "Wave") == 0)	type = OB_WAVE; */ | 
					
						
							|  |  |  |   else if (strcmp (str_type, "Empty") == 0)   type = OB_EMPTY; | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	  	"Unknown type specified")); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* Create a new object. */ | 
					
						
							|  |  |  |   if (name == NULL) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 	  /* No name is specified, set the name to the type of the object. */ | 
					
						
							|  |  |  | 		name = str_type; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   object = alloc_libblock (&(G.main->object), ID_OB, name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  |   object->id.us = 0; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   object->flag = 0; | 
					
						
							|  |  |  |   object->type = type; | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  |    | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /* transforms */ | 
					
						
							|  |  |  |   QuatOne(object->quat); | 
					
						
							|  |  |  |   QuatOne(object->dquat); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   object->col[3]= 1.0;	  // alpha 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   object->size[0] = object->size[1] = object->size[2] = 1.0; | 
					
						
							|  |  |  |   object->loc[0] = object->loc[1] = object->loc[2] = 0.0; | 
					
						
							|  |  |  |   Mat4One(object->parentinv); | 
					
						
							|  |  |  |   Mat4One(object->obmat); | 
					
						
							|  |  |  |   object->dt = OB_SHADED; // drawtype
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-13 14:50:45 +00:00
										 |  |  |   if (U.flag & USER_MAT_ON_OB) | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   { | 
					
						
							|  |  |  | 		object->colbits = -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   switch (object->type) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 		case OB_CAMERA: /* fall through. */ | 
					
						
							|  |  |  | 		case OB_LAMP: | 
					
						
							|  |  |  | 		  object->trackflag = OB_NEGZ; | 
					
						
							|  |  |  | 		  object->upflag = OB_POSY; | 
					
						
							|  |  |  | 	  	break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 		  object->trackflag = OB_POSY; | 
					
						
							|  |  |  | 	 	 object->upflag = OB_POSZ; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   object->ipoflag = OB_OFFS_OB + OB_OFFS_PARENT; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* duplivert settings */ | 
					
						
							|  |  |  |   object->dupon = 1; | 
					
						
							|  |  |  |   object->dupoff = 0; | 
					
						
							|  |  |  |   object->dupsta = 1; | 
					
						
							|  |  |  |   object->dupend = 100; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* Gameengine defaults*/ | 
					
						
							|  |  |  |   object->mass = 1.0; | 
					
						
							|  |  |  |   object->inertia = 1.0; | 
					
						
							|  |  |  |   object->formfactor = 0.4; | 
					
						
							|  |  |  |   object->damping = 0.04; | 
					
						
							|  |  |  |   object->rdamping = 0.1; | 
					
						
							|  |  |  |   object->anisotropicFriction[0] = 1.0; | 
					
						
							|  |  |  |   object->anisotropicFriction[1] = 1.0; | 
					
						
							|  |  |  |   object->anisotropicFriction[2] = 1.0; | 
					
						
							|  |  |  |   object->gameflag = OB_PROP; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   object->lay = 1; // Layer, by default visible
 | 
					
						
							|  |  |  |   G.totobj++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   object->data = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* Create a Python object from it. */ | 
					
						
							|  |  |  |   blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);  | 
					
						
							|  |  |  |   blen_object->object = object; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ((PyObject*)blen_object); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:			  M_Object_Get										 */ | 
					
						
							|  |  |  | /* Python equivalent:	  Blender.Object.Get								 */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyObject *M_Object_Get(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct Object	* object; | 
					
						
							|  |  |  | 	BPy_Object		* blen_object; | 
					
						
							|  |  |  | 	char			* name = NULL; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyArg_ParseTuple(args, "|s", &name); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (name != NULL) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		object = GetObjectByName (name); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		if (object == NULL) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			/* No object exists with the name specified in the argument name. */ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 			return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 						"Unknown object specified.")); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);  | 
					
						
							|  |  |  | 		blen_object->object = object; | 
					
						
							| 
									
										
										
										
											2003-04-21 20:33:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		return ((PyObject*)blen_object); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* No argument has been given. Return a list of all objects. */ | 
					
						
							|  |  |  | 		PyObject	* obj_list; | 
					
						
							|  |  |  | 		Link		* link; | 
					
						
							|  |  |  | 		int			  index; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		obj_list = PyList_New (BLI_countlist (&(G.main->object))); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		if (obj_list == NULL) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 			return (EXPP_ReturnPyObjError (PyExc_SystemError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"List creation failed.")); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		link = G.main->object.first; | 
					
						
							|  |  |  | 		index = 0; | 
					
						
							|  |  |  | 		while (link) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			object = (Object*)link; | 
					
						
							|  |  |  | 			blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type); | 
					
						
							|  |  |  | 			blen_object->object = object; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			PyList_SetItem (obj_list, index, (PyObject*)blen_object); | 
					
						
							|  |  |  | 			index++; | 
					
						
							|  |  |  | 			link = link->next; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		return (obj_list); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-29 19:57:41 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:			  M_Object_get										 */ | 
					
						
							|  |  |  | /* Python equivalent:	  Blender.Object.get								 */ | 
					
						
							| 
									
										
										
										
											2003-06-29 19:57:41 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyObject *M_Object_get(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyErr_Warn (PyExc_DeprecationWarning, | 
					
						
							|  |  |  | 		"The Object.get() function will be removed in Blender 2.29\n" \ | 
					
						
							|  |  |  | 		"Please update the script to use Object.Get"); | 
					
						
							|  |  |  | 	return (M_Object_Get (self, args)); | 
					
						
							| 
									
										
										
										
											2003-06-29 19:57:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:			  M_Object_GetSelected								 */ | 
					
						
							|  |  |  | /* Python equivalent:	  Blender.Object.getSelected						 */ | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-04 20:18:29 +00:00
										 |  |  | static PyObject *M_Object_GetSelected (PyObject *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	BPy_Object		  * blen_object; | 
					
						
							|  |  |  | 	PyObject		* list; | 
					
						
							|  |  |  | 	Base			* base_iter; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-25 17:42:40 +00:00
										 |  |  |     if (G.vd == NULL) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // No 3d view has been initialized yet, simply return None
 | 
					
						
							|  |  |  |         Py_INCREF (Py_None); | 
					
						
							|  |  |  |         return Py_None; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	list = PyList_New (0); | 
					
						
							|  |  |  | 	if ((G.scene->basact) && | 
					
						
							|  |  |  | 		((G.scene->basact->flag & SELECT) && | 
					
						
							|  |  |  | 		 (G.scene->basact->lay & G.vd->lay))) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* Active object is first in the list. */ | 
					
						
							|  |  |  | 		blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);  | 
					
						
							|  |  |  | 		if (blen_object == NULL) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			Py_DECREF (list); | 
					
						
							|  |  |  | 			Py_INCREF (Py_None); | 
					
						
							|  |  |  | 			return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		blen_object->object = G.scene->basact->object; | 
					
						
							|  |  |  | 		PyList_Append (list, (PyObject*)blen_object); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	base_iter = G.scene->base.first; | 
					
						
							|  |  |  | 	while (base_iter) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (((base_iter->flag & SELECT) && | 
					
						
							|  |  |  | 			 (base_iter->lay & G.vd->lay)) && | 
					
						
							|  |  |  | 			(base_iter != G.scene->basact)) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);  | 
					
						
							|  |  |  | 			if (blen_object == NULL) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				Py_DECREF (list); | 
					
						
							|  |  |  | 				Py_INCREF (Py_None); | 
					
						
							|  |  |  | 				return (Py_None); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			blen_object->object = base_iter->object; | 
					
						
							|  |  |  | 			PyList_Append (list, (PyObject*)blen_object); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		base_iter = base_iter->next; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return (list); | 
					
						
							| 
									
										
										
										
											2003-02-26 19:22:24 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-29 19:57:41 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:			  M_Object_getSelected								 */ | 
					
						
							|  |  |  | /* Python equivalent:	  Blender.Object.getSelected						 */ | 
					
						
							| 
									
										
										
										
											2003-06-29 19:57:41 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyObject *M_Object_getSelected (PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyErr_Warn (PyExc_DeprecationWarning, | 
					
						
							|  |  |  | 				"The Object.getSelected() function will be removed in "\ | 
					
						
							|  |  |  | 				"Blender 2.29\n" \ | 
					
						
							|  |  |  | 				"Please update the script to use Object.GetSelected"); | 
					
						
							|  |  |  | 	return (M_Object_GetSelected (self, args)); | 
					
						
							| 
									
										
										
										
											2003-06-29 19:57:41 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:			  initObject										 */ | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | PyObject *Object_Init (void) | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject	* module; | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Object_Type.ob_type = &PyType_Type; | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	module = Py_InitModule3("Blender.Object", M_Object_methods, M_Object_doc); | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	return (module); | 
					
						
							| 
									
										
										
										
											2003-03-08 18:10:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Python BPy_Object methods:												   */ | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-07-25 19:52:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static PyObject *Object_buildParts (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-10-28 23:23:30 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   void build_particle_system(Object *ob); | 
					
						
							|  |  |  |   struct Object *obj = self->object; | 
					
						
							| 
									
										
										
										
											2003-10-28 23:23:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   build_particle_system(obj); | 
					
						
							| 
									
										
										
										
											2003-07-25 19:52:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   Py_INCREF (Py_None); | 
					
						
							|  |  |  |   return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-07-25 19:52:51 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static PyObject *Object_clearIpo(BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Object *ob = self->object; | 
					
						
							|  |  |  | 	Ipo *ipo = (Ipo *)ob->ipo; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (ipo) { | 
					
						
							|  |  |  | 		ID *id = &ipo->id; | 
					
						
							|  |  |  | 		if (id->us > 0) id->us--; | 
					
						
							|  |  |  | 		ob->ipo = NULL; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		Py_INCREF (Py_True); | 
					
						
							|  |  |  | 		return Py_True; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Py_INCREF (Py_False); /* no ipo found */ | 
					
						
							|  |  |  | 	return Py_False; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static PyObject *Object_clrParent (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int mode=0; | 
					
						
							|  |  |  |   int fast=0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple (args, "|ii", &mode, &fast)) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		  "expected one or two integers as arguments")); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* Remove the link only, the object is still in the scene. */ | 
					
						
							|  |  |  |   self->object->parent = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (mode == 2) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 		/* Keep transform */ | 
					
						
							|  |  |  | 		apply_obmat (self->object); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!fast) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 		sort_baselist (G.scene); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Py_INCREF (Py_None); | 
					
						
							|  |  |  |   return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | static PyObject *Object_clearTrack (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int mode=0; | 
					
						
							|  |  |  |   int fast=0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple (args, "|ii", &mode, &fast)) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 		  "expected one or two integers as arguments")); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* Remove the link only, the object is still in the scene. */ | 
					
						
							|  |  |  |   self->object->track = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (mode) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 		/* Keep transform */ | 
					
						
							|  |  |  | 		apply_obmat (self->object); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!fast) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 		sort_baselist (G.scene); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Py_INCREF (Py_None); | 
					
						
							|  |  |  |   return (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | /* adds object data to a Blender object, if object->data = NULL */ | 
					
						
							|  |  |  | int EXPP_add_obdata(struct Object *object) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   if (object->data != NULL) return -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch(object->type) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 	case OB_ARMATURE: | 
					
						
							|  |  |  | 	/* TODO: Do we need to add something to G? (see the OB_LAMP case) */ | 
					
						
							|  |  |  | 	  object->data = add_armature(); | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  | 	case OB_CAMERA: | 
					
						
							|  |  |  | 	  /* TODO: Do we need to add something to G? (see the OB_LAMP case) */ | 
					
						
							|  |  |  | 	  object->data = add_camera(); | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  | 	case OB_CURVE: | 
					
						
							|  |  |  | 	  object->data = add_curve(OB_CURVE); | 
					
						
							|  |  |  | 	  G.totcurve++; | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  | 	case OB_LAMP: | 
					
						
							|  |  |  | 	  object->data = add_lamp(); | 
					
						
							|  |  |  | 	  G.totlamp++; | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  | 	case OB_MESH: | 
					
						
							|  |  |  | 	  object->data = add_mesh(); | 
					
						
							|  |  |  | 	  G.totmesh++; | 
					
						
							|  |  |  | 	  break; | 
					
						
							| 
									
										
										
										
											2003-11-13 04:00:59 +00:00
										 |  |  | 	case OB_LATTICE: | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  |       object->data = (void *)add_lattice(); | 
					
						
							|  |  |  | 	  object->dt = OB_WIRE; | 
					
						
							| 
									
										
										
										
											2003-11-13 04:00:59 +00:00
										 |  |  | 	  break; | 
					
						
							| 
									
										
										
										
											2004-06-08 07:27:37 +00:00
										 |  |  | 	case OB_MBALL: | 
					
						
							|  |  |  | 	  object->data = add_mball(); | 
					
						
							|  |  |  | 	  break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* TODO the following types will be supported later
 | 
					
						
							|  |  |  | 	case OB_SURF: | 
					
						
							|  |  |  | 	  object->data = add_curve(OB_SURF); | 
					
						
							|  |  |  | 	  G.totcurve++; | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  | 	case OB_FONT: | 
					
						
							|  |  |  | 	  object->data = add_curve(OB_FONT); | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  | 	case OB_IKA: | 
					
						
							|  |  |  | 	  object->data = add_ika(); | 
					
						
							|  |  |  | 	  object->dt = OB_WIRE; | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  | 	case OB_WAVE: | 
					
						
							|  |  |  | 	  object->data = add_wave(); | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  | 	*/ | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	  break; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!object->data) return -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-03 20:24:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static PyObject *Object_getData (BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject  * data_object; | 
					
						
							|  |  |  | 	Object * object = self->object; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* if there's no obdata, try to create it */ | 
					
						
							|  |  |  | 	if (object->data == NULL) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 	  if (EXPP_add_obdata(object) != 0) | 
					
						
							|  |  |  | 	  { /* couldn't create obdata */ | 
					
						
							|  |  |  | 		Py_INCREF (Py_None); | 
					
						
							|  |  |  | 		return (Py_None); | 
					
						
							|  |  |  | 	  } | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	data_object = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch (object->type) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		case OB_ARMATURE: | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			data_object = Armature_CreatePyObject (object->data); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case OB_CAMERA: | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			data_object = Camera_CreatePyObject (object->data); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case OB_CURVE: | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			data_object = Curve_CreatePyObject (object->data); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case ID_IM: | 
					
						
							|  |  |  | 			data_object = Image_CreatePyObject (object->data); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case ID_IP: | 
					
						
							|  |  |  | 			data_object = Ipo_CreatePyObject (object->data); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case OB_LAMP: | 
					
						
							|  |  |  | 			data_object = Lamp_CreatePyObject (object->data); | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  | 		case OB_LATTICE: | 
					
						
							| 
									
										
										
										
											2003-11-13 04:00:59 +00:00
										 |  |  | 			data_object = Lattice_CreatePyObject (object->data); | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case ID_MA: | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case OB_MESH: | 
					
						
							|  |  |  | 			data_object = NMesh_CreatePyObject (object->data, object); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case ID_OB: | 
					
						
							|  |  |  | 			data_object = Object_CreatePyObject (object->data); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case ID_SCE: | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case ID_TXT: | 
					
						
							|  |  |  | 			data_object = Text_CreatePyObject (object->data); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case ID_WO: | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (data_object == NULL) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		Py_INCREF (Py_None); | 
					
						
							|  |  |  | 		return (Py_None); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return (data_object); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getDeltaLocation (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject *attr = Py_BuildValue ("fff", | 
					
						
							|  |  |  | 									self->object->dloc[0], | 
					
						
							|  |  |  | 									self->object->dloc[1], | 
					
						
							|  |  |  | 									self->object->dloc[2]); | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (attr) return (attr); | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"couldn't get Object.dloc attributes")); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getDrawMode (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject *attr = Py_BuildValue ("b", self->object->dtx); | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (attr) return (attr); | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"couldn't get Object.drawMode attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-19 06:57:41 +00:00
										 |  |  | static PyObject *Object_getAction (BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2004-04-23 13:11:48 +00:00
										 |  |  | 	/*BPy_Action *py_action = NULL;*/ | 
					
						
							| 
									
										
										
										
											2004-04-19 06:57:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if(!self->object->action){ | 
					
						
							|  |  |  | 		Py_INCREF (Py_None); | 
					
						
							|  |  |  | 		return (Py_None); | 
					
						
							|  |  |  | 	}else{ | 
					
						
							|  |  |  | 		return Action_CreatePyObject (self->object->action); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_isSelected (BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Base *base; | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | 	base= FIRSTBASE; | 
					
						
							|  |  |  | 	while (base) { | 
					
						
							|  |  |  | 		if (base->object == self->object) { | 
					
						
							|  |  |  | 			if (base->flag & SELECT) { | 
					
						
							|  |  |  | 				Py_INCREF (Py_True); | 
					
						
							|  |  |  | 				return Py_True; | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				Py_INCREF (Py_False); | 
					
						
							|  |  |  | 				return Py_False; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		base= base->next; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							|  |  |  | 					 "Internal error: could not find objects selection state")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getDrawType (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject *attr = Py_BuildValue ("b", self->object->dt); | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (attr) return (attr); | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"couldn't get Object.drawType attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getEuler (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2004-03-03 00:45:10 +00:00
										 |  |  | {   | 
					
						
							|  |  |  | 	EulerObject *eul; | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-03 00:45:10 +00:00
										 |  |  | 	eul = (EulerObject*)newEulerObject(NULL); | 
					
						
							|  |  |  | 	eul->eul[0] = self->object->rot[0]; | 
					
						
							|  |  |  | 	eul->eul[1] = self->object->rot[1]; | 
					
						
							|  |  |  | 	eul->eul[2] = self->object->rot[2]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return (PyObject*)eul;  | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getInverseMatrix (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-02-29 13:20:34 +00:00
										 |  |  | 	MatrixObject *inverse = (MatrixObject *)newMatrixObject(NULL, 4, 4); | 
					
						
							|  |  |  | 	Mat4Invert (*inverse->matrix, self->object->obmat); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return ((PyObject *)inverse); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_getIpo(BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   struct Ipo *ipo = self->object->ipo; | 
					
						
							| 
									
										
										
										
											2003-06-22 20:14:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   if (!ipo) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		Py_INCREF (Py_None); | 
					
						
							|  |  |  | 		return Py_None; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return Ipo_CreatePyObject (ipo); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getLocation (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject *attr = Py_BuildValue ("fff", | 
					
						
							|  |  |  | 									self->object->loc[0], | 
					
						
							|  |  |  | 									self->object->loc[1], | 
					
						
							|  |  |  | 									self->object->loc[2]); | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (attr) return (attr); | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"couldn't get Object.loc attributes")); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | static PyObject *Object_getMaterials (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | 	int all = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "|i", &all)){ | 
					
						
							|  |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 			"expected an int or nothing")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	return (EXPP_PyList_fromMaterialList (self->object->mat, | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | 										  self->object->totcol, all)); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  | static PyObject *Object_getMatrix (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  | 	PyObject  *matrix; | 
					
						
							|  |  |  | 	char *space = "localspace";	 /* default to local */ | 
					
						
							| 
									
										
										
										
											2003-06-22 20:14:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "|s", &space)){ | 
					
						
							|  |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 			"expected a string or nothing")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	//new matrix
 | 
					
						
							| 
									
										
										
										
											2004-05-15 03:09:27 +00:00
										 |  |  | 	matrix = newMatrixObject(NULL, 4, 4); | 
					
						
							| 
									
										
										
										
											2003-06-22 20:14:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  | 	if (BLI_streq(space, "worldspace")){  	/* Worldspace matrix */ | 
					
						
							|  |  |  | 		where_is_object(self->object); | 
					
						
							|  |  |  | 		Mat4CpyMat4(*((MatrixObject*)matrix)->matrix, self->object->obmat); | 
					
						
							|  |  |  | 	} else if (BLI_streq(space, "localspace")) { /* Localspace matrix*/ | 
					
						
							|  |  |  | 		object_to_mat4(self->object, *((MatrixObject*)matrix)->matrix); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		return (EXPP_ReturnPyObjError (PyExc_RuntimeError,  | 
					
						
							| 
									
										
										
										
											2004-08-14 09:20:38 +00:00
										 |  |  | 			"correct spaces are 'worldspace' and 'localspace', none defaults to 'localspace'")); | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-05-15 03:09:27 +00:00
										 |  |  | 	return matrix; | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | static PyObject *Object_getName (BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject *attr = Py_BuildValue ("s", self->object->id.name+2); | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (attr) return (attr); | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"couldn't get the name of the Object")); | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getParent (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject *attr; | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (self->object->parent == NULL) | 
					
						
							|  |  |  | 		return EXPP_incr_ret (Py_None); | 
					
						
							| 
									
										
										
										
											2003-07-30 18:47:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	attr = Object_CreatePyObject (self->object->parent); | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (attr) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return (attr); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"couldn't get Object.parent attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-23 02:59:54 +00:00
										 |  |  | static PyObject *Object_getSize (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = Py_BuildValue ("fff", | 
					
						
							|  |  |  | 									self->object->size[0], | 
					
						
							|  |  |  | 									self->object->size[1], | 
					
						
							|  |  |  | 									self->object->size[2]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (attr) return (attr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2004-01-23 02:59:54 +00:00
										 |  |  | 			"couldn't get Object.size attributes")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-02 18:38:38 +00:00
										 |  |  | static PyObject *Object_getTimeOffset (BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = Py_BuildValue ("f", self->object->sf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (attr) return (attr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2004-04-02 18:38:38 +00:00
										 |  |  | 			"couldn't get Object.sf attributes")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getTracked (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject	*attr; | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (self->object->track == NULL) | 
					
						
							|  |  |  | 		return EXPP_incr_ret (Py_None); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	attr = Object_CreatePyObject (self->object->track); | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (attr) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return (attr); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-05-21 19:54:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"couldn't get Object.track attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_getType (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	switch (self->object->type) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		case OB_ARMATURE:	return (Py_BuildValue ("s", "Armature")); | 
					
						
							|  |  |  | 		case OB_CAMERA:		return (Py_BuildValue ("s", "Camera")); | 
					
						
							|  |  |  | 		case OB_CURVE:		return (Py_BuildValue ("s", "Curve")); | 
					
						
							|  |  |  | 		case OB_EMPTY:		return (Py_BuildValue ("s", "Empty")); | 
					
						
							|  |  |  | 		case OB_FONT:		return (Py_BuildValue ("s", "Text")); | 
					
						
							|  |  |  | 		case OB_IKA:		return (Py_BuildValue ("s", "Ika")); | 
					
						
							|  |  |  | 		case OB_LAMP:		return (Py_BuildValue ("s", "Lamp")); | 
					
						
							|  |  |  | 		case OB_LATTICE:	return (Py_BuildValue ("s", "Lattice")); | 
					
						
							|  |  |  | 		case OB_MBALL:		return (Py_BuildValue ("s", "MBall")); | 
					
						
							|  |  |  | 		case OB_MESH:		return (Py_BuildValue ("s", "Mesh")); | 
					
						
							|  |  |  | 		case OB_SURF:		return (Py_BuildValue ("s", "Surf")); | 
					
						
							|  |  |  | 		case OB_WAVE:		return (Py_BuildValue ("s", "Wave")); | 
					
						
							|  |  |  | 		default:			return (Py_BuildValue ("s", "unknown")); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | static PyObject *Object_getBoundBox (BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   int i; | 
					
						
							|  |  |  |   float *vec = NULL; | 
					
						
							|  |  |  |   PyObject *vector, *bbox; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!self->object->data) | 
					
						
							|  |  |  | 	return EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 	  "This object isn't linked to any object data (mesh, curve, etc) yet"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  |   if (!self->object->bb) {  /* if no ob bbox, we look in obdata */ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Mesh *me; | 
					
						
							|  |  |  | 	Curve *curve; | 
					
						
							|  |  |  | 	switch (self->object->type) { | 
					
						
							|  |  |  | 	  case OB_MESH: | 
					
						
							|  |  |  | 		me = self->object->data; | 
					
						
							|  |  |  | 		if (!me->bb) tex_space_mesh(me); | 
					
						
							|  |  |  | 		vec = (float *)me->bb->vec; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	  case OB_CURVE: | 
					
						
							|  |  |  | 	  case OB_FONT: | 
					
						
							|  |  |  | 	  case OB_SURF: | 
					
						
							|  |  |  | 		curve = self->object->data; | 
					
						
							|  |  |  | 		if (!curve->bb) tex_space_curve(curve); | 
					
						
							|  |  |  | 		vec = (float *)curve->bb->vec; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	  default: | 
					
						
							|  |  |  | 		Py_INCREF (Py_None); | 
					
						
							|  |  |  | 		return Py_None; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	{      /* transform our obdata bbox by the obmat.
 | 
					
						
							|  |  |  | 		  the obmat is 4x4 homogeneous coords matrix. | 
					
						
							|  |  |  | 	          each bbox coord is xyz, so we make it homogenous | 
					
						
							|  |  |  | 		  by padding it with w=1.0 and doing the matrix mult. | 
					
						
							|  |  |  | 		  afterwards we divide by w to get back to xyz. | 
					
						
							|  |  |  | 	       */ | 
					
						
							|  |  |  | 		/* printmatrix4( "obmat", self->object->obmat); */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		float tmpvec[4];  /* tmp vector for homogenous coords math */ | 
					
						
							|  |  |  | 		int i; | 
					
						
							|  |  |  | 		float *from; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		bbox = PyList_New(8); | 
					
						
							|  |  |  | 		if (!bbox) | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError (PyExc_MemoryError, | 
					
						
							|  |  |  | 						      "couldn't create pylist"); | 
					
						
							|  |  |  | 		for( i = 0, from = vec; | 
					
						
							|  |  |  | 		     i < 8; | 
					
						
							|  |  |  | 		     i++, from += 3 ) { | 
					
						
							|  |  |  | 			memcpy( tmpvec, from, 3*sizeof(float)); | 
					
						
							|  |  |  | 			tmpvec[3]=1.0f;  /* set w coord */ | 
					
						
							|  |  |  | 			Mat4MulVec4fl(  self->object->obmat, tmpvec ); | 
					
						
							|  |  |  | 			/* divide x,y,z by w */ | 
					
						
							|  |  |  | 			tmpvec[0] /= tmpvec[3]; | 
					
						
							|  |  |  | 			tmpvec[1] /= tmpvec[3]; | 
					
						
							|  |  |  | 			tmpvec[2] /= tmpvec[3]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if 0
 | 
					
						
							|  |  |  | 			{ /* debug print stuff */ | 
					
						
							|  |  |  | 				int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				printf("\nobj bbox transformed\n"); | 
					
						
							|  |  |  | 				for( i=0; i<4; ++i) | 
					
						
							|  |  |  | 					printf( "%f ", tmpvec[i]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				printf("\n"); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 			/* because our bounding box is calculated and
 | 
					
						
							|  |  |  | 			   does not have its own memory, | 
					
						
							|  |  |  | 			   we must create vectors that allocate space */ | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 			vector = newVectorObject( NULL, 3); | 
					
						
							|  |  |  | 			memcpy( ((VectorObject*)vector)->vec,  | 
					
						
							|  |  |  | 				tmpvec,  | 
					
						
							|  |  |  | 				3*sizeof(float)); | 
					
						
							|  |  |  | 			PyList_SET_ITEM(bbox, i, vector); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  |   else{  /* the ob bbox exists */ | 
					
						
							|  |  |  |       vec = (float *)self->object->bb->vec; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  |       if (!vec) | 
					
						
							|  |  |  | 	    return EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							|  |  |  | 					  "couldn't retrieve bounding box data"); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  |       bbox = PyList_New(8); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  |       if (!bbox) | 
					
						
							|  |  |  | 	    return EXPP_ReturnPyObjError (PyExc_MemoryError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		  "couldn't create pylist"); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  |       /* create vectors referencing object bounding box coords */ | 
					
						
							|  |  |  |       for (i = 0; i < 8; i++) { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	vector = newVectorObject(vec, 3); | 
					
						
							|  |  |  | 	PyList_SET_ITEM(bbox, i, vector); | 
					
						
							|  |  |  | 	vec += 3; | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   return bbox; | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-15 23:10:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | static PyObject *Object_makeDisplayList (BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   Object *ob = self->object; | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   if (ob->type == OB_FONT) text_to_curve(ob, 0); | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   makeDispList(ob); | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   Py_INCREF (Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											2003-09-20 03:40:16 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_link (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject	* py_data; | 
					
						
							|  |  |  | 	ID			* id; | 
					
						
							|  |  |  | 	ID			* oldid; | 
					
						
							|  |  |  | 	int			  obj_id; | 
					
						
							|  |  |  | 	void		* data = NULL; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (!PyArg_ParseTuple (args, "O", &py_data)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"expected an object as argument")); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-04-04 08:34:43 +00:00
										 |  |  | 	if (Armature_CheckPyObject (py_data)) | 
					
						
							|  |  |  | 		data = (void *)Armature_FromPyObject (py_data); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (Camera_CheckPyObject (py_data)) | 
					
						
							|  |  |  | 		data = (void *)Camera_FromPyObject (py_data); | 
					
						
							|  |  |  | 	if (Lamp_CheckPyObject (py_data)) | 
					
						
							|  |  |  | 		data = (void *)Lamp_FromPyObject (py_data); | 
					
						
							|  |  |  | 	if (Curve_CheckPyObject (py_data)) | 
					
						
							|  |  |  | 		data = (void *)Curve_FromPyObject (py_data); | 
					
						
							|  |  |  | 	if (NMesh_CheckPyObject (py_data)) | 
					
						
							|  |  |  | 		data = (void *)Mesh_FromPyObject (py_data, self->object); | 
					
						
							| 
									
										
										
										
											2003-11-13 04:00:59 +00:00
										 |  |  | 	if (Lattice_CheckPyObject (py_data)) | 
					
						
							|  |  |  | 		data = (void *)Lattice_FromPyObject (py_data); | 
					
						
							| 
									
										
										
										
											2004-06-08 07:27:37 +00:00
										 |  |  | 	if (Metaball_CheckPyObject (py_data)) | 
					
						
							|  |  |  | 		data = (void *)Metaball_FromPyObject (py_data); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* have we set data to something good? */ | 
					
						
							|  |  |  | 	if( !data ) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"link argument type is not supported ")); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	oldid = (ID*) self->object->data; | 
					
						
							|  |  |  | 	id = (ID*) data; | 
					
						
							|  |  |  | 	obj_id = MAKE_ID2 (id->name[0], id->name[1]); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	switch (obj_id) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-04-04 08:34:43 +00:00
										 |  |  | 		case ID_AR: | 
					
						
							|  |  |  | 			if (self->object->type != OB_ARMATURE) | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 				return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2004-04-04 08:34:43 +00:00
										 |  |  | 					"The 'link' object is incompatible with the base object")); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		case ID_CA: | 
					
						
							|  |  |  | 			if (self->object->type != OB_CAMERA) | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 				return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"The 'link' object is incompatible with the base object")); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_LA: | 
					
						
							|  |  |  | 			if (self->object->type != OB_LAMP) | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 				return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"The 'link' object is incompatible with the base object")); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_ME: | 
					
						
							|  |  |  | 			if (self->object->type != OB_MESH) | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 				return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"The 'link' object is incompatible with the base object")); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_CU: | 
					
						
							|  |  |  | 			if (self->object->type != OB_CURVE) | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 				return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"The 'link' object is incompatible with the base object")); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-11-13 04:00:59 +00:00
										 |  |  | 		case ID_LT: | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  | 			if (self->object->type != OB_LATTICE) | 
					
						
							|  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  | 							"The 'link' object is incompatible with the base object")); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2003-11-13 04:00:59 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2004-06-08 07:27:37 +00:00
										 |  |  | 		case ID_MB: | 
					
						
							|  |  |  | 			if (self->object->type != OB_MBALL) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 							"The 'link' object is incompatible with the base object")); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		default: | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 			return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"Linking this object type is not supported")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	self->object->data = data; | 
					
						
							| 
									
										
										
										
											2004-01-16 23:40:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if ( self->object->type == OB_MESH) | 
					
						
							| 
									
										
										
										
											2004-01-15 12:55:41 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-01-16 23:40:14 +00:00
										 |  |  | 		self->object->totcol = 0; | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | 		EXPP_synchronizeMaterialLists(self->object); | 
					
						
							| 
									
										
										
										
											2004-01-15 12:55:41 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-01-16 23:40:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	id_us_plus (id); | 
					
						
							|  |  |  | 	if (oldid) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (oldid->us > 0) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			oldid->us--; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		else | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 			return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"old object reference count below 0")); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-11-08 02:19:09 +00:00
										 |  |  | 	return EXPP_incr_ret (Py_None); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_makeParent (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject	* list; | 
					
						
							|  |  |  | 	PyObject	* py_child; | 
					
						
							| 
									
										
										
										
											2003-11-13 17:24:47 +00:00
										 |  |  | 	//BPy_Object	  * py_obj_child; unused
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Object		* child; | 
					
						
							|  |  |  | 	Object		* parent; | 
					
						
							|  |  |  | 	int			  noninverse = 0; | 
					
						
							|  |  |  | 	int			  fast = 0; | 
					
						
							|  |  |  | 	int			  i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Check if the arguments passed to makeParent are valid. */ | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple (args, "O|ii", &list, &noninverse, &fast)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"expected a list of objects and one or two integers as arguments")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!PySequence_Check (list)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"expected a list of objects")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Check if the PyObject passed in list is a Blender object. */ | 
					
						
							|  |  |  | 	for (i=0 ; i<PySequence_Length (list) ; i++) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		child = NULL; | 
					
						
							|  |  |  | 		py_child = PySequence_GetItem (list, i); | 
					
						
							|  |  |  | 		if (Object_CheckPyObject (py_child)) | 
					
						
							|  |  |  | 			child = (Object*) Object_FromPyObject (py_child); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (child == NULL) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 			return (EXPP_ReturnPyObjError (PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"Object Type expected")); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		parent = (Object*)self->object; | 
					
						
							|  |  |  | 		if (test_parent_loop (parent, child)) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 			return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"parenting loop detected - parenting failed")); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		child->partype = PAROBJECT; | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  | 		child->parent = parent; | 
					
						
							|  |  |  | 		//py_obj_child = (BPy_Object *) py_child;
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		if (noninverse == 1) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			/* Parent inverse = unity */ | 
					
						
							|  |  |  | 			child->loc[0] = 0.0; | 
					
						
							|  |  |  | 			child->loc[1] = 0.0; | 
					
						
							|  |  |  | 			child->loc[2] = 0.0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			what_does_parent (child); | 
					
						
							|  |  |  | 			Mat4Invert (child->parentinv, parent->obmat); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		if (!fast) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			sort_baselist (G.scene); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-11-11 05:37:28 +00:00
										 |  |  | 		// We don't need the child object anymore.
 | 
					
						
							|  |  |  | 		//Py_DECREF ((PyObject *) child);
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-11-08 02:19:09 +00:00
										 |  |  | 	return EXPP_incr_ret (Py_None); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_materialUsage (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 	return (EXPP_ReturnPyObjError (PyExc_NotImplementedError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			"materialUsage: not yet implemented")); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_setDeltaLocation (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	float	dloc1; | 
					
						
							|  |  |  | 	float	dloc2; | 
					
						
							|  |  |  | 	float	dloc3; | 
					
						
							|  |  |  | 	int		status; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (PyObject_Length (args) == 3) | 
					
						
							|  |  |  | 		status = PyArg_ParseTuple (args, "fff", &dloc1, &dloc2, &dloc3); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		status = PyArg_ParseTuple (args, "(fff)", &dloc1, &dloc2, &dloc3); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (!status) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 				"expected list argument of 3 floats"); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	self->object->dloc[0] = dloc1; | 
					
						
							|  |  |  | 	self->object->dloc[1] = dloc2; | 
					
						
							|  |  |  | 	self->object->dloc[2] = dloc3; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_setDrawMode (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-01-25 17:58:24 +00:00
										 |  |  | 	char	dtx; | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-25 17:58:24 +00:00
										 |  |  | 	if (!PyArg_ParseTuple (args, "b", &dtx)) | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"expected an integer as argument")); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-01-25 17:58:24 +00:00
										 |  |  | 	self->object->dtx = dtx; | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_setDrawType (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | {  | 
					
						
							| 
									
										
										
										
											2004-01-25 17:58:24 +00:00
										 |  |  | 	char	dt; | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-25 17:58:24 +00:00
										 |  |  | 	if (!PyArg_ParseTuple (args, "b", &dt)) | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"expected an integer as argument")); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-01-25 17:58:24 +00:00
										 |  |  | 	self->object->dt = dt; | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_setEuler (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	float	rot1; | 
					
						
							|  |  |  | 	float	rot2; | 
					
						
							|  |  |  | 	float	rot3; | 
					
						
							| 
									
										
										
										
											2004-05-12 08:06:15 +00:00
										 |  |  | 	int	status = 0; /* failure */ | 
					
						
							| 
									
										
										
										
											2004-03-03 00:45:10 +00:00
										 |  |  | 	PyObject* ob; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-12 08:06:15 +00:00
										 |  |  | 	/* 
 | 
					
						
							|  |  |  | 	   args is either a tuple/list of floats or an euler. | 
					
						
							|  |  |  | 	   for backward compatibility, we also accept 3 floats. | 
					
						
							|  |  |  | 	*/ | 
					
						
							|  |  |  | 	    | 
					
						
							|  |  |  | 	/* do we have 3 floats? */ | 
					
						
							|  |  |  | 	if (PyObject_Length (args) == 3) { | 
					
						
							|  |  |  | 		status = PyArg_ParseTuple (args, "fff", &rot1, &rot2, &rot3); | 
					
						
							|  |  |  |  	} | 
					
						
							|  |  |  | 	else{ 	//test to see if it's a list or a euler
 | 
					
						
							|  |  |  | 		if ( PyArg_ParseTuple (args, "O", &ob)){ | 
					
						
							|  |  |  | 			if(EulerObject_Check(ob)){ | 
					
						
							|  |  |  | 				rot1 = ((EulerObject*)ob)->eul[0]; | 
					
						
							|  |  |  | 				rot2 = ((EulerObject*)ob)->eul[1]; | 
					
						
							|  |  |  | 				rot3 = ((EulerObject*)ob)->eul[2]; | 
					
						
							|  |  |  | 				status = 1; /* success! */ | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else if(PySequence_Check(ob )) | 
					
						
							|  |  |  | 				status = PyArg_ParseTuple (args, "(fff)",  | 
					
						
							|  |  |  | 							   &rot1, &rot2, &rot3); | 
					
						
							|  |  |  | 			else{  /* not an euler or tuple */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				/* python C api doc says don't decref this */ | 
					
						
							|  |  |  | 				/*Py_DECREF (ob); */ | 
					
						
							|  |  |  | 				 | 
					
						
							|  |  |  | 				status = 0; /* false */ | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else{  /* arg parsing failed */ | 
					
						
							|  |  |  | 			status = 0; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2004-03-03 00:45:10 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-05-12 08:06:15 +00:00
										 |  |  | 		 | 
					
						
							|  |  |  | 	if( !status) /* parsing args failed */ | 
					
						
							|  |  |  | 		return (  EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 						 "expected euler or list/tuple of 3 floats ")); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	self->object->rot[0] = rot1; | 
					
						
							|  |  |  | 	self->object->rot[1] = rot2; | 
					
						
							|  |  |  | 	self->object->rot[2] = rot3; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-05-12 08:06:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-03 00:45:10 +00:00
										 |  |  | static PyObject *Object_setMatrix (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	MatrixObject* mat; | 
					
						
							|  |  |  | 	int x,y; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O!", &matrix_Type, &mat)) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError  | 
					
						
							|  |  |  | 		   (PyExc_TypeError, "expected matrix object as argument"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for(x = 0; x < 4; x++){ | 
					
						
							|  |  |  | 		for(y = 0; y < 4; y++){ | 
					
						
							|  |  |  | 			self->object->obmat[x][y] = mat->matrix[x][y]; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	apply_obmat(self->object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | static PyObject *Object_setIpo(BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *pyipo = 0; | 
					
						
							|  |  |  | 	Ipo *ipo = NULL; | 
					
						
							|  |  |  | 	Ipo *oldipo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O!", &Ipo_Type, &pyipo)) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError (PyExc_TypeError, "expected Ipo as argument"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ipo = Ipo_FromPyObject(pyipo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!ipo) return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ipo->blocktype != ID_OB) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError (PyExc_TypeError, | 
					
						
							|  |  |  | 			"this ipo is not an object ipo"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	oldipo = self->object->ipo; | 
					
						
							|  |  |  | 	if (oldipo) { | 
					
						
							|  |  |  | 		ID *id = &oldipo->id; | 
					
						
							|  |  |  | 		if (id->us > 0) id->us--; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	((ID *)&ipo->id)->us++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	self->object->ipo = ipo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_setLocation (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	float	loc1; | 
					
						
							|  |  |  | 	float	loc2; | 
					
						
							|  |  |  | 	float	loc3; | 
					
						
							|  |  |  | 	int		status; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (PyObject_Length (args) == 3) | 
					
						
							|  |  |  | 		status = PyArg_ParseTuple (args, "fff", &loc1, &loc2, &loc3); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		status = PyArg_ParseTuple (args, "(fff)", &loc1, &loc2, &loc3); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (!status) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 				"expected list argument of 3 floats"); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	self->object->loc[0] = loc1; | 
					
						
							|  |  |  | 	self->object->loc[1] = loc2; | 
					
						
							|  |  |  | 	self->object->loc[2] = loc3; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject	 * list; | 
					
						
							|  |  |  | 	int			   len; | 
					
						
							|  |  |  | 	int			   i; | 
					
						
							|  |  |  | 	Material	** matlist; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple (args, "O", &list)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"expected a list of materials as argument")); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	len = PySequence_Length (list); | 
					
						
							|  |  |  | 	if (len > 0) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		matlist = EXPP_newMaterialList_fromPyList (list); | 
					
						
							|  |  |  | 		if (!matlist) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 			return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"material list must be a list of valid materials!")); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		if ((len < 0) || (len > MAXMAT)) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 			return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2004-07-21 03:19:52 +00:00
										 |  |  | 				"material list should have at least 1, at most 16 entries")); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		if (self->object->mat) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2004-07-21 03:19:52 +00:00
										 |  |  | 			EXPP_releaseMaterialList (self->object->mat, self->object->totcol); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		/* Increase the user count on all materials */ | 
					
						
							|  |  |  | 		for (i=0 ; i<len ; i++) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2004-07-21 03:19:52 +00:00
										 |  |  | 			if (matlist[i]) id_us_plus ((ID *) matlist[i]); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		self->object->mat = matlist; | 
					
						
							|  |  |  | 		self->object->totcol = len; | 
					
						
							| 
									
										
										
										
											2004-07-21 03:19:52 +00:00
										 |  |  | 		self->object->actcol = len; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		switch (self->object->type) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			case OB_CURVE:	/* fall through */ | 
					
						
							|  |  |  | 			case OB_FONT:	/* fall through */ | 
					
						
							|  |  |  | 			case OB_MESH:	/* fall through */ | 
					
						
							|  |  |  | 			case OB_MBALL:	/* fall through */ | 
					
						
							|  |  |  | 			case OB_SURF: | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | 				EXPP_synchronizeMaterialLists (self->object); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			default: | 
					
						
							|  |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-11-08 02:19:09 +00:00
										 |  |  | 	return EXPP_incr_ret (Py_None); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | static PyObject *Object_setName (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	char  * name; | 
					
						
							|  |  |  | 	char	buf[21]; | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (!PyArg_ParseTuple (args, "s", &name)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"expected a String as argument")); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyOS_snprintf(buf, sizeof(buf), "%s", name); | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	rename_id(&self->object->id, buf); | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-23 02:59:54 +00:00
										 |  |  | 	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_setSize (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float	sizex; | 
					
						
							|  |  |  | 	float	sizey; | 
					
						
							|  |  |  | 	float	sizez; | 
					
						
							|  |  |  | 	int		status; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (PyObject_Length (args) == 3) | 
					
						
							|  |  |  | 		status = PyArg_ParseTuple (args, "fff", &sizex, &sizey, &sizez); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		status = PyArg_ParseTuple (args, "(fff)", &sizex, &sizey, &sizez); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!status) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 				"expected list argument of 3 floats"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	self->object->size[0] = sizex; | 
					
						
							|  |  |  | 	self->object->size[1] = sizey; | 
					
						
							|  |  |  | 	self->object->size[2] = sizez; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	Py_INCREF (Py_None); | 
					
						
							| 
									
										
										
										
											2004-04-02 18:38:38 +00:00
										 |  |  | 	return (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float newTimeOffset; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple (args, "f", &newTimeOffset)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2004-04-02 18:38:38 +00:00
										 |  |  | 				"expected a float as argument")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	self->object->sf=newTimeOffset; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Py_INCREF (Py_None); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-06-28 15:10:23 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | static PyObject *Object_makeTrack (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   BPy_Object *tracked = NULL; | 
					
						
							|  |  |  | 	Object *ob = self->object; | 
					
						
							|  |  |  | 	int fast = 0; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple (args, "O!|i", &Object_Type, &tracked, &fast)) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError (PyExc_TypeError, | 
					
						
							|  |  |  | 			"expected an object and optionally also an int as arguments."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ob->track = tracked->object; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!fast) sort_baselist(G.scene); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return EXPP_incr_ret(Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	BPy_Object		* object; | 
					
						
							|  |  |  | 	ID				* id; | 
					
						
							|  |  |  | 	ID				* oldid; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (!PyArg_ParseTuple (args, "O", &object)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError (PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"expected an object argument"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!Object_CheckPyObject ((PyObject*)object)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError (PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | 				"first argument is not of type 'Object'"); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (self->object->type != object->object->type) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError (PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 				"objects are not of same data type"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	switch (self->object->type) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		case OB_MESH: | 
					
						
							|  |  |  | 		case OB_LAMP: | 
					
						
							|  |  |  | 		case OB_CAMERA: /* we can probably add the other types, too */ | 
					
						
							|  |  |  | 		case OB_ARMATURE: | 
					
						
							|  |  |  | 		case OB_CURVE: | 
					
						
							| 
									
										
										
										
											2004-01-16 01:19:36 +00:00
										 |  |  | 		case OB_SURF: | 
					
						
							| 
									
										
										
										
											2003-11-13 04:00:59 +00:00
										 |  |  | 		case OB_LATTICE: | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			oldid = (ID*) self->object->data; | 
					
						
							|  |  |  | 			id = (ID*) object->object->data; | 
					
						
							|  |  |  | 			self->object->data = object->object->data; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-01-16 01:19:36 +00:00
										 |  |  | 			if ( self->object->type == OB_MESH && id ){ | 
					
						
							| 
									
										
										
										
											2004-01-16 23:40:14 +00:00
										 |  |  | 				self->object->totcol = 0; | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | 				EXPP_synchronizeMaterialLists(self->object); | 
					
						
							| 
									
										
										
										
											2004-01-15 12:55:41 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2004-07-20 08:16:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			id_us_plus (id); | 
					
						
							|  |  |  | 			if (oldid) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				if (oldid->us > 0) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					oldid->us--; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 							"old object reference count below 0")); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			Py_INCREF (Py_None); | 
					
						
							|  |  |  | 			return (Py_None); | 
					
						
							|  |  |  | 		default: | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 			return EXPP_ReturnPyObjError (PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"type not supported"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_Select (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Base *base; | 
					
						
							|  |  |  | 	int sel; | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | 	base= FIRSTBASE; | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple (args, "i", &sel)) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError  | 
					
						
							|  |  |  | 			(PyExc_TypeError, "expected an integer, 0 or 1"); | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  | 	while (base) { | 
					
						
							|  |  |  | 		if (base->object == self->object){ | 
					
						
							|  |  |  | 			if (sel == 1){ | 
					
						
							|  |  |  | 				base->flag |= SELECT; | 
					
						
							|  |  |  | 				self->object->flag= base->flag; | 
					
						
							| 
									
										
										
										
											2004-06-04 07:52:06 +00:00
										 |  |  | 				set_active_base( base ); | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  | 			} else {  | 
					
						
							|  |  |  | 				base->flag &= ~SELECT; | 
					
						
							|  |  |  | 				self->object->flag= base->flag; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		base= base->next; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | 	countall();   | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | 	Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	return (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-11 13:15:50 +00:00
										 |  |  | static PyObject *Object_getAllProperties(BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *prop_list; | 
					
						
							|  |  |  | 	bProperty *prop= NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	prop_list = PyList_New(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	prop = self->object->prop.first; | 
					
						
							|  |  |  | 	while(prop){ | 
					
						
							|  |  |  | 		PyList_Append(prop_list, Property_CreatePyObject(prop)); | 
					
						
							|  |  |  | 		prop = prop->next; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return prop_list; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_getProperty(BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *prop_name = NULL; | 
					
						
							|  |  |  | 	bProperty *prop= NULL; | 
					
						
							|  |  |  | 	PyObject *py_prop = Py_None; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(!PyArg_ParseTuple (args, "s", &prop_name)){ | 
					
						
							|  |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError,	 | 
					
						
							|  |  |  | 			"expected a string")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	prop = get_property(self->object, prop_name); | 
					
						
							|  |  |  | 	if(prop){ | 
					
						
							|  |  |  | 		py_prop = Property_CreatePyObject(prop); | 
					
						
							|  |  |  | 	}else{ | 
					
						
							|  |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError,	 | 
					
						
							|  |  |  | 			"couldn't find the property....")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return py_prop; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_addProperty(BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	bProperty *prop = NULL; | 
					
						
							|  |  |  | 	char *prop_name = NULL; | 
					
						
							|  |  |  | 	PyObject *prop_data = Py_None; | 
					
						
							|  |  |  | 	char *prop_type = NULL; | 
					
						
							|  |  |  | 	short type = -1; | 
					
						
							|  |  |  | 	BPy_Property *py_prop = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (PyObject_Length (args) == 3 || PyObject_Length (args) == 2){ | 
					
						
							|  |  |  | 		if (!PyArg_ParseTuple (args, "sO|s", &prop_name, &prop_data, &prop_type)){ | 
					
						
							|  |  |  | 			return (EXPP_ReturnPyObjError (PyExc_AttributeError,	 | 
					
						
							|  |  |  | 				"unable to get string, data, and optional string")); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}else if (PyObject_Length (args) == 1){ | 
					
						
							|  |  |  | 		if (!PyArg_ParseTuple (args, "O!", &property_Type, &py_prop)){ | 
					
						
							|  |  |  | 			return (EXPP_ReturnPyObjError (PyExc_AttributeError,	 | 
					
						
							|  |  |  | 				"unable to get Property")); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if(py_prop->property != NULL){ | 
					
						
							|  |  |  | 				return (EXPP_ReturnPyObjError (PyExc_AttributeError,	 | 
					
						
							|  |  |  | 					"Property is already added to an object")); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}else{ | 
					
						
							|  |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError,	 | 
					
						
							|  |  |  | 						"expected 1,2 or 3 arguments")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//parse property type
 | 
					
						
							|  |  |  | 	if(!py_prop){ | 
					
						
							|  |  |  | 		if(prop_type){ | 
					
						
							|  |  |  | 			if(BLI_streq(prop_type, "BOOL"))                type = PROP_BOOL; | 
					
						
							|  |  |  | 			else if (BLI_streq(prop_type, "INT"))           type = PROP_INT; | 
					
						
							|  |  |  | 			else if (BLI_streq(prop_type, "FLOAT"))     type = PROP_FLOAT; | 
					
						
							|  |  |  | 			else if (BLI_streq(prop_type, "TIME"))        type = PROP_TIME; | 
					
						
							|  |  |  | 			else if (BLI_streq(prop_type, "STRING"))  type = PROP_STRING; | 
					
						
							|  |  |  | 			else return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							|  |  |  | 					"BOOL, INT, FLOAT, TIME or STRING expected")); | 
					
						
							|  |  |  | 		}else{ | 
					
						
							|  |  |  | 			//use the default
 | 
					
						
							|  |  |  | 			if(PyInt_Check(prop_data))                 type = PROP_INT; | 
					
						
							|  |  |  | 			else if (PyFloat_Check(prop_data))    type = PROP_FLOAT; | 
					
						
							|  |  |  | 			else if (PyString_Check(prop_data))  type = PROP_STRING; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}else{ | 
					
						
							|  |  |  | 		type = py_prop->type; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//initialize a new bProperty of the specified type
 | 
					
						
							|  |  |  | 	prop = new_property(type); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//parse data
 | 
					
						
							|  |  |  | 	if(!py_prop){ | 
					
						
							|  |  |  | 		BLI_strncpy(prop->name, prop_name, 32); | 
					
						
							|  |  |  | 		if(PyInt_Check(prop_data)){ | 
					
						
							|  |  |  | 			*((int*)&prop->data) = (int)PyInt_AsLong(prop_data); | 
					
						
							|  |  |  | 		}else if (PyFloat_Check(prop_data)){ | 
					
						
							|  |  |  | 			*((float *)&prop->data) = (float)PyFloat_AsDouble(prop_data); | 
					
						
							|  |  |  | 		}else if (PyString_Check(prop_data)){ | 
					
						
							|  |  |  | 			BLI_strncpy(prop->poin, PyString_AsString(prop_data), MAX_PROPSTRING); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}else{ | 
					
						
							|  |  |  | 		py_prop->property = prop; | 
					
						
							|  |  |  | 		if(!updateProperyData(py_prop)){ | 
					
						
							|  |  |  | 			return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							|  |  |  | 					"Could not update property data - error")); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//add to property listbase for the object
 | 
					
						
							|  |  |  | 	BLI_addtail(&self->object->prop, prop); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return EXPP_incr_ret  (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_removeProperty(BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *prop_name = NULL; | 
					
						
							|  |  |  | 	BPy_Property *py_prop = NULL; | 
					
						
							|  |  |  | 	bProperty *prop = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// we have property and no optional arg
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple (args, "O!", &property_Type, &py_prop)){ | 
					
						
							|  |  |  | 		if(!PyArg_ParseTuple (args, "s", &prop_name)){ | 
					
						
							|  |  |  | 			return (EXPP_ReturnPyObjError (PyExc_AttributeError,	 | 
					
						
							|  |  |  | 				"expected a Property or a string")); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//remove the link, free the data, and update the py struct
 | 
					
						
							|  |  |  | 	if(py_prop){ | 
					
						
							|  |  |  | 		BLI_remlink(&self->object->prop, py_prop->property); | 
					
						
							|  |  |  | 		if(updatePyProperty(py_prop)){ | 
					
						
							|  |  |  | 			free_property(py_prop->property); | 
					
						
							|  |  |  | 			py_prop->property = NULL; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}else{ | 
					
						
							|  |  |  | 		prop = get_property(self->object, prop_name); | 
					
						
							|  |  |  | 		if(prop){ | 
					
						
							|  |  |  | 			BLI_remlink(&self->object->prop, prop); | 
					
						
							|  |  |  | 			free_property(prop); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return EXPP_incr_ret  (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_removeAllProperties(BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	free_properties(&self->object->prop); | 
					
						
							|  |  |  | 	return EXPP_incr_ret  (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Object_copyAllPropertiesTo(BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *dest = Py_None; | 
					
						
							|  |  |  | 	bProperty *prop = NULL; | 
					
						
							|  |  |  | 	bProperty *propn = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple (args, "O!", &Object_Type, &dest)){ | 
					
						
							|  |  |  | 		return (EXPP_ReturnPyObjError (PyExc_AttributeError,	 | 
					
						
							|  |  |  | 			"expected an Object")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//make a copy of all it's properties
 | 
					
						
							|  |  |  | 	prop = self->object->prop.first; | 
					
						
							|  |  |  | 	while(prop) { | 
					
						
							|  |  |  | 		propn= copy_property(prop); | 
					
						
							|  |  |  | 		BLI_addtail(&((BPy_Object*)dest)->object->prop, propn); | 
					
						
							|  |  |  | 		prop= prop->next; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return EXPP_incr_ret  (Py_None); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | /* obj.addScriptLink */ | 
					
						
							|  |  |  | static PyObject *Object_addScriptLink (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Object *obj = self->object; | 
					
						
							|  |  |  | 	ScriptLink *slink = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	slink = &(obj)->scriptlink; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!EXPP_addScriptLink(slink, args, 0)) | 
					
						
							|  |  |  | 		return EXPP_incr_ret (Py_None); | 
					
						
							|  |  |  | 	else return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* obj.clearScriptLinks */ | 
					
						
							|  |  |  | static PyObject *Object_clearScriptLinks (BPy_Object *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Object *obj = self->object; | 
					
						
							|  |  |  | 	ScriptLink *slink = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	slink = &(obj)->scriptlink; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return EXPP_incr_ret(Py_BuildValue("i", EXPP_clearScriptLinks (slink))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* obj.getScriptLinks */ | 
					
						
							|  |  |  | static PyObject *Object_getScriptLinks (BPy_Object *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Object *obj = self->object; | 
					
						
							|  |  |  | 	ScriptLink *slink = NULL; | 
					
						
							|  |  |  | 	PyObject *ret = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	slink = &(obj)->scriptlink; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = EXPP_getScriptLinks(slink, args, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ret) return ret; | 
					
						
							|  |  |  | 	else return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:	Object_CreatePyObject										 */ | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | /* Description: This function will create a new BlenObject from an existing  */ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /*				Object structure.											 */ | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | PyObject* Object_CreatePyObject (struct Object *obj) | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	BPy_Object	  * blen_object; | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-21 03:19:52 +00:00
										 |  |  | 	if (!obj) return EXPP_incr_ret (Py_None); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type); | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (blen_object == NULL) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return (NULL); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	blen_object->object = obj; | 
					
						
							|  |  |  | 	return ((PyObject*)blen_object); | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:	Object_CheckPyObject										 */ | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /* Description: This function returns true when the given PyObject is of the */ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /*				type Object. Otherwise it will return false.				 */ | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | int Object_CheckPyObject (PyObject *py_obj) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	return (py_obj->ob_type == &Object_Type); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:	Object_FromPyObject											 */ | 
					
						
							|  |  |  | /* Description: This function returns the Blender object from the given		 */ | 
					
						
							|  |  |  | /*				PyObject.													 */ | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | struct Object* Object_FromPyObject (PyObject *py_obj) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	BPy_Object	  * blen_obj; | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	blen_obj = (BPy_Object*)py_obj; | 
					
						
							|  |  |  | 	return (blen_obj->object); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | /* Description: Returns the object with the name specified by the argument	 */ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /*				name. Note that the calling function has to remove the first */ | 
					
						
							|  |  |  | /*				two characters of the object name. These two characters		 */ | 
					
						
							|  |  |  | /*				specify the type of the object (OB, ME, WO, ...)			 */ | 
					
						
							|  |  |  | /*				The function will return NULL when no object with the given  */ | 
					
						
							|  |  |  | /*				name is found.												 */ | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | Object * GetObjectByName (char * name) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   Object  * obj_iter; | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   obj_iter = G.main->object.first; | 
					
						
							|  |  |  |   while (obj_iter) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 	if (StringEqual (name, GetIdName (&(obj_iter->id)))) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	  return (obj_iter); | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	obj_iter = obj_iter->id.next; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   /* There is no object with the given name */ | 
					
						
							|  |  |  |   return (NULL); | 
					
						
							| 
									
										
										
										
											2003-07-27 15:56:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:	Object_dealloc												 */ | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | /* Description: This is a callback function for the BlenObject type. It is	 */ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /*				the destructor function.									 */ | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static void Object_dealloc (BPy_Object *obj) | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject_DEL (obj); | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:	Object_getAttr												 */ | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | /* Description: This is a callback function for the BlenObject type. It is	 */ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /*				the function that retrieves any value from Blender and		 */ | 
					
						
							|  |  |  | /*				passes it to Python.										 */ | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject* Object_getAttr (BPy_Object *obj, char *name) | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	struct Object	* object; | 
					
						
							|  |  |  | 	struct Ika		* ika; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	object = obj->object; | 
					
						
							|  |  |  | 	if (StringEqual (name, "LocX")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->loc[0])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "LocY")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->loc[1])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "LocZ")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->loc[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "loc")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("fff", object->loc[0], object->loc[1], | 
					
						
							|  |  |  | 							   object->loc[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dLocX")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->dloc[0])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dLocY")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->dloc[1])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dLocZ")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->dloc[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dloc")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("fff", object->dloc[0], object->dloc[1], | 
					
						
							|  |  |  | 							   object->dloc[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "RotX")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->rot[0])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "RotY")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->rot[1])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "RotZ")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->rot[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "rot")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("fff", object->rot[0], object->rot[1], | 
					
						
							|  |  |  | 							   object->rot[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dRotX")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->drot[0])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dRotY")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->drot[1])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dRotZ")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->drot[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "drot")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("fff", object->drot[0], object->drot[1], | 
					
						
							|  |  |  | 							   object->drot[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "SizeX")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->size[0])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "SizeY")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->size[1])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "SizeZ")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->size[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "size")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("fff", object->size[0], object->size[1], | 
					
						
							|  |  |  | 							   object->size[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dSizeX")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->dsize[0])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dSizeY")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->dsize[1])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dSizeZ")) | 
					
						
							|  |  |  | 		return (PyFloat_FromDouble(object->dsize[2])); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dsize")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("fff", object->dsize[0], object->dsize[1], | 
					
						
							|  |  |  | 							   object->dsize[2])); | 
					
						
							|  |  |  | 	if (strncmp (name,"Eff", 3) == 0) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if ( (object->type == OB_IKA) && (object->data != NULL) ) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			ika = object->data; | 
					
						
							|  |  |  | 			switch (name[3]) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				case 'X': | 
					
						
							|  |  |  | 					return (PyFloat_FromDouble (ika->effg[0])); | 
					
						
							|  |  |  | 				case 'Y': | 
					
						
							|  |  |  | 					return (PyFloat_FromDouble (ika->effg[1])); | 
					
						
							|  |  |  | 				case 'Z': | 
					
						
							|  |  |  | 					return (PyFloat_FromDouble (ika->effg[2])); | 
					
						
							|  |  |  | 				default: | 
					
						
							|  |  |  | 				/* Do we need to display a sensible error message here? */ | 
					
						
							|  |  |  | 					return (NULL); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		return (NULL); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "Layer")) | 
					
						
							|  |  |  | 	  return (PyInt_FromLong(object->lay)); | 
					
						
							|  |  |  | 	if (StringEqual (name, "parent")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (object->parent) | 
					
						
							|  |  |  | 			return (Object_CreatePyObject (object->parent)); | 
					
						
							|  |  |  | 		else  | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 	  Py_INCREF (Py_None); | 
					
						
							|  |  |  | 	  return (Py_None); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (StringEqual (name, "track")) | 
					
						
							|  |  |  | 	  return (Object_CreatePyObject (object->track)); | 
					
						
							|  |  |  | 	if (StringEqual (name, "data")) | 
					
						
							|  |  |  | 	  return (Object_getData (obj)); | 
					
						
							|  |  |  | 	if (StringEqual (name, "ipo")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (object->ipo == NULL) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			/* There's no ipo linked to the object, return Py_None. */ | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 			Py_INCREF (Py_None); | 
					
						
							|  |  |  | 			return (Py_None); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		return (Ipo_CreatePyObject (object->ipo)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-06-26 14:38:56 +00:00
										 |  |  | 	if (StringEqual (name, "mat") || StringEqual (name, "matrix")) | 
					
						
							|  |  |  | 		return (Object_getMatrix (obj, Py_BuildValue("(s)","localspace"))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "matrixWorld")) | 
					
						
							|  |  |  | 		return (Object_getMatrix (obj, Py_BuildValue("(s)","worldspace"))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "matrixLocal")) | 
					
						
							|  |  |  | 		return (Object_getMatrix (obj, Py_BuildValue("(s)","localspace"))); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (StringEqual (name, "colbits")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("h", object->colbits)); | 
					
						
							|  |  |  | 	if (StringEqual (name, "drawType")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("b", object->dt)); | 
					
						
							|  |  |  | 	if (StringEqual (name, "drawMode")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("b", object->dtx)); | 
					
						
							|  |  |  | 	if (StringEqual (name, "name")) | 
					
						
							|  |  |  | 		return (Py_BuildValue ("s", object->id.name+2)); | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  | 	if (StringEqual (name, "sel")) | 
					
						
							|  |  |  | 		return (Object_isSelected (obj)); | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	/* not an attribute, search the methods table */ | 
					
						
							|  |  |  | 	return Py_FindMethod(BPy_Object_methods, (PyObject *)obj, name); | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:	Object_setAttr												 */ | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | /* Description: This is a callback function for the BlenObject type. It is	 */ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /*				the function that retrieves any value from Python and sets	 */ | 
					
						
							|  |  |  | /*				it accordingly in Blender.									 */ | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static int Object_setAttr (BPy_Object *obj, char *name, PyObject *value) | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	PyObject		* valtuple; | 
					
						
							|  |  |  | 	struct Object	* object; | 
					
						
							|  |  |  | 	struct Ika		* ika; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* First put the value(s) in a tuple. For some variables, we want to */ | 
					
						
							|  |  |  | 	/* pass the values to a function, and these functions only accept */ | 
					
						
							|  |  |  | 	/* PyTuples. */ | 
					
						
							|  |  |  | 	valtuple = Py_BuildValue ("(O)", value); | 
					
						
							|  |  |  | 	if (!valtuple) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError(PyExc_MemoryError, | 
					
						
							|  |  |  | 						 "Object_setAttr: couldn't create PyTuple"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	object = obj->object; | 
					
						
							|  |  |  | 	if (StringEqual (name, "LocX")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->loc[0]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "LocY")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->loc[1]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "LocZ")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->loc[2]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "loc")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (Object_setLocation (obj, valtuple) != Py_None) | 
					
						
							|  |  |  | 			return (-1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "dLocX")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->dloc[0]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dLocY")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->dloc[1]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dLocZ")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->dloc[2]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dloc")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (Object_setDeltaLocation (obj, valtuple) != Py_None) | 
					
						
							|  |  |  | 			return (-1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "RotX")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->rot[0]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "RotY")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->rot[1]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "RotZ")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->rot[2]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "rot")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (Object_setEuler (obj, valtuple) != Py_None) | 
					
						
							|  |  |  | 			return (-1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "dRotX")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->drot[0]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dRotY")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->drot[1]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dRotZ")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->drot[2]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "drot")) | 
					
						
							| 
									
										
										
										
											2004-03-11 12:23:53 +00:00
										 |  |  | 		return (!PyArg_ParseTuple (value, "fff", &(object->drot[0]), | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 							  &(object->drot[1]), &(object->drot[2]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "SizeX")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->size[0]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "SizeY")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->size[1]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "SizeZ")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->size[2]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "size")) | 
					
						
							| 
									
										
										
										
											2004-03-11 12:23:53 +00:00
										 |  |  | 		return (!PyArg_ParseTuple  (value, "fff", &(object->size[0]), | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 							  &(object->size[1]), &(object->size[2]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dSizeX")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->dsize[0]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dSizeY")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->dsize[1]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dSizeZ")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "f", &(object->dsize[2]))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "dsize")) | 
					
						
							| 
									
										
										
										
											2004-03-11 12:23:53 +00:00
										 |  |  | 		return (!PyArg_ParseTuple  (value, "fff", &(object->dsize[0]), | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 							  &(object->dsize[1]), &(object->dsize[2]))); | 
					
						
							|  |  |  | 	if (strncmp (name,"Eff", 3) == 0) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if ( (object->type == OB_IKA) && (object->data != NULL) ) | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 			ika = object->data; | 
					
						
							|  |  |  | 			switch (name[3]) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				case 'X': | 
					
						
							|  |  |  | 					return (!PyArg_Parse (value, "f", &(ika->effg[0]))); | 
					
						
							|  |  |  | 				case 'Y': | 
					
						
							|  |  |  | 					return (!PyArg_Parse (value, "f", &(ika->effg[1]))); | 
					
						
							|  |  |  | 				case 'Z': | 
					
						
							|  |  |  | 					return (!PyArg_Parse (value, "f", &(ika->effg[2]))); | 
					
						
							|  |  |  | 				default: | 
					
						
							|  |  |  | 					/* Do we need to display a sensible error message here? */ | 
					
						
							|  |  |  | 					return (0); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2003-10-24 17:08:59 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		return (0); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "Layer")) | 
					
						
							| 
									
										
										
										
											2004-05-20 06:26:43 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  |         /*  usage note: caller of this func needs to do a 
 | 
					
						
							|  |  |  | 	   Blender.Redraw(-1) to update and redraw the interface */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Base *base; | 
					
						
							|  |  |  | 		int newLayer; | 
					
						
							|  |  |  | 		int local; | 
					
						
							|  |  |  | 		if(PyArg_Parse (value, "i", &newLayer)){ | 
					
						
							|  |  |  | 			/* uppper 2 bytes are for local view */ | 
					
						
							|  |  |  | 			newLayer &= 0x00FFFFFF;   | 
					
						
							|  |  |  | 			if( newLayer == 0 ) /* bail if nothing to do */ | 
					
						
							|  |  |  | 				return( 0 ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* update any bases pointing to our object */ | 
					
						
							|  |  |  | 			base = FIRSTBASE; | 
					
						
							|  |  |  | 			if( base->object == obj->object ){ | 
					
						
							|  |  |  | 				local = base->lay &= 0xFF000000; | 
					
						
							|  |  |  | 				base->lay = local | newLayer; | 
					
						
							|  |  |  | 				object->lay = base->lay; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			countall(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else{ | 
					
						
							|  |  |  | 			return EXPP_ReturnIntError(PyExc_AttributeError, | 
					
						
							|  |  |  | 						   "expected int as bitmask"); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 		return( 0 ); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	if (StringEqual (name, "parent")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* This is not allowed. */ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"Setting the parent is not allowed."); | 
					
						
							|  |  |  | 		return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "track")) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
											  
											
												New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms);
- bevel_center by Loic Berthe, suggested for inclusion by jms;
- doc_browser, by Daniel Dunbar (Zr)
  Thanks to them for the new contributions!
  (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'.  Opinions?)
BPython related:
- Added scriptlink methods to object, lamp, camera and world.
- Object: added object.makeTrack and object.clearTrack (old track method).
- sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither.
- doc updates and fixes.
- made ONLOAD event work.  G.f's SCENESCRIPT bit was being zeroed in set_app_data.
- Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...)
- Draw: added mouse wheel events.
- Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A).  Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate".
The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode.  It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender.  Loading after the program is up has no such problems.  When I finish I'll post examples of demo mode scripts.
											
										 
											2004-07-03 05:17:04 +00:00
										 |  |  | 		if (Object_makeTrack (obj, valtuple) != Py_None) | 
					
						
							|  |  |  | 			return (-1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return (0); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "data")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* This is not allowed. */ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"Setting the data is not allowed."); | 
					
						
							|  |  |  | 		return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "ipo")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* This is not allowed. */ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"Setting the ipo is not allowed."); | 
					
						
							|  |  |  | 		return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "mat")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* This is not allowed. */ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 					"Setting the matrix is not allowed."); | 
					
						
							|  |  |  | 		return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "matrix")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* This is not allowed. */ | 
					
						
							| 
									
										
										
										
											2004-06-06 22:42:51 +00:00
										 |  |  | 		EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2004-03-03 00:45:10 +00:00
										 |  |  | 					"Please use .setMatrix(matrix)"); | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 		return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "colbits")) | 
					
						
							|  |  |  | 		return (!PyArg_Parse (value, "h", &(object->colbits))); | 
					
						
							|  |  |  | 	if (StringEqual (name, "drawType")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (Object_setDrawType (obj, valtuple) != Py_None) | 
					
						
							|  |  |  | 			return (-1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "drawMode")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (Object_setDrawMode (obj, valtuple) != Py_None) | 
					
						
							|  |  |  | 			return (-1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (StringEqual (name, "name")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (Object_setName (obj, valtuple) != Py_None) | 
					
						
							|  |  |  | 			return (-1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-06-02 06:19:56 +00:00
										 |  |  |    | 
					
						
							|  |  |  | 	if (StringEqual (name, "sel")) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (Object_Select (obj, valtuple) != Py_None) | 
					
						
							|  |  |  | 			return (-1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return (0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | 	printf ("Unknown variable.\n"); | 
					
						
							|  |  |  | 	return (0); | 
					
						
							| 
									
										
										
										
											2003-03-15 19:14:16 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:	Object_compare												 */ | 
					
						
							|  |  |  | /* Description: This is a callback function for the BPy_Object type. It		 */ | 
					
						
							|  |  |  | /*				compares two Object_Type objects. Only the "==" and "!="	 */ | 
					
						
							|  |  |  | /*				comparisons are meaninful. Returns 0 for equality and -1 if  */ | 
					
						
							|  |  |  | /*				they don't point to the same Blender Object struct.			 */ | 
					
						
							|  |  |  | /*				In Python it becomes 1 if they are equal, 0 otherwise.		 */ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static int Object_compare (BPy_Object *a, BPy_Object *b) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   Object *pa = a->object, *pb = b->object; | 
					
						
							|  |  |  |   return (pa == pb) ? 0:-1; | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  | /* Function:	Object_repr													 */ | 
					
						
							|  |  |  | /* Description: This is a callback function for the BPy_Object type. It		 */ | 
					
						
							|  |  |  | /*				builds a meaninful string to represent object objects.		 */ | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | static PyObject *Object_repr (BPy_Object *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-10-29 01:37:32 +00:00
										 |  |  |   return PyString_FromFormat("[Object \"%s\"]", self->object->id.name+2); | 
					
						
							| 
									
										
										
										
											2003-05-17 13:46:15 +00:00
										 |  |  | } |