Repository navigation
Scripting API
Archi Online exposes a jArchi-style
JavaScript API in the Scripting panel. Scripts run in the browser against
the currently open model, and one script run is batched into one undo
step — a misbehaving script is a single Ctrl+Z away from being undone.
The API follows common jArchi patterns:
- a global
$()selector returning collections, - a global
modelwrapper withcreateElement,createRelationship, andcreateArchimateView, - wrapper objects for concepts, views, visual objects, connections, and folders,
- key-value properties through
prop()/removeProp(), - relationship traversal helpers (
rels,inRels,outRels,sourceEnds, …).
- The script library lives in the panel's list: create, rename, and delete
scripts, and import/export them as
.ajsfiles (the jArchi script extension). - Two built-in examples ship with the app: a small starter script and a jArchi capability test.
- The Monaco editor provides IntelliSense for the whole API — the same type declarations documented on this page.
- Run with the Run button or
Ctrl+Enter. Output appears in the panel's console.

Scripts receive these globals:
| Global | Description |
|---|---|
$ |
Selector function; also exposes $.model. |
model |
The open model (a JModel wrapper). |
console |
log, info, warn, error write to the panel console; clear() empties it. |
window |
alert, confirm, and prompt only. |
exit() |
Stop the script immediately (not an error). |
Scripts are not sandboxed — they run as trusted local code in the page. The globals above are the supported API surface; anything else you reach is an implementation detail that may change.
Wherever a type is expected, ArchiMate type names are accepted in jArchi
kebab-case (business-actor, application-component,
serving-relationship), in CamelCase (BusinessActor), and — for
relationships — without the -relationship suffix (composition means
composition-relationship).
$() accepts a selector string (or an existing wrapper/collection) and
returns a JCollection:
| Selector | Matches |
|---|---|
"*" |
Everything: folders, elements, relationships, views. |
"concept" |
Elements and relationships. |
"element", "relationship", "view", "folder"
|
That kind of object. |
"business-actor" |
A specific type. |
".Customer" |
Objects whose name is exactly Customer. |
"#abc123" |
The object with that id. |
"business-actor.Customer" |
Type and exact name combined. |
Name matching is exact, not substring — use filter() with a function for
fuzzy matching.
JCollection methods:
var actors = $("business-actor");
// Inspection
actors.size(); // count (also actors.length)
actors.isEmpty();
actors.first(); // wrapper or undefined
actors.last();
actors.get(0);
actors.toArray();
// Iteration and transformation
actors.each(function (obj, index) { console.log(index, obj.name); });
actors.map(function (obj) { return obj.name; }); // plain array
// Filtering
actors.filter(".Customer"); // selector…
actors.filter(function (o) { return o.name.indexOf("Cust") >= 0; }); // …or predicate
actors.not(".Draft");
actors.is("business-actor"); // boolean
actors.add($("business-role")); // union with another collection
// Bulk operations
actors.prop("status", "reviewed"); // set on every member
actors.removeProp("legacy");
actors.attr("fillColor", "#ffe0e0"); // get/set any wrapper field
actors.delete();Traversal helpers (each accepts an optional selector to filter the result):
$("folder").children(); // direct children
$("folder").find(); // all descendants
$("business-actor").parent();
$("business-actor").parents();
$(".Application").rels(); // all relationships touching the element
$(".Application").inRels(); // incoming only
$(".Application").outRels(); // outgoing only
$("serving-relationship").ends(); // both endpoints
$("serving-relationship").sourceEnds(); // source concepts
$("serving-relationship").targetEnds(); // target concepts
$(".Customer").objectRefs(); // visual objects referencing the concept
$(".Customer").viewRefs(); // views containing the conceptmodel.name;
model.purpose;
model.prop(); // property keys
model.prop("key"); // get
model.prop("key", "value"); // set (add duplicate key with third arg: true)
model.removeProp("key"); // remove (or a specific value: removeProp(key, value))
model.createElement(type, name, folder);
model.createRelationship(type, name, source, target, folder);
model.createArchimateView(name, folder);folder arguments are optional; new objects land in the default folder for
their kind. createRelationship enforces the ArchiMate allowed-relationship
matrix and throws if the combination is invalid:
var actor = model.createElement("business-actor", "Customer");
var service = model.createElement("business-service", "Claims Service");
var rel = model.createRelationship("serving-relationship", "", service, actor);
var view = model.createArchimateView("Service Overview");
var serviceNode = view.add(service, 40, 120, 160, 60);
var actorNode = view.add(actor, 40, 20, 160, 60);
view.add(rel, serviceNode, actorNode);
view.openInUI();Every wrapper (JConcept, JView, JVisual, JConnection, JFolder) has:
obj.id; // read-only
obj.type; // read-only, e.g. "business-actor"
obj.name;
obj.documentation;
obj.prop();
obj.prop("key");
obj.prop("key", "value");
obj.removeProp("key");
obj.delete();Not every wrapper supports every setter — for example, connections derive their name from the underlying relationship and refuse renames.
JConcept wraps elements and relationships. Relationship-only members:
relationship.source; // JConcept
relationship.target; // JConcept
relationship.accessType; // "access" | "read" | "write" | "readwrite"
relationship.influenceStrength; // e.g. "++"
relationship.associationDirected; // booleanJView wraps an ArchiMate diagram:
view.name;
view.documentation;
view.viewpoint;
view.openInUI(); // open/focus the view tab
view.add(element, x, y, width, height); // returns JVisual
view.add(relationship, sourceVisual, targetVisual); // returns JConnection
view.createObject("note", x, y, width, height);
view.createObject("group", x, y, width, height);
view.nodes(); // top-level visual objects
view.nodes({ recursive: true }); // including nested children
view.connections();
view.bounds(); // union of node bounds, or null when empty
view.bounds({ recursive: false });JVisual wraps a diagram node — an element visual, note, group, or view
reference:
visual.concept; // underlying JConcept (undefined for notes/groups)
visual.view; // owning JView
visual.bounds; // parent-relative {x, y, width, height}
visual.text; // note text
visual.fillColor; // "#rrggbb" or undefined for the type default
visual.lineColor;
visual.fontColor;
visual.opacity; // 0–255
visual.add(element, x, y, width, height); // nest a child (relative coordinates)
visual.parent(); // JVisual or JView
visual.children();
visual.absoluteBounds(); // view-space coordinates
visual.connections();
visual.connections({ incoming: false }); // outgoing only
visual.connections({ outgoing: false }); // incoming onlyvisual.bounds is relative to the parent container; absoluteBounds()
returns view coordinates, which is usually what layout code wants.
JConnection wraps a diagram connection:
connection.view;
connection.source; // JVisual
connection.target; // JVisual
connection.concept; // underlying relationship
connection.lineColor;
connection.bendpoints; // raw Archi/GEF format
connection.absoluteRoute();
connection.setAbsoluteRoute(points);bendpoints uses Archi's relative offset representation
({ startX, startY, endX, endY }). For layout code, prefer the absolute
helpers:
connection.setAbsoluteRoute([
{ x: 180, y: 130 },
{ x: 220, y: 160 }
]);
console.log(connection.absoluteRoute());absoluteRoute() returns only the intermediate points — the source and
target anchors are not included.
view.layout() applies many node and route changes in a single operation:
var view = $("view").first();
var nodes = view.nodes({ recursive: true });
var updates = {};
nodes.forEach(function (node, index) {
updates[node.id] = { x: 80 + index * 180, y: 120, width: 140, height: 60 };
});
view.layout({ nodes: updates });Connection routes can be updated in the same call. A connection update takes
either route (absolute intermediate points; [] clears manual routing) or
raw bendpoints, not both:
var conn = view.connections()[0];
view.layout({
connections: {
[conn.id]: { route: [{ x: 260, y: 150 }] }
}
});Rules:
- node and connection ids must belong to the target view,
- coordinates and dimensions must be finite numbers,
- omitted
width/heightkeep their current values, - minimum node dimensions follow the app settings,
- layout coordinates are absolute view coordinates; stored nested bounds remain parent-relative.
For automatic layout, the bundled ELK Layout example extension wraps the
app-hosted ELK engine — see Extension API (app.layout.elk)
and Extension Packages.
var unnamed = $("element").filter(function (item) {
return !item.name || !item.name.trim();
});
console.log("Elements:", $("element").size());
console.log("Relationships:", $("relationship").size());
console.log("Views:", $("view").size());
console.log("Unnamed elements:", unnamed.size());var capability = model.createElement("capability", "Online Service");
var app = model.createElement("application-component", "Claims Portal");
var view = model.createArchimateView("Nested Example");
var group = view.createObject("group", 40, 40, 360, 180);
group.name = "Digital Channel";
var capVisual = group.add(capability, 20, 30, 140, 55);
var appVisual = group.add(app, 190, 30, 140, 55);
console.log(capVisual.bounds.x); // relative to the group
console.log(capVisual.absoluteBounds().x); // view coordinates
view.openInUI();$("element").each(function (el) {
if (el.prop("status") === "deprecated") {
$(el).objectRefs().attr("fillColor", "#f4cccc");
}
});The core jArchi idioms — selectors, collections, model.create*, view
add/createObject, properties, traversal — work as in desktop jArchi, so
many published jArchi scripts run unchanged. APIs tied to the desktop
platform (file system access, Java interop, UI toolkits, load() of external
scripts) do not exist here. When in doubt, the Monaco IntelliSense shows
exactly what is available.
Related pages:
-
Extension API — the
appAPI for extending the UI. - User Guide — the Scripting panel in context.
Archi Online · MIT License · ArchiMate® is a registered trademark of The Open Group. This project is not affiliated with The Open Group or the Archi project.
Using Archi Online
Automation
Project