Book a Demo

Author Topic: From which folder does GetElementsByQuery start the search  (Read 7493 times)

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
From which folder does GetElementsByQuery start the search
« 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

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Re: From which folder does GetElementsByQuery start the search
« Reply #1 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

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1000
  • Karma: +58/-18
    • View Profile
Re: From which folder does GetElementsByQuery start the search
« Reply #2 on: November 15, 2016, 07:53:01 pm »
What gives your query back when you use it in „Search“ rather than in GetElementsByQuery?
Best regards,

Peter Heintz

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Re: From which folder does GetElementsByQuery start the search
« Reply #3 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.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: From which folder does GetElementsByQuery start the search
« Reply #4 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.

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Re: From which folder does GetElementsByQuery start the search
« Reply #5 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' :-)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: From which folder does GetElementsByQuery start the search
« Reply #6 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
My theories are always correct, just apply them to the right reality.

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Re: From which folder does GetElementsByQuery start the search
« Reply #7 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