Book a Demo

Author Topic: traverse the tree of project browser in order  (Read 4240 times)

sspvirgo

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
traverse the tree of project browser in order
« on: August 16, 2011, 12:50:31 am »
Hi,

Can i traverse through the tree in order as they are viewed in the project browser i want to write a script that add number in sequence the elements appears in the project browser tree.

What i want to do is update the "phase" field of an element as 1,2,3,4......by traversing down the tree in order.

Thanks

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: traverse the tree of project browser in order
« Reply #1 on: August 16, 2011, 04:29:09 pm »
I think in most cases the Element.Elements collection already returns you the correct order.
If not so check the Element.pos property.
It could also be that you have configured the elements (or features) to show up in alphabetic order, in that case you'll probably have to sort the collection yourself.

Geert

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: traverse the tree of project browser in order
« Reply #2 on: August 16, 2011, 05:11:06 pm »
Can you please confirm which version and build of EA you are currently running?  I think I recall that the sorting applied to some EA collections was changed in EA 9 to make them more consistent with the UI.  Can't remember which collections off the top of my head unfortunately...

sspvirgo

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: traverse the tree of project browser in order
« Reply #3 on: August 16, 2011, 11:53:42 pm »
Hi Aaron,

I am using EA version 9.

@Geert the elements in my case are not sorted alphabetically in the tree. However the output of my script of traversing  all the elements in the model and updating the phase field is done alphabetically for their respective packages, which i dont want. I want that EA should update the details sequentially as they appears on the list.

if this is possible how it can be done...

Thanks,

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: traverse the tree of project browser in order
« Reply #4 on: August 16, 2011, 11:58:44 pm »
In that case you'll have to sort the collection yourself (have you looked at the treepos property?)

Geert

PS. If Sparxians are asking for version and build they mean something more specific like version 9 build 908


sspvirgo

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: traverse the tree of project browser in order
« Reply #5 on: August 17, 2011, 06:59:12 am »
Hi Geert,

The tree pos is set to 0 for all elements initially. However if i move the element up and down manually in the tree then the tree pos value is set accordingly for all the elements in that package.

Once the tpos are set i can get all the elements in the collection in order but if the tree pos value is not set then it return result in an alphabetical order.

@Aaron,
Version 9 Build 907