Hi Guys,
I can't figure out how c I select the element in the browser tree after adding new attributes to the element?
My code will select the newly added attribute in the Class, and I'd like to select the parent Class where I startred from.
Thanks for the advice.
sub main
Repository.ClearOutput "Script"
Repository.EnsureOutputVisible "Script"
dim theElement as EA.Element
set theElement = Repository.GetTreeSelectedObject()
if not theElement is nothing and theElement.ObjectType = otElement then
dim i, addedAttributeID
Session.Output( "Working on element '" & theElement.Name & "' (Type=" & theElement.Type & _
", ID=" & theElement.ElementID & ")" )
' Create an attribute to work on
dim attributes as EA.Collection
set attributes = theElement.Attributes
dim attName, attType, attScope
dim newAtt, splitAtt
dim iBox
iBox=InputBox("Enter attribute", "Class Attribute", "attribute_name, string(150), public")
if IsEmpty(iBox) Then
exit sub
else
newAtt = iBox '"fullname, string(150), public"
splitAtt = Array(Split(newAtt, ","))
for each i in splitAtt
attName = trim(i(0))
Session.Output attName
attType = trim(i(1))
Session.Output attType
attScope = trim(i(2))
Session.Output attScope
next
dim newAttribute as EA.Attribute
set newAttribute = attributes.AddNew( attName, attType )
newAttribute.Visibility(attScope)
newAttribute.Update()
attributes.Refresh()
addedAttributeID = newAttribute.AttributeID
Session.Output( "Added attribute: " & newAttribute.Name & _
"(Type=" & newAttribute.Type & _
", ID=" & addedAttributeID & ")" )
end if
end if
-->> SELECT the ELEMENT?
main