Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Paul Krcma on January 24, 2012, 09:12:35 am

Title: Setting the tree position on elements
Post by: Paul Krcma on January 24, 2012, 09:12:35 am
Are there any automated interface examples on how to add embedded elements to an element and set the tree position on the embedded element? EA version 8.0.

I'm using the API to create new elements, and some elements have embedded elements, and EA is putting them in alphabetical order. I wish to have the elements appear in the browser in the order in which they were created.

Thanks,
Paul Krcma
Title: Re: Setting the tree position on elements
Post by: Geert Bellekens on January 24, 2012, 05:42:28 pm
Use Element.TreePos and make sure you allow free sorting in the General Options.

Geert
Title: Re: Setting the tree position on elements
Post by: Paul Krcma on January 25, 2012, 03:22:18 am
Thanks for the tip on the Allow Free Sorting, Geert.
I've activated the Free Sorting.  Then, for an example, I create new elements, update the element, set TreePos = 1, update the element, refresh the package. I would expect the last element to be added, be the first in the tree view. But instead, it's the tree as the alphabetic order.

I must be missing something.

-Paul
Title: Re: Setting the tree position on elements
Post by: qwerty on January 25, 2012, 04:15:11 am
You have to additionally refresh some stuff. I never remember which where and when. Try a manual reload of the model to see whether the order had changed.

q.
Title: Re: Setting the tree position on elements
Post by: Sunil Sah on January 30, 2012, 10:45:28 pm
The following steps worked for me when creating and ordering elements with API:

EA.Package.TreePos = ...;
EA.Package.Update();
EA.Repository.RefreshModelView(...);

Then I could use created elements to generate RTF documentation with elements in the right order.
Title: Re: Setting the tree position on elements
Post by: KP on January 31, 2012, 08:48:40 am
Also worth checking the TPos values for all other elements owned by the same package. They get cleared by the "Contents > Reset Sort Order" command so you may find they all need to be set.
Title: Re: Setting the tree position on elements
Post by: qwerty on January 31, 2012, 06:41:53 pm
Quote
Also worth checking the TPos values for all other elements owned by the same package. They get cleared by the "Contents > Reset Sort Order" command so you may find they all need to be set.
You must be kidding! Switching an option will clobber the whole database structure? I mean the order which might potentially been set for many elements is wiped out when a single user switches that option???? Please tell me that's not the case.

q.
Title: Re: Setting the tree position on elements
Post by: Geert Bellekens on January 31, 2012, 07:01:54 pm
q.

Its not really an option (as in Tools|Options) but a context dependent action (right click on package).
It might potentially cause havoc, but it's not as bad as you thought.

Geert
Title: Re: Setting the tree position on elements
Post by: qwerty on February 01, 2012, 12:20:04 am
There's also a global option "Sort features alphabetically". I thought Neil was talking about that option. I wasn't aware of that context specific one.

q.