how to recognize in jArchi if a selected object is an element? a relationship?
Thx
Hi,
The straightforward answer is, check its type and see if it contains the string "relationship".
But another option is to filter the selection (which is a collection of only one object in this case) with either 'element' or 'relationship' and see if its lenght is zero or not:
if(selection.filter('element').size()) {
console.log('Selection contains at least one element')
}
if(selection.filter('relationship').size()) {
console.log('Selection contains at least one relationship')
}
Regards,
JB
Thanks, so no magic :'(
Then how to distinguish a visual Object (selection in a view) from a Concept (selection in the model tree) ?
Hi,
Quote from: rchevallier on February 04, 2023, 16:18:42 PMThen how to distinguish a visual Object (selection in a view) from a Concept (selection in the model tree) ?
if (selection.first().concept == selection.first()) {
console.log('This is a concept')
} else {
console.log('This is a visual object')
}
Regards,
JB
Thanks
Also this will tell you the class of the object:
selection.first().class