Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: assato on March 07, 2007, 03:10:32 pm

Title: Problem retrieving current Diagram
Post by: assato on March 07, 2007, 03:10:32 pm
Hi

I'm trying to write a VB macro where the Repository.GetCurrentDiagram() would be useful. I'm able to use the Repository.GetTreeSelectedPackage(), so the code should be ok.

However, when I use the GetCurrentDiagram(), the selected Diagram isn't returned. Any idea what the problem might be?

Regards
Askild
Title: Re: Problem retrieving current Diagram
Post by: Aaron B on March 07, 2007, 03:35:28 pm
GetCurrentDiagram should provide you with the currently opened diagram.  It is not affected by what is selected in the Project Browser window.  If you want to get the current selection in the Project Browser, regardless of the type, use Repository.GetTreeSelectedItem.  The object parameter should become set with the selected object, and the type enumeration will be given as a return value from the function.

For example:
Dim obj as Object
If (repository.GetTreeSelectedItem(obj) = otDiagram) Then
 Dim d as EA.Diagram
 Set d = obj
 ...
End If

See:
http://www.sparxsystems.com.au/EAUserGuide/repository3.htm
http://www.sparxsystems.com.au/EAUserGuide/objecttypeenum.htm