Author Topic: GetCurrentDiagram() returns null  (Read 585 times)

aljazjelen

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
GetCurrentDiagram() returns null
« on: March 02, 2022, 04:03:39 am »
Hi to whoever reading this :)

I have a following code:

Code: [Select]

// Main
var rep as EA.Repository;
rep = Repository;

var diag as EA.Diagram;

diag = rep.GetCurrentDiagram();

if (diag != null){
Session.Output(diag.type);
}

I cannot get the "GetCurrentDiagram()" function returning anything. It always returns null (the if statement above in the code is skipped).

Anyone knows why?

Additional info:
EA v13
Selected diagram in tree
clicked on the diagram in the viewport

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11824
  • Karma: +458/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: GetCurrentDiagram() returns null
« Reply #1 on: March 02, 2022, 04:20:15 am »
The current diagram returns the diagram in the main view.

It returns null if you don't have a diagram in the active tab in the main view (there could be a script, the one you are debugging, or the database builder, or...)
I think it worked the same way back in the v13 days.

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7718
  • Karma: +101/-18
    • View Profile
Re: GetCurrentDiagram() returns null
« Reply #2 on: March 02, 2022, 08:21:21 am »
The current diagram returns the diagram in the main view.

It returns null if you don't have a diagram in the active tab in the main view (there could be a script, the one you are debugging, or the database builder, or...)
To make it even more complex, you can drag a script editor out of the main view. If you're using that it will still by the active window and the current diagram will still be null.

I think it worked the same way back in the v13 days.
I think it's been the same since the v4 days.
Eve

support@sparxsystems.com