Author Topic: Automate creation of component diagrams  (Read 1971 times)

harshvir

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Automate creation of component diagrams
« on: February 12, 2018, 10:59:21 pm »
Hi

I frequently need to create component diagrams as part of my work using components and interfaces which are already available in the tool as part of my organization's library.
I am not a fan of drawing by dragging/dropping these components/interfaces.
I was wondering if there is any way to write a piece of code which can read component/interface details from a document or excel and generate a component diagram in EA tool?
Has anyone tried this kind of functionality or come across any post on similar subject?
Any thoughts/suggestions will be helpful.

Nizam

  • EA User
  • **
  • Posts: 301
  • Karma: +9/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Re: Automate creation of component diagrams
« Reply #1 on: February 12, 2018, 11:22:41 pm »
Try scripting. just add information in an Excel and let your script do the rest.

qwerty

  • EA Guru
  • *****
  • Posts: 9685
  • Karma: +176/-150
  • I'm no guru at all
    • View Profile
Re: Automate creation of component diagrams
« Reply #2 on: February 13, 2018, 12:03:07 am »
It's not that easy. Importing data into EA is one (easy) thing. But creating a useful layout is another one. This is very tricky and will take you quite some time to develop layout rules that you can code.

q.

Eamonn John Casey

  • EA User
  • **
  • Posts: 107
  • Karma: +0/-1
    • View Profile
Re: Automate creation of component diagrams
« Reply #3 on: February 13, 2018, 12:20:35 am »
Scripting is  the way to go. There are some EA wrappers on GitHub to get you started.

Here is a wraper (and diagram code) I have made and used.

https://github.com/EamonnJCasey/Sparx-Enterprise-Architect-Wrapper

Using the Diagram Loayout functionality was not good enough. So there is alot of coordinates to keep track of.

Enjoy,
Eamonn J.

Nabil

  • EA User
  • **
  • Posts: 138
  • Karma: +5/-2
  • Customizing EA for you
    • View Profile
    • View My LinkedIn Profile Here
Re: Automate creation of component diagrams
« Reply #4 on: February 13, 2018, 01:33:31 am »
With the combination of  MDG Office Intergration and scripting you can do it in few minutes.

Check MDG office integration https://sparxsystems.com.au/products/mdg/int/office/office-integration.html. you can avail a trial license

Then with script you create a diagram for each component/interface
Refer Scripting window Local scripts - Manage Diagrams Example (testElement.Diagrams.AddNew("My Logical Diagram", "Logical") to add a digram

P.S
If you need to make element composite - testElement.IsComposite = true
Set diagram guid to element - testElement.SetCompositeDiagram(Dia GUID)

Cheers
Nabil

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

harshvir

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Automate creation of component diagrams
« Reply #5 on: February 14, 2018, 05:46:56 pm »
Thanks all for your valuable replies. As expected, scripting is the common ways suggested by all. Can anyone help on queries mentioned below:

1. I am new to EA tool and don't have a very strong coding background - what would be the best way to start learning about this? Links to resources will be really helpful. I am really keen to make this work.

2. I access EA tool through citrix. It is hosted on secure network and not installed on my machine. Will it be possible for me to use scripts in this environment.

Regarding the use Office MDG integration, unfortunately, I don't think I will get approval for additional licence costs involved. I am using corporate edition at present. If I download trail version, will it work with EA tool hosted on cloud?

Really looking forward to suggestions on getting started with this. Please share your views on above options. Any fresh ideas are also welcome.
« Last Edit: February 14, 2018, 05:53:29 pm by harshvir »

Arshad

  • EA User
  • **
  • Posts: 131
  • Karma: +6/-1
    • View Profile
Re: Automate creation of component diagrams
« Reply #6 on: February 14, 2018, 06:08:07 pm »
Hi harshvir

EA itself provides lot of sample scriptings.

To Access Code -> Tools -> Scripting -> Scripts
In the scripts tab you can find the Local Scripts Folder under which you can find sample VBScript and Jscripts.
You can refer Manage Diagram Example and Manage Elements Example for creating your own script for creating component diagrams.

For more details on scripting please refer
http://sparxsystems.com/enterprise_architect_user_guide/13.0/automation/the_scripter_window.html

I don't think I will get approval for additional licence costs involved. I am using corporate edition at present. If I download trail version, will it work with EA tool hosted on cloud?
Yes it will work as an extension for the enterprise architect.
you just need to connect the hosted model in EA as usual and in Extension you can find the MDG Office Installed.



Arshad
« Last Edit: February 14, 2018, 06:12:58 pm by Arshad »

Sparx Systems India - Services
Profile | Training PlansConsulting

qwerty

  • EA Guru
  • *****
  • Posts: 9685
  • Karma: +176/-150
  • I'm no guru at all
    • View Profile
Re: Automate creation of component diagrams
« Reply #7 on: February 14, 2018, 06:53:04 pm »
As you said that you don't have strong coding background I'd recommend to re-read my first comment.

q.

harshvir

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Automate creation of component diagrams
« Reply #8 on: February 14, 2018, 09:09:14 pm »
Thanks a lot Arshad.

Hi qwerty, yes I read that but this is something I need to develop.

It will be helpful if you could provide some alternative way to achieve this or any references/concepts/starting points which I should be aware of before I can develop this feature using scripts.
I don't want to shelve this plan unless someone says that they have already tried what I am asking for but it is impossible to meet.

Arshad

  • EA User
  • **
  • Posts: 131
  • Karma: +6/-1
    • View Profile
Re: Automate creation of component diagrams
« Reply #9 on: February 14, 2018, 09:16:37 pm »
Hi

I frequently need to create component diagrams as part of my work using components and interfaces which are already available in the tool as part of my organization's library.

How frequently you will create diagrams ?
Do you want a diagram created for each interfaces ?

Sparx Systems India - Services
Profile | Training PlansConsulting

qwerty

  • EA Guru
  • *****
  • Posts: 9685
  • Karma: +176/-150
  • I'm no guru at all
    • View Profile
Re: Automate creation of component diagrams
« Reply #10 on: February 14, 2018, 09:50:20 pm »
I really would stay with a manual and only partially script-supported approach. Importing data from some external source and placing them "somewhere" on a diagram is really easy. You could then also automatically call the layout, but do not expect anything you could live with, especially with component diagrams where you have connected ports. EA's layout just does ignore ports (I guess, because their layout is extremely complicated). I once wrote a script to support port layout. It was not too complicated and helped a lot when doing layout. It's some Perl script I still might have lying around somewhere.

You should try the above manually first. Just drop some components you already have on a diagram and try the auto-layout. You will likely be disappointed with the result. Now start thinking how you could improve that. Getting some decent result will easily add up in a couple of weeks programming.

q.

Eamonn John Casey

  • EA User
  • **
  • Posts: 107
  • Karma: +0/-1
    • View Profile
Re: Automate creation of component diagrams
« Reply #11 on: February 20, 2018, 05:38:24 am »
harshvir

>> 1. Strong Programming skills.
I have fumbled my way through the documentation og the EA API and definitly used this forum MANY times. When scripting diagram generation it was the complexity of X,Y coordinates and ensuring nothing overlaps. Enterprise Architect Diagram Layout usually gives very bad results in my opinion.

>> 2. Citrix
We use a locked down network as weill. To "program on the outside" you'll need an development environment like SharpDeveloper. Not an option here (or for me). Luckily we develop alot of our own software for ourselves - so we got a developer environment With more freedom. Don't have one? Then you will need to "program on the inside" within EA as indicated by Arshad.

Another tip: You can use EA to reverse engineer the database to discover attributes that are not available in the API. The EA API responds With JSON format. But using JSon2CSharp free online convert you get classes to deserialise anything.

Check out my GitHub link I sent. I admit I am no guru either but thankfully we got Internet.

/ EjC //