berniebernie
03-29-2009, 11:15 AM
Hello cgtalkers
I have an array full of objects (`ls -sl`), which I then process to give me a parallel array full of distances from point A to each object in the array. So far so good.
Now I'm trying to retrieve a list of the objects sorted from closest to furthest. I could use the mel 'sort' command on the array full of distances, but how can I replicate the shifts in array indexes to the one containing the object names ?
I know python handles such data much more efficiently, but right now I can't afford to learn a new language (or can I easily integrate a few python lines - some sort of "eval" into a mel script?).
I'm a little a loss. It's easy enough to create my own bubble/cocktail sort (the arrays are not immensely huge) but I really don't know how to maintain an associative array (containing strings) like php does: $key => $value
Any clues ? Thanks !
And yes, it's time that I move to python; but from what I've heard python in maya is a bastardized version that looks like a hack more than a support language. Perhaps this will change soon ? Integrated PYMEL or something.
I have an array full of objects (`ls -sl`), which I then process to give me a parallel array full of distances from point A to each object in the array. So far so good.
Now I'm trying to retrieve a list of the objects sorted from closest to furthest. I could use the mel 'sort' command on the array full of distances, but how can I replicate the shifts in array indexes to the one containing the object names ?
I know python handles such data much more efficiently, but right now I can't afford to learn a new language (or can I easily integrate a few python lines - some sort of "eval" into a mel script?).
I'm a little a loss. It's easy enough to create my own bubble/cocktail sort (the arrays are not immensely huge) but I really don't know how to maintain an associative array (containing strings) like php does: $key => $value
Any clues ? Thanks !
And yes, it's time that I move to python; but from what I've heard python in maya is a bastardized version that looks like a hack more than a support language. Perhaps this will change soon ? Integrated PYMEL or something.
