Skip to content
Phil Beauvoir edited this page May 6, 2025 · 5 revisions

Note

Methods described in this section are are available only on Views - ArchiMate, Sketch and Canvas Views.

Contents

.add(element)
.add(relationship)
.add(object)
.createConnection()
.createObject()
.createViewReference()
.duplicate()
.isAllowedConceptForViewpoint()
.openInUI()
.viewpoint


.add(element)

Create and return a new diagram object referencing an ArchiMate element with given bounds.

This method only applies to ArchiMate Views.

element is an existing ArchiMate element.

autoNest optional boolean parameter. If true the diagram object will be nested inside of any existing diagram object whose bounds surrounds the new object's bounds.

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

add(element, x, y, width, height)
add(element, x, y, width, height, autoNest)

Example:

var object= archimateView.add(businessActor, 10, 200, 150, 75);
var object= archimateView.add(businessRole, 10, 200, -1, -1, true);

.add(relationship)

Create and return a new visual object referencing an ArchiMate relationship.

relationship is an existing ArchiMate relationship.

add(relationship, sourceDiagramComponent, targetDiagramComponent)

Example:

var object1 = archimateView.add(actor, 10, 10, 150, 70);
var object2 = archimateView.add(role, 200, 10, 150, 70);
var connection = archimateView.add(relationship, object1, object2);

.add(object)

Since 1.10

Add an existing visual object to this View at position x, y. This is effectively a "move" command.

object is an existing visual object in the same View as the target but is a child of a visual object. For example, a visual object inside of a Group object.

add(object, x, y) 

Example:

// Find a View in the current model
var view = $("view").filter(".Default View").first();
// Get the object to move. This is a child in another object.
var object = $(view).find(".Object Name").first();
// Move it to the View at x,y position
view.add(object, 10, 30);

.createConnection()

Create and return a new non-ArchiMate connection between two objects in a View.

createConnection(source, target);

source - the source object

target - the target object

Connections can not be created between two ArchiMate objects.

Example:

var selectedView = $('view').get(0); // Get first view in the model
var note = selectedView.createObject("diagram-model-note", 10, 200, -1, -1); // Add a note
var group = selectedView.createObject("diagram-model-group", 10, 300, -1, -1); // Add a group
var connection = selectedView.createConnection(note, group); // Create and add a connection
connection.name = "My Connection"; // Give it a name

.createObject()

Create and return a new visual object of type with given bounds.

type can be one of diagram-model-note (or note) or diagram-model-group (or group)

autoNest optional boolean parameter. If true the diagram object will be nested inside of any existing diagram object whose bounds surrounds the new object's bounds.

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

createObject(type, x, y, width, height)
createObject(type, x, y, width, height, autoNest) 

Example:

var note = archimateView.createObject("diagram-model-note", 10, 200, 200, 100, true);
note.setText("This is a note.\n\nHello World!");

var group = archimateView.createObject("diagram-model-group", 10, 200, -1, -1);

.createViewReference()

Create and return a new View reference object with given bounds.

view is an existing View (diagram model)

autoNest optional boolean parameter. If true the diagram object will be nested inside of any existing diagram object whose bounds surrounds the new object's bounds.

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

createViewReference(view, x, y, width, height)
createViewReference(view, x, y, width, height, autoNest)

Example:

var view1 = $('view').get(0); // Get first view in the model
var view2 = $('view').get(1); // Get next view in the model
var viewRef = view1.createViewReference(view2, 10, 10, 200, 55); // Create and add a view reference

.duplicate()

Since 1.8

Duplicate (copy) a View and place the duplicate in the same or a target folder.

// Duplicate View into the same folder
view.duplicate();
// Duplicate View into the target folder
view.duplicate(folder);

Note that the target folder must be in the main "Views" folder and in the same model.

Example:

// Create a new folder called "Copied" in the "Views" folder
var viewsFolder = $("folder.Views").first();
var newFolder = viewsFolder.createFolder("Copied");
// Duplicate a given View into the new folder
view.duplicate(newFolder);

.isAllowedConceptForViewpoint()

archimateView.isAllowedConceptForViewpoint(conceptName)

Return true if the given concept is allowed in the current Viewpoint of an ArchiMate View.

Example:

var isallowed = archimateView.isAllowedConceptForViewpoint("business-actor"));

.openInUI()

Open the given View in the UI. If the View's model is not currently open in the UI, it is opened before the View is opened.

theView.openInUI();

.viewpoint

Get/set the Viewpoint of an ArchiMate View.

Allowed viewpoint identifier strings that can be set:

application_cooperation
application_usage
business_process_cooperation
capability
goal_realization
implementation_deployment
implementation_migration
information_structure
layered
migration
motivation
organization
outcome_realization
physical
product
project
requirements_realization
resource
service_realization
stakeholder
strategy
technology
technology_usage

Setting the viewpoint identifier to the empty string "" sets it to no viewpoint.

The returned viewpoint JS object consists of the viewpoint ID and the human readable name.

Example:

archimateView.viewpoint = "implementation_deployment";
var vp = archimateView.viewpoint;
var id = vp.id;
var name = vp.name;
Clone this wiki locally