Archi Forum

Archi Plug-ins => jArchi => Topic started by: wnad on February 24, 2022, 11:56:42 AM

Title: jArchi Script not working
Post by: wnad on February 24, 2022, 11:56:42 AM
after updating my version

one of  script doesn't work anymore

console.show();
console.clear();
 
var el_selection = selection.filter("element");
 
if(el_selection.size() < 2) {
  window.alert("You have to select at least two elements to run this script. Note: merging relationships is not supported for the moment.");
  exit();
}
 
var list = "Which element do you want to keep (enter its index)?";
var index = 1;
 
el_selection.each(function(o) {
  list += "\n  ("+index+") "+o.name;
  index++
})
var answer = window.prompt(list, "1");
if(answer) {
  var relaxed = window.confirm('By default, only documentation and properties of the target element are saved (those of merged elements are cleared). Click Ok for this behavior or Cancel if you want a "strict" mode where they are copied into target element.');
 
  var merge_target = el_selection.get(answer-1);
  var to_be_deleted = $("#null");
  el_selection.not($(merge_target)).each(function(o) {
    console.log('Merging "', o.name, '" into "', merge_target.name, '"');
    // We don't want to delete while iterating on the collection, so create
    // another collection containing the element (not object) to delete
    to_be_deleted.add(concept(o));
    if (relaxed) {
      removeDocAndProps(concept(o));
    }
    concept(merge_target).merge(concept(o));
  });
 
  // Deletion loop
  to_be_deleted.each(function(e) {
    e.delete();
  });
} else {
  console.log("Merge cancelled");
}
function concept(o) {
  if(o.concept)
    return o.concept;
  else
    return o;
}
 
function removeDocAndProps(c) {
  c.documentation = "";
  c.prop().forEach(function(p) {
    c.removeProp(p);
  });
}

what is the problem
thanks
Title: Re: archi 4.9
Post by: Jean-Baptiste Sarrodie on February 24, 2022, 12:38:51 PM
Hi,

Can you try to norrow it down a little bit? Can you share the error message you have on the script console and/or on the Archi error log?

Which versions (old and new) of both Archi and jArchi do/did you use?

There should not be any differences, as there have been no breaking changes in the jArchi API for a while.

Regards,

JB
Title: Re: jArchi Script not working
Post by: Phil Beauvoir on February 24, 2022, 13:11:40 PM
(Topic moved to jArchi forum and title changed from "archi 4.9" to something more descriptive)

Please make sure you are using Archi 4.9.2 and jArchi 1.2.
Title: Re: jArchi Script not working
Post by: wnad on February 28, 2022, 10:53:41 AM
I use archi 4.9.2 but I don't find how to see my jarchi version
Title: Re: jArchi Script not working
Post by: Phil Beauvoir on February 28, 2022, 11:27:56 AM
Quote from: wnad on February 28, 2022, 10:53:41 AMI use archi 4.9.2 but I don't find how to see my jarchi version

Go to Help -> Manage Plug-ins... menu item.
Title: Re: jArchi Script not working
Post by: wnad on February 28, 2022, 16:02:20 PM
it's ok this jarchi 1.2
thanks