Book a Demo

Author Topic: shape script based on tagged value relationship  (Read 4273 times)

PeterKuipers

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
shape script based on tagged value relationship
« on: September 02, 2020, 08:57:03 pm »
Hi all,

I have objects in my repository that are visible on more than one view, based on the Scope of Interest. In the one view the object is within the kernal, in another view the object is on the boundary and on a third view the object is in the environment. Based on the location of the object for that view, the shape should be different, so I wanted to solve this with the shape script.

In the MDG I have created a relationship between the object class and a SoI class. The object can be on multiple SoI's, so the relationship has a tagged value choosing between "kernal, boundary and environmental". The tagged value is "EE::elementtype".

The source of the relationship is the object. The target of the relationship is the SoI (instance) and the diagram the object is displayed on is a composite diagram of that SoI instance.



How can I use this tagged value, of the relationship between the object and the SoI in a shape script?

Thanks in advance,

Peter
« Last Edit: September 03, 2020, 06:07:30 pm by PeterKuipers »

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 script based on tagged value relationship
« Reply #1 on: September 02, 2020, 10:23:01 pm »
Peter,

You can access the tagged value in a shapescript with
So something like

Code: [Select]
    If(HasTag("elementtype","kernel"))
    {
     //draw something
    }

The thing is that you can only use that on the shapescript for the thing the tagged value is on.
So if the tagged value is defined on the relationship, you can only do this on the shapescript for the relationship, not in the shapescript for the source or target element.

If you want to do something like that you would need an add-in call in you shapescript.
Be very careful with those as this will be called a lot when showing diagrams; so it should really be a very fast function.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: shape script based on tagged value relationship
« Reply #2 on: September 02, 2020, 11:50:43 pm »
Hello,

If you want to do something like that you would need an add-in call in you shapescript.
Be very careful with those as this will be called a lot when showing diagrams; so it should really be a very fast function.

You can't make it fast enough. The vast majority of the execution is outside your control, so any optimization you can bring to bear on your Add-In function is irrelevant.
Add-In callbacks in shape scripts are a cute demo function, but Do Not Work in a production setting. EA is too flexible and you don't know where things will end up a couple of years down the line. So don't go down this route. You will regret it.

I would rather suggest you consider changing your representation.

Instead of a single element exhibiting different visual behaviour in different diagrams, you could create different elements for the different contexts. These could be either instances or specializations of one "context-free" element which holds the actual definition. Both of these relationships are supported by UML and EA, and allow for some inheritance of properties from the context-free to the context-dependent elements.


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

PeterKuipers

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: shape script based on tagged value relationship
« Reply #3 on: September 03, 2020, 06:21:57 pm »
Geert and Uffe, thanks for your replies.

I would like to go for the option to have a "context free" element, to be controlled in the project browser and use specialisations that change the appearance on the different views (Scope of Interests, SoI).

Could you help me to set that up? I am really new on this area.

Every diagram type "CSD" that will be created by the user is one on one a new SoI. Every use of the "contect free" element from the project browser should be a specialisation that inherits the properties of the basic element and have properties that determine the shape based on the shape scripts. So every SoI has a separate diagram and per object is determined element type: kernal, boudary or environmental.

I can share some examples if I know how to include attachments in this topic.

Thanks in advance,

Peter

PeterKuipers

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: shape script based on tagged value relationship
« Reply #4 on: September 03, 2020, 08:25:46 pm »
I have experimented a bit and made a specialisation in my MDG.

I have the option to put both in the toolbox.

What I want to achieve is that the project browser has object "GUID 4711" and the user is able to put an object on the diagram with all properties of that object "GUID 4711" and is able to change the property "Element Type" of the specialisation only.

This I have not achieved yet.

Peter

PeterKuipers

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: shape script based on tagged value relationship
« Reply #5 on: September 06, 2020, 07:54:05 pm »

Instead of a single element exhibiting different visual behaviour in different diagrams, you could create different elements for the different contexts. These could be either instances or specializations of one "context-free" element which holds the actual definition. Both of these relationships are supported by UML and EA, and allow for some inheritance of properties from the context-free to the context-dependent elements.


/Uffe

Dear Uffe,

I would like to go for your suggested option.

Can you help me out, how I can make a MDG object inherit properties from the clean maintained object in the project browser and let the user of the MDG select that object to make a specialisation of it and fill in the context properties?

Thanks advance,

Peter
« Last Edit: September 06, 2020, 07:55:47 pm by PeterKuipers »