Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: NewToSparxEA on April 10, 2021, 11:50:21 am
-
Hi, I am attempting to modify Archimate3 MDG to display tagged values but so far I have not been successful. I have done the following so far
1) Followed the instructions in https://sparxsystems.com/resources/user-guides/15.2/modeling/mdg-technologies.pdf to create a profile, using a copy of archimate3.xml MDG file from C:\Program Files...\MDGTechnologies folder, created the stereotype helper and added the following shapescript to display the tagged value.
2) I then exported the profile as a xml and combined it manually with the copy of archimate.xml since I couldn't figure out how to merge the profile.xml I created with the archimate3.xml through sparx.
3) Finally I imported the updated archimate.xml file into a new model and created a new diagram with the archimate element but the tag value didn't come and and it wasn't displayed. Even the line that I coded into the shapescript didn't come through. I am not able to figure out what step I am missing.
shape main
{
DrawParentShape();
MoveTo(0,0);
LineTo(100,100);
if (HasTag("Database"))
{
Println ("#TAG:Database main");
}
}
//Shape ChildElement adds Child Compartments to the parent.
shape ChildElement
{
if (HasTag("Database"))
{
SetCompartmentName("Tags");
Println ("#TAG:Database#");
Println ("Database tag compartment");
}
}
-
Hard to tell without seeing. Println ("#TAG:Database main"); misses a closing # at least. Also, why check to Database and then print Database main?
q.
-
Yes the process of customising Sparx EA isn't for the faint hearted together with a document with 230 odd pages it can be a bit daunting. Sparx EA is not the easiest of tools to customise. As well as the points Qwerty spotted looking at your method I suspect step 2) and 3) are other sources of your problem. You don't need merge the profile or import the xml. You need to create another MDG with your profile in it and point Sparx EA to it to pick it up.
...
2) I then exported the profile as a xml and combined it manually with the copy of archimate.xml since I couldn't figure out how to merge the profile.xml I created with the archimate3.xml through sparx.
3) Finally I imported the updated archimate.xml file into a new model and created a new diagram with the archimate element but the tag value didn't come and and it wasn't displayed. Even the line that I coded into the shapescript didn't come through. I am not able to figure out what step I am missing.
...
I think the way to do it is you create another MDG called ArchiMateExtension.mdg with your profile in it rather than merge.
These are the rough steps I'd try to get that to work.
- Create Stereotype Profiles using Profile Helpers - page 103 to107
- But redefine the stereotype following instructions on p30 and add your script and tagged values
- Save the diagram as a stereotype profile.
- Generate MDG with stereotype profile- p119 You could call the new MDG ArchiMateExtension.mdg for example
- Set up sparx EA to point to the MDG profile via tab Specialise Tab>MDG Technologies, Click Advanced.. button and add path to MDG
- Sparx EA should read the new MDG and redefine the ArchiMate element with your new shapescript and tagged values
when you create new ArchiMate element the redefined script and tagged values should be added after that.
Well that's the theory off the top of my head as I've not tested redefining stereotypes so there may be more to it but hopefully that gets you one step closer to making it work. You may have to specify ArchiMate MDG is required too and thats in the manual.
-
I agree with Sunshine. You shouldn't try to merge MDG files like that.
Follow the instructions to redefine stereotypes https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/redefine_ster_other_prof.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/redefine_ster_other_prof.html)
And don't forget to set your MDG as the "active" one.
Geert
-
Hard to tell without seeing. Println ("#TAG:Database main"); misses a closing # at least. Also, why check to Database and then print Database main?
q.
Hi qwerty, thanks for your response. The print in the main was just for me to see which parts of the shapescript are triggered and which are not, just for debugging purposes :-)
Yes the process of customising Sparx EA isn't for the faint hearted together with a document with 230 odd pages it can be a bit daunting. Sparx EA is not the easiest of tools to customise. As well as the points Qwerty spotted looking at your method I suspect step 2) and 3) are other sources of your problem. You don't need merge the profile or import the xml. You need to create another MDG with your profile in it and point Sparx EA to it to pick it up.
I agree with Sunshine. You shouldn't try to merge MDG files like that.
Follow the instructions to redefine stereotypes https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/redefine_ster_other_prof.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/redefine_ster_other_prof.html)
And don't forget to set your MDG as the "active" one.
Geert
Hi Sunshine and Geert, thanks for your responses to my question as well. I will follow your guidance and post a response if I run into any additional issues.
-
Hi Sunshine and Geert, thanks for your responses to my question as well. I will follow your guidance and post a response if I run into any additional issues.
Hi Sunshine and Geert, I followed your guidance but I was unable to complete the below step from the Sparx EA document. Specifically I was unable to give the Generalization the <<redefines>> stereotype since that option was not available to me - I am on version 15.1 not sure if that is the limiting factor. In any case I decided to leave the relationship as Generalization and completed all remaining steps like you guys mentioned including making the new MDG as active but still no success. I do see a stereotype of "Archimate3_Specialization" to apply to the generalization which I will try next and see if that yields the desired results. If you have any additional thoughts or ideas please do let me know.
Create a Stereotype element with the same name, not fully-qualified. See 'Principle' in the example.
Draw a Generalization from the redefining stereotype to the redefined stereotype, and give the
Generalization the <<redefines>> stereotype.
-
I was unable to give the Generalization the <<redefines>> stereotype since that option was not available to me
Unfortunately, that stereotype doesn't exist in any profile or by default in the model. In the stereotype dialog click 'New...' and type redefines. If you don't have permission to do that, get someone else to do it for you.
Yes, it has been added to EAUML profile for a future version.
-
I was unable to give the Generalization the <<redefines>> stereotype since that option was not available to me
Unfortunately, that stereotype doesn't exist in any profile or by default in the model. In the stereotype dialog click 'New...' and type redefines. If you don't have permission to do that, get someone else to do it for you.
Yes, it has been added to EAUML profile for a future version.
Hi Eve, thanks for this tip. I was able to make progress. I was able to successfully create the profile, publish the MDG, and import the MDG into a new project. I am not able to select the tag name that I created in my profile but I was able to see a part of the shapescript execute. I say only a part since I added some debugging prints which I am able to see. I added a tag value manually but I don't see the compartment for the tag so I need to dig a little further. Also for some reason the archimate elements that I modified are showing a different color (orange) vs the normal green (for technology elements) or blue (for application elements)
Please let me know if anyone has any tips or suggestions.
-
The color is probably due to the options selected when generating the UML profile.
A new tagged value added to your redefining stereotype should show up in the properties window (not on the diagram)
Geert
-
The color is probably due to the options selected when generating the UML profile.
A new tagged value added to your redefining stereotype should show up in the properties window (not on the diagram)
Geert
Thanks Geert. I see it now and after selecting a value from the drop down additional debugging print statements I added in the shapescript are being triggered. My shapescript to display the tag compartment is still not working.
shape main
{
DrawParentShape();
MoveTo(0,50);
LineTo(100,100); //adding this line just to see if shapescript is executing - it is working for me
if (HasTag("Database")) //checking if the tag exists
{
Println ("#TAG:Database main"); //this print is working as soon as I select a value from the drop down
}
}
//the below is not executing
//Shape ChildElement adds Child Compartments to the parent.
shape ChildElement
{
SetCompartmentName("Tags"); //this is to see if the tags compartment name is being added but it's not
if (HasTag("Database"))
{
SetCompartmentName("Tags-New"); // this is to see if the script finds the tag Database
Println ("#TAG:Database#"); //to display the tag name
}
}
-
Have you tried your shapescript on a regular new stereotype?
I know these compartments are a bit of a fuss to get right.
Geert
-
For me it worked. You probably have no child elements with that tag. Again: without seeing it's all guess work.
q.
-
The ChildElement shape script will only be called if the element is drawing compartments, which it won't be because the ArchiMate shape script doesn't. Additionally, it's not doing what you think it is. It's called once for each element owned by the parent, so if the compartments where being shown I suspect you would end up displaying the contents of the tag database for each of the child elements. Not the element you are drawing.
I would start by drawing the native rectangle notation, which will then allow you to enable the tagged value compartment.
shape main
{
layouttype="border";
noshadow=true;
if(hasproperty("rectanglenotation","0"))
{
DrawParentShape();
}
else
{
DrawNativeShape();
}
}
-
The ChildElement shape script will only be called if the element is drawing compartments, which it won't be because the ArchiMate shape script doesn't. Additionally, it's not doing what you think it is. It's called once for each element owned by the parent, so if the compartments where being shown I suspect you would end up displaying the contents of the tag database for each of the child elements. Not the element you are drawing.
I would start by drawing the native rectangle notation, which will then allow you to enable the tagged value compartment.
Hi Eve, thank you so much!! This worked great and the tags are displayed. The minor UI issue is that the elements have overlapping icons other than that the tags are displayed!! Please see image below. Is there any way to fix the overlapping icons?
https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags.png (https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags.png)
-
Unfortunately there isn't any way to fix that. You can't prevent the decoration from the ArchiMate shape script from being drawn and DrawNativeShape means that you get all of the native drawing.
-
Unfortunately there isn't any way to fix that. You can't prevent the decoration from the ArchiMate shape script from being drawn and DrawNativeShape means that you get all of the native drawing.
Hi Eve, Thanks for the guidance. I believe I have found a workaround for this. I followed most of the steps in https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/redefine_ster_other_prof.html (https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/redefine_ster_other_prof.html) except step 1. Instead of creating a stereotype from scratch, renaming it to "Archimate::xxxx" and marking it as abstract I created a metaclass element and selected the stereotype Archimate element I am interested in. When I took this approach the abstract checkbox got selected by default. I completed all the remaining steps, included the script you provided earlier and the decoration issue was resolved. Below are the screen shots from this approach.
https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showTags2.png (https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showTags2.png)
https://github.com/NewToSparxEA/SparxScreenShots/blob/main/alternateImage2.png (https://github.com/NewToSparxEA/SparxScreenShots/blob/main/alternateImage2.png)
-
Unfortunately there isn't any way to fix that. You can't prevent the decoration from the ArchiMate shape script from being drawn and DrawNativeShape means that you get all of the native drawing.
However there are two work arounds;
a) Avoid using DrawNativeShape and write the whole script that does the the shape including your mods.
b) Create you own custom MDG to do all the elements, diagrams and toolboxes
a) will be less work of course so here is my shapescript for an application component to get you started. At the time I needed to create a TIME bubble chart for applications to indicate whether we were going to Tolerate, Invest, Migrate or Eliminate applications so we needed to represent the Application as a circle. Of course now you can do the same thing in Sparx EA using custom draw style.
shape main
{
layouttype="border";
if(hasproperty("diagram.stereotype","BubbleChart"))
{
defsize(100,100);
ellipse(0,0,100,100);
addsubshape("padding","n");
addsubshape("bubblename","center");
}
else
{
defsize(90,70); //
rectangle(0,0,100,100);
addsubshape("padding","n");
if(hasproperty("rectanglenotation","0"))
{
addsubshape("port","w");
}
addsubshape("name","center");
}
shape bubblename
{
h_align="center";
println("#name#");
}
shape port
{
preferredwidth=20;
scalable=false;
rectangle(-10,-10,10,0);
rectangle(-10,10,10,20);
}
shape padding
{
preferredheight=15;
}
shape name
{
h_align="center";
print("#name#");
}
}
decoration component
{
orientation="ne";
if(hasproperty("diagram.stereotype", "BubbleChart"))
{
return;
}
if(hasproperty("rectanglenotation","0"))
{
return;
}
else
{
rectangle(0,0,60,100);
rectangle(-10,10,10,30);
rectangle(-10,50,10,70);
}
}
decoration composite
{
orientation="SE";
if(hasproperty("diagram.stereotype", "BubbleChart"))
{
return;
}
if(hasproperty("iscomposite","true"))
{
ellipse(0,40,40,60);
ellipse(60,40,100,60);
moveto(30,50);
lineto(70,50);
}
}
-
a) Avoid using DrawNativeShape and write the whole script that does the the shape including your mods.
Except that DrawNativeShape is the only way you will get the compartments, which is the whole point of this thread.
Maybe a better idea is to use your script to print specific tagged values instead of trying to get the compartment to show all of them.
-
a) Avoid using DrawNativeShape and write the whole script that does the the shape including your mods.
Except that DrawNativeShape is the only way you will get the compartments, which is the whole point of this thread.
Maybe a better idea is to use your script to print specific tagged values instead of trying to get the compartment to show all of them.
Oh yeah you're right, I forgot mention not to bother with compartments in that last post. How absent minded of me, thanks Eve.
-
a) Avoid using DrawNativeShape and write the whole script that does the the shape including your mods.
Except that DrawNativeShape is the only way you will get the compartments, which is the whole point of this thread.
Maybe a better idea is to use your script to print specific tagged values instead of trying to get the compartment to show all of them.
Is there anyway to remove the angle brackets and text within << and >> in the display? In the screen shots below the text <<Archimate_Node>> and <<Archimate_Device>> are added above the element name.
https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags.png (https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags.png)
https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags2.png (https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags2.png)
-
Is there anyway to remove the angle brackets and text within << and >> in the display? In the screen shots below the text <<Archimate_Node>> and <<Archimate_Device>> are added above the element name.
https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags.png (https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags.png)
https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags2.png (https://github.com/NewToSparxEA/SparxScreenShots/blob/main/showsTags2.png)
Diagram Properties > Elements > Show Element Stereotypes = OFF
It will affect all elements on the diagram.
-
Diagram Properties > Elements > Show Element Stereotypes = OFF
It will affect all elements on the diagram.
That is awesome - everything is working as expected now. Yay!! ;D Thank you so much KP!
Also a big thank you to Sunshine, Geert and Eve for guiding and solving this problem for me!! :) :)
-
Glad to hear you worked it all out in the end. Have a great weekend.
-
Hi All, we recently upgraded Sparx from 15.1 to 15.2. The database repository was upgraded using the script from Sparx https://sparxsystems.com/downloads/corp/scripts/EASchema_1558_SQLServer.sql (https://sparxsystems.com/downloads/corp/scripts/EASchema_1558_SQLServer.sql). The script was run successfully and there were no errors. The software was also upgraded and I was able to connect to the upgraded database repository. There were no issues opening and modifying any of the diagrams. However when I make changes to the MDG (which is also stored in the DB repository), publish and import the published MDG into the model the changes to the MDG are not displaying. Is there anything that needs to be upgrade the MDG from 15.1 to 15.2? Thanks in advance for your help!
-
For existing elements you'll need to synchronise the stereotypes you changed. Do this by right clicking on the element in the tool box and choose synchronize stereotype. New elements should implement the change
-
For existing elements you'll need to synchronise the stereotypes you changed. Do this by right clicking on the element in the tool box and choose synchronize stereotype. New elements should implement the change
Hi Sunshine, thanks for your input but that didn't solve the issue. I did reach out to Sparx support on this issue and they helped identify the problem. In the steps to create the MDG technology a fully qualified path for the .mts file and .xml file is required. When I provided the fully qualified path I was able to complete the steps without any issues.