Author Topic: Color an element based on a tagged value  (Read 9241 times)

Rudi Claes

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Color an element based on a tagged value
« 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?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Color an element based on a tagged value
« Reply #1 on: March 01, 2011, 05:07:34 am »
Select element
Press F4
Uncheck default color
-> the RGB values are the ones you need


q.

philchudley

  • EA User
  • **
  • Posts: 743
  • Karma: +21/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Color an element based on a tagged value
« Reply #2 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
Models are great!
Correct models are even greater!

Kris Nunes

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Color an element based on a tagged value
« Reply #3 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.

cjcrystal

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Color an element based on a tagged value
« Reply #4 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




KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Color an element based on a tagged value
« Reply #5 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.
« Last Edit: May 10, 2017, 09:15:15 am by KP »
The Sparx Team
[email protected]

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1320
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Color an element based on a tagged value
« Reply #6 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.
Happy to help
:)