Add and Manage Elements

This is an example of the code for adding and deleting elements in a Package.

     Sub ElementLifeCycle

          Dim package as Object

          Dim element as Object

          package = m_Repository.GetPackageByID(2)

          element = package.elements.AddNew("Login to Website","UseCase")

          element.Stereotype = "testcase"



          Dim idx as integer

          ''Note the repeated calls to "package.elements.GetAt."

          ''In general you should make this call once and assign to a local

          ''variable - in this example, Enterprise Architect loads the

          ''element required every time a call is made - rather than loading once

          ''and keeping a local reference.

          For idx = 0 to package.elements.count-1


               If (package.elements.GetAt(idx).Name = "Login to Website" and _

                    package.elements.GetAt(idx).Type = "UseCase") Then

                         package.elements.deleteat(idx, false)

               End If


     End Sub