Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Gilbert <ascotan@gmail.com>2005-11-22 00:26:09 +0300
committerJoseph Gilbert <ascotan@gmail.com>2005-11-22 00:26:09 +0300
commit838fb771598e987cd9fd08582c154fe91253dc98 (patch)
treedfedcb0db8d34c43256361bc36af8cc14df5ceb0 /source/blender/python/api2_2x/Armature.c
parentac80b4ba115892ca96efa2b39eb6d57411fdd7db (diff)
- drawtypes added to ArmatureType
* uses module constants added to Armature.c
Diffstat (limited to 'source/blender/python/api2_2x/Armature.c')
-rw-r--r--source/blender/python/api2_2x/Armature.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index efe559507fe..c5bfff7b3c4 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -519,6 +519,55 @@ static PyObject *Armature_saveChanges(BPy_Armature *self)
return EXPP_incr_ret(Py_None);
}
//------------------ATTRIBUTE IMPLEMENTATION---------------------------
+//------------------------Armature.drawType (getter)
+static PyObject *Armature_getDrawType(BPy_Armature *self, void *closure)
+{
+ if (self->armature->drawtype == ARM_OCTA){
+ return EXPP_GetModuleConstant("Blender.Armature", "OCTAHEDRON") ;
+ }else if (self->armature->drawtype == ARM_LINE){
+ return EXPP_GetModuleConstant("Blender.Armature", "STICK") ;
+ }else if (self->armature->drawtype == ARM_B_BONE){
+ return EXPP_GetModuleConstant("Blender.Armature", "BBONE") ;
+ }else if (self->armature->drawtype == ARM_ENVELOPE){
+ return EXPP_GetModuleConstant("Blender.Armature", "ENVELOPE") ;
+ }else{
+ goto RuntimeError;
+ }
+
+RuntimeError:
+ return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
+ sArmatureError, "drawType: ", "Internal failure!");
+}
+//------------------------Armature.drawType (setter)
+static int Armature_setDrawType(BPy_Armature *self, PyObject *value, void *closure)
+{
+ PyObject *val = NULL, *name = NULL;
+ long numeric_value;
+
+ if(value){
+ if(BPy_Constant_Check(value)){
+ name = PyDict_GetItemString(((BPy_constant*)value)->dict, "name");
+ if (!STREQ2(PyString_AsString(name), "OCTAHEDRON", "STICK") &&
+ !STREQ2(PyString_AsString(name), "BBONE", "ENVELOPE"))
+ goto ValueError;
+ val = PyDict_GetItemString(((BPy_constant*)value)->dict, "value");
+ if (PyInt_Check(val)){
+ numeric_value = PyInt_AS_LONG(val);
+ self->armature->drawtype = (int)numeric_value;
+ return 0;
+ }
+ }
+ }
+ goto AttributeError;
+
+AttributeError:
+ return EXPP_intError(PyExc_AttributeError, "%s%s",
+ sArmatureBadArgs, "Expects module constant");
+
+ValueError:
+ return EXPP_intError(PyExc_AttributeError, "%s%s",
+ sArmatureBadArgs, "Argument must be the constant OCTAHEDRON, STICK, BBONE, or ENVELOPE");
+}
//------------------------Armature.ghostStep (getter)
static PyObject *Armature_getStep(BPy_Armature *self, void *closure)
{
@@ -828,6 +877,8 @@ static PyGetSetDef BPy_Armature_getset[] = {
"Draw a number of ghosts around the current frame for current Action", NULL},
{"ghostStep", (getter)Armature_getStep, (setter)Armature_setStep,
"The number of frames between ghost instances", NULL},
+ {"drawType", (getter)Armature_getDrawType, (setter)Armature_setDrawType,
+ "The type of drawing currently applied to the armature", NULL},
{NULL}
};
//------------------------tp_new
@@ -1163,6 +1214,15 @@ PyObject *Armature_Init(void)
PyModule_AddObject(module, "WORLDSPACE",
EXPP_incr_ret(PyConstant_NewString("WORLDSPACE", "world_space")));
+ PyModule_AddObject(module, "OCTAHEDRON",
+ EXPP_incr_ret(PyConstant_NewInt("OCTAHEDRON", ARM_OCTA)));
+ PyModule_AddObject(module, "STICK",
+ EXPP_incr_ret(PyConstant_NewInt("STICK", ARM_LINE)));
+ PyModule_AddObject(module, "BBONE",
+ EXPP_incr_ret(PyConstant_NewInt("BBONE", ARM_B_BONE)));
+ PyModule_AddObject(module, "ENVELOPE",
+ EXPP_incr_ret(PyConstant_NewInt("ENVELOPE", ARM_ENVELOPE)));
+
//Add SUBMODULES to the module
dict = PyModule_GetDict( module ); //borrowed
PyDict_SetItemString(dict, "NLA", NLA_Init()); //creates a *new* module