Archi Forum

Archi Plug-ins => jArchi => Topic started by: Bain19 on November 14, 2019, 04:08:40 AM

Title: Can Jarchi filter based on currently active view ?
Post by: Bain19 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   

Title: Re: Can Jarchi filter based on currently active view ?
Post by: Phil Beauvoir 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
Title: Re: Can Jarchi filter based on currently active view ?
Post by: rchevallier 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
Title: Re: Can Jarchi filter based on currently active view ?
Post by: Phil Beauvoir on March 25, 2020, 12:53:58 PM
https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#view
Title: Re: Can Jarchi filter based on currently active view ?
Post by: rchevallier on March 25, 2020, 13:17:27 PM
Indeed, missed it. Thanks