Module NMesh :: Class NMesh
[frames | no frames]

Class NMesh


The NMesh Data object

This object gives access to mesh data in Blender. We refer to mesh as the object in Blender and NMesh as its Python counterpart.
Method Summary
  addMaterial(material)
Add a new material to this NMesh's list of materials.
int getActiveFace()
Get the index of the active face.
list getSelectedFaces(flag)
Get list of selected faces.
list getVertexInfluences(index)
Get influences of bones in a specific vertex.
bool hasFaceUV(flag)
Get (and optionally set) if this NMesh has UV-mapped textured faces.
bool hasVertexColours(flag)
Get (and optionally set) if this NMesh has vertex colours.
bool hasVertexUV(flag)
Get (and optionally set) the "sticky" flag that controls if a mesh has per vertex UV coordinates.
  insertKey(frame, type)
Insert a mesh key at the given frame.
bool removeAllKeys()
Remove all mesh keys stored in this mesh.
  update(recalc_normals)
Update the mesh in Blender.

Class Variable Summary
  faces - The list of NMesh faces (NMFaces).
  materials - The list of materials used by this NMesh.
  name - The NMesh name.
  users - The number of Objects using (linked to) this mesh.
  verts - The list of NMesh vertices (NMVerts).

Method Details

addMaterial(material)

Add a new material to this NMesh's list of materials. This method is the slower but safer way to add materials, since it checks if the argument given is really a material, imposes a limit of 16 materials and only adds the material if it wasn't already in the list.
Parameters:
material - A Blender Material.
           (type=Blender Material)

getActiveFace()

Get the index of the active face.
Returns:
The index of the active face.
           (type=int)

getSelectedFaces(flag=None)

Get list of selected faces.
Parameters:
flag - If given and non-zero, the list will have indices instead of the NMFace objects themselves.
           (type=int)
Returns:
It depends on the flag parameter:
  • if None or zero: List of NMFace objects.
  • if non-zero: List of indices to NMFace objects.

           (type=list)

getVertexInfluences(index)

Get influences of bones in a specific vertex.
Parameters:
index - The index of a vertex.
           (type=int)
Returns:
List of pairs (name, weight), where name is the bone name (string) and its weight is a float value.
           (type=list)

hasFaceUV(flag=None)

Get (and optionally set) if this NMesh has UV-mapped textured faces.
Parameters:
flag - If given and non-zero, the "textured faces" flag for this NMesh is turned on.
           (type=int)
Returns:
The current value of the "textured faces" flag.
           (type=bool)

hasVertexColours(flag=None)

Get (and optionally set) if this NMesh has vertex colours.
Parameters:
flag - If given and non-zero, the "vertex colour" flag for this NMesh is turned on.
           (type=int)
Returns:
The current value of the "vertex colour" flag.
           (type=bool)

Warning: If a mesh has both vertex colours and textured faces, this function will return False. This is due to the way Blender deals internally with the vertex colours array (if there are textured faces, it is copied to the textured face structure and the original array is freed/deleted). If you want to know if a mesh has both textured faces and vertex colours, set *in Blender* the "VCol Paint" flag for each material that covers an area that was also vertex painted and then check in your Python script if that material flag is set. Of course also tell others who use your script to do the same. The "VCol Paint" material mode flag is the way to tell Blender itself to render with vertex colours, too, so it's a natural solution.

hasVertexUV(flag=None)

Get (and optionally set) the "sticky" flag that controls if a mesh has per vertex UV coordinates.
Parameters:
flag - If given and non-zero, the "sticky" flag for this NMesh is turned on.
           (type=int)
Returns:
The current value of the "sticky" flag.
           (type=bool)

insertKey(frame=None, type='relative')

Insert a mesh key at the given frame. Remember to update the nmesh before doing this, or changes in the vertices won't be updated in the Blender mesh.
Parameters:
frame - The Scene frame where the mesh key should be inserted. If None, the current frame is used.
           (type=int)
type - The mesh key type: 'relative' or 'absolute'. This is only relevant on the first call to insertKey for each nmesh (and after all keys were removed with removeAllKeys, of course).
           (type=string)

Warning: This and removeAllKeys were included in this release only to make accessing vertex keys possible, but may not be a proper solution and may be substituted by something better later. For example, it seems that 'frame' should be kept in the range [1, 100] (the curves can be manually tweaked in the Ipo Curve Editor window in Blender itself later).

removeAllKeys()

Remove all mesh keys stored in this mesh.
Returns:
True if succesful or False if this NMesh wasn't linked to a real Blender Mesh yet (or was, but the Mesh had no keys).
           (type=bool)

Warning: Currently the mesh keys from meshs that are grabbed with NMesh.GetRaw() or .GetRawFromObject() are preserved, so if you want to clear them or don't want them at all, remember to call this method. Of course NMeshes created with NMesh.New() don't have mesh keys until you add them.

update(recalc_normals=0)

Update the mesh in Blender. The changes made are put back to the mesh in Blender, if available, or put in a newly created mesh object if this NMesh wasn't linked to one, yet.
Parameters:
recalc_normals - If given and equal to 1, the vertex normals are recalculated.
           (type=int)

Class Variable Details

faces

The list of NMesh faces (NMFaces).

materials

The list of materials used by this NMesh.

name

The NMesh name. It's common to use this field to store extra data about the mesh (to be exported to another program, for example).

users

The number of Objects using (linked to) this mesh.

verts

The list of NMesh vertices (NMVerts).

Generated by Epydoc 1.1 on Wed Aug 13 19:17:14 2003 http://epydoc.sf.net