Skip to content

Instantly share code, notes, and snippets.

@timolaine
timolaine / Map ArchiMate Subset.ajs
Last active May 21, 2026 08:46
Map the ArchiMate subset used in an #Archi model with #jArchi
/**
* Map ArchiMate Subset
* ---------------------
* Analyzes the current Archi model and creates a new model (opened directly in
* Archi's UI) containing a single "ArchiMate Subset" view showing:
*
* - One node per distinct element type (including specializations), labelled
* "TypeName (count)" or "TypeName [Specialization] (count)"
* - One connection per distinct (sourceType, relType, targetType) triple,
* labelled with the count of matching relationships
@timolaine
timolaine / Wrap Label.ajs
Created May 11, 2026 09:52
Adds (or updates) a word-wrap label expression on every selected element or relationship in Archi with #jArchi.
/**
* Wrap Label
*
* Adds (or updates) a word-wrap label expression on every selected element or relationship.
*
* Behaviour:
* - Asks for the desired character-wrap width (default: 20).
* - For each selected object, inspects any existing labelExpression:
* • No expression → wraps ${name}
* • Already wrapped → updates the wrap width only
@timolaine
timolaine / Distribute Elements.ajs
Created May 11, 2026 09:44
Distributes selected diagram elements with #jArchi in the active Archi view either horizontally or vertically with equal spacing between them.
/**
* Distribute Elements
*
* Distributes selected diagram elements in the active Archi view either
* horizontally or vertically with equal spacing between them.
*
* Usage: Select 2+ elements in a view, then run the script.
*/
(function () {
@timolaine
timolaine / Add consecutive ID to selection.ajs
Created November 5, 2025 12:56
Add consecutive ID to selection in #jArchi
/*
* Add consecutive ID to selection
* (c) 2025 Timo Laine www.timoroso.com
*/
console.log("Add consecutive ID to selection");
var propName = window.prompt("To which property do you want to add a consecutive ID for selected elements or relations? (leave empty to cancel)?", "");
if (propName) {
@timolaine
timolaine / Color relations by property value.ajs
Last active November 5, 2025 14:02
Colorize all relationships in a view based on property values in #jArchi
/*
* Color relations by property value
*
* Requires jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
*
* Original script (c) 2022 Steven Mileham
* Modifications to support relationship colorization (c) 2025 Timo Laine
*
*/
var debug = false;
@timolaine
timolaine / Mapify.ajs
Created March 11, 2025 11:39
Arranges selected elements alphabetically into a neat grid in #jArchi. The number of columns is user configurable.
/*
* Mapify
* Author: Timo Laine (timoroso.com)
* Arranges selected elements alphabetically into a neat grid.
* The number of columns is user configurable.
*/
// Get Archi's Preference Store
const archiPrefs = Java.type('com.archimatetool.editor.ArchiPlugin').PREFERENCES;
/*
* Information flows between applications
*
* This script is under construction!
*
* This script provides a list of information flows between application components.
* It is based strictly on the relationships found in the model and is therefore
* independent of views. In case more attributes for the flows are needed, they can be
* added easily (IntegrationPlatform is provided as an example).
*
@timolaine
timolaine / Insert Labels of Related Elements.ajs
Last active May 14, 2024 20:34
Insert Labels of Related Elements in Archi