styles

 From:  Michael Gibson
3918.2 In reply to 3918.1 
Hi eric, it's possible to do it with a script, I've cooked one up for you that will do that.

To use the script you'll need to set it up on a keyboard shortcut. Go to Options > Shortcut keys, and push the "Add" button at the top to add in a new blank shortcut key entry.

For the left-hand column, put in whatever key you want to use to trigger it, and for the right-hand column that says "command" on it, copy the following and paste it into that right-hand column:


script: /* Sort styles alphabetically */ moi.geometryDatabase.styleEditorOpened(); var styles = moi.geometryDatabase.getObjectStyles(); var stylearray = new Array(); for ( var i = 0; i < styles.length; ++i ) { stylearray.push( styles.item(i) ); } function sortfunc(a,b) { return a.name.toLowerCase().localeCompare( b.name.toLowerCase() ); } stylearray.sort(sortfunc); for ( var i = 0; i < stylearray.length; ++i ) { var style = stylearray[i]; while ( style.index> i ) style.moveUp(); } moi.geometryDatabase.styleEditorClosed();


Then when you hit that key, the styles should get sorted alphabetically, please let me know if it doesn't work for you.

Oh also you probably shouldn't run this script while while the style editor dialog is also open, because it won't know how to deal with the styles changing out from underneath it like this script will do. So trigger the script when you are not in that dialog.

Also the script is not tremendously efficient, if you have something like more than 100 styles it may take a few seconds or something for it to complete.

This would probably be a good thing to put as a button in the edit styles dialog in the future.

- Michael

EDIT: 8/17/2012 - updated script to work properly with upper-case/lower-case names. Previously it sorted all names starting with upper case letters into one set and ones starting with lower case letters into a separate section, the updated version should not do that anymore.

EDITED: 17 Aug 2012 by MICHAEL GIBSON