Search code examples
scriptingpackageclonejscriptenterprise-architect

Sparx Systems Enterprise Architect Script: Clone a Subpackage to another Package?


I try to wrote a Automation in JScript. If i bin done with creating the structure of 'Package b' then i need the subpackages from 'Package b' in 'Package a' for creating a diagramm of something.

is it possible to clone a Subpackage of for example 'package b' to 'package a'with the API? The Subpackage is a package which includes a lot subpackage more. need not only the "Master"-Subpackage but the complete structure of the package tree of my subpackage.

Package a

Package b  
  --> subpackage b.1     
    -->subpackage b.1.1
    -->subpackage b.1.2
    -->subpackage b.1.3
      -->subpackage b.1.3.1

-->and so on....

Solution

  • Use package.clone() which inserts a copy of the package into the same parent as the original package and returns the newly-created package.