[Bf-python] Latest update on Mesh module

Ken Hughes khughes at pacific.edu
Mon Oct 17 19:05:59 CEST 2005


Campbell Barton wrote:
> Ken Hughes wrote:
> 
>> So I'm looking now at the other miscellaneous methods in NMesh, with 
>> future thoughts of replacing NMesh completely.  Should I recode all of 
>> those methods, or are there some "legacy" ones which don't make much 
>> sense anymore or are rarely used?  Are they any methods glaringly 
>> missing, based on recent additions elsewhere in Blender.
> 
> Hi Ken, I use nmesh.transform(matrix) a lot for exporters, should be 
> trivial, and could use the same syntax as  NMesh.
> An equivilent to NMesh.getRawFromObject is needed for exporters (maybe 
> there could be added a function like Alt+C, then you get the resulting 
> mesh)

I think the two points above are separate, so I'll discuss separately 
first.

I don't know if a mesh.transform() is a good idea in the thin mesh case, 
since it's going to change all the mesh's vertices.  It's not like NMesh 
where (as I understand it) you can do nmesh.transform() and as long as 
you don't do nmesh.update() the original mesh remains unchanged.  An 
alternative might be to have the method return a sequence of transformed 
vertices and assign to mesh.verts:

origverts = mesh.verts[:]
mesh.verts = mesh.transform()
# do export stuff with transformed verts
mesh.verts = origverts

I'll look into coding a version of getRawFromObject(); had forgot about 
that method completely.

Combining the two points above, another way to approach mesh.transform() 
is to copy the mesh and transform it, leaving the original alone.

> Another usefull function is scanfill. though this will probably be a 
> editmode only function too.
> I have also needed a "Recalc Normals Outside" function, with some mesh 
> generation its tricky to work out wich way to flip the face,

Are there scanfill and "recalc normals" tools already somewhere in 
blender?  Not only do I want to avoid reinventing the wheel, if the code 
isn't already in Blender itself them maybe it should be?

> I was wondering if the editMode functions work when there are no ed 
> views open?

Well, if you call mesh.subdivide() and have marked the edges you want to 
subdivide (either in the UI or by selecting their vertices in BPython) 
it works.  It does so by using the editmesh structure, which is why you 
can't have an edit view open.  Specifically, I set G.obedit to an object 
linked to the current mesh.  Elsewhere in the editmesh code it relies on 
G.editMesh to point at the edit mesh structures (which, from what I can 
see, always points to the static variable theEditMesh).  I haven't 
looked into creating my own copy of the edit mesh structures and 
pointing G.editMesh at that as well... if others think "you can't be in 
edit mode" is too much of a constraint I'll look into it.

Ken



More information about the Bf-python mailing list