Problem: A lot of our design and architecture documentation were created and maintained in Enterprise Architect - for better or worse, that is how it is. These documents are sto
In the Example code I just discovered a function whish will do exactly what you want. But hidden away by the not so helpfull name of ProjectInterfaceExample:
option explicit
!INC Local Scripts.EAConstants-VBScript
'
' Examples of how to access and use the Project Interface.
'
' Related APIs
' =================================================================================
' Project Interface API - http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/project_2.html
'
' Global reference to the project interface
dim projectInterface as EA.Project
sub ProjectInterfaceExample()
' Show the script output window
Repository.EnsureOutputVisible "Script"
Session.Output( "VBScript PROJECT INTERFACE EXAMPLE" )
Session.Output( "=======================================" )
set projectInterface = Repository.GetProjectInterface()
' Iterate through all model nodes
dim currentModel as EA.Package
for each currentModel in Repository.Models
' Iterate through all child packages and save out their diagrams
dim childPackage as EA.Package
for each childPackage in currentModel.Packages
DumpDiagrams childPackage
next
next
Session.Output( "Done!" )
end sub
'
' Recursively saves all diagrams under the provided package and its children
'
sub DumpDiagrams ( thePackage )
' Cast thePackage to EA.Package so we get intellisense
dim currentPackage as EA.Package
set currentPackage = thePackage
' Iterate through all diagrams in the current package
dim currentDiagram as EA.Diagram
for each currentDiagram in currentPackage.Diagrams
' Open the diagram
Repository.OpenDiagram( currentDiagram.DiagramID )
' Save and close the diagram
Session.Output( "Saving " & currentDiagram.Name )
projectInterface.SaveDiagramImageToFile "c:\\temp\\" + currentDiagram.Name + ".emf"
Repository.CloseDiagram( currentDiagram.DiagramID )
next
' Process child packages
dim childPackage as EA.Package
for each childPackage in currentPackage.Packages
DumpDiagrams childPackage
next
end sub
ProjectInterfaceExample
You might have to fine tune it a litte (i.E. not writing everything into C:\Temp) but it is a good start.
I am not familiar with this product but the Web site you link to mentions an Automation interface. This should allow you to control Enterprise Architect from a scripting language such as VBScript or JavaScript. It may be possible to print via this interface; if so, you could install a PDF printer driver (or print to a file using a generic PostScript printer driver and use GhostScript to convert it to PDF.
We have Enterprise Architect and we have it nicely integrated with Word. We wrote our own Wicket/Jetty WebApp that publishes links to EA diragrams as an HTTP URL that we then "Insert&Link" into our UCR (or anything else) documents. The web app displays a tree like structure of links, one for each package and then we just copy the link into the word document.
It works really well. We can make as many changes as we like in EA and then in the Word document just go CTRL+A to select all and hit F9 to update all links. Unfortunately I didn't write the code so I can't tell you exactly how it's published from EA. I think there's some Java code that just polls the EA server and sucks out everything if it detects changes.
VBScript is really an easy and quick possibility. I figured out a small script that allows to export a diagram. The only think you have to know is it's GUID.
Set MyRep = CreateObject("EA.Repository")
If NOT MyRep.OpenFile("D:\Repository.eap") Then
MsgBox("Error opening file")
WScript.Quit -1
End If
Set Project = MyRep.GetProjectInterface
My_Diagram_GUID = "{2256B231-99F6-4c78-9AB0-72E24486D578}"
'Vector export emf/wmf
Project.PutDiagramImageToFile My_Diagram_GUID,"D:\Test.emf",0
'Bitmap export png/bmp/...
Project.PutDiagramImageToFile My_Diagram_GUID,"D:\Test.png",1