Visibility of assocations in ArchiMate diagrams

In ArchiMate there are multiple ways to define assocations between entities in ArchiMate. The most important and most used approach is to create an association (of any relevant kind) between two concepts. With this approach you have the possibility to create diagrams with elements and associations which are both visible and have the association in the repository so also in reports and other diagrams this association willl be available. 

However in some cases you want to have another diagram technique where you place the one element within the boundaries of an enclosing entity. See for example the diagram below.

 

In this diagram a display is made which component is relevant for a certain business process. However the associations are not visible and for reporting and other diagrams an association is preferred. What happens then is shown in the diagram below

 

You can see a number of associations in the diagram but these are already implicit because the one element is enclosed in the other. So one approach can be that we manually hide all the implicit associations. This is cumbersome. Therefore we created the script below so making the associations invisible when an element is enclosed in another diagram. This makes it possible to automatically show and hide associations depending on the position of the entities related to the connection. The code is shown below:

!INC Local Scripts.EAConstants-VBScript

' Klembord handigheidje " ""

Sub VisibleUnvisibleAssocation(currentDiagram)

 

if not currentDiagram is nothing then

' Get a reference to any selected connector/objects

 

dim objDL as EA.DiagramLink

Dim objDO as EA.DiagramObject

Dim targetDO as EA.DiagramObject

Dim sourceDO as EA.DiagramObject

 

dim selectedConnector as EA.Connector

Dim targetID, sourceID

 

Repository.EnableUIUpdates = false

For each objDL in currentDiagram.DiagramLinks

set selectedConnector = Repository.GetConnectorByID(objDL.ConnectorID)

sourceID = selectedConnector.SupplierID

targetID = selectedConnector.ClientID

session.output targetId

session.output sourceID

For each objDO In currentDiagram.DiagramObjects

Session.output objDO.InstanceID

If objDO.ElementID = targetID Then

Set targetDO = objDO

End If

If objDO.ElementID = sourceID Then

Set sourceDO = objDO

End If

Next

If targetDO.top>= sourceDO.top AND targetDO.bottom<=sourceDO.bottom AND targetDO.left<=sourceDO.left AND targetDO.right>=sourceDO.right Then

objDL.IsHidden = true

ElseIf targetDO.top<= sourceDO.top AND targetDO.bottom>=sourceDO.bottom AND targetDO.left>=sourceDO.left AND targetDO.right<=sourceDO.right Then

objDL.IsHidden = true

Else

objDL.IsHidden = false

End If

' If (A.xleft> K.xleft AND A.ytop

' If targetDO.left<=sourceDO.left AND targetDO.top>= sourceDO.top AND targetDO.right<=sourceDO.right AND targetDO.bottom<=sourceDO.bottom  Then

' objDL.IsHidden = true

' ElseIfsourceDO.left<=targetDO.left AND sourceDO.top>= targetDO.top AND sourceDO.right<=targetDO.right AND sourceDO.bottom<=targetDO.bottom  Then

' objDL.IsHidden = true

        ' 

    ' Else

' objDL.IsHidden = false

' End If

objDL.Update()

objDL.Update()

Session.Output(" Verwerkt ")

Next

currentDiagram.Update

Repository.SaveAllDiagrams()

Repository.RefreshOpenDiagrams(true)

Repository.ReloadDiagram(currentDiagram.DiagramID)

Repository.EnableUIUpdates = true

else

Session.Prompt "This script requires a diagram to be visible", promptOK

end if

 

end sub

 

It is a function in a library so you can call it from a project browser and from a diagram script entry.