Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Knut Paulsen on November 15, 2016, 07:19:08 pm
-
Hi Guys,
I have a problem I just cannot figure out. In a reporting program I start an instance of EA and I want to use a Model Search to find some elements. The problem is that GetElementsByQuery seems to operate on the currently selected folder in the project browser, and since I am running without the user interface it is kind of hard to select a folder.
I have had limited success by calling Repository.RefreshModelView with the package id of my preferred package just before running the search.
Does anybody know how to force the model search to start in a given package?
Cheers
Knut
-
Minor development ...
It appears that the package returned by Repository.GetTreeSelectedPackage() is the package containing my User Default diagram. So if I only needed to report from one package, this could be a solution. But, I create reports from many different packages.
I have a working solution where I run recursively through packages and find all the elements I need, but the model search is SO much faster.
cheers
Knut
-
What gives your query back when you use it in „Search“ rather than in GetElementsByQuery?
-
When I run it inside EA it gives the expected result, i.e. all the elements that I expect to see.
-
I suspect the query you call has some #Branch# tag inside which will just look into the selected package.
q.
-
I am not entirely sure what you mean with '#Branch#'. But, the search is set to return elements for the selected package and NOT the entire model, because this is what I want. I just seem to have no control over what is 'the selected package' :-)
-
I just seem to have no control over what is 'the selected package' :-)
Have a look at Repository.ShowInProjectView(). That sets the selection in the project browser. Repository.GetTreeSelected*() retrieve the selection.
/Uffe
-
Thanks Uffe, I know :-)
Was just about to post the solution.
ShowInProjectView does indeed solve this problem.
br
Knut