Author Topic: Traverse attribute that is reference to a package  (Read 1025 times)

mvinca

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Traverse attribute that is reference to a package
« on: February 01, 2012, 06:14:20 am »
I'm trying to traverse a document class from the API. The packages that you put into a documentation class show up as attributes, so I'm trying to follow the attribute. I thought I could use the ClassiferID of the attribute to find the package being referenced, but I am getting stuck...

            foreach( EA.Attribute a in source.Attributes )
            {
                EA.Package p = repo.GetPackageByID( a.ClassifierID );

but the GetPackage... causes a error dialog (ID not found).

Anyone know how to find the package object given the document object?

mvinca

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Traverse attribute that is reference to a pack
« Reply #1 on: February 01, 2012, 07:17:59 am »
Okay, this works. Not sure if it is the best solution, but it works...

            foreach( EA.Attribute a in source.Attributes )
            {
                if( a.Type == "Package" )
                {
                    EA.Element pEl = repo.GetElementByID( a.ClassifierID );
                    EA.Package p = repo.GetPackageByGuid( pEl.ElementGUID );
                }

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9618
  • Karma: +279/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Traverse attribute that is reference to a pack
« Reply #2 on: February 01, 2012, 08:38:41 pm »
Yes, you have to remember that in the API a package is both an EA.Package and an EA.Element, and both objects have their own different PackageID/ElementID

Geert