Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Barrie Treloar on March 31, 2026, 05:29:38 pm
-
In Sparx 15.2
I have two diagrams open, Diagram A and Diagram B.
I run my VBScript from the Specialize > Script Library > Scripts > "my script" > Right click > Run Script
My VBScript calls
dim currentDiagram as EA.Diagram
set currentDiagram = Repository.GetCurrentDiagram()
When I printout
"currentDiagram = " & currentDiagram.Name
it shows the wrong diagram name "Diagram B".
In
Browser > Project, Diagram A is selected
Browser > Context, Diagram A is selected
Browser > Diagram, Diagram A is selected
Main Window > Diagram A is selected
In the Main Window it is listed as "Diagram A", "Diagram B".
If I swap the order of the diagrams to be "Diagram B", "Diagram A" it prints out the correct name.
If I swap the order of the diagrams to be "Diagram A", "Diagram B" it prints out the incorrect name.
It seems to always select the rightmost diagram.
Am I doing something wrong?
-
Current diagram looks at which diagram is open in the main window.
Geert
-
I believe Geert has cut to the core of the issue.
The Browser is not relevant for this function at all.
It gets more complicated than that though:
- It is possible to drag a tab from the main window out and dock it elsewhere. In that case it becomes the last of the visible main window views that you interacted with.
- There may not be an active diagram at all. In particular if you're running from a script editor or console, that will be the active window so the current diagram will be null.