Change the color of all styles by a script

Next
 From:  crydee
2987.1 
Hi,

we have some iges files with the objects grouped into a couple of styles. Unfortunally all styles have the same color but we really need them in different colors. Because there are many styles it would be helpful to colorize them automatically with unique colors per style. Anyone with ideas?

Thanks in advance,
Crydee
  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
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
  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:  Frenchy Pilou (PILOU)
2987.3 
A cool site for have some assorted colors from A photo ;)
http://www.degraeve.com/color-palette/
  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:  crydee
2987.4 In reply to 2987.2 
thanks michael. your script is really nice. it works great. just another question. i need a shortcut for "adding a new style"and "edit style". can you help me again please?
thanks in advance.
crydee
  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
2987.5 In reply to 2987.4 
Hi crydee, yup it's possible to set those up.

To set up a shortcut for "Add new style", use this as the command:

script: /* Open Add new style dialog */ var gd = moi.geometryDatabase; gd.styleEditorOpened(); var dialog = moi.ui.createDialog( 'EditStyleDialog.htm?titleid=Add style dialog title&index=-1', '', moi.ui.mainWindow ); if ( dialog.window.doModal() != -1 ) { var styles = gd.getObjectStyles(); if ( styles.length > 0 ) moi.ui.propertiesPanel.editStyleIndex( styles.length - 1 ); } gd.styleEditorClosed();


To set up a shortcut for the "Edit styles" dialog, use this as the command:

script: /* Open Edit styles dialog */ var dialog = moi.ui.createDialog( 'EditStylesDialog.htm', 'resizeable,defaultWidth:380,defaultHeight:420', moi.ui.mainWindow ); dialog.window.doModal();


Hopefully that will get you wrangling your styles quickly... :)

- 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:  crydee
2987.6 In reply to 2987.5 
ah perfect. thats support. the bigger companies should take a close look to your response time. it's unique.
thumbs up.
have a nice weekend.

cheers crydee
  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