Author Topic: Running script from an specific Element  (Read 1368 times)

steen.jensen@sll.se

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Running script from an specific Element
« on: January 10, 2018, 03:52:20 am »
Hi all.

Is it possible to have a script in a element ie Artefact or variant of.. That can be started when needed?
that calulates some tagged values from actual diagram.

Or are scripts part of model aka in Database?
Or are script stored in EA client package? has to be deplyed to all EA clients...(as alternate Images..)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8204
  • Karma: +193/-23
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Running script from an specific Element
« Reply #1 on: January 10, 2018, 04:52:52 am »
Scripts are stored in the model.
Depending on the script group the script will appear as an option in the context menu.

Geert

Nabil

  • EA User
  • **
  • Posts: 138
  • Karma: +5/-2
  • Customizing EA for you
    • View Profile
    • View My LinkedIn Profile Here
Re: Running script from an specific Element
« Reply #2 on: January 10, 2018, 04:53:04 pm »
As geert mentioned scripts are stored in model.

but if necessary, you can store scripts in a tagged value of that element.

Best Regards,
Nabil

Sparx Systems India - Services
Ultimate Guide EA14 | Consulting | Training Plans

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6148
  • Karma: +83/-85
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Running script from an specific Element
« Reply #3 on: January 10, 2018, 05:32:48 pm »
As geert mentioned scripts are stored in model.

but if necessary, you can store scripts in a tagged value of that element.

Best Regards,
Nabil
Interesting!  How do they get executed?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Nabil

  • EA User
  • **
  • Posts: 138
  • Karma: +5/-2
  • Customizing EA for you
    • View Profile
    • View My LinkedIn Profile Here
Re: Running script from an specific Element
« Reply #4 on: January 10, 2018, 05:46:30 pm »
Hello Paolo,

We can use context item event to get the script from an element.

We can execute the script using Script Control Class (there are certain limitations)

HTH

Nabil,


Sparx Systems India - Services
Ultimate Guide EA14 | Consulting | Training Plans

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6148
  • Karma: +83/-85
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Running script from an specific Element
« Reply #5 on: January 10, 2018, 06:03:33 pm »
Hello Paolo,

We can use context item event to get the script from an element.

We can execute the script using Script Control Class (there are certain limitations)

HTH

Nabil,
Thanks, Nabil,

so it's not via the UI directly.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8204
  • Karma: +193/-23
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Running script from an specific Element
« Reply #6 on: January 10, 2018, 06:15:13 pm »
Hello Paolo,

We can use context item event to get the script from an element.

We can execute the script using Script Control Class (there are certain limitations)

HTH

Nabil,
Thanks, Nabil,

so it's not via the UI directly.

Paolo

You can use a script to execute the script stored in the tagged value ;) or an add-in.

Geert

Nabil

  • EA User
  • **
  • Posts: 138
  • Karma: +5/-2
  • Customizing EA for you
    • View Profile
    • View My LinkedIn Profile Here
Re: Running script from an specific Element
« Reply #7 on: January 10, 2018, 06:29:52 pm »
Hi Paolo,

Not directly via UI. We need an Addin in this place. But definitely it reduces manual effort & errors once in place.

Cheers,
Nabil

Sparx Systems India - Services
Ultimate Guide EA14 | Consulting | Training Plans

Uffe

  • EA Practitioner
  • ***
  • Posts: 1261
  • Karma: +91/-8
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Running script from an specific Element
« Reply #8 on: January 11, 2018, 09:17:41 pm »
Hej Steen! :)


(Back on T guys. Boring, I know.)

I've answered this question a couple times before; here on this forum and here on Stack Overflow.

TL;DR: scripts can be stored in the project, in each user's installation (don't -- maintenance nightmare), or in MDG Technologies, which is the fancy name for EA's extension facility. For any type of non-hobbyist installation, this is the way to go.

When it comes to having scripts respond specifically to one type of element, yes, you can do that. Such scripts aren't stored in the element itself, but in special script groups called Diagram Scripts or Project Browser Scripts, depending on where you want to invoke them from. (What Nabil is talking about is an adaptation they've done locally, not part of EA's built-in functionality.) Scripts in these groups are automatically made available to users in the context menu (right-click -- Scripts).

The thing with these diagram / project browser scripts is that they cannot be distributed in an MDG Technology: they have to be stored in each project where they're needed. This is a known limitation.

However, a diagram/browser script can call a script that's located in an MDG Technology. So what I always do in these situations is write a very basic diagram/browser script which just checks what type of element (or connector) it's being invoked for, and then pass control to the "real" script which is in an MDG Technology. A typical use case for this setup is when doing generation of complex documents. (Geert prefers a different approach here, I know.)

In your case, what you want is a diagram script which calculates the tagged value based on the diagram it's invoked from and stores the result in the selected element. I'd put all the calculation stuff in an MDG Technology and have the diagram script just check the basics, like that the element is an artifact and that the diagram is the proper type. Of course, if you're just testing stuff you don't need to bother with an MDG Technology, but if you're working on something that needs to be maintainable and/or have some level of protection from accidental changes there's no other option.

But you also said "started when needed." If by this you mean "run manually when the user decides to", what I've outlined above works. If on the other hand you mean "run automatically when something happens" you need an Add-In, which is a piece of software you must write and distribute to all clients. An Add-In can react to events (like elements being created, deleted, or added to a diagram), which scripts can't.

If all of this is a little overwhelming, feel free to PM me. I'm an EA consultant located in Stockholm, and I have extensive experience of large-scale EA deployments.

HTH,


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

steen.jensen@sll.se

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Running script from an specific Element
« Reply #9 on: January 15, 2018, 10:43:14 am »
Perfect Uffe.
Vi hörs  ;)