Skip to content
Phil Beauvoir edited this page Jul 20, 2018 · 11 revisions

The following functions work on the $.model global variable.

Table of contents


.create()

Create a new model:

var newModel = $.model.create("Test Model");
newModel.setAsCurrent(); // Set it to be the current model ("model")

.load()

Load a model from file:

var myModel = $.model.load("/path/test.archimate");
myModel.setAsCurrent(); // Set it to be the current model ("model")
model.openInUI(); // Open it in the UI (Models Tree)

.renderViewAsBase64()

Get the image data encoded as Base64 from a View.

.renderViewAsBase64(view, format, options...)
  • view - reference to a view
  • format - one of "PNG", "BMP", "JPG" or "GIF"
  • options
    • scale = integer value of 1 to 4
    • margin = integer value of pixels
var view = ...; // A view reference
var bytes = $.model.renderViewAsBase64(view, "PNG"); // Get bytes
// Embed in a HTML string
var html += "<html><body><p>" + view.name + "</p>" + "<img src=\"data:image/png;base64," + bytes + "\"></body></html>";
var view = ...; // A view reference
var bytes = $.model.renderViewAsBase64(view, "PNG"); // Get bytes
// Write to file
$.fs.writeFile("path/view.png", bytes, "BASE64");