[Bf-python] Got independent copy of mesh, now how to free it later?

lynx.abraxas at freenet.de lynx.abraxas at freenet.de
Thu May 28 10:05:16 CEST 2009


On 25/05/09 20:58:13, Ken Hughes wrote:
> We added a "hack" for exporter so that if you create a mesh but don't
> link it to an object (so that when Python deallocates the object, its
> user count is 0) then the mesh data is freed.  See:
>
> http://www.blender.org/documentation/248PythonDoc/Mesh-module.html#New

Hm, It says:
Note:   if  the mesh is not linked to an object, its datablock will be deleted
when the object is deallocated.

How can python know to free the mesh when I deallocat an object if the mesh is
not linked to the object?
Is ob.unlink() ment by deallocation or is that done differently again?

Thanks
Lynx


> 
> Ken
> 
> joe wrote:
> > I think there are certain hacked cases where the mesh might be freed
> > (not sure, can't remember exactly).  But in general, once you create a
> > mesh you can't free it without saving and reloading the .blend; it's
> > how blender was designed.  Library datablocks (which includes meshes)
> > are never freed, their simply not written to disk if they aren't used.
> >  This was to compensate for the lack of undo (which of course we do
> > have now).
> >
> > Joe
> >
> > On Sun, May 24, 2009 at 12:34 PM,  <lynx.abraxas at freenet.de> wrote:
> >   
> >> If someone is interested: I got it to work with:
> >>
> >>   ellm= ell.getData(mesh=1)
> >>   ellmesh= ellm.__copy__() #that's the one!!!
> >>
> >> I must have overlooked this function because it starts with __. Does that mean
> >> it's an inherited copy constructor or  "just  use  if  you  know  what  you're
> >> doing"?
> >>
> >> That  way  I  can  use  the real copy to apply any transform for pointInside()
> >> while keeping the original as it is.
> >>
> >> I'm now wondering how to free a mesh in python? Just like this?
> >>
> >> ellmesh= None #is this the correct way to free the mesh?
> >>
> >> These don't work:
> >> bpy.data.meshes.unlink(ellmesh.name)
> >> ellmesh.unlink()
> >>     
> 
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list