Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: MatthiasVDE on September 04, 2020, 03:52:17 am

Title: Set color to an element for appearance in all the diagrams
Post by: MatthiasVDE on September 04, 2020, 03:52:17 am
i'm trying to set a background color on an element object, in order to give this element the same color on each diagram it appears.

Quote
      activity.SetAppearance 1,0,RGB(35, 169, 242)
      activity.Update()

But because this doesn't work, ik was wondering I shouldn't use a diagramObject instead of an element?
Title: Re: Set color to an element for appearance in all the diagrams
Post by: qwerty on September 04, 2020, 05:05:15 am
Setting per diagram is possible but not what you intend. If the global change does not apply there are two possiblites:

a- you already have some per-diagram alteration and
b- there's a shape script in the background
(and c- you code might be wrong).

q.
Title: Re: Set color to an element for appearance in all the diagrams
Post by: MichaelJ on September 04, 2020, 05:14:34 am
i'm trying to set a background color on an element object, in order to give this element the same color on each diagram it appears....
The good news is that you don't need to use a script to do this. Use the concept of "Default Appearance" to set the appreance of a specific element or set of elements. Then, when you drop the element onto any diagram, the default appreance will be used until you clear it or override it on a given diagram.
To achieve this,
In 15.2 (1554) Sparx ahs improved the handling of default appearance. If you find that the appearance is not working as expected, click the element with incorrect appearance, click the "painter" icon (on the right side of the element) and select "Reset Local Appearance".
Title: Re: Set color to an element for appearance in all the diagrams
Post by: MatthiasVDE on September 04, 2020, 02:10:35 pm
Michael,

I create the BPMN elements with a script, and I want to automatically give them a color based on a role.
Title: Re: Set color to an element for appearance in all the diagrams
Post by: qwerty on September 04, 2020, 07:01:49 pm
See my b-remark above. BPMN uses shape script. So either you modify the native shape script or you need to stick to a per-diagram setting (if the shape script permits that at all).

q.
Title: Re: Set color to an element for appearance in all the diagrams
Post by: MatthiasVDE on September 04, 2020, 07:03:22 pm
See my b-remark above. BPMN uses shape script. So either you modify the native shape script or you need to stick to a per-diagram setting (if the shape script permits that at all).

q.

Setting the color on the diagramObject you mean?
Title: Re: Set color to an element for appearance in all the diagrams
Post by: qwerty on September 04, 2020, 07:12:22 pm
Yes. You should try that manually first. Shape scripts might override any manual setting. Not sure if that applies for per-diagramelement setting. Just give it a try. Only if it works manually you can try to mimic it with a script.

q,
Title: Re: Set color to an element for appearance in all the diagrams
Post by: MatthiasVDE on September 04, 2020, 11:59:35 pm
In what database field the color settings for a diagramobject are stored?
Title: Re: Set color to an element for appearance in all the diagrams
Post by: qwerty on September 05, 2020, 12:54:27 am
The API offers all operations to set colors. The database uses t_diagramobject.styleEx to code color information (only if you dare). I've described some of the details in my Inside book.

q.