[Bf-python] object.getDataName() - Implimented

Stephen Swaney sswaney at centurytel.net
Sun Jan 30 14:35:33 CET 2005


On Sat, Jan 29, 2005 at 10:51:15AM +0000, Campbell Barton wrote:

>  I was perplexed that There was no way to get the name of all the 
> meshs without doing a getData- Which can be slow with large mesh's.

This brings up an interesting point about the design of bpy types.
Most of our types were designed as thin python wrappers around blender
data.  This makes something like obj.getData().getName() a fairly
lightweight operation.

Our NMesh type is an exception, in that it creates quite a few useful
but relatively expensive lists.  Just a random thought, but one way to
get around the overhead of bpy type creation is to use lazy
initialization.

With lazy initialization, creating expensive data structures is not
done at object creation time, but is put off until the data is
actually accessed.  A flag or even the raw pointer is used to keep
track of the object's initialization state.

For our NMesh, this would mean we could get at the underlying blender
data without having to suffer through the work of creating all the
vert, edge and face data.  Operations like this would then be cheap:

objs = Object.Get()
for o in objs:
	print o.getData().getName()

-- 
Stephen Swaney			
sswaney at centurytel.net




More information about the Bf-python mailing list