Run Add-In Functions

To run Add-In functions from the Learning Center, you create an attribute in the Learning Center stereotype Class with the following format:

"Assembly::FunctionName()"

 

where Assembly is the name of the Add-In and FunctionName is the name of a public function in the Add-In. Give the attribute an initial value of the text that is to appear in the Learning Center.

The function receives two parameters and returns a success status, as in the following VB.Net example:

 

Public Function ShowMyDiagram(ByRef Repository As EA.Repository, ByVal args As Object) As String

    Dim ret As String

    ret = Repository.SQLQuery("select ea_guid from t_diagram where diagram_type='Custom' and StyleEx like
     '*;MDGDgm=MyDiagrams::MyCustomDiagram;*'")

    If ret Is Nothing Then

         ShowMyDiagram = False

         Exit Function

    End If

 

    Dim oXML As MSXML2.DOMDocument = New MSXML2.DOMDocument

    oXML.loadXML(ret)

 

    Dim NodeList As MSXML2.IXMLDOMNodeList = oXML.selectNodes("//ea_guid")

    If NodeList.length = 0 Then

         ShowMyDiagram = False

         Exit Function

    End If

 

    Dim Node As MSXML2.IXMLDOMNode

    Dim diag As EA.Diagram

    If NodeList.length >= 1 Then

         Node = NodeList.item(0)

               diag = Repository.GetDiagramByGuid(Node.text)

         Repository.OpenDiagram(diag.DiagramID)

         Repository.ShowInProjectView(diag)

    End If

 

    ShowMyDiagram = True

End Function