[Bf-python] NMesh.Get() Missing?

Yann Vernier yann at algonet.se
Sat Nov 13 09:37:52 CET 2004


On Fri, Nov 12, 2004 at 08:01:35PM -0500, Campbell J Barton wrote:
> All I want to do is get a list of meshs,
> Now there is no NMesh.Get()  function like there is with Object, Image
> and Material (I think there should be)...

For historical reasons (NMesh was supposed to be wrapped in a Python
module called Mesh) the NMesh getter function is called GetRaw.

> So is there a way of getting a list of mesh names??-

Not precisely.. GetRaw() will still return a list of NMesh objects.
Those are just wrappers, though, and shouldn't consume much memory.

> Also- Getting mesh names requires a Object.GetData().name Which converts
> all  the mesh data to an NMesh python data in memoy, that is a lotr of
> extra work if all want is to find the name.

AFAIK there's no way to get just the names. The Python objects Object,
NMesh and so on don't require very much memory by themselves, until one
uses them to actually work on the data. To conserve memory, remove your
references to each object after processing it, i.e. instead of:

for mesh in Blender.NMesh.GetRaw():
  do_something(mesh)

you may want to:

meshes=Blender.NMesh.GetRaw()
while meshes:
  mesh=meshes.pop(0)
  do_something(mesh)

Remove the 0 for reverse order. This way you'll only have one
non-pristine NMesh object around. I rather doubt you'll need this level
of tricks though.

-- 
PGP fingerprint = 9242 DC15 2502 FEAB E15F  84C6 D538 EC09 5380 5746
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20041113/f5f53710/attachment.sig>


More information about the Bf-python mailing list