Script to assign colour to objects

 From:  Michael Gibson
11193.6 In reply to 11193.5 
Hi shayne, try pasting this in for the "command" part of a shortcut key:

code:
script: /* Cycle selection through colors */

var styles = [
	[ 'gold', 207, 194, 37 ], 
	[ 'platinum', 145, 145, 145 ], 
	[ 'silver', 207, 208, 203 ], 
	[ 'rose gold', 214, 141, 92 ]
];

/* Create styles if not currently existing */

var style_indexes = [];

for ( var i = 0; i < styles.length; ++i )
{
	var style = moi.geometryDatabase.findStyle( styles[i][0], true /*Create if not found*/ );
	style_indexes.push( style.index );
	var r = styles[i][1];
	var g = styles[i][2];
	var b = styles[i][3];
	style.color = ( (r << 16) | (g << 8) | b );
}

var objects = moi.geometryDatabase.getSelectedObjects();

if ( objects.length > 0 )
{
	var obj = objects.item(0);
	var current = -1;
	for ( var i = 0; i < style_indexes.length; ++i )
	{
		if ( obj.styleIndex == style_indexes[i] )
			current = i;
	}

	var next = (current + 1) % style_indexes.length;
	objects.setProperty( 'styleIndex', style_indexes[next] );
}



- Michael