Color Gradient script?
 1-8  …  49-68  69-88  89-92

Previous
Next
 From:  Michael Gibson
9676.89 In reply to 9676.87 
Hi GonzoRus,

re:
> This script does not work quite correctly. It makes ALL curves the same specified color
> (color 0, 1, 2, 3, etc.) existing in the Style Menu. BUT. "Undo" and "Redo" stop working
> for styles.

Please give these versions a try:

/* Assign selected curves to style = Red */ var starting_selection = moi.geometryDatabase.getSelectedObjects(); var curves = starting_selection.getCurves(); moi.geometryDatabase.deselectAll(); curves.setProperty( 'selected', true ); var style = moi.geometryDatabase.findStyle( 'Red', false /*Create if not found*/ ); if ( style ) { moi.ui.propertiesPanel.editStyleIndex( style.index ); } moi.geometryDatabase.deselectAll(); starting_selection.setProperty( 'selected', true );

/* Assign all curves to style = Red */ var starting_selection = moi.geometryDatabase.getSelectedObjects(); var curves = moi.geometryDatabase.getObjects().getCurves(); moi.geometryDatabase.deselectAll(); curves.setProperty( 'selected', true ); var style = moi.geometryDatabase.findStyle( 'Red', false /*Create if not found*/ ); if ( style ) { moi.ui.propertiesPanel.editStyleIndex( style.index ); } moi.geometryDatabase.deselectAll(); starting_selection.setProperty( 'selected', true );

These use the properties panel mechanism for applying the style index, it's what is used when you assign a style by clicking on the style name in the properties panel and it does the extra work to set up an undo unit to make it work with undo. The properties panel only modifies the current selection so for the version that does all curves it modifies the selection first and then restores it afterwards.

- 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:  GonzoRus
9676.90 
Thanks Michael!

Everything works great with your scripts.

Undo and Redo work great. Thank you!)
  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:  bemfarmer
9676.91 In reply to 9676.89 
Both shortcuts work!

A minor observation:

For customUI shortcuts "gearpair" icon menu, add the ! i.e. /*!

Also, the second comment /*Create if not found*/ causes the customUI gearpair icon to display all of the code up to the last */, which is a long line of text in the menu.
so I removed the second comment /*Create if not found*/, in the installed shortcut.

- Brian
  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:  GonzoRus
9676.92 
Script for assigning "Magenta" color to selected faces.

code:
/* Assign selected faces to style = Magenta */ var starting_selection = moi.geometryDatabase.getSelectedObjects(); var faces = starting_selection.getFaces(); moi.geometryDatabase.deselectAll(); faces.setProperty( 'selected', true ); var style = moi.geometryDatabase.findStyle( 'Magenta', false /*Create if not found*/ ); if ( style ) { moi.ui.propertiesPanel.editStyleIndex( style.index ); } moi.geometryDatabase.deselectAll(); starting_selection.setProperty( 'selected', true );


"Magenta" can be changed to any color from the existing styles.
  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

 

 
 
Show messages:  1-8  …  29-48  49-68  69-88  89-92