Setting a new Edge Color and restoring within a script

Next
 From:  ed (EDDYF)
10401.1 
Hi Michael -

I'm developing a script + HTML that I'll share when complete. So far it's working very well.

The icing on the cake would be to set Edge color within the script, do some stuff, then restore the user's original Edge color.

I'm able to use:

//Set edge color as defined by Fixed Color under Options > View > Edge Color
moi.view.edgeColorMode = "FixedColor";

//Set edge color as defined by Style
moi.view.edgeColorMode = "ByStyle";

But the script needs to use a specific Edge color for all edges. I'm trying to avoid having the user go into Options > View > Edge Color to change the Edge color before using the script.

So is it possible to change the user's "FixedColor" to a new hex value, then restore the original color at the end of the script? (Don't want to use a color picker)

If so, I'm good to move forward.

Even better if this is possible:

If user has a Style set up called 'TempEdgeColor' for example, set Edge color to that Style color. (Or maybe the script creates the Style if it doesn't exist?)
If no such Style exists, set Edge color to a hex value defined within the script.
Do some stuff ...
If the user had Edge Options set to "FixedColor", then restore Edges to that color.
Else
moi.view.edgeColorMode = "ByStyle"; // Restore Edge color based on Style

To say it another way:

The script wants to use a specific Edge color for all edges (overriding the Option " Edge Color" if it's set to "FixedColor"), do some stuff, then set Edges back to their original color.
Nice to have, but not required > If the user wants to use their specific color, then the user (or script) could possibly create a new Style to define a temporary Edge color for the script to use.
Finally, set Edge color back to the user's original color.

Again, trying to avoid having the user go into Options and make a color change if possible.

Or maybe there's a different, easier way that I'm blind to :)

Regards,
Ed Ferguson
  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
10401.2 In reply to 10401.1 
Hi Ed, so if I understand properly you'd do something like this to set the edge display to a specific color and then back again:


var prev_color_mode = moi.view.edgeColorMode;
var prev_fixed_color = moi.view.edgeFixedColor;

moi.view.edgeColorMode = "FixedColor";

var r = 255;
var g = 0;
var b = 0;

moi.view.edgeFixedColor = (r << 16) | (g << 8) | b;

moi.ui.alert( 'edges are red' );

moi.view.edgeColorMode = prev_color_mode;
moi.view.edgeFixedColor = prev_fixed_color;



I'm not exactly following what you want for the style part, but yes it is possible to look for a style using:

var style = moi.geometryDatabase.findStyle( 'stylename', true /* Create if not found */ );

Let me know if you need more details.

- 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:  ed (EDDYF)
10401.3 In reply to 10401.2 
Thanks very much Michael! - That looks like everything I need to move forward.

I've done a lot of searching on the Moi forum and Moi script resource sites, plus studied many existing scripts, and had not come across the statements you provided. Now I have all the puzzle pieces :)

Ed Ferguson
  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