EA_GetCompartmentData

Details

This event occurs when Enterprise Architect is instructed to redraw an element. It requests that the Add-In provide the data to populate the element's compartment.

Syntax

Function EA_GetCompartmentData(Repository As EA.Repository, sCompartment As String, sGUID As String, oType As EA.ObjectType) As Variant

The EA_QueryAvailableCompartments function syntax contains the following elements:

Parameter

Type

Direction

Description

oType

ObjectType

IN

The type of the element for which data is being requested.

Repository

EA.Repository

IN

An EA.Repository object representing the currently open Enterprise Architect model. Poll its members to retrieve model data and user interface status information.

sCompartment

String

IN

The name of the compartment for which data is being requested.

sGUID

String

IN

The GUID of the element for which data is being requested.

Return Value

Variant containing a formatted string. See the example below to understand the format.

Example

 

Function EA_GetCompartmentData(Repository As EA.Repository, sCompartment As String, sGUID As String, oType As EA.ObjectType) As Variant

 

If Repository Is Nothing Then

Exit Function

End If

 

Dim sCompartmentData As String

Dim oXML As MSXML2.DOMDocument

Dim Nodes As MSXML2.IXMLDOMNodeList

Dim Node1 As MSXML2.IXMLDOMNode

Dim Node As MSXML2.IXMLDOMNode

Dim sData As String

 

sCompartmentData = ""

Set oXML = New MSXML2.DOMDocument

sData = ""

 

On Error GoTo ERR_GetCompartmentData

 

oXML.loadXML (Repository.GetTreeXMLByGUID(sGUID))

Set Node1 = oXML.selectSingleNode("//ModelItem")

 

If Node1 Is Nothing Then

     Exit Function

End If

 

sCompartmentData = sCompartmentData + "Name=" + sCompartment + ";"

sCompartmentData = sCompartmentData + "OwnerGUID=" + sGUID + ";"

sCompartmentData = sCompartmentData + "Options=SkipIfOnDiagram&_eq_^1&_sc_^"

 

Select Case sCompartment

Case "parts"

     Set Nodes = Node1.selectNodes("ModelItem[@Metatype=""Part""]")

     For Each Node In Nodes

         sData = sData + "Data&_eq_^" + Node.Attributes.getNamedItem("Name").nodeValue + "&_sc_^"

         sData = sData + "GUID&_eq_^" + Node.Attributes.getNamedItem("GUID").nodeValue + "&_sc_^,"

     Next

 

Case "ports"

     Set Nodes = Node1.selectNodes("ModelItem[@Metatype=""Port""]")

     For Each Node In Nodes

         sData = sData + "Data&_eq_^" + Node.Attributes.getNamedItem("Name").nodeValue + "&_sc_^"

         sData = sData + "GUID&_eq_^" + Node.Attributes.getNamedItem("GUID").nodeValue + "&_sc_^,"

     Next

 

End Select

 

' If there's no data to display, then don't return any compartment data

If sData <> "" Then

     sCompartmentData = sCompartmentData + "CompartmentData=" + sData + ";"

Else

     sCompartmentData = ""

End If

 

EA_GetCompartmentData = sCompartmentData

Exit Function

 

ERR_GetCompartmentData:

EA_GetCompartmentData = ""

 

End Function