return $(selection).find("element").filter(e => {
View.add(e.concept, 100, 100, 140, 60);
return $("element").filter(e => {
console.show();
console.clear();
console.log("Start \r");
debug = true;
var propertyDict = {
"source": "Legacy",
"state": "Enabled",
"taxonomyL0": "Common"
};
function findMatchingElements(properties, matchAll) {
try {
return $(selection).find("element").filter(e => {
debug ? console.log("Checking element: " + e.name + "\r") : true;
var matches = matchAll ? true : false;
for (var key in properties) {
var elementProp = e.prop(key) ? e.prop(key).trim().toLowerCase() : "";
var filterProp = properties[key] ? properties[key].trim().toLowerCase() : "";
debug ? console.log("Property: " + key + ", Element: " + elementProp + ", Filter: " + filterProp + "\r") : true;
if (matchAll) {
if (elementProp !== filterProp) {
matches = false;
break;
}
} else {
if (elementProp === filterProp) {
matches = true;
break;
}
}
}
return matches;
});
} catch (error) {
console.error("Error finding matching elements: " + error);
return [];
}
}
function addElementsToView(elements, viewName) {
try {
var View = $("view").filter(v => v.name === viewName).first();
if (!View) {
debug ? console.log("Creating a new view called: " + viewName + "\r") : true;
View = model.createArchimateView(viewName);
} else {
debug ? console.log("Selecting the existing view: " + viewName + "\r") : true;
}
elements.each(e => {
debug ? console.log("Adding element: " + e.name + " to the view: " + viewName + "\r") : true;
View.add(e, 100, 100, 140, 60); // x, y, width, height
});
// view.openInUI();
debug ? console.log("Elements added to view: " + viewName) : true;
} catch (error) {
console.error("Error adding elements to view: " + error);
}
}
function main() {
try {
if (!model) {
throw new Error("No model selected. Please select a model before running the script.");
}
var matchAllProperties = true; // Set to false to match any property
var matchingElements = findMatchingElements(propertyDict, matchAllProperties);
debug ? console.log("Matching elements: " + matchingElements.length + "\r") : true;
addElementsToView(matchingElements, propertyDict.source);
} catch (error) {
console.error("Error in main function: " + error);
}
}
main();
console.log("done \r");
QuoteError adding elements to view: TypeError: invokeMember (add) on com.archimatetool.script.dom.model.ArchimateDiagramModelProxy failed due to: no applicable overload found (overloads: [Method[public com.archimatetool.script.dom.model.DiagramModelConnectionProxy com.archimatetool.script.dom.model.ArchimateDiagramModelProxy.add(com.archimatetool.script.dom.model.ArchimateRelationshipProxy,com.archimatetool.script.dom.model.DiagramModelComponentProxy,com.archimatetool.script.dom.model.DiagramModelComponentProxy)], Method[public com.archimatetool.script.dom.model.DiagramModelObjectProxy com.archimatetool.script.dom.model.ArchimateDiagramModelProxy.add(com.archimatetool.script.dom.model.ArchimateElementProxy,int,int,int,int,boolean)], Method[public com.archimatetool.script.dom.model.DiagramModelObjectProxy com.archimatetool.script.dom.model.ArchimateDiagramModelProxy.add(com.archimatetool.script.dom.model.ArchimateElementProxy,int,int,int,int)]], arguments: [JavaObject[application-service: AzureSQLAnalytics(DefaultWorkspace-ef74c932-a6bc-4e9e-aca8-d91d2710dce1-NCUS) (com.archimatetool.script.dom.model.DiagramModelObjectProxy)] (HostObject), 100 (Integer), 100 (Integer), 140 (Integer), 60 (Integer)])
Quote from: Mate on May 16, 2024, 22:38:54 PMUnder properties.appearance there is a checkbox option called "Show Label" that does what I want, so was wondering if that can be done programmatically.
connection.labelVisible = false;