Is there a way by script to find if the object is used or not in the model?

Started by PARISAM, March 08, 2023, 13:00:33 PM

Previous topic - Next topic

PARISAM

Hi,

Is there a way by script to find if the object or link is used or not in the model?

I checked in the documentation but I can't find anything.

This will allow to clean up the model by script.

Thank in advance.

Phil Beauvoir

Hi, for elements and relations you'll need to use viewRefs:

https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Collection#viewrefs

For example:

selected = selection.first();
selectedConcept = selected.concept;
console.log(isUsedInView(selectedConcept));

function isUsedInView(concept) {
    return !$(concept).viewRefs().isEmpty();
}
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.