Book a Demo

Author Topic: packages created by api do not appear in EA  (Read 3837 times)

db

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
packages created by api do not appear in EA
« on: May 18, 2011, 02:23:46 am »
Hi,

I'm trying to create new packages from C# in an existing .eap file. My code looks like this:
Code: [Select]
 EA.Repository r = new EA.RepositoryClass();

  r.OpenFile(@"****.eap");

  EA.Package new_pack = (EA.Package)r.Models.AddNew("NEW_MODEL", "NONE");
  new_pack.Update();
  r.Models.Refresh();
  r.CloseFile();
  r.Exit();


After running this code i'm expecting to get a new root node in the existing file however when i'm opening EA i only see the the original root node (created in EA). I'm sure that the new package is created and is saved to the .eap file because if i run my application more than one time r.Models.Count is increased after each run and if i loop trough the Models i can see the ones i added.

I didn't find any "isVisible" property for EA.Package and searching for the API created package in EA returns nothing.

Am i doing something wrong?

EDIT: the posted code works fine i was writing to a backup copy and checking the original with EA. Sorry for wasting your time.
« Last Edit: May 18, 2011, 06:31:56 pm by db »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: packages created by api do not appear in EA
« Reply #1 on: May 18, 2011, 04:51:09 am »
RTFM: Models

Read only. Models are of type package and belong to a collection of packages. This is the top level entry point to an Enterprise Architect project file. Each model is a root node in the Project Browser and can contain items such as Views and packages.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: packages created by api do not appear in EA
« Reply #2 on: May 18, 2011, 08:32:54 am »
db, all collection properties are marked as readonly.

You can't

Code: [Select]
r.Models = differentCollection
You can

Code: [Select]
r.Models.AddNew("Something", "")
« Last Edit: May 18, 2011, 10:16:19 am by RoyC »