Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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?
-
That is more or less how I do it.
I guess it returns null when there is no diagram opened
Geert
-
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.
-
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?
-
I'd rather report a bug.
q.
-
Bug reported ; will let you know if I get any update.
thanks
-
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.
-
I tried that and it did not work.
q.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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)
-
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.