Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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
-
Use Element.TreePos and make sure you allow free sorting in the General Options.
Geert
-
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
-
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.
-
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.
-
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.
-
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.
-
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
-
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.