RE: Scripting - Sorting a Collection

Date : Thu, 18 Oct 2007 13:22:25 +0100
To : <XSI(at)Softimage.COM>
From : "kim aldis" <xsi(at)kim-aldis.co.uk>
Subject : RE: Scripting - Sorting a Collection

 

From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Adam Seeley
Sent: 18 October 2007 11:38
To: XSI(at)Softimage.COM
Subject: RE: Scripting - Sorting a Collection

 

Hi,

 

Seems a bit brutal but if it works, hey.

[kim:-]

 

Most of Chinny’s example is just the stuff that builds the array. You can do that however you wish. For example, copy the collection to an array, sort it then copy it back again. The documentation example is probably clearer but it does state that calling quicksort is the same as calling the array.sort() method so I’m not quite sure why it’s included in the XSIUtils object instead of, say, a collection sort method.:

 

a = new Array( "C", "a", "Check", "Z", "zed" ) ;

 

logmessage("before: a=[" + a + "]");

 

XSIUtils.QuickSort(a);

 

logmessage("after: a=[" + a + "]");

 

Surprised there isn't access somewhere to the sort functions that are found in the Explorer.

[kim:-]

 

Like ‘xsiutils.Quicksort’, or’ Array.sort()’ maybe? ;)

 

 

Adam.

 


From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Jason Brynford-Jones
Sent: 17 October 2007 20:44[kim:-] Quicksort
To: XSI(at)Softimage.COM
Subject: RE: Scripting - Sorting a Collection

    Set oPasses = ActiveProject.ActiveScene.Passes

    'create a string - which can be turned into an array using 'split'

    oContent = ""

    for each oPass in oPasses

        oContent = oContent & oPass.FullName & ";" 

    Next

    'get rid of the last ;

    oContent = Left(oContent ,len(oContent)-1)

 

    oArray = split (oContent,";")

    XSIUtils.Quicksort oArray

 

    set oColl = CreateObject ("XSI.Collection")

    for each item in oArray

        oColl.add item

    Next

   

      logmessage oColl 

 


From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Adam Seeley
Sent: Wednesday, October 17, 2007 1:32 PM
To: XSI(at)Softimage.COM
Subject: RE: Scripting - Sorting a Collection

Soz,

 

VB Script at the moment.

 

A.

 


From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Adam Seeley
Sent: 17 October 2007 18:30
To: XSI(at)Softimage.COM
Subject: Scripting - Sorting a Collection

Hi,

 

I've pulled all the Passes in a Scene into a collection and now I want to Output information to a text file or Excel sheet.

 

The default order of the Collection seems to be the Creation order, but I would like to output the information in the same order as the Alphanumeric sort that I see in the Explorer.

There is the Quicksort function which I could use. This seems to mean that I have put the collection into an Array to sort it first.

 

I can make the array ok but is there a way to easily sort the Collection instead, otherwise are there any commands lying around that would pipe the Collection Sstraight into an array (and back). Seems like the kind of function that would exist already somewhere.

 

Many thanks,

 

Adam.

 

 


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.14.12 - Release Date: 15/10/2007 00:00

 

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.14.12 - Release Date: 15/10/2007 00:00

 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.14.12 - Release Date: 15/10/2007 00:00


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.14.12 - Release Date: 15/10/2007 00:00

 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.14.12 - Release Date: 15/10/2007 00:00


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.