What you will basically do is to create an overview diagram and just drag and drop the relevant diagram from the browser. This offers a selection box
where you just leave the first selection Diagram Frame
. EA will create a new object with a name suggested from the diagram name (you can leave that but also change it if you have a need for that). Now the dragged diagram will appear inside a named frame on the overview diagram. You can not scale this diagram, so it will have the size of the original one plus the frame around it.
Note: you can use Hyperlink
in the above dialog to create nice and short links between diagrams for navigation.
Now for the scripting part. I will use a meta language, but you will likely guess how to use it in your preferred language. The first thing is to locate the overview diagram. You can query its diagram guid by right-clicking it in the browser and using Copy/Copy Node GUID...
. Now with that id you can locate it by (example guid below):
overview = rep.GetDiagramByGUID("{A006B95E-1237-4778-A339-D1B407C6FD5C}")
Next is to locate the single diagrams you want to show on the overview. This is up to you how to find them. Eventually they will be at certain locations in the repository. To statically load the first diagram in the first package in the first view of the first root you would call
model = repository.Models.GetAt(0)
view = model.Packages.GetAt(0)
package1 = view.Packages.GetAt(0)
dia1 = package1.Diagrams.GetAt(0)
You will likely use smarter ways to iterate and find the relevant diagrams.
Now with these diagram objects at hand you can create the diagram frame. This needs to be placed somewhere in a package. For simplicity I use package1
but you will eventually place them in the package of the overview diagram.
frame = package1.Elements.AddNew(dia1.Name, "UMLDiagram")
frame.Update()
sql = "UPDATE t_object SET PDATA1=" + str(dia1.DiagramID) + " WHERE Object_ID=" + str(overview.diagramID
repository.Execute(sql)
This is voodoo, I know. The API does not offer a way to link the UMLDiagram element with the referenced diagram. So this must be poked into the database directly.
Finally, the newly created frame object can be placed in the overview diagram:
diagramObj = overview.DiagramObjects.AddNew("l=10;r=110;t=-20;b=-80","")
diagramObj.ElementID = frame.ElementID
diagramobj.Update()
Since this EA, the coordinates for the y-axis are towards negative from the top (l, r, t, b stand for, guess). EA will expand he frame to the minimum above the specified size.
In order to see the result you need to close/open the overview diagram. I will leave that as exercise to you :-)