[Bf-python] getMatrix('worldspace') patch for bf-blender

Campbell Barton cbarton at metavr.com
Sat Jun 26 01:02:50 CEST 2004


Hi, have you compiled this?

if (StringEqual (name, "mat"))
    return (Object_getMatrix (obj));
if (StringEqual (name, "matrix"))
    return (Object_getMatrix (obj));

This wont work since the new Object_getMatrix wants 2 args. Object_getMatrix (obj, PyArgs)

Even if the arg is an empty python object it needs to be there.
As I sead b4, I dobnt know how to do this.

I need to create an empty Python arg and the problem will be solved.

- Cam




Gilbert, Joseph wrote:

>Hi, :)
>  Looks good but I don't think it's necessary to have an internal
>function because the getMatrix() will be backwards compatible anyway
>(when no arg is used). The extra stringcompare functions in getattr will
>never get called. Everything minus the internal function is perfect :)
>Oh, I was thinking that this also needs to be done on the bone module
>for rot/loc/size I think. Not sure where else this is applicable.
>
>static PyObject *Object_getMatrix (BPy_Object *self, PyObject *args);
>....
>{"getMatrix", (PyCFunction)Object_getMatrix, METH_VARARGS,"Returns the
>object matrix"},
>.....
>static PyObject *Object_getMatrix (BPy_Object *self, PyObject *args)
>{
>    PyObject  *matrix;
>    char *space = "localespace";	 /* default to locale */
>	
>    if (!PyArg_ParseTuple(args, "|s", &space))
>    {
>        return (EXPP_ReturnPyObjError (PyExc_AttributeError,
>          "expected a string or nothing"));
>    }
>	
>    matrix = newMatrixObject(NULL, 4, 4);
>	
>    if (BLI_streq(space, "worldspace"))		/* Worldspace matrix */
>    {
>        where_is_object(self->object);
>        Mat4CpyMat4(*((MatrixObject*)matrix)->matrix,
>self->object->obmat);
>    } else if (BLI_streq(space, "localespace")) { /* Localespace matrix
>*/
>        object_to_mat4(self->object, *((MatrixObject*)matrix)->matrix);
>    } else {
>        return (EXPP_ReturnPyObjError (PyExc_RuntimeError, "correct
>spaces 
>          are 'worldspace' and 'localespace', none defaults to 
>          localespace"));
>    }
>    return matrix;
>}
> ....
>if (StringEqual (name, "mat"))
>    return (Object_getMatrix (obj));
>if (StringEqual (name, "matrix"))
>    return (Object_getMatrix (obj));
>....
>
>_______________________________________________
>Bf-python mailing list
>Bf-python at blender.org
>http://www.blender.org/mailman/listinfo/bf-python
>
>
>  
>





More information about the Bf-python mailing list