Réserver une Démo

SVP notez : Cette page d’aide n’est pas pour la dernière version d’Enterprise Architect. La dernière aide peut être trouvée ici.

Pré. Proc.

Add and Delete Features

An example of code to add and delete Features of an object.

     Dim element as object
     Dim idx as integer
     Dim attribute as object
     Dim method as object

     'just load an element by ID - you must
     'substitute a valid ID from your model
     element = m_Repository.GetElementByID(246)

     ''create a new method
     method = element.Methods.AddNew("newMethod", "int")
     method.Update
     element.Methods.Refresh
     'now loop through methods for Element - and delete our addition
     For idx = 0 to element.Methods.Count-1
          method =element.Methods.GetAt(idx)
          Console.Writeline(method.Name)
          If(method.Name = "newMethod") Then
               element.Methods.Delete(idx)
          End if
     Next

     'create an attribute
     attribute = element.attributes.AddNew("NewAttribute", "int")
     attribute.Update
     element.attributes.Refresh

     'loop through and delete our new attribute
     For idx = 0 to element.attributes.Count-1
          attribute =element.attributes.GetAt(idx)
          Console.Writeline(attribute.Name)
          If(attribute.Name = "NewAttribute") Then
               element.attributes.Delete(idx)
          End If
     Next