Author Topic: EA Object Model - can not find diagram in a directory  (Read 37 times)

Viking

  • EA User
  • **
  • Posts: 255
  • Karma: +1/-2
    • View Profile
EA Object Model - can not find diagram in a directory
« on: December 07, 2018, 10:12:36 pm »
Hello experts,

I have a very simple problem, so I thought at least. I have a directory in SparxEA. In the directory is a diagram. The C#-program identified the directory by GUID via EA Object model (I do not know the GUID of the diagram). But both attributes Diagrams and Elements of the directory-object are empty (Collection with 0 items). Can somebody tell me how I can retrieve the diagram?

Many thanks in advance, V.

Element anElement = aRepository.GetElementByGuid(aGUID);
foreach (EA.Diagram aDiagram in anElement.Diagrams) {  }

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8601
  • Karma: +210/-26
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA Object Model - can not find diagram in a directory
« Reply #1 on: December 07, 2018, 11:05:22 pm »
What you call "Directory" is a Package I guess?
A package is a bit of a weird object. Each package (except for root packages) has a EA.Element as well. So there are two objects in the API that represent one thing.
You are now looking at the EA.Element portion of the package, and the diagrams are found in the diagrams collection of the Package object.

So you'll have to use Repository.GetPackageByGUID, and check the Diagrams collection of the Package object.

Geert


Viking

  • EA User
  • **
  • Posts: 255
  • Karma: +1/-2
    • View Profile
Re: EA Object Model - can not find diagram in a directory
« Reply #2 on: December 07, 2018, 11:45:13 pm »
Many, many thanks Geert. I will try. Yes, directory = package.