The script below will hide labels in a diagram depending on which flags are chosen:
option explicit
!INC Local Scripts.EAConstants-VBScript
' Script Name: LabelVisibility
' Author: Rupert Ryan
' Purpose: Changes label visibility across all diagram objects
' Date: 19/02/2018
'
Dim LLB 'Label Left (source) Bottom Source Role
Dim LLT 'Label Left (source) Top Source Multiplicity
Dim LMT 'Label Middle Top Name
Dim LMB 'Label Middle Bottom Stereotype
Dim LRT 'Label Right (dest) Top Dest Role
Dim LRB 'Label Right (dest) Bottom Dest Multiplicity
Dim IRHS 'Information Flows realized (dest)
Dim ILHS 'Information Flows realized (source)
LLB = 1
LLT = 0
LMT = 1
LMB = 1
LRT = 1
LRB = 1
IRHS = 1
ILHS = 1
dim geometryupdate
Dim hidden
Sub diagramconnector()
Dim currentDiagram
Set currentDiagram = repository.GetCurrentDiagram()
Dim diagramlink
Dim j
Dim diagramlinks As EA.Collection
Dim dirty
dirty = false
If currentDiagram.diagramlinks.Count > 0 Then
For j = 0 To currentDiagram.diagramlinks.Count - 1
Set diagramlink = currentDiagram.diagramlinks.GetAt(j)
labellist (diagramlink.geometry)
diagramlink.geometry = geometryupdate
diagramlink.Update
dirty = true
Next
End If
if dirty then
repository.ReloadDiagram currentDiagram.DiagramID
end if
End Sub
Sub labellist(geometry)
Dim strArray
Dim intCount
strArray = Split(geometry, ";")
For intCount = LBound(strArray) To UBound(strArray)
hidden = InStr(1, Trim(strArray(intCount)), "HDN")
If Not hidden = 0 Then
strArray(intCount) = labelhide(Trim(strArray(intCount)),hidden)
geometryupdate = Join(strArray, ";")
Else
End If
Next
End Sub
Function labelhide(label,hidden)
Dim strArray
Dim intCount
strArray = Split(label, ":")
Dim toggle
toggle = Mid(label, hidden + 4, 1)
Select Case Mid(strArray(0), 1, 4)
Case "$LLB"
toggle = LLB
Case "LLT="
toggle = LLT
Case "LMT="
toggle = LMT
Case "LMB="
toggle = LMB
Case "LRT="
toggle = LRT
Case "LRB="
toggle = LRB
Case "IRHS"
toggle = IRHS
Case "ILHS"
toggle = ILHS
End Select
labelhide = replace(label, Mid(label, hidden + 4, 1), toggle)
End Function
diagramconnector
Thanks,
Rupert