Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Fabio Riera on July 10, 2013, 11:06:17 pm
-
Hi there,
I'm creating an add-in for EA. One of my tasks is to duplicate a package (ctrl-C & ctrl-V) in project browser. How I do this task using the Repository object? The package to be duplicated is the object in context. Thanks in advance.
-
Check the package.clone method.
q,
-
Thanks! And how I move the cloned package to another package? By changing its ParentID?
-
Hi Fabio,
be aware: It may be no problem to clone a package. But I think this clone don't create new elements as it's content (shallow copy).
So you probably have to recursively dip into the package structure and clone all the elements and packages.
Helmut
-
I'm pretty sure it does, package.Clone has often been suggested as the solution to copying elements, but it would be nice to get a confirmation.
Geert
-
I just tried it. clone works recursively.
q.
-
Hello,
I'm trying with this code:
const int SOURCE_PACKAGE_ID = 227375;
Package pckSource = MyRepository.GetPackageByID(SOURCE_PACKAGE_ID);
Package pckClon = pckSource.Clone();
But pckClon is always null.
What I'm doing wrong?
-
I tried it with VB and it works. You're missing an update at the end.
Maybe it's a security issue? Have you turned on security?
q.