[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16206] trunk/blender/source/blender/ python/api2_2x: Python API

Ken Hughes khughes at pacific.edu
Thu Aug 21 18:10:31 CEST 2008


Revision: 16206
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16206
Author:   khughes
Date:     2008-08-21 18:10:30 +0200 (Thu, 21 Aug 2008)

Log Message:
-----------
Python API
----------
Access to empty shapes by object.emptyShape attribute, contributed by Domino
Marama (thanks!)

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/Object.c
    trunk/blender/source/blender/python/api2_2x/doc/Object.py

Modified: trunk/blender/source/blender/python/api2_2x/Object.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Object.c	2008-08-21 15:44:29 UTC (rev 16205)
+++ trunk/blender/source/blender/python/api2_2x/Object.c	2008-08-21 16:10:30 UTC (rev 16206)
@@ -204,6 +204,7 @@
 	EXPP_OBJ_ATTR_SB_INSPRING,
 	EXPP_OBJ_ATTR_SB_INFRICT,
 
+	EXPP_OBJ_ATTR_EMPTY_DRAWTYPE
 };
 
 #define EXPP_OBJECT_DRAWSIZEMIN         0.01f
@@ -2431,6 +2432,12 @@
 			OB_BOUNDBOX, OB_TEXTURE, 'b' );
 }
 
+static int Object_setEmptyShape( BPy_Object * self, PyObject * value )
+{
+	return EXPP_setIValueRange( value, &self->object->empty_drawtype,
+			OB_ARROWS, OB_EMPTY_CONE, 'b' );
+}
+
 static int Object_setEuler( BPy_Object * self, PyObject * args )
 {
 	float rot1, rot2, rot3;
@@ -3758,6 +3765,9 @@
 	case EXPP_OBJ_ATTR_DRAWTYPE:
 		param = object->dt;
 		break;
+	case EXPP_OBJ_ATTR_EMPTY_DRAWTYPE:
+		param = object->empty_drawtype;
+		break;
 	case EXPP_OBJ_ATTR_PARENT_TYPE:
 		param = object->partype;
 		break;
@@ -4938,6 +4948,10 @@
 	 (getter)getIntAttr, (setter)Object_setDrawType,
 	 "The object's drawing type",
 	 (void *)EXPP_OBJ_ATTR_DRAWTYPE},
+	{"emptyShape",
+	 (getter)getIntAttr, (setter)Object_setEmptyShape,
+	 "The empty's drawing shape",
+	 (void *)EXPP_OBJ_ATTR_EMPTY_DRAWTYPE},
 	{"parentType",
 	 (getter)getIntAttr, (setter)NULL,
 	 "The object's parent type",
@@ -5538,6 +5552,24 @@
 	return M;
 }
 
+static PyObject *M_Object_EmptyShapesDict( void )
+{
+	PyObject *M = PyConstant_New(  );
+
+	if( M ) {
+		BPy_constant *d = ( BPy_constant * ) M;
+		PyConstant_Insert( d, "ARROWS", PyInt_FromLong( OB_ARROWS ) );
+		PyConstant_Insert( d, "AXES", PyInt_FromLong( OB_PLAINAXES ) );
+		PyConstant_Insert( d, "CIRCLE", PyInt_FromLong( OB_CIRCLE ) );
+		PyConstant_Insert( d, "ARROW", PyInt_FromLong( OB_SINGLE_ARROW ) );
+		PyConstant_Insert( d, "CUBE", PyInt_FromLong( OB_CUBE ) );
+		PyConstant_Insert( d, "SPHERE", PyInt_FromLong( OB_EMPTY_SPHERE ) );
+		PyConstant_Insert( d, "CONE", PyInt_FromLong( OB_EMPTY_CONE ) );
+	}
+	return M;
+}
+
+
 /*****************************************************************************/
 /* Function:	 initObject						*/
 /*****************************************************************************/
@@ -5552,6 +5584,7 @@
 	PyObject *RBFlagsDict = M_Object_RBFlagsDict( );
 	PyObject *RBShapesDict = M_Object_RBShapeBoundDict( );
 	PyObject *IpoKeyTypesDict = M_Object_IpoKeyTypesDict( );
+	PyObject *EmptyShapesDict = M_Object_EmptyShapesDict( );
 
 	PyType_Ready( &Object_Type ) ;
 
@@ -5596,7 +5629,9 @@
 	if( RBShapesDict )
 		PyModule_AddObject( module, "RBShapes", RBShapesDict );
 	if( IpoKeyTypesDict )
-		PyModule_AddObject( module, "IpoKeyTypes", IpoKeyTypesDict );	
+		PyModule_AddObject( module, "IpoKeyTypes", IpoKeyTypesDict );
+	if( EmptyShapesDict )
+		PyModule_AddObject( module, "EmptyShapes", EmptyShapesDict );
 
 		/*Add SUBMODULES to the module*/
 	dict = PyModule_GetDict( module ); /*borrowed*/

Modified: trunk/blender/source/blender/python/api2_2x/doc/Object.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Object.py	2008-08-21 15:44:29 UTC (rev 16205)
+++ trunk/blender/source/blender/python/api2_2x/doc/Object.py	2008-08-21 16:10:30 UTC (rev 16206)
@@ -117,6 +117,10 @@
 	attribute.  Only one type can be selected at a time.  Values are
 	BOX, SPHERE, CYLINDER, CONE, and POLYHEDERON
 
+ at type EmptyShapes: readonly dictionary
+ at var EmptyShapes: Constant dict used for with L{Object.emptyShape} attribute.
+	Only one type can be selected at a time. Values are
+	ARROW, ARROWS, AXES, CIRCLE, CONE, CUBE AND SPHERE
 """
 
 def New (type, name='type'):
@@ -347,7 +351,7 @@
 			ob.layers = []  # object won't be visible
 			ob.layers = [1, 4] # object visible only in layers 1 and 4
 			ls = o.layers
-			ls.append([10])
+			ls.append(10)
 			o.layers = ls
 			print ob.layers # will print: [1, 4, 10]
 		B{Note}: changes will only be visible after the screen (at least
@@ -525,6 +529,8 @@
 	@ivar drawType: The object's drawing type.
 		See L{DrawTypes} constant dict for values.
 	@type drawType: int
+	@ivar emptyShape: The empty drawing shape.
+		See L{EmptyShapes} constant dict for values.
 	@ivar parentType: The object's parent type.  Read-only.
 		See L{ParentTypes} constant dict for values.
 	@type parentType: int





More information about the Bf-blender-cvs mailing list