Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Guillaume on January 31, 2014, 11:55:14 pm

Title: Repository.GetCurrentDiagram : missing object
Post by: Guillaume 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?
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: Geert Bellekens 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
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: Guillaume 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.
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: Mauricio Moya (Arquesoft) 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?
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: qwerty on February 01, 2014, 02:38:50 am
I'd rather report a bug.

q.
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: Guillaume on February 01, 2014, 02:43:06 am
Bug reported ; will let you know if I get any update.

thanks
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: Eve 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.

Title: Re: Repository.GetCurrentDiagram : missing object
Post by: qwerty on February 03, 2014, 09:54:04 am
I tried that and it did not work.

q.
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: Eve 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.
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: qwerty 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.

(https://dl.dropboxusercontent.com/u/66691423/pic%202014-02-03%20um%2017.52.38.PNG)

(Using currentDiagram.Name will pop up Object Required)

q.
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: Eve 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.
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: qwerty on February 04, 2014, 10:35:32 am
You mean like this:(https://dl.dropboxusercontent.com/u/66691423/pic%202014-02-04%20um%2000.33.56.PNG)
It has been started from the scripting window.

q.
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: qwerty 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.
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: Eve 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)
Title: Re: Repository.GetCurrentDiagram : missing object
Post by: qwerty 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.