Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: avantol13-2 on November 07, 2014, 02:30:49 am

Title: Problem creating packages
Post by: avantol13-2 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
Title: Re: Problem creating packages, am I missing somthi
Post by: EXploringEA 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(...)

Title: Re: Problem creating packages, am I missing somthi
Post by: avantol13-2 on November 07, 2014, 03:35:27 am
Yes! That was it. Thank you!