[Bf-python] Object.link

Willian Padovani Germano wgermano at ig.com.br
Sat Sep 13 20:29:45 CEST 2003


Hi,

From: <models at paposo.com>
> Heres a problem with Object.link i ran into.
> Take this script for example:
>
> import Blender
> object = Blender.Object.New('Mesh', 'myObject')
> mesh = Blender.NMesh.New()
>
> //add verts to mesh... blah, blah
>
> object.link(mesh)

This is redundant, you only need:

mesh = Blender.NMesh.New()
# create 'content' for your new mesh here
Blender.NMesh.PutRaw(mesh)

The way you wrote above is in line with how other modules work, but the
*key* point here is that NMesh is not like the other modules, much to the
contrary.  Its API and good portions of its code are maybe the oldest legacy
code in bpython.  It was announced / documented before NaN went away that
Mesh would substitute NMesh.

But Mesh wasn't finished, in fact it was only a wrapper in Python of NMesh,
so my decision was to keep NMesh and fix its bugs, because it was well known
and used in many scripts, documented in tutorials, the book, etc.

> I think that the old data should probably be freed and removed from the
> global mesh list when the new link occurs.

We can't 'axe' real Blender meshes, because they are persistent data in
Blender.  Scene children aren't deleted (only scenes, texts and maybe
something else I'm forgetting are really deleted).  The others (objects,
meshes, cameras, etc) are simply not saved to file when their user count is
0, so they will not be present in the next Blender session.

What we should do is decrement the user count of the 'discarded' mesh, if
that isn't done already.  I didn't check, please take a look there.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list