[Bf-python] Fwd: Re: 'obj.data' returns NMesh data object even when made with Mesh class.

Dietrich Bollmann diresu at web.de
Tue Aug 7 06:13:19 CEST 2007


On Mon, 2007-08-06 at 12:19 +0300, Toni Alatalo wrote: 
> On Aug 6, 2007, at 8:50 AM, Dietrich Bollmann wrote:
> 
> > When making a Mesh object the member 'data' returns a NMesh and
> > not a Mesh data object.
> 
> yep, this is 'by design' in the sense of retaining backwards 
> compatibility. the GetData() method can be used to get as Mesh (which 
> .data would do if it was introduced now).

Wouldn't it be enough for backward compatibility to let 
'data' return the data object the blender object was created with?
In the case of old code this would be NMesh anyway; in the case
of code using the newer Mesh class this would be Mesh?

But probably you have thought about this already for longer
and have your reasons for doing it this way :)

> in the meantime, i guess documentation improvements would be the thing 
> to look at.

Maybe an error message when trying to do something like
>>> object.data.materials = [ material ]
would be helpful.

Or a note at
http://www.blender.org/documentation/244PythonDoc/Object.Object-class.html#data

something like:

Note: For backward compatibility 'data' returns an NMesh object
even in the case of a blender object which has been created with 
a Mesh data object.  Use 'getData(False, True)' for getting the 
Mesh object.

Thanks,
Dietrich

By the way - is there some "standard" terminology to talk about
what I called "blender object" and "data object"?

> ~Toni




More information about the Bf-python mailing list