[Bf-python] Mesh Module
Willian Padovani Germano
wgermano at superig.com.br
Tue Oct 4 21:38:40 CEST 2005
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
More information about the Bf-python
mailing list