Author Topic: Accessing packages of newly created package  (Read 2645 times)

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Accessing packages of newly created package
« on: April 08, 2015, 11:01:01 pm »
I've got the following code which creates a new EA Model and a subpackage to that model. However it seems like the subpackage is only updated/created "visually" - by that I mean that I can see it in EA but if I try to get the packages of my new root it returns 0 which should be 1.

            var root = eaRepo.Models.AddNew("A New Root", "");
             root.Update ();
            eaRepo.Models.Refresh();

            Package newPackage = root.Packages.AddNew("New Package", "Package");
            newPackage.Update();
            eaRepo.Models.Refresh();

            var packages = root.Packages.Count; //Returns 0 but I just created one

Any suggestions on why this doesn't work?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Accessing packages of newly created package
« Reply #1 on: April 09, 2015, 02:04:04 am »
If you print eaRepo.Models.count rather than root.Packages.Count you should be fine. Alternatively refresh root.packages instead.

q.
« Last Edit: April 09, 2015, 02:04:52 am by qwerty »