Book a Demo

Author Topic: Shape scripts for UML profile I created  (Read 5382 times)

DHow

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Shape scripts for UML profile I created
« on: November 24, 2015, 09:11:34 am »
I created a UML profile for a class I defined.  I added an attribute to that class called "Lifecycle".  I would like the shape script to display that attribute's value.  I see how shape scripts can display basic content like name using the following code: println("name: #name#");

How can I access the value of the attribute I added so the shape script can display it?

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape scripts for UML profile I created
« Reply #1 on: November 24, 2015, 09:26:49 am »
There's bad news and there's good news.

The bad news is that shape scripts can't display attributes.

The good news is that they can display tagged values. If, instead of having an attribute called Lifecycle, you have a tagged value called Lifecycle, you can display it in a shape script with: print("Lifecycle: #tag:lifecycle#");
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Shape scripts for UML profile I created
« Reply #2 on: November 24, 2015, 10:12:45 am »
You could use an add-in to get the information. Of course this is by far more effort.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Shape scripts for UML profile I created
« Reply #3 on: November 24, 2015, 07:23:32 pm »
Quote
You could use an add-in to get the information. Of course this is by far more effort.
Also quite drastically inefficient. There's (apparently) no caching so think twice before you use an AddIn-backed shape script if you will be placing large numbers of elements in a single diagram and accessing the repository over a LAN.

But if the shape you're drawing is essentially the same as the non-stereotyped one but with some minor alterations, like border colour based on status or a decoration based on phase or something like that, you might be able to use drawnativeshape() or drawparentshape().

/U
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Shape scripts for UML profile I created
« Reply #4 on: November 25, 2015, 06:12:24 am »
I think it doesn't make much sense to use attribute information in shape scripts.

How can you know which attributes to expect? UML profiles and shapescripts are working on the meta-level, so logically you should only need the info on the meta-level to make your shapescript.

Attributes on Stereotypes (meta-level) are translated into tagged values on the model level.
And there are method to query the existence and value of the tagged values in your shapescript.

Geert