Author Topic: Repository.GetCurrentDiagram : missing object  (Read 8222 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1370
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Repository.GetCurrentDiagram : missing object
« on: January 31, 2014, 11:55:14 pm »
Hi,

I'm writing a script to carry various updates on the opened diagram.
When I run the script, I get a missing object : currentDiagram error.

Here is the first lines of my code :
dim currentDiagram as EA.Diagram
set currentDiagram = Repository.GetCurrentDiagram()
Session.Output( currentDiagram.Name )


Am I missing anything?
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +564/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Repository.GetCurrentDiagram : missing object
« Reply #1 on: February 01, 2014, 12:18:13 am »
That is more or less how I do it.
I guess it returns null when there is no diagram opened

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1370
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Repository.GetCurrentDiagram : missing object
« Reply #2 on: February 01, 2014, 02:27:32 am »
In my case I've got an opened diagram, but as I need to select the script to run it, I wonder if it loses the focus and things there's no active diagram?

It's easy to test with the script I gave and I wonder if there's something to amend to get this method to work.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Mauricio Moya (Arquesoft)

  • EA User
  • **
  • Posts: 340
  • Karma: +8/-4
  • EA Consulting and development in Spanish
    • View Profile
    • Arquehub Azure Module
Re: Repository.GetCurrentDiagram : missing object
« Reply #3 on: February 01, 2014, 02:31:31 am »
What if your create a Project browser group to locate your script so you can right-click the diagram on the project browser and run the script for the selected diagram?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #4 on: February 01, 2014, 02:38:50 am »
I'd rather report a bug.

q.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1370
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Repository.GetCurrentDiagram : missing object
« Reply #5 on: February 01, 2014, 02:43:06 am »
Bug reported ; will let you know if I get any update.

thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #6 on: February 03, 2014, 08:39:56 am »
If you are writing a script does that mean that the script editor is the active view? (ie. there is no active diagram so it should return null) It won't work on a diagram selected in the project browser because the function is explicitly for the currently open diagram. (You can use another function if that's what you need.)

Try switching the main view to a diagram and click the run button on the script tree.


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #7 on: February 03, 2014, 09:54:04 am »
I tried that and it did not work.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #8 on: February 03, 2014, 01:22:41 pm »
I don't know what you're doing wrong, I use scripts based on doing that on a daily basis. I just tested it and it worked fine.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #9 on: February 04, 2014, 03:47:46 am »
Neither do I know what you did ;-)

Honestly, I tried with both docked (in diagrams pane) and non-docked scripting window. In both cases the return result was nil.



(Using currentDiagram.Name will pop up Object Required)

q.
« Last Edit: February 04, 2014, 03:57:38 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #10 on: February 04, 2014, 08:23:43 am »
Your screenshot shows me that you didn't run it from the scripting tree like I suggested.

If you're debugging it the active view will always be the script editor when you step over a line. So GetCurrentDiagram will always return null.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #11 on: February 04, 2014, 10:35:32 am »
You mean like this:
It has been started from the scripting window.

q.
« Last Edit: February 04, 2014, 10:36:38 am by qwerty »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #12 on: February 04, 2014, 10:40:37 am »
P.S. After closing the scripting editor (though not docked in the diagram pane) it worked. I'd say this is a bug since the editor was not in the diagram pane and thus clearly NOT a diagram (which it is no way never anyway).

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #13 on: February 04, 2014, 11:21:25 am »
It's not a diagram, but while it is active there is no active diagram. (Call it a bug if you like, but it's not one)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Repository.GetCurrentDiagram : missing object
« Reply #14 on: February 04, 2014, 07:24:17 pm »
Quote
It's not a diagram, but while it is active there is no active diagram. (Call it a bug if you like, [highlight]but it's not one[/highlight])
You're right. It's more than one.

q.