[Bf-python] Mesh Module

Gilbert, Joseph jgilbert at tigr.ORG
Tue Oct 4 22:20:41 CEST 2005


You need to think about how people will want to use this with the math
classes. Doing math on returned lists is not as fun.

.verts, .edges, can be py_objects subclassed from py_list which all
implement the sequence protocol. 

-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Willian
Padovani Germano
Sent: Tuesday, October 04, 2005 3:39 PM
To: Blender Foundation Python list
Subject: Re: [Bf-python] Mesh Module

Ken Hughes wrote:
> I'm still trying to figure out the best 
> way to handle sequence operators (assignments in particular) while
still 
> keeping things "thin" and not messing up how meshes are referred to 
> elsewhere in Blender.

Hi Ken, opening our discussion to the group.

This is where the pure Python types could come in. Example for verts:

Add to Mesh a PyVert type, similar to NMVert.

Add function to create it: Mesh.Vert(arg), where arg could be a list of 
coordinates or a vector.

Then assignment can be made with these pyverts:

newvert = Mesh.Vert([x,y,z])
mesh.verts[n] = newvert

They can also be used when the coder needs more control of (a slice of) 
mesh.verts, with a mesh.verts.get() or .copy() or simply 
mesh.verts[start:end], if the code gets all updated to use pyverts. Ex:

myverts = mesh.verts.get() # gets a list with copies of the verts
# now you can do whatever with myverts:
# add or remove from anywhere in the list, append, extend, etc.
# Then:
mesh.verts = myverts # pass changes back to Blender

If the user forgets or doesn't want to pass the changes back to Blender,

no problem. Since it's a "pylist of pyverts", Python itself takes care 
of getting rid of the data once its ref count reaches zero (otherwise 
it's a buggy Python version).

Not thin as direct access, but with control of the quantity of data to 
work on at a time and no need to grab/transform the whole mesh, but 
simply the data you need at that time, it might be a good approach.

-- 
Willian

_______________________________________________
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