Author Topic: Trying to create some kind of automation in EA  (Read 2026 times)

mr nobody 11

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Trying to create some kind of automation in EA
« on: December 08, 2022, 10:54:56 pm »
https://ibb.co/J5K80Gn
https://ibb.co/JKPzsrg

Hi Dear EA users,

It is been 1 and half month I have been working with EA. I have a specific problem in my mind and I want to ask for your advice.

I am currently working on extending UML and creating my own MDG technology. I came to a point where I need to make things easier for the user of my MDG technology. Now, I will try to explain my work and my problem.


I have an action <<ArithmeticExpression>> (I extended UML::Action with something called ArithmeticExpression). And this specific action takes two inputs and you are able to choose an operator(it can be seen on the first link). I have my own custom diagram and custom toolbox and this arithmeticExpression action is an item in my custom toolbox. On the second link, you can see a model diagram which shows artihmeticExpression actions one after another. An arithmeticExpression itself can be chosen as an "operand" for another arithmeticExpression.

So, the goal is to model a mathematical formula. Since one ArithmeticExpression action can do one operation, if I have a very big mathematical formula, the user will have to create so many ArithmeticExpression actions one after another. It is time consuming and not user friendly.

What I want to do is the following: I want another item in my custom toolbox(can be called "MathematicalFormula"), and the user will enter the formula as an input to this new item. Then, EA will automatically create the corresponding ArithmeticExpressions inside the project browser window.

To do this, I need an algorithm(this is not what I ask), and a way to do this automation I explained above. However, I  do not know a way to this automation. I feel like I need a script that does this job, and somehow I need to add this script inside my technology. And this script should be able to read(how?) the input of this new item "MathematicalFormula", then should be able to create(how?) ArithmeticExpression actions in the browser window(I want to know how to do these).

I kindly ask you to give me some references because I do not where to start. I would appreciate if you tell me related EA tools that I need to look into, if this automation is possible.



Best,

mr nobody 11

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Trying to create some kind of automation in EA
« Reply #1 on: December 08, 2022, 11:11:41 pm »
You would need to implement an input dialog (there are many ways) and read the formula. Then you have to write a parser for that formula (which can be from very simple to very complex depending on what your requirements are). Once you parsed the expression you can create the according elements. No rocket science but a bit of work fur sure.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Trying to create some kind of automation in EA
« Reply #2 on: December 08, 2022, 11:23:30 pm »
You can't really do all of that in an MDG.

The simplest solution would be to create a script, and have the user enter the formula into a text field (notes?) of an element.
You could even create a new stereotype for such a formula object?

If you put your script into an Element type group, you can execute this script from the context menu when right clickign on such an element.

The rest is as q mentioned; parsing the formula and creating the elements.

The "better" solution would be to write an add-in for this. You can even include the MDG as part of the add-in. (see https://github.com/GeertBellekens/Enterprise-Architect-Toolpack/tree/master/EAJSON for an example)
From an add-in you can provide some kind of input box/window and provide feedback and stuff like that.

As the business logic does not seem trivial, I would probably prefer to use the add-in approach; only because then you can use C#, OO, Visual Studio and Git.

But it can also be done in scripting. I once wrote a (partial) OCL parser in VBScript: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/tree/master/Framework/OCL to support a migration from a MagicDraw model to EA.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Trying to create some kind of automation in EA
« Reply #3 on: December 09, 2022, 12:00:02 am »
OCL parser in VBScrip
You must be pain free, I guess...

q.

mr nobody 11

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: Trying to create some kind of automation in EA
« Reply #4 on: December 09, 2022, 12:18:28 am »
Thank you very much for your feedback. Before giving you a proper response, I should do some research about the terms you mentioned to solve my problem. At least, I feel like I have a direction, now. I appreciate a lot for your time and feedback.

Best,

mr nobody 11

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Trying to create some kind of automation in EA
« Reply #5 on: December 09, 2022, 12:31:39 am »
OCL parser in VBScrip
You must be pain free, I guess...

q.
Worse, I even enjoyed writing that part a lot  ;D

Once you're used to the somewhat bizarre syntax, the lack of inheritance, and the fact that you can't use autocomplete for anything else than EA's API, its just another programming language.
You can write garbage or gems in any language. I consider this part to more gem-like than garbage-like.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Trying to create some kind of automation in EA
« Reply #6 on: December 09, 2022, 12:40:49 am »
Then you should give it a try with Brainfuck or Whitepspace. That would probably be real fun (if you're a masochist).

q.