Book a Demo

Author Topic: C# - Extracting data from EA model  (Read 4509 times)

AugChin

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
C# - Extracting data from EA model
« on: December 02, 2010, 10:15:35 pm »
Hello, I am newbie in this topic. I am trying to programmatically extract information like class name, function name and their dependency from Enterprise Architect Model and saved it in a file (e.g. Compare.xml). I know that in C# I need to import Interop.EA to have access to everything EA store and also to the diagrams that are generated. In parallel I am trying to parse my source code(C, C #, C or Java) to retrieve the class name, function name and their dependency and save then in the same file (e.g.  Compare.xml).
My goal is to implement a code analyzer. The main task is to check if the architecture models components are implementing in the source code (C, C #, C or Java) at the end a reports will be generated in doc, XML or any other format (e.g. Compare.xml). In this report I will just need to compare if class name, function name and their dependency are similar.
Please I will like to know if there is a tools available who can perform this task.

Thank you

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13442
  • Karma: +570/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C# - Extracting data from EA model
« Reply #1 on: December 02, 2010, 11:03:07 pm »
Hi,

It's definitely possible to do what you need using the API, but I don't think there is a readily available tool that already does something like that.
I suggest you start reading here:http://www.sparxsystems.com/enterprise_architect_user_guide/8.0/automation_and_scripts/automation_interface.html
Then look at the examples in the C:\Program Files\Sparx Systems\EA\Code Samples\C#_Sample directory
And have a look at the addins available from the community site

Geert

AugChin

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: C# - Extracting data from EA model
« Reply #2 on: December 13, 2010, 07:56:39 pm »
Hello Geert ,
Thank you for your answer.
I have a look on this example but I have one problem,I'm not able to get access to operation.
I am able to get the Model and Component name.  how can I get the Operation name(the name of my functions)?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13442
  • Karma: +570/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C# - Extracting data from EA model
« Reply #3 on: December 13, 2010, 08:14:33 pm »
EA.Element.Methods contains a collection of all owned operations (EA.Method). The EA.Method.Name property contains the name of the operation.

Geert

AugChin

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: C# - Extracting data from EA model
« Reply #4 on: December 13, 2010, 09:09:40 pm »
Thank you  :)

AugChin

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: C# - Extracting data from EA model
« Reply #5 on: January 03, 2011, 09:28:47 pm »
Hello Geert ,
Happy New Year 2011.
I will like to know if there is a method that can help to get the EA  Dependency properties. My goal is to retrieve programmatically the interface dependency between components.
Thank you.
AugChin

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13442
  • Karma: +570/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C# - Extracting data from EA model
« Reply #6 on: January 03, 2011, 09:36:07 pm »
Element.Connectors should give you all relations between your element and other things.
Loop that and filter out the required type of relation.

Geert