Skip to content

Instantly share code, notes, and snippets.

@eduardobbs
Last active October 25, 2020 09:52
Show Gist options
  • Select an option

  • Save eduardobbs/e39b00f45d12f43a55c31823facf0926 to your computer and use it in GitHub Desktop.

Select an option

Save eduardobbs/e39b00f45d12f43a55c31823facf0926 to your computer and use it in GitHub Desktop.
#jArchi
// Copy the selected elements to another model
//
// https://gist.github.com/eduardobbs/e39b00f45d12f43a55c31823facf0926
// Requires jArchi - https://www.archimatetool.com/plugins/
//
// (c) 2020 Eduardo Cuccolotto Sequinel
var msg = "Which model is the destination one (enter its index)?";
var modelList = $.model.getLoadedModels();
for (i = 0; i < modelList.length; i++) {
msg += "\n (" + i + ") " + modelList[i];
}
var answer = window.prompt(msg, "");
if (!answer) {
console.log("Copy canceled");
} else {
console.log("*************************\ncopying elements to another model");
model = modelList[answer];
model.setAsCurrent();
$(selection).each(function (e) {
newElement = model.createElement(e.type, e.name);
newElement.documentation = e.documentation;
var props = e.prop();
for (i = 0; i < props.length; i++) {
newElement.prop(props[i], e.prop(props[i]));
}
});
console.log($(selection).length + " items copied to " + model);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment