From 5d8c7e453746e0114caddb5a5cb11cdac6f5ed3b Mon Sep 17 00:00:00 2001 From: Willian Padovani Germano Date: Fri, 23 Jan 2004 02:59:54 +0000 Subject: BPython: - local tentative fix for BLI_gethome(), which returns '.blender' appended only on some Windows systems. Created bpymenu_gethome() to check and add '.blender' if needed. - changed name: .Bpymenus to Bpymenus as suggested by GSR - trivial additions: Object module: added methods .set/getSize Armature/Bone module: bone.set???() methods now accept both n floats or a list of n floats: fff or (fff). All these additions were requested by user Carlos Lopez (Klopes). - New doc: for module Registry. --- source/blender/python/api2_2x/Bone.c | 73 +++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 22 deletions(-) (limited to 'source/blender/python/api2_2x/Bone.c') diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index c0dade51140..94ce51cf275 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -455,14 +455,20 @@ PyObject *Bone_setRoll(BPy_Bone *self, PyObject *args) static PyObject *Bone_setHead(BPy_Bone *self, PyObject *args) { float f1,f2,f3; + int status; if (!self->bone) (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't get attribute from a NULL bone")); - - if (!PyArg_ParseTuple(args, "fff", &f1,&f2,&f3)) + + if (PyObject_Length (args) == 3) + status = PyArg_ParseTuple (args, "fff", &f1, &f2, &f3); + else + status = PyArg_ParseTuple (args, "(fff)", &f1, &f2, &f3); + + if (!status) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected 3 float arguments")); - + "expected 3 (or a list of 3) float arguments")); + self->bone->head[0] = f1; self->bone->head[1] = f2; self->bone->head[2] = f3; @@ -475,14 +481,20 @@ static PyObject *Bone_setHead(BPy_Bone *self, PyObject *args) static PyObject *Bone_setTail(BPy_Bone *self, PyObject *args) { float f1,f2,f3; + int status; if (!self->bone) (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't get attribute from a NULL bone")); - - if (!PyArg_ParseTuple(args, "fff", &f1,&f2,&f3)) + + if (PyObject_Length (args) == 3) + status = PyArg_ParseTuple (args, "fff", &f1, &f2, &f3); + else + status = PyArg_ParseTuple (args, "(fff)", &f1, &f2, &f3); + + if (!status) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected 3 float arguments")); - + "expected 3 (or a list of 3) float arguments")); + self->bone->tail[0] = f1; self->bone->tail[1] = f2; self->bone->tail[2] = f3; @@ -495,14 +507,20 @@ static PyObject *Bone_setTail(BPy_Bone *self, PyObject *args) static PyObject *Bone_setLoc(BPy_Bone *self, PyObject *args) { float f1,f2,f3; + int status; if (!self->bone) (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't get attribute from a NULL bone")); - - if (!PyArg_ParseTuple(args, "fff", &f1,&f2,&f3)) + + if (PyObject_Length (args) == 3) + status = PyArg_ParseTuple (args, "fff", &f1, &f2, &f3); + else + status = PyArg_ParseTuple (args, "(fff)", &f1, &f2, &f3); + + if (!status) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected 3 float arguments")); - + "expected 3 (or a list of 3) float arguments")); + self->bone->loc[0] = f1; self->bone->loc[1] = f2; self->bone->loc[2] = f3; @@ -515,14 +533,20 @@ static PyObject *Bone_setLoc(BPy_Bone *self, PyObject *args) static PyObject *Bone_setSize(BPy_Bone *self, PyObject *args) { float f1,f2,f3; + int status; if (!self->bone) (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't get attribute from a NULL bone")); - - if (!PyArg_ParseTuple(args, "fff", &f1,&f2,&f3)) + + if (PyObject_Length (args) == 3) + status = PyArg_ParseTuple (args, "fff", &f1, &f2, &f3); + else + status = PyArg_ParseTuple (args, "(fff)", &f1, &f2, &f3); + + if (!status) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected 3 float arguments")); - + "expected 3 (or a list of 3) float arguments")); + self->bone->size[0] = f1; self->bone->size[1] = f2; self->bone->size[2] = f3; @@ -535,14 +559,20 @@ static PyObject *Bone_setSize(BPy_Bone *self, PyObject *args) static PyObject *Bone_setQuat(BPy_Bone *self, PyObject *args) { float f1,f2,f3,f4; + int status; if (!self->bone) (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't get attribute from a NULL bone")); - - if (!PyArg_ParseTuple(args, "ffff", &f1,&f2,&f3,&f4)) + + if (PyObject_Length (args) == 4) + status = PyArg_ParseTuple (args, "ffff", &f1, &f2, &f3, &f4); + else + status = PyArg_ParseTuple (args, "(ffff)", &f1, &f2, &f3, &f4); + + if (!status) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected 4 float arguments")); - + "expected 4 (or a list of 4) float arguments")); + self->bone->quat[0] = f1; self->bone->quat[1] = f2; self->bone->quat[2] = f3; @@ -552,7 +582,6 @@ static PyObject *Bone_setQuat(BPy_Bone *self, PyObject *args) return Py_None; } - /*****************************************************************************/ /* Function: Bone_dealloc */ /* Description: This is a callback function for the BPy_Bone type. It is */ @@ -707,7 +736,7 @@ int Bone_CheckPyObject (PyObject *py_obj) /*****************************************************************************/ struct Bone* Bone_FromPyObject (PyObject *py_obj) { - BPy_Bone * blen_obj; + BPy_Bone * blen_obj; blen_obj = (BPy_Bone*)py_obj; return (blen_obj->bone); -- cgit v1.2.3