Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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.
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?
-
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.
-
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,
- select the element of interest on a diagram
- Press F4
- Set the "background colour", "border color" or "border width"
- Click OK
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".
-
Michael,
I create the BPMN elements with a script, and I want to automatically give them a color based on a role.
-
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.
-
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?
-
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,
-
In what database field the color settings for a diagramobject are stored?
-
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.