I wanna create relationships of selected item - if there is a same named item by another type:
$(selection).filter("resource").each(function(obj){
name = "." + obj.name;
console.log(obj, name);
$(name).filter("course-of-action").each(function(obj2)
{
console.log("-", obj, obj2);
model.createRelationship("triggering-relationship", "triggers", obj, obj2);
});
});
I got this message:
Script Error: java.lang.ClassCastException: Cannot cast com.archimatetool.script.dom.model.DiagramModelObjectProxy to com.archimatetool.script.dom.model.ArchimateConceptProxy
I have no glue.
Hi,
I suspect you launched this script after having selected items in a view and not the model tree. This means that you're trying to create a relationship involving a view object (obj) and not the concept itself (obj.concept (https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#concept)). so simply replace obj by obj.concept.
Another remark: $(name).filter("course-of-action") can be replaced by $("course-of-action"+name).
Regards,
JB