Programatically Generate documents with Enterprise Architect

less than 1 minute read

Enterprise Architect is a tool for architecture modelling at base, but can be used for much more.

What the tool can improve is the way to generate documents based on the AutomationInterface.

There are two ways to generate documents in EA Sparx:

  1. DocumentGenerator
    function createDocument( docName, docPath  )
    {
        var Gentor as EA.DocumentGenerator;
        Gentor = Repository.CreateDocumentGenerator();
        Gentor.NewDocument("Glossary");    
  	    Gentor.InsertText( "Hello World" +"\n","Heading 1");		
  	    return Gentor; 
    }
  
    createDocument ("yourDocName", "yourDocPath");
  1. Virtual Document

This option is based on this link from Bellekens but adapted. The code below calls RunReport that runs the F8 (or generate documents) document generation option.

    !INC Local Scripts.EAConstants-JScript
  
    function main()
    {	
  	  Session.Output("Hello World");
  	
  	  var prj = Repository.GetProjectInterface();
  	  prj.RunReport("{GUID}", "test","C:\\diagram_export\\3.rtf");
  	
  	  Session.Output("Bye World");
    }
  
    main();

Published

Leave a Comment