Change the color of all styles by a script

 From:  Michael Gibson
2987.2 In reply to 2987.1 
Hi crydee, it is possible for scripts to access the color of styles.

So for example here is a script that will set styles to randomized colors:

script: /* Randomize style colors */ var styles = moi.geometryDatabase.getObjectStyles(); for ( var i = 0; i < styles.length; ++i ) { var style = styles.item(i); var red = Math.random() * 255; var green = Math.random() * 255; var blue = Math.random() * 255; style.color = (red << 16) | (green << 8) | blue; }

To run it, set up a keyboard shortcut and paste the above (as one long single line) in as the command part and then every time you hit that key styles should change to random colors.

But random colors does not guarantee that each one will be unique, it is possible for some of them to be similar, especially with dark colors.

But it may be useful and maybe you can just cycle through it several times until you get one that is pretty good and then manually alter a few of the similar ones.

- Michael