Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Guillaume on November 21, 2020, 03:13:48 am
-
Hi,
I'm using stereotyped actors and I needed to find a way to show an image as an alternative to the stickman.
So I wrote the following shapescript:
shape main{
if (HasProperty('rectanglenotation', '0')) {
Image("img",0,0,100,100);
return;
}
else {
DrawNativeShape();
return;
}
}
It works well except that I'm getting 2 options to set/unset the Rectangle notation (one being the rectangle/stickman switch, the other one being the image on/off switch). This is not a major issue but is there somehow a way to force a different menu name ?
thanks
-
You could use another menu name instead of rectangle notation (e.g. flattend stickman ;-)
q.
-
Interesting but how can I do this?
I changed "if (HasProperty('rectanglenotation', '0')) {..." with "if (HasProperty('DisplayImage', '0')) {" but this disables the Use Rectangle Notation menu.
-
Hi Guillaume,
Presumably the rectangle notation menu is enabled if that property is referenced in the script.
So try just putting the RectangleNotation check back, and try nesting it with the DisplayImage check (both ways).
I'm not aware of any way of adding your own menu items through shape scripts.
If you're getting two Use Rectangle Notation menu items under any circumstances, that's a bug.
HTH,
/Uffe
-
Interesting but how can I do this?
I changed "if (HasProperty('rectanglenotation', '0')) {..." with "if (HasProperty('DisplayImage', '0')) {" but this disables the Use Rectangle Notation menu.
You need to declare that property in the stereotype definition property stereotyped with «diagram property». The Alias is used in the script and the name appears in the context menu.
q.
-
I gave it a go with the "diagram property" stereotyped attribute as per the "Query Methods" online help and it indeed works well.
I noticed that it disables the actor rectangle notation.
If I was to add a "diagram property" RectangleNotation attribute, could I tell in the Shapescript to apply the rectangle or stickman notation?
-
Well, you just use DrawNativeShape for the stick man and Rectangle for the other rendering.
q.