Work With Attributes [Enterprise Architect User Guide]

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Work With Attributes




public Object


''An example of working with attributes.


Sub AttributeLifecycle


   Dim element as object

   Dim o as object

   Dim t as object

   Dim idx as Integer

   Dim idx2 as integer


       element = m_Repository.GetElementByID(129)


       For idx = 0 to element.Attributes.Count -1


           Console.WriteLine("attribute=" + element.Attributes.GetAt(idx).Name)


           o = element.Attributes.GetAt(idx)

           t = o.Constraints.AddNew("> 123","Precision")



           For idx2 = 0 to o.Constraints.Count-1

               t = o.Constraints.GetAt(idx2)

               Console.WriteLine("Constraint: " + t.Name)

               If(t.Name="> 123") Then

                   o.Constraints.DeleteAt(idx2, false)

               End if



           For idx2 = 0 to o.TaggedValues.Count-1

               t = o.TaggedValues.GetAt(idx2)

               If(t.Name = "Type2") Then


                   o.TaggedValues.DeleteAt(idx2, true)

               End if



           t = o.TaggedValues.AddNew("Type2","Number")



           For idx2 = 0 to o.TaggedValues.Count-1

               t = o.TaggedValues.GetAt(idx2)

               Console.WriteLine("Tagged Value: " + t.Name)



           If(element.Attributes.GetAt(idx).Name = "m_Tootle") Then

               Console.WriteLine("delete attribute")

               element.Attributes.DeleteAt(idx, false)

           End If






   catch e as exception



   End try

End Sub