styles

Next
 From:  eric (ERICCLOUGH)
3918.1 
Hi
Is there a way to put the 'styles' list in alphabetical order?
When it gets really long it would be a help.
cheers,
eric
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 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

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  DannyT (DANTAS)
3918.3 In reply to 3918.2 
Hi Michael,

Can't it be self sorted like objects?

-
~Danny~
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3918.4 In reply to 3918.3 
Hi Danny,

> Can't it be self sorted like objects?

Someone may want certain colors clustered together or something like that, which may not fit an alphabetical ordering.

It's not quite like the object list, since object names are something assigned to a selected object, while the styles list is more constructed as a list of items and so I don't really want to automatically disturb an ordering that someone may have set up for their particular list.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  DannyT (DANTAS)
3918.5 In reply to 3918.4 
ini option maybe ?

-
~Danny~
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3918.6 In reply to 3918.5 
Hi Danny,

> ini option maybe ?

That might be somewhat of a bad fit, since having only an alphabetical ordering would mean some other controls like the Up and Down buttons in the Edit styles dialog would have no effect.

It seems like it could work better to have something like a Sort button on that same dialog that would do just a one-shot sorting of them when you pushed it rather than trying to auto sort them always.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  DannyT (DANTAS)
3918.7 In reply to 3918.6 
Hi Michael,

I guess if you really want styles in alphabetical order you could just reorder them as you make a new style with the up and down buttons in edit style.

Cheers
~Danny~
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3918.8 In reply to 3918.7 
Hi Danny, yup that would work, that would just be inconvenient with a large number of them which is when a Sort button that would do that with one button push could be useful.

But anyway the script above will do it with one shortcut key right now, so that could be used for the time being.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  eric (ERICCLOUGH)
3918.9 In reply to 3918.2 
Thanks Michael ..
eric
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All