From dd493f71bee1896823b50c68fb8f96ecf7dd959c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Jun 2009 17:10:46 +0000 Subject: [PATCH] modified patch from Arystanbek, allow assigning of mathutils matrix to an rna matrix --- source/blender/python/intern/bpy_rna.c | 40 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 70ccd4f58c9..e91b96d6f26 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -410,14 +410,29 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v if (len > 0) { PyObject *item; + int py_len = -1; int i; - if (!PySequence_Check(value)) { + +#ifdef USE_MATHUTILS + if(MatrixObject_Check(value)) { + MatrixObject *mat = (MatrixObject*)value; + if(!Matrix_ReadCallback(mat)) + return -1; + + py_len = mat->rowSize * mat->colSize; + } else // continue... +#endif + if (PySequence_Check(value)) { + py_len= (int)PySequence_Length(value); + } + else { PyErr_SetString(PyExc_TypeError, "expected a python sequence type assigned to an RNA array."); return -1; } + /* done getting the length */ - if ((int)PySequence_Length(value) != len) { + if (py_len != len) { PyErr_SetString(PyExc_AttributeError, "python sequence length did not match the RNA array."); return -1; } @@ -484,14 +499,21 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v else param_arr = MEM_mallocN(sizeof(float) * len, "pyrna float array"); - - /* collect the variables */ - for (i=0; icontigPtr, sizeof(float) * len); + } else // continue... +#endif + { + /* collect the variables */ + for (i=0; i