Book a Demo

Author Topic: Inconsistent Document Table Format  (Read 5017 times)

Gayle

  • EA User
  • **
  • Posts: 37
  • Karma: +1/-0
    • View Profile
Inconsistent Document Table Format
« on: March 29, 2016, 06:27:00 am »
I'm using EA 12.1 and Visual Basic Scripts.  I copied a working script that did many of the things that I wanted to do.  The existing script collected data on connectors in sequence diagrams within the model and generated and RTF with a single table that had one line of header row.  Two templates were used - one for the header and one for the body of the table (one line per connector).  Note that I was not successful trying to combine these into one template for the modified script.

My modified script is going into the same model and packages to extract data on diagrams and enter the data into a table contained in an RTF.  I created a new header row as a template (row marked in EA template as header) and another template for the diagram table rows.  I've tested this with three fixed packages:  the model root, a package under the root and a package another level down.  The package IDs are:  1, 4, 131.  When I run the logic on package 1, no header row appears.  When I run the logic on the first level package, I get one header row if EA is freshly started and 5 header rows if I have updated the script and saved it before running it.  For the next level down, I get one header row if EA is freshly started and 7 header rows if I have updated the script and saved it before running it.  There is very little different between the original script and the modified script except at the lower levels of the logic where it decides what data to collect for output to the file.

The script begins as follows (in this case, the root model is selected as the package and the lines for the other two are commented out):

dim DOCUMENTATION_TYPE, OUTPUT_FILE
DOCUMENTATION_TYPE = dtRTF
OUTPUT_FILE = "c:\\temp\\diagrams.rtf"
'
sub getDiagrams()

   'Show the script output window and clear window
   Repository.EnsureOutputVisible "Script"
   Repository.ClearOutput "Script"
   
   'Create a document generator object
   dim docGenerator as EA.DocumentGenerator
   set docGenerator = Repository.CreateDocumentGenerator()
   docGenerator.NewDocument("")
   docGenerator.SetPageOrientation(1) ' set output page to landscape   

   dim currentPackage as EA.Package
   set currentPackage = Repository.GetPackageByID(1) ' Root Package
'   set currentPackage = Repository.GetPackageByID(4) ' Model Package
'   set currentPackage = Repository.GetPackageByID(131) ' MT Package

   Session.Output "Package = " & currentPackage.Name & "; Package ID = " & currentPackage.PackageID

   'Create a heading for the table
   docGenerator.DocumentPackage currentPackage.PackageID, 0, "ExportDiagramHeading"
   
   'Find all the diagrams
   findDiagrams docGenerator, currentPackage
   
   'Save the document
   dim saveSuccess
   saveSuccess = docGenerator.SaveDocument( OUTPUT_FILE, DOCUMENTATION_TYPE )
   
   if saveSuccess = true then
      Session.Output "Documentation complete!"
   else
      Session.Output "Error saving file: " + docGenerator.GetLastError()
   end if

end sub

The findDiagrams routine has the following statement that is executed once for each diagram located in the desired package:

         docGenerator.DocumentDiagram thisDiagram.DiagramID, 0, "ExportDiagramDataxxyy"


My expected output would be one header row and one row for each diagram. I did not see how to attach a sample output to this message, but would be glad to add one if instructions are provided.

How do I get a single header row to show up in my output table consistently?  Is there something that needs to be reset or initialized that I've missed and we just got lucky with the script that another person developed?

Thank you for any ideas.

Gayle






Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Inconsistent Document Table Format
« Reply #1 on: March 29, 2016, 02:42:48 pm »
Gayle,

I'm not sure I fully understood your question correctly, but I've had inconsistent results from script fragments myself in the past.
Often it would not work the first time I tried after restarting EA, but then it worked perfectly fine the second time (without changing anything)

I reported that as a bug and that got fixed in version 12.1.1229

Might be a good idea to try it again with that version.

Geert

Gayle

  • EA User
  • **
  • Posts: 37
  • Karma: +1/-0
    • View Profile
Re: Inconsistent Document Table Format
« Reply #2 on: March 30, 2016, 03:09:22 am »
Thank you for the idea.  I installed build 1229 and got the same results in the output table:
1. Root model level had no table header row regardless of whether script was run just after starting EA or after multiple executions of script.
2. Top package in root had one header row when script was run just after starting EA and 5 header rows for any other execution of the script.
3. Next level down package had one header row when script was run just after starting EA and 7 header rows for any other execution of the script.

The inconsistencies I'm seeing make no sense unless there is either a bug or I've missed something that needs to be initialized or reset each time the script is executed.

Gayle

Gayle

  • EA User
  • **
  • Posts: 37
  • Karma: +1/-0
    • View Profile
Re: Inconsistent Document Table Format - Problem Solved
« Reply #3 on: April 07, 2016, 09:11:51 am »
I found the problem with my script.  The table header used the document generation "DocumentPackage" option and when data was entered in the table, I used "DocumentDiagram".  When I changed the header to use "DocumentDiagram" the problem was corrected.

Gayle