[Bf-python] Object.link
models at paposo.com
models at paposo.com
Sat Sep 13 18:07:25 CEST 2003
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)
If you hit F9 you'll see there were two meshes created and 1 of them is
linked to 'myObject'. The problem is that Object.New creates a default mesh
by calling add_mesh(). This returns a real mesh with the default name of
'mesh' linked to the object. NMesh.New() does not create real mesh. When
object.link is called with a python mesh parameter the following occurs:
1.NMesh_FromPyObject is called which returns a new mesh (by again calling
add_mesh()) based on the python mesh passed.
2.The object's data pointer is set to point at the new mesh.
self->object->data = data;
So, what happens in the end is that two meshes were created. A default one
during object creation, and a new one representing the python mesh. The
object gets linked to the new one from the python mesh but it doesn't axe
the old one, so you have a floating unlinked mesh.
I think that the old data should probably be freed and removed from the
global mesh list when the new link occurs.
More information about the Bf-python
mailing list