Rickey
Rickey

Reputation: 71

Sparx Enterprise Architect to get the Tagged ´Value from otDiagram VB Script code

I have a UML diagram and all the component has tagged values . I would like to retrieve the tagged value with the element name . Something like this to get the tagged value that i have code but dont know how to start it for a diagram.

function TVGetElementTaggedValue( theElement, taggedValueName, defaultValue )
    TVGetElementTaggedValue = defaultValue

    if not theElement is nothing and Len(taggedValueName) > 0 then
        dim taggedValue as EA.TaggedValue
        set taggedValue = theElement.TaggedValues.GetByName( taggedValueName )

        if not taggedValue is nothing then
            TVGetElementTaggedValue = taggedValue.Value
        end if
    end if

end function

Upvotes: 1

Views: 2438

Answers (2)

Rickey
Rickey

Reputation: 71

Finally Here is the solution that i have and it worked finally:

  1. first select the type like this: Repository.GetTreeSelectedItemType() = otDiagram
  2. call a function and keep a variable to store the data like this: Roles = TVGetElementTaggedValue(element, "Roles", "", "")
  3. here is the function:

Function TVGetElementTaggedValue( theElement, taggedValueName, defaultValueMissing, defaultValueEmpty )

    if not theElement is nothing and Len(taggedValueName) > 0 then      
        dim taggedValue as EA.TaggedValue
        set taggedValue = theElement.TaggedValues.GetByName( taggedValueName )

        if taggedValue is nothing then
            TVGetElementTaggedValue = defaultValueMissing
' Dump warning          
'Session.Output(theElement.Name & " " & taggedValueName & " TAG Missing")           
        else
            if taggedValue.Value = "" then
                TVGetElementTaggedValue = defaultValueEmpty     
' Dump warning          
'Session.Output(theElement.Name & " " & taggedValueName & " Value Missing")         
            else
                TVGetElementTaggedValue = taggedValue.Value
            end if
        end if
    end if

end function
  1. final print:

Session.Output("Roles:   " + CStr(Roles))

Thank you for the help.

Upvotes: 1

Geert Bellekens
Geert Bellekens

Reputation: 13784

There are no tagged values on diagrams.

Upvotes: 1

Related Questions