[Tutor] sorting objects with embedded data
Tue, 15 Aug 2000 08:08:10 -1000
I can give part of a possible answer. I'd point you in the direction of
setting up a subclass for the cube object. You might explore if the work is
already done or being done, but it would make sense that there was a __cmp__
method of the object that would rank two cubes correctly. You probably also
have to implement some of the other magic methods (gurus please pipe up
here) such as __getattr__.
If subclassing 'cube' isn't working, creating a 'cubes' class that would
encapsulate the sort behaviour probably is the way to go. Maybe subclassing
UserList as a start.
Hope this helps,
> -----Original Message-----
> From: firstname.lastname@example.org [mailto:email@example.com]
> Sent: Tuesday, August 15, 2000 7:36 AM
> To: firstname.lastname@example.org
> Subject: [Tutor] sorting objects with embedded data
> I'm using python with blender (http://www.blender.nl) - an
> amazing freeware
> 3d modeling and animation package. I'm trying to sort a bunch
> of objects
> based on their positions in the Z axis direction.
> # each cube object contains coordinate data accessible through 3
> # methods? LocX, LocY, LocZ - these correspond to the x, y and
> # z axes respectively. Here's what I've got:
> for a in cubes:
> # this returns a sorted list of z coordinate values - great, but I
> # need to access the x and y coordinate data based on the sorted z
> # data - now I need to sort the cubes list based on the sorting
> # of the buffer list.
> # Is it possible to sort the cubes list in-place based on the
> # embedded LocZ numerical data?
> thanks in advance - check out blender, it's amazing.
> Tutor maillist - Tutor@python.org