current view ?

Started by rchevallier, January 05, 2021, 09:17:21 AM

Previous topic - Next topic

rchevallier

model variable allow to obtain the current model
is there an equivalent for the current view?

I know you can obtain it from a selected visual object thru the .view attribute. But is there is no object in the view or no object selected, is there a way ?

Thanks

Jean-Baptiste Sarrodie

Hi,

You can always access the collection of selected objects through "selection" variable. So if you run a script while the view itself is selected, "selection.first()" points to the view.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rchevallier

Thanks

The only issue is if you select something in the concept tree ("Models" tab), I don't see how you can obtain then the current opened view (if there is any). You can list the  views of a model, but I don't see how to obtain the one opened and in particular the current one (if any)

Jean-Baptiste Sarrodie

Hi,

Quote from: rchevallier on January 05, 2021, 16:05:50 PM
The only issue is if you select something in the concept tree ("Models" tab), I don't see how you can obtain then the current opened view (if there is any). You can list the  views of a model, but I don't see how to obtain the one opened and in particular the current one (if any)

There is no notion of "current view" in jArchi, only one of "current selection". In fact, there is no "current view" in Archi at all either as you could well change your window layout to have several views visible at the same time. So you have to assume that your script will be run with the current view opened and selected in the editor, or selected in the model tree. That's why I usually add some code to check this in my scripts.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rchevallier

Thanks for the precision. At least I can detect if there is no current active view selected directly or indirectly thru the selected visual object. That shall be enough

René

I wanna do $something with everything in the current view:

x = $(selection).first();
if(x.type == "archimate-diagram-model")
{
$(x).find("element").each(function(e){
console.log(e, e.fillColor);
})
}
else
{
console.log(x);
$(x).viewRefs().each(function(a){
console.log(a);
});
}


If nothing is selected, the view itself is selected. Everythings fine.

But: If I select one element inside this view, how do I reach the view itself? I tried viewRefs and refView. Any glue?

Phil Beauvoir

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.