Book a Demo

Author Topic: Change of object visual appearance based on attribute  (Read 16670 times)

MarcinG

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
    • View Profile
Change of object visual appearance based on attribute
« on: September 23, 2025, 08:45:17 pm »
Hi,

we are stereotyping some of default objects to have a better visual representation for end users.  We would like to include an attribute that would act as a flag that defines either user-friendly appearance (for non-architects) or standard, default appearance.  It should be changeable by the user straight from the attribute, without navigating menus around.
Does anyone have any reference to possible script that could be triggered by attribute change to set the appearance of an object ?

Thanks for any tips,
Marcin

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Change of object visual appearance based on attribute
« Reply #1 on: September 23, 2025, 08:54:49 pm »
What do you mean by Attribute? An actual attribute that appears in the features window?

That would be mixing meta-data with data.

Can't you use the rectangular notation property? That is what it is there for.

If that doesn't work for you, you can define a diagram property (or regular property => tagged value) in your steroetype definition.
You can then change the shapescript to take into account this property to change the notation accordingly.

Geert

MarcinG

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
    • View Profile
Re: Change of object visual appearance based on attribute
« Reply #2 on: September 23, 2025, 09:00:06 pm »
Geert,

thank yo for responding.  I mean an actual attribute that appears in Properties window (for stereotyped objects), which would otherwise be a tagged value (if object is not stereotyped).
Regarding use of rectangular notation - as I explained - some of our users do not understand (and frankly do not need to understand) some of the notations elements.  But if we represent the same high level concept (i.e. application service exchanging data with another application services, specifying which data and how the exchange is realized by certain application component) with some user friendly images - it would help a lot.
Now, it has been done and I have seen it also presented as a part of Sparx Global Summit 2024 (UK Ministry of Defense, if I remember properly).

Cheers,
Marcin

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Change of object visual appearance based on attribute
« Reply #3 on: September 23, 2025, 09:46:00 pm »
In that case I wouldn't call it an attribute, as it is not.

If you want to be able to switch between regulars/user friendly visualization on a diagram by diagram basis, then you need to define a diagram property on your stereotype.
If you want to update the visualization on all diagrams, you can use a regular property (tagged value)

Geert

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1346
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Change of object visual appearance based on attribute
« Reply #4 on: September 24, 2025, 08:48:11 am »
If its simply using different shapes you could do that with custom shapes built into Sparx EA natively. You need to enable the custom diagram toolbar via Start>Preferences>toolbars...>Custom Draw Style to use it.
If you what to do something more fancy like having a graphic represent an object similar to the UK defence demo then you can build that into an MDG using shapescript on the element stereotype which conditions on the stereotype of a diagram. A diagram can then show either the graphic of the native shape depending on value of diagram stereotype. See example below.

I saw that demo from UK defence and looked it was very impressive on what they did but noting it would have also required a lot of work to create an MDG like that.

To reference an image in shapescript associated with a stereotype you need to load the images into the model and have a shapescript that does something like this which I did some time ago for Enterprise Application Integration Patterns. Here is example of file transfer pattern script reference.
https://www.enterpriseintegrationpatterns.com/patterns/messaging/FileTransferIntegration.html
Code: [Select]
shape main
{
layouttype="border";
image("EAI::FileTransfer",0,0,100,100);
addsubshape("name","S");

shape name
{
h_align="center";
print("#NAME#");
}
}

Here is another example of a script that represents an archimate workpackage changing its shape if the diagram has a stereotype of "Sunray" in which case it shows the workpackage as a circle with name outside of shape otherwise the usual archimate workpackage shape. You can probably combine these two to show the image or native shape you want depending on value of diagram stereotype.
Code: [Select]
// Work Package
shape main
{
layouttype="border";
noshadow=true;
if(hasproperty("diagram.stereotype","Sunray"))
{
defsize(20,20);
startpath();
setfillcolor(getuserbordercolor());
ellipse(0,0,100,100);
endpath();
fillandstrokepath();
}
else
{

defsize(90,70);
startpath();
roundrect(0,0,100,100,20,20);
endpath();
fillandstrokepath();
addsubshape("padding","n");
addsubshape("name","center");
}

shape padding
{
preferredheight=20;
}

shape name
{
h_align="center";
v_align="top";
print("#name#");
}

}

shape label
{
setorigin("n",0,0);
if(hasproperty("diagram.stereotype","Sunray"))
{
setorigin("w",0,0);
// print("#alias# - #name#");
print("#name#");
}

}


If you are creating your own MDG there is an example of extending ArchiMate in Git Hub.
You can find the model I originally used to create Archimate Extension on GitHub.
https://github.com/EASunshine/Sparx-EA/
Download the file EAMDGProfile.zip - Has Full EA Model and files, icons etc to create a ArchiMate MDG Extension.
Instructions on how to build the MDG can be found in model.

Noting that creating an MDG is full of traps for young players so hopefully that example will help you up the learning curve.

Hope that helps.
« Last Edit: September 24, 2025, 09:49:20 am by Sunshine »
Happy to help
:)