Book a Demo

Author Topic: Alternate image on actors with Shapescript  (Read 4693 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Alternate image on actors with Shapescript
« 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

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Alternate image on actors with Shapescript
« Reply #1 on: November 21, 2020, 05:09:59 am »
You could use another menu name instead of rectangle notation (e.g. flattend stickman ;-)

q.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Alternate image on actors with Shapescript
« Reply #2 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.

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Alternate image on actors with Shapescript
« Reply #3 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
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Alternate image on actors with Shapescript
« Reply #4 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.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Alternate image on actors with Shapescript
« Reply #5 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?

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Alternate image on actors with Shapescript
« Reply #6 on: November 27, 2020, 09:27:46 pm »
Well, you just use DrawNativeShape for the stick man and Rectangle for the other rendering.

q.