[Bf-python] api requests
Toni Alatalo
antont at kyperjokki.fi
Sun Jan 1 06:34:29 CET 2006
On Saturday 31 December 2005 10:56, Yann Vernier wrote:
> > Can anyone else comment? Does the hash ID of a face always remain the
> > same through all frames? Are the rules the same for NMesh and Mesh?
> and while a python id is unique in its lifetime, it may and most likely
> will be reused. Hashes aren't ever guaranteed to be unique, and most of
> Blender's datatypes have no hash implementation. It's also possible
perhaps we should start adding them .. with vertices it should be well
possible 'cause meshes have unique IDs and verts in them have unique indices:
class Vert:
def __hash__(self):
return hash_from_blenderid_and_partid(("Mesh", self.mesh.name), self.index)
or?
> (though undesired) to get multiple wrappers for the same blender object,
> which is fixable but hasn't been done.
i think making things hashable also enables straightforward reuse by
overriding the constructor
in one other system i have code like this:
class X(object):
instances = {}
def __new__(..)
obid = ..
if obid in X.instances: #reuse
return X.instances[obid]
else: #create new object (/wrapper)
ob = object.__new__(X, ..) #or however the syntax is, didnt check now
X.instances[id(ob)] = ob
return ob
dunno if that'd work for these purposes.
~Toni
More information about the Bf-python
mailing list