Book a Demo

Author Topic: Diagram export via SDK  (Read 3816 times)

Paul Stovell

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Diagram export via SDK
« on: July 21, 2009, 10:55:28 pm »
Hi,

I want to extend the documentation generator to make use of Word 2007 formats from EA. I'm using the Sparx .NET API's to query the .EAP, but I cannot find a way to export the diagram images programmatically.

Is there a way to programmatically export a diagram image using the API's (the "SDK for Enterprise Architect - Enterprise Architect Object Model" topic under help)?

Paul

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Diagram export via SDK
« Reply #1 on: July 22, 2009, 08:55:28 am »
Hi Paul,

There are a few methods in the Project Interface that allow you to export images. If you have the latest build (846) then please check the scripting example VBScript - Project Interface Example.

If you don't have 846, the main idea is something like this:

Code: [Select]
dim currentPackage as EA.Package
set currentPackage = Repository.GetTreeSelectedPackage()

dim projectInterface as EA.Project
set projectInterface = Repository.GetProjectInterface()

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
« Last Edit: July 22, 2009, 08:56:50 am by mfraser »
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8