Skip to content

Instantly share code, notes, and snippets.

@jbsarrodie
jbsarrodie / Delete unused elements and relationships.ajs
Created March 2, 2020 15:33
#jArchi scripts to delete any element (or relationship) not used in at least one view
// Delete unused elements and relationships
//
// Requires jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
//
// This script will delete any element or relationship not used in at least one view
//
// (c) 2020 Jean-Baptiste Sarrodie
var response = window.confirm("This script will delete any element or relationship not used in at least one view. Continue?");
/*
Script: Reverse Access
A jArchi script for use on an Archi repository
Purpose: Reverse all selected access relationships Access Type direction (e.g. read -> write / write -> read)
Useful as the default access type for an access relationship is 'write'. This allows several to be reversed.
Author: Richard Heward - Tame Blue Lion
Date: 28-Feb-2019
@jfdeclercq
jfdeclercq / ExportImage.ajs
Last active September 20, 2024 04:11
Export View as image (PNG) with date and diagram name in filename. #jarchi
//Export View as image (PNG) with date and diagram name in filename.
// Get the first view in the model
//var view = $("view").first();
var view = selection.filter("archimate-diagram-model").first();
// Get the Base64 bytes of the view in PNG format. Can use "PNG", "BMP", "JPG" or "GIF"
// Options are scale (1 - 4) and margin (pixel value)
var bytes = $.model.renderViewAsBase64(view, "JPG", {scale: 1, margin: 20});
var date = new Date();
Public Sub SendToJoplin()
Dim sToken As String, sURL As String
Dim sURLNotes, sURLResources, sEscapedBody, sJSONString, sFolderID As String
Dim objItem As Outlook.MailItem
sToken = "REPLACE ME WITH YOUR TOKEN"
sURL = "http://127.0.0.1:41184"
sURLNotes = sURL & "/notes?token=" & sToken
sURLResources = sURL & "/resources?token=" & sToken
@jbsarrodie
jbsarrodie / ConvertConcept.lib.js
Last active August 21, 2024 06:22
#jArchi script to change concepts' type (and optionally convert no more valid relationships to association)
function convert(selection, convertToType) {
var relaxed = window.confirm('By default, selected concepts are converted, and relationships involving them that would no more be valid are converted to associations. Click Ok for this behavior or Cancel if you want a "strict" mode where relationships are not changed.');
$(selection).each(function(o) {
$(concept(o)).outRels().each(function(r) {
if (! $.model.isAllowedRelationship(r.type, convertToType, r.target.type)) {
checkAndConvertRelationship(r, relaxed);
}
});
$(concept(o)).inRels().each(function(r) {
@adgerrits
adgerrits / MergeTwoElements.ajs
Last active February 26, 2025 22:13
#jArchi script to merge two elements
/*
* Select 2 elements of the same type and merge the second one into the first one.
* Optional: delete the second one when it's not in use anymore.
* 2019, Ad Gerrits
*/
function q(text) {
return '"' + text + '"';
}
@robkamp
robkamp / AlignSpreadHorizontally.ajs
Last active December 28, 2023 20:12
#jArchi AlignHorizontally
// Author: Rob Kamp
// Requires: jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
// Purpose: Align to lowest, spread the selected elements horizontally, and resize to be equal size
// Date: 2019-11-20
// Version 1.0
// Change: Initial version
console.log("Start: Spread and Align horizontally");
minY = null;
@robkamp
robkamp / ColorElements.ajs
Last active May 14, 2024 20:35
#jArchi Color the selected elements with web safe colors
// Author: Rob Kamp
// Requires: jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
// Purpose: Color the selected elements with web safe colors
// Date: 2019-11-20
// Version 1.1
// Change: changed the title to add the #jArchi tag
console.log("Start: Color the selected elemets");
// Web safe colors
@xmayeur
xmayeur / RelSshape.ajs
Last active November 24, 2019 09:25
#jarchi - this script transforms a visual relationship into an orthogonal S-shape one
/*
* Author X. MAYEUR
*
* Requires jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
*
* This script takes a selection of visual objects as input, filter it to keep only relationships
* and create S-shape ortho connector
*/
// console.show()
@xmayeur
xmayeur / RelUshape.ajs
Last active November 24, 2019 09:25
#jarchi - this script transforms a visual relationship as a orthogonal U-shape one
/*
* Author X. Mayeur
*
* Requires jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
*
* This script takes a selection of visual objects as input, filter it to keep only relationships
* and create U-shape ortho connector
*/
// console.show()