Please note : This help page is for an older version of Enteprise Archtiect. The latest help can be found here.

Add and Manage Elements

Topics

Topic

Detail

public Object

 

''Add and delete 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"

   element.Update

   package.elements.Refresh()

 

   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 the example below, 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

       Console.WriteLine(package.elements.GetAt(idx).Name)

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

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

                   package.elements.deleteat(idx, false)

       End If

   Next

End Sub