[Bf-python] Fwd: Re: 'obj.data' returns NMesh data object even when made with Mesh class.
Dietrich Bollmann
diresu at web.de
Wed Aug 8 11:04:26 CEST 2007
On Tue, 2007-08-07 at 11:38 +0300, Toni Alatalo wrote:
> On Tuesday 07 August 2007 07:13:19 Dietrich Bollmann wrote:
> > 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?
>
> the api just exposes data that is in Blender, and Blender internals don't know
> how a certain Mesh datablock was created. hence there is currently no
> straightforward way to implement that kind of behaviour, and so such a
> possibility has probably never been even considered before.
>
> i think it would be confusing too. imagine you get a blend from someone else,
> where some meshes would be marked as being created using NMesh, and some with
> Mesh, but you don't know, just get strange behaviour from same script working
> for some meshes but not for others.
>
> to summarize: when you create py objects like Mesh data pyobjects in a script,
> those pyobjects are not stored anywhere. they are just a way to use Blender
> to create mesh datablocks, and in Blender (and in .blend files) they are just
> c structs with no py related information whatsoever. so the way you get the
> data (e.g. NMesh or Mesh) defines what you get, not how it has been created.
Ah ok, thank you - I finally understood :)
Looking at the mail following yours from Campbell Barton the NMesh seems to
vanish anyway and with it my problem. So all just a matter of time and I am
happily looking forward to the new Blender API :)
> > Maybe an error message when trying to do something like
> > >>> object.data.materials = [ material ]
> > would be helpful.
>
> hm .. i wonder if it would make sense for NMesh to handle some errors so that
> it suggests 'i am depracated, did you mean to use Mesh instead?. dunno if
> some hints could be easily hacked there somewhere.
>
> > Or a note at
> > http://www.blender.org/documentation/244PythonDoc/Object.Object-class.html#
> >data
> > 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.
>
> i guess that sort of thing is the solution now. gotta go now myself, perhaps
> someone else can look into improving the doc.
By the way, where can I post things concerning the docs?
I just found a typo on page
http://www.blender.org/documentation/244PythonDoc/Group-module.html :
The following doesn't work:
>>> ob= scn.objects.new(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected an object and optionally a string as arguments
And the intended probably is:
>>> ob= scn.objects.new('Empty')
Again drifting away from the original topic...
Cheers, Dietrich
More information about the Bf-python
mailing list