Author Topic: Problem creating packages  (Read 2870 times)

avantol13-2

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Problem creating packages
« on: November 07, 2014, 02:30:49 am »
I just want to create a package underneath another package.

Code: [Select]
// Get the current package.
EA.Package package = repository.GetTreeSelectedPackage();
            
// Add a new package.
EA.Package newPackage= (EA.Package)repository.Models.AddNew("New Package Name", "Package");
newPackage.ParentID = package.PackageID;
newPackage.Update();

I get a package but it's at the root level and not under the package I have selected in the project browser.

Thanks,
Alex
« Last Edit: November 07, 2014, 06:43:11 am by avantol13-2 »

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Problem creating packages, am I missing somthi
« Reply #1 on: November 07, 2014, 03:33:10 am »
You need to add your new item to the packages collection of the package

i.e.   newPackage = myExistingPackage.Packages.AddNew(...)

EXploringEA - information, utilities and addins

avantol13-2

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Problem creating packages, am I missing somthi
« Reply #2 on: November 07, 2014, 03:35:27 am »
Yes! That was it. Thank you!