Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Guillaume on November 21, 2020, 03:13:48 am

Title: Alternate image on actors with Shapescript
Post 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:

Code: [Select]
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

Title: Re: Alternate image on actors with Shapescript
Post by: qwerty on November 21, 2020, 05:09:59 am
You could use another menu name instead of rectangle notation (e.g. flattend stickman ;-)

q.
Title: Re: Alternate image on actors with Shapescript
Post by: Guillaume on November 23, 2020, 06:49:16 pm
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.

Title: Re: Alternate image on actors with Shapescript
Post by: Uffe on November 23, 2020, 07:13:31 pm
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
Title: Re: Alternate image on actors with Shapescript
Post by: qwerty on November 23, 2020, 07:30:19 pm
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.
Title: Re: Alternate image on actors with Shapescript
Post by: Guillaume on November 27, 2020, 07:33:00 pm
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?

Title: Re: Alternate image on actors with Shapescript
Post by: qwerty on November 27, 2020, 09:27:46 pm
Well, you just use DrawNativeShape for the stick man and Rectangle for the other rendering.

q.