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

Ken Hughes khughes at pacific.edu
Tue May 26 05:58:13 CEST 2009


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

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()
>>     




More information about the Bf-python mailing list