Hi Eamonn,
EA ships with a script that will do this. I have adapted it slightly for my purposes and attached it below:
'option explicit
!INC Local Scripts.EAConstants-VBScript
sub RecursiveModelDumpExample()
Repository.EnsureOutputVisible "Script"
Repository.ClearOutput "Script"
Session.Output( "PackageContents" )
Session.Output( "=======================================" )
Dim thePackage As EA.Package
Set thePackage = repository.GetTreeSelectedPackage()
If Not thePackage Is Nothing And thePackage.ParentID <> 0 Then
DumpPackage "", thePackage
Else
' No package selected in the tree
MsgBox ("This script requires a package to be selected in the Project Browser." & vbCrLf & _
"Please select a package in the Project Browser and try again.")
End If
Session.Output ("Done!")
end sub
' Outputs the packages name and elements, and then recursively processes any child packages
' Parameters:
' - indent A string representing the current level of indentation
' - thePackage The package object to be processed
Sub DumpPackage(indent, thePackage)
' Cast thePackage to EA.Package so we get intellisense
Dim currentPackage As EA.Package
Set currentPackage = thePackage
' Add the current package's name to the list
Session.Output (indent & currentPackage.Name & " (PackageID=" & currentPackage.PackageID & ")")
' Dump the elements this package contains
DumpElementsNew indent & " ", currentPackage
' Recursively process any child packages
Dim childPackage As EA.Package
For Each childPackage In currentPackage.Packages
DumpPackage indent & " ", childPackage
Next
End Sub
Sub DumpElementsNew(indent, thePackage)
' Cast thePackage to EA.Package so we get intellisense
Dim currentPackage As EA.Package
Set currentPackage = thePackage
' Iterate through all elements and add them to the list
Dim currentElement As EA.Element
For Each currentElement In currentPackage.elements
Session.Output (indent & "::" & currentElement.Name & " (" & currentElement.Type & ", ID=" & currentElement.elementid & ")")
Next
End Sub
RecursiveModelDumpExample