[Bf-python] FW: [Bf-blender-cvs] CVScommit: blender/source/blender/python/api2_2xObject.c
Gilbert, Joseph
jgilbert at tigr.ORG
Thu Nov 3 17:01:27 CET 2005
This was an idea that I had.
a. add PyObject *materials_list to PyObject
b. PyObject_New(//constructor){ self->materials_list = PyList_New(0);}
c. for the tp_getset on 'materials' do Object_getMaterials { return
Py_INCREF(self->materials_list)} Object_setMaterials { //copy into
materials_list }
This might allow object.materials.append(mat2) and object.materials =
object.materials
If you did PyDict_New() you could do
Object.materials['newmat'] = mat2
Am I out in left field?
-----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, November 03, 2005 10:39 AM
To: Blender Foundation Python list
Subject: Re: [Bf-python] FW: [Bf-blender-cvs] CVScommit:
blender/source/blender/python/api2_2xObject.c
Gilbert, Joseph wrote:
> This was part of the mathutils update and in response to the
> vector_proxy issue. However, it seems that this has generated a bit of
> confusion. We need to label in the documentation which methods return
> WRAP'ed data (i.e. give thin access) and what does not. Even then
script
> writers will still do x = y by mistake and not realize why that have
to
> reinvert a matrix for instance.
It's not just here, it's in a number of places. For example, NMesh,
Mesh and Object deal with a list of materials instead of a sequence
operator; the individual Material objects are wrapped but the list
isn't. So to assign new materials, you have to assign the whole list,
not just a single material:
matlist = obj.materials
obj.materials = [matlist[0],matlist[1],mat2]
instead of
obj.materials[2]=mat2
The problem is we would also need to implement a bunch of new sequence
operators for these types, and there may not be any guarantee that the
way Blender internally represents one type is the same as another (could
use array in one case, linked list in another).
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