Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Knut Paulsen on November 15, 2016, 07:19:08 pm

Title: From which folder does GetElementsByQuery start the search
Post 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
Title: Re: From which folder does GetElementsByQuery start the search
Post by: Knut Paulsen on November 15, 2016, 07:30:45 pm
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
Title: Re: From which folder does GetElementsByQuery start the search
Post by: PeterHeintz on November 15, 2016, 07:53:01 pm
What gives your query back when you use it in „Search“ rather than in GetElementsByQuery?
Title: Re: From which folder does GetElementsByQuery start the search
Post by: Knut Paulsen on November 15, 2016, 08:05:57 pm
When I run it inside EA it gives the expected result, i.e. all the elements that I expect to see.
Title: Re: From which folder does GetElementsByQuery start the search
Post by: qwerty on November 15, 2016, 09:28:00 pm
I suspect the query you call has some #Branch# tag inside which will just look into the selected package.

q.
Title: Re: From which folder does GetElementsByQuery start the search
Post by: Knut Paulsen on November 15, 2016, 09:48:12 pm
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' :-)
Title: Re: From which folder does GetElementsByQuery start the search
Post by: Uffe on November 15, 2016, 11:48:07 pm
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
Title: Re: From which folder does GetElementsByQuery start the search
Post by: Knut Paulsen on November 15, 2016, 11:50:27 pm
Thanks Uffe, I know :-)
Was just about to post the solution.
ShowInProjectView does indeed solve this problem.

br
Knut