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