Book a Demo

Author Topic: problems with GetTreeSelectedPackage  (Read 4367 times)

quadrabyte

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
problems with GetTreeSelectedPackage
« on: January 27, 2009, 08:28:29 am »
I've built a code generator add-in. It is working great with one glitch that is frustrating.

Of course, the code generator has to start at the root of the repository structure to walk through all the packages, diagrams, etc. to find all the stuff in the model. If I open a project and run the generator it works fine, finding the root project without problems. If I make some changes to the project, then return to the start page (but with the same project still the currently loaded project) and run the generator it only works properly some of the time. About 50% of the time it works but the other 50% I have to reload the whole project to get it to run properly.

When it works this call gives a root package with several packages in its .Packages collection:

[size=10]   oRootPackage = _oRepository.GetTreeSelectedPackage[/size]

But, when it doesn't work, the oRootPackage is non-null but the .Packages.Count value = 0.

Anyone know why this might be so? Any help appreciated.


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: problems with GetTreeSelectedPackage
« Reply #1 on: January 27, 2009, 08:44:54 am »
Well, it depends on what the user has selected in the tree.  So if the user has a package with no children selected it won't work.

It just happens that if you reload the project it also sets the tree selection.

You may be better off using Repository.Models in order to get consistent results.

quadrabyte

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: problems with GetTreeSelectedPackage
« Reply #2 on: January 31, 2009, 03:21:30 am »
Thanks for the help. I found in the VB example code the way to use the Repository.Models way of getting into the model stuff. Perfect. The fix works great.