Author Topic: Can Jarchi filter based on currently active view ?  (Read 404 times)

Bain19

  • Newbie
  • *
  • Posts: 8
Can Jarchi filter based on currently active view ?
« on: November 14, 2019, 04:08:40 AM »
Was reading through the documentation and didnt see this really mentioned.

Can jarchi create a collection of elements based on currently active view ?

I can filter based on $(selection) , but didnt see anything for activeview.

For what its worth, is $(selection) documented in the jarchi API ... I looked but couldnt find anything.

{edit}

thinking something like $("view").this   

« Last Edit: November 14, 2019, 04:15:27 AM by Bain19 »

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1619
  • Code Punk
    • Archi
Re: Can Jarchi filter based on currently active view ?
« Reply #1 on: November 14, 2019, 08:49:39 AM »
Yes, the current selection will contain the current View. So:

$(selection).first();

https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Quick-Start#the-current-selection
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

rchevallier

  • Active Member
  • ***
  • Posts: 76
Re: Can Jarchi filter based on currently active view ?
« Reply #2 on: March 25, 2020, 12:50:58 PM »
(reopening on the same subject)

Context: My goal is to develop a script for impact analysis. Ideally I'd like to select 1 element in a view, and then the script will add the elements in the same view according to the model defined (relation & co) down to a level depth.

Testing with $(selection):

* if I select the current view tab and nothing else inside: the selection contains only the archimate-diagram-model as expected
* if I select one element in the model tree: the selection contains only the selected element as expected
* if I select one element inside the current view: the selection contains only the selected element. selection.first() returns this element

How do get a reference to the current view containing it? My understanding would be to use
selection.parents.filter("archimate-diagram-model"), and if it is not empty, it will be the current view.
using .parents() and not .parent() to go thru any container in the graph in case of the element being incorporated visually (eg: Grouping)

Is that right? Any caveat? Other (simpler) way to do it ? Thanks in advance

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1619
  • Code Punk
    • Archi
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

rchevallier

  • Active Member
  • ***
  • Posts: 76
Re: Can Jarchi filter based on currently active view ?
« Reply #4 on: March 25, 2020, 13:17:27 PM »
Indeed, missed it. Thanks