UML & SysML modelling languages

Expertise and blog articles on UML, SysML, and Enterprise Architect modelling tool

version francaiseTwitterVideos UMLChannel SparxSystems EA YouTubeLinkedIn
Thursday, 18 May 2017 16:32

EA helper: switch the rectangle notation for Archimate elements with a script

Written by
Rate this item
(1 Vote)

archimate logo

EA User Group London 2017

I attended a useful and interesting training on EA and Archimate 3 from Gillian Adens (Hippo Software) at the London's EA User Group today. Defining Archimate business roles, Gillian pointed out that EA does not let one disable the rectangle notation on all selected roles. A right click on each business role to select Advanced > Disable Rectangle Notation being time consuming, I felt this could easily be achieved via a handy script.

I copied at the end of this article the VB Script code to install in your EA project so the rectangle notation can be disabled or enabled on a selection of diagram objects.

Here is a simple Archimate business diagram to illustrate the default notation:

sparx enterprise architect archimate 3 business diagram

Having the script installed, simply all elements to update, right click and select Scripts > Disable Rectangle Notation. Below is the updated diagram as expected:

archimate business roles actor rectangle disabled

Disable Rectangle Notation diagram script (EA)

The code below must be copied to a new Script within a Diagram Group:

option explicit
!INC Local Scripts.EAConstants-VBScript
' Script Name: Disable Rectangle Notation
' Author: Guillaume FINANCE
' Purpose: disable the rectangle notation on the selected objects in a diagram
' Date: 18/05/2017
sub OnDiagramScript()
' Get a reference to the current diagram
dim currentDiagram as EA.Diagram
set currentDiagram = Repository.GetCurrentDiagram()
if not currentDiagram is nothing then
' Get a reference to any selected connector/objects
dim selectedObjects as EA.Collection
set selectedObjects = currentDiagram.SelectedObjects
dim currentDiagramObject as EA.DiagramObject
dim style
dim i
if selectedObjects.Count > 0 then
' One or more diagram objects are selected
for i = 0 to selectedObjects.Count - 1
set currentDiagramObject = selectedObjects.GetAt( i )
currentDiagramObject.Style = Replace(currentDiagramObject.Style , "UCRect=1;", "UCRect=0;")
currentDiagramObject.Update()
next
currentDiagram.Update()
else
Session.Prompt "This script requires to select objects to update", promptOK
end if
else
Session.Prompt "This script requires a diagram to be visible", promptOK
end if
end sub
OnDiagramScripts

Note: the opposite version i.e. Enable Rectangle Notation is the same expect from the following line:

 currentDiagramObject.Style = Replace(currentDiagramObject.Style , "UCRect=0;", "UCRect=1;")