Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Rudi Claes on March 01, 2011, 03:54:29 am

Title: Color an element based on a tagged value
Post by: Rudi Claes on March 01, 2011, 03:54:29 am
I'm writing a script in order to color some elements on a diagram based on the presence / contents of a tagged value. Rather straightforward stuff, but the coloring is giving me some trouble. More specifically the third parameter of SetAppearance: a call to SetAppearance 1,0,255 followed by an Update gives a nice red color and 1,0,-1 returns the default color, but what of the other basic colors (yellow, blue, green, etc)? Is this documented somewhere?
Title: Re: Color an element based on a tagged value
Post by: qwerty on March 01, 2011, 05:07:34 am
Select element
Press F4
Uncheck default color
-> the RGB values are the ones you need


q.
Title: Re: Color an element based on a tagged value
Post by: philchudley on March 01, 2011, 08:32:32 pm
Not that I know off, however if you can live with a stereotype it is very easy to change an elements appearance via tagged values using shapescripts.

Not sure if this of any help, but maybe worth a look

Cheers

Phil
Title: Re: Color an element based on a tagged value
Post by: Kris Nunes on March 28, 2011, 05:52:28 pm
I have not tried this, but I would probably looking into such as feature sometime soon.. There is a method part of Element,, Hope it helps,,,


SetAppearance (long Scope, long Item, long Value)
 Void
 Sets the visual appearance of the element.

Parameter:

Scope: Long - Scope of appearance set to modify
 
0 – Local (Diagram-local appearance)
1 – Base (Default appearance across entire model)
Item: Long - Appearance item to modify
 
0 – Background color
1 – Font Color
2 – Border Color
3 – Border Width
Value: Long - Value to set appearance to.
Title: Re: Color an element based on a tagged value
Post by: cjcrystal on May 09, 2017, 12:41:47 pm
Value: Long - Value to set appearance to.

in VBScript

Clng(255) for red

tried passing a RGB representation of the color CLng(255-0-0)

both works



Title: Re: Color an element based on a tagged value
Post by: KP on May 10, 2017, 09:13:44 am
tried passing a RGB representation of the color CLng(255-0-0)
I suspect the only reason that works is because it evaluates to 255 minus zero minus zero = 255. For an RGB representation, use red + green x 100hex + blue x 10000hex.
Title: Re: Color an element based on a tagged value
Post by: Sunshine on May 11, 2017, 07:54:39 am
Found using the diagram legend -> Apply auto color, works just fine so don't use a script anymore as  its a lot faster on the larger diagrams.