Author Topic: Recursive VB script to list elements and their children  (Read 2038 times)

rupertkiwi

  • EA User
  • **
  • Posts: 133
  • Karma: +5/-0
    • View Profile
Recursive VB script to list elements and their children
« on: December 05, 2022, 01:38:16 pm »
Hi,

Does anyone have a VB script handy to list elements in a package and the element's children?

thanks

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Recursive VB script to list elements and their children
« Reply #1 on: December 05, 2022, 03:37:15 pm »
You do.

Open the scripting window.
Expand the "Local Scripts"
The script you want is called "VBScript - Recursive Model Dump Example".

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Recursive VB script to list elements and their children
« Reply #2 on: December 05, 2022, 03:56:39 pm »
If you find that slow, there's a faster alternative using SQL:

https://sparxsystems.com/forums/smf/index.php/topic,38987.msg259113.html#msg259113

Geert

rupertkiwi

  • EA User
  • **
  • Posts: 133
  • Karma: +5/-0
    • View Profile
Re: Recursive VB script to list elements and their children
« Reply #3 on: December 05, 2022, 04:17:36 pm »
Thanks Geert.

I have been using that recursive script and it works well for a single level of element but I also want to get the elements that are nested under other elements, I'm having a bit of trouble with it.

Rupert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Recursive VB script to list elements and their children
« Reply #4 on: December 05, 2022, 05:59:50 pm »
Rupert,

The idea of the SQL Query method is to call that one recursively untill you have all the ID's of all nested elements.

That is definitely the fastest way to get the elements.

Geert