Reputation: 198
I am creating new packages using the Object Model and C#. I am creating packages with subpackages recursively, and that works fine. However, my changes don't show up in EA after the script is done working unless I manually refresh the project with ctrlshiftF11, after which my created packages show up as intended.
I am updating the newly created package newPackage.Update();
, aswell as refreshing the packages of the parent package parentPackage.Packages.Refresh();
.
After recursively creating all the packages I additionally call Model.Update()
, Repository.Models.Refresh();
, Model.Packages.Refresh();
aswell as Repository.Exit()
.
EA seems to redraw the view, but doesn't show the newly created packages.
Am I missing any call at the end that updates the view?
I'm using this code:
eaApplication = new EA.App(); // Create interface to EA
eaRepository = eaApplication.Repository;
eaRepository.EnableUIUpdates = true;
eaRepository.OpenFile(pathToEAPfile)
EA.Package eaModel = eaRepository.Models.GetAt(0);
EA.Package testModelPackage = (getting it via for loop);
EA.Package newPack = testModelPackage.Packages.AddNew("foopackage", "System.__ComObject");
newPack.Update();
testModelPackage.Packages.Refresh();
eaRepository.RefreshModelView(0);
eaRepository.Exit();
Upvotes: 1
Views: 75
Reputation: 36305
I suppose you call this from an external application. Any EA client does not receive notice of underlying database updates. Only when the user explicitly reads the appropriate parts.
You either need to run the above code inside EA as add-in or refresh manually.
Answer to initial question: The following was a reply to the initial vague question. I leave that for reference by others.
Call
Repository.RefreshModelView(0)
to reload the whole view from root on. Or pass the PackageId of the package you want to refresh.
N.B. All your additional calls are superfluous. Call Update()
only for objects that have changed. The Refresh()
calls are only needed if you traverse a changed collection afterwards (after addition or deletion of objects).
Upvotes: 1