Skip to content

Instantly share code, notes, and snippets.

@tkazimie
Created July 18, 2020 19:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkazimie/5a500d3e156c7fd36166ca2fe95a2047 to your computer and use it in GitHub Desktop.
Save tkazimie/5a500d3e156c7fd36166ca2fe95a2047 to your computer and use it in GitHub Desktop.
Set the name prefix + colon for selected elements
/*
* Set the name prefix for selected elements
*
* Requires jArchi - https://www.archimatetool.com
*
* This script adds given text + collon before the object name.
* If prefix with collon already existed it is replace by new one.
* In case of wrong selection effect can be reversed with crt-z (command-z on Mac)
*
* Script will prompt you: for the text
*
*
* Version 1: Set the name prefix for selected elements
*
* 2020 by tkazimie@me.com
*
*/
var debug = false;
console.clear();
console.log("New NameReplace Script");
var txt = window.prompt("Please enter new prefix", "DB");
debug? console.log("entered:"+txt):true;
$(selection).each(function(theConcept) {
debug? console.log("Elem name:"+theConcept.name+" type:"+theConcept.type):true;
if (theConcept.type != "archimate-diagram-model") {
var nm = theConcept.name;
if (nm.search(":") != -1) {
nm = nm.split(":")[1];
}
debug? console.log("Name to replace:"+nm):true;
theConcept.name = txt + ":" + nm;
debug? console.log("Name replaced:"+theConcept.name):true;
}
});
console.log("End nameReplace Script");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment