[Bf-python] vector types in NMesh.c

Gilbert, Joseph jgilbert at tigr.ORG
Thu Sep 1 16:00:53 CEST 2005


I think the getter and setter don't match. To get the float array you
have to do float_array = [vec[0], vec[1], vec[2]].  To build a vector
object it's vector = Vector(f,f,f). I don't know if we want to make the
getters and setters return/get different things. Either we should go
with vectors here are go with float lists. I'll let willian decide here,
but for my opinion I think it should get and take vectors.

The internal setter code is:

If(!PyArg_ParseTuple(v, "ff|f", &(mv->uvco[0]), &(mv->uvco[1]),
&(mv->uvco[2])){
.....return EXPP_ReturnIntError(PyExec_AttributeError, "Vector tuple or
triple expected");

if you want to get vector in, vector out (Vector supports 2D, 3D, and 4D
sizes):

PyObject *vector= NULL;
if(!PaArg_ParseTuple(v, "O!", &vector_Type, vector){
....return intError;
}
...mv->uvco[0] = vector->vec[0];
...mv->uvco[1] = vector->vec[1];
if(vector->size == 3){
...mv->uvco[2] = vector->vec[2];
}
return 0;

-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Ken Hughes
Sent: Thursday, September 01, 2005 1:07 AM
To: Blender Foundation Python list
Subject: [Bf-python] vector types in NMesh.c

Joseph, keeper of the vector modules (also filling out a bug report when

p.b.o stops crawling):

Just discovered this problem in 2.37a and recent CVS:

    import Blender

    mesh = Blender.NMesh.GetRaw('Cube')

    result = mesh.verts[0].uvco
    mesh.verts[0].uvco = tuple(result)
    mesh.verts[0].uvco = result

I get "AttributeError: Vector tuple or triple expected" in the last 
line.  I'd fix this (I'm tp_getseting NMesh.c now) but I honestly don't 
see a "clean" method to convert a vector back into a float array.  Maybe

we need an complementaty operation for newVectorObject() ?

Ken
_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list